From a89e43ae316f67cefdd70e4ebe31ef8b4e0b0a66 Mon Sep 17 00:00:00 2001
From: Federico Pellegrin <fede@evolware.org>
Date: Thu, 11 Oct 2018 21:33:50 +0200
Subject: [PATCH] sys/arduino: add possibility to customize Arduino serial port
 at compile time

---
 sys/arduino/doc.txt             |  6 ++++++
 sys/arduino/include/arduino.hpp | 11 +++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/sys/arduino/doc.txt b/sys/arduino/doc.txt
index 5966b7d21f..253c4651cb 100644
--- a/sys/arduino/doc.txt
+++ b/sys/arduino/doc.txt
@@ -112,6 +112,12 @@
  * @endcode
  *   This links to the third entry in the `arduino_pinmap` array.
  *
+ * - a define `ARDUINO_UART_DEV` that defines the UART to use as the Arduino
+ *   primary serial port (default UART_DEV(0)):
+ * @code{c}
+ *  #define ARDUINO_UART_DEV         (UART_DEV(3))
+ * @endcode
+ *
  * In addition, you have to add the 'arduino' feature to the board. For this,
  * just add `FEATURES_PROVIDED += arduino` to the 'other features' section in
  * your board's `Makefile.features'.
diff --git a/sys/arduino/include/arduino.hpp b/sys/arduino/include/arduino.hpp
index b94f17519f..d14e346f88 100644
--- a/sys/arduino/include/arduino.hpp
+++ b/sys/arduino/include/arduino.hpp
@@ -45,10 +45,17 @@ enum {
     HIGH = 1            /**< pin is set */
 };
 
+#ifndef ARDUINO_UART_DEV
 /**
- * @brief   Primary serial port (mapped to UART_DEV(0))
+ * @brief UART device to use for Arduino serial
  */
-static SerialPort Serial(UART_DEV(0));
+#define ARDUINO_UART_DEV        UART_DEV(0)
+#endif
+
+/**
+ * @brief   Primary serial port (mapped to ARDUINO_UART_DEV)
+ */
+static SerialPort Serial(ARDUINO_UART_DEV);
 
 /**
  * @brief   Configure a pin as either input or output
-- 
GitLab