Contiki 3.x
cc2530-rf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, George Oikonomou - <oikonomou@users.sourceforge.net>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  */
31 
32 /**
33  * \file
34  * Implementation of the cc2530 RF driver
35  *
36  * \author
37  * George Oikonomou - <oikonomou@users.sourceforge.net>
38  */
39 #ifndef CC2530_RF_H_
40 #define CC2530_RF_H_
41 
42 #include "contiki.h"
43 #include "dev/radio.h"
44 #include "cc253x.h"
45 /*---------------------------------------------------------------------------
46  * RF Config
47  *---------------------------------------------------------------------------*/
48 #define CC2530_RF_TX_POWER_RECOMMENDED 0xD5
49 #ifdef CC2530_RF_CONF_TX_POWER
50 #define CC2530_RF_TX_POWER CC2530_RF_CONF_TX_POWER
51 #else
52 #define CC2530_RF_TX_POWER CC2530_RF_TX_POWER_RECOMMENDED
53 #endif /* CC2530_RF_CONF_TX_POWER */
54 
55 #ifdef CC2530_RF_CONF_CCA_THRES
56 #define CC2530_RF_CCA_THRES CC2530_RF_CONF_CCA_THRES
57 #else
58 #define CC2530_RF_CCA_THRES CCA_THRES_USER_GUIDE /* User guide recommendation */
59 #endif /* CC2530_RF_CONF_CCA_THRES */
60 
61 #ifdef CC2530_RF_CONF_CHANNEL
62 #define CC2530_RF_CHANNEL CC2530_RF_CONF_CHANNEL
63 #else
64 #define CC2530_RF_CHANNEL 18
65 #endif /* CC2530_RF_CONF_CHANNEL */
66 #define CC2530_RF_CHANNEL_MIN 11
67 #define CC2530_RF_CHANNEL_MAX 26
68 #define CC2530_RF_CHANNEL_SPACING 5
69 
70 #ifdef CC2530_RF_CONF_AUTOACK
71 #define CC2530_RF_AUTOACK CC2530_RF_CONF_AUTOACK
72 #else
73 #define CC2530_RF_AUTOACK 1
74 #endif /* CC2530_RF_CONF_AUTOACK */
75 
76 #ifdef CC2530_RF_CONF_LOW_POWER_RX
77 #define CC2530_RF_LOW_POWER_RX CC2530_RF_CONF_LOW_POWER_RX
78 #else
79 #define CC2530_RF_LOW_POWER_RX 0
80 #endif /* CC2530_RF_CONF_LOW_POWER_RX */
81 /*---------------------------------------------------------------------------*/
82 #define CCA_THRES_USER_GUIDE 0xF8
83 #define CCA_THRES_ALONE 0xFC /* -4-76=-80dBm when CC2530 operated alone or with CC2591 in LGM */
84 #define CCA_THR_HGM 0x06 /* 6-76=-70dBm when CC2530 operated with CC2591 in HGM */
85 #define CORR_THR 0x14
86 /*---------------------------------------------------------------------------*/
87 #define CC2530_RF_MAX_PACKET_LEN 127
88 #define CC2530_RF_MIN_PACKET_LEN 4
89 /*---------------------------------------------------------------------------*/
90 #define CC2530_RF_CCA_CLEAR 1
91 #define CC2530_RF_CCA_BUSY 0
92 
93 /* Wait for RSSI to be valid. */
94 #define CC2530_RF_CCA_VALID_WAIT() while(!(RSSISTAT & RSSIST))
95 /*---------------------------------------------------------------------------
96  * Command Strobe Processor
97  *---------------------------------------------------------------------------*/
98 /* OPCODES */
99 #define CSP_OP_ISRXON 0xE3
100 #define CSP_OP_ISTXON 0xE9
101 #define CSP_OP_ISTXONCCA 0xEA
102 #define CSP_OP_ISRFOFF 0xEF
103 #define CSP_OP_ISFLUSHRX 0xED
104 #define CSP_OP_ISFLUSHTX 0xEE
105 
106 #define CC2530_CSP_ISRXON() do { RFST = CSP_OP_ISRXON; } while(0)
107 #define CC2530_CSP_ISTXON() do { RFST = CSP_OP_ISTXON; } while(0)
108 #define CC2530_CSP_ISTXONCCA() do { RFST = CSP_OP_ISTXONCCA; } while(0)
109 #define CC2530_CSP_ISRFOFF() do { RFST = CSP_OP_ISRFOFF; } while(0)
110 
111 /* OP x 2 for flushes */
112 #define CC2530_CSP_ISFLUSHRX() do { \
113  RFST = CSP_OP_ISFLUSHRX; \
114  RFST = CSP_OP_ISFLUSHRX; \
115 } while(0)
116 #define CC2530_CSP_ISFLUSHTX() do { \
117  RFST = CSP_OP_ISFLUSHTX; \
118  RFST = CSP_OP_ISFLUSHTX; \
119 } while(0)
120 /*---------------------------------------------------------------------------*/
121 extern const struct radio_driver cc2530_rf_driver;
122 /*---------------------------------------------------------------------------*/
123 void cc2530_rf_set_addr(uint16_t pan);
124 /*---------------------------------------------------------------------------*/
125 #endif /* CC2530_RF_H_ */
Header file for the radio API
The structure of a device driver for a radio in Contiki.
Definition: radio.h:225
Definitions for TI/Chipcon cc2530, cc2531 and cc2533 SFR registers.