-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
boards: added support for the nRF51 Dongle
- Loading branch information
1 parent
04110fb
commit ecefad3
Showing
9 changed files
with
339 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# tell the Makefile.base which module to build | ||
MODULE = $(BOARD)_base | ||
|
||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 */ |