]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/cc2420/spi/CC2420SpiP.nc
turn on safe compilation for some modules
[tinyos-2.x.git] / tos / chips / cc2420 / spi / CC2420SpiP.nc
index cdc2df9363e95232c469c68607b29faf1b5e064d..d725e6f0ba48b7f0ab1a353b585867b80a89c056 100644 (file)
  * @author Jonathan Hui <jhui@archrock.com>
  * @author David Moss
  * @author Roman Lim
+ * @author Razvan Musaloie-E.
+ * @author Jeonggil Ko
  * @version $Revision$ $Date$
  */
 
-module CC2420SpiP {
+module CC2420SpiP @safe() {
 
   provides {
     interface ChipSpiResource;
@@ -244,8 +246,8 @@ implementation {
     
     addr += offset;
 
-    call SpiByte.write( addr | 0x80 );
-    status = call SpiByte.write( ( ( addr >> 1 ) & 0xc0 ) | 0x20 );
+    status = call SpiByte.write( addr | 0x80 );
+    call SpiByte.write( ( ( addr >> 1 ) & 0xC0 ) | 0x20 );
     for ( ; len; len-- ) {
       *data++ = call SpiByte.write( 0 );
     }
@@ -260,6 +262,8 @@ implementation {
                                                             uint8_t len ) {
 
     cc2420_status_t status = 0;
+    uint8_t tmpLen = len;
+    uint8_t * COUNT(tmpLen) tmpData = (uint8_t * COUNT(tmpLen))data;
 
     atomic {
       if(call WorkingState.isIdle()) {
@@ -269,10 +273,10 @@ implementation {
     
     addr += offset;
 
-    call SpiByte.write( addr | 0x80 );
+    status = call SpiByte.write( addr | 0x80 );
     call SpiByte.write( ( addr >> 1 ) & 0xc0 );
     for ( ; len; len-- ) {
-      status = call SpiByte.write( *data++ );
+      call SpiByte.write( tmpData[tmpLen-len] );
     }
 
     return status;