mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-12-22 09:11:37 +03:00
Add clearing of noinit segment on bad word
Code readability cleanup
This commit is contained in:
parent
16502b788f
commit
2dd7b8ba2c
@ -76,7 +76,7 @@ void DateTime::UpdateTime(uint32_t systickCounter) {
|
|||||||
} else if (hour != 0) {
|
} else if (hour != 0) {
|
||||||
isMidnightAlreadyNotified = false;
|
isMidnightAlreadyNotified = false;
|
||||||
}
|
}
|
||||||
BackUpTime = currentDateTime;
|
NoInit_BackUpTime = currentDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* DateTime::MonthShortToString() {
|
const char* DateTime::MonthShortToString() {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <chrono>
|
#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 Pinetime {
|
||||||
namespace System {
|
namespace System {
|
||||||
|
15
src/main.cpp
15
src/main.cpp
@ -160,8 +160,12 @@ Pinetime::System::SystemTask systemTask(spi,
|
|||||||
heartRateApp,
|
heartRateApp,
|
||||||
fs);
|
fs);
|
||||||
|
|
||||||
uint32_t MAGIC_RAM __attribute__((section(".noinit")));
|
extern uint32_t __start_noinit_data;
|
||||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> BackUpTime __attribute__((section(".noinit")));
|
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) {
|
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
|
||||||
if (pin == pinTouchIrq) {
|
if (pin == pinTouchIrq) {
|
||||||
@ -324,10 +328,11 @@ int main(void) {
|
|||||||
Pinetime::BootloaderVersion::SetVersion(NRF_TIMER2->CC[0]);
|
Pinetime::BootloaderVersion::SetVersion(NRF_TIMER2->CC[0]);
|
||||||
|
|
||||||
// Check Magic Ram and reset lost variables
|
// Check Magic Ram and reset lost variables
|
||||||
if (MAGIC_RAM == 0xDEADBEEF) {
|
if (NoInit_MagicWord == NoInit_MagicValue) {
|
||||||
dateTimeController.SetCurrentTime(BackUpTime);
|
dateTimeController.SetCurrentTime(NoInit_BackUpTime);
|
||||||
} else {
|
} 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();
|
lvgl.Init();
|
||||||
|
Loading…
Reference in New Issue
Block a user