HAL_ChibiOS: scale RTS threshold to make software CTS more effective

This commit is contained in:
Andrew Tridgell 2024-03-17 16:38:03 +11:00 committed by Peter Barker
parent ebc4ee99a9
commit 34815f9fb0
2 changed files with 4 additions and 2 deletions

View File

@ -299,6 +299,7 @@ void UARTDriver::_begin(uint32_t b, uint16_t rxS, uint16_t txS)
_rx_initialised = false;
_readbuf.set_size_best(rxS);
}
_rts_threshold = _readbuf.get_size() / 16U;
bool clear_buffers = false;
if (b != 0) {
@ -1414,10 +1415,10 @@ __RAMFUNC__ void UARTDriver::update_rts_line(void)
return;
}
uint16_t space = _readbuf.space();
if (_rts_is_active && space < 16) {
if (_rts_is_active && space < _rts_threshold) {
_rts_is_active = false;
palSetLine(arts_line);
} else if (!_rts_is_active && space > 32) {
} else if (!_rts_is_active && space > _rts_threshold+16) {
_rts_is_active = true;
palClearLine(arts_line);
}

View File

@ -182,6 +182,7 @@ private:
#endif
ByteBuffer _readbuf{0};
ByteBuffer _writebuf{0};
uint32_t _rts_threshold;
HAL_Semaphore _write_mutex;
#ifndef HAL_UART_NODMA
const stm32_dma_stream_t* rxdma;