2020-02-23 15:09:11 -05:00
|
|
|
#pragma once
|
2020-11-14 23:04:22 -05:00
|
|
|
#include <cstdint>
|
2020-02-23 15:09:11 -05:00
|
|
|
|
|
|
|
namespace Pinetime {
|
|
|
|
namespace Drivers {
|
|
|
|
class Watchdog {
|
2021-04-24 05:00:45 -04:00
|
|
|
public:
|
2021-04-18 13:28:14 -04:00
|
|
|
enum class ResetReasons { ResetPin, Watchdog, SoftReset, CpuLockup, SystemOff, LpComp, DebugInterface, NFC, HardReset };
|
|
|
|
void Setup(uint8_t timeoutSeconds);
|
|
|
|
void Start();
|
|
|
|
void Kick();
|
|
|
|
ResetReasons ResetReason() const {
|
|
|
|
return resetReason;
|
|
|
|
}
|
|
|
|
static const char* ResetReasonToString(ResetReasons reason);
|
|
|
|
|
2021-04-24 05:00:45 -04:00
|
|
|
private:
|
2021-04-18 13:28:14 -04:00
|
|
|
ResetReasons resetReason;
|
|
|
|
ResetReasons ActualResetReason() const;
|
2020-03-22 07:03:17 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class WatchdogView {
|
2021-04-24 05:00:45 -04:00
|
|
|
public:
|
2021-04-18 13:28:14 -04:00
|
|
|
WatchdogView(const Watchdog& watchdog) : watchdog {watchdog} {
|
|
|
|
}
|
|
|
|
Watchdog::ResetReasons ResetReason() const {
|
|
|
|
return watchdog.ResetReason();
|
|
|
|
}
|
2020-02-23 15:09:11 -05:00
|
|
|
|
2021-04-24 05:00:45 -04:00
|
|
|
private:
|
2021-04-18 13:28:14 -04:00
|
|
|
const Watchdog& watchdog;
|
2020-02-23 15:09:11 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|