SatCat5
cfgbus_uart.h
1 // Copyright 2021-2025 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
5 // Interface driver for the cfgbus_uart block
6 
7 #pragma once
8 
9 #include <satcat5/cfgbus_interrupt.h>
10 #include <satcat5/io_buffer.h>
11 
12 // Default size parameters
13 // For reference: 256 bytes = 2.7 msec buffer @ 921 kbaud
14 #ifndef SATCAT5_UART_BUFFSIZE
15 #define SATCAT5_UART_BUFFSIZE 256
16 #endif
17 
18 namespace satcat5 {
19  namespace cfg {
21  class Uart
23  , protected satcat5::cfg::Interrupt
24  {
25  public:
27  Uart(satcat5::cfg::ConfigBus* cfg, unsigned devaddr);
28 
30  void configure(
31  unsigned clkref_hz, // ConfigBus clock rate
32  unsigned baud_hz, // Desired UART baud rate
33  bool ignore_cts = true);
34 
35  private:
36  // Event handlers.
38  void irq_event();
39 
40  // Control registers
42 
43  // Raw Tx/Rx working buffers are NOT publicly accessible.
44  u8 m_txbuff[SATCAT5_UART_BUFFSIZE];
45  u8 m_rxbuff[SATCAT5_UART_BUFFSIZE];
46  };
47  }
48 }
Generic ConfigBus API.
Definition: cfgbus_core.h:124
Event-handler for individual ConfigBus interrupts.
Interface driver for the cfgbus_uart block.
Definition: cfgbus_uart.h:24
void irq_event()
Interrupt service routine.
Definition: cfgbus_uart.cc:52
void data_rcvd(satcat5::io::Readable *src)
The data_rcvd() callback is polled whenever data is available.
Definition: cfgbus_uart.cc:42
void configure(unsigned clkref_hz, unsigned baud_hz, bool ignore_cts=true)
Set baud rate and flow-control.
Definition: cfgbus_uart.cc:32
Uart(satcat5::cfg::ConfigBus *cfg, unsigned devaddr)
Initialize this UART and link to a specific register bank.
Definition: cfgbus_uart.cc:23
Pointer-like wrapper for one or more ConfigBus registers.
Definition: cfgbus_core.h:76
Extensible transmit and receive buffer.
Definition: io_buffer.h:42
Abstract API for reading byte-streams and packets.
Definition: io_readable.h:68
Buffered I/O wrappers for PacketBuffer.