kopia lustrzana https://github.com/bristol-seds/pico-tracker
Re-arranged cron a little, tasks now run after comms runs. Watchdog still being triggered for gps get position etc. Maybe need to wake on both edges of timepulse?
rodzic
28d1d18541
commit
7b48a48881
|
@ -114,7 +114,7 @@ void do_cron(void)
|
|||
|
||||
/* APRS */
|
||||
#ifdef APRS_ENABLE
|
||||
} else if ((t.minute % 2) == 0 && t.second == 55) {
|
||||
} else if ((t.minute % 2) == 0 && t.second == 0) {
|
||||
aprs_telemetry(dp);
|
||||
#endif
|
||||
|
||||
|
@ -125,9 +125,22 @@ void do_cron(void)
|
|||
}
|
||||
|
||||
/* ---- Record for backlog ---- */
|
||||
if ((t.minute % 1 == 0) && (t.second == 25)) {
|
||||
if ((t.minute % 1 == 0) && (t.second == 0)) {
|
||||
|
||||
kick_the_watchdog();
|
||||
|
||||
record_backlog(dp);
|
||||
}
|
||||
|
||||
/* Update internal time from GPS */
|
||||
/* We do this just after midnight or if time is yet to set UTC exactly */
|
||||
if (((t.hour == 0) && (t.minute == 0) && (t.second == 0)) ||
|
||||
((t.second == 0) && !(t.valid & UBX_TIMEUTC_VALID_UTC))) {
|
||||
|
||||
kick_the_watchdog();
|
||||
|
||||
read_gps_time(); /* TODO semaphore to stop mid-update increment */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,13 +159,4 @@ void cron_tick(void) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Update internal time from GPS */
|
||||
/* We do this just after midnight or if time is yet to set UTC exactly */
|
||||
if (((time.hour == 0) && (time.minute == 0) && (time.second == 5)) ||
|
||||
((time.second == 5) && !(time.valid & UBX_TIMEUTC_VALID_UTC))) {
|
||||
|
||||
/* Be careful not to call this while the collect_data function is running */
|
||||
read_gps_time();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -393,6 +393,7 @@ void timer0_tick_init(uint32_t count)
|
|||
irq_register_handler(TC0_IRQn, TC0_INT_PRIO); /* Highest Priority */
|
||||
|
||||
/* Enable Timer */
|
||||
tc_set_count_value(TC0, 0);
|
||||
tc_enable(TC0);
|
||||
tc_start_counter(TC0);
|
||||
}
|
||||
|
|
|
@ -132,6 +132,9 @@ void idle(idle_wait_t idle_t)
|
|||
|
||||
/* And sleep */
|
||||
system_sleep();
|
||||
|
||||
/* Same again when we wake from sleep */
|
||||
kick_the_watchdog();
|
||||
}
|
||||
|
||||
|
||||
|
@ -169,11 +172,11 @@ void watchdog_init(void)
|
|||
WDT_GCLK, /* Clock Source */
|
||||
WDT_PERIOD_16384CLK, /* Timeout Period */
|
||||
WDT_PERIOD_NONE, /* Window Period */
|
||||
WDT_PERIOD_256CLK); /* Early Warning Period */
|
||||
WDT_PERIOD_128CLK); /* Early Warning Period */
|
||||
|
||||
WDT->INTENSET.reg |= WDT_INTENSET_EW;
|
||||
WDT->INTFLAG.reg |= WDT_INTFLAG_EW;
|
||||
irq_register_handler(WDT_IRQn, 0);
|
||||
irq_register_handler(WDT_IRQn, WDT_INT_PRIO);
|
||||
|
||||
/* Kick Watchdogs */
|
||||
kick_external_watchdog();
|
||||
|
|
Ładowanie…
Reference in New Issue