diff --git a/boards/nrf52dk/Makefile b/boards/nrf52dk/Makefile new file mode 100644 index 000000000..f8fcbb53a --- /dev/null +++ b/boards/nrf52dk/Makefile @@ -0,0 +1,3 @@ +MODULE = board + +include $(RIOTBASE)/Makefile.base diff --git a/boards/nrf52dk/Makefile.dep b/boards/nrf52dk/Makefile.dep new file mode 100644 index 000000000..5472bf8b8 --- /dev/null +++ b/boards/nrf52dk/Makefile.dep @@ -0,0 +1,3 @@ +ifneq (,$(filter saul_default,$(USEMODULE))) + USEMODULE += saul_gpio +endif diff --git a/boards/nrf52dk/Makefile.features b/boards/nrf52dk/Makefile.features new file mode 100644 index 000000000..b36e90cbc --- /dev/null +++ b/boards/nrf52dk/Makefile.features @@ -0,0 +1,13 @@ +# Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_cpuid +FEATURES_PROVIDED += periph_gpio +FEATURES_PROVIDED += periph_random +FEATURES_PROVIDED += periph_rtt +FEATURES_PROVIDED += periph_timer +FEATURES_PROVIDED += periph_uart + +# Various other features (if any) +FEATURES_PROVIDED += cpp + +# The board MPU family (used for grouping by the CI system) +FEATURES_MCU_GROUP = cortex_m4_2 diff --git a/boards/nrf52dk/Makefile.include b/boards/nrf52dk/Makefile.include new file mode 100644 index 000000000..1f2e0e464 --- /dev/null +++ b/boards/nrf52dk/Makefile.include @@ -0,0 +1,20 @@ +# define the cpu used by the nRF52 DK +export CPU = nrf52 +export CPU_MODEL = nrf52xxaa + +# set default port depending on operating system +PORT_LINUX ?= /dev/ttyACM0 +PORT_DARWIN ?= $(shell ls -1 /dev/tty.usbmodem* | head -n 1) + +# setup the boards dependencies +include $(RIOTBOARD)/$(BOARD)/Makefile.dep + +# setup JLink for flashing +export JLINK_DEVICE := nrf52 +include $(RIOTBOARD)/Makefile.include.jlink + +# setup serial terminal +include $(RIOTBOARD)/Makefile.include.serial + +# include cortex defaults +include $(RIOTBOARD)/Makefile.include.cortexm_common diff --git a/boards/nrf52dk/board.c b/boards/nrf52dk/board.c new file mode 100644 index 000000000..8d3649c88 --- /dev/null +++ b/boards/nrf52dk/board.c @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2016 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_nrf52dk + * @{ + * + * @file + * @brief Board initialization for the nRF52 DK + * + * @author Hauke Petersen + * + * @} + */ + +#include "cpu.h" +#include "board.h" + +void board_init(void) +{ + /* initialize the boards LEDs */ + NRF_P0->DIRSET = (LED1_MASK | LED2_MASK | LED3_MASK | LED4_MASK); + NRF_P0->OUTSET = (LED1_MASK | LED2_MASK | LED3_MASK | LED4_MASK); + + /* initialize the CPU */ + cpu_init(); +} diff --git a/boards/nrf52dk/include/board.h b/boards/nrf52dk/include/board.h new file mode 100644 index 000000000..e965bef28 --- /dev/null +++ b/boards/nrf52dk/include/board.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2016 Feie 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_nrf52dk nRF52 DK + * @ingroup boards + * @{ + * + * @file + * @brief Board specific configuaration for the nRF52 DK + * + * @author Hauke Petersen + * + */ + +#ifndef BOARD_H +#define BOARD_H + +#include "cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief LED pin configuration + * @{ + */ +#define LED1_PIN (GPIO_PIN(0, 17)) +#define LED2_PIN (GPIO_PIN(0, 18)) +#define LED3_PIN (GPIO_PIN(0, 19)) +#define LED4_PIN (GPIO_PIN(0, 20)) +#define LED1_MASK (1 << 17) +#define LED2_MASK (1 << 18) +#define LED3_MASK (1 << 19) +#define LED4_MASK (1 << 20) +/** @} */ + +/** + * @brief RIOT LED macros for backwards compatibility + * @{ + */ +#define LED_RED_ON (NRF_P0->OUTSET = LED1_PIN) +#define LED_RED_OFF (NRF_P0->OUTCLR = LED2_PIN) +#define LED_RED_TOGGLE (NRF_P0->OUT ^= LED3_PIN) +#define LED_GREEN_ON (NRF_P0->OUTSET = LED1_PIN) +#define LED_GREEN_OFF (NRF_P0->OUTCLR = LED2_PIN) +#define LED_GREEN_TOGGLE (NRF_P0->OUT ^= LED3_PIN) +#define LED_ORANGE_ON (NRF_P0->OUTSET = LED1_PIN) +#define LED_ORANGE_OFF (NRF_P0->OUTCLR = LED2_PIN) +#define LED_ORANGE_TOGGLE (NRF_P0->OUT ^= LED3_PIN) +/** @} */ + +/** + * @brief Button pin configuration + * @{ + */ +#define BUTTON1_PIN (GPIO_PIN(0, 13)) +#define BUTTON2_PIN (GPIO_PIN(0, 14)) +#define BUTTON3_PIN (GPIO_PIN(0, 15)) +#define BUTTON4_PIN (GPIO_PIN(0, 16)) +/** @} */ + +/** + * @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/nrf52dk/include/gpio_params.h b/boards/nrf52dk/include/gpio_params.h new file mode 100644 index 000000000..81b82f567 --- /dev/null +++ b/boards/nrf52dk/include/gpio_params.h @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2016 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_nrf52dk + * @{ + * + * @file + * @brief Configuration of SAUL mapped GPIO pins + * + * @author Hauke Petersen + * + */ + +#ifndef GPIO_PARAMS_H +#define GPIO_PARAMS_H + +#include "board.h" +#include "saul/periph.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief LED configuration + */ +static const saul_gpio_params_t saul_gpio_params[] = +{ + { + .name = "LED 1", + .pin = LED1_PIN, + .dir = GPIO_DIR_OUT, + .pull = GPIO_NOPULL + }, + { + .name = "LED 2", + .pin = LED2_PIN, + .dir = GPIO_DIR_OUT, + .pull = GPIO_NOPULL + }, + { + .name = "LED 3", + .pin = LED3_PIN, + .dir = GPIO_DIR_OUT, + .pull = GPIO_NOPULL + }, + { + .name = "LED 4", + .pin = LED4_PIN, + .dir = GPIO_DIR_OUT, + .pull = GPIO_NOPULL + }, + { + .name = "Button 1", + .pin = BUTTON1_PIN, + .dir = GPIO_DIR_IN, + .pull = GPIO_PULLUP + }, + { + .name = "Button 2", + .pin = BUTTON2_PIN, + .dir = GPIO_DIR_IN, + .pull = GPIO_PULLUP + }, + { + .name = "Button 3", + .pin = BUTTON3_PIN, + .dir = GPIO_DIR_IN, + .pull = GPIO_PULLUP + }, + { + .name = "Button 4", + .pin = BUTTON4_PIN, + .dir = GPIO_DIR_IN, + .pull = GPIO_PULLUP + } +}; + + +#ifdef __cplusplus +} +#endif + +#endif /* GPIO_PARAMS_H */ +/** @} */ diff --git a/boards/nrf52dk/include/periph_conf.h b/boards/nrf52dk/include/periph_conf.h new file mode 100644 index 000000000..3ccf66108 --- /dev/null +++ b/boards/nrf52dk/include/periph_conf.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2016 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_nrf52dk + * @{ + * + * @file + * @brief Peripheral configuration for the nRF52 DK + * + * @author Hauke Petersen + * + */ + +#ifndef PERIPH_CONF_H +#define PERIPH_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Clock configuration + * + * @note The radio will not work with the internal RC oscillator! + * + * @{ + */ +#define CLOCK_CORECLOCK (64000000U) /* fixed for all NRF52832 */ +#define CLOCK_CRYSTAL (32U) /* set to 0: internal RC oscillator + 32: 32MHz crystal */ +/** @} */ + +/** + * @brief Timer configuration + * @{ + */ +#define TIMER_NUMOF (1U) +#define TIMER_0_EN 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 +/** @} */ + +/** + * @brief Real time counter configuration + * @{ + */ +#define RTT_NUMOF (1U) +#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 */ +/** @} */ + +/** + * @brief UART configuration + * @{ + */ +#define UART_NUMOF (1U) +#define UART_PIN_RX 8 +#define UART_PIN_TX 6 +/** @} */ + +/** + * @name Random Number Generator configuration + * @{ + */ +#define RANDOM_NUMOF (1U) +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* __PERIPH_CONF_H */