update to new driver format

This commit is contained in:
dak664 2010-02-22 22:23:18 +00:00
parent 658c35df11
commit cbb8621e30
4 changed files with 770 additions and 723 deletions

File diff suppressed because it is too large Load diff

View file

@ -45,7 +45,7 @@
* \file * \file
* \brief This file contains radio driver code. * \brief This file contains radio driver code.
* *
* $Id: rf230bb.h,v 1.1 2009/07/08 16:17:07 dak664 Exp $ * $Id: rf230bb.h,v 1.2 2010/02/22 22:23:18 dak664 Exp $
*/ */
#ifndef RADIO_H #ifndef RADIO_H
@ -68,6 +68,7 @@
#define RF230_MIN_ED_THRESHOLD ( 0 ) #define RF230_MIN_ED_THRESHOLD ( 0 )
#define RF230_MAX_ED_THRESHOLD ( 15 ) #define RF230_MAX_ED_THRESHOLD ( 15 )
#define RF230_MAX_TX_FRAME_LENGTH ( 127 ) /**< 127 Byte PSDU. */ #define RF230_MAX_TX_FRAME_LENGTH ( 127 ) /**< 127 Byte PSDU. */
//#define RF230_MAX_PACKET_LEN 127
#define TX_PWR_3DBM ( 0 ) #define TX_PWR_3DBM ( 0 )
#define TX_PWR_17_2DBM ( 15 ) #define TX_PWR_17_2DBM ( 15 )
@ -170,13 +171,37 @@ typedef void (*radio_rx_callback) (uint16_t data);
extern uint8_t rxMode; extern uint8_t rxMode;
/*============================ PROTOTYPES ====================================*/ /*============================ PROTOTYPES ====================================*/
const struct radio_driver rf230_driver; const struct radio_driver rf230_driver;
void rf230_init(void); int rf230_init(void);
//int rf230_on(void);
//int rf230_off(void);
void rf230_set_channel(int channel);
int rf230_get_channel(void); int rf230_get_channel(void);
void rf230_set_channel(int c); void rf230_set_pan_addr(unsigned pan,unsigned addr,const uint8_t *ieee_addr);
void rf230_set_pan_addr(uint16_t pan,uint16_t addr,uint8_t *ieee_addr); //void rf230_set_pan_addr(uint16_t pan,uint16_t addr,uint8_t *ieee_addr);
void rf230_set_txpower(uint8_t power); //void rf230_set_txpower(uint8_t power);
int rf230_get_txpower(void); int rf230_get_txpower(void);
//extern signed char rf230_last_rssi;
//extern uint8_t rf230_last_correlation;
//int rf230_rssi(void);
//#define CC2420_TXPOWER_MAX 31
//#define CC2420_TXPOWER_MIN 0
/**
* Interrupt function, called from the simple-cc2420-arch driver.
*
*/
//int cc2420_interrupt(void);
/* XXX hack: these will be made as Chameleon packet attributes */
//extern rtimer_clock_t rf230_time_of_arrival,rf230_time_of_departure;
//extern int rf230_authority_level_of_sender;
//radio_status_t radio_init(bool cal_rc_osc, //radio_status_t radio_init(bool cal_rc_osc,
// hal_rx_start_isr_event_handler_t rx_event, // hal_rx_start_isr_event_handler_t rx_event,
// hal_trx_end_isr_event_handler_t trx_end_event, // hal_trx_end_isr_event_handler_t trx_end_event,

View file

@ -82,6 +82,14 @@ typedef int32_t s32_t;
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2 #define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
#define SICSLOWPAN_CONF_FRAG 1 #define SICSLOWPAN_CONF_FRAG 1
/* Network setup for IPv6 */
#define NETSTACK_CONF_NETWORK sicslowpan_driver
//#define NETSTACK_CONF_MAC nullmac_driver
#define NETSTACK_CONF_MAC csma_driver
//#define NETSTACK_CONF_RDC contikimac_driver
#define NETSTACK_CONF_RDC sicslowmac_driver
#define NETSTACK_CONF_RADIO rf230_driver
/* Below will prevent fragmentation of TCP packets, undef for faster page loads, simpler wireshark captures */ /* Below will prevent fragmentation of TCP packets, undef for faster page loads, simpler wireshark captures */
//#define UIP_CONF_TCP_MSS 48 //#define UIP_CONF_TCP_MSS 48
@ -97,6 +105,7 @@ typedef int32_t s32_t;
#define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1 //for barebones driver, sicslowpan calls radio->read function #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 #undef PACKETBUF_CONF_HDR_SIZE //RF230BB takes the packetbuf default for header size
#define UIP_CONF_ROUTER 0 #define UIP_CONF_ROUTER 0
#if 0 #if 0
/* Specifies the default MAC driver */ /* Specifies the default MAC driver */
//no auto_ack gives bad FCS for some reason? //no auto_ack gives bad FCS for some reason?

View file

