[Tinyos-commits] CVS: tinyos-1.x/tos/platform/telos HumidityC.nc,
1.2, 1.3 HumidityM.nc, 1.4, 1.5 HumidityProtocolM.nc, 1.2,
1.3 HumidityProtocolC.nc, 1.3, NONE
Joe Polastre
jpolastre at users.sourceforge.net
Fri Jun 17 18:13:01 PDT 2005
- Previous message: [Tinyos-commits]
CVS: tinyos-1.x/tos/platform/telos Hamamatsu.h, 1.3,
1.4 HamamatsuC.nc, 1.4, 1.5 HamamatsuM.nc, 1.5, 1.6
- Next message: [Tinyos-commits] CVS: tinyos-1.x/tools/make deluge.extra, NONE,
1.1 redeluge.extra, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/tos/platform/telos
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19758
Modified Files:
HumidityC.nc HumidityM.nc HumidityProtocolM.nc
Removed Files:
HumidityProtocolC.nc
Log Message:
Clean up of humidity sensor driver. new driver has amazing new features
not found in any previous version of the humidity sensor driver.
These features include, but are not limited to:
* less race conditions! or at least more uses of the 'norace' keyword
either way, you don't get warnings.
* removed HumidityProtocolC. You shouldn't be using HumidityProtocolC
anyway. Bad. Don't use it. Now you can't. Bwhahahah
* none of those pesky "called asynchronously" message. you didn't like
them anyway.
oh, and by fixing the atomic warnings and asynchronous calls, the sensor
driver still appears to work. tested with oscilloscope, the tinyos
test application that has withstood the generations of tinyos language changes
Index: HumidityC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/platform/telos/HumidityC.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** HumidityC.nc 13 Jun 2005 20:59:50 -0000 1.2
--- HumidityC.nc 18 Jun 2005 01:12:59 -0000 1.3
***************
*** 1,4 ****
/* tab:4
! * "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
--- 1,5 ----
+ // $Id$
/* tab:4
! * "Copyright (c) 2000-2005 The Regents of the University of California.
* All rights reserved.
*
***************
*** 27,35 ****
* 94704. Attention: Intel License Inquiry.
*/
! /*
! *
! * Authors: Joe Polastre
! *
! * $Id$
*/
includes Humidity;
--- 28,33 ----
* 94704. Attention: Intel License Inquiry.
*/
! /**
! * @author Joe Polastre
*/
includes Humidity;
***************
*** 47,51 ****
implementation
{
! components HumidityM, TimerC, HumidityProtocolC;
SplitControl = HumidityM;
--- 45,49 ----
implementation
{
! components HumidityM, TimerC, HumidityProtocolM, HumidityInterruptC;
SplitControl = HumidityM;
***************
*** 58,67 ****
HumidityM.Timer -> TimerC.Timer[unique("Timer")];
! HumidityM.SensorControl -> HumidityProtocolC.StdControl;
! HumidityM.HumSensor -> HumidityProtocolC.HumSensor;
! HumidityM.TempSensor -> HumidityProtocolC.TempSensor;
! HumidityM.HumError -> HumidityProtocolC.HumError;
! HumidityM.TempError -> HumidityProtocolC.TempError;
}
--- 56,68 ----
HumidityM.Timer -> TimerC.Timer[unique("Timer")];
! HumidityM.SensorControl -> HumidityProtocolM.StdControl;
! HumidityM.HumSensor -> HumidityProtocolM.HumSensor;
! HumidityM.TempSensor -> HumidityProtocolM.TempSensor;
! HumidityM.HumError -> HumidityProtocolM.HumError;
! HumidityM.TempError -> HumidityProtocolM.TempError;
+ HumidityProtocolM.SensirionInterrupt -> HumidityInterruptC;
+
+ HumidityProtocolM.Timer -> TimerC.Timer[unique("Timer")];
}
Index: HumidityM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/platform/telos/HumidityM.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** HumidityM.nc 13 Jun 2005 21:28:33 -0000 1.4
--- HumidityM.nc 18 Jun 2005 01:12:59 -0000 1.5
***************
*** 1,4 ****
/* tab:4
! * "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
--- 1,5 ----
+ // $Id$
/* tab:4
! * "Copyright (c) 2000-2005 The Regents of the University of California.
* All rights reserved.
*
***************
*** 27,35 ****
* 94704. Attention: Intel License Inquiry.
*/
! /*
! *
! * Authors: Joe Polastre
! *
! * $Id$
*/
includes Humidity;
--- 28,33 ----
* 94704. Attention: Intel License Inquiry.
*/
! /**
! * @author Joe Polastre
*/
includes Humidity;
***************
*** 57,62 ****
implementation {
! char state;
! char id;
enum { IDLE = 0, WARM_UP, POWER_OFF, SAMPLE,
--- 55,62 ----
implementation {
! uint8_t state;
! uint8_t id;
!
! norace uint16_t adcdata;
enum { IDLE = 0, WARM_UP, POWER_OFF, SAMPLE,
***************
*** 75,78 ****
--- 75,108 ----
}
+ task void humDone() {
+ bool sig = FALSE;
+ atomic {
+ if (state == SAMPLE) {
+ state = IDLE;
+ sig = TRUE;
+ }
+ }
+
+ if (sig) {
+ call SensorControl.stop();
+ signal Humidity.dataReady(adcdata);
+ }
+ }
+
+ task void tempDone() {
+ bool sig = FALSE;
+ atomic {
+ if (state == SAMPLE) {
+ state = IDLE;
+ sig = TRUE;
+ }
+ }
+
+ if (sig) {
+ call SensorControl.stop();
+ signal Temperature.dataReady(adcdata);
+ }
+ }
+
command result_t SplitControl.init() {
state = POWER_OFF;
***************
*** 86,92 ****
// turn the sensor on
call TimerControl.start();
! HUMIDITY_MAKE_PWR_OUTPUT();
! HUMIDITY_SET_PWR();
! state = WARM_UP;
call Timer.start(TIMER_ONE_SHOT, 80);
return SUCCESS;
--- 116,124 ----
// turn the sensor on
call TimerControl.start();
! atomic {
! HUMIDITY_MAKE_PWR_OUTPUT();
! HUMIDITY_SET_PWR();
! state = WARM_UP;
! }
call Timer.start(TIMER_ONE_SHOT, 80);
return SUCCESS;
***************
*** 94,98 ****
command result_t SplitControl.stop() {
! state = POWER_OFF;
// turn the sensor off
call SensorControl.stop();
--- 126,130 ----
command result_t SplitControl.stop() {
! atomic state = POWER_OFF;
// turn the sensor off
call SensorControl.stop();
***************
*** 103,116 ****
event result_t Timer.fired() {
! if (state == WARM_UP) {
! state = IDLE;
! post startDone();
! }
! else if (state == SAMPLE) {
! if (id == HUMIDITY) {
! return call HumSensor.getData();
}
- else if (id == HUMIDITY_TEMP)
- return call TempSensor.getData();
}
return SUCCESS;
--- 135,150 ----
event result_t Timer.fired() {
! atomic {
! if (state == WARM_UP) {
! state = IDLE;
! post startDone();
! }
! else if (state == SAMPLE) {
! if (id == HUMIDITY) {
! return call HumSensor.getData();
! }
! else if (id == HUMIDITY_TEMP)
! return call TempSensor.getData();
}
}
return SUCCESS;
***************
*** 127,151 ****
}
async command result_t Humidity.getData() {
! if (state == IDLE)
! {
! state = SAMPLE;
! id = HUMIDITY;
! call SensorControl.start();
! return call Timer.start(TIMER_ONE_SHOT, 11);
}
! //state = IDLE;
! return FAIL;
}
async command result_t Temperature.getData() {
! if (state == IDLE)
! {
! state = SAMPLE;
! id = HUMIDITY_TEMP;
! call SensorControl.start();
! return call Timer.start(TIMER_ONE_SHOT, 11);
}
! return FAIL;
}
--- 161,199 ----
}
+ task void startSensor() {
+ call SensorControl.start();
+ call Timer.start(TIMER_ONE_SHOT, 11);
+ }
+
async command result_t Humidity.getData() {
! result_t res = FAIL;
!
! atomic {
! if (state == IDLE) {
! state = SAMPLE;
! id = HUMIDITY;
! res = SUCCESS;
! }
}
!
! if (res == SUCCESS)
! return post startSensor();
! return res;
}
async command result_t Temperature.getData() {
! result_t res = FAIL;
!
! atomic {
! if (state == IDLE) {
! state = SAMPLE;
! id = HUMIDITY_TEMP;
! res = SUCCESS;
! }
}
!
! if (res == SUCCESS)
! return post startSensor();
! return res;
}
***************
*** 161,168 ****
async event result_t TempSensor.dataReady(uint16_t data) {
! if (state == SAMPLE) {
! state = IDLE;
! call SensorControl.stop();
! signal Temperature.dataReady(data);
}
return SUCCESS;
--- 209,216 ----
async event result_t TempSensor.dataReady(uint16_t data) {
! adcdata = data;
! if (!post tempDone()) {
! atomic state = IDLE;
! signal Temperature.dataReady(data);
}
return SUCCESS;
***************
*** 170,177 ****
async event result_t HumSensor.dataReady(uint16_t data) {
! if (state == SAMPLE) {
! state = IDLE;
! call SensorControl.stop();
! signal Humidity.dataReady(data);
}
return SUCCESS;
--- 218,225 ----
async event result_t HumSensor.dataReady(uint16_t data) {
! adcdata = data;
! if (!post humDone()) {
! atomic state = IDLE;
! signal Humidity.dataReady(data);
}
return SUCCESS;
***************
*** 195,199 ****
event result_t HumError.error(uint8_t token) {
! state = IDLE;
call SensorControl.stop();
return signal HumidityError.error(token);
--- 243,247 ----
event result_t HumError.error(uint8_t token) {
! atomic state = IDLE;
call SensorControl.stop();
return signal HumidityError.error(token);
***************
*** 201,205 ****
event result_t TempError.error(uint8_t token) {
! state = IDLE;
call SensorControl.stop();
return signal TemperatureError.error(token);
--- 249,253 ----
event result_t TempError.error(uint8_t token) {
! atomic state = IDLE;
call SensorControl.stop();
return signal TemperatureError.error(token);
Index: HumidityProtocolM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/platform/telos/HumidityProtocolM.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** HumidityProtocolM.nc 13 Jun 2005 20:52:04 -0000 1.2
--- HumidityProtocolM.nc 18 Jun 2005 01:12:59 -0000 1.3
***************
*** 1,4 ****
/* tab:4
! * "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
--- 1,5 ----
+ // $Id$
/* tab:4
! * "Copyright (c) 2000-2005 The Regents of the University of California.
* All rights reserved.
*
***************
*** 27,35 ****
* 94704. Attention: Intel License Inquiry.
*/
! /*
! *
! * Authors: Mohammad Rahmim, Joe Polastre
! *
! * $Id$
*/
--- 28,34 ----
* 94704. Attention: Intel License Inquiry.
*/
! /**
! * @author Mohammad Rahmim
! * @author Joe Polastre
*/
***************
*** 63,71 ****
task void signalHumError() {
! signal HumError.error(errornum);
}
task void signalTempError() {
! signal TempError.error(errornum);
}
--- 62,74 ----
task void signalHumError() {
! uint8_t _error;
! atomic _error = errornum;
! signal HumError.error(_error);
}
task void signalTempError() {
! uint8_t _error;
! atomic _error = errornum;
! signal TempError.error(_error);
}
***************
*** 129,132 ****
--- 132,139 ----
}
+ task void startTimeoutTimer() {
+ call Timer.start(TIMER_REPEAT, HUMIDITY_TIMEOUT_MS);
+ }
+
static inline char processCommand(int cmd)
{
***************
*** 153,158 ****
if(HUMIDITY_GET_DATA())
{
! reset();
! errornum = 2;
if ((CMD == TOSH_HUMIDITY_ADDR) && (humerror == TRUE))
post signalHumError();
--- 160,167 ----
if(HUMIDITY_GET_DATA())
{
! atomic {
! reset();
! errornum = 2;
! }
if ((CMD == TOSH_HUMIDITY_ADDR) && (humerror == TRUE))
post signalHumError();
***************
*** 167,176 ****
if((CMD == TOSH_HUMIDITY_ADDR) || (CMD == TOSH_HUMIDTEMP_ADDR) ){
if ((CMD == TOSH_HUMIDITY_ADDR) && (humerror == TRUE)) {
! timeout = 0;
! call Timer.start(TIMER_REPEAT, HUMIDITY_TIMEOUT_MS);
}
else if ((CMD == TOSH_HUMIDTEMP_ADDR) && (temperror == TRUE)) {
! timeout = 0;
! call Timer.start(TIMER_REPEAT, HUMIDITY_TIMEOUT_MS);
}
}
--- 176,185 ----
if((CMD == TOSH_HUMIDITY_ADDR) || (CMD == TOSH_HUMIDTEMP_ADDR) ){
if ((CMD == TOSH_HUMIDITY_ADDR) && (humerror == TRUE)) {
! atomic timeout = 0;
! post startTimeoutTimer();
}
else if ((CMD == TOSH_HUMIDTEMP_ADDR) && (temperror == TRUE)) {
! atomic timeout = 0;
! post startTimeoutTimer();
}
}
***************
*** 187,207 ****
command result_t StdControl.start() {
! state=READY;
! HUMIDITY_MAKE_CLOCK_OUTPUT();
! HUMIDITY_CLEAR_CLOCK();
! HUMIDITY_MAKE_DATA_INPUT();
! HUMIDITY_SET_DATA();
! HUMIDITY_INT_DISABLE();
! reset();
! processCommand(TOSH_HUMIDITY_RESET);
return SUCCESS;
}
command result_t StdControl.stop() {
! state = POWER_OFF;
! HUMIDITY_CLEAR_CLOCK();
! HUMIDITY_MAKE_CLOCK_INPUT();
! HUMIDITY_CLEAR_DATA();
! HUMIDITY_MAKE_DATA_INPUT();
return SUCCESS;
}
--- 196,220 ----
command result_t StdControl.start() {
! atomic {
! state=READY;
! HUMIDITY_MAKE_CLOCK_OUTPUT();
! HUMIDITY_CLEAR_CLOCK();
! HUMIDITY_MAKE_DATA_INPUT();
! HUMIDITY_SET_DATA();
! HUMIDITY_INT_DISABLE();
! reset();
! processCommand(TOSH_HUMIDITY_RESET);
! }
return SUCCESS;
}
command result_t StdControl.stop() {
! atomic {
! state = POWER_OFF;
! HUMIDITY_CLEAR_CLOCK();
! HUMIDITY_MAKE_CLOCK_INPUT();
! HUMIDITY_CLEAR_DATA();
! HUMIDITY_MAKE_DATA_INPUT();
! }
return SUCCESS;
}
***************
*** 221,226 ****
task void readSensor()
{
! char i;
! data=0;
call Timer.stop();
--- 234,243 ----
task void readSensor()
{
! uint8_t _state, i;
!
! atomic {
! _state = state;
! data=0;
! }
call Timer.stop();
***************
*** 258,262 ****
HUMIDITY_CLEAR_CLOCK();
! if(state==TEMP_MEASUREMENT){
/* let the PC do the calculation *****
temp=data;
--- 275,279 ----
HUMIDITY_CLEAR_CLOCK();
! if(_state==TEMP_MEASUREMENT){
/* let the PC do the calculation *****
temp=data;
***************
*** 269,273 ****
signal TempSensor.dataReady(data);
}
! else if(state==HUM_MEASUREMENT) {
/* let the PC do the calculation *****
hum=data;
--- 286,290 ----
signal TempSensor.dataReady(data);
}
! else if(_state==HUM_MEASUREMENT) {
/* let the PC do the calculation *****
hum=data;
***************
*** 281,285 ****
signal HumSensor.dataReady(data);
}
! state=READY;
}
--- 298,302 ----
signal HumSensor.dataReady(data);
}
! atomic state=READY;
}
***************
*** 287,291 ****
async event void SensirionInterrupt.fired()
{
- // call Leds.yellowOff();
HUMIDITY_INT_DISABLE();
post readSensor();
--- 304,307 ----
***************
*** 306,313 ****
async command result_t TempSensor.getData()
{
! if(state!= READY ){
! reset();
}
- state=TEMP_MEASUREMENT;
processCommand(TOSH_HUMIDTEMP_ADDR);
return SUCCESS;
--- 322,331 ----
async command result_t TempSensor.getData()
{
! atomic {
! if(state != READY ){
! reset();
! }
! state=TEMP_MEASUREMENT;
}
processCommand(TOSH_HUMIDTEMP_ADDR);
return SUCCESS;
***************
*** 316,323 ****
async command result_t HumSensor.getData()
{
! if(state!= READY ){
! reset();
}
- state=HUM_MEASUREMENT;
processCommand(TOSH_HUMIDITY_ADDR);
return SUCCESS;
--- 334,343 ----
async command result_t HumSensor.getData()
{
! atomic {
! if(state != READY ){
! reset();
! }
! state=HUM_MEASUREMENT;
}
processCommand(TOSH_HUMIDITY_ADDR);
return SUCCESS;
***************
*** 325,380 ****
command result_t HumError.enable() {
! if (humerror == FALSE) {
! atomic humerror = TRUE;
! return SUCCESS;
}
! return FAIL;
}
command result_t TempError.enable() {
! if (temperror == FALSE) {
! atomic temperror = TRUE;
! return SUCCESS;
}
! return FAIL;
}
command result_t HumError.disable() {
! if (humerror == TRUE) {
! atomic humerror = FALSE;
! return SUCCESS;
}
! return FAIL;
}
command result_t TempError.disable() {
! if (temperror == TRUE) {
! atomic temperror = FALSE;
! return SUCCESS;
}
! return FAIL;
}
event result_t Timer.fired() {
! timeout++;
! // call Leds.redToggle();
! // call Leds.redOn();
! if (timeout > HUMIDITY_TIMEOUT_TRIES) {
! if ((state == HUM_MEASUREMENT) && (humerror == TRUE)) {
call Timer.stop();
! HUMIDITY_INT_DISABLE();
! state = READY;
! errornum = 1;
post signalHumError();
}
! else if ((state == TEMP_MEASUREMENT) && (temperror == TRUE)) {
call Timer.stop();
! HUMIDITY_INT_DISABLE();
! state = READY;
! errornum = 1;
post signalTempError();
}
}
- // call Leds.redOff();
return SUCCESS;
}
--- 345,426 ----
command result_t HumError.enable() {
! result_t res = FAIL;
!
! atomic {
! if (humerror == FALSE) {
! humerror = TRUE;
! res = SUCCESS;
! }
}
!
! return res;
}
command result_t TempError.enable() {
! result_t res = FAIL;
!
! atomic {
! if (temperror == FALSE) {
! temperror = TRUE;
! res = SUCCESS;
! }
}
!
! return res;
}
command result_t HumError.disable() {
! result_t res = FAIL;
!
! atomic {
! if (humerror == TRUE) {
! humerror = FALSE;
! res = SUCCESS;
! }
}
!
! return res;
}
command result_t TempError.disable() {
! result_t res = FAIL;
!
! atomic {
! if (temperror == TRUE) {
! temperror = FALSE;
! res = SUCCESS;
! }
}
!
! return res;
}
event result_t Timer.fired() {
! uint8_t _state, _time;
! atomic {
! _state = state;
! timeout++;
! _time = timeout;
! }
! if (_time > HUMIDITY_TIMEOUT_TRIES) {
! if ((_state == HUM_MEASUREMENT) && (humerror == TRUE)) {
call Timer.stop();
! atomic {
! HUMIDITY_INT_DISABLE();
! state = READY;
! errornum = 1;
! }
post signalHumError();
}
! else if ((_state == TEMP_MEASUREMENT) && (temperror == TRUE)) {
call Timer.stop();
! atomic {
! HUMIDITY_INT_DISABLE();
! state = READY;
! errornum = 1;
! }
post signalTempError();
}
}
return SUCCESS;
}
--- HumidityProtocolC.nc DELETED ---
- Previous message: [Tinyos-commits]
CVS: tinyos-1.x/tos/platform/telos Hamamatsu.h, 1.3,
1.4 HamamatsuC.nc, 1.4, 1.5 HamamatsuM.nc, 1.5, 1.6
- Next message: [Tinyos-commits] CVS: tinyos-1.x/tools/make deluge.extra, NONE,
1.1 redeluge.extra, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-commits
mailing list