[uart] update set_rx_full_threshold_ms

- Change to int32_t to prevent overflow
- dont use set_rx_timeout
This commit is contained in:
brambo123 2025-01-26 10:32:55 +01:00
parent 6d50dca0bc
commit 7480f92879

View File

@ -24,10 +24,9 @@ void UARTComponent::set_rx_full_threshold_ms(uint8_t time) {
uint8_t bytelength = this->data_bits_ + this->stop_bits_ + 1;
if (this->parity_ != UARTParityOptions::UART_CONFIG_PARITY_NONE)
bytelength += 1;
uint8_t val = (this->baud_rate_ / (bytelength * 1000 / time)) - 1;
if (val <= 1) {
int32_t val = (this->baud_rate_ / (bytelength * 1000 / time)) - 1;
if (val < 1) {
val = 1;
this->set_rx_timeout(0);
} else if (val > 120) {
val = 120;
}