blob: 310bb49faf63e37c89a918ec6a491383f633f43a [file] [log] [blame]
#include "motors/print/semihosting.h"
#include "absl/types/span.h"
#include "motors/core/semihosting.h"
namespace frc971::motors {
::std::unique_ptr<PrintingImplementation> CreatePrinting(
const PrintingParameters & /*parameters*/) {
return ::std::unique_ptr<PrintingImplementation>(new SemihostingPrinting());
}
extern "C" int _write(const int /*file*/, char *const ptr, const int len) {
semihosting::Write operation{2 /* stderr */,
absl::Span<const char>(ptr, len)};
return len - operation.Execute();
}
int SemihostingPrinting::WriteStdout(absl::Span<const char> buffer) {
semihosting::Write operation{2 /* stderr */, buffer};
return buffer.size() - operation.Execute();
}
} // namespace frc971::motors