blob: 7d8157775f448fcbcabb219416db9dc9cf715ae4 [file] [log] [blame]
Brian Silverman4787a6e2018-10-06 16:00:54 -07001#ifndef MOTORS_PRINT_UART_H_
2#define MOTORS_PRINT_UART_H_
3
4#include "motors/peripheral/uart.h"
5#include "motors/print/print.h"
6
7namespace frc971 {
8namespace motors {
9
10// A printing implementation using a hardware UART. This has a reasonably sized
11// buffer in memory and uses interrupts to keep the hardware busy. It could
12// support DMA too in the future.
13class UartPrinting : public PrintingImplementation {
14 public:
15 // All required parameters must be filled out.
16 UartPrinting(const PrintingParameters &parameters);
17 ~UartPrinting() override;
18
19 void Initialize() override;
20
Austin Schuh7fe04492022-01-02 13:37:21 -080021 int WriteStdout(absl::Span<const char> buffer) override;
Brian Silverman4787a6e2018-10-06 16:00:54 -070022
23 private:
24 teensy::InterruptBufferedUart stdout_uart_;
25 const int stdout_status_interrupt_;
26};
27
28// Could easily create a subclass of UartPrinting that also implements
29// WriteDebug on a second UART, and conditionally instantiate that.
30
31} // namespace motors
32} // namespace frc971
33
34#endif // MOTORS_PRINT_UART_H_