diff --git a/boards/nrf51dongle/Makefile b/boards/nrf51dongle/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..37891de8e6a2c369f1f81f7d875d257d482fe0ca --- /dev/null +++ b/boards/nrf51dongle/Makefile @@ -0,0 +1,4 @@ +# tell the Makefile.base which module to build +MODULE = $(BOARD)_base + +include $(RIOTBASE)/Makefile.base diff --git a/boards/nrf51dongle/Makefile.features b/boards/nrf51dongle/Makefile.features new file mode 100644 index 0000000000000000000000000000000000000000..c38538a11d91047b48960b1cd432f22f65d9e4b6 --- /dev/null +++ b/boards/nrf51dongle/Makefile.features @@ -0,0 +1,8 @@ +FEATURES_PROVIDED += cpp +FEATURES_PROVIDED += radio_nrfmin +FEATURES_PROVIDED += periph_uart +FEATURES_PROVIDED += periph_gpio +FEATURES_PROVIDED += periph_random +FEATURES_PROVIDED += periph_rtt +FEATURES_PROVIDED += periph_cpuid +FEATURES_MCU_GROUP = cortex_m0 diff --git a/boards/nrf51dongle/Makefile.include b/boards/nrf51dongle/Makefile.include new file mode 100644 index 0000000000000000000000000000000000000000..4f63a0059107831d93ef84bfeb3920cbbafcb605 --- /dev/null +++ b/boards/nrf51dongle/Makefile.include @@ -0,0 +1,26 @@ +# define the used CPU +export CPU = nrf51 +export CPU_MODEL = nrf51x22xxab + +# define the default port depending on the host OS +PORT_LINUX ?= /dev/ttyACM0 +PORT_DARWIN ?= $(shell ls -1 /dev/tty.SLAB_USBtoUART* | head -n 1) + +# define flash and debugging environment +export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh +export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh +export DEBUGSERVER = JLinkGDBServer -device nrf51822 -if SWD +export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh + +export OFLAGS = -O binary +export HEXFILE = $(ELFFILE:.elf=.bin) +export TERMFLAGS += -p "$(PORT)" +export FFLAGS = $(BINDIR) $(HEXFILE) +export DEBUGGER_FLAGS = $(BINDIR) $(ELFFILE) +export RESET_FLAGS = $(BINDIR) + +# setup serial terminal +include $(RIOTBOARD)/Makefile.include.serial + +# include cortex defaults +include $(RIOTBOARD)/Makefile.include.cortexm_common diff --git a/boards/nrf51dongle/board.c b/boards/nrf51dongle/board.c new file mode 100644 index 0000000000000000000000000000000000000000..7e00e24d6e3a84497389db094d6ed7836c71c18c --- /dev/null +++ b/boards/nrf51dongle/board.c @@ -0,0 +1,31 @@ +/* + * Copyright (C) 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 details. + */ + +/** + * @ingroup boards_nrf51dongle + * @{ + * + * @file + * @brief Board initialization code for the nRF51 Dongle + * + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> + * + * @} + */ + +#include "cpu.h" +#include "board.h" + +void board_init(void) +{ + /* initialize the boards LEDs, set pins as output and turn LEDs off */ + NRF_GPIO->DIRSET = (LED_RED_PIN | LED_GREEN_PIN | LED_BLUE_PIN); + NRF_GPIO->OUTSET = (LED_RED_PIN | LED_GREEN_PIN | LED_BLUE_PIN); + /* initialize the CPU */ + cpu_init(); +} diff --git a/boards/nrf51dongle/dist/debug.sh b/boards/nrf51dongle/dist/debug.sh new file mode 100755 index 0000000000000000000000000000000000000000..24bdbae0f64f06cfd0aec7ab536f4e8d6a901a0a --- /dev/null +++ b/boards/nrf51dongle/dist/debug.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# Start in-circuit debugging on this board: this script starts up the GDB +# client and connects to a GDB server. +# +# Start the GDB server first using the 'make debugserver' target + +# @author Hauke Petersen <hauke.petersen@fu-berlin.de> + +BINDIR=$1 +ELFFILE=$2 + +# write GDB config file +echo "target extended-remote 127.0.0.1:2331" > $BINDIR/gdb.cfg + +# run GDB +arm-none-eabi-gdb -tui -command=$BINDIR/gdb.cfg $ELFFILE diff --git a/boards/nrf51dongle/dist/flash.sh b/boards/nrf51dongle/dist/flash.sh new file mode 100755 index 0000000000000000000000000000000000000000..0f4bbb33c7d77f6e738c07b3e817b2f7c37e3177 --- /dev/null +++ b/boards/nrf51dongle/dist/flash.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# This flash script dynamically generates a file with a set of commands which +# have to be handed to the flashing script of SEGGER (JLinkExe >4.84). +# After that, JLinkExe will be executed with that set of commands to flash the +# latest .bin file to the board. + +# @author Timo Ziegler <timo.ziegler@fu-berlin.de> +# @author Hauke Petersen <hauke.petersen@fu-berlin.de> + +BINDIR=$1 +HEXFILE=$2 + +# setup JLink command file +echo "device nrf51822" > $BINDIR/burn.seg +echo "speed 1000" >> $BINDIR/burn.seg +echo "w4 4001e504 1" >> $BINDIR/burn.seg +echo "loadbin $HEXFILE 0" >> $BINDIR/burn.seg +echo "r" >> $BINDIR/burn.seg +echo "g" >> $BINDIR/burn.seg +echo "exit" >> $BINDIR/burn.seg +echo "" >> $BINDIR/burn.seg + +# flash new binary to the board +JLinkExe < $BINDIR/burn.seg diff --git a/boards/nrf51dongle/dist/reset.sh b/boards/nrf51dongle/dist/reset.sh new file mode 100755 index 0000000000000000000000000000000000000000..509f127ea42beeaaf2e4316ab5e76e7be5e408a7 --- /dev/null +++ b/boards/nrf51dongle/dist/reset.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# This script resets a nrf51822 target using JLink called +# with a pre-defined reset sequence. + +# @author Hauke Petersen <hauke.petersen@fu-berlin.de> + +BINDIR=$1 + +# create JLink command file for resetting the board +echo "device nrf51822" > $BINDIR/reset.seg +echo "r" >> $BINDIR/reset.seg +echo "g" >> $BINDIR/reset.seg +echo "exit" >> $BINDIR/reset.seg +echo " " >> $BINDIR/reset.seg + +# reset the board +JLinkExe < $BINDIR/reset.seg diff --git a/boards/nrf51dongle/include/board.h b/boards/nrf51dongle/include/board.h new file mode 100644 index 0000000000000000000000000000000000000000..672710fb673f776d301412cf2e43de3e898cd275 --- /dev/null +++ b/boards/nrf51dongle/include/board.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 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 details. + */ + +/** + * @defgroup boards_nrf51dongle nRF51 Dongle + * @ingroup boards + * @brief Board specific files for the Nordic nRF51 Dongle + * @{ + * + * @file + * @brief Board specific configuration for the nRF51 Dongle + * + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> + */ + +#ifndef BOARD_H +#define BOARD_H + +#include "cpu.h" +#include "periph_conf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Define the nominal CPU core clock in this board + */ +#define F_CPU (CLOCK_CORECLOCK) + +/** + * @brief Assign the hardware timer + */ +#define HW_TIMER TIMER_0 + +/** + * @name Define the boards STDIO + * @{ + */ +#define STDIO UART_0 +#define STDIO_BAUDRATE (115200U) +#define STDIO_RX_BUFSIZE (64U) +/** @} */ + +/** + * @name LED pin definitions + * @{ + */ +#define LED_RED_PIN (1 << 21) +#define LED_GREEN_PIN (1 << 22) +#define LED_BLUE_PIN (1 << 23) +/** @} */ + +/** + * @name Macros for controlling the on-board LEDs + * @{ + */ +#define LED_RED_ON (NRF_GPIO->OUTCLR = LED_RED_PIN) +#define LED_RED_OFF (NRF_GPIO->OUTSET = LED_RED_PIN) +#define LED_RED_TOGGLE (NRF_GPIO->OUT ^= LED_RED_PIN) +#define LED_GREEN_ON (NRF_GPIO->OUTCLR = LED_GREEN_PIN) +#define LED_GREEN_OFF (NRF_GPIO->OUTSET = LED_GREEN_PIN) +#define LED_GREEN_TOGGLE (NRF_GPIO->OUT ^= LED_GREEN_PIN) +#define LED_BLUE_ON (NRF_GPIO->OUTCLR = LED_BLUE_PIN) +#define LED_BLUE_OFF (NRF_GPIO->OUTSET = LED_BLUE_PIN) +#define LED_BLUE_TOGGLE (NRF_GPIO->OUT ^= LED_BLUE_PIN) +/** @} */ + +/** + * @brief Initialize the board, also triggers the CPU initialization + */ +void board_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /** BOARD_H */ +/** @} */ diff --git a/boards/nrf51dongle/include/periph_conf.h b/boards/nrf51dongle/include/periph_conf.h new file mode 100644 index 0000000000000000000000000000000000000000..e810f1ab755499d9f6a2bbda21c13d83dd4a03d4 --- /dev/null +++ b/boards/nrf51dongle/include/periph_conf.h @@ -0,0 +1,126 @@ +/* + * Copyright (C) 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 details. + */ + +/** + * @ingroup boards_nrf51dongle + * @{ + * + * @file + * @brief Peripheral configuration for the Nordic nRF51 Dongle + * + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> + */ + +#ifndef __PERIPH_CONF_H +#define __PERIPH_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Clock configuration + * + * @note: the radio will not work with the internal RC oscillator! + * + * @{ + */ +#define CLOCK_CORECLOCK (16000000U) /* fixed for all NRF51822 */ +#define CLOCK_CRYSTAL (16U) /* set to 0: internal RC oscillator + 16: 16MHz crystal + 32: 32MHz crystal */ +/** @} */ + +/** + * @name Timer configuration + * @{ + */ +#define TIMER_NUMOF (1U) +#define TIMER_0_EN 1 +#define TIMER_1_EN 0 +#define TIMER_2_EN 0 +#define TIMER_IRQ_PRIO 1 + +/* Timer 0 configuration */ +#define TIMER_0_DEV NRF_TIMER0 +#define TIMER_0_CHANNELS 3 +#define TIMER_0_MAX_VALUE (0xffffff) +#define TIMER_0_BITMODE TIMER_BITMODE_BITMODE_24Bit +#define TIMER_0_ISR isr_timer0 +#define TIMER_0_IRQ TIMER0_IRQn + +/* Timer 1 configuration */ +#define TIMER_1_DEV NRF_TIMER1 +#define TIMER_1_CHANNELS 3 +#define TIMER_1_MAX_VALUE (0xffff) +#define TIEMR_1_BITMODE TIMER_BITMODE_BITMODE_16Bit +#define TIMER_1_ISR isr_timer1 +#define TIMER_1_IRQ TIMER1_IRQn + +/* Timer 2 configuration */ +#define TIMER_2_DEV NRF_TIMER2 +#define TIMER_2_CHANNELS 3 +#define TIMER_2_MAX_VALUE (0xffff) +#define TIMER_2_BITMODE TIMER_BITMODE_BITMODE_16Bit +#define TIMER_2_ISR isr_timer2 +#define TIMER_2_IRQ TIMER2_IRQn +/** @} */ + +/** + * @name Real time counter configuration + * @{ + */ +#define RTT_NUMOF (1U) +#define RTT_IRQ_PRIO 1 + +#define RTT_DEV NRF_RTC1 +#define RTT_IRQ RTC1_IRQn +#define RTT_ISR isr_rtc1 +#define RTT_MAX_VALUE (0xffffff) +#define RTT_FREQUENCY (10) /* in Hz */ +#define RTT_PRESCALER (3275U) /* run with 10 Hz */ +/** @} */ + +/** + * @name UART configuration + * @{ + */ +#define UART_NUMOF (1U) +#define UART_0_EN 1 +#define UART_IRQ_PRIO 1 + +/* UART pin configuration */ +#define UART_HWFLOWCTRL 1 +#define UART_PIN_RX 11 +#define UART_PIN_TX 9 +#define UART_PIN_RTS 8 +#define UART_PIN_CTS 10 +/** @} */ + +/** + * @name Random Number Generator configuration + * @{ + */ +#define RANDOM_NUMOF (1U) +/** @} */ + +/** + * @name Radio device configuration + * + * The radio is not guarded by a NUMOF define, as the radio is selected by its + * own module in the build system. + * @{ + */ +#define RADIO_IRQ_PRIO 1 +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* __PERIPH_CONF_H */ diff --git a/examples/ng_networking/Makefile b/examples/ng_networking/Makefile index bd1b6fc874c54a388607c08f84525e51e2c1131f..bd24ff083090141d46cc9f96662fbacade43ec71 100644 --- a/examples/ng_networking/Makefile +++ b/examples/ng_networking/Makefile @@ -7,9 +7,10 @@ BOARD ?= native # This has to be the absolute path to the RIOT base directory: RIOTBASE ?= $(CURDIR)/../.. -BOARD_INSUFFICIENT_RAM := airfy-beacon chronos msb-430 msb-430h nucleo-f334 \ - pca10000 pca10005 redbee-econotag stm32f0discovery \ - telosb wsn430-v1_3b wsn430-v1_4 yunjia-nrf51822 z1 +BOARD_INSUFFICIENT_RAM := airfy-beacon chronos msb-430 msb-430h nrf51dongle \ + nucleo-f334 pca10000 pca10005 redbee-econotag \ + stm32f0discovery telosb wsn430-v1_3b wsn430-v1_4 \ + yunjia-nrf51822 z1 BOARD_BLACKLIST := arduino-mega2560 # arduino-mega2560: unknown error types (e.g. -EBADMSG) diff --git a/tests/pthread_rwlock/Makefile b/tests/pthread_rwlock/Makefile index fc571f2336255101136e370ff0a2c826ecfe7704..825b49e93e27462abf53b8c8e7069a73256d9e50 100644 --- a/tests/pthread_rwlock/Makefile +++ b/tests/pthread_rwlock/Makefile @@ -14,6 +14,6 @@ CFLAGS += -DNATIVE_AUTO_EXIT BOARD_INSUFFICIENT_RAM += chronos mbed_lpc1768 msb-430 msb-430h stm32f0discovery \ pca10000 pca10005 yunjia-nrf51822 spark-core nucleo-f334 \ - airfy-beacon + airfy-beacon nrf51dongle include $(RIOTBASE)/Makefile.include diff --git a/tests/thread_cooperation/Makefile b/tests/thread_cooperation/Makefile index 8b88072e974b08897c3af4d4956ad96b04b1b9ca..c3b8dd8a126cb52c83b01b20d0e884f8a5f9aef6 100644 --- a/tests/thread_cooperation/Makefile +++ b/tests/thread_cooperation/Makefile @@ -1,8 +1,10 @@ APPLICATION = thread_cooperation include ../Makefile.tests_common -BOARD_INSUFFICIENT_RAM := chronos msb-430 msb-430h mbed_lpc1768 redbee-econotag stm32f0discovery \ - pca10000 pca10005 yunjia-nrf51822 spark-core airfy-beacon nucleo-f334 +BOARD_INSUFFICIENT_RAM := chronos msb-430 msb-430h mbed_lpc1768 \ + redbee-econotag stm32f0discovery pca10000 pca10005 \ + yunjia-nrf51822 spark-core airfy-beacon nucleo-f334 \ + nrf51dongle DISABLE_MODULE += auto_init diff --git a/tests/unittests/Makefile b/tests/unittests/Makefile index 3e5ce104707b0d9387a2d3e76660bd254d918457..b68fae05419c916e870f864c4cc1e508cd0dec9f 100644 --- a/tests/unittests/Makefile +++ b/tests/unittests/Makefile @@ -5,7 +5,7 @@ BOARD_INSUFFICIENT_RAM := airfy-beacon chronos msb-430 msb-430h pca10000 \ pca10005 redbee-econotag spark-core stm32f0discovery \ telosb wsn430-v1_3b wsn430-v1_4 z1 nucleo-f334 \ yunjia-nrf51822 samr21-xpro arduino-mega2560 \ - airfy-beacon + airfy-beacon nrf51dongle USEMODULE += embunit