InfiniTime/src/drivers/Watchdog.h

35 lines
832 B
C
Raw Normal View History

#pragma once
2020-11-15 04:04:22 +00:00
#include <cstdint>
namespace Pinetime {
namespace Drivers {
class Watchdog {
2021-04-24 09:00:45 +00:00
public:
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 09:00:45 +00:00
private:
ResetReasons resetReason;
ResetReasons ActualResetReason() const;
};
class WatchdogView {
2021-04-24 09:00:45 +00:00
public:
WatchdogView(const Watchdog& watchdog) : watchdog {watchdog} {
}
Watchdog::ResetReasons ResetReason() const {
return watchdog.ResetReason();
}
2021-04-24 09:00:45 +00:00
private:
const Watchdog& watchdog;
};
}
}