From 1faefe4dc2d70ada92ddf1e2bf9418bcfd194aa4 Mon Sep 17 00:00:00 2001 From: Volkalex28 Date: Sun, 16 Jun 2024 04:02:46 +0300 Subject: [PATCH] Fix panics for UART - Default rx/tx_buffer_size in uart_driver_install - Make not covered ResetReason as Unknown --- src/reset.rs | 3 +-- src/uart.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/reset.rs b/src/reset.rs index b02c6030fa7..40599aa1003 100644 --- a/src/reset.rs +++ b/src/reset.rs @@ -40,11 +40,10 @@ impl From for ResetReason { esp_reset_reason_t_ESP_RST_PANIC => Self::Panic, esp_reset_reason_t_ESP_RST_INT_WDT => Self::InterruptWatchdog, esp_reset_reason_t_ESP_RST_POWERON => Self::PowerOn, - esp_reset_reason_t_ESP_RST_UNKNOWN => Self::Unknown, esp_reset_reason_t_ESP_RST_BROWNOUT => Self::Brownout, esp_reset_reason_t_ESP_RST_TASK_WDT => Self::TaskWatchdog, esp_reset_reason_t_ESP_RST_DEEPSLEEP => Self::DeepSleep, - _ => unreachable!(), + _ => Self::Unknown, } } } diff --git a/src/uart.rs b/src/uart.rs index b9c29ea89c4..f427b0a3f02 100644 --- a/src/uart.rs +++ b/src/uart.rs @@ -1899,15 +1899,15 @@ fn new_common( uart_driver_install( UART::port(), if rx.is_some() { - config.rx_fifo_size as _ + config.rx_fifo_size } else { - 0 - }, + UART_FIFO_SIZE * 2 + } as _, if tx.is_some() { - config.tx_fifo_size as _ + config.tx_fifo_size } else { - 0 - }, + UART_FIFO_SIZE * 2 + } as _, config.queue_size as _, queue.map(|q| q as *mut _).unwrap_or(ptr::null_mut()), InterruptType::to_native(config.intr_flags) as i32,