#ifndef LAMP_UART_H
#define LAMP_UART_H

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

typedef struct {
    uint32_t dropped_bytes;
    uint32_t dropped_packets;
    uint32_t hardware_errors;
    uint32_t tx_queued_bytes;
} lamp_uart_stats;

/* USART2 PA2/PA3, 8N1, oversampling by 16; caller supplies measured/configured PCLK. */
bool lamp_uart_init(uint32_t peripheral_clock_hz, uint32_t baud);
bool lamp_uart_rx_read(uint8_t *byte);
/* Accepts one whole packet into the local queue; this does not prove wire delivery. */
bool lamp_uart_tx_enqueue(void *context, const uint8_t *packet, size_t length);
void lamp_uart_get_stats(lamp_uart_stats *stats);

#endif
