Merge pull request #4270 from haukepetersen/opt_at86_autoinit
driver/at86rf2xx: optimized auto initialization
This commit is contained in:
commit
3980fa3f5d
@ -0,0 +1,4 @@
|
||||
ifneq (,$(filter gnrc_netif_default,$(USEMODULE)))
|
||||
USEMODULE += at86rf231
|
||||
USEMODULE += gnrc_nomac
|
||||
endif
|
||||
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*
|
||||
* 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 board_iotlab-m3
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief at86rf231 board specific configuration
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*/
|
||||
|
||||
#ifndef AT86RF2XX_PARAMS_H_
|
||||
#define AT86RF2XX_PARAMS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name AT86RF231 configuration
|
||||
*/
|
||||
static const at86rf2xx_params_t at86rf2xx_params[] =
|
||||
{
|
||||
{
|
||||
.spi = AT86RF231_SPI,
|
||||
.spi_speed = AT86RF231_SPI_CLK,
|
||||
.cs_pin = AT86RF231_CS,
|
||||
.int_pin = AT86RF231_INT,
|
||||
.sleep_pin = AT86RF231_SLEEP,
|
||||
.reset_pin = AT86RF231_RESET,
|
||||
},
|
||||
};
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* AT86RF2XX_PARAMS_H_ */
|
||||
/** @} */
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freie Universität Berlin
|
||||
* Copyright (C) 2014-2015 Freie Universität Berlin
|
||||
*
|
||||
* 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
|
||||
@ -49,15 +49,15 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @name Define the interface to the AT86RF231 radio
|
||||
* @{
|
||||
*
|
||||
* {spi bus, spi speed, cs pin, int pin, reset pin, sleep pin}
|
||||
*/
|
||||
#define AT86RF231_SPI SPI_0
|
||||
#define AT86RF231_CS GPIO_PIN(PORT_A,1)
|
||||
#define AT86RF231_INT GPIO_PIN(PORT_C,2)
|
||||
#define AT86RF231_RESET GPIO_PIN(PORT_C,1)
|
||||
#define AT86RF231_SLEEP GPIO_PIN(PORT_A,0)
|
||||
#define AT86RF231_SPI_CLK SPI_SPEED_5MHZ
|
||||
/** @} */
|
||||
#define AT86RF2XX_PARAMS_BOARD {.spi = SPI_0, \
|
||||
.spi_speed = SPI_SPEED_5MHZ, \
|
||||
.cs_pin = GPIO_PIN(PORT_A, 1), \
|
||||
.int_pin = GPIO_PIN(PORT_C, 2), \
|
||||
.sleep_pin = GPIO_PIN(PORT_A, 0), \
|
||||
.reset_pin = GPIO_PIN(PORT_C, 1)}
|
||||
|
||||
/**
|
||||
* @name Define the interface to the LPS331AP pressure sensor
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*
|
||||
* 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 board_iotlab-m3
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief at86rf231 board specific configuration
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*/
|
||||
|
||||
#ifndef AT86RF2XX_PARAMS_H_
|
||||
#define AT86RF2XX_PARAMS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name AT86RF231 configuration
|
||||
*/
|
||||
static const at86rf2xx_params_t at86rf2xx_params[] =
|
||||
{
|
||||
{
|
||||
.spi = AT86RF231_SPI,
|
||||
.spi_speed = AT86RF231_SPI_CLK,
|
||||
.cs_pin = AT86RF231_CS,
|
||||
.int_pin = AT86RF231_INT,
|
||||
.sleep_pin = AT86RF231_SLEEP,
|
||||
.reset_pin = AT86RF231_RESET,
|
||||
},
|
||||
};
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* AT86RF2XX_PARAMS_H_ */
|
||||
/** @} */
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freie Universität Berlin
|
||||
* Copyright (C) 2014-2015 Freie Universität Berlin
|
||||
*
|
||||
* 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
|
||||
@ -54,15 +54,15 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @name Define the interface to the AT86RF231 radio
|
||||
* @{
|
||||
*
|
||||
* {spi bus, spi speed, cs pin, int pin, reset pin, sleep pin}
|
||||
*/
|
||||
#define AT86RF231_SPI SPI_0
|
||||
#define AT86RF231_CS GPIO_PIN(PORT_A,4)
|
||||
#define AT86RF231_INT GPIO_PIN(PORT_C,4)
|
||||
#define AT86RF231_RESET GPIO_PIN(PORT_C,1)
|
||||
#define AT86RF231_SLEEP GPIO_PIN(PORT_A,2)
|
||||
#define AT86RF231_SPI_CLK SPI_SPEED_5MHZ
|
||||
/** @} */
|
||||
#define AT86RF2XX_PARAMS_BOARD {.spi = SPI_0, \
|
||||
.spi_speed = SPI_SPEED_5MHZ, \
|
||||
.cs_pin = GPIO_PIN(PORT_A, 4), \
|
||||
.int_pin = GPIO_PIN(PORT_C, 4), \
|
||||
.sleep_pin = GPIO_PIN(PORT_A, 2), \
|
||||
.reset_pin = GPIO_PIN(PORT_C, 1)}
|
||||
|
||||
/**
|
||||
* @name Define the interface for the connected flash memory
|
||||
|
||||
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* Copyright (C) 2015 Eistec AB
|
||||
*
|
||||
* 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 board_mulle
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief at86rf231 board specific configuration
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* @author Joakim Nohlgård <joakim.nohlgard@eistec.se>
|
||||
*/
|
||||
|
||||
#ifndef AT86RF2XX_PARAMS_H_
|
||||
#define AT86RF2XX_PARAMS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name AT86RF212B configuration
|
||||
*/
|
||||
static const at86rf2xx_params_t at86rf2xx_params[] =
|
||||
{
|
||||
{
|
||||
.spi = AT86RF231_SPI,
|
||||
.spi_speed = AT86RF231_SPI_CLK,
|
||||
.cs_pin = AT86RF231_CS,
|
||||
.int_pin = AT86RF231_INT,
|
||||
.sleep_pin = AT86RF231_SLEEP,
|
||||
.reset_pin = AT86RF231_RESET,
|
||||
},
|
||||
};
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* AT86RF2XX_PARAMS_H */
|
||||
/** @} */
|
||||
@ -89,16 +89,18 @@ void board_init(void);
|
||||
|
||||
/**
|
||||
* @name Define the interface to the AT86RF212B radio
|
||||
* @{
|
||||
*
|
||||
* @todo Work around missing RESET pin on Mulle v0.6x
|
||||
*
|
||||
* {spi bus, spi speed, cs pin, int pin, reset pin, sleep pin}
|
||||
*/
|
||||
#define AT86RF231_SPI SPI_0
|
||||
#define AT86RF231_CS GPIO_PIN(PORT_D, 4)
|
||||
#define AT86RF231_INT GPIO_PIN(PORT_B, 9)
|
||||
/** @todo work around missing RESET pin on Mulle v0.6x */
|
||||
#define AT86RF231_RESET GPIO_PIN(PORT_C, 12)
|
||||
#define AT86RF231_SLEEP GPIO_PIN(PORT_E, 6)
|
||||
#define AT86RF231_SPI_CLK SPI_SPEED_5MHZ
|
||||
/** @} */
|
||||
#define AT86RF2XX_PARAMS_BOARD {.spi = SPI_0, \
|
||||
.spi_speed = SPI_SPEED_5MHZ, \
|
||||
.cs_pin = GPIO_PIN(PORT_D, 4), \
|
||||
.int_pin = GPIO_PIN(PORT_B, 9), \
|
||||
.sleep_pin = GPIO_PIN(PORT_E, 6), \
|
||||
.reset_pin = GPIO_PIN(PORT_C, 12)}
|
||||
|
||||
|
||||
/**
|
||||
* @name LIS3DH configuration
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*
|
||||
* 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 board_samr21-xpro
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief at86rf233 board specific configuration
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*/
|
||||
|
||||
#ifndef AT86RF2XX_PARAMS_H_
|
||||
#define AT86RF2XX_PARAMS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name AT86RF231 configuration
|
||||
*/
|
||||
static const at86rf2xx_params_t at86rf2xx_params[] =
|
||||
{
|
||||
{
|
||||
.spi = AT86RF233_SPI,
|
||||
.spi_speed = AT86RF233_SPI_CLK,
|
||||
.cs_pin = AT86RF233_CS,
|
||||
.int_pin = AT86RF233_INT,
|
||||
.sleep_pin = AT86RF233_SLEEP,
|
||||
.reset_pin = AT86RF233_RESET,
|
||||
},
|
||||
};
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* AT86RF2XX_PARAMS_H_ */
|
||||
/** @} */
|
||||
@ -41,18 +41,6 @@ extern "C" {
|
||||
#define XTIMER TIMER_1
|
||||
#define XTIMER_CHAN (0)
|
||||
|
||||
/**
|
||||
* @name AT86RF233 configuration
|
||||
* @{
|
||||
*/
|
||||
#define AT86RF233_SPI (SPI_0)
|
||||
#define AT86RF233_CS GPIO_PIN(PB, 31)
|
||||
#define AT86RF233_INT GPIO_PIN(PB, 0)
|
||||
#define AT86RF233_RESET GPIO_PIN(PB, 15)
|
||||
#define AT86RF233_SLEEP GPIO_PIN(PA, 20)
|
||||
#define AT86RF233_SPI_CLK (SPI_SPEED_1MHZ)
|
||||
/** @}*/
|
||||
|
||||
/**
|
||||
* @name Define UART device and baudrate for stdio
|
||||
* @{
|
||||
@ -62,6 +50,18 @@ extern "C" {
|
||||
#define STDIO_RX_BUFSIZE (64U)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name AT86RF233 configuration
|
||||
*
|
||||
* {spi bus, spi speed, cs pin, int pin, reset pin, sleep pin}
|
||||
*/
|
||||
#define AT86RF2XX_PARAMS_BOARD {.spi = SPI_0, \
|
||||
.spi_speed = SPI_SPEED_5MHZ, \
|
||||
.cs_pin = GPIO_PIN(PB, 31), \
|
||||
.int_pin = GPIO_PIN(PB, 0), \
|
||||
.sleep_pin = GPIO_PIN(PA, 20), \
|
||||
.reset_pin = GPIO_PIN(PB, 15)}
|
||||
|
||||
/**
|
||||
* @name LED pin definitions
|
||||
* @{
|
||||
|
||||
78
drivers/at86rf2xx/include/at86rf2xx_params.h
Normal file
78
drivers/at86rf2xx/include/at86rf2xx_params.h
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* 2015 Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* 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_at86rf2xx
|
||||
*
|
||||
* @{
|
||||
* @file
|
||||
* @brief Default configuration for the AT86RF2xx driver
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef AT86RF2XX_PARAMS_H
|
||||
#define AT86RF2XX_PARAMS_H
|
||||
|
||||
#include "board.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Set default configuration parameters for the AT86RF2xx driver
|
||||
* @{
|
||||
*/
|
||||
#ifndef AT86RF2XX_PARAM_SPI
|
||||
#define AT86RF2XX_PARAM_SPI (SPI_0)
|
||||
#endif
|
||||
#ifndef AT86RF2XX_PARAM_SPI_SPEED
|
||||
#define AT86RF2XX_PARAM_SPI_SPEED (SPI_SPEED_5MHZ)
|
||||
#endif
|
||||
#ifndef AT86RF2XX_PARAM_CS
|
||||
#define AT86RF2XX_PARAM_CS (GPIO_PIN(0, 0))
|
||||
#endif
|
||||
#ifndef AT86RF2XX_PARAM_INT
|
||||
#define AT86RF2XX_PARAM_INT (GPIO_PIN(0, 1))
|
||||
#endif
|
||||
#ifndef AT86RF2XX_PARAM_SLEEP
|
||||
#define AT86RF2XX_PARAM_SLEEP (GPIO_PIN(0, 2))
|
||||
#endif
|
||||
#ifndef AT86RF2XX_PARAM_RESET
|
||||
#define AT86RF2XX_PARAM_RESET (GPIO_PIN(0, 3))
|
||||
#endif
|
||||
|
||||
#define AT86RF2XX_PARAMS_DEFAULT {.spi = AT86RF2XX_PARAM_SPI, \
|
||||
.spi_speed = AT86RF2XX_PARAM_SPI_SPEED, \
|
||||
.cs_pin = AT86RF2XX_PARAM_CS, \
|
||||
.int_pin = AT86RF2XX_PARAM_INT, \
|
||||
.sleep_pin = AT86RF2XX_PARAM_SLEEP, \
|
||||
.reset_pin = AT86RF2XX_PARAM_RESET}
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @brief AT86RF231 configuration
|
||||
*/
|
||||
static const at86rf2xx_params_t at86rf2xx_params[] =
|
||||
{
|
||||
#ifdef AT86RF2XX_PARAMS_BOARD
|
||||
AT86RF2XX_PARAMS_BOARD,
|
||||
#else
|
||||
AT86RF2XX_PARAMS_DEFAULT,
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AT86RF2XX_PARAMS_H */
|
||||
/** @} */
|
||||
@ -55,7 +55,7 @@ void auto_init_at86rf2xx(void)
|
||||
p->reset_pin);
|
||||
|
||||
if (res < 0) {
|
||||
DEBUG("Error initializing AT86RF2xx radio device!");
|
||||
DEBUG("Error initializing AT86RF2xx radio device!\n");
|
||||
}
|
||||
else {
|
||||
gnrc_nomac_init(_nomac_stacks[i],
|
||||
|
||||
@ -13,45 +13,21 @@ USEMODULE += shell
|
||||
USEMODULE += shell_commands
|
||||
USEMODULE += ps
|
||||
|
||||
# define parameters for selected boards
|
||||
# define the driver to be used for selected boards
|
||||
ifneq (,$(filter samr21-xpro,$(BOARD)))
|
||||
DRIVER := at86rf233
|
||||
USE_BOARD_PARAMETERS := true
|
||||
DRIVER := at86rf233
|
||||
endif
|
||||
ifneq (,$(filter iotlab-m3 fox,$(BOARD)))
|
||||
DRIVER := at86rf231
|
||||
USE_BOARD_PARAMETERS := true
|
||||
DRIVER := at86rf231
|
||||
endif
|
||||
ifneq (,$(filter mulle,$(BOARD)))
|
||||
DRIVER := at86rf212b
|
||||
endif
|
||||
|
||||
# only set specific parameters if not using board configuration
|
||||
ifneq (true,$(USE_BOARD_PARAMETERS))
|
||||
# use the at86rf231 as fallback device
|
||||
DRIVER ?= at86rf231
|
||||
|
||||
# set default device parameters in case they are undefined
|
||||
DRIVER ?= at86rf231
|
||||
ATRF_SPI ?= SPI_0
|
||||
ATRF_SPI_SPEED ?= SPI_SPEED_5MHZ
|
||||
ATRF_CS ?= GPIO_PIN\(0,0\)
|
||||
ATRF_INT ?= GPIO_PIN\(0,1\)
|
||||
ATRF_SLEEP ?= GPIO_PIN\(0,2\)
|
||||
ATRF_RESET ?= GPIO_PIN\(0,3\)
|
||||
|
||||
# export parameters
|
||||
CFLAGS += -DATRF_SPI=$(ATRF_SPI)
|
||||
CFLAGS += -DATRF_SPI_SPEED=$(ATRF_SPI_SPEED)
|
||||
CFLAGS += -DATRF_CS=$(ATRF_CS)
|
||||
CFLAGS += -DATRF_INT=$(ATRF_INT)
|
||||
CFLAGS += -DATRF_SLEEP=$(ATRF_SLEEP)
|
||||
CFLAGS += -DATRF_RESET=$(ATRF_RESET)
|
||||
|
||||
# This adds . to include path so generic at86rf2xx_params.h gets picked
|
||||
# up. All boards actually having such a device on board should define
|
||||
# USE_BOARD_PARAMETERS=true above to skip this step, as the board provides
|
||||
# this header.
|
||||
CFLAGS += -I$(CURDIR)
|
||||
|
||||
endif
|
||||
|
||||
# finally include the actual chosen driver
|
||||
# include the selected driver
|
||||
USEMODULE += $(DRIVER)
|
||||
|
||||
CFLAGS += -DDEVELHELP
|
||||
|
||||
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*
|
||||
* 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 tests_at86rf2xx
|
||||
* @brief generic at86rf231 pin config
|
||||
*
|
||||
* @{
|
||||
* @file
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef AT86RF2XX_PARAMS_H
|
||||
#define AT86RF2XX_PARAMS_H
|
||||
|
||||
/**
|
||||
* @brief make sure the SPI port and the needed GPIO pins are defined
|
||||
* @{
|
||||
*/
|
||||
#ifndef ATRF_SPI
|
||||
#error "SPI not defined"
|
||||
#endif
|
||||
#ifndef ATRF_CS
|
||||
#error "Chip select pin not defined"
|
||||
#endif
|
||||
#ifndef ATRF_INT
|
||||
#error "Interrupt pin not defined"
|
||||
#endif
|
||||
#ifndef ATRF_SLEEP
|
||||
#error "Sleep pin not defined"
|
||||
#endif
|
||||
#ifndef ATRF_RESET
|
||||
#error "Reset pin not defined"
|
||||
#endif
|
||||
#ifndef ATRF_SPI_SPEED
|
||||
#define ATRF_SPI_SPEED (SPI_SPEED_5MHZ)
|
||||
#endif
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @name AT86RF231 configuration
|
||||
*/
|
||||
static const at86rf2xx_params_t at86rf2xx_params[] =
|
||||
{
|
||||
{
|
||||
.spi = ATRF_SPI,
|
||||
.spi_speed = ATRF_SPI_SPEED,
|
||||
.cs_pin = ATRF_CS,
|
||||
.int_pin = ATRF_INT,
|
||||
.sleep_pin = ATRF_SLEEP,
|
||||
.reset_pin = ATRF_RESET,
|
||||
},
|
||||
};
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* AT86RF2XX_PARAMS_H */
|
||||
/** @} */
|
||||
Loading…
x
Reference in New Issue
Block a user