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();
+ }
}
}
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()