### FFT Bin Example Setup Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/DSP/html/arm_fft_bin_example_f32_8c-example.html This code sets up the FFT processing parameters and declares external input and output buffers for the FFT bin example. It is intended for Cortex-M4/M3 processors. ```c #include "[arm\_math.h](arm__math_8h.html)" #include "[arm\_const_structs.h](arm__const__structs_8h.html)" #if defined(SEMIHOSTING) #include #endif #define TEST_LENGTH_SAMPLES 2048 /* ------------------------------------------------------------------ * External Input and Output buffer Declarations for FFT Bin Example * ------------------------------------------------------------------ */ extern float32_t [testInput_f32_10khz](arm__fft__bin__example__f32_8c.html#a3d8ecb82590486ceebccc76263963b16) [TEST_LENGTH_SAMPLES]; static float32_t [testOutput](arm__dotproduct__example__f32_8c.html#a324833b61eae796082e07d078a67c34f) [TEST_LENGTH_SAMPLES]/2; /* ------------------------------------------------------------------ * Global variables for FFT Bin Example * ------------------------------------------------------------------- */ uint32_t [fftSize](arm__fft__bin__example__f32_8c.html#a9b500899c581f6df3ffc0a9f3a9ef6aa) = 1024; uint32_t [ifftFlag](arm__fft__bin__example__f32_8c.html#a379ccb99013d369a41b49619083c16ef) = 0; uint32_t [doBitReverse](arm__fft__bin__example__f32_8c.html#a4d2e31c38e8172505e0a369a6898657d) = 1; [arm_cfft_instance_f32](structarm__cfft__instance__f32.html) [varInstCfftF32](arm__fft__bin__example__f32_8c.html#a267b387963f2783aa103715c89a4341e); /* Reference index at which max energy of bin ocuurs */ ``` -------------------------------- ### Example MPU Region Setup Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Core/html/group__mpu__functions.html Example demonstrating how to set up MPU Region 0 for a specific memory address range with defined attributes. ```c int main() { // Set Region 0 ARM_MPU_SetRegionEx(0UL, 0x08000000UL, ARM_MPU_RASR(0UL, ARM_MPU_AP_FULL, 0UL, 0UL, 1UL, 1UL, 0x00UL, ARM_MPU_REGION_SIZE_1MB)); ``` -------------------------------- ### Flash Driver Setup and Operation Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Driver/html/group__flash__interface__gr.html Demonstrates a typical setup sequence for the Flash driver, including initialization with a callback, power control, data reading, and uninitialization. It utilizes CMSIS-RTOS2 for thread management and event signaling. Ensure the Flash driver instance and CMSIS-RTOS2 are correctly configured. ```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 (); } ``` -------------------------------- ### CMake Project Setup Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/DSP/Examples/ARM/arm_fir_example/CMakeLists.txt Sets the minimum CMake version and project name for the ARM FIR example. ```cmake cmake_minimum_required (VERSION 3.14) project (arm_fir_example VERSION 0.1) ``` -------------------------------- ### CMake Project Setup Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/DSP/Examples/ARM/arm_fft_bin_example/CMakeLists.txt Initializes the CMake build system and defines the project name and version. This is a standard starting point for CMake projects. ```cmake cmake_minimum_required (VERSION 3.14) project (arm_fft_bin_example VERSION 0.1) ``` -------------------------------- ### CMake Project Setup Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/DSP/Examples/ARM/arm_class_marks_example/CMakeLists.txt Initializes the CMake build system and defines the project name and version. This is a standard starting point for any CMake project. ```cmake cmake_minimum_required (VERSION 3.14) project (arm_class_marks_example VERSION 0.1) ``` -------------------------------- ### CMake Project Setup Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/DSP/Examples/ARM/arm_matrix_example/CMakeLists.txt Initializes the CMake project, sets the minimum version, and defines the project name and version. This is a standard starting point for CMake projects. ```cmake cmake_minimum_required (VERSION 3.14) project (arm_matrix_example VERSION 0.1) ``` -------------------------------- ### Get Driver Version Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Driver/html/group__usart__interface__gr.html Example demonstrating how to retrieve the driver version and check the API version. Requires the ARM_DRIVER_USART structure. ```c extern ARM_DRIVER_USART Driver_USART0; ARM_DRIVER_USART *drv_info; void setup_usart (void) { ARM_DRIVER_VERSION version; drv_info = &Driver_USART0; version = drv_info->GetVersion (); if (version.api < 0x10A) { // requires at minimum API version 1.10 or higher // error handling return; } } ``` -------------------------------- ### Test Signal Convergence Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/DSP/html/arm__signal__converge__example__f32_8c.html This function serves as the entry point for testing the signal convergence functionality. It orchestrates the setup and execution of the convergence tests. ```c arm_status test_signal_converge_example(void) ``` -------------------------------- ### Timer Creation and Starting Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/RTOS/html/group__CMSIS__RTOS__TimerMgmt.html Demonstrates how to create a timer and start it with a specified delay. ```APIDOC ## POST /api/timers ### Description Creates and starts a new timer with a specified delay and callback function. ### Method POST ### Endpoint /api/timers ### Parameters #### Request Body - **timer_def** (object) - Required - Definition of the timer, including its callback function. - **timer_type** (enum) - Required - Type of timer (e.g., `osTimerPeriodic`). - **timer_delay** (integer) - Required - The delay in milliseconds before the timer callback is invoked. ### Request Example ```json { "timer_def": { "name": "Timer", "callback": "Timer_Callback" }, "timer_type": "osTimerPeriodic", "timer_delay": 1000 } ``` ### Response #### Success Response (200) - **timer_id** (string) - The unique identifier for the created timer. #### Response Example ```json { "timer_id": "timer1" } ``` ``` -------------------------------- ### PMU Initialization and Example Usage Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Core/html/group__pmu8__functions.html Example demonstrating how to initialize and use the PMU for performance monitoring. ```APIDOC ## PMU Initialization and Usage Example ### Description This example demonstrates the initialization and usage of the Performance Monitoring Unit (PMU) to count instructions retired and L1 D-Cache misses. ### Method N/A (Code Example) ### Endpoint N/A ### Parameters None ### Request Example ```c // Initialize counter variables unsigned int cycle_count = 0; unsigned int l1_dcache_miss_count = 0; unsigned int instructions_retired_count = 0; // Enable the PMU // Note: Before using the PMU, software needs to ensure // that trace is enabled via the Debug Exception Monitor Control Register, DEMCR: // CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; ARM_PMU_Enable(); // Configure Event Counter Register 0 to count instructions retired // Configure Event Counter Register 1 to count L1 D-Cache misses ARM_PMU_Set_EVTYPER(0, ARM_PMU_INST_RETIRED); ARM_PMU_Set_EVTYPER(1, ARM_PMU_L1D_CACHE_MISS_RD); // Reset Event Counters and Cycle Counter ARM_PMU_EVCNTR_ALL_Reset(); ARM_PMU_CYCCNT_Reset(); // Start incrementing Cycle Count Register and Event Counter Registers 0 & 1 ARM_PMU_CNTR_Enable(PMU_CNTENSET_CCNTR_ENABLE_Msk | PMU_CNTENSET_CNT0_ENABLE_Msk | PMU_CNTENSET_CNT1_ENABLE_Msk); // Code you want to measure here // ... // Stop incrementing Cycle Count Register and Event Counter Registers 0 & 1 ARM_PMU_CNTR_Disable(PMU_CNTENCLR_CCNTR_ENABLE_Msk | PMU_CNTENCLR_CNT0_ENABLE_Msk | PMU_CNTENCLR_CNT1_ENABLE_Msk); // Get cycle count, number of instructions retired and number of L1 D-Cache misses (on read) cycle_count = cycle_count + ARM_PMU_Get_CCNTR(); instructions_retired_count = instructions_retired_count + ARM_PMU_Get_EVCNTR(0); l1_dcache_miss_count = l1_dcache_miss_count + ARM_PMU_Get_EVCNTR(1); // Note: D-Cache must be enabled using // SCB_EnableDCache() for meaningful result. ``` ### Response #### Success Response (200) None (Code Example) #### Response Example None ``` -------------------------------- ### MPU Configuration Example Table Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Core/html/group__mpu8__functions.html An example of an MPU configuration table using ARM_MPU_Region_t structure. ```c const ARM_MPU_Region_t mpuTable[1][4] = { { ``` -------------------------------- ### Signal Convergence Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/DSP/html/globals_func_t.html Demonstrates the usage of the signal convergence function. This example is part of the arm_signal_converge_example_f32.c file. ```c test_signal_converge() ``` ```c test_signal_converge_example() ``` -------------------------------- ### Update USB Endpoint Start Transfer Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Release_Notes.html Reworked API to enable the USB endpoint before unmasking the TX FIFO empty interrupt when DMA is not used. This prevents potential race conditions. ```c USB_EPStartXfer(); ``` -------------------------------- ### Ethernet MAC and PHY Initialization Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Driver/html/group__eth__phy__interface__gr.html Example demonstrating the initialization of Ethernet MAC and PHY drivers, retrieving capabilities, and setting the media interface. Ensure the correct driver instances are used. ```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); ``` -------------------------------- ### Convolution Example Initialization (C) Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/DSP/html/arm_convolution_example_f32_8c-example.html Initializes variables and structures required for the convolution example, including FFT instance setup. Ensure correct data types and sizes are used. ```c uint32_t srcALen = 64; uint32_t srcBLen = 64; uint32_t outLen; float32_t snr; arm_status status; arm_cfft_radix4_instance_f32 cfft_instance; arm_cfft_radix4_instance_f32 *cfft_instance_ptr = (arm_cfft_radix4_instance_f32*) &cfft_instance; outLen = srcALen + srcBLen - 1; ``` -------------------------------- ### RTOS Kernel Initialization and Start Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/RTOS/html/group__CMSIS__RTOS__KernelCtrl.html Demonstrates the essential steps to initialize and start the RTOS kernel, including calling osKernelInitialize() and osKernelStart(). ```APIDOC ## RTOS Kernel Initialization and Start ### Description This section shows the basic structure for initializing and starting the RTOS kernel within the `main` function. ### Method C Code Example ### Endpoint N/A ### Parameters N/A ### Request Body N/A ### Request Example ```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 } ``` ### Response N/A ### Response Example N/A ``` -------------------------------- ### CMSIS-RTOS Message Queue Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/RTOS/html/group__CMSIS__RTOS__Message.html Example demonstrating the setup and usage of message queues in CMSIS-RTOS. It includes defining memory pools, message queues, and threads for sending and receiving messages. ```c #include "cmsis_os.h" osThreadId tid_thread1; // ID for thread 1 osThreadId tid_thread2; // for thread 2 typedef struct { // Message object structure float voltage; // AD result of measured voltage float current; // AD result of measured current int counter; // A counter value } T_MEAS; osPoolDef(mpool, 16, T_MEAS); // Define memory pool osPoolId mpool; osMessageQDef(MsgBox, 16, &T_MEAS); // Define message queue osMessageQId MsgBox; void send_thread (void const *argument); // forward reference void recv_thread (void const *argument); // forward reference // Thread definitions osThreadDef(send_thread, osPriorityNormal, 1, 0); osThreadDef(recv_thread, osPriorityNormal, 1, 2000); // // Thread 1: Send thread // void send_thread (void const *argument) { T_MEAS *mptr; mptr = osPoolAlloc(mpool); // Allocate memory for the message mptr->voltage = 223.72; // Set the message content mptr->current = 17.54; mptr->counter = 120786; osMessagePut(MsgBox, (uint32_t)mptr, osWaitForever); // Send Message ``` -------------------------------- ### Get Unique Device ID Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Release_Notes.html Replaced HAL_GetUID() API with HAL_GetUIDw0(), HAL_GetUIDw1(), and HAL_GetUIDw2() for retrieving the unique device identifier in word-sized segments. ```c HAL_GetUIDw0(); ``` ```c HAL_GetUIDw1(); ``` ```c HAL_GetUIDw2(); ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/DSP/html/Source_2ComplexMathFunctions_2CMakeLists_8txt.html Initializes the CMake build system, sets the project name, and includes configuration files for the library. ```cmake cmake_minimum_required (VERSION 3.14) project(CMSISDSPComplexMath) include(configLib) include(configDsp) ``` -------------------------------- ### Setup OS Tick Timer Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/RTOS2/html/group__CMSIS__RTOS__TickAPI.html Configures the OS Tick timer to generate periodic interrupts at a specified frequency and sets the interrupt handler. The timer is initialized but not started; OS_Tick_Enable is used to start interrupts. ```c #define SYSTICK_IRQ_PRIORITY 0xFFU static uint8_t PendST; ``` -------------------------------- ### test_signal_converge_example Function Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/DSP/html/arm__signal__converge__example__f32_8c.html Executes the signal convergence example. This function likely orchestrates the test setup and execution. ```c arm_status test_signal_converge_example( void ) ``` -------------------------------- ### Initialize WiFi Bypass Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Driver/html/group__wifi__bypass__gr.html Example demonstrating the initialization of WiFi bypass mode, including checking capabilities and setting up the driver. Requires external definitions for Driver_WiFi0 and ARM_DRIVER_WIFI. ```c extern ARM_DRIVER_WIFI Driver_WiFi0; static ARM_DRIVER_WIFI *wifi; static ARM_ETH_MAC_ADDR own_mac_address; static void wifi_notify (uint32_t event, void *arg) { switch (event) { // ... } } void initialize_wifi_bypass (void) { ARM_WIFI_CAPABILITIES capabilities; wifi = &Driver_WiFi0; // ... } ``` -------------------------------- ### Add QSPI_PreInitConfig Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Projects/Release_Notes.html This snippet indicates the addition of a QSPI_PreInitConfig example. It is relevant for STM32446E-EVAL, STM32469I-EVAL, and STM32469I-Discovery boards. ```c Add QSPI_PreInitConfig example on STM32446E-EVAL, STM32469I-EVAL and STM32469I-Discovery boards ``` -------------------------------- ### System and Clock Configuration Code Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Core_A/html/group__system__init__gr.html Example demonstrating the usage of SystemCoreClock, SystemInit(), and SystemCoreClockUpdate() functions. ```APIDOC ## System and Clock Configuration Code Example ### Description This code example shows how to use the SystemCoreClock variable and the SystemInit() and SystemCoreClockUpdate() functions. ### Code ```c #include "[ARMCA9.h]" uint32_t coreClock_1 = 0; /* Variables to store core clock values */ uint32_t coreClock_2 = 0; int main (void) { coreClock_1 = [SystemCoreClock](group__system__init__gr.html#gaa3cd3e43291e81e795d642b79b6088e6); /* Store value of predefined SystemCoreClock */ [SystemCoreClockUpdate](group__system__init__gr.html#gae0c36a9591fe6e9c45ecb21a794f0f0f)(); /* Update SystemCoreClock according to register settings */ coreClock_2 = [SystemCoreClock](group__system__init__gr.html#gaa3cd3e43291e81e795d642b79b6088e6); /* Store value of calculated SystemCoreClock */ if (coreClock_2 != coreClock_1) { // Error Handling } while(1); } ``` ``` -------------------------------- ### Get Input Function Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/DSP/html/globals_func_g.html A utility function to retrieve input, likely for signal processing examples. Defined in arm_signal_converge_example_f32.c. ```c getinput() ``` -------------------------------- ### Initialize and Configure CAN Driver Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Driver/html/group__can__interface__gr.html This example demonstrates the initialization and configuration of the CAN driver. It includes setting the operating mode, bitrate, and other parameters. Ensure the CAN driver is properly initialized before use. ```c #include #include #include "cmsis_os.h" #include "Driver_CAN.h" // CAN Driver Controller selector #define CAN_CONTROLLER 1 // CAN Controller number #define _CAN_Driver_(n) Driver_CAN##n #define CAN_Driver_(n) _CAN_Driver_(n) extern ARM_DRIVER_CAN CAN_Driver_(CAN_CONTROLLER); #define ptrCAN (&CAN_Driver_(CAN_CONTROLLER)) uint32_t rx_obj_idx = 0xFFFFFFFFU; uint8_t rx_data[8]; ARM_CAN_MSG_INFO rx_msg_info; uint32_t tx_obj_idx = 0xFFFFFFFFU; uint8_t tx_data[8]; ARM_CAN_MSG_INFO tx_msg_info; static void Error_Handler (void) { while (1); } void CAN_SignalUnitEvent (uint32_t event) {} void CAN_SignalObjectEvent (uint32_t obj_idx, uint32_t event) { if (obj_idx == rx_obj_idx) { // If receive object event if (event == ARM_CAN_EVENT_RECEIVE) { // If message was received successfully if (ptrCAN->MessageRead(rx_obj_idx, &rx_msg_info, rx_data, 8U) > 0U) { // Read received message // process received message ... } } } if (obj_idx == tx_obj_idx) { // If transmit object event if (event == ARM_CAN_EVENT_SEND_COMPLETE) { // If message was sent successfully // acknowledge sent message ... } } } int main (void) { ARM_CAN_CAPABILITIES can_cap; ARM_CAN_OBJ_CAPABILITIES can_obj_cap; int32_t status; uint32_t i, num_objects; can_cap = ptrCAN->GetCapabilities (); // Get CAN driver capabilities num_objects = can_cap.num_objects; // Number of receive/transmit objects status = ptrCAN->Initialize (CAN_SignalUnitEvent, CAN_SignalObjectEvent); // Initialize CAN driver if (status != ARM_DRIVER_OK) { Error_Handler(); } status = ptrCAN->PowerControl (ARM_POWER_FULL); // Power-up CAN controller if (status != ARM_DRIVER_OK) { Error_Handler(); } status = ptrCAN->SetMode (ARM_CAN_MODE_INITIALIZATION); // Activate initialization mode if (status != ARM_DRIVER_OK) { Error_Handler(); } status = ptrCAN->SetBitrate (ARM_CAN_BITRATE_NOMINAL, // Set nominal bitrate 100000U, // Set bitrate to 100 kbit/s ARM_CAN_BIT_PROP_SEG(5U) | // Set propagation segment to 5 time quanta ARM_CAN_BIT_PHASE_SEG1(1U) | // Set phase segment 1 to 1 time quantum (sample point at 87.5% of bit time) ``` -------------------------------- ### Get RTOS Kernel State Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/RTOS2/html/group__CMSIS__RTOS__KernelCtrl.html Returns the current state of the RTOS kernel. This function can be safely called before the RTOS is initialized or started. ```c int main (void) { // System Initialization SystemCoreClockUpdate(); // ... ``` -------------------------------- ### Example Usage (main function) Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/DSP/html/globals_func_m.html Demonstrates the entry point for various example C files showcasing different DSP functionalities. ```APIDOC ## Example Usage (main function) ### Description The `main` function serves as the entry point for numerous example C files that demonstrate the usage of various DSP functions. ### Example Files - `arm_variance_example_f32.c` - `arm_dotproduct_example_f32.c` - `arm_convolution_example_f32.c` - `arm_sin_cos_example_f32.c` - `arm_linear_interp_example_f32.c` - `arm_signal_converge_example_f32.c` - `arm_graphic_equalizer_example_q31.c` - `arm_fir_example_f32.c` - `arm_class_marks_example_f32.c` - `arm_svm_example_f32.c` - `arm_bayes_example_f32.c` - `arm_fft_bin_example_f32.c` - `arm_matrix_example_f32.c` ### Source Files These examples are typically found within the project's source code, linked via their respective C files. ``` -------------------------------- ### VIO Initialization in main Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Driver/html/group__vio__interface__gr.html Example of calling vioInit after system initialization in the main function. Requires including the cmsis_vio.h header. ```c #include "cmsis_vio.h" // ::CMSIS Driver:VIO int main (void) { // System Initialization SystemCoreClockUpdate(); vioInit(); // ... } ``` -------------------------------- ### Kernel Information and Control API Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/RTOS2/html/rtos_api2.html Provides functions to get information about the RTOS kernel and control its state, including initialization, starting, stopping, and locking mechanisms. ```APIDOC ## Kernel Information and Control API ### Description Functions to retrieve information about the RTOS kernel and manage its state. ### Functions * **osKernelGetInfo** * Description: Get RTOS Kernel Information. * **osKernelGetState** * Description: Get the current RTOS Kernel state. * **osKernelGetSysTimerCount** * Description: Get the RTOS kernel system timer count. * **osKernelGetSysTimerFreq** * Description: Get the RTOS kernel system timer frequency. * **osKernelInitialize** * Description: Initialize the RTOS Kernel. * **osKernelLock** * Description: Lock the RTOS Kernel scheduler. * **osKernelUnlock** * Description: Unlock the RTOS Kernel scheduler. * **osKernelRestoreLock** * Description: Restore the RTOS Kernel scheduler lock state. * **osKernelResume** * Description: Resume the RTOS Kernel scheduler. * **osKernelStart** * Description: Start the RTOS Kernel scheduler. * **osKernelSuspend** * Description: Suspend the RTOS Kernel scheduler. * **osKernelGetTickCount** * Description: Get the RTOS kernel tick count. * **osKernelGetTickFreq** * Description: Get the RTOS kernel tick frequency. ``` -------------------------------- ### Get Thread Name Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/RTOS2/html/group__CMSIS__RTOS__ThreadMgmt.html Retrieves the name of the currently running thread. Returns NULL if the function is called outside of a thread context. Cannot be called from ISRs. ```c void ThreadGetName_example (void) { osThreadId_t thread_id = osThreadGetId(); const char* name = osThreadGetName(thread_id); if (name == NULL) { // Failed to get the thread name; not in a thread } } ``` -------------------------------- ### Example: Declare and Use a Memory Pool Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/RTOS/html/group__CMSIS__RTOS__PoolMgmt.html Demonstrates the steps to declare a data structure, define a memory pool for objects of that structure, create the pool, and allocate memory blocks. ```c typedef struct { uint32_t length; uint32_t width; uint32_t height; uint32_t weight; } properties_t; ``` ```c osPoolDef(object_pool, 10, properties_t); // Declare memory pool osPoolId (object_pool_id); // Memory pool ID ``` ```c object_pool_id = osPoolCreate(osPool(object_pool)); ``` ```c properties_t *object_data; object_data = (properties_t *) osPoolAlloc(object_pool_id); ``` -------------------------------- ### Global Variables Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/DSP/html/globals_vars_e.html This section details global variables found within the CMSIS-DSP library, categorized by their starting letter. It includes references to their definitions in specific example files. ```APIDOC ## Global Variables ### Description This section lists and describes global variables within the CMSIS-DSP library. The variables are organized alphabetically, and their definitions are linked to specific example files. ### Variables #### Starting with 'e' * **enable** (variable) - Defined in multiple configuration files for various examples (e.g., `arm_bayes_example/ARMCM55_FP_MVE_config.txt`, `arm_dotproduct_example/ARMCM55_FP_MVE_config.txt`). * **err_signal** (variable) - Defined in `arm_signal_converge_example_f32.c`. * **errOutput** (variable) - Defined in `arm_signal_converge_example_f32.c`. ``` -------------------------------- ### Get Current Thread ID Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/RTOS2/html/group__CMSIS__RTOS__ThreadMgmt.html Retrieves the ID of the currently running thread. This ID can be used for referencing the thread in other RTOS functions. May be called from ISRs. ```c void ThreadGetId_example (void) { osThreadId_t id; // id for the currently running thread id = osThreadGetId(); if (id == NULL) { // Failed to get the id } } ``` -------------------------------- ### Get Current USB Frame Number Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Driver/html/group__usbh__host__gr.html Retrieves the current USB frame number. This is a sequential 11-bit number derived from the last Start of Frame (SOF) packet. ```c uint16_t ARM_USBH_GetFrameNumber ( void ); ``` -------------------------------- ### Driver Initialization and Uninitialization Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Driver/html/group__mci__interface__gr.html Example code demonstrating how to initialize and uninitialize the MCI driver. ```APIDOC ## Driver Initialization ### Description Initializes the MCI driver and registers a callback function for events. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c #include "Driver_MCI.h" // ARM_MCI_SignalEvent callback function prototype void MCI_SignalEvent_Callback (uint32_t event); void init_driver (ARM_DRIVER_MCI *drv) { int32_t status; status = drv->Initialize(&MCI_SignalEvent_Callback); if (status != ARM_DRIVER_OK) { // Initialization and event callback registration failed } } ``` ### Response #### Success Response (200) None (Function returns int32_t status) #### Response Example None ## Driver Uninitialization ### Description Uninitializes the MCI driver. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c #include "Driver_MCI.h" void uninit_driver (ARM_DRIVER_MCI *drv) { int32_t status; status = drv->Uninitialize(); } ``` ### Response #### Success Response (200) None (Function returns int32_t status) #### Response Example None ``` -------------------------------- ### Delete RTOS Timer Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/RTOS2/html/group__CMSIS__RTOS__TimerMgmt.html Demonstrates how to create, start, and then delete an RTOS timer. Ensure the timer ID is valid before deletion. This function cannot be called from interrupt service routines. ```c #include "[cmsis_os2.h](cmsis__os2_8h.html)" void Timer_Callback (void *arg); // prototype for timer callback function uint32_t exec; // argument for the timer call back function void TimerDelete_example (void) { [osTimerId_t](group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34) id; // timer id osStatus_t status; // function return status // Create periodic timer exec = 1U; id = [osTimerNew](group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec)(Timer_Callback, [osTimerPeriodic](group__CMSIS__RTOS__TimerMgmt.html#gga7dc24a4c2b90334427081c3da7a71915ab3463d921dc310938094745c230f2b35), &exec, NULL); [osTimerStart](group__CMSIS__RTOS__TimerMgmt.html#gab6ee2859ea657641b7adfac599b8121d)(id, 1000U); // start timer status = [osTimerDelete](group__CMSIS__RTOS__TimerMgmt.html#gad0001dd74721ab461789324806db2453)(id); // stop and delete timer if (status != [osOK](cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f)) { // Timer could not be deleted } } ``` -------------------------------- ### SystemInit() Function Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Core_A/html/globals_s.html Initializes the system clock and memory system upon startup. ```APIDOC ## SystemInit() Function ### Description This function is called automatically at the beginning of program execution (before main()). It initializes the system clock, PLL, and memory system according to the configuration defined in the device's header file. It also sets the initial value for the SystemCoreClock variable. ### Source Files - [system_ARMCA9.h](system_ARMCA9_8h.html#a93f514700ccf00d08dbdcff7f1224eb2) - [Ref_SystemAndClock.txt](group__system__init__gr.html#ga93f514700ccf00d08dbdcff7f1224eb2) ``` -------------------------------- ### Thread Creation API Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/RTOS/html/group__CMSIS__RTOS__ThreadMgmt.html This section details the osThreadCreate function for creating and starting new threads. It includes information on thread definitions, arguments, return values, and a code example. ```APIDOC ## osThreadCreate ### Description Starts a thread function by adding it to the Active Threads list and setting it to state READY. The thread function receives the argument pointer as a function argument when the function is started. When the priority of the created thread function is higher than the current RUNNING thread, the created thread function starts instantly and becomes the new RUNNING thread. Note: Cannot be called from Interrupt Service Routines. ### Method `osThreadCreate` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **thread_def** (*const osThreadDef_t*) - Input - Thread definition referenced with `osThread`. - **argument** (*void wo*) - Input - Pointer that is passed to the thread function as start argument. ### Request Example ```c #include "cmsis_os.h" void Thread_1 (void const *arg); [osThreadDef](group__CMSIS__RTOS__ThreadMgmt.html#gaee93d929beb350f16e5cc7fa602e229f) (Thread_1, [osPriorityNormal](cmsis__os_8h.html#ga7f2b42f1983b9107775ec2a1c69a849aa45a2895ad30c79fb97de18cac7cc19f1), 1, 0); void ThreadCreate_example (void) { [osThreadId](cmsis__os_8h.html#adfeb153a84a81309e2d958268197617f) id; id = [osThreadCreate](group__CMSIS__RTOS__ThreadMgmt.html#gac59b5713cb083702dce759c73fd90dff) ([osThread](group__CMSIS__RTOS__ThreadMgmt.html#gaf0c7c6b5e09f8be198312144b5c9e453) (Thread_1), NULL); if (id == NULL) { // handle thread creation // Failed to create a thread } // ... [osThreadTerminate](group__CMSIS__RTOS__ThreadMgmt.html#gaea135bb90eb853eff39e0800b91bbeab) (id); // stop the thread } ``` ### Response #### Success Response (200) - **thread ID** (*osThreadId*) - A reference ID for the created thread, or NULL in case of error. #### Response Example ```json { "thread_id": "0x12345678" } ``` ``` -------------------------------- ### Flash Driver Initialization and Usage Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Driver/html/group__flash__interface__gr.html Example code demonstrating how to initialize, configure, and use the Flash driver with CMSIS-RTOS2. ```APIDOC ## Example Code ### Description This example demonstrates a typical setup sequence for the Flash driver, including initialization, power control, data read, and uninitialization, using CMSIS-RTOS2 for event handling. ### Method N/A (Example Code) ### Endpoint N/A ### Request Body N/A ### Request Example N/A ### Response N/A ### Response Example N/A ```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 (); } ``` ``` -------------------------------- ### CMSIS-RTOS Thread and Kernel Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/RTOS/html/usingOS.html This C code demonstrates how to define and create threads using CMSIS-RTOS functions, initialize the RTOS kernel, and start its execution. Ensure the cmsis_os.h header is included. ```c #include "cmsis_os.h" // CMSIS-RTOS header file void job1 (void const *argument) { // thread function 'job1' while (1) { : // execute some code osDelay (10); // delay execution for 10 milliseconds } } osThreadDef(job1, osPriorityAboveNormal, 1, 0); // define job1 as thread function void job2 (void const *argument) { // thread function 'job2' osThreadCreate (osThread(job1),NULL); // create job1 thread while (1) { : // execute some code } } osThreadDef(job2, osPriorityNormal, 1, 0); // define job2 as thread function void job3 (void const *argument) { // thread function 'job3' while (1) { : // execute some code osDelay (20); // delay execution for 20 milliseconds } } osThreadDef(job3, osPriorityNormal, 1, 0); // define job3 as thread function int main (void) { // program execution starts here osKernelInitialize (); // initialize RTOS kernel : // setup and initialize peripherals osThreadCreate (osThread(job2)); osThreadCreate (osThread(job3)); osKernelStart (); // start kernel with job2 execution } ``` -------------------------------- ### Get TTBR0 Register Value Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Core_A/html/group__CMSIS__TTBR.html Use this function to retrieve the current value of the Translation Table Base Register 0. No specific setup is required beyond including the necessary CMSIS-Core headers. ```c __STATIC_FORCEINLINE uint32_t __get_TTBR0 (void) ``` -------------------------------- ### startup_ARMCA9.c Functions Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Core_A/html/startup__ARMCA9_8c.html Provides essential functions for system initialization and exception handling. ```APIDOC ## Functions ### Vectors #### Description Handles the vector table for the Cortex-A9 processor. #### Signature `void Vectors(void)` ### Reset_Handler #### Description The entry point for the system after reset. Initializes the system and calls the main application. #### Signature `void Reset_Handler(void)` ### Default_Handler #### Description A generic handler for unassigned interrupts or exceptions. #### Signature `void Default_Handler(void)` ``` -------------------------------- ### ARM Signal Converge Example (f32) Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/DSP/html/arm__dotproduct__example__f32_8c.html Illustrates a signal convergence algorithm using 32-bit floating-point data. ```c #include "arm_math.h" int main() { /* Example usage of arm_signal_converge_f32 */ return 0; } ``` -------------------------------- ### SPI Driver Example with RTOS Integration Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/Driver/html/group__spi__interface__gr.html This example demonstrates the usage of the SPI driver in a multithreaded application using the CMSIS-RTOS. It includes setup for a thread, a callback function to handle SPI events like transfer completion or data loss, and basic version checking for the driver API. Ensure the 'cmsis_os.h' header is included for RTOS functionality. ```c #include "Driver_SPI.h" #include "cmsis_os.h" // ARM::CMSIS:RTOS:Keil RTX void mySPI_Thread(void const *argument); osThreadId tid_mySPI_Thread; /* SPI Driver */ extern ARM_DRIVER_SPI Driver_SPI0; void mySPI_callback(uint32_t event) { switch (event) { case ARM_SPI_EVENT_TRANSFER_COMPLETE: /* Success: Wakeup Thread */ osSignalSet(tid_mySPI_Thread, 0x01); break; case ARM_SPI_EVENT_DATA_LOST: /* Occurs in slave mode when data is requested/sent by master but send/receive/transfer operation has not been started and indicates that data is lost. Occurs also in master mode when driver cannot transfer data fast enough. */ __breakpoint(0); /* Error: Call debugger or replace with custom error handling */ break; case ARM_SPI_EVENT_MODE_FAULT: /* Occurs in master mode when Slave Select is deactivated and indicates Master Mode Fault. */ __breakpoint(0); /* Error: Call debugger or replace with custom error handling */ break; } } /* Test data buffers */ 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; } ``` -------------------------------- ### I2C Configuration Example (Conceptual) Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Projects/STM32469I-Discovery/Examples/I2C/I2C_TwoBoards_RestartComIT/readme.txt This snippet represents a conceptual I2C configuration. Actual configuration details, including instance and associated resources, should be updated in the 'main.h' file based on the specific hardware setup. ```c /* I2C1 init function */ if (HAL_I2C_Init(&hi2c1) != HAL_OK) { Error_Handler(); } ``` -------------------------------- ### CAN Loopback Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Projects/STM32CubeProjectsList.html Shows how to set up communication with the CAN peripheral in loopback mode. This example is available for specific STM32 evaluation boards. ```c /* CAN Loopback example */ /* How to set up a communication with the CAN in loopback mode. */ ``` -------------------------------- ### Application Main Thread Setup for RTX5 Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/RTOS2/html/os2MigrationGuide.html Adapt the main function to initialize the system, update the system core clock, initialize the CMSIS-RTOS kernel, create the application main thread, and start the RTOS scheduler. Ensure RTX_Config.h is configured appropriately. ```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](cmsis__os2_8h.html#gad4e3e0971b41f2d17584a8c6837342eca45a2895ad30c79fb97de18cac7cc19f1), 1, 0); int main (void) { // System Initialization SystemCoreClockUpdate(); // ... [osKernelInitialize](group__CMSIS__RTOS__KernelCtrl.html#gae818f6611d25ba3140bede410a52d659)(); osThreadCreate(osThread(app_main), NULL); [osKernelStart](group__CMSIS__RTOS__KernelCtrl.html#ga9ae2cc00f0d89d7b6a307bba942b5221)(); for (;;); } ``` -------------------------------- ### FFT Bin Example Source: https://github.com/stmicroelectronics/stm32cubef4/blob/master/Drivers/CMSIS/Documentation/DSP/html/globals_vars_r.html Example illustrating how to perform a Fast Fourier Transform (FFT) and extract specific frequency bins. ```c refIndex ```