Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers - cc110x_ng: Propose new CC110x driver implementation #1772

Merged
merged 3 commits into from
Dec 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ ifneq (,$(filter cc110x%,$(USEMODULE)))
USEMODULE += vtimer
endif

ifneq (,$(filter cc110x,$(USEMODULE)))
USEMODULE += transceiver
endif

ifneq (,$(filter cc110x_legacy,$(USEMODULE)))
USEMODULE += transceiver
endif
Expand Down
1 change: 1 addition & 0 deletions boards/msbiot/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# tell the Makefile.base which module to build
MODULE = $(BOARD)_base
INCLUDES += -I$(RIOTBASE)/drivers/cc110x

include $(RIOTBASE)/Makefile.base
1 change: 1 addition & 0 deletions boards/msbiot/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FEATURES_PROVIDED += cpp
FEATURES_PROVIDED += periph_gpio
FEATURES_PROVIDED += transceiver
7 changes: 7 additions & 0 deletions boards/msbiot/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,10 @@ endif

# export board specific includes to the global includes-listing
export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include

ifneq (,$(filter defaulttransceiver,$(USEMODULE)))
USEMODULE += cc110x
ifeq (,$(filter netdev_base,$(USEMODULE)))
USEMODULE += transceiver
endif
endif
15 changes: 15 additions & 0 deletions boards/msbiot/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include "cpu.h"
#include "periph_conf.h"
#include "periph/gpio.h"
#include "periph/spi.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -38,6 +40,19 @@ extern "C" {
*/
#define HW_TIMER TIMER_0

/**
* @name Configure connected CC1101 (radio) device
* @{
*/
#define CC110X_SPI SPI_0
#define CC110X_CS GPIO_7
#define CC110X_GDO0 GPIO_11
#define CC110X_GDO1 GPIO_2
#define CC110X_GDO2 GPIO_12

typedef uint8_t radio_packet_length_t;
/** @} */

/**
* @name Define UART device and baudrate for stdio
* @{
Expand Down
41 changes: 35 additions & 6 deletions boards/msbiot/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,35 @@ extern "C" {
#define UART_2_AF 7
/** @} */

/**
* @name SPI configuration
* @{
*/
#define SPI_NUMOF 1
#define SPI_0_EN 1
#define SPI_1_EN 0
#define SPI_IRQ_PRIO 1

/* SPI 0 device config */
#define SPI_0_DEV SPI1
#define SPI_0_CLKEN() (RCC->APB2ENR |= RCC_APB2ENR_SPI1EN)
#define SPI_0_CLKDIS() (RCC->APB2ENR &= ~RCC_APB2ENR_SPI1EN)
#define SPI_0_IRQ SPI1_IRQn
#define SPI_0_IRQ_HANDLER isr_spi1
/* SPI 0 pin configuration */
#define SPI_0_SCK_PORT GPIOA
#define SPI_0_SCK_PIN 5
#define SPI_0_SCK_AF 5
#define SPI_0_MISO_PORT GPIOA
#define SPI_0_MISO_PIN 6
#define SPI_0_MISO_AF 5
#define SPI_0_MOSI_PORT GPIOA
#define SPI_0_MOSI_PIN 7
#define SPI_0_MOSI_AF 5
#define SPI_0_SCK_PORT_CLKEN() (RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN)
#define SPI_0_MISO_PORT_CLKEN() (RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN)
#define SPI_0_MOSI_PORT_CLKEN() (RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN)
/** @} */

