From 753d22d3f0f9764e9a4cdfbefdcf45ff9db4c3cc Mon Sep 17 00:00:00 2001 From: "R. Steve McKown" Date: Wed, 7 Apr 2010 18:17:22 -0600 Subject: [PATCH] Remove redundant atomic blocks. --- tos/chips/msp430/usci/Msp430SpiP.nc | 16 +++++++------ tos/chips/msp430/usci/Msp430UartP.nc | 34 +++++++++++++--------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tos/chips/msp430/usci/Msp430SpiP.nc b/tos/chips/msp430/usci/Msp430SpiP.nc index 6d8e9f4c..22bfbbd3 100644 --- a/tos/chips/msp430/usci/Msp430SpiP.nc +++ b/tos/chips/msp430/usci/Msp430SpiP.nc @@ -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(); + } } } diff --git a/tos/chips/msp430/usci/Msp430UartP.nc b/tos/chips/msp430/usci/Msp430UartP.nc index 1b595bfd..742c1674 100644 --- a/tos/chips/msp430/usci/Msp430UartP.nc +++ b/tos/chips/msp430/usci/Msp430UartP.nc @@ -236,25 +236,23 @@ implementation { async event void Interrupts.rx(uint8_t byte) { - atomic { - if (m_robuf) { - /* receive() takes precedence if active */ - while (m_rlen && call Registers.getIfgRx()) { - *m_rbuf = byte; - if (--m_rlen) - m_rbuf++; - } - if (m_rlen == 0 && m_robuf) { - if (m_rxie) { - call Registers.clrIeRx(); - call Registers.clrIfgRx(); - } - m_robuf = 0; - signal UartStream.receiveDone(m_robuf, m_rolen, SUCCESS); + if (m_robuf) { + /* receive() takes precedence if active */ + while (m_rlen && call Registers.getIfgRx()) { + *m_rbuf = byte; + if (--m_rlen) + m_rbuf++; + } + if (m_rlen == 0 && m_robuf) { + if (m_rxie) { + call Registers.clrIeRx(); + call Registers.clrIfgRx(); } - } else - signal UartStream.receivedByte(byte); - } + m_robuf = 0; + signal UartStream.receiveDone(m_robuf, m_rolen, SUCCESS); + } + } else + signal UartStream.receivedByte(byte); } default async command const msp430_usci_uart_t* Configure.get() -- 2.39.2