]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/msp430/usci/Msp430SpiP.nc
Msp430SpiP.nc: allow users to call SpiPacket.send() from SpiPacket.sendDone().
[tinyos-2.x.git] / tos / chips / msp430 / usci / Msp430SpiP.nc
index 84878dd17b75f6b90aa37ceefe808109034b9153..eb217b3f92068e3cc76d2f0f4999bfe87d534359 100644 (file)
@@ -144,13 +144,13 @@ implementation {
       call Registers.clrIfgRx();
 
       /* Restore pins to their pre-configure state */
-      if (is4pin() && (m_pins & PINS_STE))
+      if (is4pin() && (m_pins & (1 << PINS_STE)))
        call STE.selectIOFunc();
-      if (m_pins & PINS_SIMO)
+      if (m_pins & (1 << PINS_SIMO))
        call SIMO.selectIOFunc();
-      if (m_pins & PINS_SOMI)
+      if (m_pins & (1 << PINS_SOMI))
        call SOMI.selectIOFunc();
-      if (m_pins & PINS_CLK)
+      if (m_pins & (1 << PINS_CLK))
        call CLK.selectIOFunc();
     }
   }
@@ -160,9 +160,9 @@ implementation {
     if (isBusy())
       return 0;
     else {
-      while (!call Registers.getIfgTx());
+      while (!call Registers.getIfgTx() && !call Registers.getCtl1(UCSWRST));
       call Registers.setTxbuf(byte);
-      while(!call Registers.getIfgRx());
+      while(!call Registers.getIfgRx() && !call Registers.getCtl1(UCSWRST));
       return call Registers.getRxbuf();
     }
   }
@@ -215,8 +215,8 @@ implementation {
   task void signalSendDone()
   {
     atomic {
-      signal SpiPacket.sendDone(m_txBuf, m_rxBuf, m_len, SUCCESS);
       m_len = 0;
+      signal SpiPacket.sendDone(m_txBuf, m_rxBuf, m_len, SUCCESS);
     }
   }