Wakeup and sleep

Informative

How to move a channel between SLEEP and OPERATIONAL and handle wakeups. Binding rules: CHI-LIN-MUST-03, CHI-LIN-MUST-04, CHI-LIN-MUST-11 (and CHI-LIN-SHOULD-01).

Go operational

There are two ways to leave SLEEP:

Lin_Wakeup(0u);            /* transmits a wakeup pulse on the bus, then -> OPERATIONAL */
Lin_WakeupInternal(0u);    /* goes -> OPERATIONAL WITHOUT transmitting a pulse */

Use Lin_Wakeup to actively wake the cluster; use Lin_WakeupInternal when the bus is already awake — typically after you were notified of an externally detected wakeup (see below). Both are valid only in SLEEP; calling Lin_Wakeup in OPERATIONAL raises a development error (CHI-LIN-MUST-04).

React to a detected wakeup

While a channel sleeps with wakeup detection enabled, a bus wakeup is reported to you:

void LinIf_OnWakeup(uint8 channelId)
{
    /* a wakeup pulse was detected while asleep */
    Lin_WakeupInternal(channelId);   /* join the now-awake bus, no extra pulse */
}

Go to sleep

Lin_GoToSleepInternal(0u);   /* OPERATIONAL -> SLEEP; enables low-power / wakeup detection */

The channel stops participating and — where the hardware supports it — enters low-power mode with wakeup detection armed.

See also

Concepts — the State transition sequence shows the internal and external wakeup paths end to end.