configuration Atm128SpiC {
provides interface Init;
provides interface SpiByte;
+ provides interface FastSpiByte;
provides interface SpiPacket;
provides interface Resource[uint8_t id];
}
Init = SpiMaster;
SpiByte = SpiMaster;
+ FastSpiByte = SpiMaster;
SpiPacket = SpiMaster;
Resource = SpiMaster;
provides {
interface Init;
interface SpiByte;
+ interface FastSpiByte;
interface SpiPacket;
interface Resource[uint8_t id];
}
}
async command uint8_t SpiByte.write( uint8_t tx ) {
- call Spi.enableSpi(TRUE);
- call McuPowerState.update();
+ /* no need to enable the SPI bus since that must have been done
+ when the resource was granted */
+ // 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
components Atm128SpiC as SpiC;
SpiResource = SpiC.Resource[unique("Atm128SpiC.Resource")];
-
- FastSpiByte = HplRF2xxP;
+ FastSpiByte = SpiC;
components HplAtm128GeneralIOC as IO;
SLP_TR = IO.PortB7;
* Author: Miklos Maroti
*/
-#include "Atm128Spi.h"
-
module HplRF2xxP
{
provides
{
interface GpioCapture as IRQ;
interface Init as PlatformInit;
-
- interface FastSpiByte;
}
uses
{
call Capture.stop();
}
-
- inline async command void FastSpiByte.splitWrite(uint8_t data)
- {
- // the SPI must have been started, so do not waste time here
- // SET_BIT(SPCR, SPE);
-
- SPDR = data;
- }
-
- inline async command uint8_t FastSpiByte.splitRead()
- {
- while( !( SPSR & 0x80 ) )
- ;
- return SPDR;
- }
-
- inline async command uint8_t FastSpiByte.splitReadWrite(uint8_t data)
- {
- uint8_t b;
-
- while( !( SPSR & 0x80 ) )
- ;
- b = SPDR;
- SPDR = data;
-
- return b;
- }
-
- inline async command uint8_t FastSpiByte.write(uint8_t data)
- {
- // the SPI must have been started, so do not waste time here
- // SET_BIT(SPCR, SPE);
-
- SPDR = data;
- while( !( SPSR & 0x80 ) )
- ;
-
- return SPDR;
- }
}