Skip to content

Commit

Permalink
HAL_ChibiOS: scale RTS threshold to make software CTS more effective
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge authored and peterbarker committed Jun 27, 2024
1 parent ebc4ee9 commit 34815f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libraries/AP_HAL_ChibiOS/UARTDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_HAL_ChibiOS/UARTDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class ChibiOS::UARTDriver : public AP_HAL::UARTDriver {
#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;
Expand Down

0 comments on commit 34815f9

Please sign in to comment.