STM32CubeG0 MCU Firmware Package

repository·master·Indexed 42 days ago

https://github.com/stmicroelectronics/stm32cubeg0

A comprehensive embedded software platform for the STM32G0 series, providing HAL/LL drivers, middleware, and software examples. Includes the CMSIS (Cortex Microcontroller Software Interface Standard) components such as CMSIS-DSP, CMSIS-NN, and CMSIS-RTOS, along with an experimental Python wrapper for CMSIS-DSP compatible with numpy and scipy.

Tokens
206.5K
Snippets
148
Records
1K
Agent score
49%

What's inside STM32CubeG0

  1. Overview of USB Source Host HID Application

    master

    This application demonstrates a Type-C provider and USB Host implementation on STM32G0xx devices using STM32Cube firmware. It serves two primary functions:

    1. USB HID Host: Uses the STM32G0xx USB DRD Host peripheral to interact with Human Interface Class (HID) devices like mice or keyboards. The MCU enumerates the device and extracts metadata (VID, PID, manufacturer, serial number, and product name) which is displayed via UART.
    2. USB-PD Provider: Initializes Type-C port 1 in source mode with a single Power Data Object (PDO) at 5V.

    The application is designed to run on STM32G0xx devices and has been validated on the STM32G0C1E-EV board.

  2. Overview of the USBPD_Analyzer application

    master

    The USBPD_Analyzer is a demonstration firmware for the STM32G071B-DISCO board that utilizes the UCPD IP for USB Power Delivery (USB-PD) communication and detection. The application operates in two distinct modes based on the physical state of the mechanical door:

    1. Standalone Sink Mode: Emulates a Type C PD3 standalone sink. This mode is active when the mechanical door is closed.
    2. Spy Mode: Spies on messages between two Type C devices. This mode is active when the mechanical door is opened. In this mode, traces of exchanges can be viewed using the STM32CubeMonitor tool.

    The implementation is based on FreeRTOS and uses the LCD for information display and a Joystick for menu navigation.

  3. Overview of the FreeRTOS Timers Example

    master

    This application demonstrates how to use timers via the CMSIS RTOS API on an STM32G0 device. It showcases the interaction between a periodic timer and a thread to control an LED (LED4) with different timing intervals.

    Behavioral Logic:

    1. Timer Phase: A periodic timer toggles LED4 every 200 ms for a 5-second cycle. During this time, the thread is suspended.
    2. Thread Phase: After 5 seconds, the thread resumes, stops the timer, and toggles LED4 every 400 ms for a 5-second cycle.
    3. Cycle: Once the thread cycle completes, it restarts the timer and suspends itself, repeating the process.

    Target Hardware:

    • Device: STM32G071RBTx
    • Board: NUCLEO-G071RB (can be tailored to other supported boards).
  4. Overview of the USB Device Mass Storage (MSC) Standalone Application

    master

    This application demonstrates how to implement a USB Mass Storage Class (MSC) device using STM32G0xx hardware. It uses the USB device peripheral to communicate with a PC Host via Bulk Only Transfer (BOT) and SCSI transparent commands. In this specific implementation, a microSD card is used as the storage media, and the STM32 MCU is enumerated as a removable drive by the PC host.

    Key technical details:

    • USB Speed: Full Speed (FS).
    • Clocking: The FS USB module requires an internal 48-MHz clock generated from an internal PLL.
    • Initialization: The application uses HAL_Init() for peripheral reset and Flash/SysTick initialization, and SystemClock_Config() to configure the system clock (SYSCLK).
  5. Overview of the USB HID Standalone Application

    master
    The USB HID Standalone application demonstrates how to use the STM32G0xx USB OTG Device peripheral to emulate a Human Interface Device (HID), specifically a mouse. The STM32 MCU is enumerated by the PC host using native HID drivers. In this specific implementation for the STM32G0C1E-EV board, the user can emulate mouse movements using the onboard Tamper push-button.
  6. Overview of Open Bootloader IAP application

    master

    The Open Bootloader IAP (In-Application Programming) application demonstrates how to develop and use an IAP application using the OpenBootloader Middleware.

    Application Lifecycle

    1. Initialization: The application calls HAL_Init() to reset peripherals, initialize the Flash interface, and set up the SysTick. It then configures the system clock (SYSCLK) to 64 MHz via SystemClock_Config().
    2. Interface Configuration: The application configures several communication protocols and memory interfaces, including:
      • Protocols: USART1, FDCAN1, I2C1, and USB.
      • Memory/System Interfaces: FLASH, RAM, Option bytes, Engi bytes, OTP, and System memory.
    3. Communication: The application enters a waiting state for incoming communication on one of the supported protocols. Once a connection is established, it waits for commands from the host.

    Critical Safety Note

    Mass Erase Operation: If performing a Mass Erase, you must protect the OpenBootloader FLASH area. Failure to do so will result in the OpenBootloader itself being erased, rendering the application unusable.

  7. Overview of I2C One Board Communication Slave 10-Bit and 7-Bit IT Example

    master

    This example demonstrates I2C data buffer transmission and reception between one Master and two Slaves using different address sizes (10-bit and 7-bit). It utilizes the STM32G0xx I2C HAL and LL APIs (for performance) with interrupts (IT) enabled.

    Key Features:

    • Master-Slave Communication: One Master communicates with two Slaves.
    • Mixed Addressing: Supports both 10-bit and 7-bit I2C addressing.
    • Interrupt Driven: Uses interrupt-based HAL functions for non-blocking communication.
    • Hardware Target: Designed for NUCLEO-G071RB (STM32G071RB), but adaptable to other STM32G0xx devices.
  8. Overview of the FreeRTOS Mail Example

    master

    This application demonstrates how to use mail queues using the CMSIS RTOS API on STM32G0 devices. It implements a producer-consumer pattern using two threads:

    1. Producer Thread: Allocates mail (a structure containing two uint32_t variables and one uint8_t variable) and puts it on a mail queue.
    2. Consumer Thread: A higher-priority thread that blocks on the mail queue. When mail is posted, the consumer preempts the producer, retrieves the mail, and frees it.

    The mail queue in this example is configured with a capacity of one item.

    Hardware Requirements:

    • Target Device: STM32G031K8Tx
    • Recommended Board: NUCLEO-G031K8

    Monitoring Success:

    • LED3: Toggles during successful operation. If LED3 remains ON, an error has occurred.
    • LiveWatch Variables: To verify data integrity, monitor the following variables. The consumer values must always match the producer values:
      • ConsumerValue1 == ProducerValue1
      • ConsumerValue2 == ProducerValue2
      • ConsumerValue3 == ProducerValue3
  9. Overview of the STM32CubeG0 software ecosystem

    master

    The STM32CubeG0 MCU Package provides a comprehensive software platform for the STM32G0 series, including:

    • CMSIS modules: Core and device modules for the ARM core.
    • HAL-LL drivers: Hardware Abstraction Layer (HAL) and Low-Layer (LL) drivers for maximized portability.
    • BSP drivers: Board Support Package drivers for supported evaluation, demonstration, or Nucleo boards.
    • Middleware libraries: RTOS, USB, FatFS, graphics, touch sensing, etc.
    • Software projects: Applications, demonstrations, and basic examples located in Projects/<Board_Name>/ directories.
  10. What is the Templates_LL project?

    master

    The Templates_LL project is a reference template designed to help developers build firmware applications using the STM32 Low-Layer (LL) API. It provides a foundational structure including clock configuration and hardware definitions, which can then be used as a base for porting specific LL examples to a target board.

    What is included:

    • LL Drivers: All LL drivers are included via main.h and source files. To use them in an IDE, ensure the USE_FULL_LL_DRIVER option is enabled.
    • Hardware Definitions: LED and user button definitions are provided in main.h.
    • Clock Configuration: The system clock setup is implemented in main.c via the SystemClock_Config() function.

    What is NOT included:

    • Functions to initialize or control the LED and user button.
    • Functions to manage the Interrupt Request (IRQ) handler for the user button.
  11. Overview of STM32G0C1E-EV Demonstration Firmware

    master

    The STM32G0C1E-EV demonstration firmware provides application subsets for the STM32G0C1E-EV board (MB1581) depending on the connected daughter board. The firmware automatically identifies the connected board by measuring the voltage level at PB11 (ADC_IN15).

    Supported Hardware Configurations

    • USB-PD Sub-demo: Requires STM32G0C1E-EV (MB1581) + USB-PD daughter board (MB1352).
    • Legacy Sub-demo: Requires STM32G0C1E-EV (MB1581) + Legacy daughter board (MB1351).
  12. Overview of the FreeRTOS Queues example

    master

    This application demonstrates how to use message queues using the CMSIS RTOS API on an STM32G0 device.

    Application Logic

    The example implements a Producer-Consumer pattern with two threads:

    1. Producer Thread: Sends an incrementing number to a queue every 1 second.
    2. Consumer Thread: A higher-priority thread that blocks on queue reads. As soon as the producer posts a message, the consumer unblocks, preempts the producer, and removes the item.

    The queue is configured with a capacity of exactly one item.

    Monitoring the Application

    • LiveWatch Variables: To verify the logic, monitor ProducerValue and ConsumerValue. These variables should remain equal at all times.
    • LED Status (NUCLEO-G031K8):
      • LED3 toggles: Occurs every 1 second when the producer posts a message.
      • LED3 stays ON: Indicates an error has occurred.