Skip to content

Commit

Permalink
Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
geekbozu committed Sep 2, 2021
1 parent 110c82c commit 28fdc37
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,12 @@ Pinetime::System::SystemTask systemTask(spi,
heartRateApp,
fs);

/* Variable Declarations for variables in noinit SRAM
Increment NoInit_MagicValue upon adding variables to this area
*/
extern uint32_t __start_noinit_data;
extern uint32_t __stop_noinit_data;
static constexpr uint32_t NoInit_MagicValue = 0xDEADBEEF;
static constexpr uint32_t NoInit_MagicValue = 0xDEAD0000;
uint32_t NoInit_MagicWord __attribute__((section(".noinit")));
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> NoInit_BackUpTime __attribute__((section(".noinit")));

Expand Down Expand Up @@ -327,10 +330,11 @@ int main(void) {
// retrieve version stored by bootloader
Pinetime::BootloaderVersion::SetVersion(NRF_TIMER2->CC[0]);

// Check Magic Ram and reset lost variables

if (NoInit_MagicWord == NoInit_MagicValue) {
dateTimeController.SetCurrentTime(NoInit_BackUpTime);
} else {
//Clear Memory to known state
memset(&__start_noinit_data,0,(uintptr_t)&__stop_noinit_data-(uintptr_t)&__start_noinit_data);
NoInit_MagicWord = NoInit_MagicValue;
}
Expand Down

0 comments on commit 28fdc37

Please sign in to comment.