summaryrefslogtreecommitdiff
path: root/src/SystemTask/SystemTask.cpp
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-02-23 20:09:11 (GMT)
committerJF <jf@codingfield.com>2020-02-23 20:09:11 (GMT)
commit0aa1803ea22b119401bcd2e4d9d5278e8386f151 (patch)
treed7c6f7073430a2e3984b390ab0b4e12dc693be83 /src/SystemTask/SystemTask.cpp
parentf07ffab4c1fa876e8da9a1bcc895ecf0dfa75acf (diff)
Enable watchdog, and issue a WDT reset when the button is pushed for more than 7s.
Diffstat (limited to 'src/SystemTask/SystemTask.cpp')
-rw-r--r--src/SystemTask/SystemTask.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/SystemTask/SystemTask.cpp b/src/SystemTask/SystemTask.cpp
index 91822fa..e15846d 100644
--- a/src/SystemTask/SystemTask.cpp
+++ b/src/SystemTask/SystemTask.cpp
@@ -29,6 +29,9 @@ void SystemTask::Process(void *instance) {
}
void SystemTask::Work() {
+ watchdog.Setup(7);
+ watchdog.Start();
+ NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::Watchdog::ResetReasonToString(watchdog.ResetReason()));
APP_GPIOTE_INIT(2);
bool erase_bonds=false;
nrf_sdh_freertos_init(ble_manager_start_advertising, &erase_bonds);
@@ -70,7 +73,7 @@ void SystemTask::Work() {
while(true) {
uint8_t msg;
- if (xQueueReceive(systemTaksMsgQueue, &msg, isSleeping?3600000 : 1000)) {
+ if (xQueueReceive(systemTaksMsgQueue, &msg, isSleeping?2500 : 1000)) {
Messages message = static_cast<Messages >(msg);
switch(message) {
case Messages::GoToRunning: isSleeping = false; break;
@@ -83,6 +86,9 @@ void SystemTask::Work() {
}
uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG);
dateTimeController.UpdateTime(systick_counter);
+
+ if(!nrf_gpio_pin_read(pinButton))
+ watchdog.Kick();
}
}