Brian Silverman | 4787a6e | 2018-10-06 16:00:54 -0700 | [diff] [blame] | 1 | #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 Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 7 | namespace frc971::motors { |
Brian Silverman | 4787a6e | 2018-10-06 16:00:54 -0700 | [diff] [blame] | 8 | |
| 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. |
| 12 | class UartPrinting : public PrintingImplementation { |
| 13 | public: |
| 14 | // All required parameters must be filled out. |
| 15 | UartPrinting(const PrintingParameters ¶meters); |
| 16 | ~UartPrinting() override; |
| 17 | |
| 18 | void Initialize() override; |
| 19 | |
Austin Schuh | 7fe0449 | 2022-01-02 13:37:21 -0800 | [diff] [blame] | 20 | int WriteStdout(absl::Span<const char> buffer) override; |
Brian Silverman | 4787a6e | 2018-10-06 16:00:54 -0700 | [diff] [blame] | 21 | |
| 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 Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 30 | } // namespace frc971::motors |
Brian Silverman | 4787a6e | 2018-10-06 16:00:54 -0700 | [diff] [blame] | 31 | |
| 32 | #endif // MOTORS_PRINT_UART_H_ |