blob: 799b928bd42c42a76ba865b0f882cf3bcdef8a35 [file] [log] [blame]
Brian Silverman4787a6e2018-10-06 16:00:54 -07001#include "motors/print/semihosting.h"
2
3#include "motors/core/semihosting.h"
4
5namespace frc971 {
6namespace motors {
7
8::std::unique_ptr<PrintingImplementation> CreatePrinting(
9 const PrintingParameters & /*parameters*/) {
10 return ::std::unique_ptr<PrintingImplementation>(new SemihostingPrinting());
11}
12
13extern "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
18int 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