Add clearing of noinit segment on bad word

Code readability cleanup
This commit is contained in:
Tim Keller 2021-08-19 00:44:22 +00:00
parent 16502b788f
commit 2dd7b8ba2c
3 changed files with 12 additions and 7 deletions

View File

@ -76,7 +76,7 @@ void DateTime::UpdateTime(uint32_t systickCounter) {
} else if (hour != 0) {
isMidnightAlreadyNotified = false;
}
BackUpTime = currentDateTime;
NoInit_BackUpTime = currentDateTime;
}
const char* DateTime::MonthShortToString() {

View File

@ -2,7 +2,7 @@
#include <cstdint>
#include <chrono>
extern std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> BackUpTime;
extern std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> NoInit_BackUpTime;
namespace Pinetime {
namespace System {

View File

@ -160,8 +160,12 @@ Pinetime::System::SystemTask systemTask(spi,
heartRateApp,
fs);
uint32_t MAGIC_RAM __attribute__((section(".noinit")));
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> BackUpTime __attribute__((section(".noinit")));
extern uint32_t __start_noinit_data;
extern uint32_t __stop_noinit_data;
static constexpr uint32_t NoInit_MagicValue = 0xDEADBEEF;
uint32_t NoInit_MagicWord __attribute__((section(".noinit")));
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> NoInit_BackUpTime __attribute__((section(".noinit")));
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
if (pin == pinTouchIrq) {
@ -324,10 +328,11 @@ int main(void) {
Pinetime::BootloaderVersion::SetVersion(NRF_TIMER2->CC[0]);
// Check Magic Ram and reset lost variables
if (MAGIC_RAM == 0xDEADBEEF) {
dateTimeController.SetCurrentTime(BackUpTime);
if (NoInit_MagicWord == NoInit_MagicValue) {
dateTimeController.SetCurrentTime(NoInit_BackUpTime);
} else {
MAGIC_RAM = 0xDEADBEEF;
memset(&__start_noinit_data,0,(uintptr_t)&__stop_noinit_data-(uintptr_t)&__start_noinit_data);
NoInit_MagicWord = NoInit_MagicValue;
}
lvgl.Init();