e252cbe04d5ca6a3e50290ac8ba58df1068ba891
ModTOS
Modbus RTU driver for STM32 + FreeRTOS with interrupt-driven frame handling and RS485 GPIO direction control.
Overview
ModTOS is a lightweight, dependency-free Modbus RTU slave implementation intended for use in embedded systems based on STM32 and FreeRTOS. It is designed to operate as a cooperative background task, minimizing CPU usage and avoiding interference with time-sensitive application logic.
The driver uses interrupt-based UART reception with idle line detection to capture complete RTU frames without polling. RS485 transceiver direction is controlled via a user-defined GPIO pin, allowing the driver to support half-duplex serial communication in industrial settings.
Features
- Function Code 0x03 Read Holding Registers
- Function Code 0x10 Write Multiple Holding Registers
- CRC-16 validation and exception handling
- Flat register buffer 128 x
uint16_t - Task-based integration with optional stats tracking
- No dynamic memory allocation
- Easily adaptable to polling or non-RTOS environments
Integration Notes
- Requires UART configured with idle line detection
- GPIO pin needed for RS485 DE/NRE control
- Designed for projects where Modbus functionality must coexist with high-speed control tasks
Description
Modbus RTU driver for STM32 + FreeRTOS with interrupt‑driven frame handling and RS485 GPIO direction control.
Languages
C
100%