From e4fb3602627b649ac1e9992d0b23dab350468689 Mon Sep 17 00:00:00 2001 From: simonduq Date: Tue, 20 Mar 2012 16:15:51 +0100 Subject: [PATCH] stm32w platforms: contikimac support in the Rime case, with EUI-64 --- cpu/stm32w108/dev/stm32w-radio.c | 22 +++++++++++++++++----- platform/mb851/contiki-conf.h | 11 ++++++----- platform/mb851/contiki-main.c | 16 +++++++++------- platform/mbxxx/contiki-conf.h | 11 ++++++----- platform/mbxxx/contiki-main.c | 21 ++++++++++----------- 5 files changed, 48 insertions(+), 33 deletions(-) diff --git a/cpu/stm32w108/dev/stm32w-radio.c b/cpu/stm32w108/dev/stm32w-radio.c index 3d2f4b71f..883099d3e 100644 --- a/cpu/stm32w108/dev/stm32w-radio.c +++ b/cpu/stm32w108/dev/stm32w-radio.c @@ -37,7 +37,8 @@ * Machine dependent STM32W radio code. * \author * Salvatore Pitrulli -* Chi-Anh La la@imag.fr +* Chi-Anh La la@imag.fr +* Simon Duquennoy */ /*---------------------------------------------------------------------------*/ @@ -61,6 +62,12 @@ #include "dev/leds.h" #define LED_ACTIVITY 0 +#ifdef ST_CONF_RADIO_AUTOACK +#define ST_RADIO_AUTOACK ST_CONF_RADIO_AUTOACK +#else +#define ST_RADIO_AUTOACK 0 +#endif /* ST_CONF_RADIO_AUTOACK */ + #if RDC_CONF_DEBUG_LED #define LED_RDC RDC_CONF_DEBUG_LED #define LED_ACTIVITY 1 @@ -108,7 +115,7 @@ #define LED_RDC_OFF() #endif -#if NETSTACK_CONF_RDC_ENABLED +#if RDC_CONF_HARDWARE_CSMA #define MAC_RETRIES 0 #endif @@ -145,7 +152,7 @@ ENERGEST_OFF(ENERGEST_TYPE_LISTEN); \ } \ } -#if NETSTACK_CONF_RDC_ENABLED +#if RDC_CONF_HARDWARE_CSMA #define ST_RADIO_CHECK_CCA FALSE #define ST_RADIO_CCA_ATTEMPT_MAX 0 #define ST_BACKOFF_EXP_MIN 0 @@ -274,12 +281,17 @@ static int stm32w_radio_init(void) ST_RadioInit(ST_RADIO_POWER_MODE_OFF); onoroff = OFF; - ST_RadioSetNodeId(STM32W_NODE_ID); // To be deleted. ST_RadioSetPanId(IEEE802154_PANID); CLEAN_RXBUFS(); CLEAN_TXBUF(); - ST_RadioEnableAutoAck(1); + +#if ST_RADIO_AUTOACK && !(UIP_CONF_LL_802154 && RIMEADDR_CONF_SIZE==8) +#error "Autoack and address filtering can only be used with EUI 64" +#endif + ST_RadioEnableAutoAck(ST_RADIO_AUTOACK); + ST_RadioEnableAddressFiltering(ST_RADIO_AUTOACK); + locked = 0; process_start(&stm32w_radio_process, NULL); diff --git a/platform/mb851/contiki-conf.h b/platform/mb851/contiki-conf.h index ee6625eba..902d8dbe5 100644 --- a/platform/mb851/contiki-conf.h +++ b/platform/mb851/contiki-conf.h @@ -51,11 +51,15 @@ #include "platform-conf.h" #endif /* PLATFORM_CONF_H */ -/* Radio and 802.15.4 params*/ +/* Radio and 802.15.4 params */ /* 802.15.4 radio channel */ #define RF_CHANNEL 16 -/* 802.15.4 PAN ID*/ +/* 802.15.4 PAN ID */ #define IEEE802154_CONF_PANID 0x1234 +/* Use EID 64, enable hardware autoack and address filtering */ +#define RIMEADDR_CONF_SIZE 8 +#define UIP_CONF_LL_802154 1 +#define ST_CONF_RADIO_AUTOACK 1 /* Number of buffers for incoming frames */ #define RADIO_RXBUFS 2 /* Set to 0 for non ethernet links */ @@ -78,7 +82,6 @@ #define NETSTACK_CONF_RDC contikimac_driver #define NETSTACK_CONF_FRAMER framer_802154 #define NETSTACK_CONF_RADIO stm32w_radio_driver -#define NETSTACK_CONF_RDC_ENABLED 1 /* ContikiMAC config */ #define CONTIKIMAC_CONF_COMPOWER 1 @@ -125,8 +128,6 @@ #define UIP_CONF_MAX_CONNECTIONS 4 #define UIP_CONF_MAX_LISTENPORTS 8 #define UIP_CONF_UDP_CONNS 4 -#define RIMEADDR_CONF_SIZE 8 -#define UIP_CONF_LL_802154 1 #include "net/sicslowpan.h" #define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_CONF_COMPRESSION_HC06 diff --git a/platform/mb851/contiki-main.c b/platform/mb851/contiki-main.c index db6cd6c85..ee09e2c91 100644 --- a/platform/mb851/contiki-main.c +++ b/platform/mb851/contiki-main.c @@ -109,9 +109,6 @@ set_rime_addr(void) 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)); @@ -170,12 +167,17 @@ main(void) netstack_init(); -#if !UIP_CONF_IPV6 - ST_RadioEnableAutoAck(FALSE); // Because frames are not 802.15.4 compatible. - ST_RadioEnableAddressFiltering(FALSE); -#endif set_rime_addr(); + + printf("%s %s, channel check rate %lu Hz\n", + NETSTACK_MAC.name, NETSTACK_RDC.name, + CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1: + NETSTACK_RDC.channel_check_interval())); + printf("802.15.4 PAN ID 0x%x, EUI-%d:", + IEEE802154_CONF_PANID, UIP_CONF_LL_802154?64:16); + uip_debug_lladdr_print(&rimeaddr_node_addr); + printf(", radio channel %u\n", RF_CHANNEL); procinit_init(); diff --git a/platform/mbxxx/contiki-conf.h b/platform/mbxxx/contiki-conf.h index 2ff971a8b..e5aa9f3c7 100644 --- a/platform/mbxxx/contiki-conf.h +++ b/platform/mbxxx/contiki-conf.h @@ -51,11 +51,15 @@ #include "platform-conf.h" #endif /* PLATFORM_CONF_H */ -/* Radio and 802.15.4 params*/ +/* Radio and 802.15.4 params */ /* 802.15.4 radio channel */ #define RF_CHANNEL 16 -/* 802.15.4 PAN ID*/ +/* 802.15.4 PAN ID */ #define IEEE802154_CONF_PANID 0x1234 +/* Use EID 64, enable hardware autoack and address filtering */ +#define RIMEADDR_CONF_SIZE 8 +#define UIP_CONF_LL_802154 1 +#define ST_CONF_RADIO_AUTOACK 1 /* Number of buffers for incoming frames */ #define RADIO_RXBUFS 2 /* Set to 0 for non ethernet links */ @@ -78,7 +82,6 @@ #define NETSTACK_CONF_RDC contikimac_driver #define NETSTACK_CONF_FRAMER framer_802154 #define NETSTACK_CONF_RADIO stm32w_radio_driver -#define NETSTACK_CONF_RDC_ENABLED 1 /* ContikiMAC config */ #define CONTIKIMAC_CONF_COMPOWER 1 @@ -125,8 +128,6 @@ #define UIP_CONF_MAX_CONNECTIONS 4 #define UIP_CONF_MAX_LISTENPORTS 8 #define UIP_CONF_UDP_CONNS 4 -#define RIMEADDR_CONF_SIZE 8 -#define UIP_CONF_LL_802154 1 #include "net/sicslowpan.h" #define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_CONF_COMPRESSION_HC06 diff --git a/platform/mbxxx/contiki-main.c b/platform/mbxxx/contiki-main.c index a0f4ca972..d5b63b16b 100644 --- a/platform/mbxxx/contiki-main.c +++ b/platform/mbxxx/contiki-main.c @@ -106,9 +106,6 @@ set_rime_addr(void) 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)); @@ -165,16 +162,18 @@ main(void) process_start(&etimer_process, NULL); ctimer_init(); - -#if !UIP_CONF_IPV6 - ST_RadioEnableAutoAck(FALSE); // Because frames are not 802.15.4 compatible. - ST_RadioEnableAddressFiltering(FALSE); -#endif - - rtimer_init(); netstack_init(); - set_rime_addr(); + set_rime_addr(); + + printf("%s %s, channel check rate %lu Hz\n", + NETSTACK_MAC.name, NETSTACK_RDC.name, + CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1: + NETSTACK_RDC.channel_check_interval())); + printf("802.15.4 PAN ID 0x%x, EUI-%d:", + IEEE802154_CONF_PANID, UIP_CONF_LL_802154?64:16); + uip_debug_lladdr_print(&rimeaddr_node_addr); + printf(", radio channel %u\n", RF_CHANNEL); procinit_init();