From f0f5126d6b5ea9c8a68d6056534f268cc8e0a878 Mon Sep 17 00:00:00 2001 From: "Frederic.Pillon" Date: Tue, 26 Sep 2017 16:53:14 +0200 Subject: [PATCH 1/9] Add new functions to find a PinName for a specific peripheral. Usage example: PinNamepin_rx = pinmap_pin(USART1, PinMap_UART_RX); PinNamepin_tx = pinmap_pin(USART1, PinMap_UART_TX); Signed-off-by: Frederic.Pillon --- cores/arduino/stm32/pinmap.c | 19 +++++++++++++++++++ cores/arduino/stm32/pinmap.h | 6 ++++-- 2 files changed, 23 insertions(+), 2 deletions(-) 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 From 15e8bddedf73e030d0bb209be4dfb0ef9b4ca27d Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Sat, 30 Sep 2017 12:01:19 +0200 Subject: [PATCH 2/9] Make Serialx instance generic Previously Serialx instance was defined by the variant. It was not enough generic and flexible. With this patch, all available Serialx instance are handled dynamically. Where 'x' is the U(S)ART number. Currently, STM32 MCU could have 9 U(S)ART. Serial is the generic name used in Arduino sketches. Serial is now mapped to the Serialx instance linked to the com port in the variant.h (mainly one linked to ST-Link) Moreover this will simplify USB integration to map the SerialUSB. Signed-off-by: Frederic.Pillon --- cores/arduino/HardwareSerial.cpp | 116 +++++++++++++++++++++++++- cores/arduino/HardwareSerial.h | 14 ++++ cores/arduino/stm32/uart.h | 31 +++++++ variants/DISCO_F100RB/variant.cpp | 34 -------- variants/DISCO_F100RB/variant.h | 49 +++++------ variants/DISCO_F407VG/variant.cpp | 14 ---- variants/DISCO_F407VG/variant.h | 7 +- variants/DISCO_F746NG/variant.cpp | 33 -------- variants/DISCO_F746NG/variant.h | 17 +--- variants/DISCO_L475VG_IOT/variant.cpp | 23 ----- variants/DISCO_L475VG_IOT/variant.h | 14 +--- variants/NUCLEO_F030R8/variant.cpp | 23 ----- variants/NUCLEO_F030R8/variant.h | 10 +-- variants/NUCLEO_F091RC/variant.cpp | 33 -------- variants/NUCLEO_F091RC/variant.h | 13 +-- variants/NUCLEO_F103RB/variant.cpp | 34 -------- variants/NUCLEO_F103RB/variant.h | 13 +-- variants/NUCLEO_F207ZG/variant.cpp | 31 ------- variants/NUCLEO_F207ZG/variant.h | 18 +--- variants/NUCLEO_F303RE/variant.cpp | 33 -------- variants/NUCLEO_F303RE/variant.h | 13 +-- variants/NUCLEO_F401RE/variant.cpp | 33 -------- variants/NUCLEO_F401RE/variant.h | 13 +-- variants/NUCLEO_F411RE/variant.cpp | 33 -------- variants/NUCLEO_F411RE/variant.h | 17 +--- variants/NUCLEO_F429ZI/variant.cpp | 34 -------- variants/NUCLEO_F429ZI/variant.h | 15 +--- variants/NUCLEO_L053R8/variant.cpp | 23 ----- variants/NUCLEO_L053R8/variant.h | 10 +-- variants/NUCLEO_L152RE/variant.cpp | 33 -------- variants/NUCLEO_L152RE/variant.h | 17 +--- variants/NUCLEO_L432KC/variant.cpp | 23 ----- variants/NUCLEO_L432KC/variant.h | 10 +-- variants/NUCLEO_L476RG/variant.cpp | 23 ----- variants/NUCLEO_L476RG/variant.h | 6 +- variants/board_template/variant.cpp | 26 ------ variants/board_template/variant.h | 15 ++-- 37 files changed, 245 insertions(+), 659 deletions(-) diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index dc2306a42d..5d5baf9372 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -30,12 +30,126 @@ #include "Arduino.h" #include "HardwareSerial.h" +// 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) +{ + _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 +201,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; diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index b31e58e127..62a24888c7 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(); @@ -121,8 +122,21 @@ class HardwareSerial : public Stream // 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/uart.h b/cores/arduino/stm32/uart.h index 0548baffdc..ac17f183bd 100644 --- a/cores/arduino/stm32/uart.h +++ b/cores/arduino/stm32/uart.h @@ -47,6 +47,37 @@ extern "C" { #endif +#if defined(USART1_BASE) +#define HAVE_HWSERIAL1 +#endif +#if defined(USART2_BASE) +#define HAVE_HWSERIAL2 +#endif +#if defined(USART3_BASE) +#define HAVE_HWSERIAL3 +#endif +#if defined(USART4_BASE) || defined(UART4_BASE) +#define HAVE_HWSERIAL4 +#endif +#if defined(USART5_BASE) || defined(UART5_BASE) +#define HAVE_HWSERIAL5 +#endif +#if defined(USART6_BASE) +#define HAVE_HWSERIAL6 +#endif +#if defined(USART7_BASE) || defined(UART7_BASE) +#define HAVE_HWSERIAL7 +#endif +#if defined(USART8_BASE) || defined(UART8_BASE) +#define HAVE_HWSERIAL8 +#endif +#if defined(UART9_BASE) +#define HAVE_HWSERIAL9 +#endif +#if defined(UART10_BASE) +#define HAVE_HWSERIAL10 +#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..50152654f9 100644 --- a/variants/DISCO_F100RB/variant.h +++ b/variants/DISCO_F100RB/variant.h @@ -152,15 +152,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM17 //TODO: advanced-control timers don't work +// UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) // Serial Pin 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 +166,26 @@ 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 +#define Serial Serial2 //Connected to ST-Link + +// 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..f928b65e9c 100644 --- a/variants/DISCO_F407VG/variant.h +++ b/variants/DISCO_F407VG/variant.h @@ -177,6 +177,7 @@ enum { #define TIMER_SERVO TIM7 #define TIMER_UART_EMULATED TIM6 +// UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) // UART Emulation @@ -195,7 +196,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; +#define Serial Serial2 // Could be connected to ST-Link // 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 @@ -212,8 +213,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..441e5439e1 100644 --- a/variants/DISCO_F746NG/variant.h +++ b/variants/DISCO_F746NG/variant.h @@ -109,19 +109,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +// UART Definitions #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 #ifdef __cplusplus } // extern "C" @@ -131,9 +124,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; +#define Serial Serial1 //Connected to ST-Link // 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 @@ -150,8 +141,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..ead0838183 100644 --- a/variants/DISCO_L475VG_IOT/variant.cpp +++ b/variants/DISCO_L475VG_IOT/variant.cpp @@ -121,29 +121,6 @@ const PinName digitalPin[] = { } #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..1e1c08d008 100644 --- a/variants/DISCO_L475VG_IOT/variant.h +++ b/variants/DISCO_L475VG_IOT/variant.h @@ -179,17 +179,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +// UART Definitions #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 #ifdef __cplusplus } // extern "C" @@ -199,8 +194,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; +#define Serial Serial1 //Connected to ST-Link // 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 @@ -217,8 +211,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..95bbe82ab8 100644 --- a/variants/NUCLEO_F030R8/variant.h +++ b/variants/NUCLEO_F030R8/variant.h @@ -150,13 +150,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM3 //TODO: advanced-control timers don't work +// UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) // Serial Pin 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,8 +165,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; +#define Serial Serial2 //Connected to ST-Link // 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 @@ -184,8 +182,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..89a1f287f7 100644 --- a/variants/NUCLEO_F091RC/variant.h +++ b/variants/NUCLEO_F091RC/variant.h @@ -149,6 +149,7 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +// UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) // UART Emulation @@ -158,10 +159,6 @@ enum { // Serial Pin 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,9 +168,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; +#define Serial Serial2 //Connected to ST-Link // 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 @@ -190,8 +185,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..f42ea99214 100644 --- a/variants/NUCLEO_F103RB/variant.h +++ b/variants/NUCLEO_F103RB/variant.h @@ -149,15 +149,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +// UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) // Serial Pin 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,9 +164,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; +#define Serial Serial2 //Connected to ST-Link // 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 @@ -186,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_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..5b986df517 100644 --- a/variants/NUCLEO_F207ZG/variant.h +++ b/variants/NUCLEO_F207ZG/variant.h @@ -194,19 +194,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +// UART Definitions #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 #ifdef __cplusplus } // extern "C" @@ -216,10 +209,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -// declare here as many UART objects than defined in variant.cpp -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; +#define Serial Serial3 //Connected to ST-Link // 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 @@ -236,8 +226,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..80547e535b 100644 --- a/variants/NUCLEO_F303RE/variant.h +++ b/variants/NUCLEO_F303RE/variant.h @@ -149,6 +149,7 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +// UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) // UART Emulation @@ -158,10 +159,6 @@ enum { // Serial Pin 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,9 +168,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; +#define Serial Serial2 //Connected to ST-Link // 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 @@ -190,8 +185,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..43451b5e48 100644 --- a/variants/NUCLEO_F401RE/variant.h +++ b/variants/NUCLEO_F401RE/variant.h @@ -150,6 +150,7 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +// UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) // UART Emulation @@ -159,10 +160,6 @@ enum { // Serial Pin 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,9 +169,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; +#define Serial Serial2 //Connected to ST-Link // 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 @@ -191,8 +186,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..985d98e612 100644 --- a/variants/NUCLEO_F411RE/variant.h +++ b/variants/NUCLEO_F411RE/variant.h @@ -150,19 +150,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +// UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) -// UART Emulation -//#define UART_EMUL_RX PC_1 -//#define UART_EMUL_TX PC_3 - // Serial Pin 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,9 +165,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; +#define Serial Serial2 //Connected to ST-Link // 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 @@ -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_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..5184ad1271 100644 --- a/variants/NUCLEO_F429ZI/variant.h +++ b/variants/NUCLEO_F429ZI/variant.h @@ -184,6 +184,7 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +// UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART3) // UART Emulation @@ -193,12 +194,6 @@ enum { // 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 - - #ifdef __cplusplus } // extern "C" @@ -208,9 +203,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; +#define Serial Serial3 //Connected to ST-Link // 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 @@ -227,8 +220,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..776e585648 100644 --- a/variants/NUCLEO_L053R8/variant.h +++ b/variants/NUCLEO_L053R8/variant.h @@ -149,13 +149,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +// UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) // Serial Pin 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,8 +164,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; +#define Serial Serial2 //Connected to ST-Link // 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 @@ -183,8 +181,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..850f18ea53 100644 --- a/variants/NUCLEO_L152RE/variant.h +++ b/variants/NUCLEO_L152RE/variant.h @@ -154,19 +154,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +// UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) -// UART Emulation -//#define UART_EMUL_RX PC_1 -//#define UART_EMUL_TX PC_3 - // Serial Pin 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,9 +169,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; +#define Serial Serial2 //Connected to ST-Link // 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 @@ -195,8 +186,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..03afc32a1e 100644 --- a/variants/NUCLEO_L432KC/variant.h +++ b/variants/NUCLEO_L432KC/variant.h @@ -103,13 +103,12 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +// UART Definitions #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 #ifdef __cplusplus } // extern "C" @@ -119,8 +118,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; +#define Serial Serial2 //Connected to ST-Link // 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 @@ -137,8 +135,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..cb3fee7ab4 100644 --- a/variants/NUCLEO_L476RG/variant.h +++ b/variants/NUCLEO_L476RG/variant.h @@ -149,6 +149,7 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +// UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) // UART Emulation @@ -158,8 +159,6 @@ enum { // Serial Pin 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,8 +168,7 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern HardwareSerial Serial; -extern HardwareSerial Serial1; +#define Serial Serial2 //Connected to ST-Link // 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 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..92787d5c42 100644 --- a/variants/board_template/variant.h +++ b/variants/board_template/variant.h @@ -106,6 +106,7 @@ enum { //Do not use basic timer: OC is required #define TIMER_SERVO TIMx //TODO: advanced-control timers don't work +// UART Definitions #define DEBUG_UART ((USART_TypeDef *) U(S)ARTX) // ex: USART3 // UART Emulation (uncomment if needed, required TIM1) @@ -115,10 +116,6 @@ enum { // Serial Pin 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,10 +125,8 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -// declare here as many UART objects than defined in variant.cpp -extern HardwareSerial Serial; -//extern HardwareSerial SerialX; -//... +// Define here Serial instance to map on Serial generic name +#define Serial Serialx //ex: Serial3 //Connected to ST-Link // 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 @@ -148,8 +143,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_ */ From 0f9c0eb246a274eb76ce9135af8c766008e6445c Mon Sep 17 00:00:00 2001 From: "Frederic.Pillon" Date: Thu, 28 Sep 2017 10:09:32 +0200 Subject: [PATCH 3/9] Add methods to change Rx/Tx pins Signed-off-by: Frederic.Pillon --- cores/arduino/HardwareSerial.cpp | 16 ++++++++++++++++ cores/arduino/HardwareSerial.h | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index 5d5baf9372..e6009d4ed9 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -338,3 +338,19 @@ 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; +} diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index 62a24888c7..d945dda495 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -119,6 +119,11 @@ 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); From 02e149a574f1ea54b67f41aaa4220f0d26cfbe2b Mon Sep 17 00:00:00 2001 From: "Frederic.Pillon" Date: Thu, 28 Sep 2017 11:56:28 +0200 Subject: [PATCH 4/9] Set default pin used for 'Serial' instance (ex: ST-Link) When Serialx instanciation, check if it is the generic 'Serial' then set Rx/Tx pins if defined else get the pins of the first peripheral occurence in PinMap Anyway, Rx/Tx pins could be changed later using Serialx.setRx/setTx methods before call the Serialx.begin() Signed-off-by: Frederic.Pillon --- cores/arduino/HardwareSerial.cpp | 17 +++++++++++++++-- variants/DISCO_F100RB/variant.h | 3 ++- variants/DISCO_F407VG/variant.h | 7 ++++--- variants/DISCO_F746NG/variant.h | 7 ++++--- variants/DISCO_L475VG_IOT/variant.h | 3 ++- variants/NUCLEO_F030R8/variant.h | 3 ++- variants/NUCLEO_F091RC/variant.h | 3 ++- variants/NUCLEO_F103RB/variant.h | 3 ++- variants/NUCLEO_F207ZG/variant.h | 7 ++++--- variants/NUCLEO_F303RE/variant.h | 3 ++- variants/NUCLEO_F401RE/variant.h | 3 ++- variants/NUCLEO_F411RE/variant.h | 3 ++- variants/NUCLEO_F429ZI/variant.h | 7 ++++--- variants/NUCLEO_L053R8/variant.h | 3 ++- variants/NUCLEO_L152RE/variant.h | 3 ++- variants/NUCLEO_L432KC/variant.h | 7 ++++--- variants/NUCLEO_L476RG/variant.h | 3 ++- variants/board_template/variant.h | 3 ++- 18 files changed, 59 insertions(+), 29 deletions(-) diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index e6009d4ed9..869846045d 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -143,8 +143,21 @@ HardwareSerial::HardwareSerial(PinName _rx, PinName _tx) HardwareSerial::HardwareSerial(void* peripheral) { - _serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX); - _serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX); +// 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(); } diff --git a/variants/DISCO_F100RB/variant.h b/variants/DISCO_F100RB/variant.h index 50152654f9..0f86c8dbc3 100644 --- a/variants/DISCO_F100RB/variant.h +++ b/variants/DISCO_F100RB/variant.h @@ -155,7 +155,8 @@ enum { // UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) -// Serial Pin Firmata +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata #define PIN_SERIAL_RX 8 #define PIN_SERIAL_TX 7 diff --git a/variants/DISCO_F407VG/variant.h b/variants/DISCO_F407VG/variant.h index f928b65e9c..878c183bec 100644 --- a/variants/DISCO_F407VG/variant.h +++ b/variants/DISCO_F407VG/variant.h @@ -184,9 +184,10 @@ enum { #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" diff --git a/variants/DISCO_F746NG/variant.h b/variants/DISCO_F746NG/variant.h index 441e5439e1..f332d538af 100644 --- a/variants/DISCO_F746NG/variant.h +++ b/variants/DISCO_F746NG/variant.h @@ -112,9 +112,10 @@ enum { // UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART1) -// Serial Pin Firmata -#define PIN_SERIAL_RX 23 -#define PIN_SERIAL_TX 24 +// 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" diff --git a/variants/DISCO_L475VG_IOT/variant.h b/variants/DISCO_L475VG_IOT/variant.h index 1e1c08d008..430dab8ea4 100644 --- a/variants/DISCO_L475VG_IOT/variant.h +++ b/variants/DISCO_L475VG_IOT/variant.h @@ -182,7 +182,8 @@ enum { // UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART1) -// 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 diff --git a/variants/NUCLEO_F030R8/variant.h b/variants/NUCLEO_F030R8/variant.h index 95bbe82ab8..100a0ee1d8 100644 --- a/variants/NUCLEO_F030R8/variant.h +++ b/variants/NUCLEO_F030R8/variant.h @@ -153,7 +153,8 @@ enum { // UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) -// 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 diff --git a/variants/NUCLEO_F091RC/variant.h b/variants/NUCLEO_F091RC/variant.h index 89a1f287f7..e28deb8595 100644 --- a/variants/NUCLEO_F091RC/variant.h +++ b/variants/NUCLEO_F091RC/variant.h @@ -156,7 +156,8 @@ enum { #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 diff --git a/variants/NUCLEO_F103RB/variant.h b/variants/NUCLEO_F103RB/variant.h index f42ea99214..803cf6cc2c 100644 --- a/variants/NUCLEO_F103RB/variant.h +++ b/variants/NUCLEO_F103RB/variant.h @@ -152,7 +152,8 @@ enum { // UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) -// 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 diff --git a/variants/NUCLEO_F207ZG/variant.h b/variants/NUCLEO_F207ZG/variant.h index 5b986df517..c8c4b9b49a 100644 --- a/variants/NUCLEO_F207ZG/variant.h +++ b/variants/NUCLEO_F207ZG/variant.h @@ -197,9 +197,10 @@ enum { // UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART3) -// Serial Pin Firmata -#define PIN_SERIAL_RX 76 -#define PIN_SERIAL_TX 77 +// 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" diff --git a/variants/NUCLEO_F303RE/variant.h b/variants/NUCLEO_F303RE/variant.h index 80547e535b..a35add0048 100644 --- a/variants/NUCLEO_F303RE/variant.h +++ b/variants/NUCLEO_F303RE/variant.h @@ -156,7 +156,8 @@ enum { #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 diff --git a/variants/NUCLEO_F401RE/variant.h b/variants/NUCLEO_F401RE/variant.h index 43451b5e48..304e648da4 100644 --- a/variants/NUCLEO_F401RE/variant.h +++ b/variants/NUCLEO_F401RE/variant.h @@ -157,7 +157,8 @@ enum { #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 diff --git a/variants/NUCLEO_F411RE/variant.h b/variants/NUCLEO_F411RE/variant.h index 985d98e612..85d96406b2 100644 --- a/variants/NUCLEO_F411RE/variant.h +++ b/variants/NUCLEO_F411RE/variant.h @@ -153,7 +153,8 @@ enum { // UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) -// 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 diff --git a/variants/NUCLEO_F429ZI/variant.h b/variants/NUCLEO_F429ZI/variant.h index 5184ad1271..ff21cdcaa9 100644 --- a/variants/NUCLEO_F429ZI/variant.h +++ b/variants/NUCLEO_F429ZI/variant.h @@ -191,9 +191,10 @@ enum { #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 +// Serial pin used for console (ex: stlink) +// Rerquired by Firmata +#define PIN_SERIAL_RX PD9 +#define PIN_SERIAL_TX PD8 #ifdef __cplusplus } // extern "C" diff --git a/variants/NUCLEO_L053R8/variant.h b/variants/NUCLEO_L053R8/variant.h index 776e585648..50cedb916a 100644 --- a/variants/NUCLEO_L053R8/variant.h +++ b/variants/NUCLEO_L053R8/variant.h @@ -152,7 +152,8 @@ enum { // UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) -// 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 diff --git a/variants/NUCLEO_L152RE/variant.h b/variants/NUCLEO_L152RE/variant.h index 850f18ea53..5b12a32a61 100644 --- a/variants/NUCLEO_L152RE/variant.h +++ b/variants/NUCLEO_L152RE/variant.h @@ -157,7 +157,8 @@ enum { // UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) -// 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 diff --git a/variants/NUCLEO_L432KC/variant.h b/variants/NUCLEO_L432KC/variant.h index 03afc32a1e..dd5f5a6a80 100644 --- a/variants/NUCLEO_L432KC/variant.h +++ b/variants/NUCLEO_L432KC/variant.h @@ -106,9 +106,10 @@ enum { // UART Definitions #define DEBUG_UART ((USART_TypeDef *) USART2) -// Serial Pin Firmata -#define PIN_SERIAL_RX 22 -#define PIN_SERIAL_TX 21 +// 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" diff --git a/variants/NUCLEO_L476RG/variant.h b/variants/NUCLEO_L476RG/variant.h index cb3fee7ab4..dd912a7966 100644 --- a/variants/NUCLEO_L476RG/variant.h +++ b/variants/NUCLEO_L476RG/variant.h @@ -156,7 +156,8 @@ enum { #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 diff --git a/variants/board_template/variant.h b/variants/board_template/variant.h index 92787d5c42..10f7a0a83b 100644 --- a/variants/board_template/variant.h +++ b/variants/board_template/variant.h @@ -113,7 +113,8 @@ enum { //#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 From f3f8809d36987c1fc3c5896e74546da99956257d Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Fri, 29 Sep 2017 22:05:20 +0200 Subject: [PATCH 5/9] Review UART_DEBUG definition By default, UART_DEBUG is linked to Serial generic instance. So it is not required to define it. It could be redefined in the variant.h to print on another instance than Serial Signed-off-by: Frederic.Pillon --- cores/arduino/stm32/uart.c | 13 +++++++++++-- variants/DISCO_F100RB/variant.h | 2 -- variants/DISCO_F407VG/variant.h | 2 -- variants/DISCO_F746NG/variant.h | 2 -- variants/DISCO_L475VG_IOT/variant.h | 2 -- variants/NUCLEO_F030R8/variant.h | 2 -- variants/NUCLEO_F091RC/variant.h | 2 -- variants/NUCLEO_F103RB/variant.h | 2 -- variants/NUCLEO_F207ZG/variant.h | 2 -- variants/NUCLEO_F303RE/variant.h | 2 -- variants/NUCLEO_F401RE/variant.h | 2 -- variants/NUCLEO_F411RE/variant.h | 2 -- variants/NUCLEO_F429ZI/variant.h | 2 -- variants/NUCLEO_L053R8/variant.h | 2 -- variants/NUCLEO_L152RE/variant.h | 2 -- variants/NUCLEO_L432KC/variant.h | 2 -- variants/NUCLEO_L476RG/variant.h | 2 -- variants/board_template/variant.h | 3 ++- 18 files changed, 13 insertions(+), 35 deletions(-) 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/variants/DISCO_F100RB/variant.h b/variants/DISCO_F100RB/variant.h index 0f86c8dbc3..07aa373548 100644 --- a/variants/DISCO_F100RB/variant.h +++ b/variants/DISCO_F100RB/variant.h @@ -153,8 +153,6 @@ enum { #define TIMER_SERVO TIM17 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART2) - // Default pin used for 'Serial' instance (ex: ST-Link) // Mandatory for Firmata #define PIN_SERIAL_RX 8 diff --git a/variants/DISCO_F407VG/variant.h b/variants/DISCO_F407VG/variant.h index 878c183bec..96edcecd4a 100644 --- a/variants/DISCO_F407VG/variant.h +++ b/variants/DISCO_F407VG/variant.h @@ -178,8 +178,6 @@ enum { #define TIMER_UART_EMULATED TIM6 // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART2) - // UART Emulation #define UART_EMUL_RX PE_9 #define UART_EMUL_TX PE_11 diff --git a/variants/DISCO_F746NG/variant.h b/variants/DISCO_F746NG/variant.h index f332d538af..fa721cbc7c 100644 --- a/variants/DISCO_F746NG/variant.h +++ b/variants/DISCO_F746NG/variant.h @@ -110,8 +110,6 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART1) - // Default pin used for 'Serial' instance (ex: ST-Link) // Mandatory for Firmata #define PIN_SERIAL_RX PB7 diff --git a/variants/DISCO_L475VG_IOT/variant.h b/variants/DISCO_L475VG_IOT/variant.h index 430dab8ea4..a90e6ea1f2 100644 --- a/variants/DISCO_L475VG_IOT/variant.h +++ b/variants/DISCO_L475VG_IOT/variant.h @@ -180,8 +180,6 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART1) - // Default pin used for 'Serial' instance (ex: ST-Link) // Mandatory for Firmata #define PIN_SERIAL_RX 0 diff --git a/variants/NUCLEO_F030R8/variant.h b/variants/NUCLEO_F030R8/variant.h index 100a0ee1d8..4ca2cc3c99 100644 --- a/variants/NUCLEO_F030R8/variant.h +++ b/variants/NUCLEO_F030R8/variant.h @@ -151,8 +151,6 @@ enum { #define TIMER_SERVO TIM3 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART2) - // Default pin used for 'Serial' instance (ex: ST-Link) // Mandatory for Firmata #define PIN_SERIAL_RX 0 diff --git a/variants/NUCLEO_F091RC/variant.h b/variants/NUCLEO_F091RC/variant.h index e28deb8595..bffb976e35 100644 --- a/variants/NUCLEO_F091RC/variant.h +++ b/variants/NUCLEO_F091RC/variant.h @@ -150,8 +150,6 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART2) - // UART Emulation #define UART_EMUL_RX PB_14 #define UART_EMUL_TX PB_13 diff --git a/variants/NUCLEO_F103RB/variant.h b/variants/NUCLEO_F103RB/variant.h index 803cf6cc2c..cdd8beac90 100644 --- a/variants/NUCLEO_F103RB/variant.h +++ b/variants/NUCLEO_F103RB/variant.h @@ -150,8 +150,6 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART2) - // Default pin used for 'Serial' instance (ex: ST-Link) // Mandatory for Firmata #define PIN_SERIAL_RX 0 diff --git a/variants/NUCLEO_F207ZG/variant.h b/variants/NUCLEO_F207ZG/variant.h index c8c4b9b49a..79f2bbb4f0 100644 --- a/variants/NUCLEO_F207ZG/variant.h +++ b/variants/NUCLEO_F207ZG/variant.h @@ -195,8 +195,6 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART3) - // Default pin used for 'Serial' instance (ex: ST-Link) // Mandatory for Firmata #define PIN_SERIAL_RX PD9 diff --git a/variants/NUCLEO_F303RE/variant.h b/variants/NUCLEO_F303RE/variant.h index a35add0048..700565b7ee 100644 --- a/variants/NUCLEO_F303RE/variant.h +++ b/variants/NUCLEO_F303RE/variant.h @@ -150,8 +150,6 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART2) - // UART Emulation #define UART_EMUL_RX PC_1 #define UART_EMUL_TX PC_3 diff --git a/variants/NUCLEO_F401RE/variant.h b/variants/NUCLEO_F401RE/variant.h index 304e648da4..bb154894fd 100644 --- a/variants/NUCLEO_F401RE/variant.h +++ b/variants/NUCLEO_F401RE/variant.h @@ -151,8 +151,6 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART2) - // UART Emulation #define UART_EMUL_RX PC_1 #define UART_EMUL_TX PC_3 diff --git a/variants/NUCLEO_F411RE/variant.h b/variants/NUCLEO_F411RE/variant.h index 85d96406b2..22ff9bd99b 100644 --- a/variants/NUCLEO_F411RE/variant.h +++ b/variants/NUCLEO_F411RE/variant.h @@ -151,8 +151,6 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART2) - // Default pin used for 'Serial' instance (ex: ST-Link) // Mandatory for Firmata #define PIN_SERIAL_RX 0 diff --git a/variants/NUCLEO_F429ZI/variant.h b/variants/NUCLEO_F429ZI/variant.h index ff21cdcaa9..2225a5abbe 100644 --- a/variants/NUCLEO_F429ZI/variant.h +++ b/variants/NUCLEO_F429ZI/variant.h @@ -185,8 +185,6 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART3) - // UART Emulation #define UART_EMUL_RX PF_15 #define UART_EMUL_TX PE_13 diff --git a/variants/NUCLEO_L053R8/variant.h b/variants/NUCLEO_L053R8/variant.h index 50cedb916a..1f4309785b 100644 --- a/variants/NUCLEO_L053R8/variant.h +++ b/variants/NUCLEO_L053R8/variant.h @@ -150,8 +150,6 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART2) - // Default pin used for 'Serial' instance (ex: ST-Link) // Mandatory for Firmata #define PIN_SERIAL_RX 0 diff --git a/variants/NUCLEO_L152RE/variant.h b/variants/NUCLEO_L152RE/variant.h index 5b12a32a61..1ed6c85730 100644 --- a/variants/NUCLEO_L152RE/variant.h +++ b/variants/NUCLEO_L152RE/variant.h @@ -155,8 +155,6 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART2) - // Default pin used for 'Serial' instance (ex: ST-Link) // Mandatory for Firmata #define PIN_SERIAL_RX 0 diff --git a/variants/NUCLEO_L432KC/variant.h b/variants/NUCLEO_L432KC/variant.h index dd5f5a6a80..ffd89bf36b 100644 --- a/variants/NUCLEO_L432KC/variant.h +++ b/variants/NUCLEO_L432KC/variant.h @@ -104,8 +104,6 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART2) - // Default pin used for 'Serial' instance (ex: ST-Link) // Mandatory for Firmata #define PIN_SERIAL_RX PA15 diff --git a/variants/NUCLEO_L476RG/variant.h b/variants/NUCLEO_L476RG/variant.h index dd912a7966..8d21f7ffb8 100644 --- a/variants/NUCLEO_L476RG/variant.h +++ b/variants/NUCLEO_L476RG/variant.h @@ -150,8 +150,6 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) USART2) - // UART Emulation #define UART_EMUL_RX PB_13 #define UART_EMUL_TX PB_14 diff --git a/variants/board_template/variant.h b/variants/board_template/variant.h index 10f7a0a83b..3794a95944 100644 --- a/variants/board_template/variant.h +++ b/variants/board_template/variant.h @@ -107,7 +107,8 @@ enum { #define TIMER_SERVO TIMx //TODO: advanced-control timers don't work // UART Definitions -#define DEBUG_UART ((USART_TypeDef *) U(S)ARTX) // ex: USART3 +// 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 From c4c55a20c5df9351e7378e2f707afd7834998fa1 Mon Sep 17 00:00:00 2001 From: "Frederic.Pillon" Date: Tue, 3 Oct 2017 16:52:44 +0200 Subject: [PATCH 6/9] Update Serial menu and defined generic Serial instance Signed-off-by: Frederic Pillon --- boards.txt | 64 ++++++++--------- cores/arduino/HardwareSerial.cpp | 8 ++- cores/arduino/stm32/uart.h | 106 +++++++++++++++++++++++++++- variants/DISCO_F100RB/variant.h | 3 +- variants/DISCO_F407VG/variant.h | 3 +- variants/DISCO_F746NG/variant.h | 3 +- variants/DISCO_L475VG_IOT/variant.h | 3 +- variants/NUCLEO_F030R8/variant.h | 3 +- variants/NUCLEO_F091RC/variant.h | 3 +- variants/NUCLEO_F103RB/variant.h | 3 +- variants/NUCLEO_F207ZG/variant.h | 3 +- variants/NUCLEO_F303RE/variant.h | 3 +- variants/NUCLEO_F401RE/variant.h | 3 +- variants/NUCLEO_F411RE/variant.h | 3 +- variants/NUCLEO_F429ZI/variant.h | 3 +- variants/NUCLEO_L053R8/variant.h | 3 +- variants/NUCLEO_L152RE/variant.h | 3 +- variants/NUCLEO_L432KC/variant.h | 3 +- variants/NUCLEO_L476RG/variant.h | 3 +- variants/board_template/variant.h | 5 +- 20 files changed, 162 insertions(+), 69 deletions(-) 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 869846045d..7c709815cf 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -30,9 +30,13 @@ #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)); @@ -367,3 +371,5 @@ void HardwareSerial::setRx(PinName _rx) { void HardwareSerial::setTx(PinName _tx){ _serial.pin_tx = _tx; } +#endif // HAVE_HWSERIALx +#endif // !NO_HWSERIAL diff --git a/cores/arduino/stm32/uart.h b/cores/arduino/stm32/uart.h index ac17f183bd..1a82e628d4 100644 --- a/cores/arduino/stm32/uart.h +++ b/cores/arduino/stm32/uart.h @@ -41,42 +41,146 @@ /* 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.h b/variants/DISCO_F100RB/variant.h index 07aa373548..cd380c7533 100644 --- a/variants/DISCO_F100RB/variant.h +++ b/variants/DISCO_F100RB/variant.h @@ -153,6 +153,7 @@ enum { #define TIMER_SERVO TIM17 //TODO: advanced-control timers don't work // 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 @@ -166,8 +167,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial2 //Connected to ST-Link - // 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/DISCO_F407VG/variant.h b/variants/DISCO_F407VG/variant.h index 96edcecd4a..472f675658 100644 --- a/variants/DISCO_F407VG/variant.h +++ b/variants/DISCO_F407VG/variant.h @@ -178,6 +178,7 @@ enum { #define TIMER_UART_EMULATED TIM6 // 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 @@ -195,8 +196,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial2 // Could be connected to ST-Link - // 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/DISCO_F746NG/variant.h b/variants/DISCO_F746NG/variant.h index fa721cbc7c..1bbdd04942 100644 --- a/variants/DISCO_F746NG/variant.h +++ b/variants/DISCO_F746NG/variant.h @@ -110,6 +110,7 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // 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 @@ -123,8 +124,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial1 //Connected to ST-Link - // 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/DISCO_L475VG_IOT/variant.h b/variants/DISCO_L475VG_IOT/variant.h index a90e6ea1f2..c2b8d31423 100644 --- a/variants/DISCO_L475VG_IOT/variant.h +++ b/variants/DISCO_L475VG_IOT/variant.h @@ -180,6 +180,7 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // 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 0 @@ -193,8 +194,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial1 //Connected to ST-Link - // 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/NUCLEO_F030R8/variant.h b/variants/NUCLEO_F030R8/variant.h index 4ca2cc3c99..0460b6c1a8 100644 --- a/variants/NUCLEO_F030R8/variant.h +++ b/variants/NUCLEO_F030R8/variant.h @@ -151,6 +151,7 @@ enum { #define TIMER_SERVO TIM3 //TODO: advanced-control timers don't work // 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 @@ -164,8 +165,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial2 //Connected to ST-Link - // 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/NUCLEO_F091RC/variant.h b/variants/NUCLEO_F091RC/variant.h index bffb976e35..6ae514c055 100644 --- a/variants/NUCLEO_F091RC/variant.h +++ b/variants/NUCLEO_F091RC/variant.h @@ -150,6 +150,7 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // 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 @@ -167,8 +168,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial2 //Connected to ST-Link - // 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/NUCLEO_F103RB/variant.h b/variants/NUCLEO_F103RB/variant.h index cdd8beac90..afcdfa9220 100644 --- a/variants/NUCLEO_F103RB/variant.h +++ b/variants/NUCLEO_F103RB/variant.h @@ -150,6 +150,7 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // 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 @@ -163,8 +164,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial2 //Connected to ST-Link - // 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/NUCLEO_F207ZG/variant.h b/variants/NUCLEO_F207ZG/variant.h index 79f2bbb4f0..eedda5ac66 100644 --- a/variants/NUCLEO_F207ZG/variant.h +++ b/variants/NUCLEO_F207ZG/variant.h @@ -195,6 +195,7 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // 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 @@ -208,8 +209,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial3 //Connected to ST-Link - // 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/NUCLEO_F303RE/variant.h b/variants/NUCLEO_F303RE/variant.h index 700565b7ee..9c661f91d5 100644 --- a/variants/NUCLEO_F303RE/variant.h +++ b/variants/NUCLEO_F303RE/variant.h @@ -150,6 +150,7 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // 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 @@ -167,8 +168,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial2 //Connected to ST-Link - // 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/NUCLEO_F401RE/variant.h b/variants/NUCLEO_F401RE/variant.h index bb154894fd..fed35037bc 100644 --- a/variants/NUCLEO_F401RE/variant.h +++ b/variants/NUCLEO_F401RE/variant.h @@ -151,6 +151,7 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // 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 @@ -168,8 +169,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial2 //Connected to ST-Link - // 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/NUCLEO_F411RE/variant.h b/variants/NUCLEO_F411RE/variant.h index 22ff9bd99b..cd70562ca7 100644 --- a/variants/NUCLEO_F411RE/variant.h +++ b/variants/NUCLEO_F411RE/variant.h @@ -151,6 +151,7 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // 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 @@ -164,8 +165,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial2 //Connected to ST-Link - // 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/NUCLEO_F429ZI/variant.h b/variants/NUCLEO_F429ZI/variant.h index 2225a5abbe..1b082b6b5f 100644 --- a/variants/NUCLEO_F429ZI/variant.h +++ b/variants/NUCLEO_F429ZI/variant.h @@ -185,6 +185,7 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // 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 @@ -202,8 +203,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial3 //Connected to ST-Link - // 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/NUCLEO_L053R8/variant.h b/variants/NUCLEO_L053R8/variant.h index 1f4309785b..6e34523465 100644 --- a/variants/NUCLEO_L053R8/variant.h +++ b/variants/NUCLEO_L053R8/variant.h @@ -150,6 +150,7 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // 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 @@ -163,8 +164,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial2 //Connected to ST-Link - // 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/NUCLEO_L152RE/variant.h b/variants/NUCLEO_L152RE/variant.h index 1ed6c85730..a3c0d9afad 100644 --- a/variants/NUCLEO_L152RE/variant.h +++ b/variants/NUCLEO_L152RE/variant.h @@ -155,6 +155,7 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // 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 @@ -168,8 +169,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial2 //Connected to ST-Link - // 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/NUCLEO_L432KC/variant.h b/variants/NUCLEO_L432KC/variant.h index ffd89bf36b..1fee78addb 100644 --- a/variants/NUCLEO_L432KC/variant.h +++ b/variants/NUCLEO_L432KC/variant.h @@ -104,6 +104,7 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // 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 @@ -117,8 +118,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial2 //Connected to ST-Link - // 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/NUCLEO_L476RG/variant.h b/variants/NUCLEO_L476RG/variant.h index 8d21f7ffb8..f9da065b5b 100644 --- a/variants/NUCLEO_L476RG/variant.h +++ b/variants/NUCLEO_L476RG/variant.h @@ -150,6 +150,7 @@ enum { #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work // 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 @@ -167,8 +168,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -#define Serial Serial2 //Connected to ST-Link - // 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.h b/variants/board_template/variant.h index 3794a95944..b8c552aacb 100644 --- a/variants/board_template/variant.h +++ b/variants/board_template/variant.h @@ -107,6 +107,8 @@ enum { #define TIMER_SERVO TIMx //TODO: advanced-control timers don't work // 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 @@ -127,9 +129,6 @@ enum { *----------------------------------------------------------------------------*/ #ifdef __cplusplus -// Define here Serial instance to map on Serial generic name -#define Serial Serialx //ex: Serial3 //Connected to ST-Link - // 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, From e933a8ed75327bba853f10fb91acccf1fa57c75b Mon Sep 17 00:00:00 2001 From: "Frederic.Pillon" Date: Tue, 3 Oct 2017 16:59:42 +0200 Subject: [PATCH 7/9] Cleaned variant.h include As HardwareSerial is no more used in variant, use pins_arduino.h instead of Arduino.h Signed-off-by: Frederic.Pillon --- variants/DISCO_F100RB/variant.h | 4 +--- variants/DISCO_F407VG/variant.h | 4 +--- variants/DISCO_F746NG/variant.h | 4 +--- variants/DISCO_L475VG_IOT/variant.h | 4 +--- variants/NUCLEO_F030R8/variant.h | 4 +--- variants/NUCLEO_F091RC/variant.h | 4 +--- variants/NUCLEO_F103RB/variant.h | 4 +--- variants/NUCLEO_F207ZG/variant.h | 4 +--- variants/NUCLEO_F303RE/variant.h | 4 +--- variants/NUCLEO_F401RE/variant.h | 4 +--- variants/NUCLEO_F411RE/variant.h | 4 +--- variants/NUCLEO_F429ZI/variant.h | 4 +--- variants/NUCLEO_L053R8/variant.h | 4 +--- variants/NUCLEO_L152RE/variant.h | 4 +--- variants/NUCLEO_L432KC/variant.h | 4 +--- variants/NUCLEO_L476RG/variant.h | 4 +--- variants/board_template/variant.h | 4 +--- 17 files changed, 17 insertions(+), 51 deletions(-) diff --git a/variants/DISCO_F100RB/variant.h b/variants/DISCO_F100RB/variant.h index cd380c7533..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 { diff --git a/variants/DISCO_F407VG/variant.h b/variants/DISCO_F407VG/variant.h index 472f675658..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 { diff --git a/variants/DISCO_F746NG/variant.h b/variants/DISCO_F746NG/variant.h index 1bbdd04942..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 { diff --git a/variants/DISCO_L475VG_IOT/variant.h b/variants/DISCO_L475VG_IOT/variant.h index c2b8d31423..99fa96e34c 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,8 +32,6 @@ extern "C"{ /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ -#include "PeripheralPins.h" - extern const PinName digitalPin[]; enum { diff --git a/variants/NUCLEO_F030R8/variant.h b/variants/NUCLEO_F030R8/variant.h index 0460b6c1a8..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 { diff --git a/variants/NUCLEO_F091RC/variant.h b/variants/NUCLEO_F091RC/variant.h index 6ae514c055..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 { diff --git a/variants/NUCLEO_F103RB/variant.h b/variants/NUCLEO_F103RB/variant.h index afcdfa9220..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 { diff --git a/variants/NUCLEO_F207ZG/variant.h b/variants/NUCLEO_F207ZG/variant.h index eedda5ac66..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 diff --git a/variants/NUCLEO_F303RE/variant.h b/variants/NUCLEO_F303RE/variant.h index 9c661f91d5..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 { diff --git a/variants/NUCLEO_F401RE/variant.h b/variants/NUCLEO_F401RE/variant.h index fed35037bc..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 { diff --git a/variants/NUCLEO_F411RE/variant.h b/variants/NUCLEO_F411RE/variant.h index cd70562ca7..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 { diff --git a/variants/NUCLEO_F429ZI/variant.h b/variants/NUCLEO_F429ZI/variant.h index 1b082b6b5f..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 { diff --git a/variants/NUCLEO_L053R8/variant.h b/variants/NUCLEO_L053R8/variant.h index 6e34523465..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 { diff --git a/variants/NUCLEO_L152RE/variant.h b/variants/NUCLEO_L152RE/variant.h index a3c0d9afad..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 { diff --git a/variants/NUCLEO_L432KC/variant.h b/variants/NUCLEO_L432KC/variant.h index 1fee78addb..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 { diff --git a/variants/NUCLEO_L476RG/variant.h b/variants/NUCLEO_L476RG/variant.h index f9da065b5b..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 { diff --git a/variants/board_template/variant.h b/variants/board_template/variant.h index b8c552aacb..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 From 2bf97af36e651dd70208c31438128f7311d86ed7 Mon Sep 17 00:00:00 2001 From: "Frederic.Pillon" Date: Wed, 4 Oct 2017 11:45:24 +0200 Subject: [PATCH 8/9] Cleaned header file Signed-off-by: Frederic.Pillon --- cores/arduino/stm32/core_callback.h | 2 +- cores/arduino/stm32/timer.c | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) 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/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" { From 29bdd7c8885bc058761a71d13e5ae15e0d4159a0 Mon Sep 17 00:00:00 2001 From: fpr Date: Fri, 6 Oct 2017 11:46:18 +0200 Subject: [PATCH 9/9] Fix missing pin declaration Signed-off-by: fpr Signed-off-by: Frederic.Pillon --- variants/DISCO_L475VG_IOT/variant.cpp | 133 ++++++++++---------- variants/DISCO_L475VG_IOT/variant.h | 173 +++++++++++++------------- 2 files changed, 156 insertions(+), 150 deletions(-) diff --git a/variants/DISCO_L475VG_IOT/variant.cpp b/variants/DISCO_L475VG_IOT/variant.cpp index ead0838183..fdc4cf817b 100644 --- a/variants/DISCO_L475VG_IOT/variant.cpp +++ b/variants/DISCO_L475VG_IOT/variant.cpp @@ -45,76 +45,79 @@ 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 diff --git a/variants/DISCO_L475VG_IOT/variant.h b/variants/DISCO_L475VG_IOT/variant.h index 99fa96e34c..19247f9a84 100644 --- a/variants/DISCO_L475VG_IOT/variant.h +++ b/variants/DISCO_L475VG_IOT/variant.h @@ -36,101 +36,104 @@ 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 @@ -148,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 @@ -181,8 +184,8 @@ enum { #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 0 -#define PIN_SERIAL_TX 1 +#define PIN_SERIAL_RX PB7 +#define PIN_SERIAL_TX PB6 #ifdef __cplusplus } // extern "C"