From: R. Steve McKown Date: Thu, 8 Apr 2010 01:16:46 +0000 (-0600) Subject: USCI fixes. X-Git-Tag: debian/2.1.0-4-1tmi~1^2~4 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=88bc2aa5e7e7c3870700a40d78829b51d3ae3754 USCI fixes. * 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. --- diff --git a/tos/chips/msp430/usci/Msp430SpiP.nc b/tos/chips/msp430/usci/Msp430SpiP.nc index 22bfbbd3..142edb7b 100644 --- a/tos/chips/msp430/usci/Msp430SpiP.nc +++ b/tos/chips/msp430/usci/Msp430SpiP.nc @@ -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(); diff --git a/tos/chips/msp430/usci/Msp430UartP.nc b/tos/chips/msp430/usci/Msp430UartP.nc index dcdc5b38..a4bec076 100644 --- a/tos/chips/msp430/usci/Msp430UartP.nc +++ b/tos/chips/msp430/usci/Msp430UartP.nc @@ -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);