Brian Silverman | 4787a6e | 2018-10-06 16:00:54 -0700 | [diff] [blame] | 1 | #include "motors/print/semihosting.h" |
| 2 | |
| 3 | #include "motors/core/semihosting.h" |
| 4 | |
| 5 | namespace frc971 { |
| 6 | namespace motors { |
| 7 | |
| 8 | ::std::unique_ptr<PrintingImplementation> CreatePrinting( |
| 9 | const PrintingParameters & /*parameters*/) { |
| 10 | return ::std::unique_ptr<PrintingImplementation>(new SemihostingPrinting()); |
| 11 | } |
| 12 | |
| 13 | extern "C" int _write(const int /*file*/, char *const ptr, const int len) { |
| 14 | semihosting::Write operation{2 /* stderr */, gsl::span<const char>(ptr, len)}; |
| 15 | return len - operation.Execute(); |
| 16 | } |
| 17 | |
| 18 | int SemihostingPrinting::WriteStdout(gsl::span<const char> buffer) { |
| 19 | semihosting::Write operation{2 /* stderr */, buffer}; |
| 20 | return buffer.size() - operation.Execute(); |
| 21 | } |
| 22 | |
| 23 | } // namespace motors |
| 24 | } // namespace frc971 |