@ -33,12 +33,14 @@
#define DEBUG 1 #define DEBUG 1
#if DEBUG #if DEBUG
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) #define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
#define PRINTSHORT(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
int pingtimer1=0,pingtimer2=0; int pingtimer1=0,pingtimer2=0;
#if RF230BB #if RF230BB
extern int rf230_interrupt_flag; extern int rf230_interrupt_flag;
#endif #endif
#else #else
#define PRINTF(...) #define PRINTF(...)
#define PRINTSHORT(...)
#endif #endif
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
@ -58,13 +60,14 @@ extern int rf230_interrupt_flag;
//#include "net/mac/framer-nullmac.h" //#include "net/mac/framer-nullmac.h"
//#include "net/mac/framer.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 "net/mac/cxmac.h" //#include "net/mac/cxmac.h"
#include "net/mac/sicslowmac.h" //#include "net/mac/sicslowmac.h"
//#include "dev/xmem.h" //#include "dev/xmem.h"
#include "net/rime.h" //#include "net/rime.h"
#if 0
#if WITH_NULLMAC #if WITH_NULLMAC
#define MAC_DRIVER nullmac_driver #define MAC_DRIVER nullmac_driver
#endif /* WITH_NULLMAC */ #endif /* WITH_NULLMAC */
@ -73,10 +76,11 @@ extern int rf230_interrupt_flag;
#ifdef MAC_CONF_DRIVER #ifdef MAC_CONF_DRIVER
#define MAC_DRIVER MAC_CONF_DRIVER #define MAC_DRIVER MAC_CONF_DRIVER
#else #else
#define MAC_DRIVER sicslowmac_driver #define MAC_DRIVER sicslowmac1_driver
//#define MAC_DRIVER cxmac_driver //#define MAC_DRIVER cxmac_driver
#endif /* MAC_CONF_DRIVER */ #endif /* MAC_CONF_DRIVER */
#endif /* MAC_DRIVER */ #endif /* MAC_DRIVER */
#endif
#else //radio driver using Atmel/Cisco 802.15.4'ish MAC #else //radio driver using Atmel/Cisco 802.15.4'ish MAC
#include <stdbool.h> #include <stdbool.h>
@ -189,7 +193,19 @@ void initialize(void)
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]); 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]);
framer_set(&framer_802154); framer_set(&framer_802154);
/* Setup X-MAC for 802.15.4 */
queuebuf_init(); queuebuf_init();
NETSTACK_RDC.init(); //prints rs2048
NETSTACK_MAC.init();
NETSTACK_NETWORK.init();
//todo: makes raven reboot
// printf(" %s, channel check rate %d Hz, radio channel %u\n",
// sicslowpan_mac->name,
// CLOCK_SECOND / (sicslowpan_mac->channel_check_interval() == 0? 1:
// sicslowpan_mac->channel_check_interval()),
// RF_CHANNEL);
// uip_ip6addr(&ipprefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0); // uip_ip6addr(&ipprefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
// uip_netif_addr_add(&ipprefix, UIP_DEFAULT_PREFIX_LEN, 0, AUTOCONF); // uip_netif_addr_add(&ipprefix, UIP_DEFAULT_PREFIX_LEN, 0, AUTOCONF);
// uip_nd6_prefix_add(&ipprefix, UIP_DEFAULT_PREFIX_LEN, 0); // uip_nd6_prefix_add(&ipprefix, UIP_DEFAULT_PREFIX_LEN, 0);
@ -202,10 +218,10 @@ void initialize(void)
uip_router_register(&rimeroute); uip_router_register(&rimeroute);
#endif #endif
sicslowpan_init(MAC_DRIVER.init(&rf230_driver)); // sicslowpan_init(MAC_DRIVER.init(&rf230_driver));
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());
//PRINTF("Driver: %s, Channel: %u\n", sicslowmac_driver.name, rf230_get_channel()); PRINTF("Driver: %s, Channel: %u\n", sicslowpan_mac->name, rf230_get_channel());
} }
#endif /*RF230BB*/ #endif /*RF230BB*/
@ -246,6 +262,7 @@ void initialize(void)
/*--------------------------Announce the configuration---------------------*/ /*--------------------------Announce the configuration---------------------*/
#define ANNOUNCE_BOOT 1 //adds about 400 bytes to program size #define ANNOUNCE_BOOT 1 //adds about 400 bytes to program size
#if ANNOUNCE_BOOT #if ANNOUNCE_BOOT
#if WEBSERVER #if WEBSERVER
@ -326,7 +343,7 @@ main(void)
rtimerworks=0; rtimerworks=0;
} }
#endif #endif
#if RF230BB #if RF230BB && 0
if (rf230processflag) { if (rf230processflag) {
printf("rf230p%d",rf230processflag); printf("rf230p%d",rf230processflag);
rf230processflag=0; rf230processflag=0;
@ -335,10 +352,11 @@ main(void)
#if 0 #if 0
if (rf230_interrupt_flag) { if (rf230_interrupt_flag) {
if (rf230_interrupt_flag!=11) { // if (rf230_interrupt_flag!=11) {
PRINTF("*****Radio interrupt %u\n",rf230_interrupt_flag); // PRINTF("*****Radio interrupt %u\n",rf230_interrupt_flag);
PRINTSHORT("**RI%u",rf230_interrupt_flag);
rf230_interrupt_flag=0; rf230_interrupt_flag=0;
} // }
} }
#endif #endif
#if PINGS #if PINGS