cc2520: Initial checkin for TI CC2520 802.15.4 driver

Integrating it into network stack. Centralizing all in drivers/802.15.4

Change-Id: Ia2916ff652afe5fe736f6560c2ed4a911a5f0679
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2015-09-11 16:13:26 +03:00 committed by Anas Nashif
commit f1563253cf
13 changed files with 1799 additions and 8 deletions

60
drivers/802.15.4/Kconfig Normal file
View file

@ -0,0 +1,60 @@
# Kconfig - IEEE 802.15.4 driver configuration options
#
# Copyright (c) 2015 Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1) Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2) Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3) Neither the name of Intel Corporation nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#
# IEEE 802.15.4 options
#
menu "IEEE 802.15.4 Options"
depends on NETWORKING_WITH_15_4
if NETWORKING_WITH_15_4_TI_CC2520
config TI_CC2520_SYMBOL_LOOP_COUNT
int
prompt "CC2520 symbol loop count"
default 20
help
Maximum number of symbols to wait before the transmission can start.
Note that we may have to wait up to 320 us (20 symbols) before the
transmission starts.
config TI_CC2520_DEBUG
bool
prompt "CC2520 driver debug"
default n
help
This option enables debug support for 802.15.4 CC2520
driver
endif
endmenu

View file

@ -0,0 +1,6 @@
subdir-ccflags-y +=-I${srctree}/net/ip/contiki
subdir-ccflags-y +=-I${srctree}/net/ip/contiki/os/lib
subdir-ccflags-y +=-I${srctree}/net/ip/contiki/os
subdir-ccflags-y +=-I${srctree}/net/ip
obj-$(CONFIG_NETWORKING_WITH_15_4_TI_CC2520)=cc2520.o

1136
drivers/802.15.4/cc2520.c Normal file

File diff suppressed because it is too large Load diff

232
drivers/802.15.4/cc2520.h Normal file
View file

