# uart001双串口互传 **Repository Path**: zhiOS/uart001 ## Basic Information - **Project Name**: uart001双串口互传 - **Description**: 实现两个串口数据互传,支持数据透传; - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2026-07-30 - **Last Updated**: 2026-08-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # UART001 - Modbus UART Implementation for STM32F1xx This project is a Modbus communication protocol implementation based on the STM32F1xx microcontroller, achieving master-slave communication through the UART interface. ## Functional Features - **Dual UART Interfaces**: Supports USART1 and USART2 dual serial port communication - **Modbus Protocol**: Complete Modbus protocol implementation - **Precise Delay**: Microsecond-level (Delay_us) and millisecond-level (Delay_ms) delay functions - **DMA Support**: Supports UART DMA transmission, improving communication efficiency - **Interrupt Handling**: Robust interrupt callback handling mechanism ## Hardware Requirements - STM32F1xx series microcontroller - Two UART interfaces (USART1, USART2) - One timer (TIM3) - Necessary GPIO pin configuration ## Software Architecture ### Core Components | File | Function Description | |------|---------| | `Core/Src/main.c` | Main program entry, containing system initialization and main loop | | `Core/Src/stm32f1xx_it.c` | Interrupt handler functions | | `Core/Src/stm32f1xx_hal_msp.c` | HAL library low-level driver initialization | | `Core/Src/system_stm32f1xx.c` | System clock configuration | ### Main Function Functions - `SystemClock_Config()` - System clock configuration - `MX_USART1_UART_Init()` - USART1 initialization - `MX_USART2_UART_Init()` - USART2 initialization - `MX_TIM3_Init()` - Timer 3 initialization - `MX_GPIO_Init()` - GPIO initialization - `Delay_us()` - Microsecond delay - `Delay_ms()` - Millisecond delay ## Usage Instructions ### Compilation and Flashing 1. Open the project using STM32CubeIDE or Keil MDK 2. Configure the build toolchain 3. Compile and flash to the target hardware ### Serial Configuration Default serial parameters: - Baud Rate: Configurable - Data Bits: 8 bits - Stop Bits: 1 bit - Parity: None ### Modbus Communication Modbus communication is managed via the `UartModbusStruct` structure, using the `ModbusCommand` variable to send and receive Modbus command frames. ## Dependencies - STM32CubeF1 Firmware Library - CMSIS Core Library - HAL Driver Library ## Directory Structure ``` ├── Core/ │ ├── Inc/ # Header file directory │ │ ├── main.h │ │ ├── stm32f1xx_hal_conf.h │ │ └── stm32f1xx_it.h │ └── Src/ # Source file directory │ ├── main.c │ ├── stm32f1xx_hal_msp.c │ ├── stm32f1xx_it.c │ └── system_stm32f1xx.c ├── Drivers/ # Driver libraries │ ├── CMSIS/ # CMSIS Core library │ └── STM32F1xx_HAL_Driver/ # HAL Driver └── .gitignore # Git ignore configuration ``` ## License This project follows an open-source agreement; please refer to the project source code for specific license information.