Skip to content

Instantly share code, notes, and snippets.

@rdlauer
Last active June 6, 2024 19:30
Show Gist options
  • Save rdlauer/bca35bad6624f6981ad52cddb3c07cf9 to your computer and use it in GitHub Desktop.
Save rdlauer/bca35bad6624f6981ad52cddb3c07cf9 to your computer and use it in GitHub Desktop.
Configuring an Arduino sketch to output Serial data over STLINK interface
// configuring an Arduino sketch to output Serial data over STLINK interface
#define serialDebug Serial
HardwareSerial stlinkSerial(PIN_VCP_RX, PIN_VCP_TX);
void setup()
{
#ifdef serialDebug
stlinkSerial.begin(115200);
const size_t usb_timeout_ms = 3000;
for (const size_t start_ms = millis(); !stlinkSerial && (millis() - start_ms) < usb_timeout_ms;)
;
#endif
stlinkSerial.println("Hello World (Setup)");
}
void loop()
{
delay(2000);
stlinkSerial.println("Hello World (Loop)");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment