From: rmspeers Date: Tue, 24 Jul 2012 02:33:56 +0000 (+0000) Subject: Moved board definition from apimote to apimote1 for versioning support. X-Git-Url: http://git.rot13.org/?p=goodfet;a=commitdiff_plain;h=dd49731422f391ad8cfbc1910b9b5285f36f43bc Moved board definition from apimote to apimote1 for versioning support. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1204 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- diff --git a/client/GoodFET.py b/client/GoodFET.py index e0d575d..6fd0f29 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -205,7 +205,7 @@ class GoodFET: self.telosBReset(); elif (os.environ.get("board")=='zolertiaz1' or os.environ.get("board")=='z1'): self.bslResetZ1(); - elif (os.environ.get("board")=='apimote'): + elif (os.environ.get("board")=='apimote1'): #Explicitly set RTS and DTR to halt board. self.serialport.setRTS(1); self.serialport.setDTR(1); @@ -670,6 +670,14 @@ class GoodFET: print "Clocked at %s" % self.monitorclocking(); return 1; + def testleds(self): + print "Flashing LEDs" + self.writecmd(self.MONITORAPP,0xD0,0,""); + try: + print "Flashed %d LED." % ord(self.data) + except: + print "Unable to process response:", self.data + def monitor_list_apps(self, full=False): self.monitor_info() old_value = self.besilent diff --git a/client/goodfet.monitor b/client/goodfet.monitor index 67ec3fb..b530a4b 100755 --- a/client/goodfet.monitor +++ b/client/goodfet.monitor @@ -19,6 +19,7 @@ if(len(sys.argv)==1): print "%s call 0x$start" % sys.argv[0]; print "%s exec '0x35 0x00 0x..'" % sys.argv[0]; print "%s listapps [full]" % sys.argv[0] + print "%s testleds" % sys.argv[0] sys.exit(); #Initialize FET and set baud rate @@ -125,4 +126,5 @@ if(sys.argv[1]=="verify"): if(i%0x100==0): print "%04x" % i; - +if(sys.argv[1]=="testleds"): + client.testleds(); diff --git a/firmware/config.mk b/firmware/config.mk index 76c118f..a59ab27 100644 --- a/firmware/config.mk +++ b/firmware/config.mk @@ -5,9 +5,9 @@ #Unset by default, but can be explicitly set later. config=undef -ifneq (,$(findstring $(board),apimote)) +ifneq (,$(findstring $(board),apimote1)) mcu ?= msp430f2618 -platform := apimote +platform := apimote1 config := monitor spi ccspi MSP430BSL?=goodfet.bsl --speed=38400 --swap-reset-test CFLAGS += -Duseuart1 diff --git a/firmware/include/monitor.h b/firmware/include/monitor.h index d38dae9..019ae59 100644 --- a/firmware/include/monitor.h +++ b/firmware/include/monitor.h @@ -29,6 +29,8 @@ #define MONITOR_WRITEBUF 0xC1 #define MONITOR_SIZEBUF 0xC2 +#define MONITOR_LEDTEST 0xD0 + extern app_t const monitor_app; #endif // MONITOR_H diff --git a/firmware/include/platform.h b/firmware/include/platform.h index dfc4681..2614ecc 100644 --- a/firmware/include/platform.h +++ b/firmware/include/platform.h @@ -33,7 +33,7 @@ void led_toggle(); #include "config.h" #ifdef useuart1 -//TelosB uses second serial port. +//TelosB and the ApiMote use the second serial port. #define serial_tx serial1_tx #define serial_rx serial1_rx #define setbaud setbaud1 diff --git a/firmware/lib/msp430.c b/firmware/lib/msp430.c index 19bca37..0f30e33 100644 --- a/firmware/lib/msp430.c +++ b/firmware/lib/msp430.c @@ -16,8 +16,15 @@ void led_init() { PLEDDIR |= PLEDPIN; + #ifdef PLED2OUT + PLED2DIR |= PLED2PIN; + #endif + #ifdef PLED3OUT + PLED3DIR |= PLED3PIN; + #endif } +//TODO define differently if needed for telos/apimote void led_on() { PLEDOUT |= PLEDPIN; @@ -31,6 +38,24 @@ void led_toggle() PLEDOUT ^= PLEDPIN; } +//LED2 and LED3 are only used by the telosb and apimote for now +void led2_on() +{ + PLED2OUT &= ~PLED2PIN; +} +void led2_off() +{ + PLED2OUT |= PLED2PIN; +} +void led3_on() +{ + PLED3OUT &= ~PLED3PIN; +} +void led3_off() +{ + PLED3OUT |= PLED3PIN; +} + //! Initialize MSP430 registers and all that jazz. void msp430_init(){ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer @@ -39,7 +64,6 @@ void msp430_init(){ led_init(); led_off(); - /* P5.0 out and low; this is chosen for the PIC app (in which P5.0 is !MCLR) to ensure that an attached PIC chip, if present, is immediately driven to reset state. A brief explanation of why this diff --git a/firmware/platforms/README.txt b/firmware/platforms/README.txt index 8d075a1..da63e90 100644 --- a/firmware/platforms/README.txt +++ b/firmware/platforms/README.txt @@ -1,7 +1,7 @@ goodfet.h GoodFET hardware and neighborly clones. telosb.h MSP430F1612-based Telos B and its clones. z1.h Zolertia Z1, an MSP430F2617 mote. - +apimote.h Api-Mote (802.15.4/ZigBee enabled GoodFET) (board rev 1) TODO: TRF7960 Dev Board diff --git a/firmware/platforms/apimote.h b/firmware/platforms/apimote.h deleted file mode 100644 index 082947a..0000000 --- a/firmware/platforms/apimote.h +++ /dev/null @@ -1,94 +0,0 @@ -/*! \file apimote.h - \author Ryan Speers - \brief Port descriptions for the GoodFET platform. -*/ - -/* #ifdef __MSPGCC__ */ -/* #include */ -/* #else */ -/* #include */ -/* #include */ -/* #include */ -/* #endif */ - -#ifndef _GNU_ASSEMBLER_ -#include -#endif - -//LED on P5.5 (pin 49) (LED1 red) -#define PLEDOUT P5OUT -#define PLEDDIR P5DIR -#define PLEDPIN BIT5 -//LED on P5.6 (pin 50) (LED2 green) -#define PLED2OUT P5OUT -#define PLED2DIR P5DIR -#define PLED2PIN BIT6 -//LED on P5.7 (pin 51) (LED3 blue) -#define PLED3OUT P5OUT -#define PLED3DIR P5DIR -#define PLED3PIN BIT7 - -//mtx frx p34 -//mrx ftx p35 - -//SPI -//TelosB: 29/3.1=RF_SI, 30/3.2=RF_SO, 31/3.3=RF_SCLK -//ApiMote: 29/3.1=RF_SI, 30/3.2=RF_SO, 31/3.3=RF_SCLK -#define SPIOUT P3OUT -#define SPIDIR P3DIR -#define SPIIN P3IN -#define SPIREN P3REN - -/* For the radio to be used: - 2.7 (!RST) must be low - 2.0 (VREF_EN) must be high (cc2420-41 rf_vreg) - 3.0 (!CS) must be low for the transaction. -*/ - - -/* TODO what to do here?. Hopefully nothing. -#define INITPLATFORM \ - P1DIR = 0xe0;\ - P1OUT = 0x00;\ - P2DIR = 0x7b;\ - P2OUT = 0x10;\ - P3DIR = 0xf1;\ - P3OUT = 0x00;\ - P4DIR = 0xfd;\ - P4OUT = 0xFd;\ - P5DIR = 0xff;\ - P5OUT = 0xff;\ - P6DIR = 0xff;\ - P6OUT = 0x00; -*/ - -//RF Control -//TelosB: Radio CS is 38/P4.2 (to CC2420 pin31) -//ApiMote: Radio CS is 28/P3.0 -#define SETSS P3OUT|=BIT0 -#define CLRSS P3OUT&=~BIT0 -#define DIRSS P3DIR|=BIT0 - -//CC2420 Chip Enable -//TelosB: Radio RESETn is 42/P4.6 (to CC2420 pin21) -//ApiMote: Radio RESETn is 27/P2.7 (to CC2420 pin21) -#define SETCE P2OUT|=BIT7 -#define CLRCE P2OUT&=~BIT7 -#define DIRCE P2DIR|=BIT7 - -//CC2420 signals -#define SFD (P2IN&BIT6) //TelosB 37/P4.1 -> ApiMote 26/P2.6 -#define FIFOP (P2IN&BIT4) //TelosB 12/P1.0 -> ApiMote 24/P2.4 (rf_pkt cc2420-29) -#define FIFO (P2IN&BIT3) //TelosB 15/P1.3 -> ApiMote 23/P2.3 (rf_gio0 cc2420-30) - -// network byte order converters -#define htons(x) ((((uint16_t)(x) & 0xFF00) >> 8) | \ - (((uint16_t)(x) & 0x00FF) << 8)) -#define htonl(x) ((((uint32_t)(x) & 0xFF000000) >> 24) | \ - (((uint32_t)(x) & 0x00FF0000) >> 8) | \ - (((uint32_t)(x) & 0x0000FF00) << 8) | \ - (((uint32_t)(x) & 0x000000FF) << 24)) - -#define ntohs htons -#define ntohl htonl - diff --git a/firmware/platforms/apimote1.h b/firmware/platforms/apimote1.h new file mode 100755 index 0000000..082947a --- /dev/null +++ b/firmware/platforms/apimote1.h @@ -0,0 +1,94 @@ +/*! \file apimote.h + \author Ryan Speers + \brief Port descriptions for the GoodFET platform. +*/ + +/* #ifdef __MSPGCC__ */ +/* #include */ +/* #else */ +/* #include */ +/* #include */ +/* #include */ +/* #endif */ + +#ifndef _GNU_ASSEMBLER_ +#include +#endif + +//LED on P5.5 (pin 49) (LED1 red) +#define PLEDOUT P5OUT +#define PLEDDIR P5DIR +#define PLEDPIN BIT5 +//LED on P5.6 (pin 50) (LED2 green) +#define PLED2OUT P5OUT +#define PLED2DIR P5DIR +#define PLED2PIN BIT6 +//LED on P5.7 (pin 51) (LED3 blue) +#define PLED3OUT P5OUT +#define PLED3DIR P5DIR +#define PLED3PIN BIT7 + +//mtx frx p34 +//mrx ftx p35 + +//SPI +//TelosB: 29/3.1=RF_SI, 30/3.2=RF_SO, 31/3.3=RF_SCLK +//ApiMote: 29/3.1=RF_SI, 30/3.2=RF_SO, 31/3.3=RF_SCLK +#define SPIOUT P3OUT +#define SPIDIR P3DIR +#define SPIIN P3IN +#define SPIREN P3REN + +/* For the radio to be used: + 2.7 (!RST) must be low + 2.0 (VREF_EN) must be high (cc2420-41 rf_vreg) + 3.0 (!CS) must be low for the transaction. +*/ + + +/* TODO what to do here?. Hopefully nothing. +#define INITPLATFORM \ + P1DIR = 0xe0;\ + P1OUT = 0x00;\ + P2DIR = 0x7b;\ + P2OUT = 0x10;\ + P3DIR = 0xf1;\ + P3OUT = 0x00;\ + P4DIR = 0xfd;\ + P4OUT = 0xFd;\ + P5DIR = 0xff;\ + P5OUT = 0xff;\ + P6DIR = 0xff;\ + P6OUT = 0x00; +*/ + +//RF Control +//TelosB: Radio CS is 38/P4.2 (to CC2420 pin31) +//ApiMote: Radio CS is 28/P3.0 +#define SETSS P3OUT|=BIT0 +#define CLRSS P3OUT&=~BIT0 +#define DIRSS P3DIR|=BIT0 + +//CC2420 Chip Enable +//TelosB: Radio RESETn is 42/P4.6 (to CC2420 pin21) +//ApiMote: Radio RESETn is 27/P2.7 (to CC2420 pin21) +#define SETCE P2OUT|=BIT7 +#define CLRCE P2OUT&=~BIT7 +#define DIRCE P2DIR|=BIT7 + +//CC2420 signals +#define SFD (P2IN&BIT6) //TelosB 37/P4.1 -> ApiMote 26/P2.6 +#define FIFOP (P2IN&BIT4) //TelosB 12/P1.0 -> ApiMote 24/P2.4 (rf_pkt cc2420-29) +#define FIFO (P2IN&BIT3) //TelosB 15/P1.3 -> ApiMote 23/P2.3 (rf_gio0 cc2420-30) + +// network byte order converters +#define htons(x) ((((uint16_t)(x) & 0xFF00) >> 8) | \ + (((uint16_t)(x) & 0x00FF) << 8)) +#define htonl(x) ((((uint32_t)(x) & 0xFF000000) >> 24) | \ + (((uint32_t)(x) & 0x00FF0000) >> 8) | \ + (((uint32_t)(x) & 0x0000FF00) << 8) | \ + (((uint32_t)(x) & 0x000000FF) << 24)) + +#define ntohs htons +#define ntohl htonl + diff --git a/firmware/platforms/telosb.h b/firmware/platforms/telosb.h index 8fb2857..56595ab 100644 --- a/firmware/platforms/telosb.h +++ b/firmware/platforms/telosb.h @@ -31,6 +31,26 @@ #define SPIIN P3IN #define SPIREN P3REN +/* INITPLATFORM PX.7 PX.6 PX.5 PX.4 PX.3 PX.2 PX.1 PX.0 + HUM HUM HUM RGIO1 RGIO0 PDVCC UART1TX PKT_INT + P1DIR = 0xe0 11100000 Out Out Out In In In In In + P1OUT = 0x00 Out?? + UsrInt GIO3 NC 1Wire GIO2 UART1RX GIO1 GIO0 + P2DIR = 0x7b 01111011 In Out Out Out Out In Out Out + P2OUT = 0x10 00010000 Hi + U1RX U1TX U0RX U0TX RSCLK R_SO R_SI NC + P3DIR = 0xf1 11110001 Out Out Out Out In In In Out + P3OUT = 0x00 + FHold RRST RVREFEN F_CS NC R_CS R_SFD NC + P4DIR = 0xfd 11111101 Out Out Out Out Out Out In Out + P4OUT = 0xfd 11111101 Hi Hi Hi Hi Hi Hi Lo Hi + SVSoutLED3 LED2 LED1 NC NC NC NC + P5DIR = 0xff 11111111 Out Out Out Out Out Out Out Out + P5OUT = 0xff 11111111 Hi Hi Hi Hi Hi Hi Hi Hi + SVSin DAC0 ADC5 ADC4 ADC3 ADC2 ADC1 ADC0 + P6DIR = 0xff 11111111 Out Out Out Out Out Out Out Out + P6OUT = 0x00 +*/ /* For the radio to be used: 4.6 (!RST) must be low