Changeset - cc569dddb24e
[Not reviewed]
default
0 1 0
Ethan Zonca - 7 years ago 2019-09-01 21:01:53
ez@ethanzonca.com
Thinks kinda work if we clear the wakeup flags and enable debugging in STOP mode... power usage went up a lot with debug in stop though.
1 file changed with 7 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/main.c
Show inline comments
 
@@ -63,24 +63,28 @@ int main(void)
 
    uint32_t nextwspr_time = 0;
 
    uint8_t nextwspr_time_valid = 0;
 
    uint32_t last_wspr_tx_time = 0;
 
 
    uint8_t packet_type = 0;
 
 
    // Transmit pilot tone to test TX on bootup
 
    HAL_Delay(1000);
 
    wspr_pilot_tone();
 
    adc_stop();
 
    HAL_Delay(1000);
 
 
    __DBGMCU_CLK_ENABLE() ; // (RCC->APB2ENR |= (RCC_APB2ENR_DBGMCUEN))
 
    HAL_EnableDBGStopMode();  //  SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
 
 
 
    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;
 
    	}
 
 
        // Update fix status every 2 seconds, only if the GPS is powered on
 
        if(HAL_GetTick() - gps_polltimer > 2000)
 
@@ -114,27 +118,29 @@ int main(void)
 
        {
 
 
            // Idling: sleep and wait for RTC timeslot trigger
 
            case SYSTEM_IDLE:
 
            {
 
                blink_rate = BLINK_SLOW;
 
 
                // 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);
 
                __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
 
        		HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
 
 
                // We have woken up!
 
                // We have woken up! Clear wakeup flag
 
        		__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
 
 
                // 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
 
 
 //               HAL_ResumeTick();
 
 
                // TODO: Eventually use GPS time to calibrate the RTC maybe
 
 
            } break;
 
 
 
            // Attempt to acquire GPS fix
0 comments (0 inline, 0 general)