Update of /cvsroot/firebug/fireboard/beta/tos/sensorboards/mts400
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16141
Modified Files:
TaosPhotoM.nc
Log Message:
initiate packet write from a task instead of async routine
Index: TaosPhotoM.nc
===================================================================
RCS file: /cvsroot/firebug/fireboard/beta/tos/sensorboards/mts400/TaosPhotoM.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TaosPhotoM.nc 24 May 2005 21:57:34 -0000 1.2
--- TaosPhotoM.nc 4 Jul 2005 03:05:37 -0000 1.3
***************
*** 181,184 ****
--- 181,195 ----
return FAIL;
}
+
+
+ // Handling the start of the write in this task has a disadvantage
+ // in the case that the writePacket fails. In that case code which
+ // calls I2CPacket.writePacket directly and used the status to return
+ // a result is better because it allows the caller to do error recovery.
+ task void readTaosADCdata() {
+ call I2CPacket.writePacket(1,(char*)&tempvalue,0x01);
+ return;
+ }
+
/******************************************************************************
* Read Taos adc data
***************
*** 186,214 ****
* Cmd to read channel 1 + enable adc/power = 0x83
*****************************************************************************/
! async command result_t ADC.getData[uint8_t id]() {
!
!
! uint8_t l_state;
! SODbg(DBG_USR2, "TaosPhoto:getData \n");
! atomic l_state = state;
! if (l_state == IDLE){
! if (id == 0){
! atomic {
! tempvalue = 0x43; //read channel 0
! state = READ_0;
! }
! return call I2CPacket.writePacket(1,(char*)&tempvalue,0x01);
! }
! else if (id == 1){
! atomic{
! tempvalue = 0x83; //read channel 1
! state = READ_1;
! }
! return call I2CPacket.writePacket(1,(char*)&tempvalue,0x01);
! }
! }
! atomic state = IDLE;
! return FAIL;
! }
/******************************************************************************
* I2C write packet complete
--- 197,226 ----
* Cmd to read channel 1 + enable adc/power = 0x83
*****************************************************************************/
! async command result_t ADC.getData[uint8_t id]() {
! uint8_t l_state;
! SODbg(DBG_USR2, "TaosPhoto:getData \n");
! atomic l_state = state;
! if (l_state == IDLE){
! if (id == 0){
! atomic {
! tempvalue = 0x43; //read channel 0
! state = READ_0;
! }
! post readTaosADCdata();
! return SUCCESS;
! }
! else if (id == 1) {
! atomic{
! tempvalue = 0x83; //read channel 1
! state = READ_1;
! }
! post readTaosADCdata();
! return SUCCESS;
! };
! };
! atomic state = IDLE;
! return FAIL;
! }
!
/******************************************************************************
* I2C write packet complete
|