Contiki-NG
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 "cc1200-rf-cfg.h"
36 #include "cc1200-const.h"
37 
38 /*
39  * This is a setup for the following configuration:
40  *
41  * 802.15.4g
42  * =========
43  * Table 68f: Frequency band identifier 4 (863-870 MHz)
44  * Table 68g: Modulation scheme identifier 0 (Filtered FSK)
45  * Table 68h: Mode #1 (50kbps)
46  */
47 
48 /* Base frequency in kHz */
49 #define RF_CFG_CHAN_CENTER_F0 863125
50 /* Channel spacing in Hz */
51 #define RF_CFG_CHAN_SPACING 200000
52 /* The minimum channel */
53 #define RF_CFG_MIN_CHANNEL 0
54 /* The maximum channel */
55 #define RF_CFG_MAX_CHANNEL 33
56 /* The maximum output power in dBm */
57 #define RF_CFG_MAX_TXPOWER CC1200_CONST_TX_POWER_MAX
58 /* The carrier sense level used for CCA in dBm */
59 #define RF_CFG_CCA_THRESHOLD (-91)
60 /* The RSSI offset in dBm */
61 #define RF_CFG_RSSI_OFFSET (-81)
62 /*---------------------------------------------------------------------------*/
63 static const char rf_cfg_descriptor[] = "802.15.4g 863-870MHz MR-FSK mode #1";
64 /*---------------------------------------------------------------------------*/
65 /*
66  * Register settings exported from SmartRF Studio using the standard template
67  * "trxEB RF Settings Performance Line".
68  */
69 
70 // Modulation format = 2-GFSK
71 // Whitening = false
72 // Packet length = 255
73 // Packet length mode = Variable
74 // Packet bit length = 0
75 // Symbol rate = 50
76 // Deviation = 24.948120
77 // Carrier frequency = 867.999878
78 // Device address = 0
79 // Manchester enable = false
80 // Address config = No address check
81 // Bit rate = 50
82 // RX filter BW = 104.166667
83 
84 static const registerSetting_t preferredSettings[]=
85 {
86  {CC1200_IOCFG2, 0x06},
87  {CC1200_SYNC3, 0x6E},
88  {CC1200_SYNC2, 0x4E},
89  {CC1200_SYNC1, 0x90},
90  {CC1200_SYNC0, 0x4E},
91  {CC1200_SYNC_CFG1, 0xE5},
92  {CC1200_SYNC_CFG0, 0x23},
93  {CC1200_DEVIATION_M, 0x47},
94  {CC1200_MODCFG_DEV_E, 0x0B},
95  {CC1200_DCFILT_CFG, 0x56},
96 
97  /*
98  * 18.1.1.1 Preamble field
99  * The Preamble field shall contain phyFSKPreambleLength (as defined in 9.3)
100  * multiples of the 8-bit sequence “01010101” for filtered 2FSK.
101  * The Preamble field shall contain phyFSKPreambleLength multiples of the
102  * 16-bit sequence “0111 0111 0111 0111” for filtered 4FSK.
103  *
104  * We need to define this in order to be able to compute e.g. timeouts for the
105  * MAC layer. According to 9.3, phyFSKPreambleLength can be configured between
106  * 4 and 1000. We set it to 4. Attention: Once we use a long wake-up preamble,
107  * the timing parameters have to change accordingly. Will we use a shorter
108  * preamble for an ACK in this case???
109  */
110  {CC1200_PREAMBLE_CFG1, 0x19},
111 
112  {CC1200_PREAMBLE_CFG0, 0xBA},
113  {CC1200_IQIC, 0xC8},
114  {CC1200_CHAN_BW, 0x84},
115  {CC1200_MDMCFG1, 0x42},
116  {CC1200_MDMCFG0, 0x05},
117  {CC1200_SYMBOL_RATE2, 0x94},
118  {CC1200_SYMBOL_RATE1, 0x7A},
119  {CC1200_SYMBOL_RATE0, 0xE1},
120  {CC1200_AGC_REF, 0x27},
121  {CC1200_AGC_CS_THR, 0xF1},
122  {CC1200_AGC_CFG1, 0x11},
123  {CC1200_AGC_CFG0, 0x90},
124  {CC1200_FIFO_CFG, 0x00},
125  {CC1200_FS_CFG, 0x12},
126  {CC1200_PKT_CFG2, 0x24},
127  {CC1200_PKT_CFG0, 0x20},
128  {CC1200_PKT_LEN, 0xFF},
129  {CC1200_IF_MIX_CFG, 0x18},
130  {CC1200_TOC_CFG, 0x03},
131  {CC1200_MDMCFG2, 0x02},
132  {CC1200_FREQ2, 0x56},
133  {CC1200_FREQ1, 0xCC},
134  {CC1200_FREQ0, 0xCC},
135  {CC1200_IF_ADC1, 0xEE},
136  {CC1200_IF_ADC0, 0x10},
137  {CC1200_FS_DIG1, 0x04},
138  {CC1200_FS_DIG0, 0x50},
139  {CC1200_FS_CAL1, 0x40},
140  {CC1200_FS_CAL0, 0x0E},
141  {CC1200_FS_DIVTWO, 0x03},
142  {CC1200_FS_DSM0, 0x33},
143  {CC1200_FS_DVC1, 0xF7},
144  {CC1200_FS_DVC0, 0x0F},
145  {CC1200_FS_PFD, 0x00},
146  {CC1200_FS_PRE, 0x6E},
147  {CC1200_FS_REG_DIV_CML, 0x1C},
148  {CC1200_FS_SPARE, 0xAC},
149  {CC1200_FS_VCO0, 0xB5},
150  {CC1200_IFAMP, 0x05},
151  {CC1200_XOSC5, 0x0E},
152  {CC1200_XOSC1, 0x03},
153 };
154 /*---------------------------------------------------------------------------*/
155 /* Global linkage: symbol name must be different in each exported file! */
156 const cc1200_rf_cfg_t cc1200_802154g_863_870_fsk_50kbps = {
157  .cfg_descriptor = rf_cfg_descriptor,
158  .register_settings = preferredSettings,
159  .size_of_register_settings = sizeof(preferredSettings),
160  .tx_pkt_lifetime = (RTIMER_SECOND / 20),
161  .tx_rx_turnaround = (RTIMER_SECOND / 100),
162  .chan_center_freq0 = RF_CFG_CHAN_CENTER_F0,
163  .chan_spacing = RF_CFG_CHAN_SPACING,
164  .min_channel = RF_CFG_MIN_CHANNEL,
165  .max_channel = RF_CFG_MAX_CHANNEL,
166  .max_txpower = RF_CFG_MAX_TXPOWER,
167  .cca_threshold = RF_CFG_CCA_THRESHOLD,
168  .rssi_offset = RF_CFG_RSSI_OFFSET,
169 };
170 /*---------------------------------------------------------------------------*/