From 84cdab8c0b5cebc890b9e6861c82ce2f74d0b8cf Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 24 Oct 2018 17:55:23 +0200 Subject: [PATCH] boards/common/nrf51: introduce common location --- boards/airfy-beacon/board.c | 28 ---------- boards/common/nrf51/Makefile | 3 + boards/common/nrf51/Makefile.dep | 3 + boards/common/nrf51/Makefile.features | 5 ++ boards/common/nrf51/Makefile.include | 18 ++++++ .../{yunjia-nrf51822 => common/nrf51}/board.c | 4 +- .../nrf51}/dist/openocd.cfg | 0 boards/common/nrf51/include/board_common.h | 50 +++++++++++++++++ .../common/nrf51/include/periph_conf_common.h | 56 +++++++++++++++++++ boards/yunjia-nrf51822/dist/openocd.cfg | 3 - 10 files changed, 137 insertions(+), 33 deletions(-) delete mode 100644 boards/airfy-beacon/board.c create mode 100644 boards/common/nrf51/Makefile create mode 100644 boards/common/nrf51/Makefile.dep create mode 100644 boards/common/nrf51/Makefile.features create mode 100644 boards/common/nrf51/Makefile.include rename boards/{yunjia-nrf51822 => common/nrf51}/board.c (79%) rename boards/{airfy-beacon => common/nrf51}/dist/openocd.cfg (100%) create mode 100644 boards/common/nrf51/include/board_common.h create mode 100644 boards/common/nrf51/include/periph_conf_common.h delete mode 100644 boards/yunjia-nrf51822/dist/openocd.cfg diff --git a/boards/airfy-beacon/board.c b/boards/airfy-beacon/board.c deleted file mode 100644 index ef39f2bac0..0000000000 --- a/boards/airfy-beacon/board.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2014 Christian Mehlis - * - * 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_airfy-beacon - * @{ - * - * @file - * @brief Board specific implementations for the Airfy Beacon board - * - * @author Christian Mehlis - * - * @} - */ - -#include "board.h" -#include "cpu.h" - -void board_init(void) -{ - /* initialize the CPU */ - cpu_init(); -} diff --git a/boards/common/nrf51/Makefile b/boards/common/nrf51/Makefile new file mode 100644 index 0000000000..3a930db95c --- /dev/null +++ b/boards/common/nrf51/Makefile @@ -0,0 +1,3 @@ +MODULE = boards_common_nrf51 + +include $(RIOTBASE)/Makefile.base diff --git a/boards/common/nrf51/Makefile.dep b/boards/common/nrf51/Makefile.dep new file mode 100644 index 0000000000..7de44689f6 --- /dev/null +++ b/boards/common/nrf51/Makefile.dep @@ -0,0 +1,3 @@ +ifneq (,$(filter gnrc_netdev_default netdev_default,$(USEMODULE))) + USEMODULE += nrfmin +endif diff --git a/boards/common/nrf51/Makefile.features b/boards/common/nrf51/Makefile.features new file mode 100644 index 0000000000..e1e4f8a581 --- /dev/null +++ b/boards/common/nrf51/Makefile.features @@ -0,0 +1,5 @@ +# Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_rtt +FEATURES_PROVIDED += periph_timer + +-include $(RIOTCPU)/nrf51/Makefile.features diff --git a/boards/common/nrf51/Makefile.include b/boards/common/nrf51/Makefile.include new file mode 100644 index 0000000000..ac436a8ae7 --- /dev/null +++ b/boards/common/nrf51/Makefile.include @@ -0,0 +1,18 @@ +# define the used CPU +export CPU = nrf51 + +# setup serial terminal +include $(RIOTMAKE)/tools/serial.inc.mk + +# include common nrf51 headers +INCLUDES += -I$(RIOTBOARD)/common/nrf51/include + +ifeq ($(PROGRAMMER),openocd) + # use common openocd configuration for nrf51 + export OPENOCD_CONFIG = $(RIOTBOARD)/common/nrf51/dist/openocd.cfg + include $(RIOTMAKE)/tools/openocd.inc.mk +else ifeq ($(PROGRAMMER),jlink) + # setup JLink for flashing + export JLINK_DEVICE := nrf51822 + include $(RIOTMAKE)/tools/jlink.inc.mk +endif diff --git a/boards/yunjia-nrf51822/board.c b/boards/common/nrf51/board.c similarity index 79% rename from boards/yunjia-nrf51822/board.c rename to boards/common/nrf51/board.c index 43c50241cb..e0be826613 100644 --- a/boards/yunjia-nrf51822/board.c +++ b/boards/common/nrf51/board.c @@ -7,11 +7,11 @@ */ /** - * @ingroup boards_yunjia-nrf51822 + * @ingroup boards_common_nrf51 * @{ * * @file - * @brief Board specific implementations for the Yunjia NRF51822 board + * @brief Board initialization for the nRF51 based boards * * @author Hauke Petersen * diff --git a/boards/airfy-beacon/dist/openocd.cfg b/boards/common/nrf51/dist/openocd.cfg similarity index 100% rename from boards/airfy-beacon/dist/openocd.cfg rename to boards/common/nrf51/dist/openocd.cfg diff --git a/boards/common/nrf51/include/board_common.h b/boards/common/nrf51/include/board_common.h new file mode 100644 index 0000000000..f7bb9d3dee --- /dev/null +++ b/boards/common/nrf51/include/board_common.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2017 Freie Universität Berlin + * 2018 Inria + * + * 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_common_nrf51 NRF51 common + * @ingroup boards_common + * @brief Shared files and configuration for some nRF51 boards. + * @{ + * + * @file + * @brief Shared configuration for some nRF51-based boards + * + * @author Hauke Petersen + * @author Alexandre Abadie + */ + +#ifndef BOARD_COMMON_H +#define BOARD_COMMON_H + +#include "cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Xtimer configuration + * @{ + */ +#define XTIMER_WIDTH (24) +#define XTIMER_BACKOFF (40) +/** @} */ + +/** + * @brief Initialize the platform + */ +void board_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* BOARD_COMMON_H */ +/** @} */ diff --git a/boards/common/nrf51/include/periph_conf_common.h b/boards/common/nrf51/include/periph_conf_common.h new file mode 100644 index 0000000000..e4c296d305 --- /dev/null +++ b/boards/common/nrf51/include/periph_conf_common.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2018 Inria + * + * 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_common_nrf51 + * @{ + * + * @file + * @brief Common peripheral MCU configuration for some nrf51 based boards + * + * @author Alexandre Abadie + */ + +#ifndef PERIPH_CONF_COMMON_H +#define PERIPH_CONF_COMMON_H + +#include "periph_cpu.h" + +#ifdef __cplusplus + extern "C" { +#endif + +/** + * @name Timer configuration + * @{ + */ +static const timer_conf_t timer_config[] = { + /* dev, channels, width */ + { NRF_TIMER0, 3, TIMER_BITMODE_BITMODE_24Bit, TIMER0_IRQn } +}; + +#define TIMER_0_ISR isr_timer0 + +#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) +/** @} */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif + +#endif /* PERIPH_CONF_COMMON_H */ diff --git a/boards/yunjia-nrf51822/dist/openocd.cfg b/boards/yunjia-nrf51822/dist/openocd.cfg deleted file mode 100644 index d16a15a3ec..0000000000 --- a/boards/yunjia-nrf51822/dist/openocd.cfg +++ /dev/null @@ -1,3 +0,0 @@ -set WORKAREASIZE 0x4000 -source [find target/nrf51.cfg] -$_TARGETNAME configure -rtos auto