Add rf230bb radio driver with conditional make on RF230BB=1

This commit is contained in:
dak664 2009-07-08 15:26:17 +00:00
parent c436b99887
commit 49989dbe45
6 changed files with 186 additions and 31 deletions

View File

@ -1,4 +1,4 @@
# $Id: Makefile.avr,v 1.13 2009/04/06 13:10:14 nifi Exp $
# $Id: Makefile.avr,v 1.14 2009/07/08 15:26:17 dak664 Exp $
### Check if we are running under Windows
@ -12,7 +12,7 @@ endif
.SUFFIXES:
### Optimization setting
### Optimization setting, OPTI=0 for easier debugging!
OPTI=s
### Define the CPU directory
@ -53,11 +53,24 @@ LDFLAGS = -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map \
CONTIKI_TARGET_DIRS_CONCAT = ${addprefix $(CONTIKI)/platform/$(TARGET)/, \
$(CONTIKI_TARGET_DIRS)}
ifdef RF230BB
### The RF230 "bare bones" driver uses the core MAC layer.
### It does NOT work with the Jackdaw USB stick.
### Define RF230BB in the base makefile, or use $make RF230BB=1 ...
### Note $make clean and $make clean RF230BB=1 use different directory paths!
CFLAGS +=-DRF230BB
vpath %.c $(PROJECTDIRS) $(CONTIKI)/cpu/avr/dev \
$(CONTIKI_CPU) $(CONTIKI)/cpu/avr/radio/rf230bb \
$(CONTIKIDIRS) $(APPDIRS) $(CONTIKI_TARGET_DIRS_CONCAT)
else
vpath %.c $(PROJECTDIRS) $(CONTIKI)/cpu/avr/dev $(CONTIKI)/cpu/avr/dev/usb \
$(CONTIKI)/cpu/avr/dev/usb/rndis $(CONTIKI)/cpu/avr/dev/usb/serial \
$(CONTIKI)/cpu/avr/dev/usb/storage \
$(CONTIKI_CPU) $(CONTIKI)/cpu/avr/radio/rf230 $(CONTIKI)/cpu/avr/radio/mac \
$(CONTIKIDIRS) $(APPDIRS) $(CONTIKI_TARGET_DIRS_CONCAT)
$(CONTIKI_CPU) $(CONTIKI)/cpu/avr/radio/rf230 $(CONTIKI)/cpu/avr/radio/mac \
$(CONTIKIDIRS) $(APPDIRS) $(CONTIKI_TARGET_DIRS_CONCAT)
endif
### Compilation rules

View File

@ -4,6 +4,7 @@ all: webserver6
APPS=raven-webserver raven-lcd-interface
TARGET=avr-raven
UIP_CONF_IPV6=1
#RF230BB=1 //Use radio driver that communicates with the core MAC layer. Still Experimental!
CONTIKI = ../..

View File

@ -1,4 +1,14 @@
# The barebones radio driver uses the contiki core MAC layer instead
# of the original glue. Define it here or invoke with $make RF230BB=1.
# If the latter, $make clean RF230BB=1 is needed to clean the same directory path.
##RF230BB=1
ifdef RF230BB
CONTIKI_TARGET_DIRS = . rf230bb apps net loader
else
CONTIKI_TARGET_DIRS = . rf230 apps net loader
endif
CONTIKI_CORE=contiki-raven-main
CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o
@ -28,11 +38,16 @@ AVRDUDE_OPTIONS=-V
include $(CONTIKIAVR)/Makefile.avr
ifdef RF230BB
# Source for AT86RF230 barebones driver using the contiki core MAC
include $(CONTIKI)/cpu/avr/radio/rf230bb/Makefile.rf230bb
else
# Source for AT86RF230
include $(CONTIKI)/cpu/avr/radio/rf230/Makefile.rf230
# Source for Atmel/Cisco 802.15.4'ish MAC
#Source for Atmel/Cisco 802.15.4'ish MAC
include $(CONTIKI)/cpu/avr/radio/mac/Makefile.mac
# Source for IEEE 802.15.4 manager interface
#Source for IEEE 802.15.4 manager interface
include $(CONTIKI)/cpu/avr/radio/ieee-manager/Makefile.ieee-manager
endif

View File

