Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic support for adding board variants for Teensy 4.x boards. #750

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9a03c7d
fix leap year calculation bug in makeTime()
A-Dunstan May 10, 2024
90810a7
add missing overrides for global operator new
A-Dunstan May 21, 2024
345566f
Minimal changes to start to support variants
KurtE Jan 21, 2024
1006612
Allow XBar table to be be defined external
KurtE Jan 21, 2024
fc4f4e5
Allow the PWM table to be replaced by variant
KurtE Jan 23, 2024
d82de1f
Add analaog and maybe SerialX overrides WIP
KurtE Jun 30, 2024
3f3faa5
Update core_pin_names.h
KurtE Jun 30, 2024
4323123
Fix Serial6 and 7 for Port addr passed in
KurtE Jul 1, 2024
85c8e51
Update HardwareSerial5.cpp
KurtE Jul 12, 2024
87a6366
remove warning of unused variable
KurtE Jul 25, 2024
56780d7
Add NOEXEC comment with link to example code
PaulStoffregen Aug 12, 2024
2b69ca9
Fix T3.x SerialEventX when format is passed in.
KurtE Aug 14, 2024
2d1fd0e
added set_psram_clock
mjs513 Aug 24, 2024
cdb3ecb
Merge pull request #3 from mjs513/variants_override
KurtE Aug 24, 2024
243cd11
do not enable cts when setting alternate rx xbar pin
sndsgd Sep 1, 2024
59b8008
Merge pull request #754 from sndsgd/serial-rx-xbar
PaulStoffregen Sep 3, 2024
316d56e
Fix hardware serial serialEvent on Teensy 3.x
PaulStoffregen Sep 7, 2024
c7015ed
Merge pull request #742 from A-Dunstan/makeTime
PaulStoffregen Sep 7, 2024
a68833b
Check non-const pin number in digitalWriteFast, etc
PaulStoffregen Sep 7, 2024
e5cf16d
Fix extmem_realloc with NULL on Teensy 4.1
PaulStoffregen Sep 7, 2024
4dd943c
Add clock speed comment
PaulStoffregen Sep 8, 2024
0753ac2
Fix return type on __SSAT
PaulStoffregen Sep 8, 2024
4b5097a
Merge pull request #743 from A-Dunstan/missing_new_overrides
PaulStoffregen Sep 8, 2024
f11c80a
FS class virtual destructor
PaulStoffregen Sep 9, 2024
427a1a6
Minimal changes to start to support variants
KurtE Jan 21, 2024
4d5e2bb
Allow XBar table to be be defined external
KurtE Jan 21, 2024
cd78b0f
Allow the PWM table to be replaced by variant
KurtE Jan 23, 2024
1982071
Add analaog and maybe SerialX overrides WIP
KurtE Jun 30, 2024
f565539
Update core_pin_names.h
KurtE Jun 30, 2024
6321b45
Fix Serial6 and 7 for Port addr passed in
KurtE Jul 1, 2024
7dcc441
Update HardwareSerial5.cpp
KurtE Jul 12, 2024
dce222f
remove warning of unused variable
KurtE Jul 25, 2024
7ff631a
Fix T3.x SerialEventX when format is passed in.
KurtE Aug 14, 2024
b64f5e2
added set_psram_clock
mjs513 Aug 24, 2024
160f748
Merge branch 'variants_override' of https://github.com/KurtE/cores in…
KurtE Sep 10, 2024
25143fa
HardwareSerial::attachRts - new optional parameter to invert signal
KurtE Sep 27, 2024
15b3e1b
Changed API as you requested: attachRtsInverted
KurtE Sep 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 6 additions & 31 deletions teensy3/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,7 @@ class HardwareSerial : public Stream
#else //(__MK64FX512__) || defined(__MK66FX1M0__)
enum {CNT_HARDWARE_SERIAL = 3};
#endif
virtual void begin(uint32_t baud);
virtual void begin(uint32_t baud, uint32_t format) {
serial_begin(BAUD2DIV(baud));
serial_format(format); }
virtual void begin(uint32_t baud, uint32_t format=(uint32_t)-1);
virtual void end(void) { serial_end(); }
virtual void transmitterEnable(uint8_t pin) { serial_set_transmit_pin(pin); }
virtual void setRX(uint8_t pin) { serial_set_rx(pin); }
Expand Down Expand Up @@ -336,10 +333,7 @@ class HardwareSerial2 : public HardwareSerial
{
public:
constexpr HardwareSerial2(void (* const se)()) : HardwareSerial(se) {}
virtual void begin(uint32_t baud);
virtual void begin(uint32_t baud, uint32_t format) {
serial2_begin(BAUD2DIV2(baud));
serial2_format(format); }
virtual void begin(uint32_t baud, uint32_t format=(uint32_t)-1);
virtual void end(void) { serial2_end(); }
virtual void transmitterEnable(uint8_t pin) { serial2_set_transmit_pin(pin); }
virtual void setRX(uint8_t pin) { serial2_set_rx(pin); }
Expand Down Expand Up @@ -375,10 +369,7 @@ class HardwareSerial3 : public HardwareSerial
{
public:
constexpr HardwareSerial3(void (* const se)()) : HardwareSerial(se) {}
virtual void begin(uint32_t baud);
virtual void begin(uint32_t baud, uint32_t format) {
serial3_begin(BAUD2DIV3(baud));
serial3_format(format); }
virtual void begin(uint32_t baud, uint32_t format=(uint32_t)-1);
virtual void end(void) { serial3_end(); }
virtual void transmitterEnable(uint8_t pin) { serial3_set_transmit_pin(pin); }
virtual void setRX(uint8_t pin) { serial3_set_rx(pin); }
Expand Down Expand Up @@ -414,10 +405,7 @@ class HardwareSerial4 : public HardwareSerial
{
public:
constexpr HardwareSerial4(void (* const se)()) : HardwareSerial(se) {}
virtual void begin(uint32_t baud);
virtual void begin(uint32_t baud, uint32_t format) {
serial4_begin(BAUD2DIV3(baud));
serial4_format(format); }
virtual void begin(uint32_t baud, uint32_t format=(uint32_t)-1);
virtual void end(void) { serial4_end(); }
virtual void transmitterEnable(uint8_t pin) { serial4_set_transmit_pin(pin); }
virtual void setRX(uint8_t pin) { serial4_set_rx(pin); }
Expand Down Expand Up @@ -453,10 +441,7 @@ class HardwareSerial5 : public HardwareSerial
{
public:
constexpr HardwareSerial5(void (* const se)()) : HardwareSerial(se) {}
virtual void begin(uint32_t baud);
virtual void begin(uint32_t baud, uint32_t format) {
serial5_begin(BAUD2DIV3(baud));
serial5_format(format); }
virtual void begin(uint32_t baud, uint32_t format=(uint32_t)-1);
virtual void end(void) { serial5_end(); }
virtual void transmitterEnable(uint8_t pin) { serial5_set_transmit_pin(pin); }
virtual void setRX(uint8_t pin) { serial5_set_rx(pin); }
Expand Down Expand Up @@ -492,17 +477,7 @@ class HardwareSerial6 : public HardwareSerial
{
public:
constexpr HardwareSerial6(void (* const se)()) : HardwareSerial(se) {}
#if defined(__MK66FX1M0__) // For LPUART just pass baud straight in.
virtual void begin(uint32_t baud);
virtual void begin(uint32_t baud, uint32_t format) {
serial6_begin(baud);
serial6_format(format); }
#else
virtual void begin(uint32_t baud);
virtual void begin(uint32_t baud, uint32_t format) {
serial6_begin(BAUD2DIV3(baud));
serial6_format(format); }
#endif
virtual void begin(uint32_t baud, uint32_t format=(uint32_t)-1);
virtual void end(void) { serial6_end(); }
virtual void transmitterEnable(uint8_t pin) { serial6_set_transmit_pin(pin); }
virtual void setRX(uint8_t pin) { serial6_set_rx(pin); }
Expand Down
3 changes: 2 additions & 1 deletion teensy3/HardwareSerial1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ uint8_t _serialEvent1_default __attribute__((weak)) PROGMEM = 0 ;

HardwareSerial Serial1(&serialEvent1);

void HardwareSerial::begin(uint32_t baud) {
void HardwareSerial::begin(uint32_t baud, uint32_t format) {
serial_begin(BAUD2DIV(baud));
if (format != (uint32_t)-1) serial_format(format);
if (!_serialEvent1_default) addToSerialEventsList();
}

3 changes: 2 additions & 1 deletion teensy3/HardwareSerial2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ HardwareSerial2 Serial2(&serialEvent2);

uint8_t _serialEvent2_default __attribute__((weak)) PROGMEM = 0 ;

void HardwareSerial2::begin(uint32_t baud) {
void HardwareSerial2::begin(uint32_t baud, uint32_t format) {
serial2_begin(BAUD2DIV2(baud));
if (format != (uint32_t)-1) serial2_format(format);
if (!_serialEvent2_default) addToSerialEventsList();
}
3 changes: 2 additions & 1 deletion teensy3/HardwareSerial3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ HardwareSerial3 Serial3(&serialEvent3);

uint8_t _serialEvent3_default __attribute__((weak)) PROGMEM = 0 ;

void HardwareSerial3::begin(uint32_t baud) {
void HardwareSerial3::begin(uint32_t baud, uint32_t format) {
serial3_begin(BAUD2DIV3(baud));
if (format != (uint32_t)-1) serial3_format(format);
if (!_serialEvent3_default) addToSerialEventsList();
}
3 changes: 2 additions & 1 deletion teensy3/HardwareSerial4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ HardwareSerial4 Serial4(&serialEvent4);

uint8_t _serialEvent4_default __attribute__((weak)) PROGMEM = 0 ;

void HardwareSerial4::begin(uint32_t baud) {
void HardwareSerial4::begin(uint32_t baud, uint32_t format) {
serial4_begin(BAUD2DIV3(baud));
if (format != (uint32_t)-1) serial4_format(format);
if (!_serialEvent4_default) addToSerialEventsList();
}

Expand Down
3 changes: 2 additions & 1 deletion teensy3/HardwareSerial5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ HardwareSerial5 Serial5(&serialEvent5);

uint8_t _serialEvent5_default __attribute__((weak)) PROGMEM = 0 ;

void HardwareSerial5::begin(uint32_t baud) {
void HardwareSerial5::begin(uint32_t baud, uint32_t format) {
serial5_begin(BAUD2DIV3(baud));
if (format != (uint32_t)-1) serial5_format(format);
if (!_serialEvent5_default) addToSerialEventsList();
}

Expand Down
3 changes: 2 additions & 1 deletion teensy3/HardwareSerial6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ HardwareSerial6 Serial6(&serialEvent6);

uint8_t _serialEvent6_default __attribute__((weak)) PROGMEM = 0 ;

void HardwareSerial6::begin(uint32_t baud) {
void HardwareSerial6::begin(uint32_t baud, uint32_t format) {
#if defined(__MK66FX1M0__) // For LPUART just pass baud straight in.
serial6_begin(baud);
#else
serial6_begin(BAUD2DIV3(baud));
#endif
if (format != (uint32_t)-1) serial6_format(format);
if (!_serialEvent6_default) addToSerialEventsList();
}

Expand Down
4 changes: 2 additions & 2 deletions teensy4/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ void HardwareSerialIMXRT::addToSerialEventsList() {
}


const pin_to_xbar_info_t PROGMEM pin_to_xbar_info[] = {
extern const pin_to_xbar_info_t PROGMEM pin_to_xbar_info[] __attribute__((weak)) = {
{0, 17, 1, &IOMUXC_XBAR1_IN17_SELECT_INPUT, 0x1},
{1, 16, 1, nullptr, 0},
{2, 6, 3, &IOMUXC_XBAR1_IN06_SELECT_INPUT, 0x0},
Expand Down Expand Up @@ -757,5 +757,5 @@ const pin_to_xbar_info_t PROGMEM pin_to_xbar_info[] = {
#endif
};

const uint8_t PROGMEM count_pin_to_xbar_info = sizeof(pin_to_xbar_info)/sizeof(pin_to_xbar_info[0]);
extern const uint8_t PROGMEM count_pin_to_xbar_info __attribute__((weak)) = sizeof(pin_to_xbar_info)/sizeof(pin_to_xbar_info[0]);

15 changes: 10 additions & 5 deletions teensy4/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,25 @@ class HardwareSerialIMXRT : public HardwareSerial
} pin_info_t;

typedef struct {
// General settings for this Serial object.
uint8_t serial_index; // which object are we? 0 based
IRQ_NUMBER_t irq;
void (*irq_handler)(void);
void (* _serialEvent)(void);
const uint16_t irq_priority;
const uint16_t rts_low_watermark;
const uint16_t rts_high_watermark;

// Settings that apply to underlying LPUART object.
IRQ_NUMBER_t irq;
volatile uint32_t &ccm_register;
const uint32_t ccm_value;
const uint8_t xbar_out_lpuartX_trig_input;

// Pin lists
pin_info_t rx_pins[cnt_rx_pins];
pin_info_t tx_pins[cnt_tx_pins];
const uint8_t cts_pin;
const uint8_t cts_mux_val;
const uint16_t irq_priority;
const uint16_t rts_low_watermark;
const uint16_t rts_high_watermark;
const uint8_t xbar_out_lpuartX_trig_input;
} hardware_t;
public:
constexpr HardwareSerialIMXRT(uintptr_t myport, const hardware_t *myhardware,
Expand Down
35 changes: 21 additions & 14 deletions teensy4/HardwareSerial1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,35 @@ void IRQHandler_Serial1()
Serial1.IRQHandler();
}

// Should we allow each one to be overwritten or all of a Port...
#ifndef SERIAL1_RX_PINS
#define SERIAL1_UART_ADDR IMXRT_LPUART6_ADDRESS
#define SERIAL1_LPUART IRQ_LPUART6, CCM_CCGR3, CCM_CCGR3_LPUART6(CCM_CCGR_ON), XBARA1_OUT_LPUART6_TRG_INPUT
#define SERIAL1_CTS_PIN 0xff, 0
#if defined(ARDUINO_TEENSY41)
#define SERIAL1_RX_PINS {{0,2, &IOMUXC_LPUART6_RX_SELECT_INPUT, 1}, {52, 2, &IOMUXC_LPUART6_RX_SELECT_INPUT, 0}}
#define SERIAL1_TX_PINS {{1,2, &IOMUXC_LPUART6_TX_SELECT_INPUT, 1}, {53, 2, &IOMUXC_LPUART6_TX_SELECT_INPUT, 0}}
#else
#define SERIAL1_RX_PINS {{0,2, &IOMUXC_LPUART6_RX_SELECT_INPUT, 1}, {0xff, 0xff, nullptr, 0}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT the serial instances are just handed out in the order the pins are defined. So if I routed LPUART4 to pins 1 and 0, those should be associated with Serial1.

It might make sense to create some more defines so custom boards can do the same?

#define SERIAL1_UART                LPUART6
#define SERIAL1_UART_ADDR           IMXRT_LPUART6_ADDRESS
#define SERIAL1_UART_OPTIONS        IRQ_LPUART6, CCM_CCGR3, CCM_CCGR3_LPUART6(CCM_CCGR_ON), XBARA1_OUT_LPUART6_TRG_INPUT
#define SERIAL1_TX_PIN              1
#define SERIAL1_RX_PIN              0
#define SERIAL1_CTS_PIN             0xff
#define SERIAL1_RTS_PIN             0xff
#define SERIAL1_TX_SELECT_INPUT     &IOMUXC_LPUART6_TX_SELECT_INPUT
#define SERIAL1_RX_SELECT_INPUT     &IOMUXC_LPUART6_RX_SELECT_INPUT
#define SERIAL1_ALT_TX_PIN          0xff
#define SERIAL1_ALT_RX_PIN          0xff
#define SERIAL1_ALT_CTS_PIN         0xff
#define SERIAL1_ALT_RTS_PIN         0xff
#define SERIAL1_ALT_TX_SELECT_INPUT nullptr
#define SERIAL1_ALT_RX_SELECT_INPUT nullptr

#define SERIAL1_TX_PINS {{1,2, &IOMUXC_LPUART6_TX_SELECT_INPUT, 1}, {0xff, 0xff, nullptr, 0}}
#endif
#endif



// Serial1
static BUFTYPE tx_buffer1[SERIAL1_TX_BUFFER_SIZE];
static BUFTYPE rx_buffer1[SERIAL1_RX_BUFFER_SIZE];

const HardwareSerialIMXRT::hardware_t UART6_Hardware = {
0, IRQ_LPUART6, &IRQHandler_Serial1,
const HardwareSerialIMXRT::hardware_t Serial1_Hardware = {
0,
&IRQHandler_Serial1,
&serialEvent1,
CCM_CCGR3, CCM_CCGR3_LPUART6(CCM_CCGR_ON),
#if defined(ARDUINO_TEENSY41)
{{0,2, &IOMUXC_LPUART6_RX_SELECT_INPUT, 1}, {52, 2, &IOMUXC_LPUART6_RX_SELECT_INPUT, 0}},
{{1,2, &IOMUXC_LPUART6_TX_SELECT_INPUT, 1}, {53, 2, &IOMUXC_LPUART6_TX_SELECT_INPUT, 0}},
#else
{{0,2, &IOMUXC_LPUART6_RX_SELECT_INPUT, 1}, {0xff, 0xff, nullptr, 0}},
{{1,2, &IOMUXC_LPUART6_TX_SELECT_INPUT, 1}, {0xff, 0xff, nullptr, 0}},
#endif
0xff, // No CTS pin
0, // No CTS
IRQ_PRIORITY, 38, 24, // IRQ, rts_low_watermark, rts_high_watermark
XBARA1_OUT_LPUART6_TRG_INPUT // XBar Tigger
// Stuff that can be overwritten easily by variant
SERIAL1_LPUART, SERIAL1_RX_PINS, SERIAL1_TX_PINS, SERIAL1_CTS_PIN
};
HardwareSerialIMXRT Serial1(IMXRT_LPUART6_ADDRESS, &UART6_Hardware, tx_buffer1,
HardwareSerialIMXRT Serial1(SERIAL1_UART_ADDR, &Serial1_Hardware, tx_buffer1,
SERIAL1_TX_BUFFER_SIZE, rx_buffer1, SERIAL1_RX_BUFFER_SIZE);

//void serialEvent1() __attribute__((weak));
Expand Down
48 changes: 22 additions & 26 deletions teensy4/HardwareSerial2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,38 +45,34 @@ void IRQHandler_Serial2()
Serial2.IRQHandler();
}

#ifndef SERIAL2_RX_PINS
#define SERIAL2_CTS_PIN 0xff, 0
#if !defined(ARDUINO_TEENSY_MICROMOD)
#define SERIAL2_UART_ADDR IMXRT_LPUART4_ADDRESS
#define SERIAL2_LPUART IRQ_LPUART4, CCM_CCGR1, CCM_CCGR1_LPUART4(CCM_CCGR_ON), XBARA1_OUT_LPUART4_TRG_INPUT
#define SERIAL2_RX_PINS {{7,2, &IOMUXC_LPUART4_RX_SELECT_INPUT, 2}, {0xff, 0xff, nullptr, 0}}
#define SERIAL2_TX_PINS {{8,2, &IOMUXC_LPUART4_TX_SELECT_INPUT, 2}, {0xff, 0xff, nullptr, 0}}

#else
#define SERIAL2_UART_ADDR IMXRT_LPUART3_ADDRESS
#define SERIAL2_LPUART IRQ_LPUART3, CCM_CCGR0, CCM_CCGR0_LPUART3(CCM_CCGR_ON), XBARA1_OUT_LPUART3_TRG_INPUT
#define SERIAL2_RX_PINS {{16,2, &IOMUXC_LPUART3_RX_SELECT_INPUT, 0}, {0xff, 0xff, nullptr, 0}}
#define SERIAL2_TX_PINS {{17,2, &IOMUXC_LPUART3_TX_SELECT_INPUT, 0}, {0xff, 0xff, nullptr, 0}}
#endif
#endif


// Serial2
static BUFTYPE tx_buffer2[SERIAL2_TX_BUFFER_SIZE];
static BUFTYPE rx_buffer2[SERIAL2_RX_BUFFER_SIZE];

#ifndef ARDUINO_TEENSY_MICROMOD
static HardwareSerialIMXRT::hardware_t UART4_Hardware = {
1, IRQ_LPUART4, &IRQHandler_Serial2,
static HardwareSerialIMXRT::hardware_t Serial2_Hardware = {
1,
&IRQHandler_Serial2,
&serialEvent2,
CCM_CCGR1, CCM_CCGR1_LPUART4(CCM_CCGR_ON),
{{7,2, &IOMUXC_LPUART4_RX_SELECT_INPUT, 2}, {0xff, 0xff, nullptr, 0}},
{{8,2, &IOMUXC_LPUART4_TX_SELECT_INPUT, 2}, {0xff, 0xff, nullptr, 0}},
0xff, // No CTS pin
0, // No CTS
IRQ_PRIORITY, 38, 24, // IRQ, rts_low_watermark, rts_high_watermark
XBARA1_OUT_LPUART4_TRG_INPUT
// Stuff that can be overwritten easily by variant
SERIAL2_LPUART, SERIAL2_RX_PINS, SERIAL2_TX_PINS, SERIAL2_CTS_PIN
};
HardwareSerialIMXRT Serial2(IMXRT_LPUART4_ADDRESS, &UART4_Hardware, tx_buffer2,
HardwareSerialIMXRT Serial2(SERIAL2_UART_ADDR, &Serial2_Hardware, tx_buffer2,
SERIAL2_TX_BUFFER_SIZE, rx_buffer2, SERIAL2_RX_BUFFER_SIZE);

#else // Teensy Micromod
static HardwareSerialIMXRT::hardware_t UART3_Hardware = {
3, IRQ_LPUART3, &IRQHandler_Serial2,
&serialEvent2,
CCM_CCGR0, CCM_CCGR0_LPUART3(CCM_CCGR_ON),
{{16,2, &IOMUXC_LPUART3_RX_SELECT_INPUT, 0}, {0xff, 0xff, nullptr, 0}},
{{17,2, &IOMUXC_LPUART3_TX_SELECT_INPUT, 0}, {0xff, 0xff, nullptr, 0}},
0xff, // No CTS pin
0, // No CTS
IRQ_PRIORITY, 38, 24, // IRQ, rts_low_watermark, rts_high_watermark
XBARA1_OUT_LPUART3_TRG_INPUT
};
HardwareSerialIMXRT Serial2(IMXRT_LPUART3_ADDRESS, &UART3_Hardware, tx_buffer2,
SERIAL2_TX_BUFFER_SIZE, rx_buffer2, SERIAL2_RX_BUFFER_SIZE);
#endif
26 changes: 17 additions & 9 deletions teensy4/HardwareSerial3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,29 @@ void IRQHandler_Serial3()
Serial3.IRQHandler();
}

#ifndef SERIAL3_RX_PINS
#define SERIAL3_UART_ADDR IMXRT_LPUART2_ADDRESS
#define SERIAL3_LPUART IRQ_LPUART2, CCM_CCGR0, CCM_CCGR0_LPUART2(CCM_CCGR_ON), XBARA1_OUT_LPUART2_TRG_INPUT
#define SERIAL3_CTS_PIN 19, 2
#define SERIAL3_RX_PINS {{15,2, &IOMUXC_LPUART2_RX_SELECT_INPUT, 1}, {0xff, 0xff, nullptr, 0}}
#define SERIAL3_TX_PINS {{14,2, &IOMUXC_LPUART2_TX_SELECT_INPUT, 1}, {0xff, 0xff, nullptr, 0}}
#endif




// Serial3
static BUFTYPE tx_buffer3[SERIAL3_TX_BUFFER_SIZE];
static BUFTYPE rx_buffer3[SERIAL3_RX_BUFFER_SIZE];

static HardwareSerialIMXRT::hardware_t UART2_Hardware = {
2, IRQ_LPUART2, &IRQHandler_Serial3,
const HardwareSerialIMXRT::hardware_t SERIAL3_Hardware = {
2,
&IRQHandler_Serial3,
&serialEvent3,
CCM_CCGR0, CCM_CCGR0_LPUART2(CCM_CCGR_ON),
{{15,2, &IOMUXC_LPUART2_RX_SELECT_INPUT, 1}, {0xff, 0xff, nullptr, 0}},
{{14,2, &IOMUXC_LPUART2_TX_SELECT_INPUT, 1}, {0xff, 0xff, nullptr, 0}},
19, //IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_00, // 19
2, // page 473
IRQ_PRIORITY, 38, 24, // IRQ, rts_low_watermark, rts_high_watermark
XBARA1_OUT_LPUART2_TRG_INPUT
// Stuff that can be overwritten easily by variant
SERIAL3_LPUART, SERIAL3_RX_PINS, SERIAL3_TX_PINS, SERIAL3_CTS_PIN
};
HardwareSerialIMXRT Serial3(IMXRT_LPUART2_ADDRESS, &UART2_Hardware, tx_buffer3,
HardwareSerialIMXRT Serial3(SERIAL3_UART_ADDR, &SERIAL3_Hardware, tx_buffer3,
SERIAL3_TX_BUFFER_SIZE, rx_buffer3, SERIAL3_RX_BUFFER_SIZE);

Loading