[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/handhelds/tos/lib/SD SD_M.nc, 1.4, 1.5
steve ayer
ayer1 at users.sourceforge.net
Tue Aug 19 11:59:07 PDT 2008
Update of /cvsroot/tinyos/tinyos-1.x/contrib/handhelds/tos/lib/SD
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv22569
Modified Files:
SD_M.nc
Log Message:
mods that power cycle the sd card pins when the device is docked to
prevent windows from freezing in isolated cases.
Index: SD_M.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/handhelds/tos/lib/SD/SD_M.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SD_M.nc 27 Mar 2008 19:13:35 -0000 1.4
--- SD_M.nc 19 Aug 2008 18:59:04 -0000 1.5
***************
*** 114,117 ****
--- 114,150 ----
bool initialization = FALSE;
+ /*
+ * this routine is supposed to prevent windows from locking up when
+ * the device is docked.
+ */
+ void powerCycle() {
+ // wait until the tx buf is clear before killing the card
+ CS_HIGH();
+
+ // this connects the path from mcu to card
+ TOSH_MAKE_DOCK_N_OUTPUT();
+ TOSH_SET_DOCK_N_PIN();
+
+ TOSH_SET_SW_SD_PWR_N_PIN();
+ TOSH_CLR_SD_CS_N_PIN();
+
+ /*
+ * here we have to clear all input pins to the card, as
+ * the card in spi mode will leech power from any pin
+ */
+ call USARTControl.disableSPI();
+ TOSH_CLR_SD_DI_PIN();
+ TOSH_CLR_SD_DO_PIN();
+ TOSH_CLR_SD_CLK_PIN();
+
+ // undo the override above
+ TOSH_MAKE_DOCK_N_INPUT();
+
+ TOSH_uwait(20000);
+
+ TOSH_SET_SD_CS_N_PIN();
+ TOSH_CLR_SW_SD_PWR_N_PIN();
+ }
+
command result_t StdControl.init(){
TOSH_CLR_SW_SD_PWR_N_PIN(); // powers up module on models so equipped
***************
*** 126,129 ****
--- 159,163 ----
call DockInterrupt.edge(TRUE); // watch for it to go high, off the dock
signal SD.unavailable();
+ powerCycle();
}
else{
***************
*** 147,151 ****
command result_t StdControl.stop(){
TOSH_SET_SW_SD_PWR_N_PIN(); // powers down module
! // tbd TOSH_CLR_SD_CS_N_PIN();
call DockInterrupt.disable();
--- 181,185 ----
command result_t StdControl.stop(){
TOSH_SET_SW_SD_PWR_N_PIN(); // powers down module
! TOSH_CLR_SD_CS_N_PIN();
call DockInterrupt.disable();
***************
*** 157,162 ****
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);
--- 191,200 ----
async event void DockInterrupt.fired() {
if (call DockInterrupt.getValue() == TRUE){ // off the dock
! /*
! * commenting out this condition on the assumption that if we power cycle
! * the card after it's initialized, then we'll need to do it again.
! */
! // if(!initialization) // started up on the dock, bus blocked
! call SD.init();
call USARTControl.setClockRate(2, 0);
***************
*** 167,170 ****
--- 205,209 ----
call DockInterrupt.edge(TRUE);
signal SD.unavailable(); // tell the app to stop talking to the card
+ powerCycle();
}
call DockInterrupt.clear();
More information about the Tinyos-contrib-commits
mailing list