add experimental cxmac code

This commit is contained in:
dak664 2010-02-18 17:24:12 +00:00
parent 38c5922294
commit 6df1e0ca58
2 changed files with 42 additions and 25 deletions

View file

@ -147,9 +147,13 @@ typedef int32_t s32_t;
#if RF230BB && 0 #if RF230BB && 0
/* Specifies the default MAC driver */ /* Specifies the default MAC driver */
//no autoack gives bad FCS for some reason?
//#define RF230_CONF_NO_AUTO_ACK 1
#define MAC_CONF_CSMA 1 #define MAC_CONF_CSMA 1
#define XMAC_CONF_COMPOWER 1 #define XMAC_CONF_COMPOWER 1
#define CXMAC_CONF_COMPOWER 1 #define CXMAC_CONF_COMPOWER 1
//following gives 50% duty cycle, undef for 5%
#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 16)
#define MAC_CONF_DRIVER cxmac_driver #define MAC_CONF_DRIVER cxmac_driver
#define MAC_CONF_CHANNEL_CHECK_RATE 8 #define MAC_CONF_CHANNEL_CHECK_RATE 8
#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0 #define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0

View file

@ -52,9 +52,13 @@
#if RF230BB //radio driver using contiki core mac #if RF230BB //radio driver using contiki core mac
#include "radio/rf230bb/rf230bb.h" #include "radio/rf230bb/rf230bb.h"
#include "net/mac/frame802154.h" #include "net/mac/frame802154.h"
#include "net/mac/framer-802154.h"
//#include "net/mac/framer-nullmac.h"
//#include "net/mac/framer.h"
#include "net/sicslowpan.h" #include "net/sicslowpan.h"
#include "net/uip-netif.h" #include "net/uip-netif.h"
#include "net/mac/lpp.h" #include "net/mac/lpp.h"
//#include "dev/xmem.h"
#if WITH_NULLMAC #if WITH_NULLMAC
#define MAC_DRIVER nullmac_driver #define MAC_DRIVER nullmac_driver
@ -98,8 +102,9 @@
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]) #define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
extern int rf230_interrupt_flag; extern int rf230_interrupt_flag;
extern uint8_t rf230processflag; extern uint8_t rf230processflag;
#endif /* RF230BB */
#if 0 //dummy tcpip process not needed? #if 1 //dummy tcpip process not needed?
PROCESS(tcpip_process, "tcpip dummy"); PROCESS(tcpip_process, "tcpip dummy");
PROCESS_THREAD(tcpip_process, ev, data) PROCESS_THREAD(tcpip_process, ev, data)
{ {
@ -113,7 +118,6 @@ tcpip_ipv6_output(void)
} }
#endif #endif
#endif /* RF230BB */
/*----------------------Configuration of the .elf file---------------------*/ /*----------------------Configuration of the .elf file---------------------*/
typedef struct {unsigned char B2;unsigned char B1;unsigned char B0;} __signature_t; typedef struct {unsigned char B2;unsigned char B1;unsigned char B0;} __signature_t;
@ -132,14 +136,11 @@ uint8_t mac_address[8] EEMEM = {0x02, 0x12, 0x13, 0xff, 0xfe, 0x14, 0x15, 0x16};
//uint8_t EEMEM server_name[16]; //uint8_t EEMEM server_name[16];
//uint8_t EEMEM domain_name[30]; //uint8_t EEMEM domain_name[30];
#if !RF230BB #if RF230BB
PROCINIT(&etimer_process, &mac_process);
#else
rimeaddr_t macLongAddr; rimeaddr_t macLongAddr;
//PROCINIT(&etimer_process, &tcpip_process);
PROCINIT(&etimer_process);
#endif #endif
//uint8_t rtimerworks;
int int
main(void) main(void)
{ {
@ -160,28 +161,29 @@ main(void)
/* Clock */ /* Clock */
clock_init(); clock_init();
// printf_P(PSTR("\n\n\n********BOOTING CONTIKI*********\n")); /* rtimers not needed yet */
// rtimer_init();
/* Process subsystem */ /* Process subsystem. */
process_init(); process_init();
/* Register initial processes */ /* etimer process must be started before ctimer init */
procinit_init(); process_start(&etimer_process, NULL);
#ifdef RF230BB #ifdef RF230BB
{ {
ctimer_init();
/* Start radio and radio receive process */ /* Start radio and radio receive process */
/* Note this starts RF230 process, so must be done after process_init */ /* Note this starts RF230 process, so must be done after process_init */
rf230_init(); rf230_init();
// set_rime_addr();
framer_set(&framer_802154);
queuebuf_init();
sicslowpan_init(MAC_DRIVER.init(&rf230_driver)); sicslowpan_init(MAC_DRIVER.init(&rf230_driver));
// sicslowpan_init(sicslowmac_init(&rf230_driver)); // sicslowpan_init(sicslowmac_init(&rf230_driver));
// sicslowpan_init(lpp_init(&rf230_driver)); // sicslowpan_init(lpp_init(&rf230_driver));
// sicslowpan_init(cxmac_init(&rf230_driver)); // sicslowpan_init(cxmac_init(&rf230_driver));
// ctimer_init();
rtimer_init();
// queuebuf_init();
/* Set addresses BEFORE starting tcpip process */ /* Set addresses BEFORE starting tcpip process */
@ -199,8 +201,6 @@ main(void)
macLongAddr.u8[6]=addr.u8[1]; macLongAddr.u8[6]=addr.u8[1];
macLongAddr.u8[7]=addr.u8[0]; macLongAddr.u8[7]=addr.u8[0];
sei(); //dak - is this necessary?
memcpy(&uip_lladdr.addr, &addr.u8, 8); memcpy(&uip_lladdr.addr, &addr.u8, 8);
rf230_set_pan_addr(IEEE802154_PANID, 0, (uint8_t *)&addr.u8); //ABCD is default - dak rf230_set_pan_addr(IEEE802154_PANID, 0, (uint8_t *)&addr.u8); //ABCD is default - dak
@ -217,25 +217,37 @@ main(void)
rime_init(rime_udp_init(NULL)); rime_init(rime_udp_init(NULL));
uip_router_register(&rimeroute); uip_router_register(&rimeroute);
#endif #endif
// printf("Driver: %s, Channel: %u\n", sicslowmac_driver.name, rf230_get_channel());
} }
#endif /*RF230BB*/ #endif /*RF230BB*/
#if RF230BB
process_start(&tcpip_process, NULL);
#else
/* The order of starting these is important! */
process_start(&mac_process, NULL);
process_start(&tcpip_process, NULL);
#endif
/* Setup USB */ /* Setup USB */
process_start(&usb_process, NULL); process_start(&usb_process, NULL);
process_start(&cdc_process, NULL); process_start(&cdc_process, NULL);
process_start(&rndis_process, NULL); process_start(&rndis_process, NULL);
process_start(&storage_process, NULL); process_start(&storage_process, NULL);
// printf_P(PSTR("System online.\n"));
//Fix MAC address //Fix MAC address
init_net(); init_net();
/* Main scheduler loop */ /* Main scheduler loop */
while(1) { while(1) {
process_run(); process_run();
#if 0
if (rtimerworks) {
printf("i");
rtimerworks=0;
}
#endif
/* Debugging - allow USB CDC to keep up with printfs */ /* Debugging - allow USB CDC to keep up with printfs */
#if ANNOUNCE #if ANNOUNCE
@ -244,6 +256,7 @@ main(void)
#if RF230BB #if RF230BB
} else if (firsttime==40000) { } else if (firsttime==40000) {
printf("MAC address %x:%x:%x:%x:%x:%x:%x:%x\n\r",addr.u8[0],addr.u8[1],addr.u8[2],addr.u8[3],addr.u8[4],addr.u8[5],addr.u8[6],addr.u8[7]); printf("MAC address %x:%x:%x:%x:%x:%x:%x:%x\n\r",addr.u8[0],addr.u8[1],addr.u8[2],addr.u8[3],addr.u8[4],addr.u8[5],addr.u8[6],addr.u8[7]);
} else if (firsttime==44000) { } else if (firsttime==44000) {
printf("Driver: %s, Channel: %u\n\r", MAC_DRIVER.name, rf230_get_channel()); printf("Driver: %s, Channel: %u\n\r", MAC_DRIVER.name, rf230_get_channel());
#endif #endif