diff --git a/boards/pba-d-01-kw2x/include/board.h b/boards/pba-d-01-kw2x/include/board.h index bd8fbb7703307..14270ce00fe56 100644 --- a/boards/pba-d-01-kw2x/include/board.h +++ b/boards/pba-d-01-kw2x/include/board.h @@ -65,13 +65,14 @@ extern "C" /** @} */ /** -@name KW2XRF configuration -@{ -*/ -#define KW2XRF_SPI (SPI_DEV(1)) -#define KW2XRF_CS (GPIO_PIN(KW2XDRF_PORT, KW2XDRF_PCS0_PIN)) -#define KW2XRF_INT (GPIO_PIN(KW2XDRF_PORT, KW2XDRF_IRQ_PIN)) -#define KW2XRF_SPI_CLK (SPI_CLK_10MHZ) + * @name KW2XRF configuration + * + * {spi bus, cs pin, int pin, spi speed,} + */ +#define KW2XRF_PARAMS_BOARD {.spi = SPI_DEV(1), \ + .spi_clk = SPI_CLK_10MHZ, \ + .cs_pin = GPIO_PIN(KW2XDRF_PORT, KW2XDRF_PCS0_PIN), \ + .int_pin = GPIO_PIN(KW2XDRF_PORT, KW2XDRF_IRQ_PIN) } #define KW2XRF_SHARED_SPI 0 /** @}*/ diff --git a/boards/pba-d-01-kw2x/include/kw2xrf_params.h b/boards/pba-d-01-kw2x/include/kw2xrf_params.h deleted file mode 100644 index 84025bbc8f106..0000000000000 --- a/boards/pba-d-01-kw2x/include/kw2xrf_params.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2015 Kaspar Schleiser - * Copyright (C) 2014 PHYTEC Messtechnik GmbH - * - * 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_pba-d-01-kw2x - * @{ - * - * @file - * @brief kw2xrf board specific configuration - * - * @author Kaspar Schleiser - * @author Jonas Remmert - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef KW2XRF_PARAMS_H -#define KW2XRF_PARAMS_H - -/** - * @name KW2XRF configuration - */ -static const kw2xrf_params_t kw2xrf_params[] = - { - { - .spi = KW2XRF_SPI, - .spi_clk = KW2XRF_SPI_CLK, - .cs_pin = KW2XRF_CS, - .int_pin = KW2XRF_INT, - }, - }; -/** @} */ - -#ifdef __cplusplus -} -#endif -#endif /* KW2XRF_PARAMS_H */ -/** @} */ diff --git a/drivers/kw2xrf/include/kw2xrf_params.h b/drivers/kw2xrf/include/kw2xrf_params.h new file mode 100644 index 0000000000000..1e6a4797ef526 --- /dev/null +++ b/drivers/kw2xrf/include/kw2xrf_params.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2017 Hamburg University of Applied Sciences + * + * 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_kw2xrf + * + * @{ + * @file + * @brief Default configuration for the KW2XRF driver + * + * @author Peter Kietzmann + */ + +#ifndef KW2XRF_PARAMS_H +#define KW2XRF_PARAMS_H + +#include "board.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Set default configuration parameters for the KW2XRF driver + * @{ + */ +#ifndef KW2XRF_PARAM_SPI +#define KW2XRF_PARAM_SPI (SPI_DEV(0)) +#endif +#ifndef KW2XRF_PARAM_SPI_CLK +#define KW2XRF_PARAM_SPI_CLK (SPI_CLK_10MHZ) +#endif +#ifndef KW2XRF_PARAM_CS +#define KW2XRF_PARAM_CS (GPIO_PIN(0, 0)) +#endif +#ifndef KW2XRF_PARAM_INT +#define KW2XRF_PARAM_INT (GPIO_PIN(0, 1)) +#endif +#ifndef KW2XRF_PARAM_SLEEP +#define KW2XRF_PARAM_SLEEP (GPIO_PIN(0, 2)) +#endif +#ifndef KW2XRF_PARAM_RESET +#define KW2XRF_PARAM_RESET (GPIO_PIN(0, 3)) +#endif + +#define KW2XRF_PARAMS_DEFAULT {.spi = KW2XRF_PARAM_SPI, \ + .spi_clk = KW2XRF_PARAM_SPI_CLK, \ + .cs_pin = KW2XRF_PARAM_CS, \ + .int_pin = KW2XRF_PARAM_INT } +/**@}*/ + +/** + * @brief KW2XRF configuration + */ +static const kw2xrf_params_t kw2xrf_params[] = +{ +#ifdef KW2XRF_PARAMS_BOARD + KW2XRF_PARAMS_BOARD, +#else + KW2XRF_PARAMS_DEFAULT, +#endif +}; + +#ifdef __cplusplus +} +#endif + +#endif /* KW2XRF_PARAMS_H */ +/** @} */ diff --git a/sys/auto_init/netif/auto_init_kw2xrf.c b/sys/auto_init/netif/auto_init_kw2xrf.c index 23d9f64f944ba..1e8399a745765 100644 --- a/sys/auto_init/netif/auto_init_kw2xrf.c +++ b/sys/auto_init/netif/auto_init_kw2xrf.c @@ -44,7 +44,7 @@ static kw2xrf_t kw2xrf_devs[KW2XRF_NUM]; static gnrc_netdev2_t gnrc_adpt[KW2XRF_NUM]; -static char _nomac_stacks[KW2XRF_MAC_STACKSIZE][KW2XRF_NUM]; +static char _kw2xrf_stacks[KW2XRF_NUM][KW2XRF_MAC_STACKSIZE]; void auto_init_kw2xrf(void) { @@ -57,7 +57,7 @@ void auto_init_kw2xrf(void) LOG_ERROR("[auto_init_netif] error, initializing kw2xrf #%u\n", i); } else { - gnrc_netdev2_init(_nomac_stacks[i], KW2XRF_MAC_STACKSIZE, + gnrc_netdev2_init(_kw2xrf_stacks[i], KW2XRF_MAC_STACKSIZE, KW2XRF_MAC_PRIO, "kw2xrf", &gnrc_adpt[i]); } } diff --git a/tests/driver_kw2xrf/Makefile b/tests/driver_kw2xrf/Makefile index 20e2a1132d02d..24683ad5a6fd4 100644 --- a/tests/driver_kw2xrf/Makefile +++ b/tests/driver_kw2xrf/Makefile @@ -4,49 +4,14 @@ include ../Makefile.tests_common FEATURES_REQUIRED = periph_spi periph_gpio BOARD_INSUFFICIENT_MEMORY := stm32f0discovery nucleo-f334 weio -# msba2 fails with linker error in cc110x USEMODULE += auto_init_gnrc_netif -USEMODULE += gnrc_netif -USEMODULE += gnrc_txtsnd -USEMODULE += gnrc_nomac USEMODULE += gnrc_netdev_default -USEMODULE += gnrc_pktdump USEMODULE += shell USEMODULE += shell_commands USEMODULE += ps -# define parameters for selected boards -ifneq (,$(filter pba-d-01-kw2x,$(BOARD))) - DRIVER := kw2xrf - USE_BOARD_PARAMETERS := true -endif - -# only set specific parameters if not using board configuration -ifneq (true,$(USE_BOARD_PARAMETERS)) - - # set default device parameters in case they are undefined - DRIVER ?= kw2xrf - KW2XRF_SHARED_SPI ?= 1 - KWRF_SPI ?= SPI_DEV\(0\) - KWRF_SPI_SPEED ?= SPI_CLK_5MHZ - KWRF_CS ?= GPIO_PIN\(0,0\) - KWRF_INT ?= GPIO_PIN\(0,1\) - - # export parameters - CFLAGS += -DKW2XRF_SHARED_SPI=$(KW2XRF_SHARED_SPI) - CFLAGS += -DKWRF_SPI=$(KWRF_SPI) - CFLAGS += -DKWRF_SPI_SPEED=$(KWRF_SPI_SPEED) - CFLAGS += -DKWRF_CS=$(KWRF_CS) - CFLAGS += -DKWRF_INT=$(KWRF_INT) - - # This adds . to include path so generic kw2xrf_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 +DRIVER ?= kw2xrf # finally include the actual chosen driver USEMODULE += $(DRIVER) diff --git a/tests/driver_kw2xrf/README.md b/tests/driver_kw2xrf/README.md index 9a237d983eab3..ea1ba44fe0ff9 100644 --- a/tests/driver_kw2xrf/README.md +++ b/tests/driver_kw2xrf/README.md @@ -1,12 +1,10 @@ # About -This is a manual test application for testing the KW2xrf network device driver. +This is a manual test application for testing the KW2XRF device driver. It enables several shell commands, allowing for special test modes of that device. Without deeper knowledge about the hardware, this application might be useless except for compile tests. If you want an example to use this radio, check the [examples](../../examples) folder. For running this test, you need to connect/configure the following pins of your -radio device: +radio device. If you are running on a phyNODE, this is already the on-board default. + - SPI DEV - CS (chip select) - INT (external interrupt) -# Usage -For testing the radio driver you can use the netif and txtsnd shell commands -that are included in this application. diff --git a/tests/driver_kw2xrf/main.c b/tests/driver_kw2xrf/main.c index 026011f57a788..770702cd97fc8 100644 --- a/tests/driver_kw2xrf/main.c +++ b/tests/driver_kw2xrf/main.c @@ -23,11 +23,12 @@ #include "kw2xrf.h" #include "shell_commands.h" #include "net/gnrc.h" -#include "net/gnrc/pktdump.h" #include "net/gnrc/netif.h" #include "net/gnrc/netapi.h" #include "net/netopt.h" +#define KW2XRF_TESTMODE (1) + #ifdef KW2XRF_TESTMODE #include "kw2xrf_tm.h" @@ -158,15 +159,9 @@ static const shell_command_t shell_commands[] = { int main(void) { - gnrc_netreg_entry_t dump = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX_CTX_ALL, - gnrc_pktdump_pid); puts("KW2XRF device driver test"); - /* register the pktdump thread */ - puts("Register the packet dump thread for GNRC_NETTYPE_UNDEF packets"); - gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump); - /* start the shell */ puts("Initialization successful - starting the shell now");