Add a working CDC TTY USB device
I'm pretty sure it reliably moves data in both directions, but it has a
lot of TODOs left wrt error handling.
Change-Id: I1d96a63eea7bdc08f6ec78c868c4a1ccbfbda600
diff --git a/motors/util.h b/motors/util.h
index b215996..e4a0271 100644
--- a/motors/util.h
+++ b/motors/util.h
@@ -150,6 +150,18 @@
#define USB0_ENDPTn(n) (*(volatile uint8_t *)(0x400720C0 + ((n)*4)))
#ifdef __cplusplus
+// RAII class to disable interrupts temporarily.
+class DisableInterrupts {
+ public:
+ DisableInterrupts() { __disable_irq(); }
+ ~DisableInterrupts() { __enable_irq(); }
+
+ DisableInterrupts(const DisableInterrupts &) = delete;
+ DisableInterrupts &operator=(const DisableInterrupts &) = delete;
+};
+#endif // __cplusplus
+
+#ifdef __cplusplus
}
#endif