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?

master
Richard Meadows 2015-07-04 00:39:33 +01:00
rodzic 28d1d18541
commit 7b48a48881
3 zmienionych plików z 21 dodań i 13 usunięć

Wyświetl plik

@ -114,7 +114,7 @@ void do_cron(void)
/* APRS */ /* APRS */
#ifdef APRS_ENABLE #ifdef APRS_ENABLE
} else if ((t.minute % 2) == 0 && t.second == 55) { } else if ((t.minute % 2) == 0 && t.second == 0) {
aprs_telemetry(dp); aprs_telemetry(dp);
#endif #endif
@ -125,9 +125,22 @@ void do_cron(void)
} }
/* ---- Record for backlog ---- */ /* ---- 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); 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();
}
} }

Wyświetl plik

@ -393,6 +393,7 @@ void timer0_tick_init(uint32_t count)
irq_register_handler(TC0_IRQn, TC0_INT_PRIO); /* Highest Priority */ irq_register_handler(TC0_IRQn, TC0_INT_PRIO); /* Highest Priority */
/* Enable Timer */ /* Enable Timer */
tc_set_count_value(TC0, 0);
tc_enable(TC0); tc_enable(TC0);
tc_start_counter(TC0); tc_start_counter(TC0);
} }

Wyświetl plik

@ -132,6 +132,9 @@ void idle(idle_wait_t idle_t)
/* And sleep */ /* And sleep */
system_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_GCLK, /* Clock Source */
WDT_PERIOD_16384CLK, /* Timeout Period */ WDT_PERIOD_16384CLK, /* Timeout Period */
WDT_PERIOD_NONE, /* Window 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->INTENSET.reg |= WDT_INTENSET_EW;
WDT->INTFLAG.reg |= WDT_INTFLAG_EW; WDT->INTFLAG.reg |= WDT_INTFLAG_EW;
irq_register_handler(WDT_IRQn, 0); irq_register_handler(WDT_IRQn, WDT_INT_PRIO);
/* Kick Watchdogs */ /* Kick Watchdogs */
kick_external_watchdog(); kick_external_watchdog();