### NAND Driver API Example (C) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Driver/html/group__nand__interface__gr.html An example demonstrating the basic usage of the NAND driver API, including defining ONFI commands and including the necessary header file. This snippet illustrates how to start interacting with the NAND flash. ```c #include "Driver_NAND.h" /* ONFI commands */ #define ONFI_CMD_READ_1ST 0x00 ///< Read 1st Cycle #define ONFI_CMD_PROGRAM_2ND 0x10 ///< Page Program 2nd Cycle #define ONFI_CMD_READ_2ND 0x30 ///< Read 2nd Cycle // Further example usage would follow, calling functions like ARM_NAND_SendCommand, etc. ``` -------------------------------- ### RTX5: Application Main Thread Initialization (C) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS2/html/os2MigrationGuide.html This C code snippet demonstrates the structure of the application's main thread after renaming the 'main' function to 'app_main'. It includes system initialization, RTOS kernel setup, thread creation, and scheduler start. ```c #include "RTE_Components.h" #include CMSIS_device_header /* Renamed main() function */ void app_main (void const *argument) { // contents of old "main" } osThreadDef(app_main, osPriorityNormal, 1, 0); int main (void) { // System Initialization SystemCoreClockUpdate(); // ... osKernelInitialize(); osThreadCreate(osThread(app_main), NULL); osKernelStart(); for (;;); } ``` -------------------------------- ### Example Topology Links for Cortex-A7 Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Pack/html/sdf_pg.html A comprehensive set of example topology links for a Cortex-A7 implementation, demonstrating various link types like ATB, CoreTrace, and CTITrigger. These examples illustrate how to connect different CoreSight components and cores. ```xml master="Cortex-A7_0" slave="CSCTI_6" trigger="7" type="CTITrigger" master="CSETM_0" slave="CSCTI_6" trigger="6" type="CTITrigger" master="Cortex-A7_0" slave="CSETM_0" type="CoreTrace" master="CSETM_0" slave="CSTFunnel_2" slave_interface="0" type="ATB" master="CSTFunnel_2" slave="CSTFunnel_0" slave_interface="1" type="ATB" master="CSTFunnel_0" slave="CSTMC_0" type="ATB" master="CSTMC_0" slave="CSTPIU" type="ATB" ``` -------------------------------- ### Complete SPI Driver Initialization and Verification - CMSIS C Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Driver/html/theoryOperation.html Full example demonstrating SPI driver initialization including version checking, capability verification, callback registration, and power control setup. Validates API version compatibility and driver capabilities before configuring the SPI peripheral for master mode 8-bit communication. ```c #include "Driver_SPI.h" #include "cmsis_os.h" // ARM::CMSIS:RTOS:Keil RTX void mySPI_Thread(void const *argument); osThreadId tid_mySPI_Thread; extern ARM_DRIVER_SPI Driver_SPI0; const uint8_t testdata_out[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; uint8_t testdata_in[8]; void mySPI_Thread(void const* arg) { ARM_DRIVER_SPI* SPIdrv = &Driver_SPI0; osEvent evt; #ifdef DEBUG ARM_DRIVER_VERSION version; ARM_SPI_CAPABILITIES drv_capabilities; version = SPIdrv->GetVersion(); if (version.api < 0x200) /* requires at minimum API version 2.00 or higher */ { /* error handling */ return; } drv_capabilities = SPIdrv->GetCapabilities(); if (drv_capabilities.event_mode_fault == 0) { /* error handling */ return; } #endif /* Initialize the SPI driver */ SPIdrv->Initialize(mySPI_callback); /* Power up the SPI peripheral */ SPIdrv->PowerControl(ARM_POWER_FULL); /* Configure the SPI to Master, 8-bit mode @10000 kBits/sec */ } ``` -------------------------------- ### Define CMSIS-Pack Example with Board and Project Configuration Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Pack/html/pdsc_examples_pg.html XML structure for defining a complete example in a CMSIS-Pack, including board vendor/name reference, project environments (uv, iar), and component attributes. The example demonstrates a Blinky LED project targeting STM32F429 discovery board with ARM and IAR environment support. ```xml This is a basic example demonstrating the development flow and letting the LED on the board blink Blinky Getting Started ``` -------------------------------- ### FIR Low-Pass Filter Example Setup in C Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/DSP/html/arm_fir_example_f32_8c-example.html Demonstrates FIR filter configuration with macro definitions for test parameters, includes external test input data and reference output buffers. Uses 320 sample test length with 29 filter taps and 32-sample block processing. Requires arm_math.h header and math helper utilities. ```C #include "arm_math.h" #include "math_helper.h" #define TEST_LENGTH_SAMPLES 320 #define SNR_THRESHOLD_F32 140.0f #define BLOCK_SIZE 32 #define NUM_TAPS 29 extern float32_t testInput_f32_1kHz_15kHz[TEST_LENGTH_SAMPLES]; extern float32_t refOutput[TEST_LENGTH_SAMPLES]; static float32_t testOutput[TEST_LENGTH_SAMPLES]; ``` -------------------------------- ### Start RTOS Kernel Scheduler - C Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS2/html/rtx__evr_8h.html Event functions for starting the RTOS kernel scheduler. EvrRtxKernelStart logs the API call to start scheduling, while EvrRtxKernelStarted logs successful scheduler startup, enabling task execution. ```C void EvrRtxKernelStart(void); void EvrRtxKernelStarted(void); ``` -------------------------------- ### Low Power Entry and Sleep Example (C) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS2/html/theory_of_operation.html An example C code snippet demonstrating entering a low power state using `osKernelSuspend`, `MSP432_LP_Entry`, and `__WFE`. It includes logic to resume the kernel based on the time slept. ```c tc_wakeup = osKernelSuspend(); /* Is there some time to sleep? */ if (tc_wakeup > 0) { tc = 0; /* Enter the low power state */ MSP432_LP_Entry(); __WFE(); } /* Adjust the kernel ticks with the amount of ticks slept */ osKernelResume(tc); ``` -------------------------------- ### Initialize and Start CMSIS-RTOS Kernel in Main Function Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS/html/group__CMSIS__RTOS__KernelCtrl.html Demonstrates the typical initialization sequence for CMSIS-RTOS, including kernel initialization, peripheral setup, thread creation, and kernel startup. This is the primary entry point for RTOS-based applications on STM32 devices. ```c int main (void) { osKernelInitialize(); // initialize CMSIS-RTOS // initialize peripherals here // create 'thread' functions that start executing, // example: tid_name = osThreadCreate (osThread(name), NULL); osKernelStart(); // start thread execution } ``` -------------------------------- ### CMSIS-Pack XML Schema Example Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Pack/html/pdsc_package_pg.html An example XML snippet illustrating the structure of a CMSIS-Pack file. It includes essential elements like vendor, name, description, and optional elements for URL, license, release history, and keywords. ```xml ExampleVendor STM32F2xx_DFP Device Family Package for STMicroelectronics STM32F2 Family of Arm Cortex-M3 based Microcontroller http://www.arm.com/support ./END_USER_LICENCE_AGREEMENT.rtf First Release version of STM32F2 Device Family Pack. Beta version of STM32F2 Device Family Pack. ST Device Support Device Family Package ST STM32F2 STM32F2xx Generic Interfaces and Templates for Evaluation and Development Boards ... ``` -------------------------------- ### LMS Signal Convergence Example Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/DSP/html/globals_l.html Example implementation demonstrating LMS and normalized LMS filter usage for signal convergence. Includes global instances for LMS filter state and coefficients used in practical signal processing applications. ```APIDOC ## LMS SIGNAL CONVERGENCE EXAMPLE ### Description Example implementation showing how to use LMS and normalized LMS adaptive filters for signal processing convergence. ### Example Global Variables #### lmsNorm_instance - **Type**: Normalized LMS filter instance structure - **Purpose**: Stores normalized LMS filter state and parameters - **Location**: arm_signal_converge_example_f32.c - **Usage**: Used to maintain LMS filter state across processing iterations #### lmsNormCoeff_f32 - **Type**: 32-bit floating-point coefficient array - **Purpose**: Stores LMS filter coefficients - **Location**: arm_signal_converge_data.c, arm_signal_converge_example_f32.c - **Usage**: Coefficient values updated during adaptive filtering #### lmsStateF32 - **Type**: 32-bit floating-point state array - **Purpose**: Stores LMS filter internal state and delayed samples - **Location**: arm_signal_converge_example_f32.c - **Usage**: Maintains filter history for recursive processing #### LPF_instance - **Type**: Low-pass filter instance structure - **Purpose**: Stores LPF state for preprocessing input signals - **Location**: arm_signal_converge_example_f32.c - **Usage**: Applied before LMS processing to condition input signals ``` -------------------------------- ### XML Device Configuration Example Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Pack/html/sdf_pg.html An example of how to define a scanchain device within an XML system description. This includes attributes like name, type, and irLength, along with nested device information items. ```xml 0x04560014 ... ``` -------------------------------- ### Example Usage of ARM_SPI_GetVersion Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Driver/html/group__spi__interface__gr.html Demonstrates how to get the driver version information using ARM_SPI_GetVersion. This example shows accessing the driver information and preparing for SPI setup. ```c extern ARM_DRIVER_SPI Driver_SPI0; ARM_DRIVER_SPI *drv_info; void setup_spi (void) { drv_info = &Driver_SPI0; // Further setup code... } ``` -------------------------------- ### Get FmBlock Start Address Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Zone/genmodel/com/arm/cmsis/zone/gen/data/FmBlock.html Retrieves the starting memory address of the FmBlock. This method returns a long integer representing the address. ```java public long getStart() { // Implementation to return the start address return 0L; } ``` -------------------------------- ### GET Block Start Address Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Zone/genmodel/com/arm/cmsis/zone/gen/data/FmBlock.html Retrieves the starting memory address of the block. This method returns a long value representing the base address where the memory block begins. ```APIDOC ## GET Block Start Address ### Description Get the start address of this block. ### Method Signature ```java public long getStart() ``` ### Returns - **long** - The start address of the memory block in bytes ### Response Example ```java long startAddress = fmBlock.getStart(); // Returns: 0x20000000 for RAM, 0x08000000 for FLASH, etc. ``` ``` -------------------------------- ### Initialize Search Box JavaScript Component Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Pack/html/cp_SWComponents.html Initialize a SearchBox component for pack documentation with document-ready handlers for resizable elements and search functionality. This sets up the search interface and adjusts the page layout height dynamically when the window loads. ```javascript $(document).ready(initResizable); $(window).load(resizeHeight); $(document).ready(function() { searchBox.OnSelectItem(0); }); var searchBox = new SearchBox("searchBox", "search", false, 'Search'); $(document).ready(function(){ initNavTree('cp_SWComponents.html', ''); }); ``` -------------------------------- ### Ethernet PHY Example - C Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Driver/html/group__eth__phy__interface__gr.html Example demonstrating the initialization and configuration of Ethernet MAC and PHY drivers. It shows how to get capabilities and set the media interface. ```c static ARM_ETH_MAC_CAPABILITIES capabilities; static ARM_DRIVER_ETH_MAC *mac; static ARM_DRIVER_ETH_PHY *phy; mac = &Driver_ETH_MAC0; phy = &Driver_ETH_PHY0; // Initialize Media Access Controller capabilities = mac->GetCapabilities(); status = phy->SetInterface(capabilities.media_interface); ``` -------------------------------- ### Initialize Search Box and Navigation - JavaScript Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Zone/html/format_peripherals.html JavaScript initialization code for CMSIS-Zone documentation interface, setting up search functionality and DOM event handlers. This includes search box instantiation, document ready callbacks for resizing and navigation tree initialization. ```javascript $(document).ready(initResizable); $(window).load(resizeHeight); $(document).ready(function() { searchBox.OnSelectItem(0); }); var searchBox = new SearchBox("searchBox", "search", false, 'Search'); $(document).ready(function(){ initNavTree('format_peripherals.html', ''); }); ``` -------------------------------- ### CMSIS-RTOS2 Initialization and Search Box Setup Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS2/html/group__CMSIS__RTOS.html Initializes the document ready state, resizes elements, and sets up the search box functionality for the documentation. This snippet is common in web-based documentation interfaces. ```javascript $(document).ready(initResizable); $(window).load(resizeHeight); $(document).ready(function() { searchBox.OnSelectItem(0); }); var searchBox = new SearchBox("searchBox", "search",false,'Search'); $(document).ready(function(){ initNavTree('group__CMSIS__RTOS.html',''); }); ``` -------------------------------- ### Create and Start Periodic Timer - CMSIS-RTOS C Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS/html/group__CMSIS__RTOS__TimerMgmt.html Creates a periodic timer using osTimerCreate and starts it with a specified delay using osTimerStart. The function returns a timer ID on success and checks for osOK status before proceeding. This example demonstrates basic timer initialization in CMSIS-RTOS applications. ```c id = osTimerCreate(osTimer(Timer), osTimerPeriodic, &exec); if (id) { timerDelay = 1000; status = osTimerStart(id, timerDelay); if (status != osOK) { // Timer could not be started } } ``` -------------------------------- ### Initialize jQuery Document Ready Functions for CMSIS-Pack Documentation Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Pack/html/pdsc_examples_pg.html JavaScript initialization code for setting up interactive documentation features including resizable elements, search box functionality, and navigation tree initialization. These functions are executed when the DOM is ready and page resources are loaded. ```javascript $(document).ready(initResizable); $(window).load(resizeHeight); $(document).ready(function() { searchBox.OnSelectItem(0); }); var searchBox = new SearchBox("searchBox", "search", false, 'Search'); $(document).ready(function() { initNavTree('pdsc_examples_pg.html', ''); }); ``` -------------------------------- ### Get Current Thread ID Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS/html/cmsis__os_8h.html Returns the unique identifier of the currently executing thread. This is useful for threads that need to refer to themselves, for example, when modifying their own properties. ```c osThreadId osThreadGetId(void); ``` -------------------------------- ### CMSIS-RTOS Thread Creation and Kernel Initialization in C Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS/html/usingOS.html Complete CMSIS-RTOS implementation demonstrating kernel initialization, thread definition with different priorities, thread creation, and kernel startup. The example defines three thread functions (job1, job2, job3) with varying priorities and execution delays, showing how the main function orchestrates RTOS kernel startup and thread spawning. This requires the cmsis_os.h header file and a CMSIS-RTOS compliant library implementation. ```c #include "cmsis_os.h" void job1 (void const *argument) { while (1) { osDelay(10); } } osThreadDef(job1, osPriorityAboveNormal, 1, 0); void job2 (void const *argument) { osThreadCreate(osThread(job1), NULL); while (1) { } } osThreadDef(job2, osPriorityNormal, 1, 0); void job3 (void const *argument) { while (1) { osDelay(20); } } osThreadDef(job3, osPriorityNormal, 1, 0); int main (void) { osKernelInitialize(); osThreadCreate(osThread(job2)); osThreadCreate(osThread(job3)); osKernelStart(); } ``` -------------------------------- ### Get Current USB Frame Number Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Driver/html/group__usbd__interface__gr.html Retrieves the sequential 11-bit frame number of the last Start of Frame (SOF) packet received by the USB peripheral. Returns the frame number. ```c uint16_t ARM_USBD_GetFrameNumber(void); ``` -------------------------------- ### STM32F1 SAU Region Configuration Example (C) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Core/html/partition_h_pg.html This C code snippet provides an example of configuring Secure Attribute Unit (SAU) memory regions for an STM32F1 device. It defines the maximum number of regions and sets the start address, end address, and Non-Secure Callable (NSC) attribute for each region. These macros are essential for defining the security boundaries of memory. ```c #define SAU_REGIONS_MAX 8 #define SAU_INIT_REGION0 1 #define SAU_INIT_START0 0x00000000 #define SAU_INIT_END0 0x001FFFE0 #define SAU_INIT_NSC0 1 #define SAU_INIT_REGION1 1 #define SAU_INIT_START1 0x00200000 #define SAU_INIT_END1 0x003FFFE0 #define SAU_INIT_NSC1 0 #define SAU_INIT_REGION2 1 #define SAU_INIT_START2 0x20200000 #define SAU_INIT_END2 0x203FFFE0 #define SAU_INIT_NSC2 0 #define SAU_INIT_REGION3 1 #define SAU_INIT_START3 0x40000000 #define SAU_INIT_END3 0x40040000 #define SAU_INIT_NSC3 0 #define SAU_INIT_REGION4 0 #define SAU_INIT_START4 0x00000000 #define SAU_INIT_END4 0x00000000 #define SAU_INIT_NSC4 0 #define SAU_INIT_REGION5 0 #define SAU_INIT_START5 0x00000000 #define SAU_INIT_END5 0x00000000 #define SAU_INIT_NSC5 0 #define SAU_INIT_REGION6 0 #define SAU_INIT_START6 0x00000000 #define SAU_INIT_END6 0x00000000 ``` -------------------------------- ### XML Platform Scanchain Configuration Example Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Pack/html/sdf_pg.html An example of an XML configuration illustrating a scanchain with multiple DAPs (Debug Access Ports) and associated devices. This structure defines the order of devices on the scanchain, their types, and specific configuration items for each. ```xml 0x0BA01477 0 AHB-AP 0xE00FF000 0xE000E000 0 0xE0001000 0 0xE0002000 0 0x4BA00477 0 AHB-AP 0xE00FF000 0xE000E000 0 0xE0001000 0 0xE0002000 0 0xE0000000 0 ``` -------------------------------- ### Get RTOS Kernel State (C) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS2/html/group__CMSIS__RTOS__KernelCtrl.html Returns the current state of the RTOS kernel. This function can be called before the RTOS is initialized or started. It returns an osKernelState_t value, which can be osKernelError in case of failure or the actual kernel state. ```c int main (void) { // System Initialization SystemCoreClockUpdate(); // ... // Example usage (assuming osKernelGetState is called elsewhere): // osKernelState_t kernelState = osKernelGetState(); // if (kernelState == osKernelRunning) { // // Kernel is running // } return 0; } ``` -------------------------------- ### Document Ready and Initialization Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/DSP/html/globals_b.html Initializes the document and resizes navigation elements upon page load. Also sets up the search box functionality. ```javascript $(document).ready(initResizable); $(window).load(resizeHeight); $(document).ready(function() { searchBox.OnSelectItem(0); }); var searchBox = new SearchBox("searchBox", "search",false,'Search'); $(document).ready(function(){initNavTree('globals_b.html','');}); ``` -------------------------------- ### Log Utilities Driver Initialization (C) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Utilities/Log/Release_Notes.html Demonstrates the initialization process for the STM32Cube Log Utilities Driver. This typically involves calling a configuration function before using any logging operations. Ensure the necessary header files are included. ```c #include "stm32_log.h" int main(void) { /* USER CODE BEGIN */ LOG_Init(); /* USER CODE END */ while (1) { /* USER CODE END */ } } ``` -------------------------------- ### Get USB Frame Number (C) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Driver/html/group__usbh__host__gr.html Retrieves the current USB frame number. This function returns a 11-bit sequential frame number, typically derived from the last Start of Frame (SOF) packet received. ```c uint16_t ARM_USBH_GetFrameNumber( void ); ``` -------------------------------- ### Document Ready and Initialization (JavaScript) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Core_A/html/globals_defs_p.html These JavaScript snippets are used for document ready events and UI initializations. They typically handle tasks like making elements resizable, adjusting window heights, and initializing search functionality within a web-based documentation interface. ```javascript $(document).ready(initResizable); $(window).load(resizeHeight); $(document).ready(function() { searchBox.OnSelectItem(0); }); ``` ```javascript $(document).ready(function(){initNavTree('globals_defs_p.html','');}); ``` -------------------------------- ### Create a Simple Thread with Default Settings (C) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS2/html/group__CMSIS__RTOS__ThreadMgmt.html This example demonstrates creating a new thread using default attributes and memory allocation from the global memory pool. The thread function 'thread1' runs indefinitely. It requires kernel initialization and starting. ```c #include "cmsis_os2.h" __NO_RETURN void thread1 (void *argument) { // ... for (;;) { } } int main (void) { osKernelInitialize(); ; osThreadNew(thread1, NULL, NULL); // Create thread with default settings ; osKernelStart(); } ``` -------------------------------- ### JavaScript: Initialize Search Box and Navigation Tree Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Pack/html/createPackPublish.html Initializes the search box functionality and sets up the navigation tree for the documentation. This script is typically executed when the document is ready. ```javascript $(document).ready(function() { searchBox.OnSelectItem(0); }); $(document).ready(function(){ initNavTree('createPackPublish.html',''); }); ``` -------------------------------- ### Initialize jQuery Document Ready and Search Box in CMSIS-DSP Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/DSP/html/globals.html This JavaScript snippet initializes the document ready state, sets up the search box component, and configures the navigation tree for the CMSIS-DSP documentation. It handles resizing and search functionality when the page loads. ```JavaScript $(document).ready(initResizable); $(window).load(resizeHeight); $(document).ready(function() { searchBox.OnSelectItem(0); }); var searchBox = new SearchBox("searchBox", "search", false, 'Search'); $(document).ready(function(){ initNavTree('globals.html', ''); }); ``` -------------------------------- ### Get RTOS Kernel Tick Count (New in CMSIS-RTOS2) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS2/html/os2MigrationFunctions.html Retrieves the current tick count of the RTOS kernel. This is a new function introduced in CMSIS-RTOS API v2. It returns the number of system ticks that have elapsed since the kernel started. ```c uint32_t osKernelGetTickCount (void); ``` -------------------------------- ### Event Recorder - Message Queue Get Pending Handler Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS2/html/group__rtx__evr__message__queue.html Event callback generated when osMessageQueueGet starts waiting for a message to be retrieved from the queue. Tracks pending retrieval operations with queue ID, message buffer address, and timeout. ```C void EvrRtxMessageQueueGetPending( osMessageQueueId_t mq_id, void *msg_ptr, uint32_t timeout ); /* Parameters: * [in] mq_id - message queue ID obtained by osMessageQueueNew * [in] msg_ptr - pointer to buffer for message to get from a queue * [in] timeout - Timeout Value or 0 in case of no time-out * * Event Recorder Value shows: * - mq_id: message queue ID * - msg_ptr: memory address of buffer for message * - timeout: Timeout Value */ ``` -------------------------------- ### JavaScript: Document Ready and Search Initialization Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Core_A/html/functions_vars_w.html Initializes document ready state and search box functionality for the documentation website. This script is common in Doxygen-generated HTML documentation. ```javascript $(document).ready(initResizable); $(window).load(resizeHeight); $(document).ready(function() { searchBox.OnSelectItem(0); }); var searchBox = new SearchBox("searchBox", "search",false,'Search'); $(document).ready(function(){ initNavTree('functions_vars_w.html',''); }); ``` -------------------------------- ### Initialize System and USB Device (C) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Projects/STM32F103RB-Nucleo/Applications/USB_Device/HID_Standalone/readme.txt Initializes the HAL, system clock, and the USB device library. This is a standard setup for STM32 USB applications. It configures the system clock to 72 MHz and initializes the USB peripheral in Full Speed mode. ```c int main(void) { /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Initialize the USB peripheral */ MX_USB_PCD_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { // ... System clock configuration code ... } /** * @brief USB_PCD Initialization * @param None * @retval None */ void MX_USB_PCD_Init(void) { /* USER CODE BEGIN USB_PCD_Init */ /* USER CODE END USB_PCD_Init */ } ``` -------------------------------- ### Initialize RTOS Kernel and Create Objects Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS/html/group__CMSIS__RTOS__KernelCtrl.html Initializes the RTOS kernel to allow peripheral setup and creation of RTOS objects. This function should be called before starting the kernel. It supports creating threads, timers, mutexes, semaphores, memory pools, and message queues. ```c #include "cmsis_os.h" int main (void) { if (!osKernelRunning ()) { // if kernel is not running, initialize the kernel if (osKernelInitialize () != osOK) { // check osStatus for other possible valid values // exit with an error message } } // ... other setup code ... return 0; } ``` -------------------------------- ### MCU Device Initialization - CMSIS SysTick Configuration C Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Core/html/using_CMSIS.html Initializes the MCU by configuring SysTick to generate 1ms interrupts using SystemCoreClock and setting up the device-specific timer. Returns error status if SysTick configuration fails. ```C void Device_Initialization (void) { if (SysTick_Config(SystemCoreClock / 1000)) { ; } timer1_init(); } ``` -------------------------------- ### Get RTOS Kernel Information (C) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS2/html/group__CMSIS__RTOS__KernelCtrl.html Retrieves the API and kernel version, along with a kernel identifier string. This function can be called before the RTOS is initialized or started. It returns osStatus_t indicating success or failure, and populates provided buffers with version and ID information. ```c void info (void) { char infobuf[100]; osVersion_t osv; osStatus_t status; status = osKernelGetInfo(&osv, infobuf, sizeof(infobuf)); if(status == osOK) { printf("Kernel Information: %s\r\n", infobuf); printf("Kernel Version : %d\r\n", osv.kernel); printf("Kernel API Version: %d\r\n", osv.api); } } ``` -------------------------------- ### Initialize SPI Driver and Configure Callbacks in C Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Driver/html/group__spi__interface__gr.html Complete example demonstrating SPI driver initialization, callback setup for transfer events, and thread-based communication. Includes version checking, capability verification, and event handling for transfer completion, data loss, and mode fault conditions. ```c #include "Driver_SPI.h" #include "cmsis_os.h" void mySPI_callback(uint32_t event) { switch (event) { case ARM_SPI_EVENT_TRANSFER_COMPLETE: osSignalSet(tid_mySPI_Thread, 0x01); break; case ARM_SPI_EVENT_DATA_LOST: __breakpoint(0); break; case ARM_SPI_EVENT_MODE_FAULT: __breakpoint(0); break; } } const uint8_t testdata_out[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; uint8_t testdata_in[8]; void mySPI_Thread(void const* arg) { ARM_DRIVER_SPI* SPIdrv = &Driver_SPI0; ARM_DRIVER_VERSION version; ARM_SPI_CAPABILITIES drv_capabilities; version = SPIdrv->GetVersion(); if (version.api < 0x200) { return; } drv_capabilities = SPIdrv->GetCapabilities(); } ``` -------------------------------- ### Initialize Search and Navigation in CMSIS-SVD Documentation Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/SVD/html/elem_peripherals.html Contains JavaScript code for initializing the search box and navigation tree in the CMSIS-SVD HTML documentation. Sets up the search functionality and initializes the navigation tree for the peripherals element page. ```javascript $(document).ready(initResizable); $(window).load(resizeHeight); $(document).ready(function() { searchBox.OnSelectItem(0); }); var searchBox = new SearchBox("searchBox", "search", false, 'Search'); $(document).ready(function() { initNavTree('elem_peripherals.html', ''); }); ``` -------------------------------- ### Define Static Inline Function (C) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Core/html/group__compiler__conntrol__gr.html The __STATIC_INLINE macro defines a static function that the compiler is encouraged to inline. If the compiler successfully inlines all calls, it can lead to space optimization by avoiding the generation of a separate function implementation. The example shows how to get the current Interrupt Vector. ```c // Get Interrupt Vector __STATIC_INLINE uint32_t NVIC_GetVector (IRQn_Type IRQn) { uint32_t *vectors = (uint32_t *)SCB->VTOR; ``` -------------------------------- ### Document Ready and Initialization - JavaScript Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/DSP/html/globals_r.html Standard jQuery code to execute functions once the DOM is fully loaded. Includes initialization of resizable elements and search box functionality. ```javascript $(document).ready(initResizable); $(window).load(resizeHeight); $(document).ready(function() { searchBox.OnSelectItem(0); }); ``` -------------------------------- ### Iterate Memory Blocks with FreeMarker Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Zone/html/GenDataModel.html This FreeMarker template example demonstrates how to iterate over a collection of memory blocks assigned to a project zone. It generates an HTML table displaying the name, start address, and size of each block. This is useful for code generators that need to process memory allocation information. ```html <#list blocks as block>
Name Start Size
${block.name} ${block.start} ${block.size}
``` -------------------------------- ### CMSIS-RTOS2 Initialization and Thread Creation (C) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS2/html/genRTOS2IF.html This C code example demonstrates the initialization of the CMSIS-RTOS2 kernel and the creation of a new application thread. It assumes the system and necessary headers (RTE_Components.h, CMSIS_device_header, cmsis_os2.h) are included. The example includes optional Event Recorder initialization. ```c #include "RTE_Components.h" #include CMSIS_device_header #include "cmsis_os2.h" /*---------------------------------------------------------------------------- * Application main thread *--------------------------------------------------------------------------*/ void app_main (void *argument) { // ... for (;;) {} } int main (void) { // System Initialization SystemCoreClockUpdate(); #ifdef RTE_Compiler_EventRecorder // Initialize and start Event Recorder EventRecorderInitialize(EventRecordError, 1U); #endif // ... osKernelInitialize(); // Initialize CMSIS-RTOS osThreadNew(app_main, NULL, NULL); // Create application main thread osKernelStart(); // Start thread execution for (;;) {} } ``` -------------------------------- ### Get I2C Driver Version and Check API Compatibility Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Driver/html/group__i2c__interface__gr.html Retrieves the driver version information including API version and driver implementation version. The example demonstrates how to obtain version details and verify minimum API version compatibility (1.10 or higher) before proceeding with I2C operations. ```c extern ARM_DRIVER_I2C Driver_I2C0; ARM_DRIVER_I2C *drv_info; void setup_i2c (void) { ARM_DRIVER_VERSION version; drv_info = &Driver_I2C0; version = drv_info->GetVersion(); if (version.api < 0x10A) { // requires at minimum API version 1.10 or higher // error handling return; } } ``` -------------------------------- ### Document Ready and Navigation Tree Initialization (JavaScript) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Core_A/html/functions_vars_e.html Ensures that the navigation tree is properly initialized once the DOM is ready. This is crucial for the interactive elements of the documentation, such as expanding and collapsing sections. ```javascript $(document).ready(function(){initNavTree('functions_vars_e.html','');}); ``` -------------------------------- ### GRU Example Main Function (C) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/NN/html/arm__nnexamples__gru_8cpp.html The main function for the GRU example. It initializes and executes the GRU network, referencing various parameters and helper functions. This serves as the entry point for the example. ```c int main () { References [DIM_HISTORY](arm__nnexamples__gru_8cpp.html#ad9fde6ff501c9cd8a6cfc45949464c49), [DIM_INPUT](arm__nnexamples__gru_8cpp.html#ac8ab7c242bba66633b8c06966da6c9bc), [gru_example()](arm__nnexamples__gru_8cpp.html#ac71a806472c7c0c284a2253e71a6a27b), [hidden_state_bias](arm__nnexamples__gru_8cpp.html#a40dda695923891899cb86b2f01bfd98a), [hidden_state_weights](arm__nnexamples__gru_8cpp.html#ab18783e8d8449d7222ec4a64dfcc92e6), [reset_gate_bias](arm__nnexamples__gru_8cpp.html#a2a9d5c9f16ee778ecc8170d8664722c7), [reset_gate_weights](arm__nnexamples__gru_8cpp.html#ac2ae1ff19167c2bb359db2b319ca1060), [scratch_buffer](arm__nnexamples__gru_8cpp.html#a935afa741bcc39e4c4c48b019d415d97), [test_history](arm__nnexamples__gru_8cpp.html#ac327d41d23812b53d83c2da91971cbfe), [test_input1](arm__nnexamples__gru_8cpp.html#a8b0acc149c9bd4aadfb9c1fa8345f57a), [test_input2](arm__nnexamples__gru_8cpp.html#aad5944359ea4a426550a87efd0d90b02), [update_gate_bias](arm__nnexamples__gru_8cpp.html#ac5569d687768d693618f987a91e8aee5), and [update_gate_weights](arm__nnexamples__gru_8cpp.html#aa2fc9b2b0449790ed7c37bab7fd3093e). } ``` -------------------------------- ### Initialize Navigation Tree - JavaScript Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Core_A/html/globals_c.html jQuery document ready handler that initializes the documentation navigation tree structure for the globals_c.html page. This establishes the sidebar navigation menu hierarchy for browsing API documentation organized alphabetically by components. ```JavaScript $(document).ready(function(){ initNavTree('globals_c.html', ''); }); ``` -------------------------------- ### Get USB Host HCI Driver Version - C Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Driver/html/group__usbh__hci__gr.html Retrieves version information of the USB Host HCI driver implementation. Returns an ARM_DRIVER_VERSION structure containing both API version (CMSIS-Driver specification version) and driver implementation version. This example demonstrates version checking to ensure minimum API compatibility (1.10 or higher). ```c extern ARM_DRIVER_USBH Driver_USBH0_HCI; ARM_DRIVER_USBH *drv_info; void setup_usbh (void) { ARM_DRIVER_VERSION version; drv_info = &Driver_USBH0_HCI; version = drv_info->GetVersion (); if (version.api < 0x10A) { // requires at minimum API version 1.10 or higher // error handling return; } } ``` -------------------------------- ### Navigation Tree Initialization (JavaScript) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Core_A/html/globals_i.html This JavaScript code initializes the navigation tree for the documentation. It uses the jQuery `ready` function to ensure the DOM is loaded before executing. The `initNavTree` function is called with the path to the 'globals_i.html' file and an empty string for the initial path. ```javascript $(document).ready(function(){initNavTree('globals_i.html','');}); ``` -------------------------------- ### I2C Master Mode Example with Signal Event Callback Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Driver/html/group__i2c__interface__gr.html Demonstrates I2C Master mode initialization and usage with external EEPROM device. Includes driver instance declaration, event callback function, and event handling for incomplete transfers. The example shows how to set up the I2C driver instance and implement the signal event callback to capture I2C events. ```C #include "Driver_I2C.h" #define EEPROM_I2C_ADDR 0x51 /* EEPROM I2C address */ /* I2C driver instance */ extern ARM_DRIVER_I2C Driver_I2C0; static ARM_DRIVER_I2C *I2Cdrv = &Driver_I2C0; static volatile uint32_t I2C_Event; /* I2C Signal Event function callback */ void I2C_SignalEvent (uint32_t event) { /* Save received events */ I2C_Event |= event; /* Optionally, user can define specific actions for an event */ if (event & ARM_I2C_EVENT_TRANSFER_INCOMPLETE) { /* Less data was transferred than requested */ } } ``` -------------------------------- ### Start RTOS Kernel Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS/html/cmsis__os_8h.html Starts the execution of the RTOS kernel. Once started, the scheduler will begin managing threads and their execution based on their priorities. ```c osStatus osKernelStart(void); ``` -------------------------------- ### Setup OS Tick Timer with Frequency and Handler - C Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS2/html/group__CMSIS__RTOS__TickAPI.html Configures the OS Tick timer to generate periodic RTOS Kernel Ticks at a specified frequency. Accepts tick frequency in Hz and an interrupt handler function pointer. Returns 0 on success or -1 on error. The timer is initialized but not started; OS_Tick_Enable must be called to begin interrupt generation. ```c int32_t OS_Tick_Setup(uint32_t freq, IRQHandler_t handler); #ifndef SYSTICK_IRQ_PRIORITY #define SYSTICK_IRQ_PRIORITY 0xFFU #endif static uint8_t PendST; ``` -------------------------------- ### Initialize search functionality with jQuery Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/RTOS2/html/functions.html Sets up DOM ready handlers and search box initialization for CMSIS-RTOS2 documentation. Initializes resizable elements, search box with autocomplete, and navigation tree on page load. ```JavaScript $(document).ready(initResizable); $(window).load(resizeHeight); $(document).ready(function() { searchBox.OnSelectItem(0); }); var searchBox = new SearchBox("searchBox", "search", false, 'Search'); $(document).ready(function(){ initNavTree('functions.html', ''); }); ``` -------------------------------- ### STM32F1 Flash Driver Initialization and Usage Example (C) Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/Driver/html/group__flash__interface__gr.html This C code demonstrates how to initialize, configure, and use the STM32F1 Flash driver within a CMSIS-RTOS2 environment. It includes setting up callbacks for events like readiness and errors, powering the device, performing read operations, and gracefully shutting down the driver. Dependencies include 'Driver_Flash.h' and 'cmsis_os2.h'. ```c #include "Driver_Flash.h" #include "cmsis_os2.h" // ARM::CMSIS:RTOS2:Keil RTX5 /* Flash driver instance */ extern ARM_DRIVER_FLASH Driver_Flash0; static ARM_DRIVER_FLASH *flashDev = &Driver_Flash0; /* CMSIS-RTOS2 Thread Id */ osThreadId_t Flash_Thread_Id; /* Flash signal event */ void Flash_Callback(uint32_t event) { if (event & ARM_FLASH_EVENT_READY) { /* The read/program/erase operation is completed */ osThreadFlagsSet(Flash_Thread_Id, 1U); } if (event & ARM_FLASH_EVENT_ERROR) { /* The read/program/erase operation is completed with errors */ /* Call debugger or replace with custom error handling */ __breakpoint(0); } } /* CMSIS-RTOS2 Thread */ void Flash_Thread (void *argument) { /* Query drivers capabilities */ const ARM_FLASH_CAPABILITIES capabilities = flashDev->GetCapabilities(); /* Initialize Flash device */ if (capabilities.event_ready) { flashDev->Initialize(&Flash_Callback); } else { flashDev->Initialize(NULL); } /* Power-on Flash device */ flashDev->PowerControl(ARM_POWER_FULL); /* Read data taking data_width into account */ uint8_t buf[256U]; flashDev->ReadData(0x1000U, buf, sizeof(buf) >> capabilities.data_width); /* Wait operation to be completed */ if (capabilities.event_ready) { osThreadFlagsWait (1U, osFlagsWaitAny, 100U); } else { osDelay(100U); } /* Switch off gracefully */ flashDev->PowerControl(ARM_POWER_OFF); flashDev->Uninitialize(); } ``` -------------------------------- ### Example Usage of arm_fir_instance_f32 Source: https://github.com/stmicroelectronics/stm32cubef1/blob/master/Drivers/CMSIS/docs/DSP/html/structarm__fir__instance__f32.html Illustrates how the arm_fir_instance_f32 struct is used in examples within the CMSIS-DSP library. These examples demonstrate practical applications of FIR filters, such as in signal processing. ```c // Example referencing arm_fir_instance_f32 struct in arm_fir_example_f32.c and arm_signal_converge_example_f32.c ```