diff --git a/boards.txt b/boards.txt index 4275780c57..962e230930 100644 --- a/boards.txt +++ b/boards.txt @@ -2,7 +2,7 @@ menu.pnum=Board part number -menu.xserial=Extra serial instance +menu.xserial=Serial interface menu.usb=USB interface menu.opt=Optimize @@ -328,37 +328,37 @@ Disco.menu.upload_method.STLink.upload.tool=stlink_upload ################################################################################ # Serialx activation -Nucleo_144.menu.xserial.none=None -Nucleo_144.menu.xserial.SerialAll=All -Nucleo_144.menu.xserial.SerialAll.build.xSerial=-DENABLE_SERIAL1 -DENABLE_SERIAL2 -Nucleo_144.menu.xserial.Serial1=Serial1 (if available) -Nucleo_144.menu.xserial.Serial1.build.xSerial=-DENABLE_SERIAL1 -Nucleo_144.menu.xserial.Serial2=Serial2 (if available) -Nucleo_144.menu.xserial.Serial2.build.xSerial=-DENABLE_SERIAL2 - -Nucleo_64.menu.xserial.none=None -Nucleo_64.menu.xserial.SerialAll=All -Nucleo_64.menu.xserial.SerialAll.build.xSerial=-DENABLE_SERIAL1 -DENABLE_SERIAL2 -Nucleo_64.menu.xserial.Serial1=Serial1 (if available) -Nucleo_64.menu.xserial.Serial1.build.xSerial=-DENABLE_SERIAL1 -Nucleo_64.menu.xserial.Serial2=Serial2 (if available) -Nucleo_64.menu.xserial.Serial2.build.xSerial=-DENABLE_SERIAL2 - -Nucleo_32.menu.xserial.none=None -Nucleo_32.menu.xserial.SerialAll=All -Nucleo_32.menu.xserial.SerialAll.build.xSerial=-DENABLE_SERIAL1 -DENABLE_SERIAL2 -Nucleo_32.menu.xserial.Serial1=Serial1 (if available) -Nucleo_32.menu.xserial.Serial1.build.xSerial=-DENABLE_SERIAL1 -Nucleo_32.menu.xserial.Serial2=Serial2 (if available) -Nucleo_32.menu.xserial.Serial2.build.xSerial=-DENABLE_SERIAL2 - -Disco.menu.xserial.none=None -Disco.menu.xserial.SerialAll=All -Disco.menu.xserial.SerialAll.build.xSerial=-DENABLE_SERIAL1 -DENABLE_SERIAL2 -Disco.menu.xserial.Serial1=Serial1 (if available) -Disco.menu.xserial.Serial1.build.xSerial=-DENABLE_SERIAL1 -Disco.menu.xserial.Serial2=Serial2 (if available) -Disco.menu.xserial.Serial2.build.xSerial=-DENABLE_SERIAL2 +Nucleo_144.menu.xserial.generic=Generic Serial +Nucleo_144.menu.xserial.none=No Serial +Nucleo_144.menu.xserial.none.build.xSerial=-DNO_HWSERIAL +Nucleo_144.menu.xserial.all=All (up to 10) +Nucleo_144.menu.xserial.all.build.xSerial=-DALL_HWSERIAL +Nucleo_144.menu.xserial.third=Enable first third (USART1 to 3 if available) +Nucleo_144.menu.xserial.third.build.xSerial=-DFIRST_THIRD_HWSERIAL + +Nucleo_64.menu.xserial.generic=Generic Serial +Nucleo_64.menu.xserial.none=No Serial +Nucleo_64.menu.xserial.none.build.xSerial=-DNO_HWSERIAL +Nucleo_64.menu.xserial.all=All (up to 10) +Nucleo_64.menu.xserial.all.build.xSerial=-DALL_HWSERIAL +Nucleo_64.menu.xserial.third=Enable first third (USART1 to 3 if available) +Nucleo_64.menu.xserial.third.build.xSerial=-DFIRST_THIRD_HWSERIAL + +Nucleo_32.menu.xserial.generic=Generic Serial +Nucleo_32.menu.xserial.none=No Serial +Nucleo_32.menu.xserial.none.build.xSerial=-DNO_HWSERIAL +Nucleo_32.menu.xserial.all=All (up to 10) +Nucleo_32.menu.xserial.all.build.xSerial=-DALL_HWSERIAL +Nucleo_32.menu.xserial.third=Enable first third (USART1 to 3 if available) +Nucleo_32.menu.xserial.third.build.xSerial=-DFIRST_THIRD_HWSERIAL + +Disco.menu.xserial.generic=Generic Serial +Disco.menu.xserial.none=No Serial +Disco.menu.xserial.none.build.xSerial=-DNO_HWSERIAL +Disco.menu.xserial.all=All (up to 10) +Disco.menu.xserial.all.build.xSerial=-DALL_HWSERIAL +Disco.menu.xserial.third=Enable first third (USART1 to 3 if available) +Disco.menu.xserial.third.build.xSerial=-DFIRST_THIRD_HWSERIAL # USB connectivity Nucleo_144.menu.usb.none=None diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index dc2306a42d..7c709815cf 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -30,12 +30,143 @@ #include "Arduino.h" #include "HardwareSerial.h" +#if !defined(NO_HWSERIAL) +#if defined(HAVE_HWSERIAL1) || defined(HAVE_HWSERIAL2) || defined(HAVE_HWSERIAL3) ||\ + defined(HAVE_HWSERIAL4) || defined(HAVE_HWSERIAL5) || defined(HAVE_HWSERIAL6) ||\ + defined(HAVE_HWSERIAL7) || defined(HAVE_HWSERIAL8) || defined(HAVE_HWSERIAL8) ||\ + defined(HAVE_HWSERIAL10) +// SerialEvent functions are weak, so when the user doesn't define them, +// the linker just sets their address to 0 (which is checked below). +#if defined(HAVE_HWSERIAL1) + HardwareSerial Serial1(USART1); + void serialEvent1() __attribute__((weak)); +#endif + +#if defined(HAVE_HWSERIAL2) + HardwareSerial Serial2(USART2); + void serialEvent2() __attribute__((weak)); +#endif + +#if defined(HAVE_HWSERIAL3) + HardwareSerial Serial3(USART3); + void serialEvent3() __attribute__((weak)); +#endif + +#if defined(HAVE_HWSERIAL4) +#if defined(USART4) + HardwareSerial Serial4(USART4); +#else + HardwareSerial Serial4(UART4); +#endif + void serialEvent4() __attribute__((weak)); +#endif + +#if defined(HAVE_HWSERIAL5) +#if defined(USART5) + HardwareSerial Serial5(USART5); +#else + HardwareSerial Serial5(UART5); +#endif + void serialEvent5() __attribute__((weak)); +#endif + +#if defined(HAVE_HWSERIAL6) + HardwareSerial Serial6(USART6); + void serialEvent6() __attribute__((weak)); +#endif + +#if defined(HAVE_HWSERIAL7) +#if defined(USART7) + HardwareSerial Serial7(USART7); +#else + HardwareSerial Serial7(UART7); +#endif + void serialEvent7() __attribute__((weak)); +#endif + +#if defined(HAVE_HWSERIAL8) +#if defined(USART8) + HardwareSerial Serial8(USART8); +#else + HardwareSerial Serial8(UART8); +#endif + void serialEvent8() __attribute__((weak)); +#endif + +#if defined(HAVE_HWSERIAL9) + HardwareSerial Serial9(UART9); + void serialEvent9() __attribute__((weak)); +#endif + +#if defined(HAVE_HWSERIAL10) + HardwareSerial Serial10(UART10); + void serialEvent10() __attribute__((weak)); +#endif + +void serialEventRun(void) +{ +#if defined(HAVE_HWSERIAL1) + if (serialEvent1 && Serial1.available()) serialEvent1(); +#endif +#if defined(HAVE_HWSERIAL2) + if (serialEvent2 && Serial2.available()) serialEvent2(); +#endif +#if defined(HAVE_HWSERIAL3) + if (serialEvent3 && Serial3.available()) serialEvent3(); +#endif +#if defined(HAVE_HWSERIAL4) + if (serialEvent4 && Serial4.available()) serialEvent4(); +#endif +#if defined(HAVE_HWSERIAL5) + if (serialEvent5 && Serial5.available()) serialEvent5(); +#endif +#if defined(HAVE_HWSERIAL6) + if (serialEvent6 && Serial6.available()) serialEvent6(); +#endif +#if defined(HAVE_HWSERIAL7) + if (serialEvent7 && Serial7.available()) serialEvent7(); +#endif +#if defined(HAVE_HWSERIAL8) + if (serialEvent8 && Serial8.available()) serialEvent8(); +#endif +#if defined(HAVE_HWSERIAL9) + if (serialEvent9 && Serial9.available()) serialEvent9(); +#endif +#if defined(HAVE_HWSERIAL10) + if (serialEventl10 && Serial10.available()) serialEvent10(); +#endif +} // Constructors //////////////////////////////////////////////////////////////// HardwareSerial::HardwareSerial(PinName _rx, PinName _tx) { _serial.pin_rx = _rx; _serial.pin_tx = _tx; + init(); +} + +HardwareSerial::HardwareSerial(void* peripheral) +{ +// If Serial is defined in variant set +// the Rx/Tx pins for com port if defined +#if defined(Serial) && defined(PIN_SERIAL_RX) && defined(PIN_SERIAL_TX) + if (this == &Serial) + { + setRx(PIN_SERIAL_RX); + setTx(PIN_SERIAL_TX); + } + else +#endif +// else get the pins of the first peripheral occurence in PinMap + { + _serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX); + _serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX); + } + init(); +} + +void HardwareSerial::init(void) +{ _serial.rx_buff = _rx_buffer; _serial.rx_head = 0; _serial.rx_tail = 0; @@ -87,7 +218,7 @@ void HardwareSerial::begin(unsigned long baud, byte config) _serial.baudrate = (uint32_t)baud; - // Manage databits + // Manage databitshardware/arduino/avr/cores/arduino/HardwareSerial.cpp switch(config & 0x07) { case 0x02: databits = 6; @@ -224,3 +355,21 @@ size_t HardwareSerial::write(uint8_t c) return 1; } + +void HardwareSerial::setRx(uint32_t _rx) { + _serial.pin_rx = digitalPinToPinName(_rx); +} + +void HardwareSerial::setTx(uint32_t _tx) { + _serial.pin_tx = digitalPinToPinName(_tx); +} + +void HardwareSerial::setRx(PinName _rx) { + _serial.pin_rx = _rx; +} + +void HardwareSerial::setTx(PinName _tx){ + _serial.pin_tx = _tx; +} +#endif // HAVE_HWSERIALx +#endif // !NO_HWSERIAL diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index b31e58e127..d945dda495 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -102,6 +102,7 @@ class HardwareSerial : public Stream public: HardwareSerial(PinName _rx, PinName _tx); + HardwareSerial(void* peripheral); void begin(unsigned long baud) { begin(baud, SERIAL_8N1); } void begin(unsigned long, uint8_t); void end(); @@ -118,11 +119,29 @@ class HardwareSerial : public Stream using Print::write; // pull in write(str) and write(buf, size) from Print operator bool() { return true; } + void setRx(uint32_t _rx); + void setTx(uint32_t _tx); + void setRx(PinName _rx); + void setTx(PinName _tx); + // Interrupt handlers static void _rx_complete_irq(serial_t* obj); static int _tx_complete_irq(serial_t* obj); + private: + void init(void); }; +extern HardwareSerial Serial1; +extern HardwareSerial Serial2; +extern HardwareSerial Serial3; +extern HardwareSerial Serial4; +extern HardwareSerial Serial5; +extern HardwareSerial Serial6; +extern HardwareSerial Serial7; +extern HardwareSerial Serial8; +extern HardwareSerial Serial9; +extern HardwareSerial Serial10; + extern void serialEventRun(void) __attribute__((weak)); #endif diff --git a/cores/arduino/stm32/core_callback.h b/cores/arduino/stm32/core_callback.h index 197009d2ec..02f2acfa98 100644 --- a/cores/arduino/stm32/core_callback.h +++ b/cores/arduino/stm32/core_callback.h @@ -39,7 +39,7 @@ #ifndef __CALLBACK_H #define __CALLBACK_H -#include "Arduino.h" +#include "variant.h" #ifdef __cplusplus extern "C" { diff --git a/cores/arduino/stm32/pinmap.c b/cores/arduino/stm32/pinmap.c index fcdf0c635b..abcd381ef9 100644 --- a/cores/arduino/stm32/pinmap.c +++ b/cores/arduino/stm32/pinmap.c @@ -36,6 +36,25 @@ void* pinmap_peripheral(PinName pin, const PinMap* map) { return peripheral; } +PinName pinmap_find_pin(void* peripheral, const PinMap* map) { + while (map->peripheral != NP) { + if (map->peripheral == peripheral) + return map->pin; + map++; + } + return NC; +} + +PinName pinmap_pin(void* peripheral, const PinMap* map) { + PinName pin = NC; + + if (peripheral != NP) { + pin = pinmap_find_pin(peripheral, map); + } + // else error("pinmap not found for pin"); + return pin; +} + uint32_t pinmap_find_function(PinName pin, const PinMap* map) { while (map->pin != NC) { if (map->pin == pin) diff --git a/cores/arduino/stm32/pinmap.h b/cores/arduino/stm32/pinmap.h index 58344fdca9..857b9c3461 100644 --- a/cores/arduino/stm32/pinmap.h +++ b/cores/arduino/stm32/pinmap.h @@ -41,10 +41,12 @@ void pin_function(PinName pin, int function); PinName pin_pinName(const PinMap* map); -void* pinmap_peripheral(PinName pin, const PinMap* map); -uint32_t pinmap_function(PinName pin, const PinMap* map); void* pinmap_find_peripheral(PinName pin, const PinMap* map); +void* pinmap_peripheral(PinName pin, const PinMap* map); +PinName pinmap_find_pin(void* peripheral, const PinMap* map); +PinName pinmap_pin(void* peripheral, const PinMap* map); uint32_t pinmap_find_function(PinName pin, const PinMap* map); +uint32_t pinmap_function(PinName pin, const PinMap* map); void* pinmap_merge_peripheral(void* a, void* b); #ifdef __cplusplus diff --git a/cores/arduino/stm32/timer.c b/cores/arduino/stm32/timer.c index 0a5080e7b1..24a432567a 100644 --- a/cores/arduino/stm32/timer.c +++ b/cores/arduino/stm32/timer.c @@ -46,12 +46,8 @@ /** @addtogroup STM32F4xx_System_Private_Includes * @{ */ -#include "stm32_def.h" #include "timer.h" -#include "digital_io.h" -#include "clock.h" -#include "analog.h" -#include "variant.h" +#include "board.h" #ifdef __cplusplus extern "C" { diff --git a/cores/arduino/stm32/uart.c b/cores/arduino/stm32/uart.c index 33d2f53cbc..49b6162f66 100644 --- a/cores/arduino/stm32/uart.c +++ b/cores/arduino/stm32/uart.c @@ -54,6 +54,15 @@ extern "C" { #endif +// if DEBUG_UART is not defined assume this is the one +// linked to PIN_SERIAL_TX +#if !defined(DEBUG_UART) +#if defined(PIN_SERIAL_TX) +#define DEBUG_UART pinmap_peripheral(digitalPinToPinName(PIN_SERIAL_TX), PinMap_UART_TX) +#else +#define DEBUG_UART NP +#endif +#endif // @brief uart caracteristics #if defined(STM32F4xx) #define UART_NUM (10) @@ -398,11 +407,11 @@ size_t uart_write(serial_t *obj, uint8_t data, uint16_t size) size_t uart_debug_write(uint8_t *data, uint32_t size) { uint8_t index = 0; + USART_TypeDef* dbg_uart = DEBUG_UART; uint32_t tickstart = HAL_GetTick(); - for(index = 0; index < UART_NUM; index++) { if(uart_handlers[index] != NULL) { - if(DEBUG_UART == uart_handlers[index]->Instance) { + if(dbg_uart == uart_handlers[index]->Instance) { break; } } diff --git a/cores/arduino/stm32/uart.h b/cores/arduino/stm32/uart.h index 0548baffdc..1a82e628d4 100644 --- a/cores/arduino/stm32/uart.h +++ b/cores/arduino/stm32/uart.h @@ -41,12 +41,147 @@ /* Includes ------------------------------------------------------------------*/ #include "stm32_def.h" -#include "PeripheralPins.h" +#include "variant.h" #ifdef __cplusplus extern "C" { #endif +#if !defined(NO_HWSERIAL) +#if defined(ALL_HWSERIAL) || defined(FIRST_THIRD_HWSERIAL) +#define ENABLE_HWSERIAL1 +#define ENABLE_HWSERIAL2 +#define ENABLE_HWSERIAL3 +#if !defined(FIRST_THIRD_HWSERIAL) +#define ENABLE_HWSERIAL4 +#define ENABLE_HWSERIAL5 +#define ENABLE_HWSERIAL6 +#define ENABLE_HWSERIAL7 +#define ENABLE_HWSERIAL8 +#define ENABLE_HWSERIAL9 +#define ENABLE_HWSERIAL10 +#endif // FIRST_THIRD_HWSERIAL +#endif // ALL_HWSERIAL || FIRST_THIRD_HWSERIAL +#ifdef SERIAL_UART_INSTANCE +#if SERIAL_UART_INSTANCE == 1 +#define ENABLE_HWSERIAL1 +#if !defined(Serial) +#define Serial Serial1 +#define serialEvent serialEvent1 +#endif +#elif SERIAL_UART_INSTANCE == 2 +#define ENABLE_HWSERIAL2 +#if !defined(Serial) +#define Serial Serial2 +#define serialEvent serialEvent2 +#endif +#elif SERIAL_UART_INSTANCE == 3 +#define ENABLE_HWSERIAL3 +#if !defined(Serial) +#define Serial Serial3 +#define serialEvent serialEvent3 +#endif +#elif SERIAL_UART_INSTANCE == 4 +#define ENABLE_HWSERIAL4 +#if !defined(Serial) +#define Serial Serial4 +#define serialEvent serialEvent4 +#endif +#elif SERIAL_UART_INSTANCE == 5 +#define ENABLE_HWSERIAL5 +#if !defined(Serial) +#define Serial Serial5 +#define serialEvent serialEvent5 +#endif +#elif SERIAL_UART_INSTANCE == 6 +#define ENABLE_HWSERIAL6 +#if !defined(Serial) +#define Serial Serial6 +#define serialEvent serialEvent6 +#endif +#elif SERIAL_UART_INSTANCE == 7 +#define ENABLE_HWSERIAL7 +#if !defined(Serial) +#define Serial Serial7 +#define serialEvent serialEvent7 +#endif +#elif SERIAL_UART_INSTANCE == 8 +#define ENABLE_HWSERIAL8 +#if !defined(Serial) +#define Serial Serial8 +#define serialEvent serialEvent8 +#endif +#elif SERIAL_UART_INSTANCE == 9 +#define ENABLE_HWSERIAL9 +#if !defined(Serial) +#define Serial Serial9 +#define serialEvent serialEvent9 +#endif +#elif SERIAL_UART_INSTANCE == 10 +#define ENABLE_HWSERIAL10 +#if !defined(Serial) +#define Serial Serial10 +#define serialEvent serialEvent10 +#endif +#endif // SERIAL_UART_INSTANCE == x +#else +#if !defined(Serial) +#warning "No generic 'Serial' defined!" +#endif +#endif // SERIAL_UART_INSTANCE +#endif // NO_HWSERIAL + +#if defined(ENABLE_HWSERIAL1) +#if defined(USART1_BASE) +#define HAVE_HWSERIAL1 +#endif +#endif +#if defined(ENABLE_HWSERIAL2) +#if defined(USART2_BASE) +#define HAVE_HWSERIAL2 +#endif +#endif +#if defined(ENABLE_HWSERIAL3) +#if defined(USART3_BASE) +#define HAVE_HWSERIAL3 +#endif +#endif +#if defined(ENABLE_HWSERIAL4) +#if defined(USART4_BASE) || defined(UART4_BASE) +#define HAVE_HWSERIAL4 +#endif +#endif +#if defined(ENABLE_HWSERIAL5) +#if defined(USART5_BASE) || defined(UART5_BASE) +#define HAVE_HWSERIAL5 +#endif +#endif +#if defined(ENABLE_HWSERIAL6) +#if defined(USART6_BASE) +#define HAVE_HWSERIAL6 +#endif +#endif +#if defined(ENABLE_HWSERIAL7) +#if defined(USART7_BASE) || defined(UART7_BASE) +#define HAVE_HWSERIAL7 +#endif +#endif +#if defined(ENABLE_HWSERIAL8) +#if defined(USART8_BASE) || defined(UART8_BASE) +#define HAVE_HWSERIAL8 +#endif +#endif +#if defined(ENABLE_HWSERIAL9) +#if defined(UART9_BASE) +#define HAVE_HWSERIAL9 +#endif +#endif +#if defined(ENABLE_HWSERIAL10) +#if defined(UART10_BASE) +#define HAVE_HWSERIAL10 +#endif +#endif + /* Exported types ------------------------------------------------------------*/ typedef struct serial_s serial_t; diff --git a/variants/DISCO_F100RB/variant.cpp b/variants/DISCO_F100RB/variant.cpp index 09a0d7675b..e15dfcb23a 100644 --- a/variants/DISCO_F100RB/variant.cpp +++ b/variants/DISCO_F100RB/variant.cpp @@ -97,40 +97,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ - - HardwareSerial Serial(PA_3, PA_2); - #ifdef ENABLE_SERIAL1 - HardwareSerial Serial1(PA_10, PA_9); - #endif - #ifdef ENABLE_SERIAL2 - HardwareSerial Serial2(PB_11, PB_10); - #endif - - void serialEvent() __attribute__((weak)); - void serialEvent() { } - #ifdef ENABLE_SERIAL1 - void serialEvent1() __attribute__((weak)); - void serialEvent1() { } - #endif - #ifdef ENABLE_SERIAL2 - void serialEvent2() __attribute__((weak)); - void serialEvent2() { } - #endif - - void serialEventRun(void) - { - if (Serial.available()) serialEvent(); - #ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); - #endif - #ifdef ENABLE_SERIAL2 - if (Serial2.available()) serialEvent2(); - #endif - } - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/DISCO_F100RB/variant.h b/variants/DISCO_F100RB/variant.h index 6888e978c2..b267c78bfd 100644 --- a/variants/DISCO_F100RB/variant.h +++ b/variants/DISCO_F100RB/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { @@ -152,15 +150,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM17 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART2) - -// Serial Pin Firmata +// UART Definitions +#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata #define PIN_SERIAL_RX 8 #define PIN_SERIAL_TX 7 -#define PIN_SERIAL1_RX 24 -#define PIN_SERIAL1_TX 23 -#define PIN_SERIAL2_RX 42 -#define PIN_SERIAL2_TX 41 #ifdef __cplusplus } // extern "C" @@ -169,28 +164,24 @@ enum { * Arduino objects - C++ only *----------------------------------------------------------------------------*/ - #ifdef __cplusplus - extern HardwareSerial Serial; - extern HardwareSerial Serial1; - extern HardwareSerial Serial2; - - // These serial port names are intended to allow libraries and architecture-neutral - // sketches to automatically default to the correct port name for a particular type - // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, - // the first hardware serial port whose RX/TX pins are not dedicated to another use. - // - // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor - // - // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial - // - // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library - // - // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. - // - // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX - // pins are NOT connected to anything by default. - #define SERIAL_PORT_MONITOR Serial - #define SERIAL_PORT_HARDWARE Serial - #endif +#ifdef __cplusplus +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial +#endif #endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/DISCO_F407VG/variant.cpp b/variants/DISCO_F407VG/variant.cpp index 4933c5cb4f..05cb519bef 100644 --- a/variants/DISCO_F407VG/variant.cpp +++ b/variants/DISCO_F407VG/variant.cpp @@ -123,20 +123,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ - -HardwareSerial Serial(PA_3, PA_2); // Could be connected to ST-Link - -void serialEvent() __attribute__((weak)); -void serialEvent() { } - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/DISCO_F407VG/variant.h b/variants/DISCO_F407VG/variant.h index cb3c489261..e0f0d6804c 100644 --- a/variants/DISCO_F407VG/variant.h +++ b/variants/DISCO_F407VG/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { @@ -177,15 +175,16 @@ enum { #define TIMER_SERVO TIM7 #define TIMER_UART_EMULATED TIM6 -#define DEBUG_UART ((USART_TypeDef *) USART2) - +// UART Definitions +#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link // UART Emulation #define UART_EMUL_RX PE_9 #define UART_EMUL_TX PE_11 -// Serial Pin Firmata -#define PIN_SERIAL_RX 42 -#define PIN_SERIAL_TX 3 +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX PA3 +#define PIN_SERIAL_TX PA2 #ifdef __cplusplus } // extern "C" @@ -195,8 +194,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -212,8 +209,8 @@ extern HardwareSerial Serial; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial // Require connections for ST-LINK VCP on U2 pin 12 and 13. - // See UM §6.1.3 ST-LINK/V2-A VCP configuration) +#define SERIAL_PORT_MONITOR Serial // Require connections for ST-LINK VCP on U2 pin 12 and 13. + // See UM §6.1.3 ST-LINK/V2-A VCP configuration) #define SERIAL_PORT_HARDWARE_OPEN Serial #endif diff --git a/variants/DISCO_F746NG/variant.cpp b/variants/DISCO_F746NG/variant.cpp index 257344f059..027661de9f 100644 --- a/variants/DISCO_F746NG/variant.cpp +++ b/variants/DISCO_F746NG/variant.cpp @@ -55,39 +55,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ -HardwareSerial Serial(PB_7, PA_9); // Connected to ST-Link -#ifdef ENABLE_SERIAL1 -HardwareSerial Serial1(PC_7, PC_6); -#endif -#ifdef ENABLE_SERIAL2 -HardwareSerial Serial2(PF_6, PF_7); -#endif - -void serialEvent() __attribute__((weak)); -void serialEvent() { } -#ifdef ENABLE_SERIAL1 -void serialEvent1() __attribute__((weak)); -void serialEvent1() { } -#endif -#ifdef ENABLE_SERIAL2 -void serialEvent2() __attribute__((weak)); -void serialEvent2() { } -#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -#ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); -#endif -#ifdef ENABLE_SERIAL2 - if (Serial2.available()) serialEvent2(); -#endif -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/DISCO_F746NG/variant.h b/variants/DISCO_F746NG/variant.h index bfaa8f56cf..f8cf9f3147 100644 --- a/variants/DISCO_F746NG/variant.h +++ b/variants/DISCO_F746NG/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { @@ -109,19 +107,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART1) - -// UART Emulation -//#define UART_EMUL_RX PX_n -//#define UART_EMUL_TX PX_n - -// Serial Pin Firmata -#define PIN_SERIAL_RX 23 -#define PIN_SERIAL_TX 24 -#define PIN_SERIAL1_RX 0 -#define PIN_SERIAL1_TX 1 -#define PIN_SERIAL2_RX 21 -#define PIN_SERIAL2_TX 20 +// UART Definitions +#define SERIAL_UART_INSTANCE 1 //Connected to ST-Link +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX PB7 +#define PIN_SERIAL_TX PA9 #ifdef __cplusplus } // extern "C" @@ -131,10 +122,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -150,8 +137,8 @@ extern HardwareSerial Serial2; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial #endif #endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/DISCO_L475VG_IOT/variant.cpp b/variants/DISCO_L475VG_IOT/variant.cpp index 1c0d6363da..fdc4cf817b 100644 --- a/variants/DISCO_L475VG_IOT/variant.cpp +++ b/variants/DISCO_L475VG_IOT/variant.cpp @@ -45,105 +45,85 @@ const PinName digitalPin[] = { // Not on connector PB_14, //D16 - LED2 PC_13, //D17 - USER_BTN +// ST-LINK + PB_6, //D18 - ST-LINK-UART1_TX + PB_7, //D19 - ST-LINK-UART1_RX // CN9 USB OTG FS connector - PA_9, //D18 - USB_OTG_FS_VBUS - PA_10, //D19 - USB_OTG_FS_ID - PA_11, //D20 - USB_OTG_FS_DM - PA_12, //D21 - USB_OTG_FS_DP - PD_12, //D22 - USB_OTG_FS_PWR_EN - PE_3, //D23 - USB_OTG_OVRCR_EXTI3 + PA_9, //D20 - USB_OTG_FS_VBUS + PA_10, //D21 - USB_OTG_FS_ID + PA_11, //D22 - USB_OTG_FS_DM + PA_12, //D23 - USB_OTG_FS_DP + PD_12, //D24 - USB_OTG_FS_PWR_EN + PE_3, //D25 - USB_OTG_OVRCR_EXTI3 // CN10 PMOD connector - PD_0, //D24 - PMOD-RESET - PD_1, //D25 - PMOD-SPI2_SCK - PD_2, //D26 - PMOD-IRQ_EXTI2 - PD_3, //D27 - PMOD-UART2_CTS/SPI2_MISO - PD_4, //D28 - PMOD-UART2_RTS/SPI2_MOSI - PD_5, //D29 - PMOD-UART2_TX/SPI2_CSN - PD_6, //D30 - PMOD-UART2_RX + PD_0, //D26 - PMOD-RESET + PD_1, //D27 - PMOD-SPI2_SCK + PD_2, //D28 - PMOD-IRQ_EXTI2 + PD_3, //D29 - PMOD-UART2_CTS/SPI2_MISO + PD_4, //D30 - PMOD-UART2_RTS/SPI2_MOSI + PD_5, //D31 - PMOD-UART2_TX/SPI2_CSN + PD_6, //D32 - PMOD-UART2_RX // Sensors / modules pins - PA_8, //D31 - SPBTLE-RF-RST - PB_5, //D32 - SPSGRF-915-SPI3_CSN - PB_10, //D33 - INTERNAL-I2C2_SCL - PB_11, //D34 - INTERNAL-I2C2_SDA - PB_12, //D35 - ISM43362-BOOT0 - PB_13, //D36 - ISM43362-WAKEUP - PB_15, //D37 - SPSGRF-915-SDN - PC_6, //D38 - VL53L0X_XSHUT - PC_7, //D39 - VL53L0X_GPIO1_EXTI7 - PC_8, //D40 - LIS3MDL_DRDY_EXTI8 - PC_9, //D41 - LED3 (WIFI) & LED4 (BLE) - PC_10, //D42 - INTERNAL-SPI3_SCK - PC_11, //D43 - INTERNAL-SPI3_MISO - PC_12, //D44 - INTERNAL-SPI3_MOSI - PD_7, //D45 - STSAFE-A100-RESET - PD_8, //D46 - INTERNAL-UART3_TX - PD_9, //D47 - INTERNAL-UART3_RX - PD_10, //D48 - LPS22HB_INT_DRDY_EXTI10 - PD_11, //D49 - LSM6DSL_INT1_EXTI11 - PD_13, //D50 - SPBTLE-RF-SPI3_CSN - PD_15, //D51 - HTS221_DRDY_EXTI15 - PE_0, //D52 - ISM43362-SPI3_CSN - PE_1, //D53 - ISM43362-DRDY_EXTI1 - PE_2, //D54 - M24SR64-Y-RF_DISABLE - PE_4, //D55 - M24SR64-Y-GPO - PE_5, //D56 - SPSGRF-915-GPIO3_EXTI5 - PE_6, //D57 - SPBTLE-RF-IRQ_EXTI6 - PE_7, //D58 - DFSDM1_DATIN2 - PE_8, //D59 - ISM43362-RST - PE_9, //D60 - DFSDM1_CKOUT - PE_10, //D61 - QUADSPI_CLK - PE_11, //D62 - QUADSPI_NCS - PE_12, //D63 - QUADSPI_BK1_IO0 - PE_13, //D64 - QUADSPI_BK1_IO1 - PE_14, //D65 - QUADSPI_BK1_IO2 - PE_15, //D66 - QUADSPI_BK1_IO3 + PA_8, //D33 - SPBTLE-RF-RST + PB_5, //D34 - SPSGRF-915-SPI3_CSN + PB_10, //D35 - INTERNAL-I2C2_SCL + PB_11, //D36 - INTERNAL-I2C2_SDA + PB_12, //D37 - ISM43362-BOOT0 + PB_13, //D38 - ISM43362-WAKEUP + PB_15, //D39 - SPSGRF-915-SDN + PC_6, //D40 - VL53L0X_XSHUT + PC_7, //D41 - VL53L0X_GPIO1_EXTI7 + PC_8, //D42 - LIS3MDL_DRDY_EXTI8 + PC_9, //D43 - LED3 (WIFI) & LED4 (BLE) + PC_10, //D44 - INTERNAL-SPI3_SCK + PC_11, //D45 - INTERNAL-SPI3_MISO + PC_12, //D46 - INTERNAL-SPI3_MOSI + PD_7, //D47 - STSAFE-A100-RESET + PD_8, //D48 - INTERNAL-UART3_TX + PD_9, //D49 - INTERNAL-UART3_RX + PD_10, //D50 - LPS22HB_INT_DRDY_EXTI10 + PD_11, //D51 - LSM6DSL_INT1_EXTI11 + PD_13, //D52 - SPBTLE-RF-SPI3_CSN + PD_15, //D53 - HTS221_DRDY_EXTI15 + PE_0, //D54 - ISM43362-SPI3_CSN + PE_1, //D55 - ISM43362-DRDY_EXTI1 + PE_2, //D56 - M24SR64-Y-RF_DISABLE + PE_4, //D57 - M24SR64-Y-GPO + PE_5, //D58 - SPSGRF-915-GPIO3_EXTI5 + PE_6, //D59 - SPBTLE-RF-IRQ_EXTI6 + PE_7, //D60 - DFSDM1_DATIN2 + PE_8, //D61 - ISM43362-RST + PE_9, //D62 - DFSDM1_CKOUT + PE_10, //D63 - QUADSPI_CLK + PE_11, //D64 - QUADSPI_NCS + PE_12, //D65 - QUADSPI_BK1_IO0 + PE_13, //D66 - QUADSPI_BK1_IO1 + PE_14, //D67 - QUADSPI_BK1_IO2 + PE_15, //D68 - QUADSPI_BK1_IO3 // CN4 connector - PC_5, //D67/A0 - PC_4, //D68/A1 - PC_3, //D69/A2 - PC_2, //D70/A3 - PC_1, //D71/A4 - PC_0, //D72/A5 + PC_5, //D69/A0 + PC_4, //D70/A1 + PC_3, //D71/A2 + PC_2, //D72/A3 + PC_1, //D73/A4 + PC_0, //D74/A5 // Duplicated pins in order to be aligned with PinMap_ADC - PA_1, //D73/A6 - PA_0, //D74/A7 - PB_0, //D75/A8 - PA_3, //D76/A9 - PB_1, //D77/A10 - PA_4, //D78/A11 - PA_2, //D79/A12 - PA_7, //D80/A13 - PA_6, //D81/A14 - PA_5 //D82/A15 + PA_1, //D75/A6 + PA_0, //D76/A7 + PB_0, //D77/A8 + PA_3, //D78/A9 + PB_1, //D79/A10 + PA_4, //D80/A11 + PA_2, //D81/A12 + PA_7, //D82/A13 + PA_6, //D83/A14 + PA_5 //D84/A15 }; #ifdef __cplusplus } #endif -/* - * UART objects - */ -HardwareSerial Serial(PB_7, PB_6); //Connected to ST-Link (USART1) -#ifdef ENABLE_SERIAL1 -HardwareSerial Serial1(PA_1, PA_0); //Connected to ST-Link (USART4) -#endif - -void serialEvent() __attribute__((weak)); -void serialEvent() { } -#ifdef ENABLE_SERIAL1 -void serialEvent1() __attribute__((weak)); -void serialEvent1() { } -#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -#ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); -#endif -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/DISCO_L475VG_IOT/variant.h b/variants/DISCO_L475VG_IOT/variant.h index b0fc4fa991..19247f9a84 100644 --- a/variants/DISCO_L475VG_IOT/variant.h +++ b/variants/DISCO_L475VG_IOT/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,107 +32,108 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { // CN3 connector - PA1, //D0 - PA0, //D1 + PA1, //D0 - UART4_RX + PA0, //D1 - UART4_TX PD14, //D2 - PB0, //D3 + PB0, //D3 - PWM PA3, //D4 - PB4, //D5 - PB1, //D6 + PB4, //D5 - PWM + PB1, //D6 - PWM PA4, //D7 // CN1 connector PB2, //D8 - PA15, //D9 - PA2, //D10 - PA7, //D11 - PA6, //D12 - PA5, //D13 - PB9, //D14 - PB8, //D15 + PA15, //D9 - PWM + PA2, //D10 - SPI_SSN/PWM + PA7, //D11 - SPI1_MOSI/PWM + PA6, //D12 - SPI1_MISO + PA5, //D13 - SPI1_SCK/LED1 + PB9, //D14 - I2C1_SDA + PB8, //D15 - I2C1_SCL // Not on connector - PB14, //D16 - PC13, //D17 + PB14, //D16 - LED2 + PC13, //D17 - USER_BTN +// ST-LINK + PB6, //D18 - ST-LINK-UART1_TX + PB7, //D19 - ST-LINK-UART1_RX // CN9 USB OTG FS connector - PA9, //D18 - PA10, //D19 - PA11, //D20 - PA12, //D21 - PD12, //D22 - PE3, //D23 + PA9, //D20 - USB_OTG_FS_VBUS + PA10, //D21 - USB_OTG_FS_ID + PA11, //D22 - USB_OTG_FS_DM + PA12, //D23 - USB_OTG_FS_DP + PD12, //D24 - USB_OTG_FS_PWR_EN + PE3, //D25 - USB_OTG_OVRCR_EXTI3 // CN10 PMOD connector - PD0, //D24 - PD1, //D25 - PD2, //D26 - PD3, //D27 - PD4, //D28 - PD5, //D29 - PD6, //D30 + PD0, //D26 - PMOD-RESET + PD1, //D27 - PMOD-SPI2_SCK + PD2, //D28 - PMOD-IRQ_EXTI2 + PD3, //D29 - PMOD-UART2_CTS/SPI2_MISO + PD4, //D30 - PMOD-UART2_RTS/SPI2_MOSI + PD5, //D31 - PMOD-UART2_TX/SPI2_CSN + PD6, //D32 - PMOD-UART2_RX // Sensors / modules pins - PA8, //D31 - PB5, //D32 - PB10, //D33 - PB11, //D34 - PB12, //D35 - PB13, //D36 - PB15, //D37 - PC6, //D38 - PC7, //D39 - PC8, //D40 - PC9, //D41 - PC10, //D42 - PC11, //D43 - PC12, //D44 - PD7, //D45 - PD8, //D46 - PD9, //D47 - PD10, //D48 - PD11, //D49 - PD13, //D50 - PD15, //D51 - PE0, //D52 - PE1, //D53 - PE2, //D54 - PE4, //D55 - PE5, //D56 - PE6, //D57 - PE7, //D58 - PE8, //D59 - PE9, //D60 - PE10, //D61 - PE11, //D62 - PE12, //D63 - PE13, //D64 - PE14, //D65 - PE15, //D66 + PA8, //D33 - SPBTLE-RF-RST + PB5, //D34 - SPSGRF-915-SPI3_CSN + PB10, //D35 - INTERNAL-I2C2_SCL + PB11, //D36 - INTERNAL-I2C2_SDA + PB12, //D37 - ISM43362-BOOT0 + PB13, //D38 - ISM43362-WAKEUP + PB15, //D39 - SPSGRF-915-SDN + PC6, //D40 - VL53L0X_XSHUT + PC7, //D41 - VL53L0X_GPIO1_EXTI7 + PC8, //D42 - LIS3MDL_DRDY_EXTI8 + PC9, //D43 - LED3 (WIFI) & LED4 (BLE) + PC10, //D44 - INTERNAL-SPI3_SCK + PC11, //D45 - INTERNAL-SPI3_MISO + PC12, //D46 - INTERNAL-SPI3_MOSI + PD7, //D47 - STSAFE-A100-RESET + PD8, //D48 - INTERNAL-UART3_TX + PD9, //D49 - INTERNAL-UART3_RX + PD10, //D50 - LPS22HB_INT_DRDY_EXTI10 + PD11, //D51 - LSM6DSL_INT1_EXTI11 + PD13, //D52 - SPBTLE-RF-SPI3_CSN + PD15, //D53 - HTS221_DRDY_EXTI15 + PE0, //D54 - ISM43362-SPI3_CSN + PE1, //D55 - ISM43362-DRDY_EXTI1 + PE2, //D56 - M24SR64-Y-RF_DISABLE + PE4, //D57 - M24SR64-Y-GPO + PE5, //D58 - SPSGRF-915-GPIO3_EXTI5 + PE6, //D59 - SPBTLE-RF-IRQ_EXTI6 + PE7, //D60 - DFSDM1_DATIN2 + PE8, //D61 - ISM43362-RST + PE9, //D62 - DFSDM1_CKOUT + PE10, //D63 - QUADSPI_CLK + PE11, //D64 - QUADSPI_NCS + PE12, //D65 - QUADSPI_BK1_IO0 + PE13, //D66 - QUADSPI_BK1_IO1 + PE14, //D67 - QUADSPI_BK1_IO2 + PE15, //D68 - QUADSPI_BK1_IO3 // CN4 connector - PC5, //D67/A0 - PC4, //D68/A1 - PC3, //D69/A2 - PC2, //D70/A3 - PC1, //D71/A4 - PC0, //D72/A5 + PC5, //D69/A0 + PC4, //D70/A1 + PC3, //D71/A2 + PC2, //D72/A3 + PC1, //D73/A4 + PC0, //D74/A5 // Duplicated pins in order to be aligned with PinMap_ADC - PA1_2, //D73/A6 - PA0_2, //D74/A7 - PB0_2, //D75/A8 - PA3_2, //D76/A9 - PB1_2, //D77/A10 - PA4_2, //D78/A11 - PA2_2, //D79/A12 - PA7_2, //D80/A13 - PA6_2, //D81/A14 - PA5_2, //D82/A15 + PA1_2, //D75/A6 + PA0_2, //D76/A7 + PB0_2, //D77/A8 + PA3_2, //D78/A9 + PB1_2, //D79/A10 + PA4_2, //D80/A11 + PA2_2, //D81/A12 + PA7_2, //D82/A13 + PA6_2, //D83/A14 + PA5_2, //D84/A15 PEND }; enum { - A_START_AFTER = D66, + A_START_AFTER = D68, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, AEND @@ -150,12 +151,12 @@ enum { //On-board LED pin number #define LED_BUILTIN 13 #define LED1 LED_BUILTIN -#define LED2 16 -#define LED3 41 +#define LED2 PB14 +#define LED3 PC9 #define LED4 LED3 //On-board user button -#define USER_BTN 17 +#define USER_BTN PC13 //SPI definitions @@ -179,17 +180,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART1) - -// UART Emulation -// #define UART_EMUL_RX PB13 -// #define UART_EMUL_TX PB14 - -// Serial Pin Firmata -#define PIN_SERIAL_RX 0 -#define PIN_SERIAL_TX 1 -#define PIN_SERIAL1_RX 2 -#define PIN_SERIAL1_TX 8 +// UART Definitions +#define SERIAL_UART_INSTANCE 1 //Connected to ST-Link +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX PB7 +#define PIN_SERIAL_TX PB6 #ifdef __cplusplus } // extern "C" @@ -199,9 +195,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -217,8 +210,8 @@ extern HardwareSerial Serial1; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial #endif #endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/NUCLEO_F030R8/variant.cpp b/variants/NUCLEO_F030R8/variant.cpp index a4074d4831..585faa3884 100644 --- a/variants/NUCLEO_F030R8/variant.cpp +++ b/variants/NUCLEO_F030R8/variant.cpp @@ -97,29 +97,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ -HardwareSerial Serial(PA_3, PA_2); //Connected to ST-Link -#ifdef ENABLE_SERIAL1 -HardwareSerial Serial1(PA_10, PA_9); -#endif - -void serialEvent() __attribute__((weak)); -void serialEvent() { } -#ifdef ENABLE_SERIAL1 -void serialEvent1() __attribute__((weak)); -void serialEvent1() { } -#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -#ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); -#endif -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/NUCLEO_F030R8/variant.h b/variants/NUCLEO_F030R8/variant.h index c6b93dfb7b..e89cac8675 100644 --- a/variants/NUCLEO_F030R8/variant.h +++ b/variants/NUCLEO_F030R8/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { @@ -150,13 +148,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM3 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART2) - -// Serial Pin Firmata +// UART Definitions +#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata #define PIN_SERIAL_RX 0 #define PIN_SERIAL_TX 1 -#define PIN_SERIAL1_RX 2 -#define PIN_SERIAL1_TX 8 #ifdef __cplusplus } // extern "C" @@ -166,9 +163,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -184,8 +178,8 @@ extern HardwareSerial Serial1; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial #endif #endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/NUCLEO_F091RC/variant.cpp b/variants/NUCLEO_F091RC/variant.cpp index 7d3f7a4dc3..d7ba7b060a 100644 --- a/variants/NUCLEO_F091RC/variant.cpp +++ b/variants/NUCLEO_F091RC/variant.cpp @@ -94,39 +94,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ -HardwareSerial Serial(PA_3, PA_2); //Connected to ST-Link -#ifdef ENABLE_SERIAL1 -HardwareSerial Serial1(PA_10, PA_9); -#endif -#ifdef ENABLE_SERIAL2 -HardwareSerial Serial2(PA_1, PA_0); -#endif - -void serialEvent() __attribute__((weak)); -void serialEvent() { } -#ifdef ENABLE_SERIAL1 -void serialEvent1() __attribute__((weak)); -void serialEvent1() { } -#endif -#ifdef ENABLE_SERIAL2 -void serialEvent2() __attribute__((weak)); -void serialEvent2() { } -#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -#ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); -#endif -#ifdef ENABLE_SERIAL2 - if (Serial2.available()) serialEvent2(); -#endif -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/NUCLEO_F091RC/variant.h b/variants/NUCLEO_F091RC/variant.h index d6e9d96ea2..daa067ce3c 100644 --- a/variants/NUCLEO_F091RC/variant.h +++ b/variants/NUCLEO_F091RC/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { @@ -149,19 +147,16 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART2) - +// UART Definitions +#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link // UART Emulation #define UART_EMUL_RX PB_14 #define UART_EMUL_TX PB_13 -// Serial Pin Firmata +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata #define PIN_SERIAL_RX 0 #define PIN_SERIAL_TX 1 -#define PIN_SERIAL1_RX 2 -#define PIN_SERIAL1_TX 8 -#define PIN_SERIAL2_RX 47 -#define PIN_SERIAL2_TX 46 #ifdef __cplusplus } // extern "C" @@ -171,10 +166,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -190,8 +181,8 @@ extern HardwareSerial Serial2; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial #endif #endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/NUCLEO_F103RB/variant.cpp b/variants/NUCLEO_F103RB/variant.cpp index 5fcb8a66ed..4bfcc77f19 100644 --- a/variants/NUCLEO_F103RB/variant.cpp +++ b/variants/NUCLEO_F103RB/variant.cpp @@ -95,40 +95,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ - -HardwareSerial Serial(PA_3, PA_2); // Connected to ST-Link -#ifdef ENABLE_SERIAL1 -HardwareSerial Serial1(PA_10, PA_9); -#endif -#ifdef ENABLE_SERIAL2 -HardwareSerial Serial2(PC_11, PC_10); //Morpho pins -#endif - -void serialEvent() __attribute__((weak)); -void serialEvent() { } -#ifdef ENABLE_SERIAL1 -void serialEvent1() __attribute__((weak)); -void serialEvent1() { } -#endif -#ifdef ENABLE_SERIAL2 -void serialEvent2() __attribute__((weak)); -void serialEvent2() { } -#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -#ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); -#endif -#ifdef ENABLE_SERIAL2 - if (Serial2.available()) serialEvent2(); -#endif -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/NUCLEO_F103RB/variant.h b/variants/NUCLEO_F103RB/variant.h index c3fec5ecf3..bc4a62a332 100644 --- a/variants/NUCLEO_F103RB/variant.h +++ b/variants/NUCLEO_F103RB/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { @@ -149,15 +147,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART2) - -// Serial Pin Firmata +// UART Definitions +#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata #define PIN_SERIAL_RX 0 #define PIN_SERIAL_TX 1 -#define PIN_SERIAL1_RX 2 -#define PIN_SERIAL1_TX 8 -#define PIN_SERIAL2_RX 30 -#define PIN_SERIAL2_TX 16 #ifdef __cplusplus } // extern "C" @@ -167,10 +162,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -186,8 +177,8 @@ extern HardwareSerial Serial2; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial #endif #endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/NUCLEO_F207ZG/variant.cpp b/variants/NUCLEO_F207ZG/variant.cpp index 229fbc1cc0..740c811d52 100644 --- a/variants/NUCLEO_F207ZG/variant.cpp +++ b/variants/NUCLEO_F207ZG/variant.cpp @@ -148,37 +148,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ -HardwareSerial Serial(PD_9, PD_8); // Connected to ST-Link - -void serialEvent() __attribute__((weak)); -void serialEvent() { } - -#ifdef ENABLE_SERIAL1 -HardwareSerial Serial1(PG_9, PG_14); - -void serialEvent1() __attribute__((weak)); -void serialEvent1() { } -#endif -#ifdef ENABLE_SERIAL2 -HardwareSerial Serial2(PD_6, PD_5); - -void serialEvent2() __attribute__((weak)); -void serialEvent2() { } -#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -#ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); -#endif -#ifdef ENABLE_SERIAL2 - if (Serial2.available()) serialEvent2(); -#endif -} // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/NUCLEO_F207ZG/variant.h b/variants/NUCLEO_F207ZG/variant.h index e0ee3c0198..717158a4f0 100644 --- a/variants/NUCLEO_F207ZG/variant.h +++ b/variants/NUCLEO_F207ZG/variant.h @@ -35,7 +35,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -44,8 +44,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; // Enum defining Arduino style alias for digital pin number --> Dx @@ -194,19 +192,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART3) - -// UART Emulation (uncomment if needed, required TIM1) -//#define UART_EMUL_RX PX_n // PinName used for RX -//#define UART_EMUL_TX PX_n // PinName used for TX - -// Serial Pin Firmata -#define PIN_SERIAL_RX 76 -#define PIN_SERIAL_TX 77 -#define PIN_SERIAL1_RX 0 -#define PIN_SERIAL1_TX 1 -#define PIN_SERIAL2_RX 52 -#define PIN_SERIAL2_TX 53 +// UART Definitions +#define SERIAL_UART_INSTANCE 3 //Connected to ST-Link +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX PD9 +#define PIN_SERIAL_TX PD8 #ifdef __cplusplus } // extern "C" @@ -216,11 +207,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -// declare here as many UART objects than defined in variant.cpp -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -236,8 +222,8 @@ extern HardwareSerial Serial2; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial #endif #endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/NUCLEO_F303RE/variant.cpp b/variants/NUCLEO_F303RE/variant.cpp index 4065bd5a69..ebb8365b34 100644 --- a/variants/NUCLEO_F303RE/variant.cpp +++ b/variants/NUCLEO_F303RE/variant.cpp @@ -94,39 +94,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ -HardwareSerial Serial(PA_3, PA_2); //Connected to ST-Link -#ifdef ENABLE_SERIAL1 -HardwareSerial Serial1(PA_10, PA_9); -#endif -#ifdef ENABLE_SERIAL2 -HardwareSerial Serial2(PD_2, PC_12); -#endif - -void serialEvent() __attribute__((weak)); -void serialEvent() { } -#ifdef ENABLE_SERIAL1 -void serialEvent1() __attribute__((weak)); -void serialEvent1() { } -#endif -#ifdef ENABLE_SERIAL2 -void serialEvent2() __attribute__((weak)); -void serialEvent2() { } -#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -#ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); -#endif -#ifdef ENABLE_SERIAL2 - if (Serial2.available()) serialEvent2(); -#endif -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/NUCLEO_F303RE/variant.h b/variants/NUCLEO_F303RE/variant.h index 6f699c2665..c56fc73e4b 100644 --- a/variants/NUCLEO_F303RE/variant.h +++ b/variants/NUCLEO_F303RE/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { @@ -149,19 +147,16 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART2) - +// UART Definitions +#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link // UART Emulation #define UART_EMUL_RX PC_1 #define UART_EMUL_TX PC_3 -// Serial Pin Firmata +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata #define PIN_SERIAL_RX 0 #define PIN_SERIAL_TX 1 -#define PIN_SERIAL1_RX 2 -#define PIN_SERIAL1_TX 8 -#define PIN_SERIAL2_RX 31 -#define PIN_SERIAL2_TX 17 #ifdef __cplusplus } // extern "C" @@ -171,10 +166,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -190,8 +181,8 @@ extern HardwareSerial Serial2; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial #endif #endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/NUCLEO_F401RE/variant.cpp b/variants/NUCLEO_F401RE/variant.cpp index 85bb2a0fbc..6074796e92 100644 --- a/variants/NUCLEO_F401RE/variant.cpp +++ b/variants/NUCLEO_F401RE/variant.cpp @@ -95,39 +95,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ -HardwareSerial Serial(PA_3, PA_2); //Connected to ST-Link -#ifdef ENABLE_SERIAL1 -HardwareSerial Serial1(PA_10, PA_9); -#endif -#ifdef ENABLE_SERIAL2 -HardwareSerial Serial2(PC_7, PC_6); -#endif - -void serialEvent() __attribute__((weak)); -void serialEvent() { } -#ifdef ENABLE_SERIAL1 -void serialEvent1() __attribute__((weak)); -void serialEvent1() { } -#endif -#ifdef ENABLE_SERIAL2 -void serialEvent2() __attribute__((weak)); -void serialEvent2() { } -#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -#ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); -#endif -#ifdef ENABLE_SERIAL2 - if (Serial2.available()) serialEvent2(); -#endif -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/NUCLEO_F401RE/variant.h b/variants/NUCLEO_F401RE/variant.h index 0c3a393d0c..4af1db56f2 100644 --- a/variants/NUCLEO_F401RE/variant.h +++ b/variants/NUCLEO_F401RE/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { @@ -150,19 +148,16 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART2) - +// UART Definitions +#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link // UART Emulation #define UART_EMUL_RX PC_1 #define UART_EMUL_TX PC_3 -// Serial Pin Firmata +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata #define PIN_SERIAL_RX 0 #define PIN_SERIAL_TX 1 -#define PIN_SERIAL1_RX 2 -#define PIN_SERIAL1_TX 8 -#define PIN_SERIAL2_RX 9 -#define PIN_SERIAL2_TX 34 #ifdef __cplusplus } // extern "C" @@ -172,10 +167,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -191,8 +182,8 @@ extern HardwareSerial Serial2; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial #endif #endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/NUCLEO_F411RE/variant.cpp b/variants/NUCLEO_F411RE/variant.cpp index 687f4b23a5..506719dd45 100644 --- a/variants/NUCLEO_F411RE/variant.cpp +++ b/variants/NUCLEO_F411RE/variant.cpp @@ -95,39 +95,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ -HardwareSerial Serial(PA_3, PA_2); //Connected to ST-Link -#ifdef ENABLE_SERIAL1 -HardwareSerial Serial1(PA_10, PA_9); -#endif -#ifdef ENABLE_SERIAL2 -HardwareSerial Serial2(PC_7, PC_6); -#endif - -void serialEvent() __attribute__((weak)); -void serialEvent() { } -#ifdef ENABLE_SERIAL1 -void serialEvent1() __attribute__((weak)); -void serialEvent1() { } -#endif -#ifdef ENABLE_SERIAL2 -void serialEvent2() __attribute__((weak)); -void serialEvent2() { } -#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -#ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); -#endif -#ifdef ENABLE_SERIAL2 - if (Serial2.available()) serialEvent2(); -#endif -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/NUCLEO_F411RE/variant.h b/variants/NUCLEO_F411RE/variant.h index 5bf23c1482..08d24e6c4e 100644 --- a/variants/NUCLEO_F411RE/variant.h +++ b/variants/NUCLEO_F411RE/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { @@ -150,19 +148,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART2) - -// UART Emulation -//#define UART_EMUL_RX PC_1 -//#define UART_EMUL_TX PC_3 - -// Serial Pin Firmata +// UART Definitions +#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata #define PIN_SERIAL_RX 0 #define PIN_SERIAL_TX 1 -#define PIN_SERIAL1_RX 2 -#define PIN_SERIAL1_TX 8 -#define PIN_SERIAL2_RX 9 -#define PIN_SERIAL2_TX 34 #ifdef __cplusplus } // extern "C" @@ -172,10 +163,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -191,8 +178,8 @@ extern HardwareSerial Serial2; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial #endif #endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/NUCLEO_F429ZI/variant.cpp b/variants/NUCLEO_F429ZI/variant.cpp index a9be4094b5..bca0af15ca 100644 --- a/variants/NUCLEO_F429ZI/variant.cpp +++ b/variants/NUCLEO_F429ZI/variant.cpp @@ -129,40 +129,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ -HardwareSerial Serial(PD_9, PD_8); // Connected to ST-Link -#ifdef ENABLE_SERIAL1 -HardwareSerial Serial1(PG_9, PG_14); -#endif -#ifdef ENABLE_SERIAL2 -HardwareSerial Serial2(PD_6, PD_5); -#endif - -void serialEvent() __attribute__((weak)); -void serialEvent() { } - -#ifdef ENABLE_SERIAL1 -void serialEvent1() __attribute__((weak)); -void serialEvent1() { } -#endif -#ifdef ENABLE_SERIAL2 -void serialEvent2() __attribute__((weak)); -void serialEvent2() { } -#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -#ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); -#endif -#ifdef ENABLE_SERIAL2 - if (Serial2.available()) serialEvent2(); -#endif -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/NUCLEO_F429ZI/variant.h b/variants/NUCLEO_F429ZI/variant.h index c6b834eac6..0dfc1e4ef3 100644 --- a/variants/NUCLEO_F429ZI/variant.h +++ b/variants/NUCLEO_F429ZI/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { @@ -184,21 +182,16 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART3) - +// UART Definitions +#define SERIAL_UART_INSTANCE 3 //Connected to ST-Link // UART Emulation #define UART_EMUL_RX PF_15 #define UART_EMUL_TX PE_13 -// Serial Pin Firmata -#define PIN_SERIAL_RX 76 -#define PIN_SERIAL_TX 77 -#define PIN_SERIAL1_RX 0 -#define PIN_SERIAL1_TX 1 -#define PIN_SERIAL2_RX 52 -#define PIN_SERIAL2_TX 53 - - +// Serial pin used for console (ex: stlink) +// Rerquired by Firmata +#define PIN_SERIAL_RX PD9 +#define PIN_SERIAL_TX PD8 #ifdef __cplusplus } // extern "C" @@ -208,10 +201,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -227,8 +216,8 @@ extern HardwareSerial Serial2; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial #endif #endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/NUCLEO_L053R8/variant.cpp b/variants/NUCLEO_L053R8/variant.cpp index bc0b508c95..5b4af03165 100644 --- a/variants/NUCLEO_L053R8/variant.cpp +++ b/variants/NUCLEO_L053R8/variant.cpp @@ -94,29 +94,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ -HardwareSerial Serial(PA_3, PA_2); //Connected to ST-Link -#ifdef ENABLE_SERIAL1 -HardwareSerial Serial1(PA_10, PA_9); -#endif - -void serialEvent() __attribute__((weak)); -void serialEvent() { } -#ifdef ENABLE_SERIAL1 -void serialEvent1() __attribute__((weak)); -void serialEvent1() { } -#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -#ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); -#endif -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/NUCLEO_L053R8/variant.h b/variants/NUCLEO_L053R8/variant.h index 3c3cbe8e23..a3144238e1 100644 --- a/variants/NUCLEO_L053R8/variant.h +++ b/variants/NUCLEO_L053R8/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { @@ -149,13 +147,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART2) - -// Serial Pin Firmata +// UART Definitions +#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata #define PIN_SERIAL_RX 0 #define PIN_SERIAL_TX 1 -#define PIN_SERIAL1_RX 2 -#define PIN_SERIAL1_TX 8 #ifdef __cplusplus } // extern "C" @@ -165,9 +162,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -183,8 +177,8 @@ extern HardwareSerial Serial1; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial #endif #endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/NUCLEO_L152RE/variant.cpp b/variants/NUCLEO_L152RE/variant.cpp index 0b37384f4f..3ce8587361 100644 --- a/variants/NUCLEO_L152RE/variant.cpp +++ b/variants/NUCLEO_L152RE/variant.cpp @@ -99,39 +99,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ -HardwareSerial Serial(PA_3, PA_2); //Connected to ST-Link -#ifdef ENABLE_SERIAL1 -HardwareSerial Serial1(PA_10, PA_9); -#endif -#ifdef ENABLE_SERIAL2 -HardwareSerial Serial2(PC_11, PC_10); -#endif - -void serialEvent() __attribute__((weak)); -void serialEvent() { } -#ifdef ENABLE_SERIAL1 -void serialEvent1() __attribute__((weak)); -void serialEvent1() { } -#endif -#ifdef ENABLE_SERIAL2 -void serialEvent2() __attribute__((weak)); -void serialEvent2() { } -#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -#ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); -#endif -#ifdef ENABLE_SERIAL2 - if (Serial2.available()) serialEvent2(); -#endif -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/NUCLEO_L152RE/variant.h b/variants/NUCLEO_L152RE/variant.h index 5fedc92c39..0b1cdba0a1 100644 --- a/variants/NUCLEO_L152RE/variant.h +++ b/variants/NUCLEO_L152RE/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { @@ -154,19 +152,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART2) - -// UART Emulation -//#define UART_EMUL_RX PC_1 -//#define UART_EMUL_TX PC_3 - -// Serial Pin Firmata +// UART Definitions +#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata #define PIN_SERIAL_RX 0 #define PIN_SERIAL_TX 1 -#define PIN_SERIAL1_RX 2 -#define PIN_SERIAL1_TX 8 -#define PIN_SERIAL2_RX 30 -#define PIN_SERIAL2_TX 16 #ifdef __cplusplus } // extern "C" @@ -176,10 +167,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -195,8 +182,8 @@ extern HardwareSerial Serial2; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial #endif #endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/NUCLEO_L432KC/variant.cpp b/variants/NUCLEO_L432KC/variant.cpp index 98cd945204..6f927bf319 100644 --- a/variants/NUCLEO_L432KC/variant.cpp +++ b/variants/NUCLEO_L432KC/variant.cpp @@ -53,29 +53,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ -HardwareSerial Serial(PA_15, PA_2); //Connected to ST-Link -#ifdef ENABLE_SERIAL1 -HardwareSerial Serial1(PA_10, PA_9); -#endif - -void serialEvent() __attribute__((weak)); -void serialEvent() { } -#ifdef ENABLE_SERIAL1 -void serialEvent1() __attribute__((weak)); -void serialEvent1() { } -#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -#ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); -#endif -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/NUCLEO_L432KC/variant.h b/variants/NUCLEO_L432KC/variant.h index 75bff7e3d6..58a19ea5fd 100644 --- a/variants/NUCLEO_L432KC/variant.h +++ b/variants/NUCLEO_L432KC/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { @@ -103,13 +101,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART2) - -// Serial Pin Firmata -#define PIN_SERIAL_RX 22 -#define PIN_SERIAL_TX 21 -#define PIN_SERIAL1_RX 0 -#define PIN_SERIAL1_TX 1 +// UART Definitions +#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX PA15 +#define PIN_SERIAL_TX PA2 #ifdef __cplusplus } // extern "C" @@ -119,9 +116,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -137,8 +131,8 @@ extern HardwareSerial Serial1; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial #endif #endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/NUCLEO_L476RG/variant.cpp b/variants/NUCLEO_L476RG/variant.cpp index 096513d84b..fbc037671d 100644 --- a/variants/NUCLEO_L476RG/variant.cpp +++ b/variants/NUCLEO_L476RG/variant.cpp @@ -94,29 +94,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ -HardwareSerial Serial(PA_3, PA_2); //Connected to ST-Link -#ifdef ENABLE_SERIAL1 -HardwareSerial Serial1(PA_10, PA_9); -#endif - -void serialEvent() __attribute__((weak)); -void serialEvent() { } -#ifdef ENABLE_SERIAL1 -void serialEvent1() __attribute__((weak)); -void serialEvent1() { } -#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -#ifdef ENABLE_SERIAL1 - if (Serial1.available()) serialEvent1(); -#endif -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/NUCLEO_L476RG/variant.h b/variants/NUCLEO_L476RG/variant.h index 502e34ed28..c3f1275aa8 100644 --- a/variants/NUCLEO_L476RG/variant.h +++ b/variants/NUCLEO_L476RG/variant.h @@ -23,7 +23,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -32,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { @@ -149,17 +147,16 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) USART2) - +// UART Definitions +#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link // UART Emulation #define UART_EMUL_RX PB_13 #define UART_EMUL_TX PB_14 -// Serial Pin Firmata +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata #define PIN_SERIAL_RX 0 #define PIN_SERIAL_TX 1 -#define PIN_SERIAL1_RX 2 -#define PIN_SERIAL1_TX 8 #ifdef __cplusplus } // extern "C" @@ -169,9 +166,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, diff --git a/variants/board_template/variant.cpp b/variants/board_template/variant.cpp index de30abf3a5..0e1cdfa781 100644 --- a/variants/board_template/variant.cpp +++ b/variants/board_template/variant.cpp @@ -142,32 +142,6 @@ const PinName digitalPin[] = { } #endif -/* - * UART objects - */ -// Replace PX_n_Rx and PX_n_Tx by UART_RX and UART_TX pin names -HardwareSerial Serial(PX_n_Rx, PX_n_Tx); // Connected to ST-Link - -void serialEvent() __attribute__((weak)); -void serialEvent() { } - -// Define as many Serial instance as desired -// Replace 'SerialX' by the desired name -//#ifdef ENABLE_SERIALX -//HardwareSerial SerialX(PX_n_Rx, PX_n_Tx); -// -//void serialEventx() __attribute__((weak)); -//void serialEventx() { } -//#endif - -void serialEventRun(void) -{ - if (Serial.available()) serialEvent(); -//#ifdef ENABLE_SERIALX -// if (SerialX.available()) serialEventX(); -//#endif -} - // ---------------------------------------------------------------------------- #ifdef __cplusplus diff --git a/variants/board_template/variant.h b/variants/board_template/variant.h index 3bac3a75a7..560b6b4111 100644 --- a/variants/board_template/variant.h +++ b/variants/board_template/variant.h @@ -35,7 +35,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "Arduino.h" +#include "pins_arduino.h" #ifdef __cplusplus extern "C"{ @@ -44,8 +44,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; // Enum defining pin names to match digital pin number --> Dx @@ -106,19 +104,20 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIMx //TODO: advanced-control timers don't work -#define DEBUG_UART ((USART_TypeDef *) U(S)ARTX) // ex: USART3 +// UART Definitions +// Define here Serial instance number to map on Serial generic name +#define SERIAL_UART_INSTANCE x //ex: 2 for Serial2 (USART2) +// DEBUG_UART could be redefined to print on another instance than 'Serial' +//#define DEBUG_UART ((USART_TypeDef *) U(S)ARTX) // ex: USART3 // UART Emulation (uncomment if needed, required TIM1) //#define UART_EMUL_RX PX_n // PinName used for RX //#define UART_EMUL_TX PX_n // PinName used for TX -// Serial Pin Firmata +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata #define PIN_SERIAL_RX Dx #define PIN_SERIAL_TX Dx -// Define as many PIN_SERIALX than desired -//#define PIN_SERIAL1_RX Dx -//#define PIN_SERIAL1_TX Dx -//... #ifdef __cplusplus } // extern "C" @@ -128,11 +127,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -// declare here as many UART objects than defined in variant.cpp -extern HardwareSerial Serial; -//extern HardwareSerial SerialX; -//... - // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, @@ -148,8 +142,8 @@ extern HardwareSerial Serial; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial #endif #endif /* _VARIANT_ARDUINO_STM32_ */