Skip to content

Commit

Permalink
Merge pull request #1 from PeterKietzmann/kw2x_various_fixes
Browse files Browse the repository at this point in the history
Kw2x various fixes
  • Loading branch information
smlng authored Feb 7, 2017
2 parents a46bb0e + 6e7f1d1 commit 055253e
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 103 deletions.
15 changes: 8 additions & 7 deletions boards/pba-d-01-kw2x/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
/** @}*/

Expand Down
46 changes: 0 additions & 46 deletions boards/pba-d-01-kw2x/include/kw2xrf_params.h

This file was deleted.

74 changes: 74 additions & 0 deletions drivers/kw2xrf/include/kw2xrf_params.h
Original file line number Diff line number Diff line change
@@ -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 <peter.kietzmann@haw-hamburg.de>
*/

#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 */
/** @} */
4 changes: 2 additions & 2 deletions sys/auto_init/netif/auto_init_kw2xrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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]);
}
}
Expand Down
37 changes: 1 addition & 36 deletions tests/driver_kw2xrf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions tests/driver_kw2xrf/README.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 2 additions & 7 deletions tests/driver_kw2xrf/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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");

Expand Down

0 comments on commit 055253e

Please sign in to comment.