h2_leaksensor_code/include/uart_manager.h
2026-07-24 16:39:26 +02:00

37 lines
1.1 KiB
C

#ifndef UART_MANAGER_H
#define UART_MANAGER_H
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "config.h"
// =====================================================
// UART MANAGER
// =====================================================
// MPS sensor link : USART1 PB3=TX (pin 11) / PB2=RX (pin 12)
// Interrupt-driven ring-buffer, 19200 baud
// Debug output : USART2 PC2=TX (pin 17) / PC1=RX (pin 16)
// Polled TX-only, 115200 baud (DEBUG_UART only)
// =====================================================
// ---- MPS UART (USART1) ----
void UART_Init(void);
void UART_SendByte(uint8_t byte);
void UART_SendBuffer(const uint8_t *buf, uint16_t len);
bool UART_Available(void);
uint8_t UART_ReadByte(void);
uint16_t UART_ReadBuffer(uint8_t *buf, uint16_t maxLen, uint32_t timeoutMs);
void UART_FlushRx(void);
uint16_t UART_RxCount(void);
// ---- DEBUG UART (USART2) — compiled in only when DEBUG_UART defined ----
#ifdef DEBUG_UART
void DBG_UART_Init(void);
void UART_Print(const char *str);
void UART_Printf(const char *fmt, ...);
#endif
#endif // UART_MANAGER_H