*
* TODO: Implement error checking via UCxxSTAT
*
- * @author R. Steve McKown <smckown@gmail.com>
+ * @author R. Steve McKown <rsmckown@gmail.com>
*/
generic module Msp430SpiP(uint16_t blockSize) {
{
atomic {
/* Disable the device */
- call Registers.setCtl1(UCSYNC);
+ call Registers.setCtl1(UCSWRST);
/* Clear interrupts and interrupt flags. We only used Rx */
call Registers.clrIeRx();
if (isBusy())
return 0;
else {
- while (!call Registers.getIfgTx());
+ while (!call Registers.getIfgTx() && !call Registers.getCtl1(UCSWRST));
call Registers.setTxbuf(byte);
- while(!call Registers.getIfgRx());
+ while(!call Registers.getIfgRx() && !call Registers.getCtl1(UCSWRST));
return call Registers.getRxbuf();
}
}