Here’s the “Hello World” edition of getting access to USART2 and USART3 on an STM32 Blue Pill in PlatformIO using the Arduino framework.
/* lib_deps = NONE
# Using a library name
-------- Platform.ini Settings----------
[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
#board = bluepill_f103c8
framework = arduino
upload_protocol = stlink
lib_compat_mode = soft
*/
#include "Arduino.h"
HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
HardwareSerial Serial3(USART3); // PB11 (RX) PB10 (TX)
void setup() {
Serial.begin(19200); // PA10 (RX) PA9 (TX)
Serial2.begin(19200); // PA3 (RX) PA2 (TX)
Serial3.begin(19200); // PB11 (RX) PB10 (TX)
Serial.println("Serial: 1");
Serial2.println("Serial2: 2");
Serial3.println("Serial3: 3");
}
void loop() {
Serial.println("Serial: 1");
Serial2.println("Serial2: 2");
Serial3.println("Serial3: 3");
delay(1000);
}