From 78533a51ab5421601b046a917dd0f6f01a402a49 Mon Sep 17 00:00:00 2001 From: rmspeers Date: Tue, 4 Jun 2013 11:07:52 +0000 Subject: [PATCH] Added initial support for board=apimote2 git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1594 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- client/goodfet.ccspi | 12 +++++- firmware/config.mk | 8 ++++ firmware/include/spi.h | 1 + firmware/platforms/apimote2.h | 72 +++++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100755 firmware/platforms/apimote2.h diff --git a/client/goodfet.ccspi b/client/goodfet.ccspi index 59eee33..b20dc64 100755 --- a/client/goodfet.ccspi +++ b/client/goodfet.ccspi @@ -13,6 +13,9 @@ import array, time; from GoodFETCCSPI import GoodFETCCSPI; +#PORTNAME=None +PORTNAME="/dev/ttyUSB0" +print "ON:", PORTNAME #Some quick functions for yanking values out of a packet. def srcadr(packet): @@ -65,7 +68,7 @@ if(len(sys.argv)==1): #Initialize FET and set baud rate client=GoodFETCCSPI(); -client.serInit() +client.serInit(port=PORTNAME) client.setup(); @@ -74,7 +77,12 @@ client.setup(); if(sys.argv[1]=="carrier"): if len(sys.argv)>2: - client.RF_setfreq(eval(sys.argv[2])); + freq=eval(sys.argv[2]); + if freq>100: + client.RF_setfreq(freq); + else: + client.RF_setchan(freq); + print "Channel set to:", freq while 1: client.RF_carrier(); while(1): diff --git a/firmware/config.mk b/firmware/config.mk index 313e2a6..827f7e1 100644 --- a/firmware/config.mk +++ b/firmware/config.mk @@ -13,6 +13,14 @@ MSP430BSL?=goodfet.bsl --speed=38400 --swap-reset-test CFLAGS += -Duseuart1 -Dapimote endif +ifneq (,$(findstring $(board),apimote2)) +mcu ?= msp430f2618 +platform := apimote2 +config := monitor spi ccspi +MSP430BSL?=goodfet.bsl --speed=38400 +CFLAGS += -Duseuart1 -Dapimote +endif + ifneq (,$(findstring $(board),goodthopter01 goodthopter10 goodthopter11)) mcu ?= msp430f2274 platform := goodfet diff --git a/firmware/include/spi.h b/firmware/include/spi.h index d940605..b4de686 100644 --- a/firmware/include/spi.h +++ b/firmware/include/spi.h @@ -25,6 +25,7 @@ # define TST BIT0 # define RST BIT6 #endif +//Apimotev2 SET/CLRRST needs to be on pin 21, so 2.1 -- just redefine RST to BIT0 #define SETMOSI SPIOUT|=MOSI #define CLRMOSI SPIOUT&=~MOSI diff --git a/firmware/platforms/apimote2.h b/firmware/platforms/apimote2.h new file mode 100755 index 0000000..0c710d0 --- /dev/null +++ b/firmware/platforms/apimote2.h @@ -0,0 +1,72 @@ +/*! \file apimote2.h + \author Ryan Speers + \brief Port descriptions for the Apimote v2 platform. +*/ + +#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 + +//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. +*/ + +#define INITPLATFORM \ + P2DIR |= BIT0+BIT7; \ + P2OUT &= ~BIT7; \ + P2OUT |= BIT0; \ + P3DIR |= BIT0; + +//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 + -- 2.20.1