blob: f4a61c840ff9471f7d211f1198d1efc49f5f9641 [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
21 int WriteStdout(gsl::span<const char> buffer) override;
22
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_