Contiki-NG
cc1200-conf.h
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 #ifndef CC1200_H_
36 #define CC1200_H_
37 
38 #include "contiki.h"
39 
40 /*---------------------------------------------------------------------------*/
41 /*
42  * Can we use GPIO2 (in addition to GPIO0)?
43  *
44  * If this is the case, we can easily handle payloads > 125 bytes
45  * (and even > 127 bytes). If GPIO2 is available, we use it as an indicator
46  * pin for RX / TX FIFO threshold.
47  */
48 #ifdef CC1200_CONF_USE_GPIO2
49 #define CC1200_USE_GPIO2 CC1200_CONF_USE_GPIO2
50 #else
51 #define CC1200_USE_GPIO2 1
52 #endif
53 /*---------------------------------------------------------------------------*/
54 /*
55  * The maximum payload length the driver can handle.
56  *
57  * - If CC1200_MAX_PAYLOAD_LEN <= 125 and CC1200_USE_GPIO2 == 0, we read
58  * out the RX FIFO at the end of the packet. RXOFF_MODE is set to RX in this
59  * case.
60  * - If 125 < CC1200_MAX_PAYLOAD_LEN <= 127 and CC1200_USE_GPIO2 == 0, we
61  * also read out the RX FIFO at the end of the packet, but read out
62  * RSSI + LQI "by hand". In this case, we also have to restart RX
63  * manually because RSSI + LQI are overwritten as soon as RX re-starts.
64  * This will lead to an increased RX/RX turnaround time.
65  * - If CC1200_USE_GPIO2 is set, we can use an arbitrary payload length
66  * (only limited by the payload length defined in the phy header).
67  *
68  * See below for 802.15.4g support.
69  */
70 #ifdef CC1200_CONF_MAX_PAYLOAD_LEN
71 #define CC1200_MAX_PAYLOAD_LEN CC1200_CONF_MAX_PAYLOAD_LEN
72 #else
73 #define CC1200_MAX_PAYLOAD_LEN 125
74 #endif
75 
76 #define cc1200_driver_max_payload_len CC1200_MAX_PAYLOAD_LEN
77 /*---------------------------------------------------------------------------*/
78 /*
79  * The RX watchdog is used to check whether the radio is in RX mode at regular
80  * intervals (once per second). Can be used to improve reliability especially
81  * if CSMA is used. Turned of by default.
82  */
83 #ifdef CC1200_CONF_USE_RX_WATCHDOG
84 #define CC1200_USE_RX_WATCHDOG CC1200_CONF_USE_RX_WATCHDOG
85 #else
86 #define CC1200_USE_RX_WATCHDOG 0
87 #endif
88 /*---------------------------------------------------------------------------*/
89 /*
90  * Use 802.15.4g frame format? Supports frame lenghts up to 2047 bytes!
91  */
92 #ifdef CC1200_CONF_802154G
93 #define CC1200_802154G CC1200_CONF_802154G
94 #else
95 #define CC1200_802154G 0
96 #endif
97 /*---------------------------------------------------------------------------*/
98 /*
99  * Do we use withening in 802.15.4g mode? Set to 1 if enabled, 0 otherwise.
100  */
101 #ifdef CC1200_CONF_802154G_WHITENING
102 #define CC1200_802154G_WHITENING CC1200_CONF_802154G_WHITENING
103 #else
104 #define CC1200_802154G_WHITENING 0
105 #endif
106 /*---------------------------------------------------------------------------*/
107 /*
108  * Do we use CRC16 in 802.15.4g mode? Set to 1 if enabled, 0 otherwise.
109  *
110  * It set to 0, we use FCS type 0: CRC32.
111  */
112 #ifdef CC1200_CONF_802154G_CRC16
113 #define CC1200_802154G_CRC16 CC1200_CONF_802154G_CRC16
114 #else
115 /* Use FCS type 0: CRC32 */
116 #define CC1200_802154G_CRC16 0
117 #endif
118 /*---------------------------------------------------------------------------*/
119 /* The RF configuration to be used. */
120 #ifdef CC1200_CONF_RF_CFG
121 #define CC1200_RF_CFG CC1200_CONF_RF_CFG
122 #else
123 #define CC1200_RF_CFG cc1200_802154g_863_870_fsk_50kbps
124 #endif
125 /*---------------------------------------------------------------------------*/
126 /*
127  * The frequency offset
128  *
129  * Might be hardware dependent (e.g. depending on crystal load capacitances),
130  * so we make it a configuration parameter. Written to FREQOFF1 / FREQOFF2.
131  * Signed 16 bit number, see cc1200 user's guide.
132  *
133  * TODO: Make it a parameter for set_value() / get_value()
134  */
135 #ifdef CC1200_CONF_FREQ_OFFSET
136 #define CC1200_FREQ_OFFSET CC1200_CONF_FREQ_OFFSET
137 #else
138 #define CC1200_FREQ_OFFSET (0)
139 #endif
140 /*---------------------------------------------------------------------------*/
141 /*
142  * The default channel to use.
143  *
144  * Permitted values depending on the data rate + band used are defined
145  * in the appropriate rf configuration file. Make sure the default value
146  * is within these limits!
147  */
148 #ifdef CC1200_CONF_DEFAULT_CHANNEL
149 #define CC1200_DEFAULT_CHANNEL CC1200_CONF_DEFAULT_CHANNEL
150 #else
151 /* 868.325 MHz */
152 #define CC1200_DEFAULT_CHANNEL 26
153 #endif
154 /*---------------------------------------------------------------------------*/
155 /*
156  * Wether to use auto calibration or not.
157  *
158  * If set to 0, calibration is performed manually when turning the radio
159  * on (on()), when transmitting (transmit()) or when changing the channel.
160  * Enabling auto calibration will increase turn around times +
161  * energy consumption. If enabled, we calibrate every time we go from
162  * IDLE to RX or TX.
163  * When RDC or channel hopping is used, there is no need to turn calibration
164  * on because either on() is called frequently or the channel is updated.
165  */
166 #ifdef CC1200_CONF_AUTOCAL
167 #define CC1200_AUTOCAL CC1200_CONF_AUTOCAL
168 #else
169 #define CC1200_AUTOCAL 0
170 #endif
171 /*---------------------------------------------------------------------------*/
172 /*
173  * If CC1200_AUTOCAL is not set, we use this parameter to defer
174  * calibration until a certain amount of time has expired.
175  *
176  * This is what happens in detail:
177  *
178  * - We (manually) calibrate once after initialization
179  * - We (manually) calibrate every time we change the channel
180  * - We (manually) calibrate when the radio is turned on() only if
181  * the timeout has expired
182  * - We (manually) calibrate when transmitting only of the timeout has expired
183  *
184  * Set this parameter to 0 when this feature is not used. In this case we
185  * (manually) calibrate in all situations mentioned above.
186  */
187 #ifdef CC1200_CONF_CAL_TIMEOUT_SECONDS
188 #define CC1200_CAL_TIMEOUT_SECONDS CC1200_CONF_CAL_TIMEOUT_SECONDS
189 #else
190 /* Calibrate at the latest every 15 minutes */
191 #define CC1200_CAL_TIMEOUT_SECONDS 900
192 #endif
193 /*---------------------------------------------------------------------------*/
194 /*
195  * If defined, use these LEDS to indicate TX activity
196  *
197  * The LEDs are turned on once the radio enters TX mode
198  * (together with ENERGEST_ON(ENERGEST_TYPE_TRANSMIT),
199  * and turned of as soon as TX has completed.
200  */
201 #ifdef CC1200_CONF_TX_LEDS
202 #define CC1200_TX_LEDS CC1200_CONF_TX_LEDS
203 #endif
204 /*---------------------------------------------------------------------------*/
205 /*
206  * If defined, use these LEDS to indicate RX activity
207  *
208  * The LEDs are turned on as soon as the first byte is read out from
209  * the RX FIFO
210  */
211 #ifdef CC1200_CONF_RX_LED
212 #define CC1200_RX_LEDS CC1200_CONF_RX_LEDS
213 #endif
214 /*---------------------------------------------------------------------------*/
215 
216 #endif /* CC1200_H_ */