[Firebug-cvs] mts400/apps/TestGPS .cvsignore,NONE,1.1 Makefile,NONE,1.1 gps_new.nc,NONE,1.1 gps_newM
Brought to you by:
doolin
From: <do...@us...> - 2003-11-11 01:58:39
|
Update of /cvsroot/firebug/mts400/apps/TestGPS In directory sc8-pr-cvs1:/tmp/cvs-serv8617/TestGPS Added Files: .cvsignore Makefile gps_new.nc gps_newM.nc Log Message: Added gps test application. --- NEW FILE: .cvsignore --- build *~ --- NEW FILE: Makefile --- COMPONENT=gps_new SENSORBOARD=gps include ../Makelocal include $(TOSROOT)/apps/Makerules --- NEW FILE: gps_new.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ includes sensorboard; configuration gps_new { #if 0 provides { interface SplitControl; } #endif } implementation { components Main, gps_newM, MicaWbSwitch, UARTGpsPacket, TimerC, // NoLeds, LedsC; Main.StdControl -> gps_newM.StdControl; Main.StdControl -> TimerC.StdControl; Main.StdControl -> MicaWbSwitch.StdControl; //Easy stuff gps_newM.Leds -> LedsC; gps_newM.Timer -> TimerC.Timer[unique("Timer")]; /** New stuff for using gps without sensirion. */ //gps_newM.SwitchControl -> MicaWbSwitch.StdControl; gps_newM.PowerSwitch -> MicaWbSwitch.Switch[0]; gps_newM.IOSwitch -> MicaWbSwitch.Switch[1]; gps_newM.GpsControl -> UARTGpsPacket; gps_newM.GpsSend -> UARTGpsPacket; gps_newM.GpsReceive -> UARTGpsPacket; gps_newM.GpsCmd -> UARTGpsPacket.GpsCmd; } --- NEW FILE: gps_newM.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ module gps_newM { provides { interface StdControl; } uses { interface Timer; interface Leds; // new stuff for using gps without sensirion //interface StdControl as SwitchControl; interface Switch as PowerSwitch; interface Switch as IOSwitch; interface StdControl as GpsControl; //interface SplitControl as GpsControl; interface I2CSwitchCmds as GpsCmd; interface BareSendMsg as GpsSend; interface ReceiveMsg as GpsReceive; } } implementation { #include "SODebug.h" #include "gps.h" 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}; /**** StdControl **/ command result_t StdControl.init() { init_debug(); call Leds.init(); /* Control.init in GpsPacket.nc */ call GpsControl.init(); return SUCCESS; } command result_t StdControl.start() { /* 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"); } call Timer.start(TIMER_REPEAT, 1000) ; return SUCCESS; } command result_t StdControl.stop() { return call Timer.stop(); //return SUCCESS; } /****************************************************/ /** Timer */ event result_t Timer.fired() { call Leds.greenToggle(); return SUCCESS; } /****************************************************/ /** PowerSwitch */ event result_t PowerSwitch.getDone(char value) { return SUCCESS; } event result_t PowerSwitch.setDone(bool local_result) { switch(state) { case MAIN_SWITCH_ON: state = IDLE; //signal GpsControl.startDone(); break; case MAIN_SWITCH_OFF: state = POWEROFF; //signal GpsControl.stopDone(); break; case WAIT_SWITCH_ON: if (call PowerSwitch.set(MICAWB_GPS_POWER,1) == SUCCESS) { state = MAIN_SWITCH_ON; } break; case WAIT_SWITCH_OFF: 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; } /****************************************************/ /** IOSwitch */ //#if 0 event result_t IOSwitch.getDone(char value) { return SUCCESS; } event result_t IOSwitch.setAllDone(bool local_result) { return SUCCESS; } event result_t IOSwitch.setDone(bool local_result) { SODbg(DBG_USR2, "SensirionHumidityM.SwitchI2W: 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, "SensirionHumidityM.SwitchI2W: Timer Started \n"); 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; } //#endif /** * Packet received from GPS - ASCII msg * 1st byte in pkt is number of ascii bytes * async used only for testing */ 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(gps_data->data[i]); } SODbg(DBG_USR2, "\n"); return data; } event result_t GpsSend.sendDone(TOS_MsgPtr msg, result_t success) { return SUCCESS; } event result_t GpsCmd.SwitchesSet(uint8_t PowerState) { SODbg(DBG_USR2, "Gps power on \n"); call Leds.yellowOn(); call Leds.redOff(); return SUCCESS; } } |