### FFT Bin Example Setup Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/DSP/html/arm_fft_bin_example_f32_8c-example.html Initializes the necessary headers, constants, and global variables for performing an FFT bin analysis. ```c #include "arm_math.h" #include "arm_const_structs.h" #define TEST_LENGTH_SAMPLES 2048 /* ------------------------------------------------------------------- * External Input and Output buffer Declarations for FFT Bin Example * ------------------------------------------------------------------- */ extern float32_t testInput_f32_10khz[TEST_LENGTH_SAMPLES]; static float32_t testOutput[TEST_LENGTH_SAMPLES/2]; /* ------------------------------------------------------------------ * Global variables for FFT Bin Example * ------------------------------------------------------------------- */ uint32_t fftSize = 1024; uint32_t ifftFlag = 0; uint32_t doBitReverse = 1; /* Reference index at which max energy of bin ocuurs */ uint32_t refIndex = 213, testIndex = 0; ``` -------------------------------- ### Adaptive Filter Convergence Example Setup Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/DSP/html/arm_signal_converge_example_f32_8c-example.html Initializes global defines, FIR state buffers, and LMSNorm structures for the adaptive filter simulation. ```c #include "arm_math.h" #include "math_helper.h" /* ---------------------------------------------------------------------- ** Global defines for the simulation * ------------------------------------------------------------------- */ #define TEST_LENGTH_SAMPLES 1536 #define NUMTAPS 32 #define BLOCKSIZE 32 #define DELTA_ERROR 0.000001f #define DELTA_COEFF 0.0001f #define MU 0.5f #define NUMFRAMES (TEST_LENGTH_SAMPLES / BLOCKSIZE) /* ---------------------------------------------------------------------- * Declare FIR state buffers and structure * ------------------------------------------------------------------- */ float32_t firStateF32[NUMTAPS + BLOCKSIZE]; arm_fir_instance_f32 LPF_instance; /* ---------------------------------------------------------------------- * Declare LMSNorm state buffers and structure * ------------------------------------------------------------------- */ float32_t lmsStateF32[NUMTAPS + BLOCKSIZE]; ``` -------------------------------- ### GET /package/examples/example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Pack/html/pdsc_examples_pg.html Retrieves details for a specific example project, including its name, folder path, documentation, and associated board/project files. ```APIDOC ## GET /package/examples/example ### Description An example section is used to provide the required information for accessing an example project contained in a Pack. ### Attributes - **name** (xs:string) - Required - Name of the example - **folder** (xs:string) - Required - Relative path to the example base folder - **archive** (xs:string) - Optional - Filename of the archive file - **doc** (xs:string) - Required - Document that describes the example - **version** (VersionType) - Optional - Example version number - **public** (xs:boolean) - Optional - Set publishing permissions for the documentation ### Child Elements - **description** (xs:string) - Required - Briefly documents the purpose and scope - **board** (BoardReferenceType) - Required - Reference to a board description - **project** (ExampleProjectType) - Required - Project files for different environments - **attributes** (ExampleAttributesType) - Required - Group element for project attributes ``` -------------------------------- ### System Initialization Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Core_A/html/group__system__init__gr.html Example demonstrating the usage of SystemCoreClock, SystemInit, and SystemCoreClockUpdate. ```APIDOC ## System Initialization Code Example ### Description This 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; /* Store value of predefined SystemCoreClock */ SystemCoreClockUpdate(); /* Update SystemCoreClock according to register settings */ coreClock_2 = SystemCoreClock; /* Store value of calculated SystemCoreClock */ if (coreClock_2 != coreClock_1) { // Error Handling } while(1); } ``` ``` -------------------------------- ### Linear Interpolation Example Setup Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/DSP/html/arm_linear_interp_example_f32_8c-example.html Includes necessary headers and defines constants for the linear interpolation test, including input data and reference output values. ```c #include "arm_math.h" #include "math_helper.h" #define SNR_THRESHOLD 90 #define TEST_LENGTH_SAMPLES 10 #define XSPACING (0.00005f) /* ---------------------------------------------------------------------- * Test input data for F32 SIN function * Generated by the MATLAB rand() function * randn('state', 0) * xi = (((1/4.18318581819710)* randn(blockSize, 1) * 2* pi)); * --------------------------------------------------------------------*/ float32_t testInputSin_f32[TEST_LENGTH_SAMPLES] = { -0.649716504673081170, -2.501723745497831200, 0.188250329003310100, 0.432092748487532540, -1.722010988459680800, 1.788766476323060600, 1.786136060975809500, -0.056525543169408797, 0.491596272728153760, 0.262309671126153390 }; /*------------------------------------------------------------------------------ * Reference out of SIN F32 function for Block Size = 10 * Calculated from sin(testInputSin_f32) *------------------------------------------------------------------------------*/ float32_t testRefSinOutput32_f32[TEST_LENGTH_SAMPLES] = { -0.604960695383043530, -0.597090287967934840, 0.187140422442966500, 0.418772124875992690, -0.988588831792106880, 0.976338412038794010, 0.976903856413481100, -0.056495446835214236, 0.472033731854734240, 0.259311907228582830 }; ``` -------------------------------- ### USART Asynchronous Communication Setup Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Driver/html/group__usart__interface__gr.html Example demonstrating the inclusion of necessary headers and the declaration of a USART driver instance and callback function. ```c #include "Driver_USART.h" #include "cmsis_os.h" /* ARM::CMSIS:RTOS:Keil RTX */ #include #include void myUART_Thread(void const *argument); osThreadId tid_myUART_Thread; /* USART Driver */ extern ARM_DRIVER_USART Driver_USART3; void myUSART_callback(uint32_t event) { uint32_t mask; ``` -------------------------------- ### Timer Stop Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/RTOS/html/group__CMSIS__RTOS__TimerMgmt.html Full example demonstrating the definition, creation, starting, stopping, and restarting of a timer. ```C #include "[cmsis_os.h](cmsis__os_8h.html)" void Timer_Callback (void const *arg); // prototype for timer callback function [osTimerDef](group__CMSIS__RTOS__TimerMgmt.html#ga1c720627e08d1cc1afcad44e799ed492) (Timer, Timer_Callback); // define timer void TimerStop_example (void) { [osTimerId](cmsis__os_8h.html#ab8530dd4273f1f5382187732e14fcaa7) id; // timer id [osStatus](group__CMSIS__RTOS__Status.html#gae2e091fefc4c767117727bd5aba4d99e) status; // function return status // Create periodic timer exec = 1; id = [osTimerCreate](group__CMSIS__RTOS__TimerMgmt.html#gaedd312bfdca04e0b8162b666e09a1ae6) ([osTimer](group__CMSIS__RTOS__TimerMgmt.html#ga1b8d670eaf964b2910fa06885e650678)(Timer2), [osTimerPeriodic](group__CMSIS__RTOS__TimerMgmt.html#gadac860eb9e1b4b0619271e6595ed83d9ab9c91f9699162edb09bb7c90c11c8788), NULL); [osTimerStart](group__CMSIS__RTOS__TimerMgmt.html#ga27a797a401b068e2644d1125f22a07ca) (id, 1000); // start timer : status = [osTimerStop](group__CMSIS__RTOS__TimerMgmt.html#ga58f36b121a812936435cacc6e1e0e091) (id); // stop timer if (status != [osOK](group__CMSIS__RTOS__Status.html#gae2e091fefc4c767117727bd5aba4d99ea9e1c9e2550bb4de8969a935acffc968f)) { // Timer could not be stopped } : [osTimerStart](group__CMSIS__RTOS__TimerMgmt.html#ga27a797a401b068e2644d1125f22a07ca) (id, 1000); // start timer again } ``` -------------------------------- ### System and Clock Configuration Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Core/html/group__system__init__gr.html Example demonstrating the usage of SystemCoreClock, SystemInit, and SystemCoreClockUpdate functions. ```APIDOC ## System and Clock Configuration Example ### Description This code example shows how to use the [SystemCoreClock](group__system__init__gr.html#gaa3cd3e43291e81e795d642b79b6088e6) variable and the [SystemInit()](group__system__init__gr.html#ga93f514700ccf00d08dbdcff7f1224eb2) and [SystemCoreClockUpdate()](group__system__init__gr.html#gae0c36a9591fe6e9c45ecb21a794f0f0f) functions. ### Method C ### Endpoint N/A ### Parameters None ### Request Body None ### Response None ### Success Response (200) N/A ### Request Example ```c #include "LPC17xx.h" uint32_t coreClock_1 = 0; /* Variables to store core clock values */ uint32_t coreClock_2 = 0; int main (void) { coreClock_1 = SystemCoreClock; /* Store value of predefined SystemCoreClock */ SystemCoreClockUpdate(); /* Update SystemCoreClock according to register settings */ coreClock_2 = SystemCoreClock; /* Store value of calculated SystemCoreClock */ if (coreClock_2 != coreClock_1) { /* Without changing the clock setting both core clock values should be the same */ // Error Handling } while(1); } ``` ``` -------------------------------- ### Define Example Project Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Pack/html/cp_SWComponents.html Define an example project with its name, documentation, board, environment, and component attributes. ```xml CMSIS-RTOS based example ``` -------------------------------- ### GET /package/examples Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Pack/html/pdsc_examples_pg.html Retrieves the grouping element for all examples contained within a CMSIS-Pack. Only one such group can exist in a single pack. ```APIDOC ## GET /package/examples ### Description Grouping element for examples. No more than one such group can exist in a Pack. ### Child Elements - **example** (ExampleType) - 1..* - Description of fully specified project ``` -------------------------------- ### Create Mutex Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/RTOS/html/group__CMSIS__RTOS__MutexMgmt.html Example showing how to define and create a mutex object. ```c #include "cmsis_os.h" osMutexDef (MutexIsr); // Mutex name definition void CreateMutex (void) { osMutexId mutex_id; mutex_id = osMutexCreate (osMutex (MutexIsr)); if (mutex_id != NULL) { // Mutex object created } } ``` -------------------------------- ### Thread Terminate Example Setup Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/RTOS2/html/group__CMSIS__RTOS__ThreadMgmt.html This code sets up the necessary components for demonstrating the osThreadTerminate function. It includes the header and declares a thread ID and status variable. The osThreadTerminate function itself is not shown here but would be called subsequently. ```c #include "cmsis_os2.h" void Thread_1 (void *arg); // function prototype for Thread_1 void ThreadTerminate_example (void) { osStatus_t status; osThreadId_t id; ``` -------------------------------- ### Kernel Initialization and Start Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/RTOS/html/group__CMSIS__RTOS__KernelCtrl.html Demonstrates the basic steps to initialize and start the CMSIS-RTOS kernel within a main function. ```APIDOC ## Initialize and Start the RTOS Kernel ### Description This section shows how to initialize the CMSIS-RTOS kernel and then start the thread execution. ### Method C Code Example ### Endpoint N/A ### Parameters 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 ``` -------------------------------- ### Add Example Project Release Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Pack/html/cp_SWComponents.html Add a new version number for example projects in the PDSC file. ```xml Example project added ``` -------------------------------- ### Define a Board for an Example Project Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Pack/html/pdsc_examples_pg.html Specifies the board compatible with the example project using vendor and name attributes. ```xml ``` -------------------------------- ### Package Index File (pidx) Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Pack/html/packIndexFile.html Example of a vendor-specific package index file listing hosted CMSIS-Packs. ```xml MyVendor http://www.MyVendor.com/pack/ 2017-01-25T15:00:10.7300074+00:00 ... ``` -------------------------------- ### Full Configuration Wizard Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Pack/html/configWizard.html A comprehensive example demonstrating thread, timer, and system configuration settings using the Configuration Wizard syntax. ```C //-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- // // Thread Configuration // ======================= // // Number of concurrent running threads <0-250> // Defines max. number of threads that will run at the same time. // Default: 6 #ifndef OS_TASKCNT #define OS_TASKCNT 6 #endif // Default Thread stack size [bytes] <64-4096:8><#/4> // Defines default stack size for threads with osThreadDef stacksz = 0 // Default: 200 #ifndef OS_STKSIZE #define OS_STKSIZE 50 #endif // Main Thread stack size [bytes] <64-32768:8><#/4> // Defines stack size for main thread. // Default: 200 #ifndef OS_MAINSTKSIZE #define OS_MAINSTKSIZE 50 #endif // Number of threads with user-provided stack size <0-250> // Defines the number of threads with user-provided stack size. // Default: 0 #ifndef OS_PRIVCNT #define OS_PRIVCNT 0 #endif // Total stack size [bytes] for threads with user-provided stack size <0-1048576:8><#/4> // Defines the combined stack size for threads with user-provided stack size. // Default: 0 #ifndef OS_PRIVSTKSIZE #define OS_PRIVSTKSIZE 0 #endif // Check for stack overflow // Includes the stack checking code for stack overflow. // Note that additional code reduces the Kernel performance. #ifndef OS_STKCHECK #define OS_STKCHECK 1 #endif // Processor mode for thread execution // <0=> Unprivileged mode // <1=> Privileged mode // Default: Privileged mode #ifndef OS_RUNPRIV #define OS_RUNPRIV 1 #endif // // RTX Kernel Timer Tick Configuration // ====================================== // Use Cortex-M SysTick timer as RTX Kernel Timer // Use the Cortex-M SysTick timer as a time-base for RTX. #ifndef OS_SYSTICK #define OS_SYSTICK 1 #endif // // Timer clock value [Hz] <1-1000000000> // Defines the timer clock value. // Default: 12000000 (12MHz) #ifndef OS_CLOCK #define OS_CLOCK 12000000 #endif // Timer tick value [us] <1-1000000> // Defines the timer tick value. // Default: 1000 (1ms) #ifndef OS_TICK #define OS_TICK 1000 #endif // // System Configuration // ======================= // // Round-Robin Thread switching // =============================== // // Enables Round-Robin Thread switching. #ifndef OS_ROBIN #define OS_ROBIN 1 #endif // Round-Robin Timeout [ticks] <1-1000> // Defines how long a thread will execute before a thread switch. // Default: 5 #ifndef OS_ROBINTOUT #define OS_ROBINTOUT 5 #endif // // User Timers // ============== // Enables user Timers #ifndef OS_TIMERS #define OS_TIMERS 1 #endif // Timer Thread Priority // <1=> Low // <2=> Below Normal <3=> Normal <4=> Above Normal // <5=> High // <6=> Realtime (highest) // Defines priority for Timer Thread // Default: High ``` -------------------------------- ### FmBlock - Get Start Address Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Zone/genmodel/com/arm/cmsis/zone/gen/data/FmBlock.html Retrieves the starting memory address of the block. ```APIDOC ## GET /fmblock/start ### Description Get the start address of this block. ### Method GET ### Endpoint /fmblock/start ### Response #### Success Response (200) - **startAddress** (long) - The starting address of the block. ### Response Example ```json { "startAddress": 16777216 } ``` ``` -------------------------------- ### Memory Configuration Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Pack/html/cpdsc_pg.html Defines a read-write memory region named IRAM2 with a specific size and starting address. ```xml ``` -------------------------------- ### Initialize and Configure Ethernet PHY Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Driver/html/group__eth__phy__interface__gr.html Full example demonstrating the initialization of the MAC and PHY, setting the interface, and configuring the PHY mode. ```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); if (status != ARM_DRIVER_OK) ... // error handling status = phy->SetMode (ARM_ETH_PHY_SPEED_100M | ARM_ETH_PHY_DUPLEX_FULL | ARM_ETH_PHY_ISOLATE); if (status != ARM_DRIVER_OK) ... // error handling ``` -------------------------------- ### Initialize and Use Flash Driver Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Driver/html/group__flash__interface__gr.html Demonstrates a typical setup sequence for the Flash driver, including initialization with a callback, power control, reading data, and uninitialization. Use this when integrating flash memory operations into an RTOS environment. ```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 (); } ``` -------------------------------- ### Get RTOS Kernel State Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/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(); // ... ``` -------------------------------- ### Timer Creation Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/RTOS/html/group__CMSIS__RTOS__TimerMgmt.html Demonstrates the full workflow of defining callback functions, timer definitions, and creating timers. ```C #include "cmsis_os.h" void Timer1_Callback (void const *arg); // prototypes for timer callback function void Timer2_Callback (void const *arg); osTimerDef (Timer1, Timer1_Callback); // define timers osTimerDef (Timer2, Timer2_Callback); uint32_t exec1; // argument for the timer call back function uint32_t exec2; // argument for the timer call back function void TimerCreate_example (void) { osTimerId id1; // timer id osTimerId id2; // timer id // Create one-shoot timer exec1 = 1; ``` -------------------------------- ### Implement Thread Communication with Mail Queues Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/RTOS/html/group__CMSIS__RTOS__Mail.html Example showing a receiver thread processing mail and an application setup function creating queues and threads. ```c void recv_thread (void const *argument) { T_MEAS *rptr; osEvent evt; for (;;) { evt = osMailGet(mail, osWaitForever); // wait for mail if (evt.status == osEventMail) { rptr = evt.value.p; printf ("\nVoltage: %.2f V\n", rptr->voltage); printf ("Current: %.2f A\n", rptr->current); printf ("Number of cycles: %d\n", rptr->counter); osMailFree(mail, rptr); // free memory allocated for mail } } } void StartApplication (void) { mail = osMailCreate(osMailQ(mail), NULL); // create mail queue tid_thread1 = osThreadCreate(osThread(send_thread), NULL); tid_thread2 = osThreadCreate(osThread(recv_thread), NULL); : } ``` -------------------------------- ### Linear Interpolate Example F32 Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/DSP/html/group__LinearInterpExample.html This C code example demonstrates the usage of the arm_linear_interp_f32 function for linear interpolation and compares its results with calculations from the arm_sin_f32 function. It includes setup for input data, reference sine values, and output buffers for both methods, along with SNR calculations. ```c #include "arm_math.h" #include /*--------------------------------------------------------------------------------------------------------------*/ /* Linear Interpolate Example */ /*--------------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------------------------*/ /* Test Input Data */ /*--------------------------------------------------------------------------------------------------------------*/ /* Input values for sine calculation */ const float32_t testInputSin_f32[10] = { 0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.5f }; /* Reference sine output values calculated from sin() matlab function */ const float32_t testRefSinOutput32_f32[10] = { 0.00000000f, 0.47942554f, 0.84147098f, 0.99749499f, 0.90929743f, 0.59847214f, 0.14112001f, -0.35078323f, -0.75680250f, -0.95081272f }; /*--------------------------------------------------------------------------------------------------------------*/ /* Test Output Data */ /*--------------------------------------------------------------------------------------------------------------*/ /* Output buffer for calculation from cubic interpolation */ float32_t testOutput[10]; /* Output buffer for calculation from linear interpolation */ float32_t testLinIntOutput[10]; /* Signal to noise ratio for reference and cubic interpolation output */ float32_t snr1; /* Signal to noise ratio for reference and linear interpolation output */ float32_t snr2; /*--------------------------------------------------------------------------------------------------------------*/ /* Function Definitions */ /*--------------------------------------------------------------------------------------------------------------*/ /** * @brief Linear Interpolate Example * @param[in] none * @return function returns 0 */ int32_t main(void) { /* Call the bilinear interpolation example function */ snr1 = arm_linear_interp_example_f32(testInputSin_f32, testRefSinOutput32_f32, testOutput, testLinIntOutput, snr1, snr2); /* Call the bilinear interpolation example function */ snr2 = arm_linear_interp_example_f32(testInputSin_f32, testRefSinOutput32_f32, testOutput, testLinIntOutput, snr1, snr2); /* return 0 always */ return 0; } /** * @brief Processing function for the Linear Interpolate example. * @param[in] pSrc Pointer to the input buffer * @param[in] pRef Pointer to the reference output buffer * @param[out] pOut Pointer to the cubic interpolation output buffer * @param[out] pLinOut Pointer to the linear interpolation output buffer * @param[in] snr1 Signal to noise ratio for reference and cubic interpolation output * @param[in] snr2 Signal to noise ratio for reference and linear interpolation output * @return function returns 0 */ float32_t arm_linear_interp_example_f32(const float32_t * pSrc, const float32_t * pRef, float32_t * pOut, float32_t * pLinOut, float32_t snr1, float32_t snr2) { uint32_t i; float32_t snr_val; /*---------------------------------------------------------------------- * Initializing the value of Sin function with cubic interpolation *----------------------------------------------------------------------*/ /* Calculate the output values using the cubic interpolation */ for (i = 0; i < 10; i++) { pOut[i] = arm_sin_f32(pSrc[i]); } /* Calculate the SNR value for the cubic interpolation */ snr_val = arm_snr_f32(pRef, pOut, 10); /*---------------------------------------------------------------------- * Initializing the value of Sin function with linear interpolation *----------------------------------------------------------------------*/ /* Calculate the output values using the linear interpolation */ for (i = 0; i < 10; i++) { pLinOut[i] = arm_linear_interp_f32(pSrc[i], &testInputSin_f32[0], &testRefSinOutput32_f32[0], 10); } /* Calculate the SNR value for the linear interpolation */ snr_val = arm_snr_f32(pRef, pLinOut, 10); /* Return the snr value */ return snr_val; } ``` -------------------------------- ### CAN Interface Usage Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Driver/html/group__can__interface__gr.html Demonstrates initializing the CAN driver, configuring bitrate, and handling events via signal callbacks. ```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) ``` -------------------------------- ### int32_t main() Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/DSP/html/arm__signal__converge__example__f32_8c.html Main entry point for the signal convergence example. ```APIDOC ## int32_t main ### Description Main execution function for the signal convergence example. ### Response - **return** (int32_t) - Execution status code. ``` -------------------------------- ### Configure Timer Interrupt and Enable Timer Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Core/html/group__NVIC__gr.html Sets up Timer0 for a 1ms interrupt, enables the interrupt in the NVIC, and starts the timer. This example assumes SystemCoreClock is defined. ```c #include "LPC17xx.h" uint32_t active; void TIMER0_IRQHandler(void) { /* Timer 0 interrupt handler */ if (LPC_TIM0->IR & (1 << 0)) { /* Check if interrupt for match channel 0 occured */ LPC_TIM0->IR |= (1 << 0); /* Acknowledge interrupt for match channel 0 occured */ } active = NVIC_GetActive(TIMER0_IRQn); /* Get interrupt active state of timer 0 */ } int main (void) { /* Set match channel register MR0 to 1 millisecond */ LPC_TIM0->MR0 = (((SystemCoreClock / 1000) / 4) - 1); /* 1 ms? */ LPC_TIM0->MCR = (3 << 0); /* Enable interrupt and reset for match channel MR0 */ NVIC_EnableIRQ(TIMER0_IRQn); /* Enable NVIC interrupt for timer 0 */ LPC_TIM0->TCR = (1 << 0); /* Enable timer 0 */ while(1); } ``` -------------------------------- ### DAP_SETUP Initialization Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/DAP/html/group__DAP__Config__Initialization__gr.html Initializes the Debug Unit I/O pins and LEDs. ```APIDOC ## DAP_SETUP ### Description Setup of the Debug Unit I/O pins and LEDs (called when Debug Unit is initialized). This function performs the initialization of the CMSIS-DAP Hardware I/O Pins and the Status LEDs. In detail the operation of Hardware I/O and LED pins are enabled and set: * I/O clock system enabled. * all I/O pins: input buffer enabled, output pins are set to HighZ mode. * for nTRST, nRESET a weak pull-up (if available) is enabled. * LED output pins are enabled and LEDs are turned off. ### Method STATIC_INLINE void ### Endpoint N/A (Function call) ### Parameters None ### Request Example ```c DAP_SETUP(); ``` ### Response None ``` -------------------------------- ### PDSC File URL Example (File URI) Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Pack/html/cp_SWComponents.html Illustrates how to specify a local file URI for the pack's URL, marking it as offline in the Pack Installer. This is useful for local development and testing. ```xml file:///c:/temp/working ``` -------------------------------- ### osKernelStart Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/RTOS/html/group__CMSIS__RTOS__KernelCtrl.html Starts the RTOS Kernel and begins thread switching. ```APIDOC ## osKernelStart ### Description Starts the RTOS Kernel and begins thread switching. Cannot be called from Interrupt Service Routines. ### Returns - **osStatus** - osOK if successfully started, osErrorISR if called from an ISR. ``` -------------------------------- ### ADC DMA Transfer Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Projects/STM32CubeProjectsList.html Configures and uses the ADC for converting external analog input, retrieving results via DMA transfer using the HAL API. Requires DMA and ADC setup. ```c How to configure and use the ADC to convert an external analog input and get the result using a DMA transfer through the HAL API. ``` -------------------------------- ### Setup OS Tick Timer Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/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; the RTOS kernel enables interrupts later. ```c #ifndef SYSTICK_IRQ_PRIORITY #define SYSTICK_IRQ_PRIORITY 0xFFU #endif static uint8_t PendST; ``` -------------------------------- ### Set Ethernet Media Interface Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Driver/html/group__eth__phy__interface__gr.html Demonstrates how to retrieve MAC capabilities and configure the PHY media interface accordingly. ```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); ``` -------------------------------- ### Get Alternate Hardware Timer Overflow Flag Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/RTOS/html/group__RTX__Global__Functions.html Returns the overflow flag of the alternate hardware timer. A return value of 1 indicates an overflow, while 0 indicates no overflow. This function is intended for use with an alternate timer setup. ```c #include "LPC43xx.h" // Device header uint32_t os_tick_ovf (void) { return (LPC_RITIMER->CTRL); } ``` -------------------------------- ### Configure and Enable MPU Region Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Core/html/group__mpu__functions.html Example demonstrating how to set up a specific MPU region using ARM_MPU_SetRegionEx and enabling the MPU. ```c void main() { // Set Region 0 ARM_MPU_SetRegionEx(0UL, 0x08000000UL, MPU_RASR(0UL, ARM_MPU_AP_FULL, 0UL, 0UL, 1UL, 1UL, 0x00UL, ARM_MPU_REGION_SIZE_1MB)); ARM_MPU_Enable(0); // Execute application code that is access protected by the MPU ARM_MPU_Disable(); } ``` -------------------------------- ### COMP Output Blanking Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Projects/STM32CubeProjectsList.html Demonstrates the comparator peripheral's output blanking feature, useful in motor control to prevent tripping due to short current spikes at the PWM period's start. Requires comparator and timer configuration. ```c How to use the comparator-peripheral output blanking feature. The purpose of the output blanking feature in motor control is to prevent tripping of the current regulation upon short current spikes at the beginning of the PWM period. ``` -------------------------------- ### EvrRtxKernelStart Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/RTOS2/html/group__rtx__evr__kernel.html Tracks the initiation of the kernel start process. ```c void EvrRtxKernelStart ( void ) ``` -------------------------------- ### Implement SPI Interface Usage Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Driver/html/theoryOperation.html A complete example showing SPI initialization, callback handling for events, and thread-based data transfer. ```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; } 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 */ ``` -------------------------------- ### Iterate Over Memory Blocks in FreeMarker Template Source: https://github.com/stmicroelectronics/stm32cubef3/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 listing the name, start address, and size of each block. Ensure the 'blocks' variable is available in the template context. ```ftl <#list blocks as block>
Name Start Size
${block.name} ${block.start} ${block.size}
``` -------------------------------- ### Create and Start a Timer Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/RTOS/html/group__CMSIS__RTOS__TimerMgmt.html Demonstrates the initialization and activation of a periodic timer using osTimerCreate and osTimerStart. ```C id = [osTimerCreate](group__CMSIS__RTOS__TimerMgmt.html#gaedd312bfdca04e0b8162b666e09a1ae6) ([osTimer](group__CMSIS__RTOS__TimerMgmt.html#ga1b8d670eaf964b2910fa06885e650678)(Timer), [osTimerPeriodic](group__CMSIS__RTOS__TimerMgmt.html#gadac860eb9e1b4b0619271e6595ed83d9ab9c91f9699162edb09bb7c90c11c8788), &exec); if (id) { timerDelay = 1000; status = [osTimerStart](group__CMSIS__RTOS__TimerMgmt.html#ga27a797a401b068e2644d1125f22a07ca) (id, timerDelay); // start timer if (status != [osOK](group__CMSIS__RTOS__Status.html#gae2e091fefc4c767117727bd5aba4d99ea9e1c9e2550bb4de8969a935acffc968f)) { // Timer could not be started } } ``` -------------------------------- ### Kernel Initialization and Start Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/RTOS2/html/group__CMSIS__RTOS__KernelCtrl.html Functions for initializing and starting the CMSIS-RTOS kernel. The kernel must be initialized before it can be started, and at least one thread should be created prior to starting. ```APIDOC ## POST /api/kernel/initialize ### Description Initializes the CMSIS-RTOS kernel if it is in an inactive state. ### Method POST ### Endpoint /api/kernel/initialize ### Parameters None ### Request Body None ### Request Example ```json { "message": "Initialize kernel" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Kernel initialized successfully" } ``` ## POST /api/kernel/start ### Description Starts the RTOS kernel and begins thread switching. This function will not return if successful. It can only be called after the kernel has been initialized and at least one thread has been created. ### Method POST ### Endpoint /api/kernel/start ### Parameters None ### Request Body None ### Request Example ```json { "message": "Start kernel" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. Note: In a real RTOS, this function typically does not return on success. #### Response Example ```json { "status": "Kernel started successfully" } ``` ``` -------------------------------- ### GRU Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/NN/html/globals.html Example usage of a Gated Recurrent Unit (GRU) network. This snippet demonstrates the GRU functionality within the examples. ```c gru_example() ``` -------------------------------- ### Value Range with Step Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Pack/html/configWizard.html Example demonstrating a value range with a specific step. This is useful for configuration options where increments are not always 1. ```c // <0-100:10> ``` -------------------------------- ### Kernel Start Events Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/RTOS2/html/group__rtx__evr__kernel.html Events related to the starting of the RTOS kernel. ```APIDOC ## EvrRtxKernelStart Function ### Description Logs when the `osKernelStart` function is called. ### Event **KernelStart**: Generated when `osKernelStart` is called. ``` ```APIDOC ## EvrRtxKernelStarted Function ### Description Logs when the RTOS kernel execution is successfully started. ### Event **KernelStarted**: Generated when `osKernelStart` successfully starts the RTOS kernel execution. ``` -------------------------------- ### Debug Configuration File Example Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Pack/html/pdsc_family_pg.html This example shows a typical \*.dbgconf file used for configuring trace pin locations. It utilizes Configuration Wizard annotations for a user-friendly interface. ```c // File: EFM32WGxxx.dbgconf // Version: 1.0 // <<< Use Configuration Wizard in Context Menu >>> // Trace Pin Setup // TPIU Pin Location // <0=> Pin Location 0 // <1=> Pin Location 1 // <2=> Pin Location 2 // <3=> Pin Location 3 // Select TPIU pin location for your board configuration: // - Pin Location 0 (TRACECLK: PD7, TRACEDATA0: PD6, TRACEDATA1: PD3, TRACEDATA2: PD4, TRACEDATA3: PD5) // - Pin Location 1 (TRACECLK: PF8, TRACEDATA0: PF9, TRACEDATA1: PD13, TRACEDATA2: PB15, TRACEDATA3: PF3) // - Pin Location 2 (TRACECLK: PC6, TRACEDATA0: PC7, TRACEDATA1: PD3, TRACEDATA2: PD4, TRACEDATA3: PD5) // - Pin Location 3 (TRACECLK: PA6, TRACEDATA0: PA2, TRACEDATA1: PA3, TRACEDATA2: PA4, TRACEDATA3: PA5) // Default: Pin Location 0 __TPIU_pinlocation = 0; // SWO Pin Location // <0=> Pin Location 0 // <1=> Pin Location 1 // <2=> Pin Location 2 // <3=> Pin Location 3 // Select SWO pin location for your board configuration: // - Pin Location 0 (SWO: PF2) // - Pin Location 1 (SWO: PC15) // - Pin Location 2 (SWO: PD1) // - Pin Location 3 (SWO: PD2) // Default: Pin Location 0 __SWO_pinlocation = 0; // // <<< end of configuration section >>> ``` -------------------------------- ### Initialize System and Update Core Clock Source: https://github.com/stmicroelectronics/stm32cubef3/blob/master/Drivers/CMSIS/docs/Core_A/html/group__system__init__gr.html Demonstrates the usage of SystemCoreClock, SystemInit(), and SystemCoreClockUpdate() to manage and verify the system clock frequency. ```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; /* Store value of predefined SystemCoreClock */ SystemCoreClockUpdate(); /* Update SystemCoreClock according to register settings */ coreClock_2 = SystemCoreClock; /* Store value of calculated SystemCoreClock */ if (coreClock_2 != coreClock_1) { /* Without changing the clock setting both core clock values should be the same */ // Error Handling } while(1); } ```