From a4463be1e39f9c483fe0d18efe7b2a82712b24f3 Mon Sep 17 00:00:00 2001
From: Alexandre Abadie <alexandre.abadie@inria.fr>
Date: Wed, 24 Oct 2018 17:56:24 +0200
Subject: [PATCH] boards/microbit: factorize common code

---
 boards/microbit/Makefile.dep      |  4 +---
 boards/microbit/Makefile.features | 11 ++---------
 boards/microbit/Makefile.include  | 15 +++++----------
 boards/microbit/include/board.h   | 16 +---------------
 4 files changed, 9 insertions(+), 37 deletions(-)

diff --git a/boards/microbit/Makefile.dep b/boards/microbit/Makefile.dep
index e54ceaf6ec..73cf142b58 100644
--- a/boards/microbit/Makefile.dep
+++ b/boards/microbit/Makefile.dep
@@ -7,6 +7,4 @@ ifneq (,$(filter saul_default,$(USEMODULE)))
   USEMODULE += saul_gpio
 endif
 
-ifneq (,$(filter gnrc_netdev_default netdev_default,$(USEMODULE)))
-  USEMODULE += nrfmin
-endif
+include $(RIOTBOARD)/common/nrf51/Makefile.dep
diff --git a/boards/microbit/Makefile.features b/boards/microbit/Makefile.features
index 2c53068f05..e8d2c5b39d 100644
--- a/boards/microbit/Makefile.features
+++ b/boards/microbit/Makefile.features
@@ -1,13 +1,6 @@
 # Put defined MCU peripherals here (in alphabetical order)
-FEATURES_PROVIDED += periph_gpio periph_gpio_irq
 FEATURES_PROVIDED += periph_i2c
-FEATURES_PROVIDED += periph_rtt
-FEATURES_PROVIDED += periph_timer
 FEATURES_PROVIDED += periph_uart
 
-# Various other features (if any)
-
-# The board MPU family (used for grouping by the CI system)
-FEATURES_MCU_GROUP = cortex_m0_1
-
-include $(RIOTCPU)/nrf51/Makefile.features
+# include common nrf51 based boards features
+include $(RIOTBOARD)/common/nrf51/Makefile.features
diff --git a/boards/microbit/Makefile.include b/boards/microbit/Makefile.include
index 6349546dbd..8fb097901b 100644
--- a/boards/microbit/Makefile.include
+++ b/boards/microbit/Makefile.include
@@ -1,15 +1,12 @@
 # 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 ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*)))
 
-# setup serial terminal
-include $(RIOTMAKE)/tools/serial.inc.mk
-
-# we support flashing through plain fscopy or using JLink
+# this board supports flashing through plain fscopy, using JLink or using
+# openocd. Default programmer is fscopy
 PROGRAMMER ?= fscopy
 ifeq (fscopy,$(PROGRAMMER))
   export FFLAGS =
@@ -18,9 +15,7 @@ ifeq (fscopy,$(PROGRAMMER))
   export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
   export DEBUGGER =
   export DEBUGSERVER =
-else ifeq (jlink,$(PROGRAMMER))
-  export JLINK_DEVICE := nrf51822
-  include $(RIOTMAKE)/tools/jlink.inc.mk
-else
-  $(info ERROR: invalid flash tool specified)
 endif
+
+# include nrf51 boards common configuration
+include $(RIOTBOARD)/common/nrf51/Makefile.include
diff --git a/boards/microbit/include/board.h b/boards/microbit/include/board.h
index c2c0d8daa4..5a4d74755b 100644
--- a/boards/microbit/include/board.h
+++ b/boards/microbit/include/board.h
@@ -20,21 +20,12 @@
 #ifndef BOARD_H
 #define BOARD_H
 
-#include "cpu.h"
-#include "periph_conf.h"
+#include "board_common.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/**
- * @name    Xtimer configuration
- * @{
- */
-#define XTIMER_WIDTH                (24)
-#define XTIMER_BACKOFF              (40)
-/** @} */
-
 /**
  * @name    LED matrix pin configuration
  * @{
@@ -80,11 +71,6 @@ extern "C" {
 #define MAG3110_PARAM_ADDR          0x0e
 /** @} */
 
-/**
- * @brief   Initialize the board, also triggers the CPU initialization
- */
-void board_init(void);
-
 #ifdef __cplusplus
 }
 #endif
-- 
GitLab