STM32CubeWBA: System modules

Revision as of 17:46, 28 March 2023 by Registered User (→‎Background process)

1. Introduction

This page regroups the wiki pages dedicated to the STM32WBA systems modules. They provide information on concepts, how to use the modules, plus a full description of their APIs.

2. System modules

Below some system modules available on STM32WBA microcontrollers:

  • Memory management (dynamic allocation manager on a static pool, such as allocation or free)
  • Flash management (Interfaces and tools to execute flash operations, such as write or erase)
  • Real-time debugging (configuration and management of GPIOs for debug purposes)
  • System clock manager (management of clock frequency to select the best suitable frequency at the right time)
  • Low-power management (such as Interfaces for managing power modes)
  • Trace management (low-impact trace manager API)

3. Background process

Some system modules are based on the request/callback mechanism: the user requests an operation to the module, and she/he is notified later of the result, since the operation is not executed at user call but later.
This is made possible thanks to the "background process" method. The user call is used to check the feasibility of the operation, and the operation is executed by the background process function in a different context.

The typical workflow is the following:

  • The user request is analyzed and registered (it can be a request to check a parameter, a state, or a context). An error code about the result of the request is returned to the user.
  • The system module requests the future execution of its "background process" function to the scheduler. This function is in charge of processing the real user operation.
  • The scheduler sets the system "background process" function to active. Once the operation is achieved, the system module notifies the user using the callback.

The workflow can be represented as follows:

Background process use case

3.1. User steps

For this mechanism to operate correctly, the user must follow the steps described below, since the "ProcessRequest" function is defined in the module but its implementation is missing and must be performed by the user. The content of this function is always the same: Scheduling of the Background process function. However, you will have to adapt it to your operating system needs and specifies. Furthermore, do not forget to register the Background process function to your OS if needed for scheduling purposes.

Sum up
  • Register the Background function in the OS
  • Implement the Process request function to schedule the background function


Info white.png Information
An example of this setup is present in the How to section

3.2. How to

The following example explain how to setup the Background Process as a user. This can be applied to any module relying on a background process method.
This example deals with the advanced memory manager (AMM) module setup in a project relying on the sequencer.

Register the Background process function
The first thing before any use is to register the background process function of our system module:
/* Register the AMM background task */
UTIL_SEQ_RegTask( 1U << CFG_TASK_AMM_BCKGND, UTIL_SEQ_RFU, AMM_BackgroundProcess);
This way the background process function is registered for future scheduling.
Implement the Process request function
Once register of the background function is done, you shall implement the process request function. As said above, this function has to schedule the background function so the operation can be executed:
void AMM_ProcessRequest (void)
{
  /* Ask for AMM background task scheduling */
  UTIL_SEQ_SetTask(1U << CFG_TASK_AMM_BCKGND, CFG_SCH_PRIO_0);
}
Setup and initialize the module
After these two steps, you can now setup and initialize the memory manager module.
An example of AMM initialization can be found here.