fix(uart): allow same pin for tx and rx in uart_set_pin

Also add IO reserve to uart driver

Closes https://github.com/espressif/esp-idf/issues/14787
This commit is contained in:
Song Ruo Jing
2024-11-07 11:51:16 +08:00
parent bb9a2658a9
commit e8f0299557
4 changed files with 100 additions and 30 deletions
+2 -2
View File
@@ -321,8 +321,8 @@ static void twai_configure_gpio(twai_obj_t *p_obj)
uint64_t busy_mask = esp_gpio_reserve(gpio_mask);
uint64_t conflict_mask = busy_mask & gpio_mask;
for (; conflict_mask > 0;) {
uint8_t pos = __builtin_ctz(conflict_mask);
conflict_mask &= ~(1 << pos);
uint8_t pos = __builtin_ctzll(conflict_mask);
conflict_mask &= ~(1ULL << pos);
ESP_LOGW(TWAI_TAG, "GPIO %d is not usable, maybe used by others", pos);
}
}