From b3b0cd921a1075b7933b4b2adcf9b47989e693b8 Mon Sep 17 00:00:00 2001
From: Alexandre Abadie <alexandre.abadie@inria.fr>
Date: Fri, 26 Oct 2018 10:13:40 +0200
Subject: [PATCH] boards/calliope-mini: factorize common code

---
 boards/calliope-mini/Makefile.features | 11 ++---------
 boards/calliope-mini/Makefile.include  | 18 ++++++++----------
 boards/calliope-mini/include/board.h   | 16 +---------------
 3 files changed, 11 insertions(+), 34 deletions(-)

diff --git a/boards/calliope-mini/Makefile.features b/boards/calliope-mini/Makefile.features
index 937a642587..18eeae03c8 100644
--- a/boards/calliope-mini/Makefile.features
+++ b/boards/calliope-mini/Makefile.features
@@ -1,14 +1,7 @@
 # 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
 FEATURES_PROVIDED += periph_pwm
 
-# 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/calliope-mini/Makefile.include b/boards/calliope-mini/Makefile.include
index 7fe765e3a7..6f969e2c20 100644
--- a/boards/calliope-mini/Makefile.include
+++ b/boards/calliope-mini/Makefile.include
@@ -1,16 +1,14 @@
 # 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.usbmodem*)))
 
-# 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
 PROGRAMMER ?= fscopy
+
 ifeq (fscopy,$(PROGRAMMER))
   export FFLAGS =
   export DEBUGGER_FLAGS =
@@ -18,9 +16,9 @@ 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)
+else ifeq (openocd,$(PROGRAMMER))
+  DEBUG_ADAPTER = jlink
 endif
+
+# include nrf51 boards common configuration
+include $(RIOTBOARD)/common/nrf51/Makefile.include
diff --git a/boards/calliope-mini/include/board.h b/boards/calliope-mini/include/board.h
index 553b3a4815..099284158d 100644
--- a/boards/calliope-mini/include/board.h
+++ b/boards/calliope-mini/include/board.h
@@ -22,21 +22,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
  * @{
@@ -65,11 +56,6 @@ extern "C" {
 #define BTN1_MODE                   GPIO_IN
 /** @} */
 
-/**
- * @brief   Initialize the board, also triggers the CPU initialization
- */
-void board_init(void);
-
 #ifdef __cplusplus
 }
 #endif
-- 
GitLab