STM32CubeF3 MCU Firmware Package

repository·master·Indexed 41 days ago

https://github.com/stmicroelectronics/stm32cubef3

A comprehensive software platform for STM32F3 series microcontrollers. It provides HAL/LL drivers, Board Support Package (BSP) drivers, middleware libraries (RTOS, USB, FatFS), and CMSIS modules (Core, DSP, NN). The package includes ready-to-use software projects, applications, and demonstrations for evaluation and Nucleo boards.

Tokens
199.4K
Snippets
155
Records
1K
Agent score
45%

What's inside STM32CubeF3

  1. Overview of USB Device CDC Standalone Example

    master

    The CDC Standalone example implements a USB-to-RS232 bridge using the Device Communication Class (CDC) following the PSTN subprotocol. The STM32 MCU acts as a Virtual COM Port (VCP), where it exchanges data with a PC host via the USB interface (Device mode) and with other devices via the UART interface (RS232).

    Key Features:

    • Full-Duplex Communication: UART receiving is handled via interrupts, while UART transmitting is handled via DMA, allowing simultaneous bidirectional data flow.
    • USB Endpoints:
      • Bulk IN: Transmits data from STM32 to PC. Data received over UART is stored in UserTxBuffer and transmitted periodically based on the CDC_POLLING_INTERVAL.
      • Bulk OUT: Receives data from PC to STM32. Data is stored in UserRxBuffer and transmitted over UART using interrupt mode.
      • Interrupt IN: Handles serial-port parameter requests (Set line/Get line) via CDC_Itf_Control().
    • Clock Configuration: The system clock (SYSCLK) runs at 72 MHz, and the Full Speed (FS) USB module uses an internal 48-MHz clock generated from an integrated PLL.
  2. Overview of the USB HID Standalone Example

    master

    This example demonstrates how to use the USB peripheral in Device mode using the Human Interface Device (HID) class V1.11. It emulates mouse movements using the User button on the STM32F3-Discovery board.

    Key features include:

    • Mouse Emulation: Uses the GetPointerData() function to move the cursor (configured by default to move forward and backward in an infinite loop).
    • Remote Wakeup: Supports bringing a suspended USB bus back to an active state using the User button as the wakeup source.
    • Clock Configuration: The system clock (SYSCLK) is configured to 72 MHz, with the Full Speed (FS) USB module using an internal 48-MHz clock generated via an integrated PLL.
    • Static Allocation: To reduce the footprint, toolchain dynamic allocation is replaced by static allocation using a pre-defined static buffer for the HID class structure.
  3. Overview of the FreeRTOS Mail Example

    master

    This example demonstrates how to use mail queues using the CMSIS RTOS API on STM32F303xE devices. It implements a producer-consumer pattern where two threads communicate via a mail queue.

    Key Concepts

    • Mail Structure: The mail being sent/received is a structure containing three variables: var1 (uint32), var2 (uint32), and var3 (uint8).
    • Producer Thread: Allocates mail and puts it onto the queue. The queue has a capacity for one item.
    • Consumer Thread: Has a higher priority than the producer and is configured to block while waiting for mail. When mail is posted, the consumer preempts the producer, retrieves the mail, and frees it.

    Monitoring and Status

    • LiveWatch Variables: To verify correct operation, monitor these variables in LiveWatch. The producer values must always match the consumer values:
      • ConsumerValue1 == ProducerValue1
      • ConsumerValue2 == ProducerValue2
      • ConsumerValue3 == ProducerValue3
    • LED Indicators:
      • LED1: Toggles when the example is running successfully.
      • LED3: Toggles when an error occurs.
  4. Overview of the USB DFU Standalone Example

    master

    The USB DFU (Device Firmware Upgrade) Standalone example provides a compliant implementation for programming the embedded Flash memory of STM32F3xx devices via a USB peripheral. It uses Endpoint 0 (control endpoint) for all requests and status control transactions.

    Memory Layout

    The internal flash memory is partitioned into two distinct areas:

    1. DFU area: Located in [0x08000000 : USBD_DFU_APP_DEFAULT_ADD-1]. This area is read-only.
    2. Application area: Located in [USBD_DFU_APP_DEFAULT_ADD : Device's end address]. This area supports Read, Write, and Erase access for the new firmware.

    Operating Modes

    • DFU operating mode: Entered if the user forces it (by pressing the Key button on the Discovery board after reset) or if no valid code is found in the application area (determined by checking if the MSB of the initial Main Stack Pointer (MSP) at the application start address is 0x2000).
    • Run-time application mode: Normal application execution (e.g., toggling LEDs).
  5. Overview of the FatFs with uSD card drive example

    master

    This example demonstrates how to use the STM32Cube firmware with the FatFs middleware component as a generic FAT file system module. It specifically focuses on configuring and interacting with a microSD drive.

    The application performs a complete lifecycle of file operations: initializing the system, mounting the drive, formatting the FAT volume, writing a text file, reading it back, and finally unmounting the driver.

    Status Monitoring via LEDs:

    • LED1: ON when the example runs successfully.
    • LED3: ON when an error occurs during execution.
  6. Overview of FatFs with uSD card drive example

    master

    This example demonstrates how to use the STM32Cube firmware with the FatFs middleware component as a generic FAT file system module. It specifically focuses on configuring and interacting with a microSD drive.

    Application Workflow

    The application performs a complete lifecycle of file operations to verify the drive:

    1. Initialization: Calls HAL_Init() to reset peripherals and initialize Flash/SysTick, followed by SystemClock_Config() to set the system clock to 72 MHz.
    2. Driver Setup: Links the uSD disk I/O driver.
    3. Mounting: Registers the file system object (mount) to the FatFs module.
    4. Formatting: Creates a FAT file system (format) on the uSD drive.
    5. File Operations:
      • Creates and opens a new text file with write access.
      • Writes data to the file.
      • Closes the file.
      • Re-opens the file with read access.
      • Reads the data back.
      • Closes the file.
    6. Verification: Checks the read data against the original data.
    7. Cleanup: Unlinks the uSD disk I/O driver.

    Status Monitoring

    You can monitor the execution status using the LEDs on the STM32 Eval board:

    • LED1: ON when the example runs successfully.
    • LED3: ON when an error occurs.
  7. Overview of USB Device Mass Storage (MSC) Standalone Example

    master

    This example demonstrates how to use the STM32F3xx USB Device peripheral to implement a Mass Storage Class (MSC) device. The STM32 MCU acts as a removable drive (using Bulk Only Transfer and SCSI commands) connected to a PC Host, with a microSD card serving as the storage media.

    Key Technical Details

    • Clock Configuration: The system clock (SYSCLK) is configured to 72 MHz. The Full Speed (FS) USB module uses an internal 48-MHz clock generated from an integrated PLL.
    • USB Interrupt Remapping: Users can choose between default USB interrupt lines or remapped lines (USB_LP and USB_WKUP on interrupt lines 75 and 76) using macros defined in main.h:
      • USE_USB_INTERRUPT_DEFAULT
      • USE_USB_INTERRUPT_REMAPPED
    • Memory Management: To minimize the footprint, toolchain dynamic allocation is replaced by static allocation using a pre-defined static buffer for the MSC class structure.
    • VBUS Detection: The STM32F3x USB peripheral does not have a dedicated interrupt for cable plug/unplug detection. Detection should be implemented by monitoring the VBUS line via a GPIO pin using an external interrupt.
  8. Overview of USB Custom HID Standalone Example

    master

    This example demonstrates how to use the STM32F3xx USB Device peripheral as a HID (Human Interface Device) compliant device using the Custom HID Class. The STM32 MCU is enumerated by the PC host using native HID drivers.

    Key technical details:

    • Clock Configuration: The system clock (SYSCLK) is configured to 72 MHz. The Full Speed (FS) USB module uses an internal 48-MHz clock generated from an integrated PLL.
    • Memory Management: To reduce the footprint, toolchain dynamic allocation is replaced by static allocation using a pre-defined static buffer for the HID class structure.
    • Interrupt Remapping: USB interrupts (USB_LP and USB_WKUP) can be remapped to interrupt lines 75 and 76. This is controlled via macros in main.h:
      • USE_USB_INTERRUPT_DEFAULT
      • USE_USB_INTERRUPT_REMAPPED
  9. Overview of USB Device Custom HID Example

    master

    This example demonstrates how to use the STM32F3xx USB Device peripheral to implement a Custom HID (Human Interface Device) class. The STM32 MCU is enumerated as a HID-compliant device, allowing it to be recognized by native PC Host HID drivers.

    Key technical details:

    • Clock Configuration: The system clock (SYSCLK) is configured to 72 MHz. The Full Speed (FS) USB module uses an internal 48-MHz clock generated from an integrated PLL.
    • Memory Management: To reduce the footprint, dynamic allocation is replaced by static allocation using a pre-defined static buffer for the HID class structure.
    • Interrupt Remapping: USB interrupts (USB_LP and USB_WKUP) can be remapped to interrupt lines 75 and 76. This is controlled via macros in main.h:
      • USE_USB_INTERRUPT_DEFAULT
      • USE_USB_INTERRUPT_REMAPPED
  10. Overview of the TouchSensing 1 linear sensor example

    master

    This firmware example demonstrates how to use the STMTouch driver with a single linear sensor. It incorporates ECS (Environmental Compensation System) and DTO (Detection Timeout) functionalities.

    Observed Behavior

    • LED Indicators:
      • LD1, LD2, and LD3: Follow the linear sensor position when touched.
      • LD4: Blinks whenever the ECS process completes.
      • LD3: Blinks continuously if an error occurs.
    • LCD Display:
      • ECS state (ON/OFF).
      • Linear sensor state (e.g., RELEASE, DETECT) and position (range 0 to 15).
      • Delta values for the three channels composing the linear sensor.

    Key Concepts

    • ECS (Environmental Compensation System): The ECS is active (ON) when no touch is detected (all sensors in RELEASE state). Its behavior is configurable via the tsl_conf.h file.
    • DTO (Detection Timeout): If a sensor is touched for several seconds, the system automatically enters the RELEASE state and performs a re-calibration after a timeout. This timeout duration is controlled by the TSLPRM_DTO parameter in tsl_conf.h.
  11. Overview of the TouchSensing 1 linear sensor interrupt example

    master

    This firmware example demonstrates how to use the STMTouch driver with a single linear sensor, incorporating ECS (Environmental Compensation System) and DTO (Detection Timeout) functionalities. It is designed for STM32F373xx devices and has been validated on the STM32373C-EVAL board.

    Observed Behavior

    • LED Indicators:
      • LD1, LD2, and LD3: Follow the linear sensor position when touched.
      • LD4: Blinks when the ECS process completes.
      • LD3: Blinks continuously if an error occurs.
    • LCD Display:
      • ECS state (ON/OFF).
      • Linear sensor state (e.g., RELEASE, DETECT) and position (range 0 to 15).
      • Delta values for the three channels composing the linear sensor.

    Key Concepts

    • ECS (Environmental Compensation System): Automatically manages sensor stability. It is ON when no touch is detected (all sensors in RELEASE state). Behavior can be tuned via tsl_conf.h.
    • DTO (Detection Timeout): Allows testing of the RELEASE state by touching a sensor for a specific duration. After the timeout, the system automatically enters the RELEASE state and performs re-calibration. The timeout duration is controlled by the TSLPRM_DTO parameter in tsl_conf.h.
  12. Overview of the TouchSensing 2 touchkey sensors example

    master

    This firmware example demonstrates how to use the STMTouch driver with two touchkey sensors. It utilizes the ECS (Environmental Compensation System) and DTO (Detection Timeout) features.

    Observed Behavior

    • LED1: Turns ON when the TS1 sensor is touched.
    • LED2: Turns ON when the TS2 sensor is touched.
    • LED4: Blinks whenever the ECS process completes.
    • LED3: Blinks continuously if an error occurs.

    LCD Display Information

    • ECS State: Shows whether ECS is ON or OFF.
    • Sensor States: Displays the current state (e.g., RELEASE, DETECT) and the delta value for both TS1 and TS2 sensors.

    Key Concepts

    • ECS (Environmental Compensation System): The ECS is active when no touch is detected (all sensors are in the RELEASE state). Its behavior is configurable via the tsl_conf.h file.
    • DTO (Detection Timeout): If a sensor is touched for several seconds, the system automatically enters the RELEASE state and performs a re-calibration after a timeout. This timeout duration is controlled by the TSLPRM_DTO parameter in tsl_conf.h.