Changeset - 0b86288f0749
[Not reviewed]
default
0 1 0
Ethan Zonca - 9 years ago 2016-10-11 21:24:17
ez@ethanzonca.com
Fix deinitting things that aren't initted
1 file changed with 14 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/main.c
Show inline comments
 
@@ -39,25 +39,27 @@ int main(void)
 
 
    led_blink(4);
 
 
    uint16_t blink_rate = BLINK_FAST;
 
    uint8_t state = SYSTEM_GPSACQ;
 
 
    uint32_t fixinfo_timer = 0;
 
    uint32_t gps_polltimer = 0;
 
    uint32_t fix_acq_starttime = 0;
 
 
    uint8_t fix_ok = 0;
 
    uint8_t numsats = 0;
 
 
    while (1)
 
    {
 
 
        // Update fix status every 2 seconds
 
        if(HAL_GetTick() - fixinfo_timer > 2000)
 
        if(HAL_GetTick() - gps_polltimer > 2000)
 
        {
 
            if(gps_ison())
 
                gps_update_data();
 
        	fixinfo_timer = HAL_GetTick();
 
            gps_polltimer = HAL_GetTick();
 
        }
 
 
 
 
        switch(state)
 
        {
 
@@ -78,31 +80,35 @@ int main(void)
 
            // Attempt to acquire GPS fix
 
            case SYSTEM_GPSACQ:
 
            {
 
                blink_rate = BLINK_FAST;
 
 
                if(!gps_ison())
 
                {
 
                	fix_starttime = HAL_GetTick();
 
                    gps_poweron(); // power on and initialize GPS module
 
                
 
                }
 
 
                if(gps_getdata()->fixtype > 0 && gps_getdata()->pdop < 5)
 
                {
 
                    // Disable GPS module
 
                    gps_poweroff();
 
 
                    // TODO: Set RTC from GPS time
 
 
                    // TODO: Set RTC for countdown to next transmission timeslot!
 
 
                    // TODO: Set wspr countdown timer for this transmission!
 
                    fix_acq_starttime = 0;
 
                    state = SYSTEM_WSPRTX;
 
                }
 
//                else if(fix_timeout)
 
 //               {
 
  //                  // Flash error code and go to idle probably? or just try forever?
 
   //             }
 
                else if(HAL_GetTick() - fix_acq_starttime > 60000)
 
                {
 
                	  // Flash error code and go to idle probably? or just try forever?
 
                	led_blink(4);
 
                }
 
 
            } break;
 
 
            
 
            // Wait for wspr timeslot and start transmitting
 
            case SYSTEM_WSPRTX:
0 comments (0 inline, 0 general)