ToCoNet_vSleep()

Explanation

Sleep with WakeTimer.

About wake-up interruptions

It is also possible to set an interrupt source other than WakeTimer. It is set beforehand before calling this function.

E_EVENT_TOCONET_ON_SLEEP event

Just before sleep, E_EVENT_TOCONET_ON_SLEEP is passed to each user-defined event processing function.

To prevent ToCoNet_vSleep() from being called recursively, the following code example handles E_EVENT_NEW_STATE.

void vMyProcessEv(...) {
    ...
    case E_STATE_SLEEPING: 
        if (eEvent == E_EVENT_NEW_STATE) { 
            ToCoNet_vSleep(…);
        }
        break;
    ...
}

About sleep time

The WakeTimer works with the accuracy of a 32 kHz oscillator, so the accuracy of the oscillator is very important for the wake-up accuracy. The built-in oscillator must be calibrated before use (unless otherwise specified in sToCoNet_AppContext, in which case it will be executed in the TWENET library on cold start).

Extremely short sleep intervals cannot be set. The lower limit is approximately 30ms.

The wake-up time depends on the accuracy of the WakeTimer, but even in the best case there is an error of about ±0.1%.

Arguments

Returns

None

Sample code

// set UART Rx port as interrupt source
vAHI_DioSetDirection(u32DioPortWakeUp, 0); // set as input

// set DIO wakeup source
(void)u32AHI_DioInterruptStatus(); // clear interrupt register
vAHI_DioWakeEnable(u32DioPortWakeUp, 0); // enable ports
vAHI_DioWakeEdge(u32DioPortWakeUp, 0); // set edge (rising)

// 10sec
ToCoNet_vSleep(E_AHI_WAKE_TIMER_0, 10000, FALSE, FALSE); 

最終更新