Skip to content

Commit 0995aab

Browse files
committed
Update low-power code as per #78
1 parent 8c9499b commit 0995aab

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

Firmware/OpenLog_Artemis/OpenLog_Artemis.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
(done) Add support for the SDP3X Differential Pressure sensor
8888
(done) Add support for the MS5837 - as used in the BlueRobotics BAR02 and BAR30 water pressure sensors
8989
(done) Correct an issue which was causing the OLA to crash when waking from sleep and outputting serial data https://github.com/sparkfun/OpenLog_Artemis/issues/79
90+
(done) Correct low-power code as per https://github.com/sparkfun/OpenLog_Artemis/issues/78
9091
*/
9192

9293
const int FIRMWARE_VERSION_MAJOR = 1;

Firmware/OpenLog_Artemis/lowerPower.ino

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,9 @@ void powerDown()
137137
qwiicPowerOff();
138138
#endif
139139

140-
//Power down Flash, SRAM, cache
141-
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_CACHE); //Turn off CACHE
142-
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_FLASH_512K); //Turn off everything but lower 512k
143-
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_SRAM_64K_DTCM); //Turn off everything but lower 64k
144-
//am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_ALL); //Turn off all memory (doesn't recover)
140+
//Power down cache, flash, SRAM
141+
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_ALL); // Power down all flash and cache
142+
am_hal_pwrctrl_memory_deepsleep_retain(AM_HAL_PWRCTRL_MEM_SRAM_384K); // Retain all SRAM
145143

146144
//Keep the 32kHz clock running for RTC
147145
am_hal_stimer_config(AM_HAL_STIMER_CFG_CLEAR | AM_HAL_STIMER_CFG_FREEZE);
@@ -320,11 +318,9 @@ void goToSleep(uint32_t sysTicksToSleep)
320318
//else
321319
// powerLEDOff();
322320

323-
//Power down Flash, SRAM, cache
324-
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_CACHE); //Turn off CACHE
325-
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_FLASH_512K); //Turn off everything but lower 512k
326-
//am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_SRAM_64K_DTCM); //Turn off everything but lower 64k (Leaving 64K powered up probably isn't enough - "Global variables use 70496 bytes of dynamic memory.")
327-
//am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_ALL); //Turn off all memory (doesn't recover)
321+
//Power down cache, flash, SRAM
322+
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_ALL); // Power down all flash and cache
323+
am_hal_pwrctrl_memory_deepsleep_retain(AM_HAL_PWRCTRL_MEM_SRAM_384K); // Retain all SRAM
328324

329325
//Use the lower power 32kHz clock. Use it to run CT6 as well.
330326
am_hal_stimer_config(AM_HAL_STIMER_CFG_CLEAR | AM_HAL_STIMER_CFG_FREEZE);
@@ -365,9 +361,6 @@ void goToSleep(uint32_t sysTicksToSleep)
365361
//Power everything up gracefully
366362
void wakeFromSleep()
367363
{
368-
//Power up SRAM, turn on entire Flash
369-
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_MAX);
370-
371364
//Go back to using the main clock
372365
//am_hal_stimer_int_enable(AM_HAL_STIMER_INT_OVERFLOW);
373366
//NVIC_EnableIRQ(STIMER_IRQn);

0 commit comments

Comments
 (0)