firebug-cvs Mailing List for FireBug: wireless wildfire monitoring (Page 28)
Brought to you by:
doolin
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(36) |
Jun
(45) |
Jul
(108) |
Aug
(31) |
Sep
(2) |
Oct
(4) |
Nov
(113) |
Dec
(20) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(63) |
Feb
(37) |
Mar
(24) |
Apr
(6) |
May
(5) |
Jun
(5) |
Jul
(71) |
Aug
(42) |
Sep
(7) |
Oct
|
Nov
|
Dec
|
2005 |
Jan
|
Feb
|
Mar
(3) |
Apr
|
May
(64) |
Jun
(71) |
Jul
(51) |
Aug
(89) |
Sep
(24) |
Oct
(1) |
Nov
(1) |
Dec
(2) |
2006 |
Jan
|
Feb
|
Mar
(3) |
Apr
(2) |
May
|
Jun
|
Jul
(21) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
From: <do...@us...> - 2003-11-15 02:00:31
|
Update of /cvsroot/firebug/mts400/apps/TestGPS_SHT In directory sc8-pr-cvs1:/tmp/cvs-serv2229/apps/TestGPS_SHT Modified Files: gps_shtM.nc Log Message: Instrumenting the mica switch and adding test programs to monitor control of flow. Index: gps_shtM.nc =================================================================== RCS file: /cvsroot/firebug/mts400/apps/TestGPS_SHT/gps_shtM.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gps_shtM.nc 13 Nov 2003 18:35:22 -0000 1.1 --- gps_shtM.nc 15 Nov 2003 02:00:27 -0000 1.2 *************** *** 62,65 **** --- 62,67 ---- WAIT_SWITCH_OFF, TIMER, GPS_WORKING, GPS_FINISHED, HUMIDITY_DONE}; + + uint16_t HumData; *************** *** 71,75 **** /** Control.init in GpsPacket.nc */ call GpsControl.init(); ! call TempHumControl.init(); //init Sensirion return SUCCESS; } --- 73,77 ---- /** Control.init in GpsPacket.nc */ call GpsControl.init(); ! call TempHumControl.init(); return SUCCESS; } *************** *** 86,91 **** */ call GpsControl.start(); call GPSTimer.start(TIMER_REPEAT, 10000) ; ! call SHTTimer.start(TIMER_REPEAT, 2000) ; return SUCCESS; } --- 88,96 ---- */ call GpsControl.start(); + + call TempHumControl.start(); + call GPSTimer.start(TIMER_REPEAT, 10000) ; ! //call SHTTimer.start(TIMER_REPEAT, 2000) ; return SUCCESS; } *************** *** 107,110 **** --- 112,117 ---- SODbg(DBG_USR2, "gps_newM.StdControl.stop(): GPS sensor powered off. \n"); } + //call TempHumControl.start(); + } *************** *** 120,123 **** --- 127,132 ---- } + //call TempHumControl.stop(); + call Leds.greenToggle(); *************** *** 139,143 **** call Leds.redToggle(); ! call TempHumControl.start(); return SUCCESS; } --- 148,152 ---- call Leds.redToggle(); ! //call TempHumControl.start(); return SUCCESS; } *************** *** 149,153 **** /** FIXME: Make sure we don't need the startDone, stopDone ! * calls. */ event result_t PowerSwitch.setDone(bool local_result) { --- 158,162 ---- /** FIXME: Make sure we don't need the startDone, stopDone ! * calls. Where is this called from? */ event result_t PowerSwitch.setDone(bool local_result) { *************** *** 323,327 **** } fTemp = 10*fTemp; ! SODbg(DBG_USR2, "Humidity: Temp(adc): %i Humidity(adc): %i Temp(degCx10): %i Humidity(%): %i \n", data,HumData,(int)fTemp, (int)fHumidity); --- 332,336 ---- } fTemp = 10*fTemp; ! SODbg(DBG_USR2, "gps_shtM.Humidity: Temp(adc): %i Humidity(adc): %i Temp(degCx10): %i Humidity(%): %i \n", data,HumData,(int)fTemp, (int)fHumidity); *************** *** 334,344 **** async event result_t Humidity.dataReady(uint16_t data) { atomic { HumData = data; ! } return call Temperature.getData(); } event result_t TempHumControl.startDone() { call Humidity.getData(); return SUCCESS; --- 343,357 ---- async event result_t Humidity.dataReady(uint16_t data) { + SODbg(DBG_USR2, "gsp_shtM.Humidity.dataReady()\n") + atomic { HumData = data; ! } return call Temperature.getData(); } event result_t TempHumControl.startDone() { + + SODbg(DBG_USR2, "gps_shtM.TempHumControl.startDone()\n") call Humidity.getData(); return SUCCESS; *************** *** 357,360 **** --- 370,375 ---- event result_t HumidityError.error(uint8_t token) { + SODbg(DBG_USR2, "gps_shtM.HumidityError.error()\n") + call Leds.redOff(); call Leds.yellowOff(); *************** *** 366,369 **** --- 381,385 ---- event result_t TemperatureError.error(uint8_t token) { + SODbg(DBG_USR2, "gps_shtM.Temperature.error()\n") call TempHumControl.stop(); call Leds.yellowOff(); |
From: <do...@us...> - 2003-11-15 02:00:31
|
Update of /cvsroot/firebug/mts400/apps/TestSwitch In directory sc8-pr-cvs1:/tmp/cvs-serv2229/apps/TestSwitch Added Files: switchtest.nc switchtestM.nc Log Message: Instrumenting the mica switch and adding test programs to monitor control of flow. --- NEW FILE: switchtest.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ /** * Test and example code for the weatherboard i2c * switches. */ includes sensorboard; configuration switchtest { } implementation { components Main, switchtestM, LedsC, MicaWbSwitch; Main.StdControl -> switchtestM.StdControl; Main.StdControl -> MicaWbSwitch.StdControl; switchtestM.Leds -> LedsC; switchtestM.PowerSwitch -> MicaWbSwitch.Switch[0]; //switchtestM.IOSwitch -> MicaWbSwitch.Switch[1]; } --- NEW FILE: switchtestM.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ module switchtestM { provides { interface StdControl; } uses { interface Leds; interface StdControl as SwitchControl; interface Switch as PowerSwitch; //interface Switch as IOSwitch; } } implementation { #include "SODebug.h" /** * Initialize the component and its subcomponents. * * @return Whether initialization was successful. */ command result_t StdControl.init() { init_debug(); SODbg(DBG_USR2, "switchtestM.StdControl.init()\n"); //call StdControl.start(); return SUCCESS; } /** * Start the component and its subcomponents. * * @return Whether starting was successful. */ command result_t StdControl.start() { result_t result; call Leds.redOn(); SODbg(DBG_USR2, "switchtestM.StdControl.start()\n"); result = call PowerSwitch.set(MICAWB_GPS_POWER,0); return SUCCESS; } /** * Stop the component and pertinent subcomponents (not all * subcomponents may be turned off due to wakeup timers, etc.). * * @return Whether stopping was successful. */ command result_t StdControl.stop() { call Leds.redOff(); SODbg(DBG_USR2, "switchtestM.StdControl.stop()\n"); return SUCCESS; } event result_t PowerSwitch.setDone(bool result) { signal PowerSwitch.getDone(1); SODbg(DBG_USR2, "switchtestM.PowerSwitch.setDone()\n"); return SUCCESS; } event result_t PowerSwitch.setAllDone(bool result) { SODbg(DBG_USR2, "switchtestM.PowerSwitch.setAllDone()\n"); return SUCCESS; } event result_t PowerSwitch.getDone(char value) { SODbg(DBG_USR2, "switchtestM.PowerSwitch.getDone()\n"); return SUCCESS; } } |
From: <do...@us...> - 2003-11-15 00:44:54
|
Update of /cvsroot/firebug/mts400/sensors/sensirion In directory sc8-pr-cvs1:/tmp/cvs-serv24882/sensirion Modified Files: SensirionHumidityM.nc Log Message: Added a debugging header specifically for the switch component. Index: SensirionHumidityM.nc =================================================================== RCS file: /cvsroot/firebug/mts400/sensors/sensirion/SensirionHumidityM.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SensirionHumidityM.nc 12 Nov 2003 01:44:20 -0000 1.1 --- SensirionHumidityM.nc 15 Nov 2003 00:44:51 -0000 1.2 *************** *** 62,65 **** --- 62,68 ---- command result_t SplitControl.start() { + + SODbg(DBG_USR2, "SensirionHumidityM.SplitControl.start() \n", state); + // turn the sensor on state = MAIN_SWITCH_ON; *************** *** 73,76 **** --- 76,82 ---- command result_t SplitControl.stop() { + + SODbg(DBG_USR2, "SensirionHumidityM.SplitControl.stop() \n", state); + power = FALSE; state = MAIN_SWITCH_OFF; *************** *** 88,91 **** --- 94,99 ---- event result_t Switch1.setDone(bool local_result) { + SODbg(DBG_USR2, "SensirionHumidityM.Switch1.setDone() \n", state); + if (state == MAIN_SWITCH_ON) { state = IDLE; *************** *** 125,138 **** ! SODbg(DBG_USR2, "SensirionHumidityM.SwitchI2W: state: %i \n", state); - - if (state == OPENSCK) { //SCK line enabled state = OPENDATA; return call SwitchI2W.set(MICAWB_HUMIDITY_DATA,1); } else if (state == OPENDATA) { //Data line enabled ! state = TIMER; ! SODbg(DBG_USR2, "SensirionHumidityM.SwitchI2W: Timer Started \n"); return call Timer.start(TIMER_ONE_SHOT, 100); --- 133,144 ---- ! SODbg(DBG_USR2, "SensirionHumidityM.SwitchI2W.setDone: state: %i \n", state); if (state == OPENSCK) { //SCK line enabled state = OPENDATA; return call SwitchI2W.set(MICAWB_HUMIDITY_DATA,1); } else if (state == OPENDATA) { //Data line enabled ! state = TIMER; ! SODbg(DBG_USR2, "SensirionHumidityM.SwitchI2W: Timer Started \n"); return call Timer.start(TIMER_ONE_SHOT, 100); *************** *** 151,155 **** if (id == MICAWB_HUMIDITY){ signal Humidity.dataReady(l_result); //everything complete, humidity data ready ! } else if (id == MICAWB_HUMIDITY_TEMP) signal Temperature.dataReady(l_result); //everything complete, temp data ready --- 157,161 ---- if (id == MICAWB_HUMIDITY){ signal Humidity.dataReady(l_result); //everything complete, humidity data ready ! } else if (id == MICAWB_HUMIDITY_TEMP) signal Temperature.dataReady(l_result); //everything complete, temp data ready *************** *** 158,167 **** } ! event result_t Timer.fired() { state = BUSY; if (id == MICAWB_HUMIDITY) { SODbg(DBG_USR2, "SensirionHumidityM.Timer.fired: get humidity data \n"); ! return call HumSensor.getData(); } --- 164,177 ---- } ! event result_t Timer.fired() { ! ! ! SODbg(DBG_USR2, "SensirionHumidityM.Timer.fired() \n", state); ! state = BUSY; if (id == MICAWB_HUMIDITY) { SODbg(DBG_USR2, "SensirionHumidityM.Timer.fired: get humidity data \n"); ! return call HumSensor.getData(); } *************** *** 190,193 **** --- 200,206 ---- async command result_t Humidity.getData() { + + SODbg(DBG_USR2, "SensirionHumidityM.Humidity.getData(), state: \n", state); + if (state == IDLE) { *************** *** 201,205 **** async command result_t Temperature.getData() { ! if (state == IDLE) { id = MICAWB_HUMIDITY_TEMP; --- 214,222 ---- async command result_t Temperature.getData() { ! ! ! SODbg(DBG_USR2, "SensirionHumidityM.Temperature.getData(), state: \n", state); ! ! if (state == IDLE) { id = MICAWB_HUMIDITY_TEMP; |
From: <do...@us...> - 2003-11-15 00:44:54
|
Update of /cvsroot/firebug/mts400/sensors/i2c In directory sc8-pr-cvs1:/tmp/cvs-serv24882/i2c Modified Files: MicaWbSwitchM.nc Added Files: wbswitch_debug.h Log Message: Added a debugging header specifically for the switch component. --- NEW FILE: wbswitch_debug.h --- #include <stdarg.h> //#include <stdio.h> //#define SCRATCH 16 #define SCRATCH 64 #define BUF_LEN 256 char debugbuf[BUF_LEN]; //init comm port (56K baud, mica2 only, use 19K baud for mica2dot, mica....) for debug // call this from startup routine void init_debug(){ outp(0,UBRR0H); outp(15, UBRR0L); //set baud rate outp((1<<U2X),UCSR0A); // Set UART double speed outp(((1 << UCSZ1) | (1 << UCSZ0)) , UCSR0C); // Set frame format: 8 data-bits, 1 stop-bit inp(UDR0); outp((1 << TXEN) ,UCSR0B); // Enable uart reciever and transmitter } //init comm port (19K baud) for mica2dot for debug // call this from startup routine void init_debug_mica2dot(){ outp(0,UBRR0H); // Set baudrate to 19.2 KBps outp(12, UBRR0L); outp(0,UCSR0A); // Disable U2X and MPCM outp(((1 << UCSZ1) | (1 << UCSZ0)) , UCSR0C); inp(UDR0); outp((1 << TXEN) ,UCSR0B); } // output a char to the uart void UARTPutChar(char c) { if (c == '\n') UARTPutChar('\r'); loop_until_bit_is_set(UCSR0A, UDRE); outb(UDR0,c); } void writedebug() { int i = 0; UARTPutChar('\n'); //write a carriage return 1st while (debugbuf[i] != '\n') UARTPutChar(debugbuf[i++]); // UARTPutChar('\n'); } #define SPRINTF //use this sprintf function #ifdef SPRINTF int sprintf(uint8_t *buf, const uint8_t *format, ...) /* simplified sprintf */ { uint8_t scratch[SCRATCH]; uint8_t format_flag; uint16_t u_val=0, base; uint8_t *ptr; va_list ap; bool b_ChkForNegInt = FALSE; va_start (ap, format); for (;;){ while ((format_flag = *format++) != '%'){ /* Until '%' or '\0' */ if (!format_flag){va_end (ap); return (0);} *buf = format_flag; buf++; *buf=0; } b_ChkForNegInt = FALSE; switch (format_flag = *format++){ case 'c': format_flag = va_arg(ap,int); default: *buf = format_flag; buf++; *buf=0; continue; case 'S': case 's': ptr = va_arg(ap,char *); strcat(buf, ptr); continue; case 'o': base = 8; *buf = '0'; buf++; *buf=0; goto CONVERSION_LOOP; case 'i': b_ChkForNegInt = TRUE; // if (((int)u_val) < 0){ // u_val = - u_val; // *buf = '-'; buf++; *buf=0; // } /* no break -> run into next case */ case 'u': base = 10; goto CONVERSION_LOOP; case 'x': base = 16; CONVERSION_LOOP: u_val = va_arg(ap,int); if (b_ChkForNegInt){ if (((int)u_val) < 0){ u_val = - u_val; *buf = '-'; buf++; *buf=0; } } ptr = scratch + SCRATCH; *--ptr = 0; do { char ch = u_val % base + '0'; if (ch > '9') ch += 'a' - '9' - 1; *--ptr = ch; u_val /= base; } while (u_val); strcat(buf, ptr); buf += strlen(ptr); } } } #endif #define SO_NO_DEBUG 0 #if WB_DEBUG #define WBDbg(__x,__args...) { \ char bStatus; \ if(__x != SO_NO_DEBUG){ \ bStatus=bit_is_set(SREG,7); \ cli(); \ sprintf(debugbuf,__args); \ writedebug(); \ if (bStatus) sei(); \ } \ } #else #define WBDbg(__x,__args...) #endif Index: MicaWbSwitchM.nc =================================================================== RCS file: /cvsroot/firebug/mts400/sensors/i2c/MicaWbSwitchM.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MicaWbSwitchM.nc 12 Nov 2003 23:52:42 -0000 1.1 --- MicaWbSwitchM.nc 15 Nov 2003 00:44:51 -0000 1.2 *************** *** 68,77 **** */ ! module MicaWbSwitchM ! { provides { interface StdControl; interface Switch[uint8_t id]; } uses { interface StdControl as I2CPacketControl; --- 68,81 ---- */ ! ! ! ! module MicaWbSwitchM { ! provides { interface StdControl; interface Switch[uint8_t id]; } + uses { interface StdControl as I2CPacketControl; *************** *** 80,88 **** } } - implementation - { ! enum { GET_SWITCH, SET_SWITCH, SET_SWITCH_ALL, ! SET_SWITCH_GET, IDLE}; char sw_state; /* current state of the switch */ --- 84,99 ---- } } ! ! implementation { ! ! #define WB_DEBUG 0 ! #include "wbswitch_debug.h" ! ! enum { GET_SWITCH = 0, ! SET_SWITCH, ! SET_SWITCH_ALL, ! SET_SWITCH_GET, ! IDLE}; char sw_state; /* current state of the switch */ *************** *** 93,112 **** command result_t StdControl.init() { ! state = IDLE; return call I2CPacketControl.init(); } command result_t StdControl.start() { return call I2CPacketControl.start(); } command result_t StdControl.stop() { return call I2CPacketControl.stop(); } command result_t Switch.get[uint8_t id]() { ! if (state == IDLE) ! { state = GET_SWITCH; if (id == 0) return call I2CSwitch0.readPacket(1, 0x01); --- 104,138 ---- command result_t StdControl.init() { ! ! state = IDLE; ! WBDbg(DBG_USR2, "MicaWBSwitch.StdControl.init() state: %i\n,",state); return call I2CPacketControl.init(); } command result_t StdControl.start() { + + WBDbg(DBG_USR2, "MicaWBSwitch.StdControl.start() state: %i\n",state); + return call I2CPacketControl.start(); } command result_t StdControl.stop() { + + WBDbg(DBG_USR2, "MicaWBSwitch.StdControl.stop() state: %i\n",state); + return call I2CPacketControl.stop(); } + command result_t Switch.get[uint8_t id]() { ! ! ! WBDbg(DBG_USR2, "MicaWBSwitch.Switch.get() state: %i\n",state); ! ! if (state == IDLE) { ! state = GET_SWITCH; + WBDbg(DBG_USR2, "MicaWBSwitch.Switch.get() state: %i\n",state); + if (id == 0) return call I2CSwitch0.readPacket(1, 0x01); *************** *** 118,122 **** --- 144,152 ---- } + command result_t Switch.set[uint8_t id](char l_position, char l_value) { + + WBDbg(DBG_USR2, "MicaWBSwitch.Switch.set() state: %i\n",state); + if (state == IDLE) { *************** *** 134,137 **** --- 164,170 ---- command result_t Switch.setAll[uint8_t id](char l_value) { + + WBDbg(DBG_USR2, "MicaWBSwitch.Switch.setAll() state: %i\n",state); + if (state == IDLE) { *************** *** 148,151 **** --- 181,188 ---- event result_t I2CSwitch0.writePacketDone(bool result) { + + + WBDbg(DBG_USR2, "MicaWBSwitch.I2CSwitch0.writePacketDone() state: %i\n",state); + if (state == SET_SWITCH) { *************** *** 161,164 **** --- 198,204 ---- event result_t I2CSwitch1.writePacketDone(bool result) { + + WBDbg(DBG_USR2, "MicaWBSwitch.I2CSwitch1.writePacketDone() state: %i\n",state); + if (state == SET_SWITCH) { *************** *** 174,179 **** event result_t I2CSwitch0.readPacketDone(char length, char* data) { ! if (state == GET_SWITCH) ! { if (length != 1) { --- 214,223 ---- event result_t I2CSwitch0.readPacketDone(char length, char* data) { ! ! ! WBDbg(DBG_USR2, "MicaWBSwitch.I2CSwitch0.readPacketDone() state: %i\n",state); ! ! if (state == GET_SWITCH) { ! if (length != 1) { *************** *** 188,191 **** --- 232,236 ---- } } + if (state == SET_SWITCH_GET) { *************** *** 240,243 **** --- 285,292 ---- event result_t I2CSwitch1.readPacketDone(char length, char* data) { + + + WBDbg(DBG_USR2, "MicaWBSwitch.I2CSwitch1.readPacketDone() state: %i\n",state); + if (state == GET_SWITCH) { *************** *** 307,310 **** --- 356,361 ---- default event result_t Switch.setDone[uint8_t id](bool result) { + WBDbg(DBG_USR2, "MicaWBSwitch.Switch.setDone() id: %i\n",id); + return SUCCESS; } *************** *** 312,315 **** --- 363,367 ---- default event result_t Switch.setAllDone[uint8_t id](bool result) { + WBDbg(DBG_USR2, "MicaWBSwitch.Switch.setAllDone() id: %i\n",id); return SUCCESS; } *************** *** 317,320 **** --- 369,373 ---- default event result_t Switch.getDone[uint8_t id](char l_value) { + WBDbg(DBG_USR2, "MicaWBSwitch.Switch.getDone() id: %i\n",id); return SUCCESS; } |
From: <do...@us...> - 2003-11-15 00:44:54
|
Update of /cvsroot/firebug/mts400/sensors/gps In directory sc8-pr-cvs1:/tmp/cvs-serv24882/gps Modified Files: GpsPacket.nc Log Message: Added a debugging header specifically for the switch component. Index: GpsPacket.nc =================================================================== RCS file: /cvsroot/firebug/mts400/sensors/gps/GpsPacket.nc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** GpsPacket.nc 13 Nov 2003 00:17:18 -0000 1.4 --- GpsPacket.nc 15 Nov 2003 00:44:51 -0000 1.5 *************** *** 409,412 **** --- 409,415 ---- command result_t GpsCmd.PowerSwitch(uint8_t PowerState){ + + SODbg(DBG_USR2, "GpsPacket.PowerSwitch.setDone(): PowerState: %i \n", PowerState); + if (state_gps == GPS_SWITCH_IDLE){ *************** *** 414,423 **** --- 417,429 ---- if (power_gps){ + /** Wired to MicaWBSwitch.set() */ if (call PowerSwitch.set(MICAWB_GPS_POWER,0) == SUCCESS) { state_gps = GPS_PWR_SWITCH_WAIT; + SODbg(DBG_USR2, "GpsPacket.PowerSwitch.setDone(): 2d arg 0\n"); } } else { if (call PowerSwitch.set(MICAWB_GPS_POWER,1) == SUCCESS) { state_gps = GPS_PWR_SWITCH_WAIT; + SODbg(DBG_USR2, "GpsPacket.PowerSwitch.setDone(): 2d arg 1\n"); } } |
From: <do...@us...> - 2003-11-15 00:43:43
|
Update of /cvsroot/firebug/mts400/apps/TestSwitch In directory sc8-pr-cvs1:/tmp/cvs-serv24679/TestSwitch Log Message: Directory /cvsroot/firebug/mts400/apps/TestSwitch added to the repository |
Update of /cvsroot/firebug/mts400/sensors/gps In directory sc8-pr-cvs1:/tmp/cvs-serv24055 Removed Files: HPLI2CM.nc HPLInterrupt.nc I2CC.nc I2CPacketC.nc I2CPacketM.nc I2CSwitchCmds.nc Interrupt.nc MicaWbSwitch.nc MicaWbSwitchM.nc Log Message: Removed superfluous files from gps sensor driver. --- HPLI2CM.nc DELETED --- --- HPLInterrupt.nc DELETED --- --- I2CC.nc DELETED --- --- I2CPacketC.nc DELETED --- --- I2CPacketM.nc DELETED --- --- I2CSwitchCmds.nc DELETED --- --- Interrupt.nc DELETED --- --- MicaWbSwitch.nc DELETED --- --- MicaWbSwitchM.nc DELETED --- |
From: <do...@us...> - 2003-11-13 18:36:01
|
Update of /cvsroot/firebug/mts400/apps In directory sc8-pr-cvs1:/tmp/cvs-serv14819/apps Modified Files: Makelocal Log Message: Added line to Makelocal to handle multiple sensor drivers. Index: Makelocal =================================================================== RCS file: /cvsroot/firebug/mts400/apps/Makelocal,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makelocal 13 Nov 2003 00:17:18 -0000 1.2 --- Makelocal 13 Nov 2003 18:35:58 -0000 1.3 *************** *** 2,6 **** --- 2,11 ---- #LOCAL_PATH += -I$(XBOWROOT)/tos/platform -I$(XBOWROOT)/tos/interfaces -I$(XBOWROOT)/tos/sensorboards/$(SENSORBOARD) LOCAL_PATH += -I../../sensors/$(SENSORBOARD) + LOCAL_PATH += -I../../sensors/i2c + + # This is a problem. + LOCAL_PATH += -I../../sensors/sensirion + PFLAGS := $(LOCAL_PATH) $(LOCAL_DEFINES) $(PFLAGS) CFLAGS = -DCC1K_DEFAULT_FREQ=CC1K_433_002_MHZ |
From: <do...@us...> - 2003-11-13 18:35:26
|
Update of /cvsroot/firebug/mts400/apps/TestGPS_SHT In directory sc8-pr-cvs1:/tmp/cvs-serv14732 Added Files: .cvsignore Makefile gps_sht.nc gps_shtM.nc Log Message: Test application for taking data from gps and sht sensors in same application. It does not currently work, there is a lockup somewhere in the gps sensor. Might need to power down the sht or something, hard to say right now. Getting this applet to work will be key for handling data in the networked application. --- NEW FILE: .cvsignore --- build *~ --- NEW FILE: Makefile --- COMPONENT=gps_sht SENSORBOARD=gps include ../Makelocal include $(TOSROOT)/apps/Makerules --- NEW FILE: gps_sht.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ includes sensorboard; configuration gps_sht { } implementation { components Main, gps_shtM, MicaWbSwitch, UARTGpsPacket, SensirionHumidity, TimerC, LedsC; Main.StdControl -> gps_shtM.StdControl; Main.StdControl -> TimerC.StdControl; Main.StdControl -> MicaWbSwitch.StdControl; gps_shtM.Leds -> LedsC; gps_shtM.GPSTimer -> TimerC.Timer[unique("Timer")]; gps_shtM.SHTTimer -> TimerC.Timer[unique("Timer")]; gps_shtM.PowerSwitch -> MicaWbSwitch.Switch[0]; gps_shtM.IOSwitch -> MicaWbSwitch.Switch[1]; gps_shtM.GpsControl -> UARTGpsPacket; gps_shtM.GpsSend -> UARTGpsPacket; gps_shtM.GpsReceive -> UARTGpsPacket; gps_shtM.GpsCmd -> UARTGpsPacket.GpsCmd; // Wiring for Sensirion humidity/temperature sensor gps_shtM.TempHumControl -> SensirionHumidity; gps_shtM.Humidity -> SensirionHumidity.Humidity; gps_shtM.Temperature -> SensirionHumidity.Temperature; gps_shtM.HumidityError -> SensirionHumidity.HumidityError; gps_shtM.TemperatureError -> SensirionHumidity.TemperatureError; } --- NEW FILE: gps_shtM.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ module gps_shtM { provides { interface StdControl; command void readGps(); command void stopGps(); } uses { interface Leds; interface Timer as GPSTimer; interface Timer as SHTTimer; interface StdControl as SwitchControl; interface Switch as PowerSwitch; interface Switch as IOSwitch; interface StdControl as GpsControl; interface I2CSwitchCmds as GpsCmd; interface BareSendMsg as GpsSend; interface ReceiveMsg as GpsReceive; interface SplitControl as TempHumControl; interface ADC as Humidity; interface ADC as Temperature; interface ADCError as HumidityError; interface ADCError as TemperatureError; } } implementation { #include "SODebug.h" #include "gps.h" /** 0 means GPS runs forever, 1 means it takes one reading * and powers down. * FIXME: The GPS sensor powers back up after it powers down, * this should not happen and is a problem. */ #define GPS_ONE_SHOT 1 char state; char gps_state; enum {IDLE, BUSY, BUSY_0, BUSY_1, GET_SAMPLE_0, GET_SAMPLE_1, OPENSCK, OPENDATA, CLOSESCK, CLOSEDATA, POWEROFF, MAIN_SWITCH_ON, MAIN_SWITCH_OFF, WAIT_SWITCH_ON, WAIT_SWITCH_OFF, TIMER, GPS_WORKING, GPS_FINISHED, HUMIDITY_DONE}; uint16_t HumData; command result_t StdControl.init() { init_debug(); call Leds.init(); /** Control.init in GpsPacket.nc */ call GpsControl.init(); call TempHumControl.init(); //init Sensirion return SUCCESS; } command result_t StdControl.start() { call Leds.redOn(); call HumidityError.enable(); //in case Sensirion doesn't respond call TemperatureError.enable(); // " /** Control.start in GpsPacket.nc, calls * SwitchControl.start and ByteControl.start() */ call GpsControl.start(); call GPSTimer.start(TIMER_REPEAT, 10000) ; call SHTTimer.start(TIMER_REPEAT, 2000) ; return SUCCESS; } command result_t StdControl.stop() { /** Turn the timer off so that it doesn't fire any * sensor readings. Timer.stop always returns success. */ call GPSTimer.stop(); call SHTTimer.stop(); return SUCCESS; } command void stopGps() { if (call GpsCmd.PowerSwitch(GPS_POWER_OFF)) { SODbg(DBG_USR2, "gps_newM.StdControl.stop(): GPS sensor powered off. \n"); } } /** Ok, this function turns on the gps unit for reading, * which is turned of elsewhere when the read is finished. * If the read isn't finished, the function exits. */ command void readGps() { if (gps_state == GPS_WORKING) { SODbg(DBG_USR2, "gps_newM.readGps(): GPS_WORKING\n"); return; } call Leds.greenToggle(); /* Implementation is in GpsPacket.nc */ if (call GpsCmd.PowerSwitch(GPS_POWER_ON)) { SODbg(DBG_USR2, "gps_newM.readGps(): GPS powered on\n"); gps_state = GPS_WORKING; } } event result_t GPSTimer.fired() { call readGps(); return SUCCESS; } event result_t SHTTimer.fired() { call Leds.redToggle(); call TempHumControl.start(); return SUCCESS; } event result_t PowerSwitch.getDone(char value) { return SUCCESS; } /** FIXME: Make sure we don't need the startDone, stopDone * calls. */ event result_t PowerSwitch.setDone(bool local_result) { switch(state) { case MAIN_SWITCH_ON: SODbg(DBG_USR2, "PowerSwitch.setDone() MAIN_SWITCH_ON\n"); state = IDLE; /** GpsControl is wired to GpsPacket.nc */ //signal GpsControl.startDone(); break; case MAIN_SWITCH_OFF: SODbg(DBG_USR2, "PowerSwitch.setDone() MAIN_SWITCH_OFF\n"); state = POWEROFF; /** GpsControl is wired to GpsPacket.nc */ //signal GpsControl.stopDone(); break; case WAIT_SWITCH_ON: SODbg(DBG_USR2, "PowerSwitch.setDone() WAIT_SWITCH_ON\n"); if (call PowerSwitch.set(MICAWB_GPS_POWER,1) == SUCCESS) { state = MAIN_SWITCH_ON; } break; case WAIT_SWITCH_OFF: SODbg(DBG_USR2, "PowerSwitch.setDone() WAIT_SWITCH_OFF\n"); if (call PowerSwitch.set(MICAWB_GPS_POWER,0) == SUCCESS) { state = MAIN_SWITCH_OFF; } default: break; } return SUCCESS; } event result_t PowerSwitch.setAllDone(bool local_result) { return SUCCESS; } event result_t IOSwitch.getDone(char value) { return SUCCESS; } event result_t IOSwitch.setAllDone(bool local_result) { return SUCCESS; } /** FIXME: Rewrite this with a switch/case. */ /** FIXME: I see no reason why we need I2C information this * high in the application. All this I2C bus info needs * to be shoved down a level, and wired from here to something * like turnSensorOn(), turnSensorOff(), etc. */ event result_t IOSwitch.setDone(bool local_result) { //SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): state: %i \n", state); if (state == OPENSCK) { //SCK line enabled SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): SCK enabled \n"); state = OPENDATA; return call IOSwitch.set(MICAWB_HUMIDITY_DATA,1); } else if (state == OPENDATA) { //Data line enabled SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): SDA enabled \n"); state = TIMER; SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): Timer Started, state: %i \n", state); return call GPSTimer.start(TIMER_ONE_SHOT, 100); } else if (state == CLOSESCK) { state = CLOSEDATA; SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): SCK disabled \n"); return call IOSwitch.set(MICAWB_HUMIDITY_DATA,0); } else if (state == CLOSEDATA) { SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): SDA disabled \n"); } return SUCCESS; } /** * Packet received from GPS - ASCII msg * 1st byte in pkt is number of ascii bytes * async used only for testing. * * FIXME: Why is the data returned? It's passed in. * It should be declared const. * * This function is called from GpsPacket.receiveTask(). */ event TOS_MsgPtr GpsReceive.receive(TOS_MsgPtr data) { uint8_t i; GPS_MsgPtr gps_data = (GPS_MsgPtr)data; call Leds.greenToggle(); for (i=0; i<=gps_data->data[0]; i++) { /** UARTPutChar is an SODebug function. * FIXME: Change this to use a char[]. */ UARTPutChar(gps_data->data[i]); } SODbg(DBG_USR2, "\n"); /** FIXME: Pulled the preprocessor define out, * code this up as a user defined variable that * is set when the gps unit is initialized. */ #if GPS_ONE_SHOT { /** Already written out one message. */ static uint16_t msg_count = 1; if (msg_count == 2) { atomic { gps_state = GPS_FINISHED; } call stopGps(); msg_count = 0; } msg_count++; } #endif return data; } event result_t GpsSend.sendDone(TOS_MsgPtr msg, result_t success) { SODbg(DBG_USR2, "GpsSend.sendDone(): state: %i \n", state); return SUCCESS; } event result_t GpsCmd.SwitchesSet(uint8_t PowerState) { char tmp[] = {"Foo"}; //SODbg(DBG_USR2, "gps_new.GpsCmd.SwitchesSet(): PowerState: %i \n\n", PowerState); SODbg(DBG_USR2, "gps_new.GpsCmd.SwitchesSet(): dummy string: %s \n", tmp); call Leds.yellowOn(); call Leds.redOff(); return SUCCESS; } /****************************************************************************** * Sensirion SHT11 humidity/temperature sensor * - Humidity data is 12 bit: * Linear calc (no temp correction) * fRH = -4.0 + 0.0405 * data -0.0000028 * data^2 'RH linear * With temperature correction: * fRH = (fTemp - 25) * (0.01 + 0.00008 * data) + fRH 'RH true * - Temperature data is 14 bit * Temp(degC) = -38.4 + 0.0098 * data *****************************************************************************/ async event result_t Temperature.dataReady(uint16_t data) { float fTemp, fHumidity; fTemp = -38.4 + 0.0098*(float)data; atomic { fHumidity = -4.0 + 0.0405 * HumData -0.0000028 * HumData * HumData; fHumidity= (fTemp-25.0)* (0.01 + 0.00008 * HumData) + fHumidity; } fTemp = 10*fTemp; SODbg(DBG_USR2, "Humidity: Temp(adc): %i Humidity(adc): %i Temp(degCx10): %i Humidity(%): %i \n", data,HumData,(int)fTemp, (int)fHumidity); atomic { call TempHumControl.stop(); } return SUCCESS; } async event result_t Humidity.dataReady(uint16_t data) { atomic { HumData = data; } return call Temperature.getData(); } event result_t TempHumControl.startDone() { call Humidity.getData(); return SUCCESS; } event result_t TempHumControl.initDone() { return SUCCESS; } event result_t TempHumControl.stopDone() { state = HUMIDITY_DONE; return SUCCESS; } event result_t HumidityError.error(uint8_t token) { call Leds.redOff(); call Leds.yellowOff(); call Temperature.getData(); return SUCCESS; } event result_t TemperatureError.error(uint8_t token) { call TempHumControl.stop(); call Leds.yellowOff(); return SUCCESS; } } |
From: <do...@us...> - 2003-11-13 18:12:48
|
Update of /cvsroot/firebug/mts400/apps/TestGPS_SHT In directory sc8-pr-cvs1:/tmp/cvs-serv9333/TestGPS_SHT Log Message: Directory /cvsroot/firebug/mts400/apps/TestGPS_SHT added to the repository |
From: <do...@us...> - 2003-11-13 00:17:58
|
Update of /cvsroot/firebug/mts400/apps/TestADXL In directory sc8-pr-cvs1:/tmp/cvs-serv12709 Added Files: .cvsignore Log Message: Forgot the ignore file. --- NEW FILE: .cvsignore --- build *~ |
From: <do...@us...> - 2003-11-13 00:17:21
|
Update of /cvsroot/firebug/mts400/sensors/i2c In directory sc8-pr-cvs1:/tmp/cvs-serv12616/sensors/i2c Modified Files: MicaWbSwitch.nc Log Message: Clean up commit to make nothing was missed when the offline driver and test applications were added and commited. Index: MicaWbSwitch.nc =================================================================== RCS file: /cvsroot/firebug/mts400/sensors/i2c/MicaWbSwitch.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MicaWbSwitch.nc 12 Nov 2003 23:52:42 -0000 1.1 --- MicaWbSwitch.nc 13 Nov 2003 00:17:18 -0000 1.2 *************** *** 1,3 **** ! /* tab:4 * * --- 1,6 ---- ! /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ ! ! ! /* * * *************** *** 22,26 **** * */ ! /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to --- 25,29 ---- * */ ! /* * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to *************** *** 68,72 **** includes sensorboard; ! configuration MicaWbSwitch { provides { --- 71,75 ---- includes sensorboard; ! configuration MicaWbSwitch { provides { *************** *** 75,78 **** --- 78,82 ---- } } + implementation { |
From: <do...@us...> - 2003-11-13 00:17:21
|
Update of /cvsroot/firebug/mts400/sensors/gps In directory sc8-pr-cvs1:/tmp/cvs-serv12616/sensors/gps Modified Files: GpsPacket.nc HPLUART1M.nc Log Message: Clean up commit to make nothing was missed when the offline driver and test applications were added and commited. Index: GpsPacket.nc =================================================================== RCS file: /cvsroot/firebug/mts400/sensors/gps/GpsPacket.nc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GpsPacket.nc 12 Nov 2003 01:44:20 -0000 1.3 --- GpsPacket.nc 13 Nov 2003 00:17:18 -0000 1.4 *************** *** 457,461 **** } } else if (state_gps == GPS_RX_SWITCH_WAIT) { ! SODbg(DBG_USR2, "GpsPacket: all switches set \n"); state_gps = GPS_SWITCH_IDLE; signal GpsCmd.SwitchesSet(state_gps); --- 457,461 ---- } } else if (state_gps == GPS_RX_SWITCH_WAIT) { ! SODbg(DBG_USR2, "GpsPacket.IOSwitch.setDone(): all switches set \n"); state_gps = GPS_SWITCH_IDLE; signal GpsCmd.SwitchesSet(state_gps); Index: HPLUART1M.nc =================================================================== RCS file: /cvsroot/firebug/mts400/sensors/gps/HPLUART1M.nc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HPLUART1M.nc 11 Nov 2003 01:59:40 -0000 1.1 --- HPLUART1M.nc 13 Nov 2003 00:17:18 -0000 1.2 *************** *** 82,86 **** async command result_t UART.init() { ! SODbg(DBG_BOOT, "UART1 initialized\n"); // UART will run at: (N-8-1) --- 82,86 ---- async command result_t UART.init() { ! SODbg(DBG_BOOT, "HPLUART1M.UART1.init() initialized\n"); // UART will run at: (N-8-1) |
From: <do...@us...> - 2003-11-13 00:17:21
|
Update of /cvsroot/firebug/mts400/apps/TestGPS In directory sc8-pr-cvs1:/tmp/cvs-serv12616/apps/TestGPS Modified Files: gps_new.nc gps_newM.nc Log Message: Clean up commit to make nothing was missed when the offline driver and test applications were added and commited. Index: gps_new.nc =================================================================== RCS file: /cvsroot/firebug/mts400/apps/TestGPS/gps_new.nc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gps_new.nc 12 Nov 2003 01:44:20 -0000 1.2 --- gps_new.nc 13 Nov 2003 00:17:18 -0000 1.3 *************** *** 22,28 **** gps_newM.Leds -> LedsC; ! gps_newM.Timer -> TimerC.Timer[unique("Timer")]; ! /** Use gps without sensirion. */ //gps_newM.SwitchControl -> MicaWbSwitch.StdControl; gps_newM.PowerSwitch -> MicaWbSwitch.Switch[0]; --- 22,29 ---- gps_newM.Leds -> LedsC; ! gps_newM.GPSTimer -> TimerC.Timer[unique("Timer")]; ! gps_newM.REDTimer -> TimerC.Timer[unique("Timer")]; ! /** Use gps without sensirion or adxl. */ //gps_newM.SwitchControl -> MicaWbSwitch.StdControl; gps_newM.PowerSwitch -> MicaWbSwitch.Switch[0]; Index: gps_newM.nc =================================================================== RCS file: /cvsroot/firebug/mts400/apps/TestGPS/gps_newM.nc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gps_newM.nc 12 Nov 2003 02:49:10 -0000 1.4 --- gps_newM.nc 13 Nov 2003 00:17:18 -0000 1.5 *************** *** 7,17 **** interface StdControl; } uses { ! interface Timer; interface Leds; interface StdControl as SwitchControl; interface Switch as PowerSwitch; --- 7,23 ---- interface StdControl; + + command void readGps(); + command void stopGps(); } uses { ! interface Leds; + interface Timer as GPSTimer; + interface Timer as REDTimer; + interface StdControl as SwitchControl; interface Switch as PowerSwitch; *************** *** 40,48 **** char state; enum {IDLE, BUSY, BUSY_0, BUSY_1, GET_SAMPLE_0, GET_SAMPLE_1, OPENSCK, OPENDATA, CLOSESCK, CLOSEDATA, POWEROFF, MAIN_SWITCH_ON, MAIN_SWITCH_OFF, WAIT_SWITCH_ON, ! WAIT_SWITCH_OFF, TIMER}; --- 46,55 ---- char state; + char gps_state; enum {IDLE, BUSY, BUSY_0, BUSY_1, GET_SAMPLE_0, GET_SAMPLE_1, OPENSCK, OPENDATA, CLOSESCK, CLOSEDATA, POWEROFF, MAIN_SWITCH_ON, MAIN_SWITCH_OFF, WAIT_SWITCH_ON, ! WAIT_SWITCH_OFF, TIMER, GPS_WORKING, GPS_FINISHED}; *************** *** 61,105 **** call Leds.redOn(); ! /* Control.start in GpsPacket.nc */ call GpsControl.start(); ! /* Implementation is in GpsPacket.nc */ ! if (!call GpsCmd.PowerSwitch(GPS_POWER_ON)) { ! SODbg(DBG_USR2, "Failed to power on gps \n"); ! } ! ! /** Do we need this? */ ! call Timer.start(TIMER_REPEAT, 1000) ; return SUCCESS; } - command result_t StdControl.stop() { ! SODbg(DBG_USR2, "StdControl.stop() \n"); if (call GpsCmd.PowerSwitch(GPS_POWER_OFF)) { ! SODbg(DBG_USR2, "GPS sensor powered off. \n"); } - /** Timer.stop always returns success. */ - call Timer.stop(); - return SUCCESS; } ! /****************************************************/ ! /** Timer */ ! event result_t Timer.fired() { ! //call Leds.greenToggle(); return SUCCESS; } - /****************************************************/ - /** PowerSwitch */ event result_t PowerSwitch.getDone(char value) { --- 68,133 ---- call Leds.redOn(); ! /** Control.start in GpsPacket.nc, calls ! * SwitchControl.start and ByteControl.start() ! */ call GpsControl.start(); + call GPSTimer.start(TIMER_REPEAT, 10000) ; + call REDTimer.start(TIMER_REPEAT, 500) ; + return SUCCESS; + } ! command result_t StdControl.stop() { + /** Turn the timer off so that it doesn't fire any + * sensor readings. Timer.stop always returns success. + */ + call GPSTimer.stop(); + call REDTimer.stop(); return SUCCESS; } ! command void stopGps() { if (call GpsCmd.PowerSwitch(GPS_POWER_OFF)) { ! SODbg(DBG_USR2, "gps_newM.StdControl.stop(): GPS sensor powered off. \n"); } } + /** Ok, this function turns on the gps unit for reading, + * which is turned of elsewhere when the read is finished. + * If the read isn't finished, the function exits. + */ + command void readGps() { ! if (gps_state == GPS_WORKING) { ! SODbg(DBG_USR2, "gps_newM.readGps(): GPS_WORKING\n"); ! return; ! } ! call Leds.greenToggle(); ! /* Implementation is in GpsPacket.nc */ ! if (call GpsCmd.PowerSwitch(GPS_POWER_ON)) { ! SODbg(DBG_USR2, "gps_newM.readGps(): GPS powered on\n"); ! gps_state = GPS_WORKING; ! } ! } ! ! ! event result_t GPSTimer.fired() { ! ! call readGps(); return SUCCESS; } + event result_t REDTimer.fired() { + + call Leds.redToggle(); + return SUCCESS; + } event result_t PowerSwitch.getDone(char value) { *************** *** 107,111 **** } - /** FIXME: Make sure we don't need the startDone, stopDone * calls. --- 135,138 ---- *************** *** 116,119 **** --- 143,147 ---- case MAIN_SWITCH_ON: + SODbg(DBG_USR2, "PowerSwitch.setDone() MAIN_SWITCH_ON\n"); state = IDLE; /** GpsControl is wired to GpsPacket.nc */ *************** *** 122,125 **** --- 150,154 ---- case MAIN_SWITCH_OFF: + SODbg(DBG_USR2, "PowerSwitch.setDone() MAIN_SWITCH_OFF\n"); state = POWEROFF; /** GpsControl is wired to GpsPacket.nc */ *************** *** 128,131 **** --- 157,161 ---- case WAIT_SWITCH_ON: + SODbg(DBG_USR2, "PowerSwitch.setDone() WAIT_SWITCH_ON\n"); if (call PowerSwitch.set(MICAWB_GPS_POWER,1) == SUCCESS) { state = MAIN_SWITCH_ON; *************** *** 134,137 **** --- 164,168 ---- case WAIT_SWITCH_OFF: + SODbg(DBG_USR2, "PowerSwitch.setDone() WAIT_SWITCH_OFF\n"); if (call PowerSwitch.set(MICAWB_GPS_POWER,0) == SUCCESS) { state = MAIN_SWITCH_OFF; *************** *** 144,148 **** } - event result_t PowerSwitch.setAllDone(bool local_result) { return SUCCESS; --- 175,178 ---- *************** *** 150,153 **** --- 180,184 ---- + event result_t IOSwitch.getDone(char value) { return SUCCESS; *************** *** 159,183 **** /** FIXME: Rewrite this with a switch/case. */ event result_t IOSwitch.setDone(bool local_result) { ! SODbg(DBG_USR2, "IOSwitch.setDone(): state: %i \n", state); if (state == OPENSCK) { //SCK line enabled state = OPENDATA; return call IOSwitch.set(MICAWB_HUMIDITY_DATA,1); } else if (state == OPENDATA) { //Data line enabled state = TIMER; ! SODbg(DBG_USR2, "IOSwitch.setDone(): Timer Started, state: %i \n", state); ! return call Timer.start(TIMER_ONE_SHOT, 100); } else if (state == CLOSESCK) { state = CLOSEDATA; return call IOSwitch.set(MICAWB_HUMIDITY_DATA,0); } else if (state == CLOSEDATA) { ! } return SUCCESS; } /** * Packet received from GPS - ASCII msg --- 190,223 ---- /** FIXME: Rewrite this with a switch/case. */ + /** FIXME: I see no reason why we need I2C information this + * high in the application. All this I2C bus info needs + * to be shoved down a level, and wired from here to something + * like turnSensorOn(), turnSensorOff(), etc. + */ event result_t IOSwitch.setDone(bool local_result) { ! //SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): state: %i \n", state); if (state == OPENSCK) { //SCK line enabled + SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): SCK enabled \n"); state = OPENDATA; return call IOSwitch.set(MICAWB_HUMIDITY_DATA,1); } else if (state == OPENDATA) { //Data line enabled + SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): SDA enabled \n"); state = TIMER; ! SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): Timer Started, state: %i \n", state); ! return call GPSTimer.start(TIMER_ONE_SHOT, 100); } else if (state == CLOSESCK) { state = CLOSEDATA; + SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): SCK disabled \n"); return call IOSwitch.set(MICAWB_HUMIDITY_DATA,0); } else if (state == CLOSEDATA) { ! SODbg(DBG_USR2, "gps_newM.IOSwitch.setDone(): SDA disabled \n"); } return SUCCESS; } + /** * Packet received from GPS - ASCII msg *************** *** 185,190 **** * async used only for testing. * ! * FIXME: Why is the data return? It should be ! * declared const. * * This function is called from GpsPacket.receiveTask(). --- 225,230 ---- * async used only for testing. * ! * FIXME: Why is the data returned? It's passed in. ! * It should be declared const. * * This function is called from GpsPacket.receiveTask(). *************** *** 197,209 **** for (i=0; i<=gps_data->data[0]; i++) { UARTPutChar(gps_data->data[i]); } SODbg(DBG_USR2, "\n"); #if GPS_ONE_SHOT { ! static uint16_t msg_count = 0; ! if (msg_count == 4) { ! call StdControl.stop(); } msg_count++; --- 237,262 ---- for (i=0; i<=gps_data->data[0]; i++) { + /** UARTPutChar is an SODebug function. + * FIXME: Change this to use a char[]. + */ UARTPutChar(gps_data->data[i]); } SODbg(DBG_USR2, "\n"); + + /** FIXME: Pulled the preprocessor define out, + * code this up as a user defined variable that + * is set when the gps unit is initialized. + */ #if GPS_ONE_SHOT { ! /** Already written out one message. */ ! static uint16_t msg_count = 1; ! if (msg_count == 2) { ! atomic { ! gps_state = GPS_FINISHED; ! } ! call stopGps(); ! msg_count = 0; } msg_count++; *************** *** 216,220 **** event result_t GpsSend.sendDone(TOS_MsgPtr msg, result_t success) { ! SODbg(DBG_USR2, "GpsSend.sendDone()\n", state); return SUCCESS; --- 269,273 ---- event result_t GpsSend.sendDone(TOS_MsgPtr msg, result_t success) { ! SODbg(DBG_USR2, "GpsSend.sendDone(): state: %i \n", state); return SUCCESS; *************** *** 223,227 **** event result_t GpsCmd.SwitchesSet(uint8_t PowerState) { ! SODbg(DBG_USR2, "Gps power on \n"); call Leds.yellowOn(); call Leds.redOff(); --- 276,283 ---- event result_t GpsCmd.SwitchesSet(uint8_t PowerState) { ! char tmp[] = {"Foo"}; ! ! //SODbg(DBG_USR2, "gps_new.GpsCmd.SwitchesSet(): PowerState: %i \n\n", PowerState); ! SODbg(DBG_USR2, "gps_new.GpsCmd.SwitchesSet(): dummy string: %s \n", tmp); call Leds.yellowOn(); call Leds.redOff(); |
From: <do...@us...> - 2003-11-13 00:17:20
|
Update of /cvsroot/firebug/mts400/apps In directory sc8-pr-cvs1:/tmp/cvs-serv12616/apps Modified Files: Makelocal Log Message: Clean up commit to make nothing was missed when the offline driver and test applications were added and commited. Index: Makelocal =================================================================== RCS file: /cvsroot/firebug/mts400/apps/Makelocal,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makelocal 5 Nov 2003 15:57:00 -0000 1.1 --- Makelocal 13 Nov 2003 00:17:18 -0000 1.2 *************** *** 1,14 **** - #LOCAL_PATH += -I$(XBOWROOT)/tos/platform -I$(XBOWROOT)/tos/interfaces -I$(XBOWROOT)/tos/sensorboards/$(SENSORBOARD) LOCAL_PATH += -I../../sensors/$(SENSORBOARD) ! ! ! ! PFLAGS := $(LOCAL_PATH) $(LOCAL_DEFINES) $(PFLAGS) - - - CFLAGS = -DCC1K_DEFAULT_FREQ=CC1K_433_002_MHZ --- 1,7 ---- #LOCAL_PATH += -I$(XBOWROOT)/tos/platform -I$(XBOWROOT)/tos/interfaces -I$(XBOWROOT)/tos/sensorboards/$(SENSORBOARD) LOCAL_PATH += -I../../sensors/$(SENSORBOARD) ! LOCAL_PATH += -I../../sensors/i2c PFLAGS := $(LOCAL_PATH) $(LOCAL_DEFINES) $(PFLAGS) CFLAGS = -DCC1K_DEFAULT_FREQ=CC1K_433_002_MHZ |
From: <do...@us...> - 2003-11-13 00:16:35
|
Update of /cvsroot/firebug/mts400/sensors/adxl In directory sc8-pr-cvs1:/tmp/cvs-serv12477 Added Files: Accel.nc AccelM.nc Log Message: Driver files for adxl sensor. --- NEW FILE: Accel.nc --- /* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ includes sensorboard; configuration Accel { provides interface ADC as AccelX; provides interface ADC as AccelY; provides interface StdControl; provides interface I2CSwitchCmds as AccelCmd; } implementation { components AccelM, ADCC, MicaWbSwitch, TimerC; AccelCmd = AccelM; StdControl = AccelM; AccelM.Timer -> TimerC.Timer[unique("Timer")]; AccelX = ADCC.ADC[ADC_ACCEL_X_PORT]; AccelY = ADCC.ADC[ADC_ACCEL_Y_PORT]; AccelM.ADCControl -> ADCC; AccelM.SwitchControl -> MicaWbSwitch.StdControl; AccelM.Switch1 -> MicaWbSwitch.Switch[0]; } --- NEW FILE: AccelM.nc --- /* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ /* * * Authors: Crossbow * */ includes sensorboard; module AccelM { provides { interface StdControl; interface I2CSwitchCmds as AccelCmd; } uses { interface ADCControl; interface Timer; interface StdControl as SwitchControl; interface Switch as Switch1; } } implementation { #include "SODebug.h" #define DBG_USR2 0 enum {ACCEL_SWITCH_IDLE, //I2C switches are not using the I2C bus ACCEL_PWR_SWITCH_WAIT, //Couldn't get GPS I2C bus ACCEL_PWR_SWITCH, //Got I2C bus, power turning on BUSY, POWEROFF, TIMER}; uint8_t state_accel; uint8_t power_accel; command result_t StdControl.init() { state_accel = ACCEL_SWITCH_IDLE; power_accel = 0; SODbg(DBG_USR2, "ACCEL initialized.\n"); call SwitchControl.init(); return call ADCControl.init(); } command result_t StdControl.start() { call SwitchControl.start(); SODbg(DBG_USR2, "AccelM: I2C switch init \n"); return SUCCESS; } command result_t StdControl.stop() { return SUCCESS; } /****************************************************************************** * Turn Accel power on/off * PowerState = 0 then accel power off, * = 1 then accel power on * ADXL202E has turn on time of 160*Cflt+0.3 ms * Cflt = 0.1 uF * Turn on time = ~16 msec. *****************************************************************************/ command result_t AccelCmd.PowerSwitch(uint8_t PowerState){ SODbg(DBG_USR2, "AccelM: PowerSwitch \n"); if (state_accel == ACCEL_SWITCH_IDLE){ state_accel = ACCEL_PWR_SWITCH; power_accel = PowerState; if (!call Switch1.set(MICAWB_ACCEL_POWER,power_accel) == SUCCESS) state_accel = ACCEL_PWR_SWITCH_WAIT; return SUCCESS; } return FAIL; } event result_t Switch1.getDone(char value) { return SUCCESS; } /****************************************************************************** * Power switch set on or off * If turning power on then wait 100 msec for ADXL202 turn-on before returning * else return immediately. *****************************************************************************/ event result_t Switch1.setDone(bool local_result) { SODbg(DBG_USR2, "AccelM: setDone: state %i \n", state_accel); if (state_accel == ACCEL_PWR_SWITCH_WAIT){ //try again to get I2C bus SODbg(DBG_USR2, "AccelM: setDone: I2C retry \n "); state_accel = ACCEL_PWR_SWITCH; if (!call Switch1.set(MICAWB_ACCEL_POWER,power_accel) == SUCCESS) state_accel = ACCEL_PWR_SWITCH_WAIT; return SUCCESS; } if (state_accel == ACCEL_PWR_SWITCH){ if (power_accel) { return call Timer.start(TIMER_ONE_SHOT, 100); } state_accel = ACCEL_SWITCH_IDLE; signal AccelCmd.SwitchesSet(power_accel); } return SUCCESS; } event result_t Switch1.setAllDone(bool local_result) { return SUCCESS; } // sensor is now warmed up event result_t Timer.fired() { state_accel = ACCEL_SWITCH_IDLE; signal AccelCmd.SwitchesSet(power_accel); return SUCCESS; } } |
From: <do...@us...> - 2003-11-13 00:15:45
|
Update of /cvsroot/firebug/mts400/apps/TestADXL In directory sc8-pr-cvs1:/tmp/cvs-serv12319 Added Files: Makefile adxl.nc adxlM.nc Log Message: Test application for adxl. --- NEW FILE: Makefile --- COMPONENT=adxl SENSORBOARD=adxl include ../Makelocal include $(TOSROOT)/apps/Makerules --- NEW FILE: adxl.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ configuration adxl { } implementation { components Main, adxlM, MicaWbSwitch, TimerC, NoLeds, LedsC, Accel; adxlM.Leds -> LedsC; adxlM.Timer -> TimerC.Timer[unique("Timer")]; Main.StdControl -> adxlM; Main.StdControl -> TimerC; adxlM.AccelControl -> Accel.StdControl; adxlM.AccelCmd -> Accel.AccelCmd; adxlM.AccelX -> Accel.AccelX; adxlM.AccelY -> Accel.AccelY; } --- NEW FILE: adxlM.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ /** * Displays ADXL output. * * Output results through mica2 uart port. * Connect serial cable from programming * board to PC to monitor ouput. Use any * terminal monitoring program set for * 57600, N,8,1 * * NOTE: * No real power strategy; just turns sensors on sequentially. * Should add BusArbitration routines, like mica2dotwb * for better power control */ module adxlM { provides interface StdControl; uses { interface Timer; interface Leds; interface StdControl as AccelControl; interface I2CSwitchCmds as AccelCmd; interface ADC as AccelX; interface ADC as AccelY; } } implementation { #include "SODebug.h" #define ACCEL_POWER_OFF 0 #define ACCEL_POWER_ON 1 enum {START, BUSY}; uint16_t AccelData; command result_t StdControl.init() { init_debug(); call Leds.init(); call AccelControl.init(); return SUCCESS; } command result_t StdControl.start() { call Leds.redOn(); call Leds.yellowOn(); call Leds.greenOn(); call Timer.start(TIMER_REPEAT, 500); return SUCCESS; } command result_t StdControl.stop() { return SUCCESS; } event result_t Timer.fired() { call Leds.redOff(); call Leds.yellowOff(); call Leds.greenOff(); call AccelCmd.PowerSwitch(ACCEL_POWER_ON); return SUCCESS; } /****************************************************************************** * ADXL202E Accelerometer * At 3.0 supply this sensor's sensitivty is ~167mv/g * 0 g is at ~1.5V or ~VCC/2 - this varies alot. * For an accurate calibration measure each axis at +/- 1 g and * compute the center point (0 g level) as 1/2 of difference. * Note: this app doesn't measure the battery voltage, it assumes 3.2 volts * To getter better accuracy measure the battery voltage as this effects the * full scale of the Atmega128 ADC. * bits/mv = 1024/(1000*VBATT) * bits/g = 1024/(1000*VBATT)(bits/mv) * 167(mv/g) * = 171/VBATT (bits/g) * C = 0.171/VBATT (bits/mg) * Accel(mg) ~ (ADC DATA - 512) /C *****************************************************************************/ async event result_t AccelY.dataReady(uint16_t data){ float Accel, C; float VBATT = 3.2; C = 0.171/VBATT; atomic { Accel = ((float)AccelData - 512.0)/C; SODbg(DBG_BOOT, "AccelX data %i AcceX(mg) %i \n",AccelData, (int)Accel); } Accel = ((float)data - 512.0)/C; SODbg(DBG_BOOT, "AccelY data %i AcceY(mg) %i \n",data, (int)Accel); call AccelCmd.PowerSwitch(ACCEL_POWER_OFF); return SUCCESS; } async event result_t AccelX.dataReady(uint16_t data){ atomic { AccelData = data; } call AccelY.getData(); return SUCCESS; } event result_t AccelCmd.SwitchesSet(uint8_t PowerState) { call Leds.greenToggle(); if (PowerState) { call AccelX.getData(); } return SUCCESS; } } |
From: <do...@us...> - 2003-11-13 00:13:42
|
Update of /cvsroot/firebug/mts400/apps/TestTaos In directory sc8-pr-cvs1:/tmp/cvs-serv11889 Added Files: .cvsignore Makefile taos.nc taosM.nc Log Message: Test application for taos light sensor. --- NEW FILE: .cvsignore --- build *~ --- NEW FILE: Makefile --- COMPONENT=taos SENSORBOARD=taos include ../Makelocal include $(TOSROOT)/apps/Makerules --- NEW FILE: taos.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ configuration taos { } implementation { components Main, taosM, MicaWbSwitch, TimerC, NoLeds, LedsC, TaosPhoto; Main.StdControl -> taosM; Main.StdControl -> TimerC; taosM.Leds -> LedsC; taosM.Timer -> TimerC.Timer[unique("Timer")]; taosM.TaosControl -> TaosPhoto; taosM.TaosCh0 -> TaosPhoto.ADC[0]; taosM.TaosCh1 -> TaosPhoto.ADC[1]; } --- NEW FILE: taosM.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ /****************************************************************************** * Measures MTS400/420 weatherboard sensors & gps and converts to engineering units * were possible. * * Output results through mica2 uart port. Connect serial cable from programming * board to PC to monitor ouput. Use any terminal monitoring program set for * 57600, N,8,1 * * NOTE: * No real power strategy; just turns sensors on sequentially. * Should add BusArbitration routines, like mica2dotwb for better power control *****************************************************************************/ module taosM { provides interface StdControl; uses { interface Timer; interface Leds; interface SplitControl as TaosControl; interface ADC as TaosCh0; interface ADC as TaosCh1; } } implementation { #include "SODebug.h" enum {START, BUSY, LIGHT_DONE, ACCEL_DONE}; uint16_t TaosData; uint8_t state; command result_t StdControl.init() { atomic { TaosData = 0; } init_debug(); call Leds.init(); call TaosControl.init(); return SUCCESS; } command result_t StdControl.start() { call Leds.redOn(); call Leds.yellowOn(); call Leds.greenOn(); state = START; call Timer.start(TIMER_REPEAT, 500); return SUCCESS; } command result_t StdControl.stop() { return SUCCESS; } event result_t Timer.fired() { call Leds.redOff(); call Leds.yellowOff(); call Leds.greenOff(); switch (state) { case START: state = BUSY; call TaosControl.start(); break; case LIGHT_DONE: state = START; break; default: break; } return SUCCESS; } /** * Taos- tsl2250 light sensor * Two ADC channels: * ADC Count Value (ACNTx) = INT(16.5*[CV-1]) +S*CV * where CV = 2^^C * C = (data & 0x7) >> 4 * S = data & 0xF * Light level (lux) = ACNT0*0.46*(e^^-3.13*R) * R = ACNT1/ACNT0 */ async event result_t TaosCh1.dataReady(uint16_t data) { uint16_t CV1,CH1,ST1,ACNT0,ACNT1; float CNT1,R,Lux; call Leds.greenToggle(); atomic { ST1 = TaosData & 0xf; } atomic { CH1 = (TaosData & 0x70) >> 4; } CV1 = 1 << CH1; CNT1 = (int)(16.5*(CV1-1)) + ST1*CV1; ACNT0 = (int)CNT1; atomic { if (TaosData == 0xff) { SODbg(DBG_USR2, "Taos Ch0 data: OVERFLOW \n") ; } } SODbg(DBG_USR2, "Taos Ch0 data: %i Cord: %i Step: %i ADC Counts: %i \n", TaosData & 0x0FF, CH1,ST1,ACNT0); data = data & 0xff; ST1 = data & 0xf; CH1 = (data & 0x70) >> 4; CV1 = 1 << CH1; CNT1 = (int)(16.5*(CV1-1)) + ST1*CV1; ACNT1 = (int)CNT1; R = (float)ACNT1/(float)ACNT0; Lux = (float)ACNT0*0.46/exp(3.13*R); if (data == 0xff) { SODbg(DBG_USR2, "Taos Ch1 data: OVERFLOW \n"); } SODbg(DBG_USR2, "Taos Ch1 data: %i Cord: %i Step: %i ADC Counts: %i Light(lux): %i \n", data & 0x0FF, CH1,ST1,ACNT1,(int)Lux); call TaosControl.stop(); return SUCCESS; } async event result_t TaosCh0.dataReady(uint16_t data) { atomic { TaosData = data & 0xff; } SODbg(DBG_USR2, "Got Taos Ch0 data \n") ; return call TaosCh1.getData(); } event result_t TaosControl.startDone(){ return call TaosCh0.getData(); } event result_t TaosControl.initDone() { return SUCCESS; } event result_t TaosControl.stopDone() { state = LIGHT_DONE; return SUCCESS; } } |
From: <do...@us...> - 2003-11-13 00:12:01
|
Update of /cvsroot/firebug/mts400/sensors/taos In directory sc8-pr-cvs1:/tmp/cvs-serv11561 Added Files: TaosPhoto.nc TaosPhotoM.nc Log Message: Photo sensor driver files. --- NEW FILE: TaosPhoto.nc --- /* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ /* * * Authors: Joe Polastre * * $Id: TaosPhoto.nc,v 1.1 2003/11/13 00:11:56 doolin Exp $ */ includes sensorboard; configuration TaosPhoto { provides { interface ADC[uint8_t id]; interface SplitControl; } } implementation { components TaosPhotoM, I2CPacketC, TimerC, MicaWbSwitch; SplitControl = TaosPhotoM; ADC = TaosPhotoM; TaosPhotoM.I2CPacketControl -> I2CPacketC.StdControl; TaosPhotoM.I2CPacket -> I2CPacketC.I2CPacket[TOSH_PHOTO_ADDR]; TaosPhotoM.Timer -> TimerC.Timer[unique("Timer")]; TaosPhotoM.SwitchControl -> MicaWbSwitch.StdControl; TaosPhotoM.Switch -> MicaWbSwitch.Switch[0]; } --- NEW FILE: TaosPhotoM.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ /* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ /* * * Authors: Joe Polastre * * $Id: TaosPhotoM.nc,v 1.1 2003/11/13 00:11:56 doolin Exp $ */ includes sensorboard; module TaosPhotoM { provides { interface ADC[uint8_t id]; interface SplitControl; } uses { interface StdControl as SwitchControl; interface StdControl as I2CPacketControl; interface Switch; interface Timer; interface I2CPacket; } } implementation { #include "SODebug.h" #define DBG_USR2 0 enum {IDLE, START_TAOS, SWITCH_POWER_ON, SWITCH_POWER_OFF, SWITCH_WAIT, READ_0, READ_1}; norace char state; norace char tempvalue; bool power; char data_adc; task void DataReady_0() { SODbg(DBG_USR2, "TaosPhoto:Ch0:, %i \n", (uint16_t)data_adc); signal ADC.dataReady[0](data_adc); return; } task void DataReady_1(){ SODbg(DBG_USR2, "TaosPhoto:Ch1:, %i \n", (uint16_t)data_adc); signal ADC.dataReady[1](data_adc); return; } command result_t SplitControl.init() { atomic { state = IDLE; power = FALSE; } SODbg(DBG_USR2, "TaosPhoto:init \n"); call I2CPacketControl.init(); call SwitchControl.init(); signal SplitControl.initDone(); return SUCCESS;; } /** * Start: * - turn on power * - if can't set switch then state = SWITCH_WAIT */ command result_t SplitControl.start() { SODbg(DBG_USR2, "TaosPhoto:start \n"); atomic { state = SWITCH_POWER_ON; } call I2CPacketControl.start(); call SwitchControl.start(); if (call Switch.set(MICAWB_LIGHT_POWER,1) != SUCCESS) { state = SWITCH_WAIT; } return SUCCESS; } command result_t SplitControl.stop() { power = FALSE; // turn the sensor off state = SWITCH_POWER_OFF; return call Switch.set(MICAWB_LIGHT_POWER,0); } event result_t Switch.getDone(char value) { return SUCCESS; } /** * Switch control done * - if state= SWITCH_POWER_ON: * power just turned on, xmit cmd to start Taos * - if state= SWITCH_POWER_OFF: * notify completion */ event result_t Switch.setDone(bool result) { if (state == SWITCH_POWER_OFF){ //asb state = IDLE; return signal SplitControl.stopDone(); } if (state == SWITCH_POWER_ON) { state = START_TAOS; TOSH_uwait(1000); // wait for sensor to power up atomic { tempvalue = 0x03; } return call I2CPacket.writePacket(1,(char*)&tempvalue,0x01); } else if (state == SWITCH_WAIT) { if (call Switch.set(MICAWB_LIGHT_POWER,1) != SUCCESS) { state = SWITCH_WAIT; } else { state = SWITCH_POWER_ON; } } return SUCCESS; } event result_t Switch.setAllDone(bool result) { return SUCCESS; } // no such thing async command result_t ADC.getContinuousData[uint8_t id]() { return FAIL; } /** * Read Taos adc data * Cmd to read channel 0 + enable adc/power = 0x43 * Cmd to read channel 1 + enable adc/power = 0x83 */ async command result_t ADC.getData[uint8_t id]() { SODbg(DBG_USR2, "TaosPhoto:getData \n"); if (state == IDLE) { if (id == 0) { //read channel 0 atomic { tempvalue = 0x43; state = READ_0; } return call I2CPacket.writePacket(1,(char*)&tempvalue,0x01); } else if (id == 1) { //read channel 1 atomic { tempvalue = 0x83; state = READ_1; } return call I2CPacket.writePacket(1,(char*)&tempvalue,0x01); } } state = IDLE; return FAIL; } /****************************************************************************** * I2C write packet complete * If state = START_TAOS then fire timer to wait 800msec for conversion complete * *****************************************************************************/ event result_t I2CPacket.writePacketDone(bool result) { if (state == START_TAOS) { return call Timer.start(TIMER_ONE_SHOT, 850); } if (state == READ_0) { return call I2CPacket.readPacket(1,0x01); } else if (state == READ_1) { return call I2CPacket.readPacket(1,0x01); } return FAIL; } /****************************************************************************** * I2C read packet complete * If state = * *****************************************************************************/ event result_t I2CPacket.readPacketDone(char length, char* data) { if (state == READ_0) { SODbg(DBG_USR2, "TaosPhoto:getData 0, %i \n", (int)data[0]); data_adc = data[0]; post DataReady_0(); state = IDLE; return SUCCESS; } else if (state == READ_1) { SODbg(DBG_USR2, "TaosPhoto:getData 1, %i \n", (int)data[0]); data_adc = data[0]; post DataReady_1(); state = IDLE; return SUCCESS; } return SUCCESS; } /****************************************************************************** * Timer fired. * Taos ready for readout * *****************************************************************************/ event result_t Timer.fired() { atomic { state = IDLE; } signal SplitControl.startDone(); // asb return SUCCESS; } default async event result_t ADC.dataReady[uint8_t id](uint16_t data) { return SUCCESS; } } |
Update of /cvsroot/firebug/mts400/sensors/intersema In directory sc8-pr-cvs1:/tmp/cvs-serv11301 Added Files: ADCError.nc Calibration.nc IntersemaLower.nc IntersemaLowerM.nc IntersemaPressure.nc IntersemaPressureM.nc Log Message: Driver files for intersema pressure sensor. --- NEW FILE: ADCError.nc --- /* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ /* * * Authors: Joe Polastre * * $Id: ADCError.nc,v 1.1 2003/11/13 00:10:04 doolin Exp $ * */ interface ADCError { /** * Enables error reporting for an ADC channel. * enable() must be called when the ADC is IDLE. If it is busy * processing a request, enable() should return FAIL. * * @return SUCCESS if error reporting has been enabled */ command result_t enable(); /** * Disables error reporting for an ADC channel * disable() must be called when the ADC is IDLE. If it is busy * processing a request, disable() should return FAIL. * * @return SUCCESS if error reporting has been disabled */ command result_t disable(); /** * Notification that an error has occurred in the sampling process. * Token values are sensor specific, see the specific sensor to * determine what the error values mean. * * @param token an error code that describes the error that occurred * @return SUCCESS to continue error reporting, FAIL to disable error * reporting */ event result_t error(uint8_t token); } --- NEW FILE: Calibration.nc --- /* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ /* * * Authors: Joe Polastre * * $Id: Calibration.nc,v 1.1 2003/11/13 00:10:06 doolin Exp $ */ interface Calibration { command result_t getData(); event result_t dataReady(char word, uint16_t value); } --- NEW FILE: IntersemaLower.nc --- /* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ /* * * Authors: Joe Polastre * * $Id: IntersemaLower.nc,v 1.1 2003/11/13 00:10:06 doolin Exp $ */ includes sensorboard; configuration IntersemaLower { provides { interface ADC as Pressure; interface ADC as Temp; interface ADCError as PressError; interface ADCError as TempError; interface StdControl; interface Calibration; } } implementation { components IntersemaLowerM, TimerC; StdControl = IntersemaLowerM; Pressure = IntersemaLowerM.Pressure; Temp = IntersemaLowerM.Temp; Calibration = IntersemaLowerM; PressError = IntersemaLowerM.PressError; TempError = IntersemaLowerM.TempError; IntersemaLowerM.Timer -> TimerC.Timer[unique("Timer")]; IntersemaLowerM.TimerControl -> TimerC; // IntersemaLowerM.FlashControl -> HPLFlash; } --- NEW FILE: IntersemaLowerM.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ /* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ /* * * Authors: Joe Polastre * * $Id: IntersemaLowerM.nc,v 1.1 2003/11/13 00:10:06 doolin Exp $ */ includes sensorboard; includes hardware; module IntersemaLowerM { provides { interface ADC as Pressure; interface ADC as Temp; interface ADCError as PressError; interface ADCError as TempError; interface StdControl; interface Calibration; } uses { // interface StdControl as FlashControl; interface Timer; interface StdControl as TimerControl; } } implementation { enum { IDLE=7, RESET=8, CALIBRATE=9, TEMP=10, PRESSURE=11, DATA_READY=12 }; //FIXME: Remove the norace and fix the rest of the atomic r/w warnings norace char state; norace char sensor; uint16_t calibration[4]; uint16_t reading; uint8_t timeout; uint8_t errornum; bool presserror, temperror; void task signalPressError() { signal PressError.error(errornum); } void task signalTempError() { signal TempError.error(errornum); } void pulse_clock() { TOSH_wait_250ns(); TOSH_wait_250ns(); PRESSURE_SET_CLOCK(); TOSH_wait_250ns(); TOSH_wait_250ns(); PRESSURE_CLEAR_CLOCK(); } char din_value() { return PRESSURE_READ_IN_PIN(); } char read_bit() { char i; PRESSURE_CLEAR_OUT_PIN(); PRESSURE_SET_CLOCK(); TOSH_wait_250ns(); TOSH_wait_250ns(); i = PRESSURE_READ_IN_PIN(); PRESSURE_CLEAR_CLOCK(); return i; } void write_bit(bool bit) { if (bit) PRESSURE_SET_OUT_PIN(); else PRESSURE_CLEAR_OUT_PIN(); pulse_clock(); } // resets the intersema device void spi_reset() { int i = 0; for (i = 0; i < 21; i++) { if (i < 16) { if ((i % 2) == 0) { write_bit(TRUE); } else { write_bit(FALSE); } } else { write_bit(FALSE); } } } uint16_t adc_read() { uint16_t result = 0; uint16_t tresult = 0; char i; TOSH_wait_250ns(); for (i = 0; i < 16; i++) { tresult = (uint16_t)read_bit(); tresult = tresult << (15-i); result += tresult; } return result; } uint16_t spi_word(char num) { int i; TOSH_wait_250ns(); TOSH_wait_250ns(); // write first byte for (i = 0; i < 3; i++) { write_bit(TRUE); } write_bit(FALSE); write_bit(TRUE); if (num == 1) { write_bit(FALSE); write_bit(TRUE); write_bit(FALSE); write_bit(TRUE); } else if (num == 2) { write_bit(FALSE); write_bit(TRUE); write_bit(TRUE); write_bit(FALSE); } else if (num == 3) { write_bit(TRUE); write_bit(FALSE); write_bit(FALSE); write_bit(TRUE); } else if (num == 4) { write_bit(TRUE); write_bit(FALSE); write_bit(TRUE); write_bit(FALSE); } for (i = 0; i < 4; i++) write_bit(FALSE); TOSH_wait_250ns(); return adc_read(); } void task gotInterrupt() { uint16_t l_reading; reading = adc_read(); l_reading = reading; atomic { // we're done, so we can be idle state = IDLE; // give the application the sensor data if (sensor == TEMP) { signal Temp.dataReady(l_reading); } else if (sensor == PRESSURE) { signal Pressure.dataReady(l_reading); } } } void sense() { int i; TOSH_wait_250ns(); TOSH_wait_250ns(); // write first byte for (i = 0; i < 3; i++) { write_bit(TRUE); } if (sensor == PRESSURE) { write_bit(TRUE); write_bit(FALSE); write_bit(TRUE); write_bit(FALSE); } else if (sensor == TEMP) { write_bit(TRUE); write_bit(FALSE); write_bit(FALSE); write_bit(TRUE); } for (i = 0; i < 5; i++) { write_bit(FALSE); } timeout = 0; call Timer.start(TIMER_ONE_SHOT, 36); // kill busy waiting for now // while (PRESSURE_READ_IN_PIN() == 1) { TOSH_wait_250ns(); TOSH_wait_250ns(); } // falling edge of int0 triggers data ready //cbi(EICRA, ISC01); //cbi(EICRA, ISC00); // enable INT0 //sbi(EIMSK, INT0); } event result_t Timer.fired() { if (PRESSURE_READ_IN_PIN() == 1) { timeout++; if (timeout > PRESSURE_TIMEOUT_TRIES) { if ((sensor == PRESSURE) && (presserror == TRUE)) { errornum = 1; call Timer.stop(); state = IDLE; post signalPressError(); return SUCCESS; } else if ((sensor == TEMP) && (temperror == TRUE)) { errornum = 1; call Timer.stop(); state = IDLE; post signalTempError(); return SUCCESS; } } call Timer.start(TIMER_ONE_SHOT, 20); } else { call Timer.stop(); post gotInterrupt(); } return SUCCESS; } TOSH_SIGNAL(PRESSURE_INTERRUPT) { post gotInterrupt(); } task void SPITask() { char i; if (state == RESET) { // if calibration is on, grab the calibration data if (sensor == CALIBRATE) { for (i = 0; i < 4; i++) { // reset the device spi_reset(); calibration[(int)i] = spi_word(i+1); } // we're done, so we can be idle state = IDLE; // send the calibration data up to the application for (i = 0; i < 4; i++) signal Calibration.dataReady(i+1, calibration[(int)i]); return; } else { // reset the device spi_reset(); // grab the sensor reading and store it locally sense(); } } } command result_t StdControl.init() { state = IDLE; presserror = temperror = FALSE; call TimerControl.init(); return SUCCESS; } command result_t StdControl.start() { UART1_DISABLE(); PRESSURE_MAKE_CLOCK_OUTPUT(); PRESSURE_MAKE_IN_INPUT(); PRESSURE_SET_IN_PIN(); PRESSURE_MAKE_OUT_OUTPUT(); return SUCCESS; } command result_t StdControl.stop() { return SUCCESS; } // tells this module whether to report back the calibration data command result_t Calibration.getData() { if (state == IDLE) { state = RESET; atomic { sensor = CALIBRATE; } post SPITask(); return SUCCESS; } return FAIL; } // no such thing async command result_t Pressure.getContinuousData() { return FAIL; } // no such thing async command result_t Temp.getContinuousData() { return FAIL; } async command result_t Pressure.getData() { if (state == IDLE) { state = RESET; atomic { sensor = PRESSURE; } post SPITask(); return SUCCESS; } return FAIL; } async command result_t Temp.getData() { if (state == IDLE) { state = RESET; sensor = TEMP; post SPITask(); return SUCCESS; } return FAIL; } command result_t PressError.enable() { if (presserror == FALSE) { atomic presserror = TRUE; return SUCCESS; } return FAIL; } command result_t PressError.disable() { if (presserror == TRUE) { atomic presserror = FALSE; return SUCCESS; } return FAIL; } command result_t TempError.enable() { if (temperror == FALSE) { atomic temperror = TRUE; return SUCCESS; } return FAIL; } command result_t TempError.disable() { if (temperror == TRUE) { atomic temperror = FALSE; return SUCCESS; } return FAIL; } default event result_t PressError.error(uint8_t token) { return SUCCESS; } default event result_t TempError.error(uint8_t token) { return SUCCESS; } async default event result_t Pressure.dataReady(uint16_t data) { return SUCCESS; } async default event result_t Temp.dataReady(uint16_t data) { return SUCCESS; } // in case people don't want to use the calibration data default event result_t Calibration.dataReady(char word, uint16_t value) { return SUCCESS; } } --- NEW FILE: IntersemaPressure.nc --- /* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ /* * * Authors: Joe Polastre * * $Id: IntersemaPressure.nc,v 1.1 2003/11/13 00:10:06 doolin Exp $ */ includes sensorboard; configuration IntersemaPressure { provides { interface ADC as Temperature; interface ADC as Pressure; interface Calibration; interface SplitControl; } } implementation { components IntersemaPressureM, IntersemaLower, MicaWbSwitch, TimerC; SplitControl = IntersemaPressureM; Temperature = IntersemaPressureM.Temperature; Pressure = IntersemaPressureM.Pressure; Calibration = IntersemaPressureM; IntersemaPressureM.SwitchControl -> MicaWbSwitch.StdControl; IntersemaPressureM.Switch -> MicaWbSwitch.Switch[0]; IntersemaPressureM.IOSwitch -> MicaWbSwitch.Switch[1]; IntersemaPressureM.LowerControl -> IntersemaLower.StdControl; IntersemaPressureM.LowerPressure -> IntersemaLower.Pressure; IntersemaPressureM.LowerTemp -> IntersemaLower.Temp; IntersemaPressureM.LowerCalibrate -> IntersemaLower.Calibration; IntersemaPressureM.Timer -> TimerC.Timer[unique("Timer")]; IntersemaPressureM.TimerControl -> TimerC; } --- NEW FILE: IntersemaPressureM.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ /* * * Authors: Joe Polastre * * $Id: IntersemaPressureM.nc,v 1.1 2003/11/13 00:10:06 doolin Exp $ */ includes sensorboard; module IntersemaPressureM { provides { interface ADC as Temperature; interface ADC as Pressure; interface SplitControl; interface Calibration; } uses { interface StdControl as SwitchControl; interface StdControl as LowerControl; interface Calibration as LowerCalibrate; interface Switch; interface Switch as IOSwitch; interface ADC as LowerPressure; interface ADC as LowerTemp; interface Timer; interface StdControl as TimerControl; } } implementation { #include "SODebug.h" #define DBG_USR2 0 //disables printf msgs enum { IDLE, WARM_UP, WAIT_SWITCH_ON, WAIT_SWITCH_OFF, BUSY, MAIN_SWITCH_ON, MAIN_SWITCH_OFF, SWITCH_IO1, SWITCH_IO2, SWITCH_IO3, POWERON, POWEROFF, IOON = 1, IOOFF = 0 }; // FIXME: Remove the norace and fix the rest of the atomic r/w warnings. norace char state; char sensor; char iostate; char c_word; uint16_t temp,pressure; uint16_t c_value; task void initDone() { signal SplitControl.initDone(); } task void stopDone() { signal SplitControl.stopDone(); } task void startDone(){ signal SplitControl.startDone(); } task void IOBus() { atomic { if (state == BUSY) { state = SWITCH_IO1; call IOSwitch.set(MICAWB_PRESSURE_SCLK, iostate); } else if (state == SWITCH_IO1) { SODbg(DBG_USR2, "IntesemaPressure.IoBus.SCLK switch set \n"); state = SWITCH_IO2; call IOSwitch.set(MICAWB_PRESSURE_DIN, iostate); } else if (state == SWITCH_IO2) { SODbg(DBG_USR2, "IntesemaPressure.IoBus.Din switch set \n"); state = SWITCH_IO3; call IOSwitch.set(MICAWB_PRESSURE_DOUT, iostate); } else if (state == SWITCH_IO3) { SODbg(DBG_USR2, "IntesemaPressure.IOBus.all switches set \n"); state = IDLE; atomic { if (iostate == IOOFF){ call LowerControl.stop(); post stopDone(); } else { post startDone(); } } } } // else if (iostate == IOOFF) { // call LowerControl.stop(); // state = IDLE; // post stopDone(); // state = POWEROFF; //} } command result_t SplitControl.init() { state = IDLE; atomic { iostate = IOOFF; } call LowerControl.init(); call SwitchControl.init(); call TimerControl.init(); post initDone(); return SUCCESS; } command result_t SplitControl.start() { SODbg(DBG_USR2, "IntersemaPressure.start: turning on power \n"); state = MAIN_SWITCH_ON; call SwitchControl.start(); if (call Switch.set(MICAWB_PRESSURE_POWER,1) != SUCCESS) { state = WAIT_SWITCH_ON; } return SUCCESS; } command result_t SplitControl.stop() { SODbg(DBG_USR2, "IntersemaPressure.stop: turning off power \n"); state = MAIN_SWITCH_OFF; call SwitchControl.start(); if (call Switch.set(MICAWB_PRESSURE_POWER,0) != SUCCESS) { SODbg(DBG_USR2, "IntersemaPressure.stop: failed to get bus \n"); state = WAIT_SWITCH_OFF; } return SUCCESS; } event result_t Switch.getDone(char value) { return SUCCESS; } event result_t Switch.setDone(bool l_result) { if (state == WAIT_SWITCH_ON) { if (call Switch.set(MICAWB_PRESSURE_POWER,1) == SUCCESS) { state = MAIN_SWITCH_ON; } } else if (state == WAIT_SWITCH_OFF) { if (call Switch.set(MICAWB_PRESSURE_POWER,0) == SUCCESS) { state = MAIN_SWITCH_OFF; } } else if (state == MAIN_SWITCH_ON) { SODbg(DBG_USR2, "IntesemaPressure.start: power on, timer activated \n"); atomic { iostate = IOON; } state = BUSY; post IOBus(); //turn on other switches return SUCCESS; } else if (state == MAIN_SWITCH_OFF) { state = BUSY; atomic { iostate = IOOFF; } post IOBus(); // post stopDone(); // state = POWEROFF; } return SUCCESS; } event result_t Switch.setAllDone(bool l_result) { return SUCCESS; } event result_t IOSwitch.getDone(char value) { return SUCCESS; } //turn on/off all the I/O switches event result_t IOSwitch.setDone(bool l_result) { if ((state == SWITCH_IO1) || (state == SWITCH_IO2) || (state == SWITCH_IO3)) { post IOBus(); } return SUCCESS; } event result_t IOSwitch.setAllDone(bool l_result) { return SUCCESS; } event result_t Timer.fired() { if (state == WARM_UP) { SODbg(DBG_USR2, "IntesemaPressure.Timer.fired \n"); state = BUSY; post IOBus(); } return SUCCESS; } /****************************************************************************** * Get temperature or pressure data from sensor *****************************************************************************/ async command result_t Temperature.getData() { if (state == IDLE) { state = BUSY; call LowerControl.start(); call LowerTemp.getData(); return SUCCESS; } return FAIL; } async event result_t LowerTemp.dataReady(uint16_t data) { atomic { state = IDLE; } signal Temperature.dataReady(data); return SUCCESS; } async command result_t Pressure.getData() { if (state == IDLE) { state = BUSY; atomic { sensor = MICAWB_PRESSURE; iostate = IOON; } call LowerControl.start(); call LowerPressure.getData(); return SUCCESS; } return FAIL; } async event result_t LowerPressure.dataReady(uint16_t data) { state = IDLE; signal Pressure.dataReady(data); return SUCCESS; } // no such thing async command result_t Temperature.getContinuousData() { return FAIL; } // no such thing async command result_t Pressure.getContinuousData() { return FAIL; } default async event result_t Temperature.dataReady(uint16_t data) { return SUCCESS; } default async event result_t Pressure.dataReady(uint16_t data) { return SUCCESS; } /****************************************************************************** * Read calibration words (4) from sensor *****************************************************************************/ command result_t Calibration.getData() { if (state == IDLE) { SODbg(DBG_USR2, "IntesemaPressure.Calibration.getData \n"); state = BUSY; call LowerControl.start(); call LowerCalibrate.getData(); return SUCCESS; } return FAIL; } // on the last byte of calibration data, shut down the I/O interface // async event result_t LowerCalibrate.dataReady(char word, uint16_t value) { event result_t LowerCalibrate.dataReady(char word, uint16_t value) { if (word == 4) { call LowerControl.stop(); atomic { state = IDLE; } signal Calibration.dataReady(word, value); } else { call LowerControl.stop(); signal Calibration.dataReady(word, value); } return SUCCESS; } // default async event result_t Calibration.dataReady(char word, uint16_t value) { default event result_t Calibration.dataReady(char word, uint16_t value) { return SUCCESS; } } |
From: <do...@us...> - 2003-11-13 00:08:03
|
Update of /cvsroot/firebug/mts400/apps/TestIntersema In directory sc8-pr-cvs1:/tmp/cvs-serv10966 Added Files: .cvsignore Intersema.nc IntersemaM.nc Makefile Log Message: Standalone pressure application. --- NEW FILE: .cvsignore --- build *~ --- NEW FILE: Intersema.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ configuration Intersema { } implementation { components Main, IntersemaM, IntersemaPressure, MicaWbSwitch, TimerC, NoLeds,LedsC; Main.StdControl -> IntersemaM; Main.StdControl -> TimerC; // Wiring for Intersema barometric pressure/temperature sensor IntersemaM.IntersemaCal -> IntersemaPressure; IntersemaM.PressureControl -> IntersemaPressure; IntersemaM.IntersemaPressure -> IntersemaPressure.Pressure; IntersemaM.IntersemaTemp -> IntersemaPressure.Temperature; IntersemaM.Leds -> LedsC; IntersemaM.Timer -> TimerC.Timer[unique("Timer")]; } --- NEW FILE: IntersemaM.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ /* History: created 1/25/2001 * * */ /****************************************************************************** * Measures MTS400/420 weatherboard sensors & gps and converts to engineering units * were possible. *----------------------------------------------------------------------------- * Output results through mica2 uart port. Connect serial cable from programming * board to PC to monitor ouput. Use any terminal monitoring program set for * 57600, N,8,1 * NOTE: * No real power strategy; just turns sensors on sequentially. * Should add BusArbitration routines, like mica2dotwb for better power control *****************************************************************************/ module IntersemaM { provides interface StdControl; uses { //Intersema interface SplitControl as PressureControl; //interface StdControl as PressureControl; interface ADC as IntersemaTemp; interface ADC as IntersemaPressure; interface Calibration as IntersemaCal; interface Timer; interface Leds; } } implementation { #include "SODebug.h" enum {START, BUSY, HUMIDITY_DONE, PRESSURE_DONE, LIGHT_DONE, ACCEL_DONE}; char count; uint16_t calibration[6]; uint16_t C1,C2,C3,C4,C5,C6; //intersema calibration coefficients uint16_t PressureData; uint8_t state; bool gps_active; //true if gps is active command result_t StdControl.init() { init_debug(); call Leds.init(); call PressureControl.init(); return SUCCESS; } command result_t StdControl.start() { call Leds.redOn(); call Leds.yellowOn(); call Leds.greenOn(); state = START; call Timer.start(TIMER_REPEAT, 500); return SUCCESS; } command result_t StdControl.stop() { return SUCCESS; } /****************************************************************************** * Timer fired, test GPS, humidity/temp * async for test only *****************************************************************************/ event result_t Timer.fired() { call Leds.redOff(); call Leds.yellowOff(); call Leds.greenOff(); call PressureControl.start(); return SUCCESS; } /****************************************************************************** * Intersema MS5534A barometric pressure/temperature sensor * - 6 cal coefficients (C1..C6) are extracted from 4, 16 bit,words from sensor * - Temperature measurement: * UT1=8*C5+20224 * dT=data-UT1 * Temp=(degC x10)=200+dT(C6+50)/1024 * - Pressure measurement: * OFF=C2*4 + ((C4-512)*dT)/1024 * SENS=C1+(C3*dT)/1024 + 24576 * X=(SENS*(PressureData-7168))/16384 - OFF * Press(mbar)= X/32+250 *****************************************************************************/ async event result_t IntersemaTemp.dataReady(uint16_t data) { float UT1,dT,Temp; float OFF,SENS,X,Press; //temperature UT1=8*(float)C5+20224; dT = (float)data-UT1; Temp = 200.0 + dT*((float)C6+50.0)/1024.0; //pressure OFF = (float)C2*4 + (((float)C4-512.0)*dT)/1024; SENS = (float)C1 + ((float)C3*dT)/1024 + 24576; atomic { X = (SENS*((float)PressureData-7168.0))/16384 - OFF; } Press = X/32.0 + 250.0; SODbg(DBG_USR2, "Pressure: Temp(adc): %i Press(adc): %i Temp(degCx10): %i Press(mbar): %i \n", data,PressureData,(int)Temp, (int)Press); // FIXME: PressureControl is wired to SplitControl in IntersemaPressureM, // and called asynchronously from here, which needs to be fixed. call PressureControl.stop(); return SUCCESS; } async event result_t IntersemaPressure.dataReady(uint16_t data) { atomic { PressureData = data; } return call IntersemaTemp.getData(); } event result_t IntersemaCal.dataReady(char word, uint16_t value) { // make sure we get all the calibration bytes count++; // SODbg(DBG_USR2, " cal word %i value %x \n",word,value); calibration[word-1] = value; if (count == 4) { SODbg(DBG_USR2, "Pressure cal words (1..4): %x,%x,%x,%x \n", calibration[0],calibration[1],calibration[2],calibration[3] ); atomic { C1 = calibration[0] >> 1; C2 = ((calibration[2] & 0x3f) << 6) | (calibration[3] & 0x3f); C3 = calibration[3] >> 6; C4 = calibration[2] >> 6; C5 = ((calibration[0] & 1) << 10) | (calibration[1] >> 6); C6 = calibration[1] & 0x3f; } // SODbg(DBG_USR2, "Pressure C1:%x C2:%x C3:%x C4:%x C5:%x C6:%x \n", // C1,C2,C3,C4,C5,C6 ); SODbg(DBG_USR2, "Pressure C1:%i C2:%i C3:%i C4:%i C5:%i C6:%i \n", C1,C2,C3,C4,C5,C6 ); call IntersemaPressure.getData(); } return SUCCESS; } event result_t PressureControl.initDone() { return SUCCESS; } event result_t PressureControl.stopDone() { state = PRESSURE_DONE; return SUCCESS; } event result_t PressureControl.startDone() { count = 0; call IntersemaCal.getData(); return SUCCESS; } } --- NEW FILE: Makefile --- COMPONENT=Intersema SENSORBOARD=intersema include ../Makelocal include $(TOSROOT)/apps/Makerules |
From: <do...@us...> - 2003-11-13 00:02:31
|
Update of /cvsroot/firebug/mts400/sensors/taos In directory sc8-pr-cvs1:/tmp/cvs-serv10216/taos Log Message: Directory /cvsroot/firebug/mts400/sensors/taos added to the repository |
From: <do...@us...> - 2003-11-13 00:02:00
|
Update of /cvsroot/firebug/mts400/sensors/intersema In directory sc8-pr-cvs1:/tmp/cvs-serv10152/intersema Log Message: Directory /cvsroot/firebug/mts400/sensors/intersema added to the repository |
From: <do...@us...> - 2003-11-13 00:01:52
|
Update of /cvsroot/firebug/mts400/sensors/adxl In directory sc8-pr-cvs1:/tmp/cvs-serv10136/adxl Log Message: Directory /cvsroot/firebug/mts400/sensors/adxl added to the repository |
From: <do...@us...> - 2003-11-12 23:52:46
|
Update of /cvsroot/firebug/mts400/sensors/i2c In directory sc8-pr-cvs1:/tmp/cvs-serv8789 Added Files: MicaWbSwitch.nc MicaWbSwitchM.nc SODebug.h Switch.nc sensorboard.h Log Message: Adding rest of i2c driver code. --- NEW FILE: MicaWbSwitch.nc --- /* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ /* * * Authors: Joe Polastre * * $Id: MicaWbSwitch.nc,v 1.1 2003/11/12 23:52:42 doolin Exp $ */ includes sensorboard; configuration MicaWbSwitch { provides { interface StdControl; interface Switch[uint8_t id]; } } implementation { components I2CPacketC,MicaWbSwitchM; StdControl = MicaWbSwitchM; Switch = MicaWbSwitchM; MicaWbSwitchM.I2CPacketControl -> I2CPacketC.StdControl; MicaWbSwitchM.I2CSwitch0 -> I2CPacketC.I2CPacket[TOSH_SWITCH0_ADDR]; MicaWbSwitchM.I2CSwitch1 -> I2CPacketC.I2CPacket[TOSH_SWITCH1_ADDR]; } --- NEW FILE: MicaWbSwitchM.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ /** * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ /* * * Authors: Joe Polastre * * $Id: MicaWbSwitchM.nc,v 1.1 2003/11/12 23:52:42 doolin Exp $ */ module MicaWbSwitchM { provides { interface StdControl; interface Switch[uint8_t id]; } uses { interface StdControl as I2CPacketControl; interface I2CPacket as I2CSwitch0; interface I2CPacket as I2CSwitch1; } } implementation { enum { GET_SWITCH, SET_SWITCH, SET_SWITCH_ALL, SET_SWITCH_GET, IDLE}; char sw_state; /* current state of the switch */ char state; /* current state of the i2c request */ char addr; /* destination address */ char position; char value; command result_t StdControl.init() { state = IDLE; return call I2CPacketControl.init(); } command result_t StdControl.start() { return call I2CPacketControl.start(); } command result_t StdControl.stop() { return call I2CPacketControl.stop(); } command result_t Switch.get[uint8_t id]() { if (state == IDLE) { state = GET_SWITCH; if (id == 0) return call I2CSwitch0.readPacket(1, 0x01); else if (id == 1) return call I2CSwitch1.readPacket(1, 0x01); } state = IDLE; return FAIL; } command result_t Switch.set[uint8_t id](char l_position, char l_value) { if (state == IDLE) { state = SET_SWITCH_GET; value = l_value; position = l_position; if (id == 0) return call I2CSwitch0.readPacket(1,0x01); else if (id == 1) return call I2CSwitch1.readPacket(1,0x01); } state = IDLE; return FAIL; } command result_t Switch.setAll[uint8_t id](char l_value) { if (state == IDLE) { state = SET_SWITCH_ALL; sw_state = l_value; if (id == 0) return call I2CSwitch0.writePacket(1, (char*)(&sw_state), 0x01); else if (id == 1) return call I2CSwitch1.writePacket(1, (char*)(&sw_state), 0x01); } state = IDLE; return FAIL; } event result_t I2CSwitch0.writePacketDone(bool result) { if (state == SET_SWITCH) { state = IDLE; signal Switch.setDone[0](result); } else if (state == SET_SWITCH_ALL) { state = IDLE; signal Switch.setAllDone[0](result); } return SUCCESS; } event result_t I2CSwitch1.writePacketDone(bool result) { if (state == SET_SWITCH) { state = IDLE; signal Switch.setDone[1](result); } else if (state == SET_SWITCH_ALL) { state = IDLE; signal Switch.setAllDone[1](result); } return SUCCESS; } event result_t I2CSwitch0.readPacketDone(char length, char* data) { if (state == GET_SWITCH) { if (length != 1) { state = IDLE; signal Switch.getDone[0](0); return SUCCESS; } else { state = IDLE; signal Switch.getDone[0](data[0]); return SUCCESS; } } if (state == SET_SWITCH_GET) { if (length != 1) { state = IDLE; signal Switch.getDone[0](0); return SUCCESS; } sw_state = data[0]; if (position == 1) { sw_state = sw_state & 0xFE; sw_state = sw_state | value; } if (position == 2) { sw_state = sw_state & 0xFD; sw_state = sw_state | (value << 1); } if (position == 3) { sw_state = sw_state & 0xFB; sw_state = sw_state | (value << 2); } if (position == 4) { sw_state = sw_state & 0xF7; sw_state = sw_state | (value << 3); } if (position == 5) { sw_state = sw_state & 0xEF; sw_state = sw_state | (value << 4); } if (position == 6) { sw_state = sw_state & 0xDF; sw_state = sw_state | (value << 5); } if (position == 7) { sw_state = sw_state & 0xBF; sw_state = sw_state | (value << 6); } if (position == 8) { sw_state = sw_state & 0x7F; sw_state = sw_state | (value << 7); } data[0] = sw_state; state = SET_SWITCH; call I2CSwitch0.writePacket(1, (char*)&sw_state, 0x01); return SUCCESS; } return SUCCESS; } event result_t I2CSwitch1.readPacketDone(char length, char* data) { if (state == GET_SWITCH) { if (length != 1) { state = IDLE; signal Switch.getDone[1](0); return SUCCESS; } else { state = IDLE; signal Switch.getDone[1](data[0]); return SUCCESS; } } if (state == SET_SWITCH_GET) { if (length != 1) { state = IDLE; signal Switch.getDone[1](0); return SUCCESS; } sw_state = data[0]; if (position == 1) { sw_state = sw_state & 0xFE; sw_state = sw_state | value; } if (position == 2) { sw_state = sw_state & 0xFD; sw_state = sw_state | (value << 1); } if (position == 3) { sw_state = sw_state & 0xFB; sw_state = sw_state | (value << 2); } if (position == 4) { sw_state = sw_state & 0xF7; sw_state = sw_state | (value << 3); } if (position == 5) { sw_state = sw_state & 0xEF; sw_state = sw_state | (value << 4); } if (position == 6) { sw_state = sw_state & 0xDF; sw_state = sw_state | (value << 5); } if (position == 7) { sw_state = sw_state & 0xBF; sw_state = sw_state | (value << 6); } if (position == 8) { sw_state = sw_state & 0x7F; sw_state = sw_state | (value << 7); } data[0] = sw_state; state = SET_SWITCH; call I2CSwitch1.writePacket(1, (char*)&sw_state, 0x01); return SUCCESS; } return SUCCESS; } default event result_t Switch.setDone[uint8_t id](bool result) { return SUCCESS; } default event result_t Switch.setAllDone[uint8_t id](bool result) { return SUCCESS; } default event result_t Switch.getDone[uint8_t id](char l_value) { return SUCCESS; } } --- NEW FILE: SODebug.h --- #include <stdarg.h> //#include <stdio.h> //#define SCRATCH 16 #define SCRATCH 64 #define BUF_LEN 256 char debugbuf[BUF_LEN]; //init comm port (56K baud, mica2 only, use 19K baud for mica2dot, mica....) for debug // call this from startup routine void init_debug(){ outp(0,UBRR0H); outp(15, UBRR0L); //set baud rate outp((1<<U2X),UCSR0A); // Set UART double speed outp(((1 << UCSZ1) | (1 << UCSZ0)) , UCSR0C); // Set frame format: 8 data-bits, 1 stop-bit inp(UDR0); outp((1 << TXEN) ,UCSR0B); // Enable uart reciever and transmitter } //init comm port (19K baud) for mica2dot for debug // call this from startup routine void init_debug_mica2dot(){ outp(0,UBRR0H); // Set baudrate to 19.2 KBps outp(12, UBRR0L); outp(0,UCSR0A); // Disable U2X and MPCM outp(((1 << UCSZ1) | (1 << UCSZ0)) , UCSR0C); inp(UDR0); outp((1 << TXEN) ,UCSR0B); } // output a char to the uart void UARTPutChar(char c) { if (c == '\n') UARTPutChar('\r'); loop_until_bit_is_set(UCSR0A, UDRE); outb(UDR0,c); } void writedebug() { int i = 0; UARTPutChar('\n'); //write a carriage return 1st while (debugbuf[i] != '\n') UARTPutChar(debugbuf[i++]); // UARTPutChar('\n'); } #define SPRINTF //use this sprintf function #ifdef SPRINTF int sprintf(uint8_t *buf, const uint8_t *format, ...) /* simplified sprintf */ { uint8_t scratch[SCRATCH]; uint8_t format_flag; uint16_t u_val=0, base; uint8_t *ptr; va_list ap; bool b_ChkForNegInt = FALSE; va_start (ap, format); for (;;){ while ((format_flag = *format++) != '%'){ /* Until '%' or '\0' */ if (!format_flag){va_end (ap); return (0);} *buf = format_flag; buf++; *buf=0; } b_ChkForNegInt = FALSE; switch (format_flag = *format++){ case 'c': format_flag = va_arg(ap,int); default: *buf = format_flag; buf++; *buf=0; continue; case 'S': case 's': ptr = va_arg(ap,char *); strcat(buf, ptr); continue; case 'o': base = 8; *buf = '0'; buf++; *buf=0; goto CONVERSION_LOOP; case 'i': b_ChkForNegInt = TRUE; // if (((int)u_val) < 0){ // u_val = - u_val; // *buf = '-'; buf++; *buf=0; // } /* no break -> run into next case */ case 'u': base = 10; goto CONVERSION_LOOP; case 'x': base = 16; CONVERSION_LOOP: u_val = va_arg(ap,int); if (b_ChkForNegInt){ if (((int)u_val) < 0){ u_val = - u_val; *buf = '-'; buf++; *buf=0; } } ptr = scratch + SCRATCH; *--ptr = 0; do { char ch = u_val % base + '0'; if (ch > '9') ch += 'a' - '9' - 1; *--ptr = ch; u_val /= base; } while (u_val); strcat(buf, ptr); buf += strlen(ptr); } } } #endif #define SO_NO_DEBUG 0 #define SO_DEBUG //turn on debug output #ifdef SO_DEBUG #define SODbg(__x,__args...) { \ char bStatus; \ if(__x != SO_NO_DEBUG){ \ bStatus=bit_is_set(SREG,7); \ cli(); \ sprintf(debugbuf,__args); \ writedebug(); \ if (bStatus) sei(); \ } \ } #else #define SODbg(__x,__args...) #endif --- NEW FILE: Switch.nc --- /* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ /* * * Authors: Joe Polastre * * $Id: Switch.nc,v 1.1 2003/11/12 23:52:42 doolin Exp $ */ interface Switch { command result_t get(); command result_t set(char position, char value); command result_t setAll(char value); event result_t getDone(char value); event result_t setDone(bool result); event result_t setAllDone(bool result); } --- NEW FILE: sensorboard.h --- /* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice, the following * two paragraphs and the author appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * */ /* tab:4 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By * downloading, copying, installing or using the software you agree to * this license. If you do not agree to this license, do not download, * install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ /* * * Authors: Joe Polastre * * $Id: sensorboard.h,v 1.1 2003/11/12 23:52:42 doolin Exp $ */ #define UART1_DISABLE() outp(0 ,UCSR1B); //disable uart1 #define PRESSURE_SET_CLOCK() TOSH_SET_FLASH_CLK_PIN() #define PRESSURE_CLEAR_CLOCK() TOSH_CLR_FLASH_CLK_PIN() #define PRESSURE_MAKE_CLOCK_OUTPUT() asm volatile ("nop" ::) #define PRESSURE_MAKE_IN_INPUT() TOSH_MAKE_FLASH_IN_INPUT() #define PRESSURE_READ_IN_PIN() TOSH_READ_FLASH_IN_PIN() #define PRESSURE_SET_IN_PIN() TOSH_SET_FLASH_IN_PIN() #define PRESSURE_CLEAR_IN_PIN() TOSH_CLR_FLASH_IN_PIN() #define PRESSURE_MAKE_OUT_OUTPUT() TOSH_MAKE_FLASH_OUT_OUTPUT() #define PRESSURE_SET_OUT_PIN() TOSH_SET_FLASH_OUT_PIN() #define PRESSURE_CLEAR_OUT_PIN() TOSH_CLR_FLASH_OUT_PIN() #define HUMIDITY_INT_DISABLE() cbi(EIMSK , 7) //disable int 7 // #define HUMIDITY_INTERRUPT SIG_INTERRUPT3 #define HUMIDITY_INTERRUPT SIG_INTERRUPT7 //Atmega128 INT7 #define HUMIDITY_MAKE_CLOCK_OUTPUT() asm volatile ("nop" ::) #define HUMIDITY_MAKE_CLOCK_INPUT() { } #define HUMIDITY_SET_CLOCK() TOSH_SET_PW3_PIN() // sbi(PORTC, 3) #define HUMIDITY_CLEAR_CLOCK() TOSH_CLR_PW3_PIN() // cbi(PORTC, 3) #define HUMIDITY_SET_DATA() TOSH_SET_INT3_PIN() // sbi(PORTD, 3) #define HUMIDITY_CLEAR_DATA() TOSH_CLR_INT3_PIN() // cbi(PORTD, 3) #define HUMIDITY_MAKE_DATA_OUTPUT() TOSH_MAKE_INT3_OUTPUT() // sbi(DDRD, 3) #define HUMIDITY_MAKE_DATA_INPUT() TOSH_MAKE_INT3_INPUT() //cbi(DDRD, 3) #define HUMIDITY_GET_DATA() TOSH_READ_INT3_PIN() // (inp(PIND) >> 3) & 0x1 #define HUMIDITY_TIMEOUT_MS 40 #define HUMIDITY_TIMEOUT_TRIES 5 //#define HUMIDITY_TIMEOUT_TRIES 50 #define PRESSURE_TIMEOUT_TRIES 5 // adc channels for accel x,y outputs #define ADC_ACCEL_X_PORT 1 #define ADC_ACCEL_Y_PORT 2 #define TOS_ADC_ACCEL_X_PORT 2 #define TOS_ADC_ACCEL_Y_PORT 3 const char crctable[256] = { 0, 49, 98, 83, 196, 245, 166, 151, 185, 136, 219, 234, 125, 76, 31, 46, 67, 114, 33, 16, 135, 182, 229, 212, 250, 203, 152, 169, 62, 15, 92, 109, 134, 183, 228, 213, 66, 115, 32, 17, 63, 14, 93, 108,251, 202,153, 168,197, 244,167, 150,1, 48, 99, 82, 124, 77, 30, 47, 184, 137,218, 235,61, 12, 95, 110,249, 200,155, 170,132, 181,230, 215, 64, 113,34, 19, 126, 79, 28, 45, 186, 139,216, 233,199, 246,165, 148,3, 50, 97, 80, 187, 138,217, 232, 127, 78, 29, 44, 2, 51, 96, 81, 198, 247,164, 149,248, 201,154, 171,60, 13, 94, 111, 65, 112,35, 18, 133, 180,231, 214,122, 75, 24, 41, 190, 143,220, 237, 195, 242,161, 144, 7, 54, 101, 84, 57, 8, 91, 106,253, 204,159, 174,128, 177,226, 211,68, 117,38, 23, 252, 205,158, 175,56, 9, 90, 107,69, 116,39, 22, 129, 176,227, 210,191, 142,221, 236, 123, 74, 25, 40, 6, 55, 100, 85, 194, 243,160, 145,71, 118,37, 20, 131, 178,225, 208, 254, 207,156, 173,58, 11, 88, 105,4, 53, 102, 87, 192, 241,162, 147,189, 140,223, 238, 121, 72, 27, 42, 193, 240,163, 146,5, 52, 103, 86, 120, 73, 26, 43, 188, 141,222, 239, 130, 179,224, 209,70, 119,36, 21, 59, 10, 89, 104,255, 206,157, 172}; enum { // Main Switch addresses MICAWB_LIGHT_POWER = 1, MICAWB_PRESSURE_POWER = 3, MICAWB_HUMIDITY_POWER = 4, MICAWB_EEPROM_POWER = 5, MICAWB_ACCEL_POWER = 6, MICAWB_GPS_POWER = 7, MICAWB_GPS_ENABLE = 8, // I/O Switch addresses MICAWB_GPS_RX_SELECT = 1, //enable GPS serial Rx line MICAWB_GPS_TX_SELECT = 2, //enable GPS serial Tx line MICAWB_PRESSURE_SCLK = 3, //enable Intersema SCLK MICAWB_PRESSURE_DIN = 4, //enable Intersema Data In MICAWB_PRESSURE_DOUT = 5, //enable Intersema Data Out MICAWB_HUMIDITY_SCLK = 7, //enable Sensirion SCLK MICAWB_HUMIDITY_DATA = 8, //enable Sensirion Data I/O // for the ADC[] parameterized interface in IntersemaPressure.ADC[] MICAWB_PRESSURE = 0, MICAWB_PRESSURE_TEMP = 1, MICAWB_HUMIDITY = 0, MICAWB_HUMIDITY_TEMP = 1, // I2C Switch Addresses TOSH_SWITCH0_ADDR = 72, TOSH_SWITCH1_ADDR = 73, // I2C Taos Photo Sensor Switch Address TOSH_PHOTO_ADDR = 57, MELEXIS_WP_EN = 0x0065, // Sensirion Humidity addresses and commands TOSH_HUMIDITY_ADDR = 5, TOSH_HUMIDTEMP_ADDR = 3, TOSH_HUMIDITY_RESET = 0x1E }; |