Clean up printing in MCU code and add new options

We now have four different ways of getting debug prints off of boards,
with varying tradeoffs. Split out the printing into dedicated libraries
that are easy to switch between to avoid duplicating even more code, and
also make using the new options easy.

USB is handy for testing the code on a Teensy.
Semihosting is nice in theory, but in practice it's super slow and
messes up the code's timing.
ITM works well, as long as you have a debugger attached.
Serial also works pretty well, but it means having another cable.

Change-Id: I7af5099d421c33f0324aeca92b46732e341848d4
diff --git a/motors/print/semihosting.cc b/motors/print/semihosting.cc
new file mode 100644
index 0000000..799b928
--- /dev/null
+++ b/motors/print/semihosting.cc
@@ -0,0 +1,24 @@
+#include "motors/print/semihosting.h"
+
+#include "motors/core/semihosting.h"
+
+namespace frc971 {
+namespace 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 */, gsl::span<const char>(ptr, len)};
+  return len - operation.Execute();
+}
+
+int SemihostingPrinting::WriteStdout(gsl::span<const char> buffer) {
+  semihosting::Write operation{2 /* stderr */, buffer};
+  return buffer.size() - operation.Execute();
+}
+
+}  // namespace motors
+}  // namespace frc971