From 2b815a385a00d8b212992a6763ee93650b41ef24 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Wed, 10 Jan 2018 15:03:06 +0100 Subject: [PATCH] boards: add support for nrf52-base RuuviTag --- boards/ruuvitag/Makefile | 4 ++ boards/ruuvitag/Makefile.dep | 11 +++ boards/ruuvitag/Makefile.features | 14 ++++ boards/ruuvitag/Makefile.include | 10 +++ boards/ruuvitag/include/board.h | 85 ++++++++++++++++++++++ boards/ruuvitag/include/periph_conf.h | 100 ++++++++++++++++++++++++++ 6 files changed, 224 insertions(+) create mode 100644 boards/ruuvitag/Makefile create mode 100644 boards/ruuvitag/Makefile.dep create mode 100644 boards/ruuvitag/Makefile.features create mode 100644 boards/ruuvitag/Makefile.include create mode 100644 boards/ruuvitag/include/board.h create mode 100644 boards/ruuvitag/include/periph_conf.h diff --git a/boards/ruuvitag/Makefile b/boards/ruuvitag/Makefile new file mode 100644 index 0000000000..f07357235f --- /dev/null +++ b/boards/ruuvitag/Makefile @@ -0,0 +1,4 @@ +MODULE = board +DIRS = $(RIOTBOARD)/common/nrf52xxxdk + +include $(RIOTBASE)/Makefile.base diff --git a/boards/ruuvitag/Makefile.dep b/boards/ruuvitag/Makefile.dep new file mode 100644 index 0000000000..dbad8a2d08 --- /dev/null +++ b/boards/ruuvitag/Makefile.dep @@ -0,0 +1,11 @@ +include $(RIOTBOARD)/common/nrf52xxxdk/Makefile.dep + +ifneq (,$(filter saul_default,$(USEMODULE))) + # TODO: enable drivers once their adaption/implementations are merged + # USEMODULE += bme280_spi + # USEMODULE += lis2dh12_spi +endif + +ifneq (,$(filter gnrc_netdev_default,$(USEMODULE))) + USEMODULE += nrfmin +endif diff --git a/boards/ruuvitag/Makefile.features b/boards/ruuvitag/Makefile.features new file mode 100644 index 0000000000..5c594d4b0d --- /dev/null +++ b/boards/ruuvitag/Makefile.features @@ -0,0 +1,14 @@ +# Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_gpio +FEATURES_PROVIDED += periph_rtt +FEATURES_PROVIDED += periph_spi +FEATURES_PROVIDED += periph_timer +FEATURES_PROVIDED += periph_uart + +# Various other features (if any) +FEATURES_PROVIDED += radio_nrfmin + +# The board MPU family (used for grouping by the CI system) +FEATURES_MCU_GROUP = cortex_m4_3 + +-include $(RIOTCPU)/nrf52/Makefile.features diff --git a/boards/ruuvitag/Makefile.include b/boards/ruuvitag/Makefile.include new file mode 100644 index 0000000000..2f4830fefa --- /dev/null +++ b/boards/ruuvitag/Makefile.include @@ -0,0 +1,10 @@ +# CPU configuration +CPU_MODEL = nrf52832xxaa + +# for this board, we are using Segger's RTT as default terminal interface +USEMODULE += rtt_stdio +TERMPROG = $(RIOTBASE)/dist/tools/jlink/jlink.sh +TERMFLAGS = term_rtt + +# use shared Makefile.include +include $(RIOTBOARD)/common/nrf52xxxdk/Makefile.include diff --git a/boards/ruuvitag/include/board.h b/boards/ruuvitag/include/board.h new file mode 100644 index 0000000000..0278f245e8 --- /dev/null +++ b/boards/ruuvitag/include/board.h @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2018 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_ruuvitag RuuviTag + * @ingroup boards + * @brief Board specific configuration for the RuuviTag board + * @{ + * + * @file + * @brief Board specific configuration for the RuuviTag board + * + * @author Hauke Petersen + */ + +#ifndef BOARD_H +#define BOARD_H + +#include "cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name LED pin configuration + * @{ + */ +#define LED0_PIN GPIO_PIN(0, 17) +#define LED1_PIN GPIO_PIN(0, 19) + +#define LED_PORT NRF_P0 +#define LED0_MASK (1 << 17) +#define LED1_MASK (1 << 19) +#define LED_MASK (LED0_MASK | LED1_MASK) + +#define LED0_ON (LED_PORT->OUTCLR = LED0_MASK) +#define LED0_OFF (LED_PORT->OUTSET = LED0_MASK) +#define LED0_TOGGLE (LED_PORT->OUT ^= LED0_MASK) + +#define LED1_ON (LED_PORT->OUTCLR = LED1_MASK) +#define LED1_OFF (LED_PORT->OUTSET = LED1_MASK) +#define LED1_TOGGLE (LED_PORT->OUT ^= LED1_MASK) +/** @} */ + +/** + * @name Button pin configuration + * @{ + */ +#define BTN0_PIN GPIO_PIN(0, 13) +#define BTN0_MODE GPIO_IN_PU +/** @} */ + +/** + * @name Environmental sensor configuration (Bosch BMX280) + * @{ + */ +#define BMX280_PARAM_CS GPIO_PIN(0, 3) +/** @} */ + +/** + * @name Accelerometer configuration + * @{ + */ +#define LIS2DH12_PARAM_CS GPIO_PIN(0, 8) +#define LIS2DH12_PARAM_INT1 GPIO_PIN(0, 2) +#define LIS2DH12_PARAM_INT2 GPIO_PIN(0, 6) +/** @} */ + +/** + * @brief Initialize board specific hardware + */ +void board_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* BOARD_H */ +/** @} */ diff --git a/boards/ruuvitag/include/periph_conf.h b/boards/ruuvitag/include/periph_conf.h new file mode 100644 index 0000000000..95105cf71e --- /dev/null +++ b/boards/ruuvitag/include/periph_conf.h @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2017 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_ruuvitag + * @{ + * + * @file + * @brief Peripheral configuration for the RuuviTag + * + * @author Hauke Petersen + * + */ + +#ifndef PERIPH_CONF_H +#define PERIPH_CONF_H + +#include "periph_cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Clock configuration + * + * @note The radio will not work with the internal RC oscillator! + * + * @{ + */ +#define CLOCK_HFCLK (32U) /* set to 0: internal RC oscillator + * 32: 32MHz crystal */ +#define CLOCK_LFCLK (1) /* set to 0: internal RC oscillator + * 1: 32.768 kHz crystal + * 2: derived from HFCLK */ +/** @} */ + +/** + * @name Timer configuration + * @{ + */ +static const timer_conf_t timer_config[] = { + { + .dev = NRF_TIMER1, + .channels = 3, + .bitmode = TIMER_BITMODE_BITMODE_32Bit, + .irqn = TIMER1_IRQn + } +}; + +#define TIMER_0_ISR isr_timer1 + +#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) +/** @} */ + +/** + * @name Real time counter configuration + * @{ + */ +#define RTT_NUMOF (1U) +#define RTT_DEV (1) /* NRF_RTC1 */ +#define RTT_MAX_VALUE (0x00ffffff) +#define RTT_FREQUENCY (1024) +/** @} */ + +/** + * @name SPI configuration + * @{ + */ +static const spi_conf_t spi_config[] = { + { + .dev = NRF_SPI0, + .sclk = 29, + .mosi = 25, + .miso = 28, + } +}; + +#define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0])) +/** @} */ + +/** + * @name UART configuration + * @{ + */ +#define UART_NUMOF (1U) +#define UART_PIN_RX GPIO_PIN(0, 4) +#define UART_PIN_TX GPIO_PIN(0, 5) +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* PERIPH_CONF_H */