]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
make the FastSpiByte interface generic and implement it in Atm128Spi
authormmaroti <mmaroti>
Mon, 9 Mar 2009 18:12:58 +0000 (18:12 +0000)
committermmaroti <mmaroti>
Mon, 9 Mar 2009 18:12:58 +0000 (18:12 +0000)
tos/chips/atm128/spi/Atm128SpiC.nc
tos/chips/atm128/spi/Atm128SpiP.nc
tos/platforms/iris/chips/rf230/HplRF2xxC.nc
tos/platforms/iris/chips/rf230/HplRF2xxP.nc

index c10a9f573c9b6af3ee18b0831692554cde603ee9..80d9243171adbcb1813ab29c92b1ba6ff39b2be7 100644 (file)
@@ -65,6 +65,7 @@
 configuration Atm128SpiC {
   provides interface Init;
   provides interface SpiByte;
+  provides interface FastSpiByte;
   provides interface SpiPacket;
   provides interface Resource[uint8_t id];
 }
@@ -76,6 +77,7 @@ implementation {
   Init         = SpiMaster;
   
   SpiByte      = SpiMaster;
+  FastSpiByte  = SpiMaster;
   SpiPacket    = SpiMaster;
   Resource     = SpiMaster;
 
index 6bec916b6c249e94f4677f514eab6d0d76af8f02..d457e42a7ce9847e932b08450bc98c315d66dd0d 100644 (file)
@@ -76,6 +76,7 @@ module Atm128SpiP @safe() {
   provides {
     interface Init;
     interface SpiByte;
+    interface FastSpiByte;
     interface SpiPacket;
     interface Resource[uint8_t id];
   }
@@ -125,13 +126,42 @@ implementation {
   }
 
   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
index cc3c1cf98f37dcb90f48425c317042d5e31be369..8d9a27fc2ed931ec774c7ea5213a715c5c122dd0 100644 (file)
@@ -49,8 +49,7 @@ implementation
        
        components Atm128SpiC as SpiC;
        SpiResource = SpiC.Resource[unique("Atm128SpiC.Resource")];
-
-       FastSpiByte = HplRF2xxP;
+       FastSpiByte = SpiC;
 
        components HplAtm128GeneralIOC as IO;
        SLP_TR = IO.PortB7;
index a97f81c67abdcf78a7d2e0888d13dd47e5f27e31..560fbe6fa6b3bb91ed005146da8de0a905e05fe1 100644 (file)
  * Author: Miklos Maroti
  */
 
-#include "Atm128Spi.h"
-
 module HplRF2xxP
 {
        provides
        {
                interface GpioCapture as IRQ;
                interface Init as PlatformInit;
-
-               interface FastSpiByte;
        }
 
        uses
@@ -83,43 +79,4 @@ implementation
        {
                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;
-       }
 }