summaryrefslogtreecommitdiff
path: root/src/SystemTask
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-02-23 21:09:11 +0100
committerJF <jf@codingfield.com>2020-02-23 21:09:11 +0100
commit0aa1803ea22b119401bcd2e4d9d5278e8386f151 (patch)
treed7c6f7073430a2e3984b390ab0b4e12dc693be83 /src/SystemTask
parentf07ffab4c1fa876e8da9a1bcc895ecf0dfa75acf (diff)
Enable watchdog, and issue a WDT reset when the button is pushed for more than 7s.
Diffstat (limited to 'src/SystemTask')
-rw-r--r--src/SystemTask/SystemTask.cpp8
-rw-r--r--src/SystemTask/SystemTask.h2
2 files changed, 9 insertions, 1 deletions
diff --git a/src/SystemTask/SystemTask.cpp b/src/SystemTask/SystemTask.cpp
index 91822fa2..e15846da 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();
}
}
diff --git a/src/SystemTask/SystemTask.h b/src/SystemTask/SystemTask.h
index cb913545..f5ba2d75 100644
--- a/src/SystemTask/SystemTask.h
+++ b/src/SystemTask/SystemTask.h
@@ -7,6 +7,7 @@
#include <drivers/St7789.h>
#include <Components/Battery/BatteryController.h>
#include <DisplayApp/DisplayApp.h>
+#include <drivers/Watchdog.h>
namespace Pinetime {
namespace System {
@@ -41,6 +42,7 @@ namespace Pinetime {
Pinetime::Controllers::DateTime& dateTimeController;
QueueHandle_t systemTaksMsgQueue;
bool isSleeping = false;
+ Pinetime::Drivers::Watchdog watchdog;
static constexpr uint8_t pinSpiSck = 2;