call Registers.clrIfgRx();
/* Restore pins to their pre-configure state */
- if (is4pin() && (m_pins & PINS_STE))
+ if (is4pin() && (m_pins & (1 << PINS_STE)))
call STE.selectIOFunc();
- if (m_pins & PINS_SIMO)
+ if (m_pins & (1 << PINS_SIMO))
call SIMO.selectIOFunc();
- if (m_pins & PINS_SOMI)
+ if (m_pins & (1 << PINS_SOMI))
call SOMI.selectIOFunc();
- if (m_pins & PINS_CLK)
+ if (m_pins & (1 << PINS_CLK))
call CLK.selectIOFunc();
}
}
if (end > m_len)
end = m_len;
- call Registers.setTxbuf((m_txBuf) ? m_txBuf[m_pos] : 0);
+ call Registers.setTxbuf(m_txBuf ? m_txBuf[m_pos] : 0);
while (++m_pos < end) {
- while (!call Registers.getIfgRx());
+ while (!call Registers.getIfgRx() && !call Registers.getCtl1(UCSWRST));
+ tmp = call Registers.getRxbuf();
if (m_rxBuf)
m_rxBuf[m_pos - 1] = call Registers.getRxbuf();
- else
- tmp = call Registers.getRxbuf();
- call Registers.setTxbuf((m_txBuf) ? m_txBuf[m_pos] : 0);
+ call Registers.setTxbuf(m_txBuf ? m_txBuf[m_pos] : 0);
}
}
}
task void signalSendDone()
{
atomic {
- signal SpiPacket.sendDone(m_txBuf, m_rxBuf, m_len, SUCCESS);
+ uint16_t len = m_len;
m_len = 0;
+ signal SpiPacket.sendDone(m_txBuf, m_rxBuf, len, SUCCESS);
}
}
async event void Interrupts.rx(uint8_t byte)
{
if (m_rxBuf)
- m_rxBuf[m_pos - 1] = call Registers.getRxbuf();
- else
- call Registers.getRxbuf();
+ m_rxBuf[m_pos - 1] = byte;
if (m_pos < m_len)
sendData();