/**
* @name GPIO configuration
Expand Down Expand Up @@ -153,9 +182,9 @@ extern "C" {
#define GPIO_IRQ_1 GPIO_1 /* alternatively GPIO_10 could be used here */
#define GPIO_IRQ_2 GPIO_15
#define GPIO_IRQ_3 -1/* not configured */
#define GPIO_IRQ_4 GPIO_2 /* alternatively GPIO_11 could be used here */
#define GPIO_IRQ_4 GPIO_11
#define GPIO_IRQ_5 GPIO_12
#define GPIO_IRQ_6 -1/* not configured */
#define GPIO_IRQ_6 GPIO_2
#define GPIO_IRQ_7 -1/* not configured */
#define GPIO_IRQ_8 GPIO_13
#define GPIO_IRQ_9 GPIO_5
Expand All @@ -179,11 +208,11 @@ extern "C" {
#define GPIO_1_EXTI_CFG() (SYSCFG->EXTICR[0] |= SYSCFG_EXTICR1_EXTI1_PA)
#define GPIO_1_IRQ EXTI1_IRQn
/* GPIO channel 2 config */
#define GPIO_2_PORT GPIOA
#define GPIO_2_PIN 4
#define GPIO_2_PORT GPIOA /* CC1101 GDO1 */
#define GPIO_2_PIN 6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

broken indentation (I know it was broken before, too)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the problem to me? I don't really see what is wrong with the indentation x)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, is apparently correct - just a browser issue. Never mind!

#define GPIO_2_CLKEN() (RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN)
#define GPIO_2_EXTI_CFG() (SYSCFG->EXTICR[1] |= SYSCFG_EXTICR2_EXTI4_PA)
#define GPIO_2_IRQ EXTI4_IRQn
#define GPIO_2_EXTI_CFG() (SYSCFG->EXTICR[1] |= SYSCFG_EXTICR2_EXTI6_PA)
#define GPIO_2_IRQ EXTI9_5_IRQn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again

/* GPIO channel 3 config */
#define GPIO_3_PORT GPIOA /* CC3000 SPI_IRQ */
#define GPIO_3_PIN 10
Expand Down
10 changes: 10 additions & 0 deletions cpu/stm32f4/include/cpu-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@
#endif
/** @} */

/**
* @name CC110X buffer size definitions for the stm32f4
* @{
*/
#ifdef MODULE_CC110X
#define TRANSCEIVER_BUFFER_SIZE (10)
#define RX_BUF_SIZE (10)
#endif
/** @} */

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
3 changes: 3 additions & 0 deletions drivers/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
ifneq (,$(filter cc2420,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/cc2420/include
endif
ifneq (,$(filter cc110x,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/cc110x/include
endif
ifneq (,$(filter cc110x_legacy_csma,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/cc110x_legacy_csma/include
endif
Expand Down
1 change: 1 addition & 0 deletions drivers/cc110x/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(RIOTBASE)/Makefile.base
133 changes: 133 additions & 0 deletions drivers/cc110x/cc110x-defaultsettings.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
* Copyright (C) 2013 INRIA
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup drivers_cc110x
* @{
*
* @file
* @brief TI Chipcon CC110x default settings
*
* @author Thomas Hillebrandt <hillebra@inf.fu-berlin.de>
* @author Heiko Will <hwill@inf.fu-berlin.de>
* @author Oliver Hahm <oliver.hahm@inria.fr>
* @}
*/

#include "cc110x.h"

/**
* @brief Default PA table index (output power)
*/
#define PATABLE (11)

/**
* @brief Current PATABLE Index
*/
uint8_t pa_table_index = PATABLE;

/**
* @brief PATABLE with available output powers
* @note If changed in size, adjust MAX_OUTPUT_POWER definition
* in CC110x interface
*/
uint8_t pa_table[] = {
0x00, ///< -52 dBm
0x03, ///< -30 dBm
0x0D, ///< -20 dBm
0x1C, ///< -15 dBm
0x34, ///< -10 dBm
0x57, ///< - 5 dBm
0x3F, ///< - 1 dBm
0x8E, ///< 0 dBm
0x85, ///< + 5 dBm
0xCC, ///< + 7 dBm
0xC6, ///< + 9 dBm
0xC3 ///< +10 dBm
};

/**
* Usable, non overlapping channels and corresponding frequencies
* for use with CC110x. CHANNR is the register for selecting a channel.
*
* channel number | CHANNR | frequency [MHz]
* -----------------------------------------
* 0 | 0 | 869.525
* 1 | 10 | 871.61
* 2 | 20 | 873.58 ~ seems to be bad (hang-ups with this channel)
* 3 | 30 | 875.61
* 4 | 40 | 877.58
* 5 | 50 | 879.61
* 6 | 60 | 881.58
* 7 | 70 | 883.61
* 8 | 80 | 885.58
* 9 | 90 | 887.61
* 10 | 100 | 889.58
* 11 | 110 | 891.57
* 12 | 120 | 893.58
* 13 | 130 | 895.61
* 14 | 140 | 897.58
* 15 | 150 | 899.57
* 16 | 160 | 901.57
* 17 | 170 | 903.61
* 18 | 180 | 905.57
* 19 | 190 | 907.57
* 20 | 200 | 909.57
* 21 | 210 | 911.57
* 22 | 220 | 913.57
* 23 | 230 | 915.61
* 24 | 240 | 917.61
*/

/**
* @brief Initial CC110x configuration
*
* 400 kbps, MSK, X-tal: 26 MHz (Chip Revision F)
*/
char cc110x_conf[] = {
0x06, /* IOCFG2 */
0x2E, /* IOCFG1 */
0x0E, /* IOCFG0 */
0x0F, /* FIFOTHR */
0x9B, /* SYNC1 */
0xAD, /* SYNC0 */
0x3D, /* PKTLEN (maximum value of packet length byte = 61) */
0x06, /* PKTCTRL1 */
0x45, /* PKTCTRL0 (variable packet length) */
0xFF, /* ADDR */
CC1100_DEFAULT_CHANNR * 10, /* CHANNR */
0x0B, /* FSCTRL1 */
0x00, /* FSCTRL0 */
0x21, /* FREQ2 */
0x71, /* FREQ1 */
0x7A, /* FREQ0 */
0x2D, /* MDMCFG4 */
0xF8, /* MDMCFG3 */
0x73, /* MDMCFG2 */
0x42, /* MDMCFG1 */
0xF8, /* MDMCFG0 */
0x00, /* DEVIATN */
0x07, /* MCSM2 */
0x03, /* MCSM1 */
0x18, /* MCSM0 */
0x1D, /* FOCCFG */
0x1C, /* BSCFG */
0xC0, /* AGCCTRL2 */
0x49, /* AGCCTRL1 */
0xB2, /* AGCCTRL0 */
0x87, /* WOREVT1 */
0x6B, /* WOREVT0 */
0xF8, /* WORCTRL */
0xB6, /* FREND1 */
0x10, /* FREND0 */
0xEA, /* FSCAL3 */
0x2A, /* FSCAL2 */
0x00, /* FSCAL1 */
0x1F, /* FSCAL0 */
0x00 /* padding to 4 bytes */
};
Loading