]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/msp430/usci/Msp430SpiP.nc
USCI fixes.
[tinyos-2.x.git] / tos / chips / msp430 / usci / Msp430SpiP.nc
index b4a25436232a75d2e5010ce30edac84395a8c8db..142edb7b9f9996a8a15b1ad96a759a2b8b2a8c73 100644 (file)
@@ -166,7 +166,7 @@ implementation {
     error_t error = (m_pos == m_len) ? SUCCESS : FAIL;
 
     m_len = 0;
-    signal SpiPacket.sendDone(m_txBuf, m_rxBuf, m_pos, error);
+    atomic signal SpiPacket.sendDone(m_txBuf, m_rxBuf, m_pos, error);
   }
 
   async command void ResourceConfigure.unconfigure()
@@ -229,13 +229,15 @@ implementation {
 
   async command uint8_t SpiByte.write(uint8_t byte)
   {
-    if (isBusy())
-      return 0;
-    else {
-      waitOnTx();
-      call Registers.setTxbuf(byte);
-      waitOnRx();
-      return call Registers.getRxbuf();
+    atomic {
+      if (isBusy())
+       return 0;
+      else {
+       waitOnTx();
+       call Registers.setTxbuf(byte);
+       waitOnRx();
+       return call Registers.getRxbuf();
+      }
     }
   }
 
@@ -248,6 +250,7 @@ implementation {
 
       if (end > m_len)
        end = m_len;
+      waitOnTx(); /* Don't assume that the last tx is done already */
       call Registers.setTxbuf(m_txBuf ? m_txBuf[m_pos] : 0);
       while (++m_pos < end) {
        waitOnRx();