summaryrefslogtreecommitdiff
path: root/src/micropeak-v2.0/ao_pins.h
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2019-07-16 11:10:36 -0700
committerKeith Packard <keithp@keithp.com>2019-07-16 11:10:36 -0700
commitc37cd66b7c11f904b528c5ff7e80e18c5e0d26e5 (patch)
treeae69d02e2371648be7944d9e599b3fef116295eb /src/micropeak-v2.0/ao_pins.h
parent40624256be70088d7608742b71e1241d95a7fcdf (diff)
altos/micropeak-v2.0: Reduce power usage
This gets power consumption down under 1mA on the pad. Not really low enough to sell, but I think this is about as low as the chip will go. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/micropeak-v2.0/ao_pins.h')
-rw-r--r--src/micropeak-v2.0/ao_pins.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/micropeak-v2.0/ao_pins.h b/src/micropeak-v2.0/ao_pins.h
index 9dba26bd..d3bd2281 100644
--- a/src/micropeak-v2.0/ao_pins.h
+++ b/src/micropeak-v2.0/ao_pins.h
@@ -43,8 +43,8 @@ extern uint8_t ao_on_battery;
#define AO_RCC_CFGR_HPRE_DIV (ao_on_battery ? STM_RCC_CFGR_HPRE_DIV_16 : STM_RCC_CFGR_HPRE_DIV_1)
/* APB = 12MHz usb / 2MHz battery */
-#define AO_APB_PRESCALER 1
-#define AO_RCC_CFGR_PPRE_DIV STM_RCC_CFGR_PPRE_DIV_1
+#define AO_APB_PRESCALER (ao_on_battery ? 2 : 1)
+#define AO_RCC_CFGR_PPRE_DIV (ao_on_battery ? STM_RCC_CFGR_PPRE_DIV_2 : STM_RCC_CFGR_PPRE_DIV_1)
#define HAS_USB 1
#define AO_PA11_PA12_RMP 1
@@ -86,6 +86,7 @@ extern uint8_t ao_on_battery;
/* SPI */
#define HAS_SPI_1 1
+#define SPI_1_POWER_MANAGE 1
#define SPI_1_PA5_PA6_PA7 1
#define SPI_1_PB3_PB4_PB5 0
#define SPI_1_OSPEEDR STM_OSPEEDR_MEDIUM
@@ -128,9 +129,11 @@ void ao_delay_until(uint16_t target);
#define ao_async_stop() do { \
ao_serial2_drain(); \
stm_moder_set(&stm_gpioa, 2, STM_MODER_OUTPUT); \
+ ao_serial_shutdown(); \
} while (0)
#define ao_async_start() do { \
+ ao_serial_init(); \
stm_moder_set(&stm_gpioa, 2, STM_MODER_ALTERNATE); \
ao_delay(AO_MS_TO_TICKS(100)); \
} while (0)