### FFT Bin Example Setup Source: https://github.com/inavflight/inav/blob/master/lib/main/STM32H7/Drivers/CMSIS/docs/DSP/html/arm_fft_bin_example_f32_8c-example.html This snippet shows the setup for the FFT bin example, including buffer declarations and global variables for FFT configuration. It defines the input and output buffer sizes and FFT parameters like size, ifftFlag, and doBitReverse. ```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; ``` -------------------------------- ### Install Example Dependencies Source: https://github.com/inavflight/inav/blob/master/lib/main/STM32H7/Drivers/CMSIS/DSP/PythonWrapper/README.md Install necessary Python packages (NumPy, SciPy, Matplotlib) within the activated virtual environment to run the example scripts. ```bash > pip install numpy > pip install scipy > pip install matplotlib ``` -------------------------------- ### MPU Configuration Example Source: https://github.com/inavflight/inav/blob/master/lib/main/STM32H7/Drivers/CMSIS/docs/Core/html/group__mpu__functions.html Example demonstrating how to configure MPU Region 0 with specific attributes and enable the MPU. This setup protects the region starting at 0x08000000 with a size of 1MB. ```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 ``` -------------------------------- ### Initialize WiFi Bypass Example Source: https://github.com/inavflight/inav/blob/master/lib/main/STM32H7/Drivers/CMSIS/docs/Driver/html/group__wifi__bypass__gr.html Example demonstrating the initialization of the WiFi driver and retrieval of its capabilities. This setup is a prerequisite for configuring bypass mode. ```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; capabilities = wifi->GetCapabilities (); ``` -------------------------------- ### RTOS Kernel Initialization and Start Example (C) Source: https://github.com/inavflight/inav/blob/master/lib/main/STM32H7/Drivers/CMSIS/docs/RTOS2/html/group__CMSIS__RTOS__KernelCtrl.html Demonstrates the typical sequence for initializing the RTOS kernel, creating a main application thread, and starting the scheduler. Ensure SystemCoreClockUpdate() is called before kernel initialization. ```c /*---------------------------------------------------------------------------- * Application main thread *---------------------------------------------------------------------------*/ void app_main (void *argument) { // ... for (;;) { } } int main (void) { // System Initialization SystemCoreClockUpdate(); // ... osKernelInitialize(); // Initialize CMSIS-RTOS osThreadNew(app_main, NULL, NULL); // Create application main thread osKernelStart(); // Start thread execution for (;;) { } } ``` -------------------------------- ### Setup and Create Message Queue Example Source: https://github.com/inavflight/inav/blob/master/lib/main/STM32H7/Drivers/CMSIS/docs/RTOS/html/group__CMSIS__RTOS__Message.html Demonstrates the steps to set up and create a message queue. First, define the queue using osMessageQDef, then declare an ID, and finally create the queue using osMessageCreate. ```c osMessageQDef(message_q, 5, uint32_t); // Declare a message queue osMessageQId (message_q_id); // Declare an ID for the message queue message_q_id = osMessageCreate(osMessageQ(message_q), NULL); ``` -------------------------------- ### Flash Driver Initialization and Operation Example Source: https://github.com/inavflight/inav/blob/master/lib/main/STM32H7/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, data reading, and uninitialization. It utilizes CMSIS-RTOS2 for thread management and event signaling. ```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 (); } ``` -------------------------------- ### Install Programs with Make Source: https://github.com/inavflight/inav/blob/master/lib/main/STM32H7/Middlewares/Third_Party/LibJPEG/install.txt Use 'make install' to install executable files and man pages to standard locations. It's recommended to first run 'make -n install' to preview the installation targets. ```bash make install ``` ```bash make -n install ``` -------------------------------- ### Start Vagrant Virtual Machine Source: https://github.com/inavflight/inav/blob/master/docs/development/Building in Vagrant.md Initiates the Vagrant virtual machine. The first run may take longer due to base image downloads and setup. ```bash vagrant up ``` -------------------------------- ### Define Example Project Structure Source: https://github.com/inavflight/inav/blob/master/lib/main/STM32H7/Drivers/CMSIS/docs/Pack/html/cp_SWComponents.html Example projects are defined within an section. Each element specifies a name, documentation file, folder, description, target board, and project environment. ```xml CMSIS-RTOS based example ``` -------------------------------- ### Floating-Point Convolution Example Setup Source: https://github.com/inavflight/inav/blob/master/lib/main/STM32H7/Drivers/CMSIS/docs/DSP/html/arm_convolution_example_f32_8c-example.html This section declares the necessary buffers for input signals A and B, and the output buffer for the convolution result. It also defines constants for block size and a small delta value for comparisons. ```c #include "arm_math.h" #include "math_helper.h" /* ---------------------------------------------------------------------- * Defines each of the tests performed * ------------------------------------------------------------------- */ #define MAX_BLOCKSIZE 128 #define DELTA (0.000001f) #define SNR_THRESHOLD 90 /* ---------------------------------------------------------------------- * Declare I/O buffers * ------------------------------------------------------------------- */ float32_t Ak[MAX_BLOCKSIZE]; /* Input A */ float32_t Bk[MAX_BLOCKSIZE]; /* Input B */ float32_t AxB[MAX_BLOCKSIZE * 2]; /* Output */ ``` -------------------------------- ### I2C Master Mode Initialization and Event Handling Source: https://github.com/inavflight/inav/blob/master/lib/main/STM32H7/Drivers/CMSIS/docs/Driver/html/group__i2c__interface__gr.html Example demonstrating the setup and event handling for I2C in Master mode. It includes driver initialization, event callback registration, and basic event checking. ```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 */ } ``` -------------------------------- ### Example Generator with Project Files Source: https://github.com/inavflight/inav/blob/master/lib/main/STM32H7/Drivers/CMSIS/docs/Pack/html/pdsc_generators_pg.html Defines a generator (e.g., STM32CubeMX) and lists the source and header files required for the project setup. This is used to specify files generated by a tool that are part of the project. ```xml STM32CubeMX Environment