fdr1-modbus-slave/includes/rtu.h
2026-03-09 15:08:40 +01:00

40 lines
1.8 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef RTU_H
#define RTU_H
#include <xc.h>
#include <stdint.h>
// ─────────────────────────────────────────────
// Configuration Modbus RTU
// ─────────────────────────────────────────────
#define RTU_SLAVE_ADDR 0xB7
#define RTU_FC03 0x03
#define RTU_HR0_ADDR 0x1700 // Position QEI
// ─────────────────────────────────────────────
// Timer2 — timeout inter-caractère 3.5×
// ≈ 304 µs @ 115200 bps
// prescaler 1:16, PR2 = 151
// ─────────────────────────────────────────────
#define RTU_TIMER_PRESCALER 16
#define RTU_TIMER_PR2 151
// ─────────────────────────────────────────────
// Buffer
// ─────────────────────────────────────────────
#define RTU_BUF_SIZE 32
// ─────────────────────────────────────────────
// API publique
// ─────────────────────────────────────────────
void RTU_Init(void);
void RTU_RxISR(void); // ISR UART RX haute priorité
void RTU_TimerISR(void); // ISR Timer2 basse priorité
void RTU_Task(void); // boucle principale
#endif // RTU_H