diff --git a/boards/rfduino/Makefile b/boards/rfduino/Makefile new file mode 100644 index 000000000000..37891de8e6a2 --- /dev/null +++ b/boards/rfduino/Makefile @@ -0,0 +1,4 @@ +# tell the Makefile.base which module to build +MODULE = $(BOARD)_base + +include $(RIOTBASE)/Makefile.base diff --git a/boards/rfduino/Makefile.features b/boards/rfduino/Makefile.features new file mode 100644 index 000000000000..498e6d7eeb20 --- /dev/null +++ b/boards/rfduino/Makefile.features @@ -0,0 +1,2 @@ +FEATURES_PROVIDED += cpp +FEATURES_PROVIDED += periph_uart periph_gpio periph_random periph_rtt periph_cpuid diff --git a/boards/rfduino/Makefile.include b/boards/rfduino/Makefile.include new file mode 100644 index 000000000000..aa8b686608c6 --- /dev/null +++ b/boards/rfduino/Makefile.include @@ -0,0 +1,57 @@ +# define the cpu used by the rfduino-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 CXX = $(PREFIX)g++ +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) + +# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++ +export CXXUWFLAGS += +export CXXEXFLAGS += + +# use the nano-specs of the NewLib when available +ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null + * @author Jan Wagner + * + * @} + */ + +#include "board.h" +#include "cpu.h" + +void board_init(void) +{ + /* initialize the CPU */ + cpu_init(); +} diff --git a/boards/rfduino/dist/debug-server.sh b/boards/rfduino/dist/debug-server.sh new file mode 100755 index 000000000000..b61c5bdd8b7f --- /dev/null +++ b/boards/rfduino/dist/debug-server.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ -L "$0" ]; then + FILE=$(readlink "$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/rfduino/dist/debug.sh b/boards/rfduino/dist/debug.sh new file mode 100755 index 000000000000..a73beba147e2 --- /dev/null +++ b/boards/rfduino/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 "$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/rfduino/dist/flash.sh b/boards/rfduino/dist/flash.sh new file mode 100755 index 000000000000..92b656767325 --- /dev/null +++ b/boards/rfduino/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 "$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/rfduino/dist/gdb.cfg b/boards/rfduino/dist/gdb.cfg new file mode 100644 index 000000000000..6dacee6e0601 --- /dev/null +++ b/boards/rfduino/dist/gdb.cfg @@ -0,0 +1 @@ +target extended-remote :3333 diff --git a/boards/rfduino/dist/openocd.cfg b/boards/rfduino/dist/openocd.cfg new file mode 100644 index 000000000000..38b7f694c658 --- /dev/null +++ b/boards/rfduino/dist/openocd.cfg @@ -0,0 +1,7 @@ +# nRF51822 Target +source [find interface/stlink-v2.cfg] + +transport select hla_swd + +set WORKAREASIZE 0x4000 +source [find target/nrf51.cfg] diff --git a/boards/rfduino/dist/reset.sh b/boards/rfduino/dist/reset.sh new file mode 100755 index 000000000000..daa5a334f33d --- /dev/null +++ b/boards/rfduino/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/rfduino/include/board.h b/boards/rfduino/include/board.h new file mode 100644 index 000000000000..7f0737bd33f8 --- /dev/null +++ b/boards/rfduino/include/board.h @@ -0,0 +1,75 @@ +/* + * 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_rfduino-nrf51822 RFduino NRF51822 + * @ingroup boards + * @brief Board specific files for the RFduino RF51822 board + * @{ + * + * @file + * @brief Board specific definitions for the RFduino RF51822 board + * + * @author Hauke Petersen + * @author Jan Wagner + */ + +#ifndef __BOARD_H +#define __BOARD_H + +#include "cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @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) +#define STDIO_RX_BUFSIZE (64U) +/** @} */ + +/** + * @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 */ +#define LED_BLUE_ON /* not available */ +#define LED_BLUE_OFF /* not available */ +#define LED_BLUE_TOGGLE /* not available */ +/* @} */ + +/** + * @brief Initialize board specific hardware, including clock, LEDs and std-IO + */ +void board_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /** __BOARD_H */ +/** @} */ diff --git a/boards/rfduino/include/periph_conf.h b/boards/rfduino/include/periph_conf.h new file mode 100644 index 000000000000..e634b4473f53 --- /dev/null +++ b/boards/rfduino/include/periph_conf.h @@ -0,0 +1,138 @@ +/* + * 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_rfduino-nrf51822 + * @{ + * + * @file + * @brief Peripheral MCU configuration for the RFduino NRF51822 board + * + * @author Hauke Petersen + * @author Jan Wagner + */ + +#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 /* only possible value for TIMER0 */ +#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 pin configuration */ +#define UART_PIN_RX 0 +#define UART_PIN_TX 1 +/** @} */ + +/** + * @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_IRQ_PRIO 1 + +/* GPIO pin configuration */ +#define GPIO_0_PIN 0 +#define GPIO_1_PIN 1 +#define GPIO_2_PIN 2 +#define GPIO_3_PIN 3 +#define GPIO_4_PIN 4 +#define GPIO_5_PIN 5 +#define GPIO_6_PIN 6 +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* __PERIPH_CONF_H */