[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/handhelds/tos/lib/SD SD_M.nc, 1.2, 1.3

steve ayer ayer1 at users.sourceforge.net
Tue Jan 22 12:20:48 PST 2008


Update of /cvsroot/tinyos/tinyos-1.x/contrib/handhelds/tos/lib/SD
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv30377

Modified Files:
	SD_M.nc 
Log Message:


added pins used on new SHIMMER2 platform (dock_n and ..sd_pwr_n), as
well as an addition of interrupts for docking that implement new
interface features, available and unavailable.  these are used to
indicate that a SHIMMER2 was docked, meaning that the msp430 cannot
talk to this bus (by h/w usurpation!).



Index: SD_M.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/handhelds/tos/lib/SD/SD_M.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SD_M.nc	25 Oct 2006 13:26:42 -0000	1.2
--- SD_M.nc	22 Jan 2008 20:20:46 -0000	1.3
***************
*** 99,104 ****
    }
    uses {
-     interface Timer;
      interface HPLUSARTControl as USARTControl;
      interface Leds;
    }
--- 99,104 ----
    }
    uses {
      interface HPLUSARTControl as USARTControl;
+     interface MSP430Interrupt as DockInterrupt;
      interface Leds;
    }
***************
*** 112,134 ****
  #define CS_HIGH()   SPI_TX_DONE; TOSH_SET_SD_CS_N_PIN();
  
    command result_t StdControl.init(){
!     call SD.init();
      return SUCCESS;
    }
  
    command result_t StdControl.start(){
!     //    call Timer.start(TIMER_REPEAT, 50 );
      return SUCCESS;
    }
  
    command result_t StdControl.stop(){
!     //    call Timer.stop();
!     return SUCCESS;
!   }
  
-   event result_t Timer.fired() {
      return SUCCESS;
    }
  
  
    // setup usart1 in spi mode
--- 112,172 ----
  #define CS_HIGH()   SPI_TX_DONE; TOSH_SET_SD_CS_N_PIN();
  
+   bool initialization = FALSE;
+ 
    command result_t StdControl.init(){
!     TOSH_CLR_SW_SD_PWR_N_PIN();    // powers up module on models so equipped
! 
!     /* 
!      * this pin, when low, tells us that the sd card is unavailable to the processor
!      * it should be attached to a pullup unless platform has a docking pin doing an sd override;
!      * generally, we need to avoid talking to the sd with the mcu when the pin is low;
!      * if it's low now, we'll fire an interrupt when the sd is available to software.
!      */
!     if(!TOSH_READ_DOCK_N_PIN()){
!       call DockInterrupt.edge(TRUE);    // watch for it to go high, off the dock
!       signal SD.unavailable();
!     }
!     else{
!       call DockInterrupt.edge(FALSE);    // tell us when we're docked
! 
!       call SD.init();
! 
!       signal SD.available();
!     }
!     call DockInterrupt.enable();
!     call DockInterrupt.clear();
!     
      return SUCCESS;
    }
  
    command result_t StdControl.start(){
! 
      return SUCCESS;
    }
  
    command result_t StdControl.stop(){
!     TOSH_SET_SW_SD_PWR_N_PIN();    // powers down module
! 
!     call DockInterrupt.disable();
!     call DockInterrupt.clear();
  
      return SUCCESS;
    }
  
+   async event void DockInterrupt.fired() {
+     if (call DockInterrupt.getValue() == TRUE){      // off the dock
+       if(!initialization)                            // started up on the dock, bus blocked
+ 	call SD.init();
+ 
+       call USARTControl.setClockRate(2, 0);
+       call DockInterrupt.edge(FALSE);
+       signal SD.available();                         // tell the app that it can talk to the sd card
+     }
+     else{
+       call DockInterrupt.edge(TRUE);      
+       signal SD.unavailable();                         // tell the app to stop talking to the card
+     }
+     call DockInterrupt.clear();
+   }
  
    // setup usart1 in spi mode
***************
*** 237,240 ****
--- 275,279 ----
    command result_t SD.init(){
      register uint8_t i;
+     uint8_t r;
  
      initSPI();
***************
*** 245,249 ****
        spiSendByte(0xff);
      
!     return call SD.setIdle();
    }
  
--- 284,291 ----
        spiSendByte(0xff);
      
!     if((r = call SD.setIdle()) == MMC_SUCCESS)
!       initialization = TRUE;
! 
!     return r;
    }
  
***************
*** 297,300 ****
--- 339,349 ----
      
    command result_t SD.readSector(uint32_t sector, uint8_t * pBuffer) {
+     /*
+      * need to test dock pin for some platforms
+      * on others this will be attached to a pullup
+      */
+     if(!TOSH_READ_DOCK_N_PIN())
+       return MMC_INIT_ERROR;
+ 
      return call SD.readBlock(sector * 512, 512, pBuffer);
    }
***************
*** 347,350 ****
--- 396,406 ----
  
    command result_t SD.writeSector(uint32_t sector, uint8_t * pBuffer){
+     /*
+      * need to test dock pin for some platforms
+      * on others this will be attached to a pullup
+      */
+     if(!TOSH_READ_DOCK_N_PIN())
+       return MMC_INIT_ERROR;
+ 
      return call SD.writeBlock(sector * 512, 512, pBuffer);
    }



More information about the Tinyos-contrib-commits mailing list