Contiki-NG
Loading...
Searching...
No Matches
cc1200-802154g-863-870-fsk-50kbps.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 "dev/radio/cc1200/cc1200-rf-cfg.h"
36#include "dev/radio/cc1200/cc1200-const.h"
37#include "net/mac/tsch/tsch.h"
38
39/*
40 * This is a setup for the following configuration:
41 *
42 * 802.15.4g
43 * =========
44 * Table 68f: Frequency band identifier 4 (863-870 MHz)
45 * Table 68g: Modulation scheme identifier 0 (Filtered FSK)
46 * Table 68h: Mode #1 (50kbps)
47 */
48
49/* Base frequency in kHz */
50#define RF_CFG_CHAN_CENTER_F0 863125
51/* Channel spacing in Hz */
52#define RF_CFG_CHAN_SPACING 200000
53/* The minimum channel */
54#define RF_CFG_MIN_CHANNEL 0
55/* The maximum channel */
56#define RF_CFG_MAX_CHANNEL 33
57/* The maximum output power in dBm */
58#define RF_CFG_MAX_TXPOWER CC1200_CONST_TX_POWER_MAX
59/* The carrier sense level used for CCA in dBm */
60#define RF_CFG_CCA_THRESHOLD (-91)
61/* The RSSI offset in dBm */
62#define RF_CFG_RSSI_OFFSET (-81)
63/*---------------------------------------------------------------------------*/
64static const char rf_cfg_descriptor[] = "802.15.4g 863-870MHz MR-FSK mode #1";
65/*---------------------------------------------------------------------------*/
66
67/* 1 byte time: 160 usec */
68#define CC1200_TSCH_PREAMBLE_LENGTH 800 /* 5 bytes */
69#define CC1200_TSCH_CONF_RX_WAIT 2200
70#define CC1200_TSCH_CONF_RX_ACK_WAIT 400
71
72#define CC1200_TSCH_DEFAULT_TS_CCA_OFFSET 1800
73#define CC1200_TSCH_DEFAULT_TS_CCA 128
74
75#define CC1200_TSCH_DEFAULT_TS_TX_OFFSET 3800
76#define CC1200_TSCH_DEFAULT_TS_RX_OFFSET (CC1200_TSCH_DEFAULT_TS_TX_OFFSET - CC1200_TSCH_PREAMBLE_LENGTH - (CC1200_TSCH_CONF_RX_WAIT / 2))
77#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))
78#define CC1200_TSCH_DEFAULT_TS_TX_ACK_DELAY 3000
79
80#define CC1200_TSCH_DEFAULT_TS_RX_WAIT (CC1200_TSCH_PREAMBLE_LENGTH + CC1200_TSCH_CONF_RX_WAIT)
81#define CC1200_TSCH_DEFAULT_TS_ACK_WAIT (CC1200_TSCH_PREAMBLE_LENGTH + CC1200_TSCH_CONF_RX_ACK_WAIT)
82#define CC1200_TSCH_DEFAULT_TS_RX_TX 192
83#define CC1200_TSCH_DEFAULT_TS_MAX_ACK 3360 /* 17+1+3 bytes at 50 kbps */
84#define CC1200_TSCH_DEFAULT_TS_MAX_TX 20800 /* 126+1+3 bytes at 50 kbps */
85
86#define CC1200_TSCH_DEFAULT_SLACK_TIME 500
87/* Timeslot length: 31460 usec */
88#define CC1200_TSCH_DEFAULT_TS_TIMESLOT_LENGTH \
89 ( CC1200_TSCH_DEFAULT_TS_TX_OFFSET \
90 + CC1200_TSCH_DEFAULT_TS_MAX_TX \
91 + CC1200_TSCH_DEFAULT_TS_TX_ACK_DELAY \
92 + CC1200_TSCH_DEFAULT_TS_MAX_ACK \
93 + CC1200_TSCH_DEFAULT_SLACK_TIME \
94 )
95
96/* TSCH timeslot timing (mircoseconds) */
97static const tsch_timeslot_timing_usec cc1200_50kbps_tsch_timing = {
98 CC1200_TSCH_DEFAULT_TS_CCA_OFFSET,
99 CC1200_TSCH_DEFAULT_TS_CCA,
100 CC1200_TSCH_DEFAULT_TS_TX_OFFSET,
101 CC1200_TSCH_DEFAULT_TS_RX_OFFSET,
102 CC1200_TSCH_DEFAULT_TS_RX_ACK_DELAY,
103 CC1200_TSCH_DEFAULT_TS_TX_ACK_DELAY,
104 CC1200_TSCH_DEFAULT_TS_RX_WAIT,
105 CC1200_TSCH_DEFAULT_TS_ACK_WAIT,
106 CC1200_TSCH_DEFAULT_TS_RX_TX,
107 CC1200_TSCH_DEFAULT_TS_MAX_ACK,
108 CC1200_TSCH_DEFAULT_TS_MAX_TX,
109 CC1200_TSCH_DEFAULT_TS_TIMESLOT_LENGTH,
110};
111
112/*
113 * Register settings exported from SmartRF Studio using the standard template
114 * "trxEB RF Settings Performance Line".
115 */
116
117// Modulation format = 2-GFSK
118// Whitening = false
119// Packet length = 255
120// Packet length mode = Variable
121// Packet bit length = 0
122// Symbol rate = 50
123// Deviation = 24.948120
124// Carrier frequency = 867.999878
125// Device address = 0
126// Manchester enable = false
127// Address config = No address check
128// Bit rate = 50
129// RX filter BW = 104.166667
130
131static const registerSetting_t preferredSettings[]=
132{
133 {CC1200_IOCFG2, 0x06},
134 {CC1200_SYNC3, 0x6E},
135 {CC1200_SYNC2, 0x4E},
136 {CC1200_SYNC1, 0x90},
137 {CC1200_SYNC0, 0x4E},
138 {CC1200_SYNC_CFG1, 0xE5},
139 {CC1200_SYNC_CFG0, 0x23},
140 {CC1200_DEVIATION_M, 0x47},
141 {CC1200_MODCFG_DEV_E, 0x0B},
142 {CC1200_DCFILT_CFG, 0x56},
143
144 /*
145 * 18.1.1.1 Preamble field
146 * The Preamble field shall contain phyFSKPreambleLength (as defined in 9.3)
147 * multiples of the 8-bit sequence “01010101” for filtered 2FSK.
148 * The Preamble field shall contain phyFSKPreambleLength multiples of the
149 * 16-bit sequence “0111 0111 0111 0111” for filtered 4FSK.
150 *
151 * We need to define this in order to be able to compute e.g. timeouts for the
152 * MAC layer. According to 9.3, phyFSKPreambleLength can be configured between
153 * 4 and 1000. We set it to 4. Attention: Once we use a long wake-up preamble,
154 * the timing parameters have to change accordingly. Will we use a shorter
155 * preamble for an ACK in this case???
156 */
157 {CC1200_PREAMBLE_CFG1, 0x19},
158
159 {CC1200_PREAMBLE_CFG0, 0xBA},
160 {CC1200_IQIC, 0xC8},
161 {CC1200_CHAN_BW, 0x84},
162 {CC1200_MDMCFG1, 0x42},
163 {CC1200_MDMCFG0, 0x05},
164 {CC1200_SYMBOL_RATE2, 0x94},
165 {CC1200_SYMBOL_RATE1, 0x7A},
166 {CC1200_SYMBOL_RATE0, 0xE1},
167 {CC1200_AGC_REF, 0x27},
168 {CC1200_AGC_CS_THR, 0xF1},
169 {CC1200_AGC_CFG1, 0x11},
170 {CC1200_AGC_CFG0, 0x90},
171 {CC1200_FIFO_CFG, 0x00},
172 {CC1200_FS_CFG, 0x12},
173 {CC1200_PKT_CFG2, 0x24},
174 {CC1200_PKT_CFG0, 0x20},
175 {CC1200_PKT_LEN, 0xFF},
176 {CC1200_IF_MIX_CFG, 0x18},
177 {CC1200_TOC_CFG, 0x03},
178 {CC1200_MDMCFG2, 0x02},
179 {CC1200_FREQ2, 0x56},
180 {CC1200_FREQ1, 0xCC},
181 {CC1200_FREQ0, 0xCC},
182 {CC1200_IF_ADC1, 0xEE},
183 {CC1200_IF_ADC0, 0x10},
184 {CC1200_FS_DIG1, 0x04},
185 {CC1200_FS_DIG0, 0x50},
186 {CC1200_FS_CAL1, 0x40},
187 {CC1200_FS_CAL0, 0x0E},
188 {CC1200_FS_DIVTWO, 0x03},
189 {CC1200_FS_DSM0, 0x33},
190 {CC1200_FS_DVC1, 0xF7},
191 {CC1200_FS_DVC0, 0x0F},
192 {CC1200_FS_PFD, 0x00},
193 {CC1200_FS_PRE, 0x6E},
194 {CC1200_FS_REG_DIV_CML, 0x1C},
195 {CC1200_FS_SPARE, 0xAC},
196 {CC1200_FS_VCO0, 0xB5},
197 {CC1200_IFAMP, 0x05},
198 {CC1200_XOSC5, 0x0E},
199 {CC1200_XOSC1, 0x03},
200};
201/*---------------------------------------------------------------------------*/
202/* Global linkage: symbol name must be different in each exported file! */
203const cc1200_rf_cfg_t cc1200_802154g_863_870_fsk_50kbps = {
204 .cfg_descriptor = rf_cfg_descriptor,
205 .register_settings = preferredSettings,
206 .size_of_register_settings = sizeof(preferredSettings),
207 .tx_pkt_lifetime = (RTIMER_SECOND / 20),
208 .tx_rx_turnaround = (RTIMER_SECOND / 100),
209 /* Includes 3 Bytes preamble + 2 Bytes SFD, at 160usec per byte = 800 usec */
210 /* Includes time to completion of "Wait for TX to start" if cc1200.c: 397 usec */
211 .delay_before_tx = ((unsigned)US_TO_RTIMERTICKS(800 + 397 + 423)),
212 .delay_before_rx = (unsigned)US_TO_RTIMERTICKS(400),
213 .delay_before_detect = 0,
214 .chan_center_freq0 = RF_CFG_CHAN_CENTER_F0,
215 .chan_spacing = RF_CFG_CHAN_SPACING,
216 .min_channel = RF_CFG_MIN_CHANNEL,
217 .max_channel = RF_CFG_MAX_CHANNEL,
218 .max_txpower = RF_CFG_MAX_TXPOWER,
219 .cca_threshold = RF_CFG_CCA_THRESHOLD,
220 .rssi_offset = RF_CFG_RSSI_OFFSET,
221 .bitrate = 50000,
222 .tsch_timing = cc1200_50kbps_tsch_timing,
223};
224/*---------------------------------------------------------------------------*/
#define RTIMER_SECOND
Number of rtimer ticks for 1 second.
Definition rtimer.h:112
uint16_t tsch_timeslot_timing_usec[tsch_ts_elements_count]
TSCH timeslot timing elements in micro-seconds.
Definition tsch-types.h:145
Main API declarations for TSCH.