Define constants for watchdog timeout flags

This commit is contained in:
2024-09-06 15:55:16 +02:00
parent 82126d9aba
commit f4a6c655bd
2 changed files with 23 additions and 15 deletions

View File

@@ -3,6 +3,14 @@
#include "common/types.h" #include "common/types.h"
// Timeout Flags
#define WDT2000 0x7 // 2000 ms
#define WDT1000 0x6 // 1000 ms
#define WDT500 0x5 // 500 ms
#define WDT250 0x4 // 250 ms
#define WDT100 0x3 // 100 ms
// XXX: WDT...
void WDT_Enable(void); void WDT_Enable(void);
void WDT_SetTimeoutFlag(byte flag); void WDT_SetTimeoutFlag(byte flag);
bool WDT_HasTriggered(void); bool WDT_HasTriggered(void);

View File

@@ -50,7 +50,7 @@ int Init(void)
Info("Unexpected system reset."); Info("Unexpected system reset.");
WDT_Enable(); WDT_Enable();
WDT_SetTimeoutFlag(0x7); // 2 seconds WDT_SetTimeoutFlag(WDT2000); // 2 seconds
// There is a possiblity to use interrupt signals // There is a possiblity to use interrupt signals
// for I2C communication but only as one large // for I2C communication but only as one large
@@ -96,30 +96,30 @@ int Init(void)
void Update(void) void Update(void)
{ {
float temp[3], rhum[3]; float temp[3], rh[3];
short raw[4]; short adc[4];
Info("Reading sensor values..."); Info("Reading sensor values...");
I2C_SetChannel(AHT01); I2C_SetChannel(AHT01);
I2C_AHT20_Read(&temp[0], &rhum[0]); I2C_AHT20_Read(&temp[0], &rh[0]);
I2C_SetChannel(AHT02); I2C_SetChannel(AHT02);
I2C_AHT20_Read(&temp[1], &rhum[1]); I2C_AHT20_Read(&temp[1], &rh[1]);
I2C_SetChannel(AHT03); I2C_SetChannel(AHT03);
I2C_AHT20_Read(&temp[2], &rhum[2]); I2C_AHT20_Read(&temp[2], &rh[2]);
raw[0] = I2C_ADS1115_Read(0); adc[0] = I2C_ADS1115_Read(0);
raw[1] = I2C_ADS1115_Read(1); adc[1] = I2C_ADS1115_Read(1);
raw[2] = I2C_ADS1115_Read(2); adc[2] = I2C_ADS1115_Read(2);
raw[3] = I2C_ADS1115_Read(3); adc[3] = I2C_ADS1115_Read(3);
Info("TEM0=%.2fC, RH0=%.2f%%", temp[0], rhum[0]); Info("TEMP0=%.2fC, RH0=%.2f%%", temp[0], rh[0]);
Info("TEM1=%.2fC, RH1=%.2f%%", temp[1], rhum[1]); Info("TEMP1=%.2fC, RH1=%.2f%%", temp[1], rh[1]);
Info("TEM2=%.2fC, RH2=%.2f%%", temp[2], rhum[2]); Info("TEMP2=%.2fC, RH2=%.2f%%", temp[2], rh[2]);
Info("ADC0=%04X, ADC1=%04X, ADC2=%04X, ADC3=%04X", Info("ADC0=%04X, ADC1=%04X", adc[0], adc[1]);
raw[0], raw[1], raw[2], raw[3]); Info("ADC2=%04X, ADC3=%04X", adc[2], adc[3]);
} }
int main(void) int main(void)