64 setup_pin_if_needed(this->
rx_pin_);
66 setup_pin_if_needed(this->
tx_pin_);
71 constexpr uint32_t valid_tx_uart_0 = __bitset({0, 12, 16, 28});
72 constexpr uint32_t valid_tx_uart_1 = __bitset({4, 8, 20, 24});
74 constexpr uint32_t valid_rx_uart_0 = __bitset({1, 13, 17, 29});
75 constexpr uint32_t valid_rx_uart_1 = __bitset({5, 9, 21, 25});
82 ESP_LOGD(TAG,
"An inverted TX pin %u can only be used with SerialPIO", this->
tx_pin_->
get_pin());
86 }
else if (((1 << this->
tx_pin_->
get_pin()) & valid_tx_uart_1) != 0) {
89 ESP_LOGD(TAG,
"TX pin %u can only be used with SerialPIO", this->
tx_pin_->
get_pin());
96 ESP_LOGD(TAG,
"An inverted RX pin %u can only be used with SerialPIO", this->
rx_pin_->
get_pin());
100 }
else if (((1 << this->
rx_pin_->
get_pin()) & valid_rx_uart_1) != 0) {
103 ESP_LOGD(TAG,
"RX pin %u can only be used with SerialPIO", this->
rx_pin_->
get_pin());
114 const bool tx_configured = (this->
tx_pin_ !=
nullptr);
115 const bool rx_configured = (this->
rx_pin_ !=
nullptr);
117 if (tx_configured && rx_configured) {
119 if (tx_hw != -1 && rx_hw != -1 && tx_hw == rx_hw) {
122 }
else if (tx_configured) {
124 }
else if (rx_configured) {
130 ESP_LOGD(TAG,
"Using SerialPIO as UART%d is taken by the logger", hw_uart);
136 ESP_LOGV(TAG,
"Using SerialPIO");
142 gpio_set_outover(tx, GPIO_OVERRIDE_INVERT);
144 gpio_set_inover(rx, GPIO_OVERRIDE_INVERT);
147 ESP_LOGV(TAG,
"Using Hardware Serial");