blob: e223ae7f945fa647644ca640936d2d628f678f20 [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
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -08007namespace frc971::motors {
Brian Silverman4787a6e2018-10-06 16:00:54 -07008
9// A printing implementation using a hardware UART. This has a reasonably sized
10// buffer in memory and uses interrupts to keep the hardware busy. It could
11// support DMA too in the future.
12class UartPrinting : public PrintingImplementation {
13 public:
14 // All required parameters must be filled out.
15 UartPrinting(const PrintingParameters &parameters);
16 ~UartPrinting() override;
17
18 void Initialize() override;
19
Austin Schuh7fe04492022-01-02 13:37:21 -080020 int WriteStdout(absl::Span<const char> buffer) override;
Brian Silverman4787a6e2018-10-06 16:00:54 -070021
22 private:
23 teensy::InterruptBufferedUart stdout_uart_;
24 const int stdout_status_interrupt_;
25};
26
27// Could easily create a subclass of UartPrinting that also implements
28// WriteDebug on a second UART, and conditionally instantiate that.
29
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080030} // namespace frc971::motors
Brian Silverman4787a6e2018-10-06 16:00:54 -070031
32#endif // MOTORS_PRINT_UART_H_