# ERT **Repository Path**: chenxi666/ert ## Basic Information - **Project Name**: ERT - **Description**: No description available - **Primary Language**: C - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-22 - **Last Updated**: 2026-05-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ERT STM32G474xx Test Project ## Project Overview This is an embedded test project based on the STM32G474CBTx microcontroller. The project integrates peripherals such as ADC, DAC, and USART, and implements USB CDC device functionality. ## Hardware Configuration - **MCU**: STM32G474CBTx - **Clock Frequency**: 170 MHz (ARM Cortex-M4 with FPU) - **Flash**: 128 KB - **SRAM**: 32 KB ## Peripheral Functions | Peripheral | Description | |------------|-------------| | ADC1/ADC2 | 12-bit Analog-to-Digital Converters | | DAC1 | 12-bit Digital-to-Analog Converter | | USART1 | Asynchronous Serial Communication | | USB | USB 2.0 Full-Speed Device (CDC Class) | | GPIO | General-Purpose Input/Output | ## Project Structure ``` ├── Core/ # Core application code │ ├── Inc/ # Header files │ │ ├── main.h │ │ ├── adc.h │ │ ├── dac.h │ │ ├── gpio.h │ │ └── usart.h │ └── Src/ # Source files │ ├── main.c # Main program │ ├── test.c # Test functions │ ├── adc.c # ADC configuration │ ├── dac.c # DAC configuration │ ├── gpio.c # GPIO configuration │ └── usart.c # USART configuration ├── USB_Device/ # USB device-related code │ ├── App/ │ │ ├── usb_device.c # USB initialization │ │ ├── usbd_cdc_if.c # CDC interface │ │ └── usbd_desc.c # Descriptors │ └── Target/ │ └── usbd_conf.c # USB configuration ├── Drivers/ # Driver libraries │ ├── CMSIS/ # CMSIS drivers │ └── STM32G4xx_HAL_Driver/ # STM32 HAL drivers └── Middlewares/ # Middleware └── STM32_USB_Device_Library/ # USB Device Library ``` ## Compilation Instructions ### Environment Requirements - GCC Arm Embedded Toolchain - CMake 3.16+ - STM32CubeMX (optional, for generating .ioc configuration) ### Compilation Steps ```bash # Create build directory mkdir build && cd build # Configure project cmake .. # Build cmake --build . ``` ## Usage Instructions 1. Flash the firmware to the development board using an ST-Link or J-Link debugger. 2. Connect the USB port to a PC; it will be recognized as a CDC virtual serial port device. 3. Use a serial debugging tool to perform communication tests. ## Communication Protocol This project supports a USB CDC binary-frame protocol and currently implements the `DISCOVER` command handling. - `DISCOVER` command: the host sends a frame with a zeroed destination address and an empty payload; the device replies with `DISCOVER_ACK`. - `DISCOVER_ACK` frame: the device places its 96-bit UID in the `SRC` field and returns a success status. - CRC verification: CRC-16/MODBUS is used (see `Docs/协议.md`). > The current firmware parses received USB CDC frames, validates the header and CRC, and replies with the device UID when `CMD == 0x01` and `LEN == 0x0000`. ## License MIT License