diff --git a/boards/pca10000/include/periph_conf.h b/boards/pca10000/include/periph_conf.h index 25fb6ce0dbec7c996e6bb334c2b76cc2b13b598f..bb23a517ec59fdcd6bcd2e1950fae5386dfde7c1 100644 --- a/boards/pca10000/include/periph_conf.h +++ b/boards/pca10000/include/periph_conf.h @@ -35,6 +35,7 @@ #define TIMER_0_DEV NRF_TIMER0 #define TIMER_0_CHANNELS 3 #define TIMER_0_MAX_VALUE (0xffffffff) +#define TIMER_0_BITMODE TIMER_BITMODE_BITMODE_32Bit #define TIMER_0_ISR isr_timer0 #define TIMER_0_IRQ TIMER0_IRQn @@ -42,6 +43,7 @@ #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 @@ -49,6 +51,7 @@ #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 /** @} */ @@ -115,6 +118,7 @@ #define GPIO_15_EN 1 #define GPIO_IRQ_PRIO 1 +/* GPIO pin configuration */ #define GPIO_0_PIN 0 #define GPIO_1_PIN 1 #define GPIO_2_PIN 2 diff --git a/boards/pca10005/include/periph_conf.h b/boards/pca10005/include/periph_conf.h index 1f1f9bad134c890c8dac8bde1f0dde40f8f0bae6..59633d114161bd00225641e78ce9a981dc5e7ad7 100644 --- a/boards/pca10005/include/periph_conf.h +++ b/boards/pca10005/include/periph_conf.h @@ -15,6 +15,7 @@ * * @author Christian Kühling <kuehling@zedat.fu-berlin.de> * @author Timo Ziegler <timo.ziegler@fu-berlin.de> + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> */ #ifndef __PERIPH_CONF_H @@ -26,7 +27,6 @@ */ #define TIMER_NUMOF (1U) #define TIMER_0_EN 1 -/* timers 1 and 2 are not supported yet */ #define TIMER_1_EN 0 #define TIMER_2_EN 0 #define TIMER_IRQ_PRIO 1 @@ -35,6 +35,7 @@ #define TIMER_0_DEV NRF_TIMER0 #define TIMER_0_CHANNELS 3 #define TIMER_0_MAX_VALUE (0xffffffff) +#define TIMER_0_BITMODE TIMER_BITMODE_BITMODE_32Bit #define TIMER_0_ISR isr_timer0 #define TIMER_0_IRQ TIMER0_IRQn @@ -42,6 +43,7 @@ #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 @@ -49,11 +51,11 @@ #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 UART configuration * @{ @@ -70,6 +72,21 @@ #define UART_0_PIN_TX 9 /** @} */ +/** + * @name Real time counter configuration + * @{ + */ +#define RTT_NUMOF (1U) +#define RTT_IRQ_PRIO 1 + +#define RTT_DEV NRF_RTC0 +#define RTT_IRQ RTC0_IRQn +#define RTT_ISR isr_rtc0 +#define RTT_MAX_VALUE (0xffffff) +#define RTT_FREQUENCY (10) /* in Hz */ +#define RTT_PRESCALER (3275U) /* run with 10 Hz */ +/** @} */ + /** * @name Random Number Generator configuration * @{ @@ -77,7 +94,6 @@ #define RANDOM_NUMOF (1U) /** @} */ - /** * @name GPIO configuration * @{ diff --git a/boards/yunjia-nrf51822/Makefile b/boards/yunjia-nrf51822/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..37891de8e6a2c369f1f81f7d875d257d482fe0ca --- /dev/null +++ b/boards/yunjia-nrf51822/Makefile @@ -0,0 +1,4 @@ +# tell the Makefile.base which module to build +MODULE = $(BOARD)_base + +include $(RIOTBASE)/Makefile.base diff --git a/boards/yunjia-nrf51822/Makefile.include b/boards/yunjia-nrf51822/Makefile.include new file mode 100644 index 0000000000000000000000000000000000000000..a0ca43a533aed8d0fb0e18a9e63cd04724c193b7 --- /dev/null +++ b/boards/yunjia-nrf51822/Makefile.include @@ -0,0 +1,52 @@ +# define the cpu used by the yunjia-nrf51822 board +export CPU = nrf51822 +export CPU_MODEL = nrf51822qfaa + +#define the default port depending on the host OS +OS := $(shell uname) +ifeq ($(OS),Linux) + PORT ?= /dev/ttyUSB0 +else ifeq ($(OS),Darwin) + PORT ?= $(shell ls -1 /dev/tty.SLAB_USBtoUART* | head -n 1) +else + $(info CAUTION: No flash tool for your host system found!) + # TODO: add support for windows as host platform +endif +export PORT + +# define tools used for building the project +export PREFIX = arm-none-eabi- +export CC = $(PREFIX)gcc +export AR = $(PREFIX)ar +export AS = $(PREFIX)as +export LINK = $(PREFIX)gcc +export SIZE = $(PREFIX)size +export OBJCOPY = $(PREFIX)objcopy +export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm +export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh +export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh +export DEBUGSERVER = $(RIOTBOARD)/$(BOARD)/dist/debug-server.sh +export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh + +# define build specific options +CPU_USAGE = -mcpu=cortex-m0 +FPU_USAGE = +export CFLAGS += -ggdb -g3 -std=gnu99 -Os -Wall -Wstrict-prototypes $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -mthumb -mthumb-interwork -nostartfiles +export CFLAGS += -ffunction-sections -fdata-sections -fno-builtin +export ASFLAGS += -ggdb -g3 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian +export LINKFLAGS += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -static -lgcc -mthumb -mthumb-interwork -nostartfiles +# $(LINKERSCRIPT) is specified in cpu/Makefile.include +export LINKFLAGS += -T$(LINKERSCRIPT) +export OFLAGS = -O binary +export HEXFILE = $(ELFFILE:.elf=.bin) +export TERMFLAGS += -p "$(PORT)" +export FFLAGS = $(HEXFILE) +export DEBUGGER_FLAGS = $(ELFFILE) + +# use the nano-specs of the NewLib when available +ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) +export LINKFLAGS += -specs=nano.specs -lc -lnosys +endif + +# export board specific includes to the global includes-listing +export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include diff --git a/boards/yunjia-nrf51822/board.c b/boards/yunjia-nrf51822/board.c new file mode 100644 index 0000000000000000000000000000000000000000..4e87ebb906c8b4b90efc72d70ed28568a5427521 --- /dev/null +++ b/boards/yunjia-nrf51822/board.c @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2014 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 board_yunjia-nrf51822 + * @{ + * + * @file board.c + * @brief Board specific implementations for the Yunjia NRF51822 board + * + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> + * + * @} + */ + +#include "board.h" +#include "cpu.h" + +#include "periph/uart.h" + +void board_init(void) +{ + /* initialize the CPU */ + cpu_init(); +} diff --git a/boards/yunjia-nrf51822/dist/debug b/boards/yunjia-nrf51822/dist/debug new file mode 100755 index 0000000000000000000000000000000000000000..c2626d71a22592a08776d6a87eb3bcf82a4404f6 --- /dev/null +++ b/boards/yunjia-nrf51822/dist/debug @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ -L "$0" ]; then + FILE=$(readlink -e "$0") +else + FILE="$0" +fi + +BIN_FOLDER=$(dirname "${FILE}") + +openocd -f "${BIN_FOLDER}/openocd.cfg" \ + -c "init" \ + -c "targets" \ + -c "reset halt" \ diff --git a/boards/yunjia-nrf51822/dist/debug-server.sh b/boards/yunjia-nrf51822/dist/debug-server.sh new file mode 100755 index 0000000000000000000000000000000000000000..b892483caf63fad24c76fae6dac76812bb77ad1d --- /dev/null +++ b/boards/yunjia-nrf51822/dist/debug-server.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ -L "$0" ]; then + FILE=$(readlink -e "$0") +else + FILE="$0" +fi + +BIN_FOLDER=$(dirname "${FILE}") + +echo "##" +echo "## Starting debug server" +echo "##" +openocd -f "${BIN_FOLDER}/openocd.cfg" \ + -c "init" \ + -c "targets" \ + -c "reset halt" \ diff --git a/boards/yunjia-nrf51822/dist/debug.sh b/boards/yunjia-nrf51822/dist/debug.sh new file mode 100755 index 0000000000000000000000000000000000000000..09be600cdadfa878fc3f086689879e8402c4ece3 --- /dev/null +++ b/boards/yunjia-nrf51822/dist/debug.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +if [ ! -f "$1" ]; then + echo "ELF-file $1 does not exist" + exit 1 +fi + +if [ -L "$0" ]; then + FILE=$(readlink -e "$0") +else + FILE="$0" +fi + +BIN_FOLDER=$(dirname "${FILE}") + +echo "##" +echo "## Debugging $1" +echo "##" +arm-none-eabi-gdb -tui -command="${BIN_FOLDER}/gdb.cfg" $1 diff --git a/boards/yunjia-nrf51822/dist/flash.sh b/boards/yunjia-nrf51822/dist/flash.sh new file mode 100755 index 0000000000000000000000000000000000000000..3afb80068b1844dd9869cb3b2e9292a1db13fd93 --- /dev/null +++ b/boards/yunjia-nrf51822/dist/flash.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +if [ ! -f "$1" ]; then + echo "Binary file $1 does not exist" + exit 1 +fi + +if [ -L "$0" ]; then + FILE=$(readlink -e "$0") +else + FILE="$0" +fi + +BIN_FOLDER=$(dirname "${FILE}") + +echo "##" +echo "## Flashing $1" +echo "##" +openocd -f "${BIN_FOLDER}/openocd.cfg" \ + -c "init" \ + -c "targets" \ + -c "flash banks" \ + -c "reset halt" \ + -c "flash write_image erase $1 0" \ + -c "verify_image $1" \ + -c "reset run"\ + -c "shutdown" diff --git a/boards/yunjia-nrf51822/dist/gdb.cfg b/boards/yunjia-nrf51822/dist/gdb.cfg new file mode 100644 index 0000000000000000000000000000000000000000..900a550d05b901bf83e9beb1a5ef3b8413b25f93 --- /dev/null +++ b/boards/yunjia-nrf51822/dist/gdb.cfg @@ -0,0 +1 @@ +target extended-remote 127.0.0.1:3333 diff --git a/boards/yunjia-nrf51822/dist/openocd.cfg b/boards/yunjia-nrf51822/dist/openocd.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ab9a01187e745fa5dd7fb348e0e19b10717f6c0a --- /dev/null +++ b/boards/yunjia-nrf51822/dist/openocd.cfg @@ -0,0 +1,8 @@ +# nRF51822 Target +source [find interface/stlink-v2.cfg] + +set WORKAREASIZE 0x4000 +source [find target/nrf51_stlink.tcl] + +# use hardware reset, connect under reset +#reset_config srst_only srst_nogate diff --git a/boards/yunjia-nrf51822/dist/reset.sh b/boards/yunjia-nrf51822/dist/reset.sh new file mode 100755 index 0000000000000000000000000000000000000000..daa5a334f33dd3417d68682551d186e001dc2ed4 --- /dev/null +++ b/boards/yunjia-nrf51822/dist/reset.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ -L "$0" ]; then + FILE=$(readlink "$0") +else + FILE="$0" +fi + +BIN_FOLDER=$(dirname "${FILE}") + +echo "##" +echo "## Resetting $BOARD" +echo "##" +openocd -f "${BIN_FOLDER}/openocd.cfg" \ + -c "init" \ + -c "reset run" \ + -c "shutdown" diff --git a/boards/yunjia-nrf51822/include/board.h b/boards/yunjia-nrf51822/include/board.h new file mode 100644 index 0000000000000000000000000000000000000000..70180b7ce5fdeab0978642e9e7c90e518082ac42 --- /dev/null +++ b/boards/yunjia-nrf51822/include/board.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2014 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 board_yunjia-nrf51822 Yunjia NRF51822 + * @ingroup boards + * @brief Board specific files for the Yunjia NRF51822 board + * @{ + * + * @file board.h + * @brief Board specific definitions for the Yunjia NRF51822 board + * + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> + */ + +#ifndef __BOARD_H +#define __BOARD_H + +#include "cpu.h" + +/** + * @name Define the nominal CPU core clock in this board + */ +#define F_CPU (16000000UL) + +/** + * @name Define the boards stdio + * @{ + */ +#define STDIO UART_0 +#define STDIO_BAUDRATE (115200U) +/** @} */ + +/** + * @name Assign the hardware timer + */ +#define HW_TIMER TIMER_0 + +/** + * @name Macros for controlling the on-board LEDs. + * @{ + */ +#define LED_RED_ON /* not available */ +#define LED_RED_OFF /* not available */ +#define LED_RED_TOGGLE /* not available */ +#define LED_GREEN_ON /* not available */ +#define LED_GREEN_OFF /* not available */ +#define LED_GREEN_TOGGLE /* not available */ +/* @} */ + +/** + * @brief Initialize board specific hardware, including clock, LEDs and std-IO + */ +void board_init(void); + +#endif /** __BOARD_H */ +/** @} */ diff --git a/boards/yunjia-nrf51822/include/periph_conf.h b/boards/yunjia-nrf51822/include/periph_conf.h new file mode 100644 index 0000000000000000000000000000000000000000..13a2556ff00cdf9c1f048953e2a54c7e8e535327 --- /dev/null +++ b/boards/yunjia-nrf51822/include/periph_conf.h @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2014 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 board_yunjia-nrf51822 + * @{ + * + * @file periph_conf.h + * @brief Peripheral MCU configuration for the Yunjia NRF51822 board + * + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> + */ + +#ifndef __PERIPH_CONF_H +#define __PERIPH_CONF_H + +/** + * @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 (0xffffffff) +#define TIMER_0_BITMODE TIMER_BITMODE_BITMODE_32Bit +#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 UART configuration + * @{ + */ +#define UART_NUMOF (1U) +#define UART_0_EN 1 +#define UART_IRQ_PRIO 1 + +/* UART 0 device configuration */ +#define UART_0_DEV NRF_UART0 +#define UART_0_PIN_RX 1 +#define UART_0_PIN_TX 2 +/** @} */ + +/** + * @name Real time counter configuration + * @{ + */ +#define RTT_NUMOF (1U) +#define RTT_IRQ_PRIO 1 + +#define RTT_DEV NRF_RTC0 +#define RTT_IRQ RTC0_IRQn +#define RTT_ISR isr_rtc0 +#define RTT_MAX_VALUE (0xffffff) +#define RTT_FREQUENCY (10) /* in Hz */ +#define RTT_PRESCALER (3275U) /* run with 10 Hz */ +/** @} */ + +/** + * @name Random Number Generator configuration + * @{ + */ +#define RANDOM_NUMOF (1U) +/** @} */ + +/** + * @name GPIO configuration + * @{ + */ +#define GPIO_NUMOF (8U) +#define GPIO_0_EN 1 +#define GPIO_1_EN 1 +#define GPIO_2_EN 1 +#define GPIO_3_EN 1 +#define GPIO_4_EN 1 +#define GPIO_5_EN 1 +#define GPIO_6_EN 1 +#define GPIO_7_EN 1 +#define GPIO_IRQ_PRIO 1 + +/* GPIO pin configuration */ +#define GPIO_0_PIN 7 +#define GPIO_1_PIN 8 +#define GPIO_2_PIN 9 +#define GPIO_3_PIN 10 +#define GPIO_4_PIN 11 +#define GPIO_5_PIN 12 +#define GPIO_6_PIN 13 +#define GPIO_7_PIN 14 +/** @} */ + +#endif /* __PERIPH_CONF_H */ diff --git a/cpu/nrf51822/include/cpu-conf.h b/cpu/nrf51822/include/cpu-conf.h index 939fe028b2cc0803e520523de627a8e7fdc106f2..8a5accd9b84b307a394b4d12de978e6823ddb7b8 100644 --- a/cpu/nrf51822/include/cpu-conf.h +++ b/cpu/nrf51822/include/cpu-conf.h @@ -29,10 +29,10 @@ * TODO: measure and adjust for the cortex-m0 * @{ */ -#define KERNEL_CONF_STACKSIZE_PRINTF (1024) +#define KERNEL_CONF_STACKSIZE_PRINTF (524) #ifndef KERNEL_CONF_STACKSIZE_DEFAULT -#define KERNEL_CONF_STACKSIZE_DEFAULT (1024) +#define KERNEL_CONF_STACKSIZE_DEFAULT (524) #endif #define KERNEL_CONF_STACKSIZE_IDLE (256) diff --git a/cpu/nrf51822/nrf51822qfaa_linkerscript.ld b/cpu/nrf51822/nrf51822qfaa_linkerscript.ld index c89f2fe04342cfe6fa6e732b4b8f5a31dc34a5c9..d1358af19c697713a52db192ef0b98b17c849f9c 100644 --- a/cpu/nrf51822/nrf51822qfaa_linkerscript.ld +++ b/cpu/nrf51822/nrf51822qfaa_linkerscript.ld @@ -34,8 +34,8 @@ SEARCH_DIR(.) /* Memory Spaces Definitions */ MEMORY { - rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x40000 /* 256K flash */ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000 /* 16K ram */ + rom (rx) : ORIGIN = 0x00000000, LENGTH = 256K + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 16K } /* The stack size used by the application. NOTE: you need to adjust */ diff --git a/cpu/nrf51822/periph/timer.c b/cpu/nrf51822/periph/timer.c index ffafbb468163c21791844ed4c3bcefbcec61fa62..c68f02b2c2a3003f61e40cf8fc77c6e192ec93fb 100644 --- a/cpu/nrf51822/periph/timer.c +++ b/cpu/nrf51822/periph/timer.c @@ -43,14 +43,14 @@ static timer_conf_t timer_config[TIMER_NUMOF]; int timer_init(tim_t dev, unsigned int ticks_per_us, void (*callback)(int)) { - NRF_TIMER_Type *timer; switch (dev) { #if TIMER_0_EN case TIMER_0: timer = TIMER_0_DEV; - timer->BITMODE = TIMER_BITMODE_BITMODE_32Bit; /* 32 Bit Mode */ + timer->POWER = 1; + timer->BITMODE = TIMER_0_BITMODE; NVIC_SetPriority(TIMER_0_IRQ, TIMER_IRQ_PRIO); NVIC_EnableIRQ(TIMER_0_IRQ); break; @@ -58,7 +58,8 @@ int timer_init(tim_t dev, unsigned int ticks_per_us, void (*callback)(int)) #if TIMER_1_EN case TIMER_1: timer = TIMER_1_DEV; - timer->BITMODE = TIMER_BITMODE_BITMODE_16Bit; /* 16 Bit Mode */ + timer->POWER = 1; + timer->BITMODE = TIEMR_1_BITMODE; NVIC_SetPriority(TIMER_1_IRQ, TIMER_IRQ_PRIO); NVIC_EnableIRQ(TIMER_1_IRQ); break; @@ -66,7 +67,8 @@ int timer_init(tim_t dev, unsigned int ticks_per_us, void (*callback)(int)) #if TIMER_2_EN case TIMER_2: timer = TIMER_2_DEV; - timer->BITMODE = TIMER_BITMODE_BITMODE_16Bit; /* 16 Bit Mode */ + timer->POWER = 1; + timer->BITMODE = TIMER_2_BITMODE; NVIC_SetPriority(TIMER_2_IRQ, TIMER_IRQ_PRIO); NVIC_EnableIRQ(TIMER_2_IRQ); break; @@ -102,14 +104,17 @@ int timer_init(tim_t dev, unsigned int ticks_per_us, void (*callback)(int)) default: return -1; } - /* timer->INTENSET = TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos; */ + + /* clear all compare channels */ timer->SHORTS = (TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos); timer->SHORTS = (TIMER_SHORTS_COMPARE1_CLEAR_Enabled << TIMER_SHORTS_COMPARE1_CLEAR_Pos); timer->SHORTS = (TIMER_SHORTS_COMPARE2_CLEAR_Enabled << TIMER_SHORTS_COMPARE2_CLEAR_Pos); timer->SHORTS = (TIMER_SHORTS_COMPARE3_CLEAR_Enabled << TIMER_SHORTS_COMPARE3_CLEAR_Pos); + + /* start the timer */ timer->TASKS_START = 1; - return 1; + return 0; } int timer_set(tim_t dev, int channel, unsigned int timeout) diff --git a/cpu/nrf51822/periph/uart.c b/cpu/nrf51822/periph/uart.c index d99966a799bfc8f7d177b9547160e54adcdc7f4d..80c6101968154e014c6eabcefe3fdc89d6adf12d 100644 --- a/cpu/nrf51822/periph/uart.c +++ b/cpu/nrf51822/periph/uart.c @@ -15,6 +15,7 @@ * * @author Christian Kühling <kuehling@zedat.fu-berlin.de> * @author Timo Ziegler <timo.ziegler@fu-berlin.de> + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> * * @} */ @@ -117,18 +118,29 @@ int uart_init_blocking(uart_t uart, uint32_t baudrate) switch (uart) { #if UART_0_EN case UART_0: + /* power on UART device */ + UART_0_DEV->POWER = 1; + /* reset configuration registers */ UART_0_DEV->CONFIG = 0; /* select baudrate */ UART_0_DEV->BAUDRATE = baudrate_real; + /* configure RX/TX pin modes */ + NRF_GPIO->DIRSET = (1 << UART_0_PIN_TX); + NRF_GPIO->DIRCLR = (1 << UART_0_PIN_RX); + /* configure UART pins to use */ UART_0_DEV->PSELTXD = UART_0_PIN_TX; UART_0_DEV->PSELRXD = UART_0_PIN_RX; /* enable hw-flow control if defined */ #if UART_0_HWFLOWCTRL + /* set pin mode for RTS and CTS pins */ + NRF_GPIO->DIRSET = (1 << UART_0_PIN_RTS); + NRF_GPIO->DIRSET = (1 << UART_0_PIN_CTS); + /* configure RTS and CTS pins to use */ UART_0_DEV->PSELRTS = UART_0_PIN_RTS; UART_0_DEV->PSELCTS = UART_0_PIN_CTS; UART_0_DEV->CONFIG |= 1; /* enable HW flow control */ @@ -147,8 +159,6 @@ int uart_init_blocking(uart_t uart, uint32_t baudrate) #endif } - DEBUG("UART INITIALIZATION complete\n"); - return 0; } @@ -208,4 +218,30 @@ int uart_write_blocking(uart_t uart, char data) return 1; } +void uart_poweron(uart_t uart) +{ + switch (uart) { +#if UART_0_EN + case UART_0: + UART_0_DEV->POWER = 1; + break; +#endif + default: + return; + } +} + +void uart_poweroff(uart_t uart) +{ + switch (uart) { +#if UART_0_EN + case UART_0: + UART_0_DEV->POWER = 0; + break; +#endif + default: + return; + } +} + #endif /* UART_NUMOF */ diff --git a/cpu/nrf51822/startup.c b/cpu/nrf51822/startup.c index aaaaa0c82c322816718fcaf59b856d8364a80ae4..f229ba5073ee162379b1f73fc87a70caeda1a1db 100644 --- a/cpu/nrf51822/startup.c +++ b/cpu/nrf51822/startup.c @@ -90,8 +90,12 @@ void isr_nmi(void) void isr_hard_fault(void) { - LED_RED_ON; - while (1) {asm ("nop");} + while (1) { + for (int i = 0; i < 500000; i++) { + asm("nop"); + } + LED_RED_TOGGLE; + } } /* Cortex-M specific interrupt vectors */ diff --git a/examples/ccn-lite-client/Makefile b/examples/ccn-lite-client/Makefile index f93974d2943e1a446295c995f3fb9256439a2277..282d891778dc5c8b636f4149af19157eb77ff79b 100644 --- a/examples/ccn-lite-client/Makefile +++ b/examples/ccn-lite-client/Makefile @@ -29,8 +29,8 @@ QUIET ?= 1 BOARD_INSUFFICIENT_RAM := chronos msb-430h telosb wsn430-v1_3b wsn430-v1_4 z1 redbee-econotag BOARD_BLACKLIST := arduino-due mbed_lpc1768 msb-430 pttu udoo qemu-i386 \ - stm32f0discovery stm32f3discovery stm32f4discovery pca10000 pca10005 arduino-mega2560 \ - msbiot + stm32f0discovery stm32f3discovery stm32f4discovery pca10000 pca10005 \ + arduino-mega2560 msbiot yunjia-nrf51822 # mbed_lpc1768: see https://github.com/RIOT-OS/RIOT/issues/675 # msb-430: see https://github.com/RIOT-OS/RIOT/issues/658 # pttu: see https://github.com/RIOT-OS/RIOT/issues/659 @@ -42,6 +42,7 @@ BOARD_BLACKLIST := arduino-due mbed_lpc1768 msb-430 pttu udoo qemu-i386 \ # pca10005: no transceiver, yet # arduino-mega2560: no transceiver, yet # msbiot: no transceiver, yet +# yunjia-nrf51822: no transceiver, yet # Modules to include: diff --git a/examples/ccn-lite-relay/Makefile b/examples/ccn-lite-relay/Makefile index 9c52be273ccaf3fcac564e332ccab45ecbfcfc99..2ef532217be6e8643bd67103b91c089a7c01d5d3 100644 --- a/examples/ccn-lite-relay/Makefile +++ b/examples/ccn-lite-relay/Makefile @@ -30,7 +30,7 @@ QUIET ?= 1 BOARD_INSUFFICIENT_RAM := chronos msb-430h telosb wsn430-v1_3b wsn430-v1_4 z1 redbee-econotag BOARD_BLACKLIST := arduino-due mbed_lpc1768 msb-430 pttu udoo qemu-i386 \ stm32f0discovery stm32f3discovery stm32f4discovery \ - pca10000 pca10005 arduino-mega2560 msbiot + pca10000 pca10005 arduino-mega2560 msbiot yunjia-nrf51822 # mbed_lpc1768: see https://github.com/RIOT-OS/RIOT/issues/675 # msb-430: see https://github.com/RIOT-OS/RIOT/issues/658 # pttu: see https://github.com/RIOT-OS/RIOT/issues/659 @@ -41,6 +41,7 @@ BOARD_BLACKLIST := arduino-due mbed_lpc1768 msb-430 pttu udoo qemu-i386 \ # pca10000/5: no transceiver, yet # arduino-mega2560: no transceiver, yet # msbiot: no transceiver, yet +# yunjia-nrf51822: no transceiver, yet # Modules to include: diff --git a/examples/riot_and_cpp/Makefile b/examples/riot_and_cpp/Makefile index b79ea3b2b848fb47abf885b1ecb243322ad1a1a8..cef5a849c83eee12b9cb709a67d4639d3e58485d 100644 --- a/examples/riot_and_cpp/Makefile +++ b/examples/riot_and_cpp/Makefile @@ -31,7 +31,7 @@ QUIET ?= 1 BOARD_BLACKLIST := arduino-due avsextrem chronos mbed_lpc1768 msb-430h msba2 redbee-econotag \ telosb wsn430-v1_3b wsn430-v1_4 msb-430 pttu udoo qemu-i386 z1 stm32f0discovery \ stm32f3discovery stm32f4discovery pca10000 pca10005 iot-lab_M3 arduino-mega2560 \ - msbiot + msbiot yunjia-nrf51822 # This example only works with native for now. # msb430-based boards: msp430-g++ is not provided in mspgcc. @@ -42,7 +42,8 @@ BOARD_BLACKLIST := arduino-due avsextrem chronos mbed_lpc1768 msb-430h msba2 red # stm32f4discovery: g++ does not support some used flags (e.g. -mthumb...) # pca10000: g++ does not support some used flags (e.g. -mthumb...) # pca10005: g++ does not support some used flags (e.g. -mthumb...) -# iot-lab_M3: g++ does not support some used flags (e.g. -mthumb...) +# yunjia-nrf51822: g++ does not support some used flags (e.g. -mthumb...) +# iot-lab_M3: g++ does not support some used flags (e.g. -mthumb...) # arduino-mega2560: cstdio header missing from avr-libc # msbiot g++ does not support some used flags (e.g. -mthumb...) # others: untested. diff --git a/examples/rpl_udp/Makefile b/examples/rpl_udp/Makefile index 7a671d719c81eebfe281cbfcea914b3db322692c..0bab29b29eafa3cf63082800fb1fbbc84e301a07 100644 --- a/examples/rpl_udp/Makefile +++ b/examples/rpl_udp/Makefile @@ -37,7 +37,7 @@ endif BOARD_INSUFFICIENT_RAM := chronos msb-430h redbee-econotag telosb wsn430-v1_3b wsn430-v1_4 z1 BOARD_BLACKLIST := arduino-due mbed_lpc1768 msb-430 pttu udoo qemu-i386 stm32f0discovery \ stm32f3discovery stm32f4discovery pca10000 pca10005 arduino-mega2560 \ - msbiot + msbiot yunjia-nrf51822 # mbed_lpc1768: see https://github.com/RIOT-OS/RIOT/issues/675 # msb-430: see https://github.com/RIOT-OS/RIOT/issues/658 # pttu: see https://github.com/RIOT-OS/RIOT/issues/659 @@ -49,6 +49,7 @@ BOARD_BLACKLIST := arduino-due mbed_lpc1768 msb-430 pttu udoo qemu-i386 stm32f0d # pca10005: no transceiver, yet # arduino-mega2560: time.h missing from avr-libc # msbiot: no transceiver, yet +# yunjia-nrf51822: no transceiver, yet # Modules to include: diff --git a/tests/bloom/Makefile b/tests/bloom/Makefile index f4171d577138ee661092818ce0852c9911f5e446..497d0c95e83a5590c23d22c19eeadf2e75cb7a6b 100644 --- a/tests/bloom/Makefile +++ b/tests/bloom/Makefile @@ -3,7 +3,7 @@ include ../Makefile.tests_common BOARD_INSUFFICIENT_RAM := chronos mbed_lpc1768 msb-430 msb-430h redbee-econotag \ telosb wsn430-v1_3b wsn430-v1_4 z1 stm32f0discovery \ - stm32f3discovery pca10000 pca10005 + stm32f3discovery pca10000 pca10005 yunjia-nrf51822 BOARD_BLACKLIST := arduino-mega2560 # arduino-mega2560: Errors in assembly, e.g: diff --git a/tests/coap/Makefile b/tests/coap/Makefile index 561df2fd41646e8a73286065d5e9c73d9f8c8adc..7df140dd12fae40697455284c0f05af746f3bd64 100644 --- a/tests/coap/Makefile +++ b/tests/coap/Makefile @@ -3,13 +3,13 @@ include ../Makefile.tests_common BOARD_BLACKLIST := arduino-due chronos mbed_lpc1768 msb-430 msb-430h qemu-i386 stm32f0discovery \ stm32f3discovery stm32f4discovery telosb wsn430-v1_3b wsn430-v1_4 udoo z1 \ - pca10000 pca10005 arduino-mega2560 msbiot + pca10000 pca10005 arduino-mega2560 msbiot yunjia-nrf51822 #arduino-mega2560: missing header sys/types.h - -BOARD_INSUFFICIENT_RAM := redbee-econotag #MSP boards: no assert.h #rest: no radio +BOARD_INSUFFICIENT_RAM := redbee-econotag + USEMODULE += defaulttransceiver USEPKG += libcoap diff --git a/tests/net_if/Makefile b/tests/net_if/Makefile index 1a035450a93c81cfe918df06e070b80590e5e33f..b94a72724b35093a10922f8c20d0146185bc38cf 100644 --- a/tests/net_if/Makefile +++ b/tests/net_if/Makefile @@ -1,7 +1,7 @@ APPLICATION = net_if BOARD_BLACKLIST = mbed_lpc1768 arduino-due udoo qemu-i386 stm32f0discovery stm32f3discovery \ - stm32f4discovery pca10000 pca10005 arduino-mega2560 msbiot + stm32f4discovery pca10000 pca10005 arduino-mega2560 msbiot yunjia-nrf51822 # qemu-i386: no transceiver, yet # stm32f0discovery: no transceiver, yet # stm32f3discovery: no transceiver, yet @@ -9,6 +9,8 @@ BOARD_BLACKLIST = mbed_lpc1768 arduino-due udoo qemu-i386 stm32f0discovery stm32 # pca10000: no transceiver, yet # pca10005: no transceiver, yet # msbiot: no transceiver, yet +# yunjia-nrf51822: no transceiver, yet + include ../Makefile.tests_common ifeq ($(BOARD),stm32f4discovery) diff --git a/tests/pnet/Makefile b/tests/pnet/Makefile index 25bdbca46592e36141d12da363eb645290f84b9b..7926c8a8dadd2ac6afb6120127d73fbbee4ffc58 100644 --- a/tests/pnet/Makefile +++ b/tests/pnet/Makefile @@ -4,7 +4,7 @@ include ../Makefile.tests_common BOARD_INSUFFICIENT_RAM := chronos msb-430h redbee-econotag telosb wsn430-v1_3b wsn430-v1_4 z1 BOARD_BLACKLIST := arduino-due mbed_lpc1768 msb-430 udoo qemu-i386 stm32f0discovery \ stm32f3discovery stm32f4discovery pca10000 pca10005 arduino-mega2560 \ - msbiot + msbiot yunjia-nrf51822 # mbed_lpc1768: see https://github.com/RIOT-OS/RIOT/issues/675 # msb-430: see https://github.com/RIOT-OS/RIOT/issues/658 # qemu-i386: no transceiver, yet @@ -15,6 +15,7 @@ BOARD_BLACKLIST := arduino-due mbed_lpc1768 msb-430 udoo qemu-i386 stm32f0discov # pca10005: no transceiver, yet # arduino-mega2560: unknown type name ‘radio_packet_length_t’ # msbiot: no transceiver, yet +# yunjia-nrf51822: no transceiver, yet USEMODULE += posix USEMODULE += pnet diff --git a/tests/posix_semaphore/Makefile b/tests/posix_semaphore/Makefile index 02208ca52d863ca3523561a8ce1b0b870bcc2a66..30c3952443ac6ed475e9de2debc45aafeae5a1dd 100644 --- a/tests/posix_semaphore/Makefile +++ b/tests/posix_semaphore/Makefile @@ -2,7 +2,7 @@ APPLICATION = posix_semaphore include ../Makefile.tests_common BOARD_INSUFFICIENT_RAM := msb-430 msb-430h mbed_lpc1768 redbee-econotag chronos stm32f0discovery \ - pca10000 pca10005 + pca10000 pca10005 yunjia-nrf51822 USEMODULE += posix diff --git a/tests/pthread_rwlock/Makefile b/tests/pthread_rwlock/Makefile index 2d4a2b678a3ed892bd96dd417f3731bb12612ce1..d3daccbf1a38d40079abfe105ad8610fc3c728cd 100644 --- a/tests/pthread_rwlock/Makefile +++ b/tests/pthread_rwlock/Makefile @@ -13,6 +13,6 @@ DISABLE_MODULE += auto_init CFLAGS += -DNATIVE_AUTO_EXIT BOARD_INSUFFICIENT_RAM += chronos mbed_lpc1768 msb-430 msb-430h stm32f0discovery \ - pca10000 pca10005 + pca10000 pca10005 yunjia-nrf51822 include $(RIOTBASE)/Makefile.include diff --git a/tests/thread_cooperation/Makefile b/tests/thread_cooperation/Makefile index c46d5377e49ff918b6e33d38c66a004a4f4a9d89..c82cd8bf5ea0edc84406f373c04c0a55da768237 100644 --- a/tests/thread_cooperation/Makefile +++ b/tests/thread_cooperation/Makefile @@ -2,7 +2,7 @@ APPLICATION = thread_cooperation include ../Makefile.tests_common BOARD_INSUFFICIENT_RAM := chronos msb-430 msb-430h mbed_lpc1768 redbee-econotag stm32f0discovery \ - pca10000 pca10005 + pca10000 pca10005 yunjia-nrf51822 DISABLE_MODULE += auto_init