From d8711d32a34bd6097c66dd63b181318c3bed52e7 Mon Sep 17 00:00:00 2001 From: salvopitru Date: Wed, 27 Oct 2010 14:05:23 +0000 Subject: [PATCH] Added configuration in order to run Rime. --- cpu/stm32w108/dev/stm32w-radio.c | 4 +- platform/mb851/contiki-conf.h | 10 ++--- platform/mb851/contiki-main.c | 73 ++++++++++++++++++++------------ 3 files changed, 53 insertions(+), 34 deletions(-) diff --git a/cpu/stm32w108/dev/stm32w-radio.c b/cpu/stm32w108/dev/stm32w-radio.c index 267dedf7c..47e839631 100644 --- a/cpu/stm32w108/dev/stm32w-radio.c +++ b/cpu/stm32w108/dev/stm32w-radio.c @@ -29,6 +29,7 @@ * * This file is part of the Contiki OS * + * $Id: stm32w-radio.c,v 1.2 2010/10/27 14:05:23 salvopitru Exp $ */ /*---------------------------------------------------------------------------*/ /** @@ -218,9 +219,6 @@ static int stm32w_radio_init(void) ST_RadioSetNodeId(STM32W_NODE_ID); // To be deleted. ST_RadioSetPanId(IEEE802154_PANID); - ST_RadioEnableAutoAck(TRUE); - - CLEAN_RXBUFS(); CLEAN_TXBUF(); diff --git a/platform/mb851/contiki-conf.h b/platform/mb851/contiki-conf.h index 2e12288ed..9fe19aa5a 100644 --- a/platform/mb851/contiki-conf.h +++ b/platform/mb851/contiki-conf.h @@ -29,7 +29,7 @@ * * This file is part of the Contiki OS * - * $Id: contiki-conf.h,v 1.1 2010/10/25 09:03:39 salvopitru Exp $ + * $Id: contiki-conf.h,v 1.2 2010/10/27 14:05:24 salvopitru Exp $ */ /*---------------------------------------------------------------------------*/ /** @@ -79,6 +79,8 @@ typedef unsigned short uip_stats_t; #define QUEUEBUF_CONF_NUM 2 +#define NETSTACK_CONF_RADIO stm32w_radio_driver + #if WITH_UIP6 /* No radio cycling */ @@ -86,8 +88,9 @@ typedef unsigned short uip_stats_t; #define NETSTACK_CONF_MAC nullmac_driver #define NETSTACK_CONF_RDC sicslowmac_driver #define NETSTACK_CONF_FRAMER framer_802154 -#define NETSTACK_CONF_RADIO stm32w_radio_driver +#define RIMEADDR_CONF_SIZE 8 +#define UIP_CONF_LL_802154 1 #define UIP_CONF_ROUTER 1 #define UIP_CONF_IPV6_RPL 1 @@ -103,7 +106,6 @@ typedef unsigned short uip_stats_t; #define UIP_CONF_IPV6_QUEUE_PKT 0 // This is a very costly feature as it increases the RAM usage by approximately UIP_ND6_MAX_NEIGHBORS * UIP_LINK_MTU bytes. #define UIP_CONF_IPV6_CHECKS 1 #define UIP_CONF_IPV6_REASSEMBLY 0 -#define UIP_CONF_NETIF_MAX_ADDRESSES 3 #define UIP_CONF_ND6_MAX_PREFIXES 2 #define UIP_CONF_ND6_MAX_NEIGHBORS 2 #define UIP_CONF_ND6_MAX_DEFROUTERS 1 @@ -131,8 +133,6 @@ typedef unsigned short uip_stats_t; #define STM32W_NODE_ID 0x5678 // to be deleted #define RF_CHANNEL 16 #define RADIO_RXBUFS 2 // Set to a number greater than 1 to decrease packet loss probability at high rates (e.g, with fragmented packets) -#define RIMEADDR_CONF_SIZE 8 -#define UIP_CONF_LL_802154 1 #define UIP_CONF_LLH_LEN 0 typedef unsigned long clock_time_t; diff --git a/platform/mb851/contiki-main.c b/platform/mb851/contiki-main.c index 99e98a68a..916e3952c 100644 --- a/platform/mb851/contiki-main.c +++ b/platform/mb851/contiki-main.c @@ -29,7 +29,7 @@ * * This file is part of the Contiki OS * - * $Id: contiki-main.c,v 1.1 2010/10/25 09:03:39 salvopitru Exp $ + * $Id: contiki-main.c,v 1.2 2010/10/27 14:05:24 salvopitru Exp $ */ /*---------------------------------------------------------------------------*/ /** @@ -81,7 +81,7 @@ #endif -#ifdef WITH_UIP6 +#if UIP_CONF_IPV6 PROCINIT(&etimer_process, &tcpip_process, &sensors_process); #else PROCINIT(&etimer_process, &sensors_process); @@ -91,7 +91,45 @@ PROCINIT(&etimer_process, &sensors_process); SENSORS(&button_sensor,&temperature_sensor,&acc_sensor); /*---------------------------------------------------------------------------*/ +static void +set_rime_addr(void) +{ + int i; + union { + u8_t u8[8]; + }eui64; + + //rimeaddr_t lladdr; + + int8u *stm32w_eui64 = ST_RadioGetEui64(); + { + int8u c; + for(c = 0; c < 8; c++) { // Copy the EUI-64 to lladdr converting from Little-Endian to Big-Endian. + eui64.u8[c] = stm32w_eui64[7 - c]; + } + } + PRINTF("\n\rRadio EUI-64:"); + PRINTLLADDR(eui64); + PRINTF("\n\r"); + +#if UIP_CONF_IPV6 + memcpy(&uip_lladdr.addr, &eui64, sizeof(uip_lladdr.addr)); +#endif +#if UIP_CONF_IPV6 + rimeaddr_set_node_addr((rimeaddr_t *)&eui64); +#else + rimeaddr_set_node_addr((rimeaddr_t *)&eui64.u8[8-RIMEADDR_SIZE]); +#endif + + printf("Rime started with address "); + for(i = 0; i < sizeof(rimeaddr_t) - 1; i++) { + printf("%d.", rimeaddr_node_addr.u8[i]); + } + printf("%d\n", rimeaddr_node_addr.u8[i]); + +} +/*---------------------------------------------------------------------------*/ int main(void) { @@ -119,35 +157,18 @@ main(void) process_init(); - #if WITH_SERIAL_LINE_INPUT +#if WITH_SERIAL_LINE_INPUT uart1_set_input(serial_line_input_byte); serial_line_init(); - #endif - -#ifdef WITH_UIP6 +#endif netstack_init(); - - { - rimeaddr_t lladdr; - - int8u *stm32w_eui64 = ST_RadioGetEui64(); - { - int8u c; - for(c = 0; c < 8; c++) { // Copy the EUI-64 to lladdr converting from Little-Endian to Big-Endian. - lladdr.u8[c] = stm32w_eui64[7 - c]; - } - } - PRINTF("\n\rRadio EUI-64:"); - PRINTLLADDR(lladdr); - PRINTF("\n\r"); - - rimeaddr_set_node_addr(&lladdr); - - memcpy(&uip_lladdr.addr, &lladdr, sizeof(uip_lladdr.addr)); - } - +#if !UIP_CONF_IPV6 + ST_RadioEnableAutoAck(FALSE); // Because frames are not 802.15.4 compatible. + ST_RadioEnableAddressFiltering(FALSE); #endif + + set_rime_addr(); ctimer_init(); rtimer_init();