adding ducy cycling support to the stm32w-based platforms (patch by Chi-Anh La)

This commit is contained in:
simonduq 2012-03-19 14:00:57 +01:00
parent 2aa1f587bd
commit 5da4463236
9 changed files with 287 additions and 56 deletions

View file

@ -127,7 +127,11 @@ static int is_receiver_awake = 0;
consists of two or more CCA checks. CCA_COUNT_MAX is the number of consists of two or more CCA checks. CCA_COUNT_MAX is the number of
CCAs to be done for each periodic channel check. The default is CCAs to be done for each periodic channel check. The default is
two.*/ two.*/
#ifdef CONTIKIMAC_CONF_CCA_COUNT_MAX
#define CCA_COUNT_MAX CONTIKIMAC_CONF_CCA_COUNT_MAX
#else
#define CCA_COUNT_MAX 2 #define CCA_COUNT_MAX 2
#endif
/* Before starting a transmission, Contikimac checks the availability /* Before starting a transmission, Contikimac checks the availability
of the channel with CCA_COUNT_MAX_TX consecutive CCAs */ of the channel with CCA_COUNT_MAX_TX consecutive CCAs */
@ -176,7 +180,11 @@ static int is_receiver_awake = 0;
/* GUARD_TIME is the time before the expected phase of a neighbor that /* GUARD_TIME is the time before the expected phase of a neighbor that
a transmitted should begin transmitting packets. */ a transmitted should begin transmitting packets. */
#ifdef CONTIKIMAC_CONF_GUARD_TIME
#define GUARD_TIME CONTIKIMAC_CONF_GUARD_TIME * CHECK_TIME + CHECK_TIME_TX
#else
#define GUARD_TIME 10 * CHECK_TIME + CHECK_TIME_TX #define GUARD_TIME 10 * CHECK_TIME + CHECK_TIME_TX
#endif
/* INTER_PACKET_INTERVAL is the interval between two successive packet transmissions */ /* INTER_PACKET_INTERVAL is the interval between two successive packet transmissions */
#define INTER_PACKET_INTERVAL RTIMER_ARCH_SECOND / 5000 #define INTER_PACKET_INTERVAL RTIMER_ARCH_SECOND / 5000
@ -723,7 +731,7 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_
watchdog_periodic(); watchdog_periodic();
t0 = RTIMER_NOW(); t0 = RTIMER_NOW();
seqno = packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO); seqno = packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO);
previous_txtime = RTIMER_NOW();
for(strobes = 0, collisions = 0; for(strobes = 0, collisions = 0;
got_strobe_ack == 0 && collisions == 0 && got_strobe_ack == 0 && collisions == 0 &&
RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + STROBE_TIME); strobes++) { RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + STROBE_TIME); strobes++) {
@ -737,7 +745,7 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_
len = 0; len = 0;
previous_txtime = RTIMER_NOW();
{ {
rtimer_clock_t wt; rtimer_clock_t wt;
rtimer_clock_t txtime; rtimer_clock_t txtime;

View file

@ -781,6 +781,7 @@ input_packet(void)
{ {
struct lpp_hdr hdr; struct lpp_hdr hdr;
clock_time_t reception_time; clock_time_t reception_time;
int ret;
reception_time = clock_time(); reception_time = clock_time();
@ -845,7 +846,7 @@ input_packet(void)
if(i->broadcast_flag == BROADCAST_FLAG_NONE || if(i->broadcast_flag == BROADCAST_FLAG_NONE ||
i->broadcast_flag == BROADCAST_FLAG_SEND) { i->broadcast_flag == BROADCAST_FLAG_SEND) {
i->num_transmissions = 1; i->num_transmissions = 1;
NETSTACK_RADIO.send(queuebuf_dataptr(i->packet), ret = NETSTACK_RADIO.send(queuebuf_dataptr(i->packet),
queuebuf_datalen(i->packet)); queuebuf_datalen(i->packet));
sent = 1; sent = 1;
PRINTF("%d.%d: got a probe from %d.%d, sent packet to %d.%d\n", PRINTF("%d.%d: got a probe from %d.%d, sent packet to %d.%d\n",
@ -860,7 +861,7 @@ input_packet(void)
} }
#else /* WITH_PENDING_BROADCAST */ #else /* WITH_PENDING_BROADCAST */
i->num_transmissions = 1; i->num_transmissions = 1;
NETSTACK_RADIO.send(queuebuf_dataptr(i->packet), ret = NETSTACK_RADIO.send(queuebuf_dataptr(i->packet),
queuebuf_datalen(i->packet)); queuebuf_datalen(i->packet));
PRINTF("%d.%d: got a probe from %d.%d, sent packet to %d.%d\n", PRINTF("%d.%d: got a probe from %d.%d, sent packet to %d.%d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1], rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
@ -879,12 +880,23 @@ input_packet(void)
neighbors, and are dequeued by the dutycycling function neighbors, and are dequeued by the dutycycling function
instead, after the appropriate time. */ instead, after the appropriate time. */
if(!rimeaddr_cmp(receiver, &rimeaddr_null)) { if(!rimeaddr_cmp(receiver, &rimeaddr_null)) {
#if RDC_CONF_HARDWARE_ACK
if(ret == RADIO_TX_OK) {
remove_queued_packet(i, 1);
} else {
remove_queued_packet(i, 0);
}
#else
if(detect_ack()) { if(detect_ack()) {
remove_queued_packet(i, 1); remove_queued_packet(i, 1);
} else { } else {
remove_queued_packet(i, 0); remove_queued_packet(i, 0);
} }
#endif /* RDC_CONF_HARDWARE_ACK */
#if WITH_PROBE_AFTER_TRANSMISSION #if WITH_PROBE_AFTER_TRANSMISSION
/* Send a probe packet to catch any reply from the other node. */ /* Send a probe packet to catch any reply from the other node. */
restart_dutycycle(PROBE_AFTER_TRANSMISSION_TIME); restart_dutycycle(PROBE_AFTER_TRANSMISSION_TIME);

View file

@ -454,6 +454,7 @@ send_packet(void)
rtimer_clock_t t; rtimer_clock_t t;
rtimer_clock_t encounter_time = 0; rtimer_clock_t encounter_time = 0;
int strobes; int strobes;
int ret;
#if 0 #if 0
struct xmac_hdr *hdr; struct xmac_hdr *hdr;
#endif #endif
@ -640,11 +641,11 @@ send_packet(void)
if(is_broadcast) { if(is_broadcast) {
#if WITH_STROBE_BROADCAST #if WITH_STROBE_BROADCAST
NETSTACK_RADIO.send(strobe, strobe_len); ret = NETSTACK_RADIO.send(strobe, strobe_len);
#else #else
/* restore the packet to send */ /* restore the packet to send */
queuebuf_to_packetbuf(packet); queuebuf_to_packetbuf(packet);
NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen()); ret = NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen());
#endif #endif
off(); off();
} else { } else {
@ -652,7 +653,7 @@ send_packet(void)
rtimer_clock_t wt; rtimer_clock_t wt;
#endif #endif
on(); on();
NETSTACK_RADIO.send(strobe, strobe_len); ret = NETSTACK_RADIO.send(strobe, strobe_len);
#if 0 #if 0
/* Turn off the radio for a while to let the other side /* Turn off the radio for a while to let the other side
respond. We don't need to keep our radio on when we know respond. We don't need to keep our radio on when we know
@ -661,12 +662,20 @@ send_packet(void)
wt = RTIMER_NOW(); wt = RTIMER_NOW();
while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + WAIT_TIME_BEFORE_STROBE_ACK)); while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + WAIT_TIME_BEFORE_STROBE_ACK));
#endif /* 0 */ #endif /* 0 */
#if RDC_CONF_HARDWARE_ACK
if(ret == RADIO_TX_OK) {
got_strobe_ack = 1;
} else {
off();
}
#else
if(detect_ack()) { if(detect_ack()) {
got_strobe_ack = 1; got_strobe_ack = 1;
} else { } else {
off(); off();
} }
#endif /* RDC_CONF_HARDWARE_ACK */
} }
} }
} }
@ -693,12 +702,18 @@ send_packet(void)
/* Send the data packet. */ /* Send the data packet. */
if((is_broadcast || got_strobe_ack || is_streaming) && collisions == 0) { if((is_broadcast || got_strobe_ack || is_streaming) && collisions == 0) {
NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen()); ret = NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen());
if(!is_broadcast) { if(!is_broadcast) {
#if RDC_CONF_HARDWARE_ACK
if(ret == RADIO_TX_OK) {
got_ack = 1;
}
#else
if(detect_ack()) { if(detect_ack()) {
got_ack = 1; got_ack = 1;
} }
#endif /* RDC_CONF_HARDWARE_ACK */
} }
} }
off(); off();

View file

@ -37,6 +37,7 @@
* Machine dependent STM32W radio code. * Machine dependent STM32W radio code.
* \author * \author
* Salvatore Pitrulli * Salvatore Pitrulli
* Chi-Anh La la@imag.fr
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -53,13 +54,20 @@
#include "net/packetbuf.h" #include "net/packetbuf.h"
#include "net/rime/rimestats.h" #include "net/rime/rimestats.h"
#include "sys/rtimer.h"
#define DEBUG 0 #define DEBUG 0
#include "dev/leds.h" #include "dev/leds.h"
#define LED_ACTIVITY 0 #define LED_ACTIVITY 0
#if RDC_CONF_DEBUG_LED
#define LED_RDC RDC_CONF_DEBUG_LED
#define LED_ACTIVITY 1
#else
#define LED_RDC 0
#endif
#if DEBUG > 0 #if DEBUG > 0
#include <stdio.h> #include <stdio.h>
@ -71,13 +79,37 @@
#if LED_ACTIVITY #if LED_ACTIVITY
#define LED_TX_ON() leds_on(LEDS_GREEN) #define LED_TX_ON() leds_on(LEDS_GREEN)
#define LED_TX_OFF() leds_off(LEDS_GREEN) #define LED_TX_OFF() leds_off(LEDS_GREEN)
#define LED_RX_ON() leds_on(LEDS_RED) #define LED_RX_ON() { \
#define LED_RX_OFF() leds_off(LEDS_RED) if(LED_RDC == 0){ \
leds_on(LEDS_RED); \
} \
}
#define LED_RX_OFF() { \
if(LED_RDC == 0){ \
leds_off(LEDS_RED); \
} \
}
#define LED_RDC_ON() { \
if(LED_RDC == 1){ \
leds_on(LEDS_RED); \
} \
}
#define LED_RDC_OFF() { \
if(LED_RDC == 1){ \
leds_off(LEDS_RED); \
} \
}
#else #else
#define LED_TX_ON() #define LED_TX_ON()
#define LED_TX_OFF() #define LED_TX_OFF()
#define LED_RX_ON() #define LED_RX_ON()
#define LED_RX_OFF() #define LED_RX_OFF()
#define LED_RDC_ON()
#define LED_RDC_OFF()
#endif
#if NETSTACK_CONF_RDC_ENABLED
#define MAC_RETRIES 0
#endif #endif
#ifndef MAC_RETRIES #ifndef MAC_RETRIES
@ -113,16 +145,28 @@
ENERGEST_OFF(ENERGEST_TYPE_LISTEN); \ ENERGEST_OFF(ENERGEST_TYPE_LISTEN); \
} \ } \
} }
#if NETSTACK_CONF_RDC_ENABLED
#define ST_RADIO_CHECK_CCA FALSE
#define ST_RADIO_CCA_ATTEMPT_MAX 0
#define ST_BACKOFF_EXP_MIN 0
#define ST_BACKOFF_EXP_MAX 0
#else
#define ST_RADIO_CHECK_CCA TRUE
#define ST_RADIO_CCA_ATTEMPT_MAX 4
#define ST_BACKOFF_EXP_MIN 2
#define ST_BACKOFF_EXP_MAX 6
#endif
const RadioTransmitConfig radioTransmitConfig = { const RadioTransmitConfig radioTransmitConfig = {
TRUE, // waitForAck; TRUE, // waitForAck;
TRUE, // checkCca; // Set to FALSE with low-power MACs. ST_RADIO_CHECK_CCA, // checkCca; // Set to FALSE with low-power MACs.
4, // ccaAttemptMax; ST_RADIO_CCA_ATTEMPT_MAX, // ccaAttemptMax;
2, // backoffExponentMin; ST_BACKOFF_EXP_MIN, // backoffExponentMin;
6, // backoffExponentMax; ST_BACKOFF_EXP_MAX, // backoffExponentMax;
TRUE // appendCrc; TRUE // appendCrc;
}; };
#define MAC_RETRIES 0
/* /*
* The buffers which hold incoming data. * The buffers which hold incoming data.
*/ */
@ -173,6 +217,20 @@ static uint8_t receiving_packet = 0;
static s8 last_rssi; static s8 last_rssi;
static volatile StStatus last_tx_status; static volatile StStatus last_tx_status;
#define BUSYWAIT_UNTIL(cond, max_time) \
do { \
rtimer_clock_t t0; \
t0 = RTIMER_NOW(); \
while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + (max_time))); \
} while(0)
static uint8_t locked;
#define GET_LOCK() locked++
static void RELEASE_LOCK(void) {
if(locked>0)
locked--;
}
static volatile uint8_t is_transmit_ack;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS(stm32w_radio_process, "STM32W radio driver"); PROCESS(stm32w_radio_process, "STM32W radio driver");
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -208,20 +266,21 @@ const struct radio_driver stm32w_radio_driver =
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int stm32w_radio_init(void) static int stm32w_radio_init(void)
{ {
// A channel needs also to be setted. // A channel needs also to be setted.
ST_RadioSetChannel(RF_CHANNEL); ST_RadioSetChannel(RF_CHANNEL);
// Initialize radio (analog section, digital baseband and MAC). // Initialize radio (analog section, digital baseband and MAC).
// Leave radio powered up in non-promiscuous rx mode. // Leave radio powered up in non-promiscuous rx mode.
ST_RadioInit(ST_RADIO_POWER_MODE_OFF); ST_RadioInit(ST_RADIO_POWER_MODE_OFF);
onoroff = OFF; onoroff = OFF;
ST_RadioSetNodeId(STM32W_NODE_ID); // To be deleted. ST_RadioSetNodeId(STM32W_NODE_ID); // To be deleted.
ST_RadioSetPanId(IEEE802154_PANID); ST_RadioSetPanId(IEEE802154_PANID);
CLEAN_RXBUFS(); CLEAN_RXBUFS();
CLEAN_TXBUF(); CLEAN_TXBUF();
ST_RadioEnableAutoAck(1);
locked = 0;
process_start(&stm32w_radio_process, NULL); process_start(&stm32w_radio_process, NULL);
return 0; return 0;
@ -291,6 +350,10 @@ static int stm32w_radio_transmit(unsigned short payload_len)
ENERGEST_ON(ENERGEST_TYPE_LISTEN); ENERGEST_ON(ENERGEST_TYPE_LISTEN);
} }
#if RADIO_WAIT_FOR_PACKET_SENT
GET_LOCK();
#endif /* RADIO_WAIT_FOR_PACKET_SENT */
last_tx_status = -1;
LED_TX_ON(); LED_TX_ON();
if(ST_RadioTransmit(stm32w_txbuf)==ST_SUCCESS){ if(ST_RadioTransmit(stm32w_txbuf)==ST_SUCCESS){
@ -312,14 +375,21 @@ static int stm32w_radio_transmit(unsigned short payload_len)
PRINTF("stm32w: unknown tx error.\r\n"); PRINTF("stm32w: unknown tx error.\r\n");
TO_PREV_STATE(); TO_PREV_STATE();
LED_TX_OFF(); LED_TX_OFF();
RELEASE_LOCK();
return RADIO_TX_ERR; return RADIO_TX_ERR;
} }
TO_PREV_STATE(); TO_PREV_STATE();
if(last_tx_status == ST_SUCCESS || last_tx_status == ST_PHY_ACK_RECEIVED){ if(last_tx_status == ST_SUCCESS || last_tx_status == ST_PHY_ACK_RECEIVED || last_tx_status == ST_MAC_NO_ACK_RECEIVED){
return RADIO_TX_OK; RELEASE_LOCK();
if(last_tx_status == ST_PHY_ACK_RECEIVED){
return RADIO_TX_OK; /* ACK status */
}
else if (last_tx_status == ST_MAC_NO_ACK_RECEIVED || last_tx_status == ST_SUCCESS){
return RADIO_TX_NOACK;
}
} }
LED_TX_OFF(); LED_TX_OFF();
RELEASE_LOCK();
return RADIO_TX_ERR; return RADIO_TX_ERR;
#else /* RADIO_WAIT_FOR_PACKET_SENT */ #else /* RADIO_WAIT_FOR_PACKET_SENT */
@ -332,6 +402,9 @@ static int stm32w_radio_transmit(unsigned short payload_len)
} }
#if RADIO_WAIT_FOR_PACKET_SENT
RELEASE_LOCK();
#endif /* RADIO_WAIT_FOR_PACKET_SENT */
TO_PREV_STATE(); TO_PREV_STATE();
PRINTF("stm32w: transmission never started.\r\n"); PRINTF("stm32w: transmission never started.\r\n");
@ -372,7 +445,14 @@ static int stm32w_radio_off(void)
/* Any transmit or receive packets in progress are aborted. /* Any transmit or receive packets in progress are aborted.
* Waiting for end of transmission or reception have to be done. * Waiting for end of transmission or reception have to be done.
*/ */
if(onoroff == ON){ if(locked)
{
PRINTF("stm32w: try to off while sending/receiving (lock=%u).\r\n", locked);
return 0;
}
/* off only if there is no transmission or reception of packet. */
if(onoroff == ON && TXBUF_EMPTY() && !receiving_packet){
LED_RDC_OFF();
ST_RadioSleep(); ST_RadioSleep();
onoroff = OFF; onoroff = OFF;
CLEAN_TXBUF(); CLEAN_TXBUF();
@ -386,7 +466,9 @@ static int stm32w_radio_off(void)
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int stm32w_radio_on(void) static int stm32w_radio_on(void)
{ {
PRINTF("stm32w: turn radio on\n");
if(onoroff == OFF){ if(onoroff == OFF){
LED_RDC_ON();
ST_RadioWake(); ST_RadioWake();
onoroff = ON; onoroff = ON;
@ -410,6 +492,7 @@ void ST_RadioReceiveIsrCallback(u8 *packet,
s8 rssi) s8 rssi)
{ {
LED_RX_ON(); LED_RX_ON();
PRINTF("stm32w: incomming packet received\n");
receiving_packet = 0; receiving_packet = 0;
/* Copy packet into the buffer. It is better to do this here. */ /* Copy packet into the buffer. It is better to do this here. */
if(add_to_rxbuf(packet)){ if(add_to_rxbuf(packet)){
@ -417,6 +500,21 @@ void ST_RadioReceiveIsrCallback(u8 *packet,
last_rssi = rssi; last_rssi = rssi;
} }
LED_RX_OFF(); LED_RX_OFF();
GET_LOCK();
is_transmit_ack = 1;
/* Wait for sending ACK */
BUSYWAIT_UNTIL(!is_transmit_ack, RTIMER_SECOND / 1500);
RELEASE_LOCK();
}
void ST_RadioTxAckIsrCallback (void)
{
/* This callback is for simplemac 1.1.0.
Till now we block (RTIMER_SECOND / 1500)
to prevent radio off during ACK transmission */
is_transmit_ack = 0;
//RELEASE_LOCK();
} }
@ -461,19 +559,19 @@ void ST_RadioTransmitCompleteIsrCallback(StStatus status,
/* Debug outputs. */ /* Debug outputs. */
if(status == ST_SUCCESS || status == ST_PHY_ACK_RECEIVED){ if(status == ST_SUCCESS || status == ST_PHY_ACK_RECEIVED){
PRINTF("TX_END"); PRINTF("stm32w: return status TX_END\r\n");
} }
else if (status == ST_MAC_NO_ACK_RECEIVED){ else if (status == ST_MAC_NO_ACK_RECEIVED){
PRINTF("TX_END_NOACK!!!"); PRINTF("stm32w: return status TX_END_NOACK\r\n");
} }
else if (status == ST_PHY_TX_CCA_FAIL){ else if (status == ST_PHY_TX_CCA_FAIL){
PRINTF("TX_END_CCA!!!"); PRINTF("stm32w: return status TX_END_CCA_FAIL\r\n");
} }
else if(status == ST_PHY_TX_UNDERFLOW){ else if(status == ST_PHY_TX_UNDERFLOW){
PRINTF("TX_END_UFL!!!"); PRINTF("stm32w: return status TX_END_UNDERFLOW\r\n");
} }
else { else {
PRINTF("TX_END_INCOMPL!!!"); PRINTF("stm32w: return status TX_END_INCOMPLETE\r\n");
} }
} }
@ -533,7 +631,7 @@ static int stm32w_radio_read(void *buf, unsigned short bufsize)
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void ST_RadioOverflowIsrCallback(void) void ST_RadioOverflowIsrCallback(void)
{ {
PRINTF("OVERFLOW\r\n"); PRINTF("stm32w: radio overflow\r\n");
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void ST_RadioSfdSentIsrCallback(u32 sfdSentTime) void ST_RadioSfdSentIsrCallback(u32 sfdSentTime)

View file

@ -46,8 +46,12 @@
#include "sys/clock.h" #include "sys/clock.h"
//#define RT_RESOLUTION RES_85US
#ifdef RT_CONF_RESOLUTION
#define RT_RESOLUTION RT_CONF_RESOLUTION
#else
#define RT_RESOLUTION RES_171US #define RT_RESOLUTION RES_171US
#endif
#define RES_341US 0 #define RES_341US 0
#define RES_171US 1 #define RES_171US 1

View file

@ -37,6 +37,7 @@
* contiki-conf.h for MB851. * contiki-conf.h for MB851.
* \author * \author
* Salvatore Pitrulli <salvopitru@users.sourceforge.net> * Salvatore Pitrulli <salvopitru@users.sourceforge.net>
* Chi-Anh La <la@imag.fr>
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -66,7 +67,6 @@ typedef int32_t s32_t;
typedef unsigned short uip_stats_t; typedef unsigned short uip_stats_t;
//#define FIXED_NET_ADDRESS 1 //#define FIXED_NET_ADDRESS 1
//#define NET_ADDR_A 0x2001 //#define NET_ADDR_A 0x2001
//#define NET_ADDR_B 0xdb8 //#define NET_ADDR_B 0xdb8
@ -84,13 +84,54 @@ typedef unsigned short uip_stats_t;
#define NETSTACK_CONF_RADIO stm32w_radio_driver #define NETSTACK_CONF_RADIO stm32w_radio_driver
#if WITH_UIP6 #if WITH_UIP6
#define NETSTACK_CONF_RDC_ENABLED 0
#if NETSTACK_CONF_RDC_ENABLED
/* With radio cycling */
/* RDC params */
/* rtimer_second = 11719 */
#define RT_CONF_RESOLUTION 2
/* TX routine passes the cca/ack result in the return parameter */
#define RDC_CONF_HARDWARE_ACK 1
/* TX routine does automatic cca and optional backoff */
#define RDC_CONF_HARDWARE_CSMA 0
/* Channel check rate (per second) */
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
/* Use ACK for optimization (LPP, XMAC) */
#define WITH_ACK_OPTIMIZATION 0
/* RDC debug with LED */
#define RDC_CONF_DEBUG_LED 1
/* ContikiMAC config */
#define CONTIKIMAC_CONF_CCA_COUNT_MAX 3
#define CONTIKIMAC_CONF_WITH_CONTIKIMAC_HEADER 0
#define WITH_PHASE_OPTIMIZATION 1
#define CONTIKIMAC_CONF_COMPOWER 1
#define CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT 0
#define CONTIKIMAC_CONF_ANNOUNCEMENTS 0
#define WITH_FAST_SLEEP 0
#define CONTIKIMAC_CONF_GUARD_TIME 4
/* CXMAC config */
#define CXMAC_CONF_ANNOUNCEMENTS 0
#define CXMAC_CONF_COMPOWER 1
/* XMAC config */
#define XMAC_CONF_ANNOUNCEMENTS 0
#define XMAC_CONF_COMPOWER 1
/* Netstacks */
#define NETSTACK_CONF_NETWORK sicslowpan_driver
#define NETSTACK_CONF_MAC csma_driver
#define NETSTACK_CONF_RDC contikimac_driver
#define NETSTACK_CONF_FRAMER framer_802154
#else
/* No radio cycling */ /* No radio cycling */
#define NETSTACK_CONF_NETWORK sicslowpan_driver #define NETSTACK_CONF_NETWORK sicslowpan_driver
#define NETSTACK_CONF_MAC nullmac_driver #define NETSTACK_CONF_MAC nullmac_driver
#define NETSTACK_CONF_RDC sicslowmac_driver #define NETSTACK_CONF_RDC sicslowmac_driver
#define NETSTACK_CONF_FRAMER framer_802154 #define NETSTACK_CONF_FRAMER framer_802154
#endif
#define RIMEADDR_CONF_SIZE 8 #define RIMEADDR_CONF_SIZE 8
#define UIP_CONF_LL_802154 1 #define UIP_CONF_LL_802154 1
@ -99,6 +140,8 @@ typedef unsigned short uip_stats_t;
#define UIP_CONF_ND6_SEND_RA 0 #define UIP_CONF_ND6_SEND_RA 0
//#define RPL_BORDER_ROUTER 0 //#define RPL_BORDER_ROUTER 0
#define RPL_CONF_MAX_DODAG_PER_INSTANCE 1
/* A trick to resolve a compilation error with IAR. */ /* A trick to resolve a compilation error with IAR. */
#ifdef __ICCARM__ #ifdef __ICCARM__
#define UIP_CONF_DS6_AADDR_NBU 1 #define UIP_CONF_DS6_AADDR_NBU 1

View file

@ -37,6 +37,7 @@
* Contiki main file. * Contiki main file.
* \author * \author
* Salvatore Pitrulli <salvopitru@users.sourceforge.net> * Salvatore Pitrulli <salvopitru@users.sourceforge.net>
* Chi-Anh La <la@imag.fr>
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -82,9 +83,9 @@
#if UIP_CONF_IPV6 #if UIP_CONF_IPV6
PROCINIT(&etimer_process, &tcpip_process, &sensors_process); PROCINIT(&tcpip_process, &sensors_process);
#else #else
PROCINIT(&etimer_process, &sensors_process); PROCINIT(&sensors_process);
#warning "No TCP/IP process!" #warning "No TCP/IP process!"
#endif #endif
@ -161,6 +162,12 @@ main(void)
uart1_set_input(serial_line_input_byte); uart1_set_input(serial_line_input_byte);
serial_line_init(); serial_line_init();
#endif #endif
/* rtimer and ctimer should be initialized before radio duty cycling layers*/
rtimer_init();
/* etimer_process should be initialized before ctimer */
process_start(&etimer_process, NULL);
ctimer_init();
netstack_init(); netstack_init();
#if !UIP_CONF_IPV6 #if !UIP_CONF_IPV6
@ -170,9 +177,6 @@ main(void)
set_rime_addr(); set_rime_addr();
ctimer_init();
rtimer_init();
procinit_init(); procinit_init();
energest_init(); energest_init();

View file

@ -36,6 +36,7 @@
* contiki-conf.h for MBXXX. * contiki-conf.h for MBXXX.
* \author * \author
* Salvatore Pitrulli <salvopitru@users.sourceforge.net> * Salvatore Pitrulli <salvopitru@users.sourceforge.net>
* Chi-Anh La <la@imag.fr>
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -82,12 +83,55 @@ typedef unsigned short uip_stats_t;
#define NETSTACK_CONF_RADIO stm32w_radio_driver #define NETSTACK_CONF_RADIO stm32w_radio_driver
#if WITH_UIP6 #if WITH_UIP6
#define NETSTACK_CONF_RDC_ENABLED 0
#if NETSTACK_CONF_RDC_ENABLED
/* With radio cycling */
/* RDC params */
/* rtimer_second = 11719 */
#define RT_CONF_RESOLUTION 2
/* TX routine passes the cca/ack result in the return parameter */
#define RDC_CONF_HARDWARE_ACK 1
/* TX routine does automatic cca and optional backoff */
#define RDC_CONF_HARDWARE_CSMA 0
/* Channel check rate (per second) */
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
/* Use ACK for optimization (LPP, XMAC) */
#define WITH_ACK_OPTIMIZATION 0
/* RDC debug with LED */
#define RDC_CONF_DEBUG_LED 1
/* ContikiMAC config */
#define CONTIKIMAC_CONF_CCA_COUNT_MAX 3
#define CONTIKIMAC_CONF_WITH_CONTIKIMAC_HEADER 0
#define WITH_PHASE_OPTIMIZATION 1
#define CONTIKIMAC_CONF_COMPOWER 1
#define CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT 0
#define CONTIKIMAC_CONF_ANNOUNCEMENTS 0
#define WITH_FAST_SLEEP 0
#define CONTIKIMAC_CONF_GUARD_TIME 4
/* CXMAC config */
#define CXMAC_CONF_ANNOUNCEMENTS 0
#define CXMAC_CONF_COMPOWER 1
/* XMAC config */
#define XMAC_CONF_ANNOUNCEMENTS 0
#define XMAC_CONF_COMPOWER 1
/* Netstacks */
#define NETSTACK_CONF_NETWORK sicslowpan_driver
#define NETSTACK_CONF_MAC csma_driver
#define NETSTACK_CONF_RDC contikimac_driver
#define NETSTACK_CONF_FRAMER framer_802154
#else
/* No radio cycling */ /* No radio cycling */
#define NETSTACK_CONF_NETWORK sicslowpan_driver #define NETSTACK_CONF_NETWORK sicslowpan_driver
#define NETSTACK_CONF_MAC nullmac_driver #define NETSTACK_CONF_MAC nullmac_driver
#define NETSTACK_CONF_RDC sicslowmac_driver #define NETSTACK_CONF_RDC sicslowmac_driver
#define NETSTACK_CONF_FRAMER framer_802154 #define NETSTACK_CONF_FRAMER framer_802154
#endif
#define RIMEADDR_CONF_SIZE 8 #define RIMEADDR_CONF_SIZE 8
#define UIP_CONF_LL_802154 1 #define UIP_CONF_LL_802154 1

View file

@ -36,6 +36,7 @@
* Contiki main file. * Contiki main file.
* \author * \author
* Salvatore Pitrulli <salvopitru@users.sourceforge.net> * Salvatore Pitrulli <salvopitru@users.sourceforge.net>
* Chi-Anh La <la@imag.fr>
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -65,8 +66,6 @@
#include "net/rime.h" #include "net/rime.h"
#include "net/rime/rime-udp.h" #include "net/rime/rime-udp.h"
#include "net/uip.h" #include "net/uip.h"
#define DEBUG 1 #define DEBUG 1
#if DEBUG #if DEBUG
#include <stdio.h> #include <stdio.h>
@ -81,9 +80,9 @@
#if UIP_CONF_IPV6 #if UIP_CONF_IPV6
PROCINIT(&etimer_process, &tcpip_process, &sensors_process); PROCINIT(&tcpip_process, &sensors_process);
#else #else
PROCINIT(&etimer_process, &sensors_process); PROCINIT(&sensors_process);
#warning "No TCP/IP process!" #warning "No TCP/IP process!"
#endif #endif
@ -160,17 +159,22 @@ main(void)
uart1_set_input(serial_line_input_byte); uart1_set_input(serial_line_input_byte);
serial_line_init(); serial_line_init();
#endif #endif
/* rtimer and ctimer should be initialized before radio duty cycling layers*/
rtimer_init();
/* etimer_process should be initialized before ctimer */
process_start(&etimer_process, NULL);
ctimer_init();
netstack_init();
#if !UIP_CONF_IPV6 #if !UIP_CONF_IPV6
ST_RadioEnableAutoAck(FALSE); // Because frames are not 802.15.4 compatible. ST_RadioEnableAutoAck(FALSE); // Because frames are not 802.15.4 compatible.
ST_RadioEnableAddressFiltering(FALSE); ST_RadioEnableAddressFiltering(FALSE);
#endif #endif
set_rime_addr();
ctimer_init();
rtimer_init(); rtimer_init();
netstack_init();
set_rime_addr();
procinit_init(); procinit_init();
@ -179,7 +183,6 @@ main(void)
autostart_start(autostart_processes); autostart_start(autostart_processes);
watchdog_start(); watchdog_start();
while(1){ while(1){