@ -0,0 +1,232 @@
/* cc2520.h - IEEE 802.15.4 driver for TI CC2520 */
/*
* Copyright (c) 2015 Intel Corporation.
*
* Copyright (c) 2011, Swedish Institute of Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2) Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3) Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __CC2520_CONST_H__
#define __CC2520_CONST_H__
/*
* All constants are from the Chipcon cc2520 Data Sheet that at one
* point in time could be found at
* http://www.chipcon.com/files/cc2520_Data_Sheet_1_4.pdf
*
* The page numbers below refer to pages in this document.
*/
/* Page 27. */
enum cc2520_status_byte {
CC2520_XOSC16M_STABLE = 7,
CC2520_RSSI_VALID = 6,
CC2520_EXCEPTION_CHA = 5,
CC2520_EXCEPTION_CHB = 4,
CC2520_DPU_H = 3,
CC2520_DPU_L = 2,
CC2520_TX_ACTIVE = 1,
CC2520_RX_ACTIVE = 0,
};
#define TX_FRM_DONE 0x02
#define RX_FRM_DONE 0x01
#define RX_FRM_ABORTED 0x20
#define RX_FRM_UNDERFLOW 0x20
enum cc2520_radio_status {
CC2520_STATUS_FIFO = 7,
CC2520_STATUS_FIFOP = 6,
CC2520_STATUS_SFD = 5,
CC2520_STATUS_CCA = 4,
CC2520_STATUS_SAMPLED_CCA = 3,
CC2520_STATUS_LOCK_STATUS = 2,
CC2520_STATUS_TX_ACTIVE = 1,
CC2520_STATUS_RX_ACTIVE = 0,
};
/* Page 27. */
enum cc2520_memory_size {
CC2520_RAM_SIZE = 640,
CC2520_FIFO_SIZE = 128,
};
/* Page 29. */
enum cc2520_address {
CC2520RAM_TXFIFO = 0x100,
CC2520RAM_RXFIFO = 0x180,
CC2520RAM_IEEEADDR = 0x3EA,
CC2520RAM_PANID = 0x3F2,
CC2520RAM_SHORTADDR = 0x3F4,
};
/* IEEE 802.15.4 defined constants (2.4 GHz logical channels) */
#define MIN_CHANNEL 11 /* 2405 MHz */
#define MAX_CHANNEL 26 /* 2480 MHz */
#define CHANNEL_SPACING 5 /* MHz */
/* FREG definitions (BSET/BCLR supported) */
#define CC2520_FRMFILT0 0x000
#define CC2520_FRMFILT1 0x001
#define CC2520_SRCMATCH 0x002
#define CC2520_SRCSHORTEN0 0x004
#define CC2520_SRCSHORTEN1 0x005
#define CC2520_SRCSHORTEN2 0x006
#define CC2520_SRCEXTEN0 0x008
#define CC2520_SRCEXTEN1 0x009
#define CC2520_SRCEXTEN2 0x00A
#define CC2520_FRMCTRL0 0x00C
#define CC2520_FRMCTRL1 0x00D
#define CC2520_RXENABLE0 0x00E
#define CC2520_RXENABLE1 0x00F
#define CC2520_EXCFLAG0 0x010
#define CC2520_EXCFLAG1 0x011
#define CC2520_EXCFLAG2 0x012
#define CC2520_EXCMASKA0 0x014
#define CC2520_EXCMASKA1 0x015
#define CC2520_EXCMASKA2 0x016
#define CC2520_EXCMASKB0 0x018
#define CC2520_EXCMASKB1 0x019
#define CC2520_EXCMASKB2 0x01A
#define CC2520_EXCBINDX0 0x01C
#define CC2520_EXCBINDX1 0x01D
#define CC2520_EXCBINDY0 0x01E
#define CC2520_EXCBINDY1 0x01F
#define CC2520_GPIOCTRL0 0x020
#define CC2520_GPIOCTRL1 0x021
#define CC2520_GPIOCTRL2 0x022
#define CC2520_GPIOCTRL3 0x023
#define CC2520_GPIOCTRL4 0x024
#define CC2520_GPIOCTRL5 0x025
#define CC2520_GPIOPOLARITY 0x026
#define CC2520_GPIOCTRL 0x028
#define CC2520_DPUCON 0x02A
#define CC2520_DPUSTAT 0x02C
#define CC2520_FREQCTRL 0x02E
#define CC2520_FREQTUNE 0x02F
#define CC2520_TXPOWER 0x030
#define CC2520_TXCTRL 0x031
#define CC2520_FSMSTAT0 0x032
#define CC2520_FSMSTAT1 0x033
#define CC2520_FIFOPCTRL 0x034
#define CC2520_FSMCTRL 0x035
#define CC2520_CCACTRL0 0x036
#define CC2520_CCACTRL1 0x037
#define CC2520_RSSI 0x038
#define CC2520_RSSISTAT 0x039
#define CC2520_TXFIFO_BUF 0x03A
#define CC2520_RXFIRST 0x03C
#define CC2520_RXFIFOCNT 0x03E
#define CC2520_TXFIFOCNT 0x03F
/* SREG definitions (BSET/BCLR unsupported) */
#define CC2520_CHIPID 0x040
#define CC2520_VERSION 0x042
#define CC2520_EXTCLOCK 0x044
#define CC2520_MDMCTRL0 0x046
#define CC2520_MDMCTRL1 0x047
#define CC2520_FREQEST 0x048
#define CC2520_RXCTRL 0x04A
#define CC2520_FSCTRL 0x04C
#define CC2520_FSCAL0 0x04E
#define CC2520_FSCAL1 0x04F
#define CC2520_FSCAL2 0x050
#define CC2520_FSCAL3 0x051
#define CC2520_AGCCTRL0 0x052
#define CC2520_AGCCTRL1 0x053
#define CC2520_AGCCTRL2 0x054
#define CC2520_AGCCTRL3 0x055
#define CC2520_ADCTEST0 0x056
#define CC2520_ADCTEST1 0x057
#define CC2520_ADCTEST2 0x058
#define CC2520_MDMTEST0 0x05A
#define CC2520_MDMTEST1 0x05B
#define CC2520_DACTEST0 0x05C
#define CC2520_DACTEST1 0x05D
#define CC2520_ATEST 0x05E
#define CC2520_DACTEST2 0x05F
#define CC2520_PTEST0 0x060
#define CC2520_PTEST1 0x061
#define CC2520_RESERVED 0x062
#define CC2520_DPUBIST 0x07A
#define CC2520_ACTBIST 0x07C
#define CC2520_RAMBIST 0x07E
/* Instruction implementation */
#define CC2520_INS_SNOP 0x00
#define CC2520_INS_IBUFLD 0x02
#define CC2520_INS_SIBUFEX 0x03
#define CC2520_INS_SSAMPLECCA 0x04
#define CC2520_INS_SRES 0x0F
#define CC2520_INS_MEMRD 0x10
#define CC2520_INS_MEMWR 0x20
#define CC2520_INS_RXBUF 0x30
#define CC2520_INS_RXBUFCP 0x38
#define CC2520_INS_RXBUFMOV 0x32
#define CC2520_INS_TXBUF 0x3A
#define CC2520_INS_TXBUFCP 0x3E
#define CC2520_INS_RANDOM 0x3C
#define CC2520_INS_SXOSCON 0x40
#define CC2520_INS_STXCAL 0x41
#define CC2520_INS_SRXON 0x42
#define CC2520_INS_STXON 0x43
#define CC2520_INS_STXONCCA 0x44
#define CC2520_INS_SRFOFF 0x45
#define CC2520_INS_SXOSCOFF 0x46
#define CC2520_INS_SFLUSHRX 0x47
#define CC2520_INS_SFLUSHTX 0x48
#define CC2520_INS_SACK 0x49
#define CC2520_INS_SACKPEND 0x4A
#define CC2520_INS_SNACK 0x4B
#define CC2520_INS_SRXMASKBITSET 0x4C
#define CC2520_INS_SRXMASKBITCLR 0x4D
#define CC2520_INS_RXMASKAND 0x4E
#define CC2520_INS_RXMASKOR 0x4F
#define CC2520_INS_MEMCP 0x50
#define CC2520_INS_MEMCPR 0x52
#define CC2520_INS_MEMXCP 0x54
#define CC2520_INS_MEMXWR 0x56
#define CC2520_INS_BCLR 0x58
#define CC2520_INS_BSET 0x59
#define CC2520_INS_CTR 0x60
#define CC2520_INS_CBCMAC 0x64
#define CC2520_INS_UCBCMAC 0x66
#define CC2520_INS_CCM 0x68
#define CC2520_INS_UCCM 0x6A
#define CC2520_INS_ECB 0x70
#define CC2520_INS_ECBO 0x72
#define CC2520_INS_ECBX 0x74
#define CC2520_INS_ECBXO 0x76
#define CC2520_INS_INC 0x78
#define CC2520_INS_ABORT 0x7F
#define CC2520_INS_REGRD 0x80
#define CC2520_INS_REGWR 0xC0
#endif /* __CC2520_CONST_H__ */

