diff --git a/boards/fox/Makefile.dep b/boards/fox/Makefile.dep index e69de29bb2..a72a7aafb8 100644 --- a/boards/fox/Makefile.dep +++ b/boards/fox/Makefile.dep @@ -0,0 +1,4 @@ +ifneq (,$(filter gnrc_netif_default,$(USEMODULE))) + USEMODULE += at86rf231 + USEMODULE += gnrc_nomac +endif diff --git a/boards/fox/include/at86rf2xx_params.h b/boards/fox/include/at86rf2xx_params.h deleted file mode 100644 index 55f272773a..0000000000 --- a/boards/fox/include/at86rf2xx_params.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2015 Kaspar Schleiser - * - * 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 - */ - -#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_ */ -/** @} */ diff --git a/boards/fox/include/board.h b/boards/fox/include/board.h index 7ec9c42b9d..7100a5f765 100644 --- a/boards/fox/include/board.h +++ b/boards/fox/include/board.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 diff --git a/boards/iotlab-m3/include/at86rf2xx_params.h b/boards/iotlab-m3/include/at86rf2xx_params.h deleted file mode 100644 index 55f272773a..0000000000 --- a/boards/iotlab-m3/include/at86rf2xx_params.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2015 Kaspar Schleiser - * - * 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 - */ - -#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_ */ -/** @} */ diff --git a/boards/iotlab-m3/include/board.h b/boards/iotlab-m3/include/board.h index 36aeed2b7e..2e2ddf2177 100644 --- a/boards/iotlab-m3/include/board.h +++ b/boards/iotlab-m3/include/board.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 diff --git a/boards/mulle/include/at86rf2xx_params.h b/boards/mulle/include/at86rf2xx_params.h deleted file mode 100644 index 444fe3740d..0000000000 --- a/boards/mulle/include/at86rf2xx_params.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2015 Kaspar Schleiser - * 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 - * @author Joakim Nohlgård - */ - -#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 */ -/** @} */ diff --git a/boards/mulle/include/board.h b/boards/mulle/include/board.h index 028c66b8bc..f89553146d 100644 --- a/boards/mulle/include/board.h +++ b/boards/mulle/include/board.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 diff --git a/boards/samr21-xpro/include/at86rf2xx_params.h b/boards/samr21-xpro/include/at86rf2xx_params.h deleted file mode 100644 index c74f33f160..0000000000 --- a/boards/samr21-xpro/include/at86rf2xx_params.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2015 Kaspar Schleiser - * - * 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 - */ - -#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_ */ -/** @} */ diff --git a/boards/samr21-xpro/include/board.h b/boards/samr21-xpro/include/board.h index 3a96c9e061..c4c3d56771 100644 --- a/boards/samr21-xpro/include/board.h +++ b/boards/samr21-xpro/include/board.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 * @{ diff --git a/drivers/at86rf2xx/include/at86rf2xx_params.h b/drivers/at86rf2xx/include/at86rf2xx_params.h new file mode 100644 index 0000000000..8dd9a31568 --- /dev/null +++ b/drivers/at86rf2xx/include/at86rf2xx_params.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2015 Kaspar Schleiser + * 2015 Hauke Petersen + * + * 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 + * @author Hauke Petersen + */ + +#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 */ +/** @} */ diff --git a/sys/auto_init/netif/auto_init_at86rf2xx.c b/sys/auto_init/netif/auto_init_at86rf2xx.c index 84c9cc28d7..f9fa3b1b4b 100644 --- a/sys/auto_init/netif/auto_init_at86rf2xx.c +++ b/sys/auto_init/netif/auto_init_at86rf2xx.c @@ -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], diff --git a/tests/driver_at86rf2xx/Makefile b/tests/driver_at86rf2xx/Makefile index 95926b6e97..03f6c10e65 100644 --- a/tests/driver_at86rf2xx/Makefile +++ b/tests/driver_at86rf2xx/Makefile @@ -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 diff --git a/tests/driver_at86rf2xx/at86rf2xx_params.h b/tests/driver_at86rf2xx/at86rf2xx_params.h deleted file mode 100644 index ae89a65e0d..0000000000 --- a/tests/driver_at86rf2xx/at86rf2xx_params.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2015 Kaspar Schleiser - * - * 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 - */ - -#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 */ -/** @} */