summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2018-04-21 16:16:18 -0700
committerKeith Packard <keithp@keithp.com>2018-04-26 19:33:48 -0700
commit0dfaecc25a12da57248541a66dd5118161616cce (patch)
tree9eec27d4fe24e1818dd657de37a67a5d3feab6b0 /src
parent8025b98420f16730e5e6e45114cbdbbf88f7a748 (diff)
altos/fox1ihu: Pull down radio control pin in flash loader
Ensures that the radio is powered down while in the flash loader. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
-rw-r--r--src/fox1ihu/flash-loader/ao_pins.h25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/fox1ihu/flash-loader/ao_pins.h b/src/fox1ihu/flash-loader/ao_pins.h
index 31201eb0..19f29b08 100644
--- a/src/fox1ihu/flash-loader/ao_pins.h
+++ b/src/fox1ihu/flash-loader/ao_pins.h
@@ -22,16 +22,27 @@
#define AO_HSE 8000000
#define AO_WATCHDOG_PORT (&stm_gpiod)
+#define AO_WATCHDOG_PORT_BIT (1 << STM_RCC_AHBENR_GPIODEN)
#define AO_WATCHDOG_BIT 3
-
-#define AO_FLASH_LOADER_INIT do { \
- ao_enable_output(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG, 0); \
+#define AO_WATCHDOG_VALUE 0
+
+#define AO_RADIO_CONTROL_PORT (&stm_gpioe)
+#define AO_RADIO_CONTROL_PORT_BIT (1 << STM_RCC_AHBENR_GPIOEEN)
+#define AO_RADIO_CONTROL_BIT 12
+#define AO_RADIO_CONTROL_VALUE 1
+
+#define AO_FLASH_LOADER_INIT do { \
+ stm_rcc.ahbenr |= AO_WATCHDOG_PORT_BIT | AO_RADIO_CONTROL_PORT_BIT; \
+ \
+ stm_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG_VALUE); \
+ stm_moder_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, STM_MODER_OUTPUT); \
+ \
+ stm_gpio_set(AO_RADIO_CONTROL_PORT, AO_RADIO_CONTROL_BIT, AO_RADIO_CONTROL_VALUE); \
+ stm_moder_set(AO_RADIO_CONTROL_PORT, AO_RADIO_CONTROL_BIT, STM_MODER_OUTPUT); \
} while (0)
-
+
#define AO_TIMER_HOOK do { \
- static uint8_t watchdog; \
- ao_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG_PIN, watchdog); \
- watchdog ^= 1; \
+ AO_WATCHDOG_PORT->odr ^= (1 << AO_WATCHDOG_BIT); \
} while (0)
#define HAS_TICK 1