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 0fe452999..b1d4b2064 100644 --- a/arch/dev/cc1200/cc1200-802154g-863-870-fsk-50kbps.c +++ b/arch/dev/cc1200/cc1200-802154g-863-870-fsk-50kbps.c @@ -34,6 +34,7 @@ #include "cc1200-rf-cfg.h" #include "cc1200-const.h" +#include "net/mac/tsch/tsch.h" /* * This is a setup for the following configuration: @@ -62,7 +63,53 @@ /*---------------------------------------------------------------------------*/ static const char rf_cfg_descriptor[] = "802.15.4g 863-870MHz MR-FSK mode #1"; /*---------------------------------------------------------------------------*/ -/* + +/* 1 byte time: 160 usec */ +#define CC1200_TSCH_PREAMBLE_LENGTH 800 /* 5 bytes */ +#define CC1200_TSCH_CONF_RX_WAIT 2200 +#define CC1200_TSCH_CONF_RX_ACK_WAIT 400 + +#define CC1200_TSCH_DEFAULT_TS_CCA_OFFSET 1800 +#define CC1200_TSCH_DEFAULT_TS_CCA 128 + +#define CC1200_TSCH_DEFAULT_TS_TX_OFFSET 3800 +#define CC1200_TSCH_DEFAULT_TS_RX_OFFSET (CC1200_TSCH_DEFAULT_TS_TX_OFFSET - CC1200_TSCH_PREAMBLE_LENGTH - (CC1200_TSCH_CONF_RX_WAIT / 2)) +#define CC1200_TSCH_DEFAULT_TS_RX_ACK_DELAY (CC1200_TSCH_DEFAULT_TS_TX_ACK_DELAY - CC1200_TSCH_PREAMBLE_LENGTH - (CC1200_TSCH_CONF_RX_ACK_WAIT / 2)) +#define CC1200_TSCH_DEFAULT_TS_TX_ACK_DELAY 3000 + +#define CC1200_TSCH_DEFAULT_TS_RX_WAIT (CC1200_TSCH_PREAMBLE_LENGTH + CC1200_TSCH_CONF_RX_WAIT) +#define CC1200_TSCH_DEFAULT_TS_ACK_WAIT (CC1200_TSCH_PREAMBLE_LENGTH + CC1200_TSCH_CONF_RX_ACK_WAIT) +#define CC1200_TSCH_DEFAULT_TS_RX_TX 192 +#define CC1200_TSCH_DEFAULT_TS_MAX_ACK 3360 /* 17+1+3 bytes at 50 kbps */ +#define CC1200_TSCH_DEFAULT_TS_MAX_TX 20800 /* 126+1+3 bytes at 50 kbps */ + +#define CC1200_TSCH_DEFAULT_SLACK_TIME 500 +/* Timeslot length: 31460 usec */ +#define CC1200_TSCH_DEFAULT_TS_TIMESLOT_LENGTH \ + ( CC1200_TSCH_DEFAULT_TS_TX_OFFSET \ + + CC1200_TSCH_DEFAULT_TS_MAX_TX \ + + CC1200_TSCH_DEFAULT_TS_TX_ACK_DELAY \ + + CC1200_TSCH_DEFAULT_TS_MAX_ACK \ + + CC1200_TSCH_DEFAULT_SLACK_TIME \ + ) + +/* TSCH timeslot timing (mircoseconds) */ +static uint16_t cc1200_50kbps_tsch_timing[tsch_ts_elements_count] = { + CC1200_TSCH_DEFAULT_TS_CCA_OFFSET, + CC1200_TSCH_DEFAULT_TS_CCA, + CC1200_TSCH_DEFAULT_TS_TX_OFFSET, + CC1200_TSCH_DEFAULT_TS_RX_OFFSET, + CC1200_TSCH_DEFAULT_TS_RX_ACK_DELAY, + CC1200_TSCH_DEFAULT_TS_TX_ACK_DELAY, + CC1200_TSCH_DEFAULT_TS_RX_WAIT, + CC1200_TSCH_DEFAULT_TS_ACK_WAIT, + CC1200_TSCH_DEFAULT_TS_RX_TX, + CC1200_TSCH_DEFAULT_TS_MAX_ACK, + CC1200_TSCH_DEFAULT_TS_MAX_TX, + CC1200_TSCH_DEFAULT_TS_TIMESLOT_LENGTH, +}; + +/* * Register settings exported from SmartRF Studio using the standard template * "trxEB RF Settings Performance Line". */ @@ -159,6 +206,11 @@ const cc1200_rf_cfg_t cc1200_802154g_863_870_fsk_50kbps = { .size_of_register_settings = sizeof(preferredSettings), .tx_pkt_lifetime = (RTIMER_SECOND / 20), .tx_rx_turnaround = (RTIMER_SECOND / 100), + /* Includes 3 Bytes preamble + 2 Bytes SFD, at 160usec per byte = 800 usec */ + /* Includes time to completion of "Wait for TX to start" if cc1200.c: 397 usec */ + .delay_before_tx = ((unsigned)US_TO_RTIMERTICKS(800 + 397 + 423)), + .delay_before_rx = (unsigned)US_TO_RTIMERTICKS(400), + .delay_before_detect = 0, .chan_center_freq0 = RF_CFG_CHAN_CENTER_F0, .chan_spacing = RF_CFG_CHAN_SPACING, .min_channel = RF_CFG_MIN_CHANNEL, @@ -166,5 +218,7 @@ const cc1200_rf_cfg_t cc1200_802154g_863_870_fsk_50kbps = { .max_txpower = RF_CFG_MAX_TXPOWER, .cca_threshold = RF_CFG_CCA_THRESHOLD, .rssi_offset = RF_CFG_RSSI_OFFSET, + .bitrate = 50000, + .tsch_timing = cc1200_50kbps_tsch_timing, }; /*---------------------------------------------------------------------------*/ diff --git a/arch/dev/cc1200/cc1200-868-fsk-1-2kbps.c b/arch/dev/cc1200/cc1200-868-fsk-1-2kbps.c index 7c8d52cb4..7cb8f3021 100644 --- a/arch/dev/cc1200/cc1200-868-fsk-1-2kbps.c +++ b/arch/dev/cc1200/cc1200-868-fsk-1-2kbps.c @@ -126,6 +126,9 @@ const cc1200_rf_cfg_t cc1200_868_fsk_1_2kbps = { .size_of_register_settings = sizeof(preferredSettings), .tx_pkt_lifetime = (2 * RTIMER_SECOND), .tx_rx_turnaround = (RTIMER_SECOND / 2), + .delay_before_tx = 0, + .delay_before_rx = 0, + .delay_before_detect = 0, .chan_center_freq0 = RF_CFG_CHAN_CENTER_F0, .chan_spacing = RF_CFG_CHAN_SPACING, .min_channel = RF_CFG_MIN_CHANNEL, @@ -133,5 +136,7 @@ const cc1200_rf_cfg_t cc1200_868_fsk_1_2kbps = { .max_txpower = RF_CFG_MAX_TXPOWER, .cca_threshold = RF_CFG_CCA_THRESHOLD, .rssi_offset = RF_CFG_RSSI_OFFSET, + .bitrate = 1200, + .tsch_timing = NULL, }; /*---------------------------------------------------------------------------*/ diff --git a/arch/dev/cc1200/cc1200-rf-cfg.h b/arch/dev/cc1200/cc1200-rf-cfg.h index 4b206959b..d047f772e 100644 --- a/arch/dev/cc1200/cc1200-rf-cfg.h +++ b/arch/dev/cc1200/cc1200-rf-cfg.h @@ -69,6 +69,13 @@ typedef struct cc1200_rf_cfg { rtimer_clock_t tx_pkt_lifetime; /* The maximum time it takes to switch from Tx to Rx */ rtimer_clock_t tx_rx_turnaround; + /* The delay between a call to transmit() and end of SFD */ + rtimer_clock_t delay_before_tx; + /* Delay between GO signal and start listening + * Measured 104us: between GO signal and start listening */ + rtimer_clock_t delay_before_rx; + /* Delay between the SFD finishes arriving and it is detected in software */ + rtimer_clock_t delay_before_detect; /* Base frequency in kHz */ uint32_t chan_center_freq0; /* Channel spacing in Hz */ @@ -87,6 +94,10 @@ typedef struct cc1200_rf_cfg { /* The RSSI offset in dBm. * -99 when MDMCFG1.DVGA_GAIN=00, -81 when MDMCFG1.DVGA_GAIN=01 */ int8_t rssi_offset; + /* The bitrate in bps */ + uint32_t bitrate; + /* TSCH timeslot timing */ + uint16_t *tsch_timing; } cc1200_rf_cfg_t; /*---------------------------------------------------------------------------*/ #endif /* CC1200_RF_CFG_H */