Start implementing watchdog timer
This commit is contained in:
20
src/main.c
20
src/main.c
@@ -33,6 +33,24 @@ int Init(void)
|
||||
|
||||
Info("Initializing...");
|
||||
|
||||
// The watchdog timer is clocked from a separate
|
||||
// on-chip oscillator which runs at 1MHz. Eight
|
||||
// different clock cycle periods can be selected
|
||||
// to determine the reset period. If the reset
|
||||
// period expires, the chip resets and executes
|
||||
// from the reset vector.
|
||||
|
||||
// The update loop must call WDT_Reset to reset
|
||||
// the timer, kind of like a dead man's switch
|
||||
// allowing us to detect infinite loops and any
|
||||
// other error that halts execution.
|
||||
|
||||
if (WDT_HasTriggered())
|
||||
Info("Unexpected system reset.");
|
||||
|
||||
// WDT_Enable();
|
||||
// WDT_SetTimeout(7);
|
||||
|
||||
// There is a possiblity to use interrupt signals
|
||||
// for I2C communication but only as one large
|
||||
// branching routine for the whole I2C system.
|
||||
@@ -80,6 +98,8 @@ void Update(void)
|
||||
float temp[3], rhum[3];
|
||||
short raw[4];
|
||||
|
||||
WDT_Reset(); // Reset watchdog
|
||||
|
||||
Info("Reading sensor values...");
|
||||
|
||||
I2C_SetChannel(AHT01);
|
||||
|
||||
Reference in New Issue
Block a user