diff --git a/src/main.c b/src/main.c --- a/src/main.c +++ b/src/main.c @@ -17,6 +17,13 @@ // Probabl wake up 1 minute early -- 0.45min possible +/- on wakeup time with 15min sync intervals +// TODO: Add JT9 message with more grid locator digits + altitude + vbatt + temp +// MSG13charmax: +// X: gridloc +// Y: altitude +// Z: temperature +// KD8TDF XXYYZZ // could use alt callsign thing + enum _state { SYSTEM_IDLE = 0, // awaiting RTC interrupt for wakeup TODO wake up before scheduled time to get fix? @@ -98,17 +105,22 @@ int main(void) case SYSTEM_IDLE: { blink_rate = BLINK_SLOW; - HAL_PWR_EnterSLEEPMode(0, PWR_SLEEPENTRY_WFI); - HAL_PWR_EnterSLEEPMode(0, PWR_SLEEPENTRY_WFI); - HAL_PWR_EnterSLEEPMode(0, PWR_SLEEPENTRY_WFI); + + // Actually sleep for real: disable systick and sleep until RTC interrupt + HAL_SuspendTick(); + + // Enter sleep mode: wait for interrupt HAL_PWR_EnterSLEEPMode(0, PWR_SLEEPENTRY_WFI); - // Wait for RTC wakeup interrupt - //wfi(); - //enter_sleep(); + // We have woken up! + + // This is hopefully the only timer that needs to stay alive in idle mode + last_wspr_tx_time += 0; // move this timer forward based on sleep length - // Somehow go to another state when we get an interrupt -// state = SYSTEM_GPSACQ; + HAL_ResumeTick(); + + // TODO: Eventually use GPS time to calibrate the RTC maybe + } break;