+ bool waitOnRx()
+ {
+ if (call Registers.getCtl0(UCMST)) {
+ while (!call Registers.getIfgRx() && !call Registers.getCtl1(UCSWRST));
+ return TRUE;
+ } else {
+ /* If SPI slave, the host could quit clocking any time, so we need a
+ * timeout.
+ */
+ unsigned i = 0;
+
+ while (++i) {
+ if (call Registers.getIfgRx())
+ return TRUE;
+ if (call Registers.getCtl1(UCSWRST))
+ return FALSE;
+ }
+ return FALSE;
+ }
+ }
+
+ bool waitOnTx()
+ {
+ if (call Registers.getCtl0(UCMST)) {
+ while (!call Registers.getIfgTx() && !call Registers.getCtl1(UCSWRST));
+ return TRUE;
+ } else {
+ /* If SPI slave, the host could quit clocking any time, so we need a
+ * timeout.
+ */
+ unsigned i = 0;
+
+ while (++i) {
+ if (call Registers.getIfgTx())
+ return TRUE;
+ if (call Registers.getCtl1(UCSWRST))
+ return FALSE;
+ }
+ return FALSE;
+ }
+ }
+
+ /* Return FALSE if we are in reset, so callers can clean up as appropriate. */
+ bool sendData()