From 2fc550ecfc8fb03f258b5a692c8e7e90793aced2 Mon Sep 17 00:00:00 2001 From: "R. Steve McKown" Date: Mon, 2 Aug 2010 14:25:37 -0600 Subject: [PATCH] Interrupts.tx() signal is only relevant when UartStream.send() pending. --- tos/chips/msp430/usci/Msp430UartP.nc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tos/chips/msp430/usci/Msp430UartP.nc b/tos/chips/msp430/usci/Msp430UartP.nc index 72df1df0..cdc08089 100644 --- a/tos/chips/msp430/usci/Msp430UartP.nc +++ b/tos/chips/msp430/usci/Msp430UartP.nc @@ -158,16 +158,18 @@ 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) { - call Registers.clrIeTx(); - m_sobuf = 0; - signal UartStream.sendDone(m_sobuf, m_solen, SUCCESS); + if (m_sobuf) { + 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) { + call Registers.clrIeTx(); + m_sobuf = 0; + signal UartStream.sendDone(m_sobuf, m_solen, SUCCESS); + } } } -- 2.39.2