@ -28,7 +28,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id: raven-lcd.c,v 1.1 2009/03/12 19:15:25 adamdunkels Exp $
* $Id: raven-lcd.c,v 1.2 2009/07/08 15:26:17 dak664 Exp $
*/
/**
@ -62,7 +62,7 @@
#include "webserver-nogui.h"
#include "httpd-cgi.h"
#include "frame.h"
//#include "frame.h"
#include "mac.h"
#include "raven-lcd.h"
@ -195,7 +195,7 @@ raven_gui_loop(process_event_t ev, process_data_t data)
break;
}
/* Reset command done flag. */
cmd.done = false;
cmd.done = 0;
}
break;
default:
@ -214,9 +214,9 @@ int raven_lcd_serial_input(unsigned char ch)
switch (cmd.ndx){
case 0:
/* first byte, must be 0x01 */
cmd.done = false;
cmd.done = 0;
if (ch != 0x01){
return;
return 0;
}
break;
case 1:
@ -232,7 +232,7 @@ int raven_lcd_serial_input(unsigned char ch)
if (cmd.ndx >= cmd.len+3){
/* all done, check ETX */
if (ch == 0x04){
cmd.done = true;
cmd.done = 1;
process_post(&raven_lcd_process, SERIAL_CMD, 0);
} else {
/* Failed ETX */

View File

@ -70,7 +70,7 @@ typedef int32_t s32_t;
#define CLIF
#define RIMEADDR_CONF_SIZE 8
#define PACKETBUF_CONF_HDR_SIZE 0
//#define PACKETBUF_CONF_HDR_SIZE 0 //undefine when using the barebones driver
/* 0 for IPv6, or 1 for HC1, 2 for HC01 */
#define SICSLOWPAN_CONF_COMPRESSION_IPV6 0
@ -79,7 +79,15 @@ typedef int32_t s32_t;
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_CONF_COMPRESSION_HC01
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
#define SICSLOWPAN_CONF_FRAG 1
#define SICSLOWPAN_CONF_FRAG 1 //set zero for sky equivalence with barebones driver
#ifdef RF230BB
#define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1 //for barebones driver
//#define SICSLOWPAN_CONF_FRAG 0 //for sky equivalence with barebones driver
//#define UIP_CONF_BUFFER_SIZE 256 //for sky equivalence with barebones driver
//#define UIP_CONF_ROUTER 1
#define UIP_CONF_ROUTER 0
#endif
#define SICSLOWPAN_CONF_MAXAGE 5

View File

@ -35,15 +35,26 @@
#include <avr/fuse.h>
#include <avr/eeprom.h>
#include <stdio.h>
#include <string.h>
#include "lib/mmem.h"
//#include "lib/mmem.h"
#include "loader/symbols-def.h"
#include "loader/symtab.h"
#include <stdbool.h>
//#include <stdbool.h>
#ifdef RF230BB
#include "radio/rf230bb/rf230bb.h"
#include "net/mac/frame802154.h"
#include "net/sicslowpan.h"
#include "net/uip-netif.h"
#include "net/mac/sicslowmac.h"
#else
#include "mac.h"
#include "sicslowmac.h"
#include "sicslowpan.h"
#include "ieee-15-4-manager.h"
#endif /*RF230BB*/
#include "contiki.h"
#include "contiki-net.h"
@ -58,23 +69,63 @@
#endif
#include "sicslowmac.h"
#if UIP_CONF_ROUTER
#include "net/routing/rimeroute.h"
#include "net/rime/rime-udp.h"
#endif /* UIP_CONF_ROUTER*/
#include "net/rime.h"
//#include "node-id.h"
#define DEBUG 0
#if DEBUG
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
#else
#define PRINTF(...) do {} while (0)
#endif
typedef struct
{
unsigned char B2;
unsigned char B1;
unsigned char B0;
} __signature_t;
/* Put the MCU signature in the .elf file */
#define SIGNATURE __signature_t __signature __attribute__((section (".signature")))
SIGNATURE =
{
/* Older AVR-GCCs may not define the SIGNATURE_n bytes so use explicit 1284p values */
.B2 = 0x05,//SIGNATURE_2,
.B1 = 0x97,//SIGNATURE_1,
.B0 = 0x1E,//SIGNATURE_0,
};
/* Set the fuses in the .elf file */
FUSES =
{
.low = 0xe2,
.high = 0x99,
.extended = 0xff,
};
{
.low = 0xe2,
.high = 0x99,
.extended = 0xff,
};
/* Put default MAC address in EEPROM */
uint8_t mac_address[8] EEMEM = {0x02, 0x11, 0x22, 0xff, 0xfe, 0x33, 0x44, 0x55};
#ifdef RAVEN_LCD_INTERFACE
#ifdef RF230BB
PROCINIT(&etimer_process, &tcpip_process, &raven_lcd_process);
#else
PROCINIT(&etimer_process, &mac_process, &tcpip_process, &raven_lcd_process);
#endif /*RF230BB*/
#else
#ifdef RF230BB
PROCINIT(&etimer_process, &tcpip_process);
#else
PROCINIT(&etimer_process, &mac_process, &tcpip_process);
#endif
#endif /*RF230BB*/
#endif /*RAVEN_LCD_INTERFACE*/
void
init_lowlevel(void)
@ -95,39 +146,106 @@ init_lowlevel(void)
/* Redirect stdout to second port */
rs232_redirect_stdout(RS232_PORT_1);
}
#ifdef RF230BB
/* Address initialization when using the core MAC layer */
/*---------------------------------------------------------------------------*/
static void
set_addresses(void)
{
rimeaddr_t addr;
memset(&addr, 0, sizeof(rimeaddr_t));
AVR_ENTER_CRITICAL_REGION();
eeprom_read_block ((void *)&addr.u8, &mac_address, 8);
AVR_LEAVE_CRITICAL_REGION();
memcpy(&uip_lladdr.addr, &addr.u8, 8);
rf230_set_pan_addr(IEEE802154_PANID, 0, (uint8_t *)&addr.u8);
rf230_set_channel(24);
rimeaddr_set_node_addr(&addr);
PRINTF("MAC address %x:%x:%x:%x:%x:%x:%x:%x\n",addr.u8[0],addr.u8[1],addr.u8[2],addr.u8[3],addr.u8[4],addr.u8[5],addr.u8[6],addr.u8[7]);
// uip_ip6addr(&ipprefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
// uip_netif_addr_add(&ipprefix, UIP_DEFAULT_PREFIX_LEN, 0, AUTOCONF);
// uip_nd6_prefix_add(&ipprefix, UIP_DEFAULT_PREFIX_LEN, 0);
// PRINTF("Prefix %x::/%u\n",ipprefix.u16[0],UIP_DEFAULT_PREFIX_LEN);
#if UIP_CONF_ROUTER
rime_init(rime_udp_init(NULL));
uip_router_register(&rimeroute);
#endif
}
#if DEBUG
int pingtimer1=0;pingtimer2=0
extern int rf230_interrupt_flag;
#endif
#endif /*RF230BB*/
int
main(void)
{
//calibrate_rc_osc_32k(); //CO: Had to comment this out
/* Initialize hardware */
/* Initialize serial ports */
init_lowlevel();
/* Clock */
clock_init();
printf_P(PSTR("\n********BOOTING CONTIKI*********\n"));
/* Process subsystem */
/* Process subsystem */
process_init();
#ifdef RF230BB
/* Start radio and radio receive process */
rf230_init();
sicslowpan_init(sicslowmac_init(&rf230_driver));
// ctimer_init();
// sicslowpan_init(lpp_init(&rf230_driver));
// rime_init(sicslowmac_driver.init(&rf230_driver));
// rime_init(lpp_init(&rf230_driver));
/* Set addresses BEFORE starting tcpip process */
set_addresses();
PRINTF(PSTR("Driver: %s, Channel: %u\n"), sicslowmac_driver.name, rf230_get_channel());
#endif /*RF230BB*/
/* Register initial processes */
procinit_init();
procinit_init();
/* Autostart processes */
autostart_start(autostart_processes);
//Give ourselves a prefix
//init_net();
// init_net();
printf_P(PSTR("\n********BOOTING CONTIKI*********\n"));
printf_P(PSTR("System online.\n"));
printf_P(PSTR(CONTIKI_VERSION_STRING" online\n"));
/* Main scheduler loop */
while(1) {
process_run();
#if DEBUG
if (rf230_interrupt_flag) {
if (rf230_interrupt_flag!=11) {
PRINTF("*****Radio interrupt %u\n",rf230_interrupt_flag);
rf230_interrupt_flag=0;
}
}
if (pingtimer1++==10000) {
pingtimer1=0;
if (pingtimer2++==1000) {
PRINTF("-------Ping\n");
pingtimer2=0;
raven_ping6();
}
}
#endif
}
return 0;