Contiki-NG
cc1200-868-4gfsk-1000kbps.c
1 /*
2  * Copyright (c) 2015, Weptech elektronik GmbH Germany
3  * http://www.weptech.de
4  *
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30  * OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * This file is part of the Contiki operating system.
33  */
34 
35 #include "cc1200-rf-cfg.h"
36 #include "cc1200-const.h"
37 #include "net/mac/tsch/tsch.h"
38 
39 /*
40 * Register settings exported from SmartRF Studio using the standard 1000kpbs 868MHz template
41  */
42 
43  /* Base frequency in kHz */
44  #define RF_CFG_CHAN_CENTER_F0 863125
45  /* Channel spacing in Hz */
46  #define RF_CFG_CHAN_SPACING 1666667
47 /* The minimum channel */
48 #define RF_CFG_MIN_CHANNEL 0
49 /* The maximum channel */
50 #define RF_CFG_MAX_CHANNEL 3
51 /* The maximum output power in dBm */
52 #define RF_CFG_MAX_TXPOWER CC1200_CONST_TX_POWER_MAX
53 /* The carrier sense level used for CCA in dBm */
54 #define RF_CFG_CCA_THRESHOLD (-91)
55 /* The RSSI offset in dBm */
56 #define RF_CFG_RSSI_OFFSET (-81)
57 /*---------------------------------------------------------------------------*/
58 static const char rf_cfg_descriptor[] = "868MHz 2-GFSK 1000 kbps";
59 /*---------------------------------------------------------------------------*/
60 
61 /* 1 byte time: 8 usec */
62 #define CC1200_TSCH_PREAMBLE_LENGTH 800 /* 5 bytes */
63 #define CC1200_TSCH_CONF_RX_WAIT 2200
64 #define CC1200_TSCH_CONF_RX_ACK_WAIT 400
65 
66 #define CC1200_TSCH_DEFAULT_TS_CCA_OFFSET 1800
67 #define CC1200_TSCH_DEFAULT_TS_CCA 128
68 #define CC1200_TSCH_DEFAULT_TS_TX_OFFSET 2200
69 #define CC1200_TSCH_DEFAULT_TS_RX_OFFSET (CC1200_TSCH_DEFAULT_TS_TX_OFFSET - CC1200_TSCH_PREAMBLE_LENGTH - (CC1200_TSCH_CONF_RX_WAIT / 2))
70 #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))
71 #define CC1200_TSCH_DEFAULT_TS_TX_ACK_DELAY 1900
72 #define CC1200_TSCH_DEFAULT_TS_RX_WAIT (CC1200_TSCH_PREAMBLE_LENGTH + CC1200_TSCH_CONF_RX_WAIT)
73 #define CC1200_TSCH_DEFAULT_TS_ACK_WAIT (CC1200_TSCH_PREAMBLE_LENGTH + CC1200_TSCH_CONF_RX_ACK_WAIT)
74 #define CC1200_TSCH_DEFAULT_TS_RX_TX 192
75 #define CC1200_TSCH_DEFAULT_TS_MAX_ACK 168 /* 17+1+3 bytes at 1000 kbps */
76 #define CC1200_TSCH_DEFAULT_TS_MAX_TX 1040 /* 126+1+3 bytes at 1000 kbps */
77 
78 #define CC1200_TSCH_DEFAULT_SLACK_TIME 500
79 /* Timeslot length: 5808 usec */
80 #define CC1200_TSCH_DEFAULT_TS_TIMESLOT_LENGTH \
81  ( CC1200_TSCH_DEFAULT_TS_TX_OFFSET \
82  + CC1200_TSCH_DEFAULT_TS_MAX_TX \
83  + CC1200_TSCH_DEFAULT_TS_TX_ACK_DELAY \
84  + CC1200_TSCH_DEFAULT_TS_MAX_ACK \
85  + CC1200_TSCH_DEFAULT_SLACK_TIME \
86  )
87 
88 /* TSCH timeslot timing (in rtimer ticks) */
89 static const tsch_timeslot_timing_usec cc1200_1000kbps_tsch_timing = {
90  CC1200_TSCH_DEFAULT_TS_CCA_OFFSET,
91  CC1200_TSCH_DEFAULT_TS_CCA,
92  CC1200_TSCH_DEFAULT_TS_TX_OFFSET,
93  CC1200_TSCH_DEFAULT_TS_RX_OFFSET,
94  CC1200_TSCH_DEFAULT_TS_RX_ACK_DELAY,
95  CC1200_TSCH_DEFAULT_TS_TX_ACK_DELAY,
96  CC1200_TSCH_DEFAULT_TS_RX_WAIT,
97  CC1200_TSCH_DEFAULT_TS_ACK_WAIT,
98  CC1200_TSCH_DEFAULT_TS_RX_TX,
99  CC1200_TSCH_DEFAULT_TS_MAX_ACK,
100  CC1200_TSCH_DEFAULT_TS_MAX_TX,
101  CC1200_TSCH_DEFAULT_TS_TIMESLOT_LENGTH,
102 };
103 
104 static const registerSetting_t preferredSettings[]=
105 {
106  {CC1200_IOCFG2, 0x06},
107  {CC1200_SYNC_CFG1, 0xA8},
108  {CC1200_DEVIATION_M, 0x47},
109  {CC1200_MODCFG_DEV_E, 0x2F},
110  {CC1200_DCFILT_CFG, 0x1E},
111  {CC1200_PREAMBLE_CFG0, 0x8A},
112  {CC1200_IQIC, 0x00},
113  {CC1200_CHAN_BW, 0x01},
114  {CC1200_MDMCFG1, 0x42},
115  {CC1200_MDMCFG0, 0x05},
116  {CC1200_SYMBOL_RATE2, 0xC9},
117  {CC1200_SYMBOL_RATE1, 0x99},
118  {CC1200_SYMBOL_RATE0, 0x99},
119  {CC1200_AGC_REF, 0x2F},
120  {CC1200_AGC_CS_THR, 0xF8},
121  {CC1200_AGC_CFG2, 0x60},
122  {CC1200_AGC_CFG1, 0x12},
123  {CC1200_AGC_CFG0, 0x84},
124  {CC1200_FIFO_CFG, 0x00},
125  {CC1200_FS_CFG, 0x12},
126  {CC1200_PKT_CFG2, 0x00},
127  {CC1200_PKT_CFG0, 0x20},
128  {CC1200_PKT_LEN, 0xFF},
129  {CC1200_FREQOFF_CFG, 0x23},
130  {CC1200_MDMCFG2, 0x00},
131  {CC1200_FREQ2, 0x56},
132  {CC1200_FREQ1, 0xCC},
133  {CC1200_FREQ0, 0xCC},
134  {CC1200_IF_ADC1, 0xEE},
135  {CC1200_IF_ADC0, 0x10},
136  {CC1200_FS_DIG1, 0x04},
137  {CC1200_FS_DIG0, 0xA3},
138  {CC1200_FS_CAL1, 0x40},
139  {CC1200_FS_CAL0, 0x0E},
140  {CC1200_FS_DIVTWO, 0x03},
141  {CC1200_FS_DSM0, 0x33},
142  {CC1200_FS_DVC1, 0xF7},
143  {CC1200_FS_DVC0, 0x0F},
144  {CC1200_FS_PFD, 0x00},
145  {CC1200_FS_PRE, 0x6E},
146  {CC1200_FS_REG_DIV_CML, 0x1C},
147  {CC1200_FS_SPARE, 0xAC},
148  {CC1200_FS_VCO0, 0xB5},
149  {CC1200_IFAMP, 0x0D},
150  {CC1200_XOSC5, 0x0E},
151  {CC1200_XOSC1, 0x03},
152 };
153 /*---------------------------------------------------------------------------*/
154 /* Global linkage: symbol name must be different in each exported file! */
155 const cc1200_rf_cfg_t cc1200_868_4gfsk_1000kbps = {
156  .cfg_descriptor = rf_cfg_descriptor,
157  .register_settings = preferredSettings,
158  .size_of_register_settings = sizeof(preferredSettings),
159  .tx_pkt_lifetime = (RTIMER_SECOND),
160  .tx_rx_turnaround = (RTIMER_SECOND / 100),
161  /* Includes 3 Bytes preamble + 2 Bytes SFD, at 8usec per byte = 40 usec */
162  /* Includes time to completion of "Wait for TX to start" if cc1200.c: 397 usec */
163  .delay_before_tx = ((unsigned)US_TO_RTIMERTICKS(40 + 397 + 207)),
164  .delay_before_rx = (unsigned)US_TO_RTIMERTICKS(400),
165  .delay_before_detect = 0,
166  .chan_center_freq0 = RF_CFG_CHAN_CENTER_F0,
167  .chan_spacing = RF_CFG_CHAN_SPACING,
168  .min_channel = RF_CFG_MIN_CHANNEL,
169  .max_channel = RF_CFG_MAX_CHANNEL,
170  .max_txpower = RF_CFG_MAX_TXPOWER,
171  .cca_threshold = RF_CFG_CCA_THRESHOLD,
172  .rssi_offset = RF_CFG_RSSI_OFFSET,
173  .bitrate = 1000000,
174  .tsch_timing = cc1200_1000kbps_tsch_timing,
175 };
176 /*---------------------------------------------------------------------------*/
#define RTIMER_SECOND
Number of rtimer ticks for 1 second.
Definition: rtimer.h:112
Main API declarations for TSCH.
uint16_t tsch_timeslot_timing_usec[tsch_ts_elements_count]
TSCH timeslot timing elements in micro-seconds.
Definition: tsch-types.h:149