From 6debe1b21b047f84903aed176d8a01cf8c4af1b5 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 24 Feb 2019 15:48:56 +0100 Subject: [PATCH] Added explicit types for TSCH timeslot timings in usec and ticks --- arch/cpu/cc26x0-cc13x0/rf-core/cc13xx-50kbps-tsch.c | 2 +- arch/dev/cc1200/cc1200-802154g-863-870-fsk-50kbps.c | 2 +- arch/dev/cc1200/cc1200-868-4gfsk-1000kbps.c | 2 +- arch/dev/cc2420/cc2420-tsch-15ms.c | 2 +- os/net/mac/tsch/tsch-timeslot-timing.c | 2 +- os/net/mac/tsch/tsch-types.h | 6 ++++++ os/net/mac/tsch/tsch.h | 6 +++--- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/arch/cpu/cc26x0-cc13x0/rf-core/cc13xx-50kbps-tsch.c b/arch/cpu/cc26x0-cc13x0/rf-core/cc13xx-50kbps-tsch.c index af76d63e3..f2874fd03 100644 --- a/arch/cpu/cc26x0-cc13x0/rf-core/cc13xx-50kbps-tsch.c +++ b/arch/cpu/cc26x0-cc13x0/rf-core/cc13xx-50kbps-tsch.c @@ -57,7 +57,7 @@ #define CC13XX_TSCH_DEFAULT_TS_TIMESLOT_LENGTH 40000 /* TSCH timeslot timing (microseconds) */ -const uint16_t tsch_timing_cc13xx_50kbps[tsch_ts_elements_count] = { +const tsch_timeslot_timing_usec tsch_timing_cc13xx_50kbps = { CC13XX_TSCH_DEFAULT_TS_CCA_OFFSET, CC13XX_TSCH_DEFAULT_TS_CCA, CC13XX_TSCH_DEFAULT_TS_TX_OFFSET, diff --git a/arch/dev/cc1200/cc1200-802154g-863-870-fsk-50kbps.c b/arch/dev/cc1200/cc1200-802154g-863-870-fsk-50kbps.c index ad19b5769..f6b1e9a5a 100644 --- a/arch/dev/cc1200/cc1200-802154g-863-870-fsk-50kbps.c +++ b/arch/dev/cc1200/cc1200-802154g-863-870-fsk-50kbps.c @@ -94,7 +94,7 @@ static const char rf_cfg_descriptor[] = "802.15.4g 863-870MHz MR-FSK mode #1"; ) /* TSCH timeslot timing (mircoseconds) */ -static const uint16_t cc1200_50kbps_tsch_timing[tsch_ts_elements_count] = { +static const tsch_timeslot_timing_usec cc1200_50kbps_tsch_timing = { CC1200_TSCH_DEFAULT_TS_CCA_OFFSET, CC1200_TSCH_DEFAULT_TS_CCA, CC1200_TSCH_DEFAULT_TS_TX_OFFSET, diff --git a/arch/dev/cc1200/cc1200-868-4gfsk-1000kbps.c b/arch/dev/cc1200/cc1200-868-4gfsk-1000kbps.c index 29beef6c0..5314bb517 100644 --- a/arch/dev/cc1200/cc1200-868-4gfsk-1000kbps.c +++ b/arch/dev/cc1200/cc1200-868-4gfsk-1000kbps.c @@ -86,7 +86,7 @@ static const char rf_cfg_descriptor[] = "868MHz 2-GFSK 1000 kbps"; ) /* TSCH timeslot timing (in rtimer ticks) */ -static const uint16_t cc1200_1000kbps_tsch_timing[tsch_ts_elements_count] = { +static const tsch_timeslot_timing_usec cc1200_1000kbps_tsch_timing = { CC1200_TSCH_DEFAULT_TS_CCA_OFFSET, CC1200_TSCH_DEFAULT_TS_CCA, CC1200_TSCH_DEFAULT_TS_TX_OFFSET, diff --git a/arch/dev/cc2420/cc2420-tsch-15ms.c b/arch/dev/cc2420/cc2420-tsch-15ms.c index b3b825584..cccc63b34 100644 --- a/arch/dev/cc2420/cc2420-tsch-15ms.c +++ b/arch/dev/cc2420/cc2420-tsch-15ms.c @@ -45,7 +45,7 @@ * \brief 15ms TSCH timeslot timings, required for cc2420 platforms as * they are unable to keep up with the defulat 10ms timeslots. */ -const uint16_t tsch_timeslot_timing_us_15000[tsch_ts_elements_count] = { +const tsch_timeslot_timing_usec tsch_timeslot_timing_us_15000= { 1800, /* CCAOffset */ 128, /* CCA */ 4000, /* TxOffset */ diff --git a/os/net/mac/tsch/tsch-timeslot-timing.c b/os/net/mac/tsch/tsch-timeslot-timing.c index a75676101..1d598a4ae 100644 --- a/os/net/mac/tsch/tsch-timeslot-timing.c +++ b/os/net/mac/tsch/tsch-timeslot-timing.c @@ -61,7 +61,7 @@ * (TxOffset - (RxWait / 2)) instead */ -const uint16_t tsch_timeslot_timing_us_10000[tsch_ts_elements_count] = { +const tsch_timeslot_timing_usec tsch_timeslot_timing_us_10000 = { 1800, /* CCAOffset */ 128, /* CCA */ 2120, /* TxOffset */ diff --git a/os/net/mac/tsch/tsch-types.h b/os/net/mac/tsch/tsch-types.h index 20f9911f6..1c2cdb13a 100644 --- a/os/net/mac/tsch/tsch-types.h +++ b/os/net/mac/tsch/tsch-types.h @@ -142,6 +142,12 @@ enum tsch_timeslot_timing_elements { tsch_ts_elements_count, /* Not a timing element */ }; +/** \brief TSCH timeslot timing elements in rtimer ticks */ +typedef rtimer_clock_t tsch_timeslot_timing_ticks[tsch_ts_elements_count]; + +/** \brief TSCH timeslot timing elements in micro-seconds */ +typedef uint16_t tsch_timeslot_timing_usec[tsch_ts_elements_count]; + /** \brief Stores data about an incoming packet */ struct input_packet { uint8_t payload[TSCH_PACKET_MAX_LEN]; /* Packet payload */ diff --git a/os/net/mac/tsch/tsch.h b/os/net/mac/tsch/tsch.h index ba2926341..6991c08c4 100644 --- a/os/net/mac/tsch/tsch.h +++ b/os/net/mac/tsch/tsch.h @@ -167,9 +167,9 @@ extern uint8_t tsch_current_channel; extern uint8_t tsch_hopping_sequence[TSCH_HOPPING_SEQUENCE_MAX_LEN]; extern struct tsch_asn_divisor_t tsch_hopping_sequence_length; /* TSCH timeslot timing (in micro-second) */ -extern uint16_t tsch_timing_us[tsch_ts_elements_count]; +extern tsch_timeslot_timing_usec tsch_timing_us; /* TSCH timeslot timing (in rtimer ticks) */ -extern rtimer_clock_t tsch_timing[tsch_ts_elements_count]; +extern tsch_timeslot_timing_ticks tsch_timing; /* Statistics on the current session */ extern unsigned long tx_count; extern unsigned long rx_count; @@ -177,7 +177,7 @@ extern unsigned long sync_count; extern int32_t min_drift_seen; extern int32_t max_drift_seen; /* The TSCH standard 10ms timeslot timing */ -extern const uint16_t tsch_timeslot_timing_us_10000[tsch_ts_elements_count]; +extern const tsch_timeslot_timing_usec tsch_timeslot_timing_us_10000; /* TSCH processes */ PROCESS_NAME(tsch_process);