Use RF230BB for compilation - untested!

This commit is contained in:
dak664 2010-06-18 15:33:15 +00:00
parent e965b74cf5
commit ac6f837e4a
3 changed files with 122 additions and 21 deletions

View File

@ -1,4 +1,4 @@
CONTIKI_TARGET_DIRS = . rf230 apps net loader
CONTIKI_TARGET_DIRS = . apps net loader
CONTIKI_CORE=contiki-avr-zigbit
CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o
@ -27,12 +27,4 @@ AVRDUDE_OPTIONS=-V
include $(CONTIKIAVR)/Makefile.avr
# Source for AT86RF230
include $(CONTIKI)/cpu/avr/radio/rf230/Makefile.rf230
# 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
include $(CONTIKI)/cpu/avr/radio/ieee-manager/Makefile.ieee-manager
include $(CONTIKIAVR)/radio/Makefile.radio

View File

@ -35,15 +35,34 @@
#include <avr/fuse.h>
#include <avr/eeprom.h>
#include <stdio.h>
#include <string.h>
#include "lib/mmem.h"
#include "loader/symbols-def.h"
#include "loader/symtab.h"
#define ANNOUNCE_BOOT 0 //adds about 600 bytes to program size
#define DEBUG 0
#if DEBUG
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
#define PRINTSHORT(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
#else
#define PRINTF(...)
#define PRINTSHORT(...)
#endif
#if RF230BB //radio driver using contiki core mac
#include "radio/rf230bb/rf230bb.h"
#include "net/mac/frame802154.h"
#include "net/mac/framer-802154.h"
#include "net/sicslowpan.h"
#else //radio driver using Atmel/Cisco 802.15.4'ish MAC
#include <stdbool.h>
#include "mac.h"
#include "sicslowmac.h"
#include "sicslowpan.h"
#include "ieee-15-4-manager.h"
#endif /*RF230BB*/
#include "contiki.h"
#include "contiki-net.h"
@ -62,8 +81,11 @@ FUSES =
.extended = 0xff,
};
#if RF230BB
//PROCINIT(&etimer_process, &tcpip_process );
#else
PROCINIT(&etimer_process, &mac_process, &tcpip_process );
#endif
/* Put default MAC address in EEPROM */
uint8_t mac_address[8] EEMEM = {0x02, 0x11, 0x22, 0xff, 0xfe, 0x33, 0x44, 0x55};
@ -78,6 +100,70 @@ init_lowlevel(void)
/* Redirect stdout to second port */
rs232_redirect_stdout(RS232_PORT_1);
/* rtimers needed for radio cycling */
rtimer_init();
/* Initialize process subsystem */
process_init();
/* etimers must be started before ctimer_init */
process_start(&etimer_process, NULL);
#if RF230BB
ctimer_init();
/* Start radio and radio receive process */
NETSTACK_RADIO.init();
/* Set addresses BEFORE starting tcpip process */
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]);
/* Initialize stack protocols */
queuebuf_init();
NETSTACK_RDC.init();
NETSTACK_MAC.init();
NETSTACK_NETWORK.init();
#if ANNOUNCE_BOOT
printf_P(PSTR("%s %s, channel %u"),NETSTACK_MAC.name, NETSTACK_RDC.name,rf230_get_channel());
if (NETSTACK_RDC.channel_check_interval) {//function pointer is zero for sicslowmac
unsigned short tmp;
tmp=CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval == 0 ? 1:\
NETSTACK_RDC.channel_check_interval());
if (tmp<65535) printf_P(PSTR(", check rate %u Hz"),tmp);
}
printf_P(PSTR("\n"));
#endif
#if UIP_CONF_ROUTER
#if ANNOUNCE_BOOT
printf_P(PSTR("Routing Enabled\n"));
#endif
rime_init(rime_udp_init(NULL));
uip_router_register(&rimeroute);
#endif
process_start(&tcpip_process, NULL);
#else
/* mac process must be started before tcpip process! */
process_start(&mac_process, NULL);
process_start(&tcpip_process, NULL);
#endif /*RF230BB*/
}
@ -92,12 +178,8 @@ main(void)
/* Clock */
clock_init();
/* Process subsystem */
process_init();
/* Register initial processes */
procinit_init();
// procinit_init();
/* Autostart processes */
autostart_start(autostart_processes);

View File

@ -76,20 +76,47 @@ typedef int32_t s32_t;
#define RIMEADDR_CONF_SIZE 8
#define PACKETBUF_CONF_HDR_SIZE 0
/* RF230BB must be used with low power protocols */
#if RF230BB
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
#define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1 //for barebones driver, sicslowpan calls radio->read function
#undef PACKETBUF_CONF_HDR_SIZE //RF230BB takes the packetbuf default for header size
#define UIP_CONF_LLH_LEN 0
/* No radio cycling */
#define NETSTACK_CONF_NETWORK sicslowpan_driver
#define NETSTACK_CONF_MAC nullmac_driver
#define NETSTACK_CONF_RDC sicslowmac_driver
#define NETSTACK_CONF_FRAMER framer_802154
#define NETSTACK_CONF_RADIO rf230_driver
#define RF230_CONF_AUTOACK 1
#define RF230_CONF_AUTORETRIES 2
#define SICSLOWPAN_CONF_FRAG 1
//Most browsers reissue GETs after 3 seconds which stops frag reassembly, longer MAXAGE does no good
#define SICSLOWPAN_CONF_MAXAGE 3
#define QUEUEBUF_CONF_NUM 1
#define QUEUEBUF_CONF_REF_NUM 1
/* Default uip_aligned_buf and sicslowpan_aligned_buf sizes of 1280 overflows RAM */
#define UIP_CONF_BUFFER_SIZE 240
#else
/* Original combined RF230/mac code will not compile with current contiki stack */
//#define PACKETBUF_CONF_HDR_SIZE 0 //RF230 handles headers internally
/* 0 for IPv6, or 1 for HC1, 2 for HC01 */
#define SICSLOWPAN_CONF_COMPRESSION_IPV6 0
#define SICSLOWPAN_CONF_COMPRESSION_HC1 1
#define SICSLOWPAN_CONF_COMPRESSION_HC01 2
#define SICSLOWPAN_CONF_COMPRESSION_HC01 2 //NB '2' is now HC06 in the core mac!
//FTH081105
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_CONF_COMPRESSION_HC01
#define SICSLOWPAN_CONF_MAXAGE 5
#define UIP_CONF_LLH_LEN 14
#endif /*RF230BB */
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
#define SICSLOWPAN_CONF_FRAG 1
#define SICSLOWPAN_CONF_MAXAGE 5
#define UIP_CONF_LL_802154 1
#define UIP_CONF_LLH_LEN 14
#define UIP_CONF_MAX_CONNECTIONS 2
#define UIP_CONF_MAX_LISTENPORTS 2