X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=blobdiff_plain;f=tos%2Fchips%2Fatm128%2Fspi%2FAtm128SpiP.nc;h=1838f7b0d00a48c6a76858b0341c825ebeca97d7;hp=6bec916b6c249e94f4677f514eab6d0d76af8f02;hb=e9bfab607e051bae6afb47b44892ce37541d1b44;hpb=adf1de6c009d13b7b52e68535c63b28f59c97400 diff --git a/tos/chips/atm128/spi/Atm128SpiP.nc b/tos/chips/atm128/spi/Atm128SpiP.nc index 6bec916b..1838f7b0 100644 --- a/tos/chips/atm128/spi/Atm128SpiP.nc +++ b/tos/chips/atm128/spi/Atm128SpiP.nc @@ -76,6 +76,7 @@ module Atm128SpiP @safe() { provides { interface Init; interface SpiByte; + interface FastSpiByte; interface SpiPacket; interface Resource[uint8_t id]; } @@ -125,13 +126,46 @@ implementation { } async command uint8_t SpiByte.write( uint8_t tx ) { + /* There is no need to enable the SPI bus and update the power state + here since that must have been done when the resource was granted. + However there seems to be a bug somewhere in the radio driver for + the MicaZ platform so we cannot remove the following two lines + before that problem is resolved. (Miklos Maroti) */ call Spi.enableSpi(TRUE); call McuPowerState.update(); + call Spi.write( tx ); while ( !( SPSR & 0x80 ) ); return call Spi.read(); } + inline async command void FastSpiByte.splitWrite(uint8_t data) { + call Spi.write(data); + } + + inline async command uint8_t FastSpiByte.splitRead() { + while( !( SPSR & 0x80 ) ) + ; + return call Spi.read(); + } + + inline async command uint8_t FastSpiByte.splitReadWrite(uint8_t data) { + uint8_t b; + + while( !( SPSR & 0x80 ) ) + ; + b = call Spi.read(); + call Spi.write(data); + + return b; + } + + inline async command uint8_t FastSpiByte.write(uint8_t data) { + call Spi.write(data); + while( !( SPSR & 0x80 ) ) + ; + return call Spi.read(); + } /** * This component sends SPI packets in chunks of size SPI_ATOMIC_SIZE