Contiki-NG
cc2538-rf.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
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 * \addtogroup cc2538
33 * @{
34 *
35 * \defgroup cc2538-rf cc2538 RF Driver
36 *
37 * Driver implementation for the cc2538 RF transceiver
38 * @{
39 *
40 * \file
41 * Header file for the cc2538 RF driver
42 */
43#ifndef CC2538_RF_H__
44#define CC2538_RF_H__
45
46#include "contiki.h"
47#include "dev/radio.h"
48#include "dev/rfcore.h"
49#include "reg.h"
50/*---------------------------------------------------------------------------
51 * RF Config
52 *---------------------------------------------------------------------------*/
53/* Constants */
54#define CC2538_RF_CCA_THRES_USER_GUIDE 0xF8
55#define CC2538_RF_TX_POWER_RECOMMENDED 0xD5 /* ToDo: Determine value */
56#define CC2538_RF_CHANNEL_MIN 11
57#define CC2538_RF_CHANNEL_MAX 26
58#define CC2538_RF_CHANNEL_SPACING 5
59#define CC2538_RF_MAX_PACKET_LEN 127
60#define CC2538_RF_MIN_PACKET_LEN 4
61#define CC2538_RF_CCA_CLEAR 1
62#define CC2538_RF_CCA_BUSY 0
63/*---------------------------------------------------------------------------*/
64#ifdef CC2538_RF_CONF_TX_POWER
65#define CC2538_RF_TX_POWER CC2538_RF_CONF_TX_POWER
66#else
67#define CC2538_RF_TX_POWER CC2538_RF_TX_POWER_RECOMMENDED
68#endif /* CC2538_RF_CONF_TX_POWER */
69
70#ifdef CC2538_RF_CONF_CCA_THRES
71#define CC2538_RF_CCA_THRES CC2538_RF_CONF_CCA_THRES
72#else
73#define CC2538_RF_CCA_THRES CC2538_RF_CCA_THRES_USER_GUIDE
74#endif /* CC2538_RF_CONF_CCA_THRES */
75
76#ifdef CC2538_RF_CONF_AUTOACK
77#define CC2538_RF_AUTOACK CC2538_RF_CONF_AUTOACK
78#else
79#define CC2538_RF_AUTOACK 1
80#endif /* CC2538_RF_CONF_AUTOACK */
81/*---------------------------------------------------------------------------
82 * Command Strobe Processor
83 *---------------------------------------------------------------------------*/
84/* OPCODES */
85#define CC2538_RF_CSP_OP_ISRXON 0xE3
86#define CC2538_RF_CSP_OP_ISTXON 0xE9
87#define CC2538_RF_CSP_OP_ISTXONCCA 0xEA
88#define CC2538_RF_CSP_OP_ISRFOFF 0xEF
89#define CC2538_RF_CSP_OP_ISFLUSHRX 0xED
90#define CC2538_RF_CSP_OP_ISFLUSHTX 0xEE
91
92/**
93 * \brief Send an RX ON command strobe to the CSP
94 */
95#define CC2538_RF_CSP_ISRXON() \
96 do { REG(RFCORE_SFR_RFST) = CC2538_RF_CSP_OP_ISRXON; } while(0)
97
98/**
99 * \brief Send a TX ON command strobe to the CSP
100 */
101#define CC2538_RF_CSP_ISTXON() \
102 do { REG(RFCORE_SFR_RFST) = CC2538_RF_CSP_OP_ISTXON; } while(0)
103
104/**
105 * \brief Send a RF OFF command strobe to the CSP
106 */
107#define CC2538_RF_CSP_ISRFOFF() \
108 do { REG(RFCORE_SFR_RFST) = CC2538_RF_CSP_OP_ISRFOFF; } while(0)
109
110/**
111 * \brief Flush the RX FIFO
112 */
113#define CC2538_RF_CSP_ISFLUSHRX() do { \
114 REG(RFCORE_SFR_RFST) = CC2538_RF_CSP_OP_ISFLUSHRX; \
115} while(0)
116
117/**
118 * \brief Flush the TX FIFO
119 */
120#define CC2538_RF_CSP_ISFLUSHTX() do { \
121 REG(RFCORE_SFR_RFST) = CC2538_RF_CSP_OP_ISFLUSHTX; \
122} while(0)
123/*---------------------------------------------------------------------------*/
124/** The NETSTACK data structure for the cc2538 RF driver */
125extern const struct radio_driver cc2538_rf_driver;
126/*---------------------------------------------------------------------------*/
127/**
128 * \brief Sets addresses and PAN identifier to the relevant RF hardware
129 * registers
130 * \param pan The PAN Identifier
131 *
132 * Values for short and extended addresses are not needed as parameters
133 * since they exist in the linkaddr buffer in the contiki core. They
134 * are thus simply copied over from there.
135 */
136void cc2538_rf_set_addr(uint16_t pan);
137
138/*---------------------------------------------------------------------------*/
139#endif /* CC2538_RF_H__ */
140
141/**
142 * @}
143 * @}
144 */
const struct radio_driver cc2538_rf_driver
The NETSTACK data structure for the cc2538 RF driver.
Definition: cc2538-rf.c:1127
void cc2538_rf_set_addr(uint16_t pan)
Sets addresses and PAN identifier to the relevant RF hardware registers.
Header file for the radio API.
Header file with register manipulation macro definitions.
Top-level header file for cc2538 RF Core registers.
The structure of a Contiki-NG radio device driver.
Definition: radio.h:534