Empty C Bare-Metal Application to FreeRTOS Application with M4 Sleep#

This section explains how to convert a simple bare-metal button example into a FreeRTOS-based application that leverages the Power Manager to control M4 low-power states. You’ll integrate task scheduling, Tickless Idle, and power-state management so that button presses request PS4 ⇄ PS3 ⇄ PS2 ⇄ PS1 transitions, and the system automatically enters a low-power sleep when idle.

When the application becomes idle, the Power Manager triggers either Sleep or Standby mode, depending on the value of the SL_SI91X_STANDBY macro or the PS1 state if sl_si91x_power_manager_request_ps1_state() is called.

  1. Create the Button Bare-Metal Sample Application sample application. (See the WiSeConnect documentation for steps to create a sample application.)

    • This sample application will be considered the base application.

    • See the Platform documentation for steps to port from the bare-metal sample application to an RTOS-based application using the sl_main software module.

  2. Create the Power Manager Tickless Idle sample application as a reference to create a FreeRTOS application with M4 sleep from the base application. The following elements can be adapted to the base application:

    • The required header files such as FreeRTOS, Button, Power Manager, and Ultra-Low-Power (ULP) peripheral.

    • The software components needed for Universal Asynchronous Receiver/Transmitter (UART) output, WiSeConnect SDK, RAM Execution, Power Manager, and wireless functionality.

    • Enable the wake-up sources (such as calendar, Ultra-Ultra-Low-Power (UULP) General Purpose Input/Output (GPIO), and wireless) needed for the M4 to wake from the sleep state.

    • Initialize Power Manager and map button events to power-state requirements (PS4/PS3/PS2/PS1).

    • For external switch boards, for M4 to enter PS2 Active, Standby, or Sleep, the NWP should be in Unconnected Sleep, with or without retention.

    • Add the required application file that is used in PS2 state in the .data section (RAM) of the application linker file as mentioned above in RAM Retention. See the linker file in the reference application.

    • Configure any supported ULP peripheral to wake from PS1.

    • Add the preprocessors which are required for the low-power execution (for example, SL_SI91X_ULP_STATE_ENABLE and SLI_SI91X_MCU_ENABLE_RAM_BASED_EXECUTION when PS2 is used).

    • The required code snippets for power-state transitions and their transition callbacks.

      • Add state-machine logic for the power-state transitions.

Note: Ensure that all the components installed in the reference application are also installed in the base application. This helps avoid build errors and ensure that the application runs smoothly.