Change the way we switch between cc2530 models
The switch is now performed through a configuration define, which has also been renamed to better match Contiki's naming conventions
This commit is contained in:
parent
1b0470687b
commit
f30d92b101
12 changed files with 29 additions and 19 deletions
|
@ -1,6 +1,3 @@
|
|||
# To build for the cc2531 USB stick:
|
||||
DEFINES+=MODEL_CC2531=1,
|
||||
|
||||
DEFINES+=PROJECT_CONF_H=\"project-conf.h\"
|
||||
|
||||
# We need uIPv6, therefore we also need banking
|
||||
|
|
|
@ -53,4 +53,7 @@
|
|||
|
||||
#define UIP_FALLBACK_INTERFACE slip_interface
|
||||
|
||||
/* Change to 0 to build for the SmartRF + cc2530 EM */
|
||||
#define MODELS_CONF_CC2531_USB_STICK 1
|
||||
|
||||
#endif /* PROJECT_CONF_H_ */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
CONTIKI_PROJECT = cc2531-usb-demo
|
||||
|
||||
DEFINES+=MODEL_CC2531=1
|
||||
DEFINES+=MODELS_CONF_CC2531_USB_STICK=1
|
||||
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
DEFINES+=PROJECT_CONF_H
|
||||
DEFINES+=MODEL_CC2531=1
|
||||
PROJECT_SOURCEFILES += stub-rdc.c
|
||||
|
||||
CONTIKI_PROJECT = sniffer
|
||||
|
|
|
@ -47,6 +47,9 @@
|
|||
#define LPM_CONF_MODE 0
|
||||
#define UART0_CONF_HIGH_SPEED 1
|
||||
|
||||
/* Change to 0 to build for the SmartRF + cc2530 EM */
|
||||
#define MODELS_CONF_CC2531_USB_STICK 1
|
||||
|
||||
/* Used by cc2531 USB dongle builds, has no effect on SmartRF builds */
|
||||
#define USB_SERIAL_CONF_BUFFERED 1
|
||||
|
||||
|
|
|
@ -10,6 +10,14 @@
|
|||
#include "project-conf.h"
|
||||
#endif /* PROJECT_CONF_H */
|
||||
|
||||
/*
|
||||
* Build for SmartRF05EB+CC2530EM by default.
|
||||
* This define needs to have its final value before inclusion of models.h
|
||||
*/
|
||||
#ifndef MODELS_CONF_CC2531_USB_STICK
|
||||
#define MODELS_CONF_CC2531_USB_STICK 0
|
||||
#endif
|
||||
|
||||
#include "models.h"
|
||||
|
||||
/*
|
||||
|
|
|
@ -63,7 +63,7 @@ configure_b1(int type, int value)
|
|||
{
|
||||
switch(type) {
|
||||
case SENSORS_HW_INIT:
|
||||
#if !MODEL_CC2531
|
||||
#if !MODELS_CONF_CC2531_USB_STICK
|
||||
P0INP |= 2; /* Tri-state */
|
||||
#endif
|
||||
BUTTON_IRQ_ON_PRESS(1);
|
||||
|
@ -87,7 +87,7 @@ configure_b1(int type, int value)
|
|||
/*---------------------------------------------------------------------------*/
|
||||
/* Button 2 - cc2531 USb Dongle only */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if MODEL_CC2531
|
||||
#if MODELS_CONF_CC2531_USB_STICK
|
||||
static int
|
||||
value_b2(int type)
|
||||
{
|
||||
|
@ -138,7 +138,7 @@ configure_b2(int type, int value)
|
|||
#if CC_CONF_OPTIMIZE_STACK_SIZE
|
||||
#pragma exclude bits
|
||||
#endif
|
||||
#if MODEL_CC2531
|
||||
#if MODELS_CONF_CC2531_USB_STICK
|
||||
void
|
||||
port_1_isr(void) __interrupt(P1INT_VECTOR)
|
||||
{
|
||||
|
@ -195,6 +195,6 @@ port_0_isr(void) __interrupt(P0INT_VECTOR)
|
|||
#pragma restore
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(button_1_sensor, BUTTON_SENSOR, value_b1, configure_b1, status_b1);
|
||||
#if MODEL_CC2531
|
||||
#if MODELS_CONF_CC2531_USB_STICK
|
||||
SENSORS_SENSOR(button_2_sensor, BUTTON_SENSOR, value_b2, configure_b2, status_b2);
|
||||
#endif
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
* B2: P1_3
|
||||
*
|
||||
*/
|
||||
#if MODEL_CC2531
|
||||
#if MODELS_CONF_CC2531_USB_STICK
|
||||
#define BUTTON1_PORT 1
|
||||
#define BUTTON1_PIN 2
|
||||
#define BUTTON2_PORT 1
|
||||
|
@ -73,7 +73,7 @@ extern const struct sensors_sensor button_1_sensor;
|
|||
extern const struct sensors_sensor button_2_sensor;
|
||||
|
||||
#if BUTTON_SENSOR_ON
|
||||
#if MODEL_CC2531
|
||||
#if MODELS_CONF_CC2531_USB_STICK
|
||||
/* USB Dongle */
|
||||
/* Buttons: P1_2 & P1_3 - Port 1 ISR needed */
|
||||
void port_1_isr(void) __interrupt(P1INT_VECTOR);
|
||||
|
@ -82,12 +82,12 @@ void port_1_isr(void) __interrupt(P1INT_VECTOR);
|
|||
button_2_sensor.configure(SENSORS_ACTIVE, 1); \
|
||||
} while(0)
|
||||
|
||||
#else /* MODEL_CC2531 */
|
||||
#else /* MODELS_CONF_CC2531_USB_STICK */
|
||||
/* SmartRF */
|
||||
/* Button 1: P0_1 - Port 0 ISR needed */
|
||||
void port_0_isr(void) __interrupt(P0INT_VECTOR);
|
||||
#define BUTTON_SENSOR_ACTIVATE() button_sensor.configure(SENSORS_ACTIVE, 1)
|
||||
#endif /* MODEL_CC2531 */
|
||||
#endif /* MODELS_CONF_CC2531_USB_STICK */
|
||||
|
||||
#else /* BUTTON_SENSOR_ON */
|
||||
#define BUTTON_SENSOR_ACTIVATE()
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if MODEL_CC2531
|
||||
#if MODELS_CONF_CC2531_USB_STICK
|
||||
#include "dev/usb-serial.h"
|
||||
#define IO_ARCH_PREFIX usb_serial
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
void
|
||||
leds_arch_init(void)
|
||||
{
|
||||
#if MODEL_CC2531
|
||||
#if MODELS_CONF_CC2531_USB_STICK
|
||||
P1SEL &= ~LED1_MASK;
|
||||
P1DIR |= LED1_MASK;
|
||||
P0SEL &= ~LED2_MASK;
|
||||
|
@ -58,7 +58,7 @@ leds_arch_init(void)
|
|||
unsigned char
|
||||
leds_arch_get(void)
|
||||
{
|
||||
#if MODEL_CC2531
|
||||
#if MODELS_CONF_CC2531_USB_STICK
|
||||
return (unsigned char)(LED1_PIN | ((LED2_PIN ^ 0x01) << 1));
|
||||
#else
|
||||
return (unsigned char)(LED1_PIN | (LED2_PIN << 1) | (LED3_PIN << 2));
|
||||
|
@ -69,7 +69,7 @@ void
|
|||
leds_arch_set(unsigned char leds)
|
||||
{
|
||||
LED1_PIN = leds & 0x01;
|
||||
#if MODEL_CC2531
|
||||
#if MODELS_CONF_CC2531_USB_STICK
|
||||
LED2_PIN = ((leds & 0x02) >> 1) ^ 0x01;
|
||||
#else
|
||||
LED2_PIN = (leds & 0x02) >> 1;
|
||||
|
|
|
@ -47,7 +47,7 @@ const struct sensors_sensor *sensors[] = {
|
|||
#endif
|
||||
#if BUTTON_SENSOR_ON
|
||||
&button_1_sensor,
|
||||
#if MODEL_CC2531
|
||||
#if MODELS_CONF_CC2531_USB_STICK
|
||||
&button_2_sensor,
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
* 1: P0_0 (Red)
|
||||
* 2: P1_1 (Green - active: low)
|
||||
*/
|
||||
#if MODEL_CC2531
|
||||
#if MODELS_CONF_CC2531_USB_STICK
|
||||
#define MODEL_STRING "TI cc2531 USB Dongle\n"
|
||||
#define USB_CONF_ENABLE 1
|
||||
|
||||
|
|
Loading…
Reference in a new issue