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