Skip to content

Commit

Permalink
👽️ Update Teensy 4.0/4.1 Serial (MarlinFirmware#26457)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellensp authored Nov 25, 2023
1 parent e98e307 commit ae695e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
12 changes: 11 additions & 1 deletion Marlin/src/HAL/TEENSY40_41/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,19 @@

#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X)
#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X)
#if WITHIN(SERIAL_PORT, 0, 3)
#if WITHIN(SERIAL_PORT, 0, 8)
IMPLEMENT_SERIAL(SERIAL_PORT);
#endif
#ifdef SERIAL_PORT_2
#if WITHIN(SERIAL_PORT_2, 0, 8)
IMPLEMENT_SERIAL(SERIAL_PORT_2);
#endif
#endif
#ifdef SERIAL_PORT_3
#if WITHIN(SERIAL_PORT_3, 0, 8)
IMPLEMENT_SERIAL(SERIAL_PORT_3);
#endif
#endif
USBSerialType USBSerial(false, SerialUSB);

// ------------------------
Expand Down
16 changes: 14 additions & 2 deletions Marlin/src/HAL/TEENSY40_41/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ extern USBSerialType USBSerial;
#define MSERIAL(X) _MSERIAL(X)

#if SERIAL_PORT == -1
#define MYSERIAL1 SerialUSB
#define MYSERIAL1 USBSerial
#elif WITHIN(SERIAL_PORT, 0, 8)
DECLARE_SERIAL(SERIAL_PORT);
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
Expand All @@ -90,16 +90,28 @@ extern USBSerialType USBSerial;

#ifdef SERIAL_PORT_2
#if SERIAL_PORT_2 == -1
#define MYSERIAL2 usbSerial
#define MYSERIAL2 USBSerial
#elif SERIAL_PORT_2 == -2
#define MYSERIAL2 ethernet.telnetClient
#elif WITHIN(SERIAL_PORT_2, 0, 8)
DECLARE_SERIAL(SERIAL_PORT_2);
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
#else
#error "SERIAL_PORT_2 must be from 0 to 8, or -1 for Native USB, or -2 for Ethernet."
#endif
#endif

#ifdef SERIAL_PORT_3
#if SERIAL_PORT_3 == -1
#define MYSERIAL3 USBSerial
#elif WITHIN(SERIAL_PORT_3, 0, 8)
DECLARE_SERIAL(SERIAL_PORT_3);
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
#else
#error "SERIAL_PORT_3 must be from 0 to 8, or -1 for Native USB."
#endif
#endif

// ------------------------
// Types
// ------------------------
Expand Down

0 comments on commit ae695e8

Please sign in to comment.