diff --git a/src/main.c b/src/main.c --- a/src/main.c +++ b/src/main.c @@ -11,6 +11,7 @@ #include "wspr.h" #include "rtc.h" #include "gps.h" +#include "config.h" // We have access to the 1PPS pin of the gps... could have trim routine for internal oscillator based on this when we have a fix @@ -63,16 +64,23 @@ int main(void) uint8_t packet_type = 0; + // Transmit pilot tone to test TX on bootup + HAL_Delay(1000); + wspr_pilot_tone(); + adc_stop(); + HAL_Delay(1000); + while (1) { + // TODO: Disable GPIO port clocking when not needed! // Every 10 minutes, wake up and try to wspr - if(state == SYSTEM_IDLE && (HAL_GetTick() - last_wspr_tx_time > 60000 * 10)) - { - state = SYSTEM_GPSACQ; - } +// if(state == SYSTEM_IDLE && (HAL_GetTick() - last_wspr_tx_time > 60000 * 10)) +// { +// state = SYSTEM_GPSACQ; +// } - // Update fix status every 2 seconds + // Update fix status every 2 seconds, only if the GPS is powered on if(HAL_GetTick() - gps_polltimer > 2000) { if(gps_ison()) @@ -142,6 +150,9 @@ int main(void) gps_poweron(); // power on and initialize GPS module } + // TODO: Move GPS processing into here from above! + + // If 3d fix with a decent enough precision if( ((gps_getdata()->fixtype == 2) || (gps_getdata()->fixtype == 3)) && gps_getdata()->pdop < 10 && nextwspr_time_valid == 1) { @@ -213,25 +224,26 @@ int main(void) HAL_PWR_EnterSLEEPMode(0, PWR_SLEEPENTRY_WFI); } - // Schedule next wakeup (maybe 2mins prior ot timeslot if no osc trim) + // Schedule next wakeup (maybe 2mins prior to timeslot if no osc trim) // Next wakeup should enter SYSTEM_GPSACQ state... } break; } + #ifndef LED_DISABLE + if(HAL_GetTick() - led_timer > blink_rate) + { + ledpulse(); + led_timer = HAL_GetTick(); + } - if(HAL_GetTick() - led_timer > blink_rate) - { - ledpulse(); - led_timer = HAL_GetTick(); - } - - if(statled_ontime && HAL_GetTick() - statled_ontime > 10) - { - HAL_GPIO_WritePin(LED_BLUE, 0); - statled_ontime = 0; - } + if(statled_ontime && HAL_GetTick() - statled_ontime > 10) + { + HAL_GPIO_WritePin(LED_BLUE, 0); + statled_ontime = 0; + } + #endif } }