diff --git a/cpu/msp430/rtimer-arch.h b/cpu/msp430/rtimer-arch.h index 446ef99e1..6063292b1 100644 --- a/cpu/msp430/rtimer-arch.h +++ b/cpu/msp430/rtimer-arch.h @@ -48,6 +48,20 @@ #define RTIMER_ARCH_SECOND (4096U*8) #endif +/* Do the math in 32bits to save precision. + * Round to nearest integer rather than truncate. */ +#define US_TO_RTIMERTICKS(US) ((US) >= 0 ? \ + (((int32_t)(US) * (RTIMER_ARCH_SECOND) + 500000) / 1000000L) : \ + ((int32_t)(US) * (RTIMER_ARCH_SECOND) - 500000) / 1000000L) + +#define RTIMERTICKS_TO_US(T) ((T) >= 0 ? \ + (((int32_t)(T) * 1000000L + ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND)) : \ + ((int32_t)(T) * 1000000L - ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND)) + +/* A 64-bit version because the 32-bit one cannot handle T >= 4295 ticks. + Intended only for positive values of T. */ +#define RTIMERTICKS_TO_US_64(T) ((uint32_t)(((uint64_t)(T) * 1000000 + ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND))) + rtimer_clock_t rtimer_arch_now(void); #endif /* RTIMER_ARCH_H_ */ diff --git a/platform/sky/contiki-conf.h b/platform/sky/contiki-conf.h index 53f22f87f..ff4ad8578 100644 --- a/platform/sky/contiki-conf.h +++ b/platform/sky/contiki-conf.h @@ -37,6 +37,10 @@ #define CC2420_CONF_AUTOACK 1 #endif /* CC2420_CONF_AUTOACK */ +/* The TSCH default slot length of 10ms is a bit too short for this platform, + * use 15ms instead. */ +#define TSCH_CONF_DEFAULT_TIMESLOT_LENGTH 15000 + /* Specify whether the RDC layer should enable per-packet power profiling. */ #define CONTIKIMAC_CONF_COMPOWER 1 diff --git a/platform/sky/platform-conf.h b/platform/sky/platform-conf.h index f5530f3aa..4d5bd9094 100644 --- a/platform/sky/platform-conf.h +++ b/platform/sky/platform-conf.h @@ -46,6 +46,13 @@ /* Platform TMOTE_SKY */ #define TMOTE_SKY 1 +/* Delay between GO signal and SFD: radio fixed delay + 4Bytes preample + 1B SFD -- 1Byte time is 32us + * ~327us + 129preample = 456 us */ +#define RADIO_DELAY_BEFORE_TX ((unsigned)US_TO_RTIMERTICKS(456)) +/* Delay between GO signal and start listening + * ~50us delay + 129preample + ?? = 183 us */ +#define RADIO_DELAY_BEFORE_RX ((unsigned)US_TO_RTIMERTICKS(183)) + #define PLATFORM_HAS_LEDS 1 #define PLATFORM_HAS_BUTTON 1 #define PLATFORM_HAS_LIGHT 1 diff --git a/platform/z1/contiki-conf.h b/platform/z1/contiki-conf.h index 783b3ec8c..44d74efdb 100644 --- a/platform/z1/contiki-conf.h +++ b/platform/z1/contiki-conf.h @@ -103,6 +103,10 @@ #define IEEE802154_CONF_PANID 0xABCD +/* The TSCH default slot length of 10ms is a bit too short for this platform, + * use 15ms instead. */ +#define TSCH_CONF_DEFAULT_TIMESLOT_LENGTH 15000 + #define SHELL_VARS_CONF_RAM_BEGIN 0x1100 #define SHELL_VARS_CONF_RAM_END 0x2000 diff --git a/platform/z1/platform-conf.h b/platform/z1/platform-conf.h index 2d05c96b0..d17c463b6 100644 --- a/platform/z1/platform-conf.h +++ b/platform/z1/platform-conf.h @@ -43,6 +43,13 @@ */ #define ZOLERTIA_Z1 1 /* Enric */ +/* Delay between GO signal and SFD: radio fixed delay + 4Bytes preample + 1B SFD -- 1Byte time is 32us + * ~327us + 129preample = 456 us */ +#define RADIO_DELAY_BEFORE_TX ((unsigned)US_TO_RTIMERTICKS(456)) +/* Delay between GO signal and start listening + * ~50us delay + 129preample + ?? = 183 us */ +#define RADIO_DELAY_BEFORE_RX ((unsigned)US_TO_RTIMERTICKS(183)) + #define PLATFORM_HAS_LEDS 1 #define PLATFORM_HAS_BUTTON 1 #define PLATFORM_HAS_RADIO 1