boards: added support for nRF52 DK

pr/gpio
Hauke Petersen 7 years ago
parent 2964969600
commit 3ecd1ee3fb

@ -0,0 +1,3 @@
MODULE = board
include $(RIOTBASE)/Makefile.base

@ -0,0 +1,3 @@
ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif

@ -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

@ -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

@ -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 <hauke.petersen@fu-berlin.de>
*
* @}
*/
#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();
}

@ -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 <hauke.petersen@fu-berlin.de>
*
*/
#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 */
/** @} */

@ -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 <hauke.petersen@fu-berlin.de>
*
*/
#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 */
/** @} */

@ -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 <hauke.petersen@fu-berlin.de>
*
*/
#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 */
Loading…
Cancel
Save