From 64ce406ae4e0b4c96b4a3ab7bf0e3f15abbb6f7b Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Wed, 3 Oct 2018 13:33:29 +0200 Subject: [PATCH] Zoul: TSCH configuration assuming not only cc2538 --- arch/cpu/cc2538/cc2538-def.h | 21 +++------------- arch/platform/zoul/contiki-conf.h | 41 ++++++++++++++++++++++++++++++ arch/platform/zoul/platform.c | 42 +++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 18 deletions(-) diff --git a/arch/cpu/cc2538/cc2538-def.h b/arch/cpu/cc2538/cc2538-def.h index e4c7451a6..75195258e 100644 --- a/arch/cpu/cc2538/cc2538-def.h +++ b/arch/cpu/cc2538/cc2538-def.h @@ -37,26 +37,11 @@ #define RTIMER_ARCH_SECOND 32768 /*---------------------------------------------------------------------------*/ /* 352us from calling transmit() until the SFD byte has been sent */ -#define RADIO_DELAY_BEFORE_TX ((unsigned)US_TO_RTIMERTICKS(352)) +#define CC2538_DELAY_BEFORE_TX ((unsigned)US_TO_RTIMERTICKS(352)) /* 192us as in datasheet but ACKs are not always received, so adjusted to 250us */ -#define RADIO_DELAY_BEFORE_RX ((unsigned)US_TO_RTIMERTICKS(250)) -#define RADIO_DELAY_BEFORE_DETECT 0 -#ifndef TSCH_CONF_BASE_DRIFT_PPM -/* The drift compared to "true" 10ms slots. - * Enable adaptive sync to enable compensation for this. - * Slot length 10000 usec - * 328 ticks - * Tick duration 30.517578125 usec - * Real slot duration 10009.765625 usec - * Target - real duration = -9.765625 usec - * TSCH_CONF_BASE_DRIFT_PPM -977 - */ -#define TSCH_CONF_BASE_DRIFT_PPM -977 -#endif +#define CC2538_DELAY_BEFORE_RX ((unsigned)US_TO_RTIMERTICKS(250)) +#define CC2538_DELAY_BEFORE_DETECT 0 -#if MAC_CONF_WITH_TSCH -#define TSCH_CONF_HW_FRAME_FILTERING 0 -#endif /* MAC_CONF_WITH_TSCH */ /*---------------------------------------------------------------------------*/ #define SPI_CONF_CONTROLLER_COUNT 2 /*---------------------------------------------------------------------------*/ diff --git a/arch/platform/zoul/contiki-conf.h b/arch/platform/zoul/contiki-conf.h index 098c37404..b8f545bf0 100644 --- a/arch/platform/zoul/contiki-conf.h +++ b/arch/platform/zoul/contiki-conf.h @@ -55,6 +55,47 @@ #endif /* PROJECT_CONF_PATH */ /*---------------------------------------------------------------------------*/ #include "cc2538-def.h" + +unsigned radio_phy_overhead(void); +unsigned radio_byte_air_time(void); +unsigned radio_delay_before_tx(void); +unsigned radio_delay_before_rx(void); +unsigned radio_delay_before_detect(void); +uint16_t *radio_tsch_timeslot_timing(void); + +/** @} */ +/*---------------------------------------------------------------------------*/ +/* 352us from calling transmit() until the SFD byte has been sent */ +#define CC2538_DELAY_BEFORE_TX ((unsigned)US_TO_RTIMERTICKS(352)) +/* 192us as in datasheet but ACKs are not always received, so adjusted to 250us */ +#define CC2538_DELAY_BEFORE_RX ((unsigned)US_TO_RTIMERTICKS(250)) +#define CC2538_DELAY_BEFORE_DETECT 0 + +#define RADIO_PHY_OVERHEAD radio_phy_overhead() +#define RADIO_BYTE_AIR_TIME radio_byte_air_time() +#define RADIO_DELAY_BEFORE_TX radio_delay_before_tx() +#define RADIO_DELAY_BEFORE_RX radio_delay_before_rx() +#define RADIO_DELAY_BEFORE_DETECT radio_delay_before_detect() + +#define TSCH_CONF_DEFAULT_TIMESLOT_TIMING radio_tsch_timeslot_timing() + +#ifndef TSCH_CONF_BASE_DRIFT_PPM +/* The drift compared to "true" 10ms slots. + * Enable adaptive sync to enable compensation for this. + * Slot length 10000 usec + * 328 ticks + * Tick duration 30.517578125 usec + * Real slot duration 10009.765625 usec + * Target - real duration = -9.765625 usec + * TSCH_CONF_BASE_DRIFT_PPM -977 + */ +#define TSCH_CONF_BASE_DRIFT_PPM -977 +#endif + +#if MAC_CONF_WITH_TSCH +#define TSCH_CONF_HW_FRAME_FILTERING 0 +#endif /* MAC_CONF_WITH_TSCH */ + /*---------------------------------------------------------------------------*/ /** * \name Serial Boot Loader Backdoor configuration diff --git a/arch/platform/zoul/platform.c b/arch/platform/zoul/platform.c index 703f0e521..bed948829 100644 --- a/arch/platform/zoul/platform.c +++ b/arch/platform/zoul/platform.c @@ -257,6 +257,48 @@ platform_idle() lpm_enter(); } /*---------------------------------------------------------------------------*/ +unsigned +radio_phy_overhead(void) { + radio_value_t ret; + NETSTACK_RADIO.get_value(RADIO_CONST_PHY_OVERHEAD, &ret); + return (unsigned)ret; +} +/*---------------------------------------------------------------------------*/ +unsigned +radio_byte_air_time(void) { + radio_value_t ret; + NETSTACK_RADIO.get_value(RADIO_CONST_BYTE_AIR_TIME, &ret); + return (unsigned)ret; +} +/*---------------------------------------------------------------------------*/ +unsigned +radio_delay_before_tx(void) { + radio_value_t ret; + NETSTACK_RADIO.get_value(RADIO_CONST_DELAY_BEFORE_TX, &ret); + return (unsigned)ret; +} +/*---------------------------------------------------------------------------*/ +unsigned +radio_delay_before_rx(void) { + radio_value_t ret; + NETSTACK_RADIO.get_value(RADIO_CONST_DELAY_BEFORE_RX, &ret); + return (unsigned)ret; +} +/*---------------------------------------------------------------------------*/ +unsigned +radio_delay_before_detect(void) { + radio_value_t ret; + NETSTACK_RADIO.get_value(RADIO_CONST_DELAY_BEFORE_DETECT, &ret); + return (unsigned)ret; +} +/*---------------------------------------------------------------------------*/ +uint16_t * +radio_tsch_timeslot_timing(void) { + uint16_t *ret; + NETSTACK_RADIO.get_object(RADIO_CONST_TSCH_TIMING, &ret, sizeof(ret)); + return ret; +} +/*---------------------------------------------------------------------------*/ /** * @} * @}