2020-02-23 21:09:11 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Pinetime {
|
|
|
|
namespace Drivers {
|
|
|
|
class Watchdog {
|
|
|
|
public:
|
|
|
|
enum class ResetReasons { ResetPin, Watchdog, SoftReset, CpuLockup, SystemOff, LpComp, DebugInterface, NFC, HardReset };
|
|
|
|
void Setup(uint8_t timeoutSeconds);
|
|
|
|
void Start();
|
|
|
|
void Kick();
|
2020-03-22 12:03:17 +01:00
|
|
|
ResetReasons ResetReason() const { return resetReason; }
|
2020-02-23 21:09:11 +01:00
|
|
|
static const char* ResetReasonToString(ResetReasons reason);
|
2020-03-22 12:03:17 +01:00
|
|
|
private:
|
|
|
|
ResetReasons resetReason;
|
|
|
|
ResetReasons ActualResetReason() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WatchdogView {
|
|
|
|
public:
|
|
|
|
WatchdogView(const Watchdog& watchdog) : watchdog{watchdog} { }
|
|
|
|
Watchdog::ResetReasons ResetReason() const { return watchdog.ResetReason();}
|
2020-02-23 21:09:11 +01:00
|
|
|
|
2020-03-22 12:03:17 +01:00
|
|
|
private:
|
|
|
|
const Watchdog& watchdog;
|
2020-02-23 21:09:11 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|