Found a way that appears to work to detect if a sketch has our default serialEvantX functions, and that the users code has not implemented their own. Before on SerialX.begin() I would add that serial ports code to table of function calls to do the if SerialX.available() call serialEvernt.. But I now have a hacked up version where each of the event functions are in their own source file, along with a variable that is defined. Elsewhere I have those same variables defined with an attribute of ((weak)), so if our default implemention is pulled in it is defined with a value of 1, if the weak version is used because the user has their own implemention, then it is defined as a 0... So I can detect this at the begin method and only add the code to do the checks in yield if the user implemented it. WARNING this also brought in changes for using XBar pins for CTS and RX pins... As I did not wish to split back out and have you maybe have to manually merge.teensy4-core
@@ -41,6 +41,8 @@ EventResponder * EventResponder::lastInterrupt = nullptr; | |||
bool EventResponder::runningFromYield = false; | |||
// TODO: interrupt disable/enable needed in many places!!! | |||
// BUGBUG: See if file name order makes difference? | |||
uint8_t _serialEvent_default __attribute__((weak)) PROGMEM = 0 ; | |||
void EventResponder::triggerEventNotImmediate() | |||
{ | |||
@@ -343,6 +345,7 @@ extern "C" void systick_isr(void) | |||
systick_cycle_count = ARM_DWT_CYCCNT; | |||
systick_millis_count++; | |||
} | |||
extern "C" void systick_isr_with_timer_events(void) | |||
{ | |||
systick_cycle_count = ARM_DWT_CYCCNT; | |||
@@ -350,4 +353,3 @@ extern "C" void systick_isr_with_timer_events(void) | |||
MillisTimer::runFromTimer(); | |||
} | |||
@@ -62,6 +62,10 @@ | |||
#define UART_CLOCK 24000000 | |||
extern "C" { | |||
extern void xbar_connect(unsigned int input, unsigned int output); | |||
} | |||
#if defined(ARDUINO_TEENSY41) | |||
SerialEventCheckingFunctionPointer HardwareSerial::serial_event_handler_checks[8] = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; | |||
#else | |||
@@ -193,7 +197,8 @@ void HardwareSerial::begin(uint32_t baud, uint16_t format) | |||
if ( format & 0x100) port->BAUD |= LPUART_BAUD_SBNS; | |||
//Serial.printf(" stat:%x ctrl:%x fifo:%x water:%x\n", port->STAT, port->CTRL, port->FIFO, port->WATER ); | |||
enableSerialEvents(); // Enable the processing of serialEvent for this object | |||
// Only if the user implemented their own... | |||
if (!(*hardware->serial_event_handler_default)) enableSerialEvents(); // Enable the processing of serialEvent for this object | |||
}; | |||
inline void HardwareSerial::rts_assert() | |||
@@ -243,9 +248,9 @@ void HardwareSerial::setRX(uint8_t pin) | |||
// new pin - so lets maybe reset the old pin to INPUT? and then set new pin parameters | |||
// only change IO pins if done after begin has been called. | |||
if ((hardware->ccm_register & hardware->ccm_value)) { | |||
*(portConfigRegister(hardware->rx_pins[rx_pin_index_].pin)) = 5; | |||
*(portConfigRegister(hardware->rx_pins[rx_pin_index_].pin)) = 5; | |||
// now set new pin info. | |||
// now set new pin info. | |||
*(portControlRegister(hardware->rx_pins[rx_pin_new_index].pin)) = IOMUXC_PAD_DSE(7) | IOMUXC_PAD_PKE | IOMUXC_PAD_PUE | IOMUXC_PAD_PUS(3) | IOMUXC_PAD_HYS;; | |||
*(portConfigRegister(hardware->rx_pins[rx_pin_new_index].pin)) = hardware->rx_pins[rx_pin_new_index].mux_val; | |||
if (hardware->rx_pins[rx_pin_new_index].select_input_register) { | |||
@@ -253,7 +258,29 @@ void HardwareSerial::setRX(uint8_t pin) | |||
} | |||
} | |||
rx_pin_index_ = rx_pin_new_index; | |||
break; | |||
return; // done. | |||
} | |||
} | |||
// If we got to here and did not find a valid pin there. Maybe see if it is an XBar pin... | |||
for (uint8_t i = 0; i < count_pin_to_xbar_info; i++) { | |||
if (pin_to_xbar_info[i].pin == pin) { | |||
// So it is an XBAR pin set the XBAR.. | |||
//Serial.printf("ACTS XB(%d), X(%u %u), MUX:%x\n", i, pin_to_xbar_info[i].xbar_in_index, | |||
// hardware->xbar_out_lpuartX_trig_input, pin_to_xbar_info[i].mux_val); | |||
CCM_CCGR2 |= CCM_CCGR2_XBAR1(CCM_CCGR_ON); | |||
xbar_connect(pin_to_xbar_info[i].xbar_in_index, hardware->xbar_out_lpuartX_trig_input); | |||
// We need to update port register to use this as the trigger | |||
port->PINCFG = LPUART_PINCFG_TRGSEL(1); // Trigger select as alternate RX | |||
// configure the pin. | |||
*(portControlRegister(pin)) = IOMUXC_PAD_DSE(7) | IOMUXC_PAD_PKE | IOMUXC_PAD_PUE | IOMUXC_PAD_PUS(3) | IOMUXC_PAD_HYS;; | |||
*(portConfigRegister(pin)) = pin_to_xbar_info[i].mux_val; | |||
port->MODIR |= LPUART_MODIR_TXCTSE; | |||
if (pin_to_xbar_info[i].select_input_register) *(pin_to_xbar_info[i].select_input_register) = pin_to_xbar_info[i].select_val; | |||
//Serial.printf("SerialX::begin stat:%x ctrl:%x fifo:%x water:%x\n", port->STAT, port->CTRL, port->FIFO, port->WATER ); | |||
//Serial.printf(" PINCFG: %x MODIR: %x\n", port->PINCFG, port->MODIR); | |||
return; | |||
} | |||
} | |||
} | |||
@@ -315,6 +342,30 @@ bool HardwareSerial::attachCts(uint8_t pin) | |||
port->MODIR |= LPUART_MODIR_TXCTSE; | |||
return true; | |||
} else { | |||
// See maybe this a pin we can use XBAR for. | |||
for (uint8_t i = 0; i < count_pin_to_xbar_info; i++) { | |||
if (pin_to_xbar_info[i].pin == pin) { | |||
// So it is an XBAR pin set the XBAR.. | |||
//Serial.printf("ACTS XB(%d), X(%u %u), MUX:%x\n", i, pin_to_xbar_info[i].xbar_in_index, | |||
// hardware->xbar_out_lpuartX_trig_input, pin_to_xbar_info[i].mux_val); | |||
CCM_CCGR2 |= CCM_CCGR2_XBAR1(CCM_CCGR_ON); | |||
xbar_connect(pin_to_xbar_info[i].xbar_in_index, hardware->xbar_out_lpuartX_trig_input); | |||
// We need to update port register to use this as the trigger | |||
port->PINCFG = LPUART_PINCFG_TRGSEL(2); // Trigger select as alternate CTS pin | |||
// configure the pin. | |||
*(portControlRegister(pin)) = IOMUXC_PAD_DSE(7) | IOMUXC_PAD_PKE | IOMUXC_PAD_PUE | IOMUXC_PAD_PUS(0) | IOMUXC_PAD_HYS; | |||
*(portConfigRegister(pin)) = pin_to_xbar_info[i].mux_val; | |||
if (pin_to_xbar_info[i].select_input_register) *(pin_to_xbar_info[i].select_input_register) = pin_to_xbar_info[i].select_val; | |||
port->MODIR |= LPUART_MODIR_TXCTSE; | |||
//Serial.printf("SerialX::begin stat:%x ctrl:%x fifo:%x water:%x\n", port->STAT, port->CTRL, port->FIFO, port->WATER ); | |||
//Serial.printf(" PINCFG: %x MODIR: %x\n", port->PINCFG, port->MODIR); | |||
return true; | |||
} | |||
} | |||
// Fell through so not valid pin for this. | |||
port->MODIR &= ~LPUART_MODIR_TXCTSE; | |||
return false; | |||
} | |||
@@ -580,3 +631,40 @@ void HardwareSerial::disableSerialEvents() | |||
if (!serial_event_handlers_active) yield_active_check_flags &= ~YIELD_CHECK_HARDWARE_SERIAL; | |||
} | |||
} | |||
const pin_to_xbar_info_t PROGMEM pin_to_xbar_info[] = { | |||
{0, 17, 1, &IOMUXC_XBAR1_IN17_SELECT_INPUT, 0x1}, | |||
{1, 16, 1, nullptr, 0}, | |||
{2, 6, 3, &IOMUXC_XBAR1_IN06_SELECT_INPUT, 0x0}, | |||
{3, 7, 3, &IOMUXC_XBAR1_IN07_SELECT_INPUT, 0x0}, | |||
{4, 8, 3, &IOMUXC_XBAR1_IN08_SELECT_INPUT, 0x0}, | |||
{5, 17, 3, &IOMUXC_XBAR1_IN17_SELECT_INPUT, 0x0}, | |||
{7, 15, 1, nullptr, 0 }, | |||
{8, 14, 1, nullptr, 0}, | |||
{30, 23, 1, &IOMUXC_XBAR1_IN23_SELECT_INPUT, 0x0}, | |||
{31, 22, 1, &IOMUXC_XBAR1_IN22_SELECT_INPUT, 0x0}, | |||
{32, 10, 1, nullptr, 0}, | |||
{33, 9, 3, &IOMUXC_XBAR1_IN09_SELECT_INPUT, 0x0}, | |||
#ifdef ARDUINO_TEENSY41 | |||
{36, 16, 1, nullptr, 0}, | |||
{37, 17, 1, &IOMUXC_XBAR1_IN17_SELECT_INPUT, 0x3}, | |||
{42, 7, 3, &IOMUXC_XBAR1_IN07_SELECT_INPUT, 0x1}, | |||
{43, 6, 3, &IOMUXC_XBAR1_IN06_SELECT_INPUT, 0x1}, | |||
{44, 5, 3, &IOMUXC_XBAR1_IN05_SELECT_INPUT, 0x1}, | |||
{45, 4, 3, &IOMUXC_XBAR1_IN04_SELECT_INPUT, 0x1}, | |||
{46, 9, 3, &IOMUXC_XBAR1_IN09_SELECT_INPUT, 0x1}, | |||
{47, 8, 3, &IOMUXC_XBAR1_IN08_SELECT_INPUT, 0x1} | |||
#else | |||
{34, 7, 3, &IOMUXC_XBAR1_IN07_SELECT_INPUT, 0x1}, | |||
{35, 6, 3, &IOMUXC_XBAR1_IN06_SELECT_INPUT, 0x1}, | |||
{36, 5, 3, &IOMUXC_XBAR1_IN05_SELECT_INPUT, 0x1}, | |||
{37, 4, 3, &IOMUXC_XBAR1_IN04_SELECT_INPUT, 0x1}, | |||
{38, 9, 3, &IOMUXC_XBAR1_IN09_SELECT_INPUT, 0x1}, | |||
{39, 8, 3, &IOMUXC_XBAR1_IN08_SELECT_INPUT, 0x1} | |||
#endif | |||
}; | |||
const uint8_t PROGMEM count_pin_to_xbar_info = sizeof(pin_to_xbar_info)/sizeof(pin_to_xbar_info[0]); | |||
@@ -125,6 +125,23 @@ extern "C" { | |||
#endif | |||
} | |||
//=================================================================== | |||
// Should find a good home for this | |||
// Map IO pin to XBar pin... | |||
//=================================================================== | |||
// BUGBUG - find a good home | |||
typedef struct _pin_to_xbar_info{ | |||
const uint8_t pin; // The pin number | |||
const uint8_t xbar_in_index; // What XBar input index. | |||
const uint32_t mux_val; // Value to set for mux; | |||
volatile uint32_t *select_input_register; // Which register controls the selection | |||
const uint32_t select_val; // Value for that selection | |||
} pin_to_xbar_info_t; | |||
extern const pin_to_xbar_info_t pin_to_xbar_info[]; | |||
extern const uint8_t count_pin_to_xbar_info; | |||
typedef void(*SerialEventCheckingFunctionPointer)(); | |||
class HardwareSerial : public Stream | |||
@@ -144,6 +161,7 @@ public: | |||
IRQ_NUMBER_t irq; | |||
void (*irq_handler)(void); | |||
void (*serial_event_handler_check)(void); | |||
const uint8_t *serial_event_handler_default; | |||
volatile uint32_t &ccm_register; | |||
const uint32_t ccm_value; | |||
pin_info_t rx_pins[cnt_rx_pins]; | |||
@@ -153,6 +171,7 @@ public: | |||
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 HardwareSerial(IMXRT_LPUART_t *myport, const hardware_t *myhardware, |
@@ -1,3 +1,4 @@ | |||
/* Teensyduino Core Library | |||
* http://www.pjrc.com/teensy/ | |||
* Copyright (c) 2019 PJRC.COM, LLC. | |||
@@ -52,9 +53,11 @@ void serial_event_check_serial1() | |||
// Serial1 | |||
static BUFTYPE tx_buffer1[SERIAL1_TX_BUFFER_SIZE]; | |||
static BUFTYPE rx_buffer1[SERIAL1_RX_BUFFER_SIZE]; | |||
uint8_t _serialEvent1_default __attribute__((weak)) PROGMEM = 0 ; | |||
const HardwareSerial::hardware_t UART6_Hardware = { | |||
0, IRQ_LPUART6, &IRQHandler_Serial1, &serial_event_check_serial1, | |||
0, IRQ_LPUART6, &IRQHandler_Serial1, | |||
&serial_event_check_serial1, &_serialEvent1_default, | |||
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}}, | |||
@@ -66,12 +69,13 @@ const HardwareSerial::hardware_t UART6_Hardware = { | |||
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 | |||
}; | |||
HardwareSerial Serial1(&IMXRT_LPUART6, &UART6_Hardware, tx_buffer1, SERIAL1_TX_BUFFER_SIZE, | |||
rx_buffer1, SERIAL1_RX_BUFFER_SIZE); | |||
void serialEvent1() __attribute__((weak)); | |||
void serialEvent1() {Serial1.disableSerialEvents(); } // No use calling this so disable if called... | |||
//void serialEvent1() __attribute__((weak)); | |||
//void serialEvent1() {Serial1.disableSerialEvents(); } // No use calling this so disable if called... | |||
// C wrapper functions to help take care of places that used to call these from standard C | |||
void serial_print(const char *p) |
@@ -54,9 +54,11 @@ void serial_event_check_serial2() | |||
// Serial2 | |||
static BUFTYPE tx_buffer2[SERIAL2_TX_BUFFER_SIZE]; | |||
static BUFTYPE rx_buffer2[SERIAL2_RX_BUFFER_SIZE]; | |||
uint8_t _serialEvent2_default __attribute__((weak)) PROGMEM = 0 ; | |||
static HardwareSerial::hardware_t UART4_Hardware = { | |||
1, IRQ_LPUART4, &IRQHandler_Serial2, &serial_event_check_serial2, | |||
1, IRQ_LPUART4, &IRQHandler_Serial2, | |||
&serial_event_check_serial2, &_serialEvent2_default, | |||
CCM_CCGR1, CCM_CCGR1_LPUART4(CCM_CCGR_ON), | |||
#if defined(__IMXRT1052__) | |||
{{6,2, &IOMUXC_LPUART4_RX_SELECT_INPUT, 2}, {0xff, 0xff, nullptr, 0}}, | |||
@@ -68,6 +70,7 @@ static HardwareSerial::hardware_t UART4_Hardware = { | |||
0xff, // No CTS pin | |||
0, // No CTS | |||
IRQ_PRIORITY, 38, 24, // IRQ, rts_low_watermark, rts_high_watermark | |||
XBARA1_OUT_LPUART4_TRG_INPUT | |||
}; | |||
HardwareSerial Serial2(&IMXRT_LPUART4, &UART4_Hardware, tx_buffer2, SERIAL2_TX_BUFFER_SIZE, | |||
rx_buffer2, SERIAL2_RX_BUFFER_SIZE); |
@@ -52,15 +52,18 @@ void serial_event_check_serial3() | |||
// Serial3 | |||
static BUFTYPE tx_buffer3[SERIAL3_TX_BUFFER_SIZE]; | |||
static BUFTYPE rx_buffer3[SERIAL3_RX_BUFFER_SIZE]; | |||
uint8_t _serialEvent3_default __attribute__((weak)) PROGMEM = 0 ; | |||
static HardwareSerial::hardware_t UART2_Hardware = { | |||
2, IRQ_LPUART2, &IRQHandler_Serial3, &serial_event_check_serial3, | |||
CCM_CCGR0, CCM_CCGR0_LPUART2(CCM_CCGR_ON), | |||
2, IRQ_LPUART2, &IRQHandler_Serial3, | |||
&serial_event_check_serial3, &_serialEvent3_default, | |||
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 | |||
}; | |||
HardwareSerial Serial3(&IMXRT_LPUART2, &UART2_Hardware,tx_buffer3, SERIAL3_TX_BUFFER_SIZE, | |||
rx_buffer3, SERIAL3_RX_BUFFER_SIZE); |
@@ -53,15 +53,18 @@ void serial_event_check_serial4() | |||
// Serial4 | |||
static BUFTYPE tx_buffer4[SERIAL4_TX_BUFFER_SIZE]; | |||
static BUFTYPE rx_buffer4[SERIAL4_RX_BUFFER_SIZE]; | |||
uint8_t _serialEvent4_default __attribute__((weak)) PROGMEM = 0 ; | |||
static HardwareSerial::hardware_t UART3_Hardware = { | |||
3, IRQ_LPUART3, &IRQHandler_Serial4, &serial_event_check_serial4, | |||
3, IRQ_LPUART3, &IRQHandler_Serial4, | |||
&serial_event_check_serial4, &_serialEvent4_default, | |||
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 | |||
}; | |||
HardwareSerial Serial4(&IMXRT_LPUART3, &UART3_Hardware, tx_buffer4, SERIAL4_TX_BUFFER_SIZE, | |||
rx_buffer4, SERIAL4_RX_BUFFER_SIZE); |
@@ -53,9 +53,11 @@ void serial_event_check_serial5() | |||
// Serial5 | |||
static BUFTYPE tx_buffer5[SERIAL5_TX_BUFFER_SIZE]; | |||
static BUFTYPE rx_buffer5[SERIAL5_RX_BUFFER_SIZE]; | |||
uint8_t _serialEvent5_default __attribute__((weak)) PROGMEM = 0 ; | |||
static HardwareSerial::hardware_t UART8_Hardware = { | |||
4, IRQ_LPUART8, &IRQHandler_Serial5, &serial_event_check_serial5, | |||
4, IRQ_LPUART8, &IRQHandler_Serial5, | |||
&serial_event_check_serial5, &_serialEvent5_default, | |||
CCM_CCGR6, CCM_CCGR6_LPUART8(CCM_CCGR_ON), | |||
#if defined(ARDUINO_TEENSY41) | |||
{{21,2, &IOMUXC_LPUART8_RX_SELECT_INPUT, 1}, {46, 2, &IOMUXC_LPUART8_RX_SELECT_INPUT, 0}}, | |||
@@ -69,6 +71,7 @@ static HardwareSerial::hardware_t UART8_Hardware = { | |||
2, // CTS | |||
#endif | |||
IRQ_PRIORITY, 38, 24, // IRQ, rts_low_watermark, rts_high_watermark | |||
XBARA1_OUT_LPUART8_TRG_INPUT | |||
}; | |||
HardwareSerial Serial5(&IMXRT_LPUART8, &UART8_Hardware, tx_buffer5, SERIAL5_TX_BUFFER_SIZE, | |||
rx_buffer5, SERIAL5_RX_BUFFER_SIZE); |
@@ -53,16 +53,18 @@ void serial_event_check_serial6() | |||
// Serial6 | |||
static BUFTYPE tx_buffer6[SERIAL6_TX_BUFFER_SIZE]; | |||
static BUFTYPE rx_buffer6[SERIAL6_RX_BUFFER_SIZE]; | |||
uint8_t _serialEvent6_default __attribute__((weak)) PROGMEM = 0 ; | |||
static HardwareSerial::hardware_t UART1_Hardware = { | |||
5, IRQ_LPUART1, &IRQHandler_Serial6, &serial_event_check_serial6, | |||
5, IRQ_LPUART1, &IRQHandler_Serial6, | |||
&serial_event_check_serial6, &_serialEvent6_default, | |||
CCM_CCGR5, CCM_CCGR5_LPUART1(CCM_CCGR_ON), | |||
{{25,2, nullptr, 0}, {0xff, 0xff, nullptr, 0}}, | |||
{{24,2, nullptr, 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_LPUART1_TRG_INPUT | |||
}; | |||
HardwareSerial Serial6(&IMXRT_LPUART1, &UART1_Hardware, tx_buffer6, SERIAL6_TX_BUFFER_SIZE, |
@@ -53,15 +53,18 @@ void serial_event_check_serial7() | |||
// Serial7 | |||
static BUFTYPE tx_buffer7[SERIAL7_TX_BUFFER_SIZE]; | |||
static BUFTYPE rx_buffer7[SERIAL7_RX_BUFFER_SIZE]; | |||
uint8_t _serialEvent7_default __attribute__((weak)) PROGMEM = 0 ; | |||
static HardwareSerial::hardware_t UART7_Hardware = { | |||
6, IRQ_LPUART7, &IRQHandler_Serial7, &serial_event_check_serial7, | |||
6, IRQ_LPUART7, &IRQHandler_Serial7, | |||
&serial_event_check_serial7, &_serialEvent7_default, | |||
CCM_CCGR5, CCM_CCGR5_LPUART7(CCM_CCGR_ON), | |||
{{28,2, &IOMUXC_LPUART7_RX_SELECT_INPUT, 1}, {0xff, 0xff, nullptr, 0}}, | |||
{{29,2, &IOMUXC_LPUART7_TX_SELECT_INPUT, 1}, {0xff, 0xff, nullptr, 0}}, | |||
0xff, // No CTS pin | |||
0, // No CTS | |||
IRQ_PRIORITY, 38, 24, // IRQ, rts_low_watermark, rts_high_watermark | |||
XBARA1_OUT_LPUART7_TRG_INPUT | |||
}; | |||
HardwareSerial Serial7(&IMXRT_LPUART7, &UART7_Hardware, tx_buffer7, SERIAL7_TX_BUFFER_SIZE, | |||
rx_buffer7, SERIAL7_RX_BUFFER_SIZE); |
@@ -55,9 +55,11 @@ void serial_event_check_serial8() | |||
// Serial8 | |||
static BUFTYPE tx_buffer8[SERIAL8_TX_BUFFER_SIZE]; | |||
static BUFTYPE rx_buffer8[SERIAL8_RX_BUFFER_SIZE]; | |||
uint8_t _serialEvent8_default __attribute__((weak)) PROGMEM = 0 ; | |||
static HardwareSerial::hardware_t UART5_Hardware = { | |||
7, IRQ_LPUART5, &IRQHandler_Serial8, &serial_event_check_serial8, | |||
7, IRQ_LPUART5, &IRQHandler_Serial8, | |||
&serial_event_check_serial8, &_serialEvent8_default, | |||
CCM_CCGR3, CCM_CCGR3_LPUART5(CCM_CCGR_ON), | |||
{{34,1, &IOMUXC_LPUART5_RX_SELECT_INPUT, 1}, {48, 2, &IOMUXC_LPUART5_RX_SELECT_INPUT, 0}}, | |||
{{35,1, &IOMUXC_LPUART5_TX_SELECT_INPUT, 1}, {0xff, 0xff, nullptr, 0}}, | |||
@@ -65,6 +67,7 @@ static HardwareSerial::hardware_t UART5_Hardware = { | |||
50, // CTS pin | |||
2, // CTS | |||
IRQ_PRIORITY, 38, 24, // IRQ, rts_low_watermark, rts_high_watermark | |||
XBARA1_OUT_LPUART5_TRG_INPUT | |||
}; | |||
HardwareSerial Serial8(&IMXRT_LPUART5, &UART5_Hardware, tx_buffer8, SERIAL8_TX_BUFFER_SIZE, | |||
rx_buffer8, SERIAL8_RX_BUFFER_SIZE); |
@@ -0,0 +1,6 @@ | |||
#include <Arduino.h> | |||
void serialEvent() __attribute__((weak)); | |||
void serialEvent() { | |||
} | |||
uint8_t _serialEvent_default PROGMEM = 1; |
@@ -0,0 +1,6 @@ | |||
#include <Arduino.h> | |||
#include "HardwareSerial.h" | |||
void serialEvent1() __attribute__((weak)); | |||
void serialEvent1() {} // No use calling this so disable if called... | |||
uint8_t _serialEvent1_default PROGMEM = 1; |
@@ -0,0 +1,6 @@ | |||
#include <Arduino.h> | |||
#include "HardwareSerial.h" | |||
void serialEvent2() __attribute__((weak)); | |||
void serialEvent2() {} // No use calling this so disable if called... | |||
uint8_t _serialEvent2_default PROGMEM = 1; |
@@ -0,0 +1,6 @@ | |||
#include <Arduino.h> | |||
#include "HardwareSerial.h" | |||
void serialEvent3() __attribute__((weak)); | |||
void serialEvent3() {} // No use calling this so disable if called... | |||
uint8_t _serialEvent3_default PROGMEM = 1; |
@@ -0,0 +1,6 @@ | |||
#include <Arduino.h> | |||
#include "HardwareSerial.h" | |||
void serialEvent4() __attribute__((weak)); | |||
void serialEvent4() {} // No use calling this so disable if called... | |||
uint8_t _serialEvent4_default PROGMEM = 1; |
@@ -0,0 +1,6 @@ | |||
#include <Arduino.h> | |||
#include "HardwareSerial.h" | |||
void serialEvent5() __attribute__((weak)); | |||
void serialEvent5() {} // No use calling this so disable if called... | |||
uint8_t _serialEvent5_default PROGMEM = 1; |
@@ -0,0 +1,6 @@ | |||
#include <Arduino.h> | |||
#include "HardwareSerial.h" | |||
void serialEvent6() __attribute__((weak)); | |||
void serialEvent6() {} // No use calling this so disable if called... | |||
uint8_t _serialEvent6_default PROGMEM = 1; |
@@ -0,0 +1,6 @@ | |||
#include <Arduino.h> | |||
#include "HardwareSerial.h" | |||
void serialEvent7() __attribute__((weak)); | |||
void serialEvent7() {} // No use calling this so disable if called... | |||
uint8_t _serialEvent7_default PROGMEM = 1; |
@@ -0,0 +1,6 @@ | |||
#include <Arduino.h> | |||
#include "HardwareSerial.h" | |||
void serialEvent8() __attribute__((weak)); | |||
void serialEvent8() {} // No use calling this so disable if called... | |||
uint8_t _serialEvent8_default PROGMEM = 1; |
@@ -96,5 +96,4 @@ usb_seremu_class Serial; | |||
#endif | |||
#endif // F_CPU | |||
void serialEvent() __attribute__((weak)); | |||
void serialEvent() {yield_active_check_flags &= ~YIELD_CHECK_USB_SERIAL;} | |||
@@ -31,9 +31,9 @@ | |||
#include <Arduino.h> | |||
#include "EventResponder.h" | |||
extern uint8_t usb_enable_serial_event_processing; // from usb_inst.cpp | |||
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL; // default to check USB. | |||
extern const uint8_t _serialEvent_default; | |||
void yield(void) __attribute__ ((weak)); | |||
void yield(void) | |||
{ | |||
@@ -44,7 +44,10 @@ void yield(void) | |||
// USB Serail - Add hack to minimize impact... | |||
if ((yield_active_check_flags & YIELD_CHECK_USB_SERIAL) && Serial.available()) serialEvent(); | |||
if (yield_active_check_flags & YIELD_CHECK_USB_SERIAL) { | |||
if (Serial.available()) serialEvent(); | |||
if (_serialEvent_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIAL; | |||
} | |||
// Current workaround until integrate with EventResponder. | |||
if (yield_active_check_flags & YIELD_CHECK_HARDWARE_SERIAL) HardwareSerial::processSerialEvents(); |