View file

@ -0,0 +1,281 @@
/* cc2520_arch.h - TI CC2520 arch/driver model specific header */
/*
* Copyright (c) 2015 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* You should not include this file directly and it should only be
* included by board.h file.
*/
#ifndef __CC2520_ARCH_H__
#define __CC2520_ARCH_H__
#include <nanokernel.h>
#include <stdbool.h>
#include <string.h>
#include <spi.h>
#include <gpio.h>
#include "cc2520.h"
#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define CC2520_PRINT printf
#else
#include <misc/printk.h>
#define CC2520_PRINT printk
#endif
#if CONFIG_TI_CC2520_DEBUG
#define CC2520_PRINTF(...) CC2520_PRINT(__VA_ARGS__)
#else
#define CC2520_PRINTF(...)
#endif
#ifndef CLOCK_CYCLE_LT
#define CLOCK_CYCLE_LT(a, b) ((signed)((a)-(b)) < 0)
#endif
#ifndef CLOCK_MSEC_TO_CYCLES
#define CLOCK_MSEC_TO_CYCLES(msec) \
((msec) * sys_clock_hw_cycles_per_tick * \
sys_clock_us_per_tick / 1000)
#endif
#define CONFIG_CC2520_DRV_NAME "CC2520"
struct cc2520_gpio_config {
struct device *gpio;
};
struct cc2520_config {
struct cc2520_gpio_config **gpios;
struct device *spi;
};
extern struct cc2520_gpio_config cc2520_gpio_config[CC2520_GPIO_IDX_LAST_ENTRY];
extern struct cc2520_config cc2520_config;
typedef void (*cc2520_gpio_int_handler_t)(struct device *port, uint32_t pin);
struct device *cc2520_spi_configure(void);
struct cc2520_gpio_config **cc2520_gpio_configure(void);
#define CC2520_GPIO(p) \
(((struct device *)& \
((struct cc2520_config *) \
device_get_binding(CONFIG_CC2520_DRV_NAME)-> \
config->config_info)->gpios[CC2520_GPIO_IDX_ ## p]->gpio))
#define CC2520_SPI() \
(((struct cc2520_config *) \
device_get_binding(CONFIG_CC2520_DRV_NAME)-> \
config->config_info)->spi)
static inline bool cc2520_read_fifo_buf(uint8_t *buffer, uint32_t count)
{
uint8_t data[128 + 1] = { 0xff };
int ret;
data[0] = CC2520_INS_RXBUF;
ret = spi_transceive(CC2520_SPI(), data, sizeof(data),
data, sizeof(data));
memcpy(buffer, data + 1, count);
return (!ret);
}
static inline bool cc2520_write_fifo_buf(uint8_t *buffer, int count)
{
uint8_t data[128 + 1];
if (count > (sizeof(data) - 1)) {
CC2520_PRINTF("%s: too long data %d, max is %d\n", __func__,
count, sizeof(data) - 1);
return false;
}
data[0] = CC2520_INS_TXBUF;
memcpy(&data[1], buffer, count);
return (!spi_write(CC2520_SPI(), data, count + 1));
}
static inline bool cc2520_write_reg(uint16_t addr, uint16_t value)
{
uint8_t data[3];
data[0] = CC2520_INS_MEMWR | ((addr >> 8) & 0x0f);
data[1] = addr;
data[2] = value;
return (!spi_write(CC2520_SPI(), data, 3));
}
static inline bool cc2520_read_reg(uint16_t addr, uint16_t *value)
{
uint8_t data[3];
int ret;
data[0] = CC2520_INS_MEMRD | ((addr >> 8) & 0x0f);
data[1] = addr;
data[2] = 0;
ret = spi_transceive(CC2520_SPI(), data, 3, data, 3);
*value = data[2];
return (!ret);
}
static inline bool cc2520_write_ram(uint8_t *buffer, int addr, int count)
{
uint8_t data[128 + 1 + 1];
if (count > (sizeof(data) - 2)) {
CC2520_PRINTF("%s: too long data %d, max is %d\n",
__func__, count, sizeof(data) - 2);
return false;
}
data[0] = CC2520_INS_MEMWR | (addr >> 8);
data[1] = addr;
memcpy(&data[2], buffer, count);
return (!spi_write(CC2520_SPI(), data, count + 2));
}
static inline bool cc2520_read_ram(uint8_t *buffer, int addr, uint32_t count)
{
uint8_t data[128 + 1 + 1] = { 0 };
int ret;
data[0] = CC2520_INS_MEMRD | (addr >> 8);
data[1] = addr;
ret = spi_transceive(CC2520_SPI(), data, sizeof(data),
data, sizeof(data));
memcpy(buffer, data + 2, count);
return (!ret);
}
static inline bool cc2520_get_status(uint8_t *status)
{
uint8_t data[1];
data[0] = CC2520_INS_SNOP;
return (!spi_transceive(CC2520_SPI(), data, 1, status, 1));
}
static inline bool cc2520_strobe(uint8_t strobe)
{
uint8_t data[1];
data[0] = strobe;
return (!spi_write(CC2520_SPI(), data, 1));
}
static inline bool cc2520_strobe_plus_nop(uint8_t strobe)
{
uint8_t data[2];
data[0] = strobe;
data[1] = CC2520_INS_SNOP;
return (!spi_write(CC2520_SPI(), data, 2));
}
static inline int cc2520_get_fifop(void)
{
uint32_t value;
gpio_pin_read(CC2520_GPIO(FIFOP), CONFIG_CC2520_GPIO_FIFOP, &value);
return value;
}
static inline int cc2520_get_fifo(void)
{
uint32_t value;
gpio_pin_read(CC2520_GPIO(FIFO), CONFIG_CC2520_GPIO_FIFO, &value);
return value;
}
static inline int cc2520_get_sfd(void)
{
uint32_t value;
gpio_pin_read(CC2520_GPIO(SFD), CONFIG_CC2520_GPIO_SFD, &value);
return value;
}
static inline int cc2520_get_cca(void)
{
uint32_t value;
gpio_pin_read(CC2520_GPIO(CCA), CONFIG_CC2520_GPIO_CCA, &value);
return value;
}
static inline void cc2520_set_vreg(int enable)
{
/* If VREG_EN is connected to VDD, then set the gpio pointer
* to NULL and do not configure.
*/
if (!CC2520_GPIO(VREG)) {
return;
}
gpio_pin_write(CC2520_GPIO(VREG), CONFIG_CC2520_GPIO_VREG, enable);
}
static inline void cc2520_set_reset(int enable)
{
gpio_pin_write(CC2520_GPIO(RESET), CONFIG_CC2520_GPIO_RESET, enable);
}
static inline void cc2520_enable_fifop_int(int enable)
{
CC2520_PRINTF("%s FIFOP\n", enable ? "enable" : "disable");
if (enable) {
gpio_pin_enable_callback(CC2520_GPIO(FIFOP),
CONFIG_CC2520_GPIO_FIFOP);
} else {
gpio_pin_disable_callback(CC2520_GPIO(FIFOP),
CONFIG_CC2520_GPIO_FIFOP);
}
}
static inline void cc2520_clear_fifop_int(void)
{
/* Do nothing */
}
static inline void cc2520_init_fifop_int(cc2520_gpio_int_handler_t handler)
{
gpio_set_callback(CC2520_GPIO(FIFOP), handler);
}
#endif /* __CC2520_ARCH_H__ */

View file

@ -21,6 +21,8 @@ menu "Device Drivers"
source "drivers/bluetooth/Kconfig" source "drivers/bluetooth/Kconfig"
source "drivers/802.15.4/Kconfig"
source "drivers/console/Kconfig" source "drivers/console/Kconfig"
source "drivers/ethernet/Kconfig" source "drivers/ethernet/Kconfig"

View file

@ -15,6 +15,7 @@ obj-$(CONFIG_I2C) += i2c/
obj-$(CONFIG_PWM) += pwm/ obj-$(CONFIG_PWM) += pwm/
obj-$(CONFIG_ADC) += adc/ obj-$(CONFIG_ADC) += adc/
obj-$(CONFIG_ETHERNET) += ethernet/ obj-$(CONFIG_ETHERNET) += ethernet/
obj-$(CONFIG_NETWORKING_WITH_15_4) += 802.15.4/
obj-$(CONFIG_WATCHDOG) += watchdog/ obj-$(CONFIG_WATCHDOG) += watchdog/
obj-$(CONFIG_RTC) += rtc/ obj-$(CONFIG_RTC) += rtc/
obj-$(CONFIG_CLOCK_CONTROL) += clock_control/ obj-$(CONFIG_CLOCK_CONTROL) += clock_control/

View file

@ -0,0 +1,52 @@
/* cc2520.h - Public utilities for TI CC2520 (IEEE 802.15.4) */
/*
* Copyright (c) 2015 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CC2520_H__
#define __CC2520_H__
#include <stdbool.h>
#include "dev/radio.h"
#define CC2520_MAX_PACKET_LEN 127
/* extern signed char cc2520_last_rssi; */
/* extern uint8_t cc2520_last_correlation; */
radio_result_t cc2520_get_value(radio_param_t param, radio_value_t *value);
radio_result_t cc2520_set_value(radio_param_t param, radio_value_t value);
int cc2520_set_channel(int channel);
int cc2520_get_channel(void);
bool cc2520_set_pan_addr(unsigned pan,
unsigned addr,
const uint8_t *ieee_addr);
int cc2520_rssi(void);
void cc2520_set_cca_threshold(int value);
/* Power is between 1 and 31 */
void cc2520_set_txpower(uint8_t power);
int cc2520_get_txpower(void);
#define CC2520_TXPOWER_MAX 31
#define CC2520_TXPOWER_MIN 0
typedef struct radio_driver cc2520_driver_api_t;
#endif /* __CC2520_H__ */

View file

@ -247,16 +247,23 @@ default n
help help
The 802.15.4 layer can either support loopback within The 802.15.4 layer can either support loopback within
or loopback with uart but not both at the same time. or loopback with uart but not both at the same time.
config NETWORKING_WITH_15_4_TI_CC2520
bool
prompt "TI CC2520"
select CONFIG_NETWORKING_WITH_15_4
help
Enable Texas Instruments CC2520 802.15.4 radio driver.
config NETWORKING_WITH_15_4_LOOPBACK config NETWORKING_WITH_15_4_LOOPBACK
bool bool
prompt "Enable 802.15.4 loopback radio driver" prompt "Loopback"
help help
Enable 802.15.4 loopback radio driver that receives Enable 802.15.4 loopback radio driver that receives
the 802.15.4 frame and put it back 802.15.4 Rx Fifo. the 802.15.4 frame and put it back 802.15.4 Rx Fifo.
config NETWORKING_WITH_15_4_LOOPBACK_UART config NETWORKING_WITH_15_4_LOOPBACK_UART
bool bool
prompt "Enable 802.15.4 loopback radio uart driver" prompt "Loopback with UART"
select UART_PIPE select UART_PIPE
help help
Enable 802.15.4 loopback radio driver that sends Enable 802.15.4 loopback radio driver that sends

View file

@ -0,0 +1,8 @@
#ifndef CC2520154RADIO_H
#define CC2520154RADIO_H
#include "dev/radio.h"
extern const struct radio_driver cc2520_15_4_radio_driver;
#endif /* CC2520154RADIO_H */

View file

@ -95,8 +95,16 @@ typedef unsigned int uip_stats_t;
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_IPHC #define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_IPHC
#endif /* CONFIG_NETWORKING_WITH_BT */ #endif /* CONFIG_NETWORKING_WITH_BT */
#endif /* CONFIG_NETWORKING_WITH_15_4 */ #endif /* CONFIG_NETWORKING_WITH_15_4 */
#define NETSTACK_CONF_LLSEC nullsec_driver #define NETSTACK_CONF_LLSEC nullsec_driver
#ifdef CONFIG_NETWORKING_WITH_15_4_TI_CC2520
#define NETSTACK_CONF_RADIO cc2520_15_4_radio_driver
#ifdef CONFIG_TI_CC2520_SYMBOL_LOOP_COUNT
#define CC2520_CONF_SYMBOL_LOOP_COUNT CONFIG_TI_CC2520_SYMBOL_LOOP_COUNT
#endif
#endif
#ifdef CONFIG_NETWORKING_WITH_RPL #ifdef CONFIG_NETWORKING_WITH_RPL
#define UIP_MCAST6_CONF_ENGINE UIP_MCAST6_ENGINE_SMRF #define UIP_MCAST6_CONF_ENGINE UIP_MCAST6_ENGINE_SMRF
#define UIP_CONF_IPV6_MULTICAST 1 #define UIP_CONF_IPV6_MULTICAST 1

View file

@ -19,12 +19,6 @@
#include "sys/clock.h" #include "sys/clock.h"
#include <stdlib.h> #include <stdlib.h>
#ifdef CONFIG_MICROKERNEL
#include <microkernel.h>
#else
#include <nanokernel.h>
#endif
#define DEBUG 0 #define DEBUG 0
#include "contiki/ip/uip-debug.h" #include "contiki/ip/uip-debug.h"

View file

@ -790,6 +790,10 @@ static int network_initialization(void)
handler_802154_join(CONFIG_NETWORKING_WITH_15_4_PAN_ID, 1); handler_802154_join(CONFIG_NETWORKING_WITH_15_4_PAN_ID, 1);
#endif #endif
#ifdef CONFIG_NETWORKING_WITH_15_4_PAN_ID
NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID);
#endif
return 0; return 0;
} }