Skip to content

Power Saving

Power saving functions.

The RTOS kernel determines periods where it is idle and does not need to run. It then can put the MCU into a basic sleep state by pausing until an interrupt occurs. If this behaviour is desired, the following function should be called in program initialization, i.e. early on in main().

Types

Name
typedef int(*)(void)osIdleSleepEnterEvent_t
invoked by the kernel, when it wants to enter sleep mode
typedef void(*)(void)osIdleSleepExitEvent_t
invoked by the kernel, after it wakes up from sleep mode

Functions Overview

Name
voidosKernelEnableIdleSleep(osIdleSleepEnterEvent_t enter_sleep_event, osIdleSleepExitEvent_t exit_sleep_event)
register two callbacks the kernel will invoke whenever it wants to enter or exit sleep.
voidosKernelDisableIdleSleep(void )
Replaces osKernelResume.

Types Documentation

typedef osIdleSleepEnterEvent_t

cpp
typedef int(* osIdleSleepEnterEvent_t) (void);

invoked by the kernel, when it wants to enter sleep mode

Return: 0 to inform the kernel that the application can't sleep at the moment, 1 to accept the request

typedef osIdleSleepExitEvent_t

cpp
typedef void(* osIdleSleepExitEvent_t) (void);

invoked by the kernel, after it wakes up from sleep mode

under normal circumstances the applicaton does not need to do anything here.

Function Details

function osKernelEnableIdleSleep

cpp
void osKernelEnableIdleSleep(
    osIdleSleepEnterEvent_t enter_sleep_event,
    osIdleSleepExitEvent_t exit_sleep_event
)

register two callbacks the kernel will invoke whenever it wants to enter or exit sleep.

Parameters:

  • enter_sleep_event callback that gets called by the scheduler before entering sleep.
  • enter_sleep_event callback that gets called by the scheduler after waking up

function osKernelDisableIdleSleep

cpp
void osKernelDisableIdleSleep(
    void 
)

Replaces osKernelResume.