kopia lustrzana https://github.com/bristol-seds/pico-tracker
[watchdog] Implement IDLE_WAIT_FOR_GPS.
TODO: Measure maxlimit in operationmain-solar-only
rodzic
45cf89abbf
commit
73281c2d80
|
@ -45,10 +45,12 @@ typedef enum {
|
||||||
*/
|
*/
|
||||||
#define MAXIDLE_WHILE_TELEMETRY_ACTIVE 60000
|
#define MAXIDLE_WHILE_TELEMETRY_ACTIVE 60000
|
||||||
#define MAXIDLE_WAIT_FOR_NEXT_TELEMETRY 30000
|
#define MAXIDLE_WAIT_FOR_NEXT_TELEMETRY 30000
|
||||||
|
#define MAXIDLE_WAIT_FOR_GPS 1000
|
||||||
|
|
||||||
struct idle_counter {
|
struct idle_counter {
|
||||||
uint32_t while_telemetry_active;
|
uint32_t while_telemetry_active;
|
||||||
uint32_t wait_for_next_telemetry;
|
uint32_t wait_for_next_telemetry;
|
||||||
|
uint32_t wait_for_gps;
|
||||||
};
|
};
|
||||||
|
|
||||||
void awake_do_watchdog(void);
|
void awake_do_watchdog(void);
|
||||||
|
|
|
@ -57,6 +57,8 @@ void increment_idle_counter(idle_wait_t idle_t)
|
||||||
case IDLE_WAIT_FOR_NEXT_TELEMETRY:
|
case IDLE_WAIT_FOR_NEXT_TELEMETRY:
|
||||||
idle_count.wait_for_next_telemetry++;
|
idle_count.wait_for_next_telemetry++;
|
||||||
break;
|
break;
|
||||||
|
case IDLE_WAIT_FOR_GPS:
|
||||||
|
idle_count.wait_for_gps++;
|
||||||
default:
|
default:
|
||||||
/* Oh no no no. Let's die here */
|
/* Oh no no no. Let's die here */
|
||||||
while(1);
|
while(1);
|
||||||
|
@ -68,7 +70,8 @@ void increment_idle_counter(idle_wait_t idle_t)
|
||||||
void check_idle_counters(void)
|
void check_idle_counters(void)
|
||||||
{
|
{
|
||||||
if ((idle_count.while_telemetry_active > MAXIDLE_WHILE_TELEMETRY_ACTIVE) ||
|
if ((idle_count.while_telemetry_active > MAXIDLE_WHILE_TELEMETRY_ACTIVE) ||
|
||||||
(idle_count.wait_for_next_telemetry > MAXIDLE_WAIT_FOR_NEXT_TELEMETRY)) {
|
(idle_count.wait_for_next_telemetry > MAXIDLE_WAIT_FOR_NEXT_TELEMETRY) ||
|
||||||
|
(idle_count.wait_for_next_telemetry > MAXIDLE_WAIT_FOR_GPS)) {
|
||||||
/* Oh dear. Let's die here */
|
/* Oh dear. Let's die here */
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
@ -82,6 +85,7 @@ void clear_idle_counters(void)
|
||||||
{
|
{
|
||||||
SET_COUNT_MAX(while_telemetry_active);
|
SET_COUNT_MAX(while_telemetry_active);
|
||||||
SET_COUNT_MAX(wait_for_next_telemetry);
|
SET_COUNT_MAX(wait_for_next_telemetry);
|
||||||
|
SET_COUNT_MAX(wait_for_gps);
|
||||||
|
|
||||||
/* Zero out counter */
|
/* Zero out counter */
|
||||||
memset(&idle_count, 0, sizeof(struct idle_counter));
|
memset(&idle_count, 0, sizeof(struct idle_counter));
|
||||||
|
@ -117,28 +121,29 @@ void kick_the_watchdog(void)
|
||||||
void idle(idle_wait_t idle_t)
|
void idle(idle_wait_t idle_t)
|
||||||
{
|
{
|
||||||
/* Check valid */
|
/* Check valid */
|
||||||
/* if ((idle_t != IDLE_TELEMETRY_ACTIVE) && */
|
if ((idle_t != IDLE_TELEMETRY_ACTIVE) &&
|
||||||
/* (idle_t != IDLE_WAIT_FOR_NEXT_TELEMETRY)) { */
|
(idle_t != IDLE_WAIT_FOR_NEXT_TELEMETRY) &&
|
||||||
/* /\* Oh dear *\/ */
|
(idle_t != IDLE_WAIT_FOR_GPS)) {
|
||||||
/* while (1); */
|
/* Oh dear */
|
||||||
/* } */
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
/* /\* Maybe clear *\/ */
|
/* Maybe clear */
|
||||||
/* if (idle_t != last_idle_t) { */
|
if (idle_t != last_idle_t) {
|
||||||
/* clear_idle_counters(); */
|
clear_idle_counters();
|
||||||
/* last_idle_t = idle_t; */
|
last_idle_t = idle_t;
|
||||||
/* } */
|
}
|
||||||
|
|
||||||
/* /\* Increment the idle counter *\/ */
|
/* Increment the idle counter */
|
||||||
/* increment_idle_counter(idle_t); */
|
increment_idle_counter(idle_t);
|
||||||
|
|
||||||
/* /\* Check idle counter is still okay *\/ */
|
/* Check idle counter is still okay */
|
||||||
/* check_idle_counters(); */
|
check_idle_counters();
|
||||||
|
|
||||||
/* /\* Kick the watchdog *\/ */
|
/* Kick the watchdog */
|
||||||
/* #ifdef DEBUG_USE_INTWATCHDOG */
|
#ifdef DEBUG_USE_INTWATCHDOG
|
||||||
/* wdt_reset_count(); */
|
wdt_reset_count();
|
||||||
/* #endif */
|
#endif
|
||||||
|
|
||||||
/* WDI toggle */
|
/* WDI toggle */
|
||||||
port_pin_toggle_output_level(WDT_WDI_PIN);
|
port_pin_toggle_output_level(WDT_WDI_PIN);
|
||||||
|
|
Ładowanie…
Reference in New Issue