From 4e94d97da7315835beb4124674137432aac4e913 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Fri, 13 Nov 2015 16:27:34 +0100 Subject: [PATCH 1/8] drivers/at86rf2xx: added default params definition --- drivers/at86rf2xx/include/at86rf2xx_params.h | 78 ++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 drivers/at86rf2xx/include/at86rf2xx_params.h 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 */ +/** @} */ From 36a111e72f65c6e768ec912d2f58b423cb699ca1 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Fri, 13 Nov 2015 16:29:00 +0100 Subject: [PATCH 2/8] boards/fox: added radio to netif_default --- boards/fox/Makefile.dep | 4 ++++ 1 file changed, 4 insertions(+) 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 From 973d85fa2e5b47d035c4ccaffda7d10b37c59bdb Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Fri, 13 Nov 2015 16:29:48 +0100 Subject: [PATCH 3/8] boards/fox: use default at86rf2xx_params.h --- boards/fox/include/at86rf2xx_params.h | 46 --------------------------- boards/fox/include/board.h | 18 +++++------ 2 files changed, 9 insertions(+), 55 deletions(-) delete mode 100644 boards/fox/include/at86rf2xx_params.h 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 From 7430ab30bb7465a1639e02e4c058a768355fc9b5 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Fri, 13 Nov 2015 16:30:42 +0100 Subject: [PATCH 4/8] boards/iotlab-m3: use default at86rf2xx_params.h --- boards/iotlab-m3/include/at86rf2xx_params.h | 46 --------------------- boards/iotlab-m3/include/board.h | 18 ++++---- 2 files changed, 9 insertions(+), 55 deletions(-) delete mode 100644 boards/iotlab-m3/include/at86rf2xx_params.h 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 From af067e9428727eb22db99e805dfa15973796ead0 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Fri, 13 Nov 2015 16:31:14 +0100 Subject: [PATCH 5/8] boards/mulle: use default at86rf2xx_params.h --- boards/mulle/include/at86rf2xx_params.h | 48 ------------------------- boards/mulle/include/board.h | 20 ++++++----- 2 files changed, 11 insertions(+), 57 deletions(-) delete mode 100644 boards/mulle/include/at86rf2xx_params.h 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 From 004537e045a3ed149278abae048addc29590e2bb Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Fri, 13 Nov 2015 16:32:08 +0100 Subject: [PATCH 6/8] boards/samr21-xpro: use default at86rf2xx_params.h --- boards/samr21-xpro/include/at86rf2xx_params.h | 46 ------------------- boards/samr21-xpro/include/board.h | 24 +++++----- 2 files changed, 12 insertions(+), 58 deletions(-) delete mode 100644 boards/samr21-xpro/include/at86rf2xx_params.h 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 * @{ From 6e3e99cf4d017d7e770b61c0429ef3d63b32eb6d Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Fri, 13 Nov 2015 16:33:50 +0100 Subject: [PATCH 7/8] tests/driver_at86rf2xx: use default atrf_params.h --- tests/driver_at86rf2xx/Makefile | 42 +++----------- tests/driver_at86rf2xx/at86rf2xx_params.h | 70 ----------------------- 2 files changed, 9 insertions(+), 103 deletions(-) delete mode 100644 tests/driver_at86rf2xx/at86rf2xx_params.h 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 */ -/** @} */ From 6597abe25e3c14446eeacaa1a4a8c7acc8f022b6 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Thu, 19 Nov 2015 16:24:55 +0100 Subject: [PATCH 8/8] sys/auto_init/at86rf: fixed debug message --- sys/auto_init/netif/auto_init_at86rf2xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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],