diff --git a/ion/src/device/n0200/drivers/power.cpp b/ion/src/device/n0200/drivers/power.cpp index 3e15d82aa..1e4f339e0 100644 --- a/ion/src/device/n0200/drivers/power.cpp +++ b/ion/src/device/n0200/drivers/power.cpp @@ -1,17 +1,28 @@ #include #include +#include #include namespace Ion { namespace Power { -void __attribute__((noinline)) standby() { - Device::Power::waitUntilOnOffKeyReleased(); - Device::Power::standbyConfiguration(); - Device::Board::shutdown(); +/* We isolate the standby code that needs to be executed from the internal + * flash (because the external flash is then shut down). We forbid inlining to + * avoid inlining these instructions in the external flash. */ + +void __attribute__((noinline)) internal_flash_standby() { + Device::ExternalFlash::shutdown(); + Device::Board::shutdownClocks(); Device::Power::enterLowPowerMode(); Device::Reset::core(); } +void standby() { + Device::Power::waitUntilOnOffKeyReleased(); + Device::Power::standbyConfiguration(); + Device::Board::shutdownPeripherals(); + internal_flash_standby(); +} + } } diff --git a/ion/src/device/n0200/flash.ld b/ion/src/device/n0200/flash.ld index 64769cea1..9b88f6232 100644 --- a/ion/src/device/n0200/flash.ld +++ b/ion/src/device/n0200/flash.ld @@ -61,6 +61,7 @@ SECTIONS { * done with -fdata-sections -ffunction-sections */ .text.internal : { . = ALIGN(4); + *(.text.start) *(.text.abort) *(.text.isr_systick) *(.text.__assert) @@ -73,8 +74,7 @@ SECTIONS { *(.text.strcmp) *(.text.memmove) */ - /* 'start' dependecies */ - *(.text.start) + /* 'start' dependencies */ *(.text._ZN3Ion6Device5Board4initEv) *(.text._ZN3Ion6Device5Board7initFPUEv) *(.text._ZN3Ion6Device5Board7initMPUEv) @@ -86,10 +86,13 @@ SECTIONS { *(.text._ZN3Ion6Device5Cache*) *(.text._ZN3Ion6Timing6usleepEj) - /* 'abort' dependcies */ + /* 'abort' dependencies */ *(.text._ZN3Ion6Device5Reset4coreEv) - /**(.text._ZN3Ion5Power7suspendEb)*/ + /* 'standby' dependencies '*/ + *(.text._ZN3Ion5Power22internal_flash_standbyEv) + *(.text._ZN3Ion6Device5Power17enterLowPowerModeEv) + *(.text._ZN3Ion6Device5Board14shutdownClocksEb) /* Optimization */ */libgcc.a:(.text)