]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
USCI fixes.
authorR. Steve McKown <rsmckown@gmail.com>
Thu, 8 Apr 2010 01:16:46 +0000 (19:16 -0600)
committerR. Steve McKown <rsmckown@gmail.com>
Tue, 13 Apr 2010 20:18:27 +0000 (14:18 -0600)
* Watch out for sendData() clobbering TXBUF.
* May solve a loss of UART TX chars.
* USCI UartStream.send() gains nothing by immediately sending the 1st byte.
* m_sobuf cannot be null in Interrupts.tx, so remove the check.

tos/chips/msp430/usci/Msp430SpiP.nc
tos/chips/msp430/usci/Msp430UartP.nc

index 22bfbbd376b1aa00237b8539a94b7ab402ea7a4f..142edb7b9f9996a8a15b1ad96a759a2b8b2a8c73 100644 (file)
@@ -250,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();
index dcdc5b380d8370aa01507bf9783a5ececba13822..a4bec07698e521599d379e4c4634fb885e8d296a 100644 (file)
@@ -146,14 +146,9 @@ implementation {
     atomic {
       if (m_sobuf || !buf || !len)
        return FAIL;
-      m_sobuf = buf;
-      m_solen = len;
-      while (!call Registers.getIfgTx());
+      m_sbuf = m_sobuf = buf;
+      m_slen = m_solen = len;
       call Registers.setIeTx();
-      call Registers.setTxbuf(*m_sobuf);
-      m_slen = m_solen - 1;
-      if (m_slen)
-       m_sbuf = m_sobuf + 1;
       return SUCCESS;
     }
   }
@@ -163,12 +158,13 @@ implementation {
     /* FIXME: this can cause an arbitrarily long ISR, if m_slen is large.
      * But depending on timing, we may always only write 1 byte.
      */
+    while (!call Registers.getIfgTx()); /* in case interleaved UB.send */
     while (m_slen && call Registers.getIfgTx()) {
       call Registers.setTxbuf(*m_sbuf);
       if (--m_slen)
        m_sbuf++;
     }
-    if (m_slen == 0 && m_sobuf) {
+    if (m_slen == 0) {
       call Registers.clrIeTx();
       m_sobuf = 0;
       signal UartStream.sendDone(m_sobuf, m_solen, SUCCESS);