MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / _rx_timer_tick

Method _rx_timer_tick

libraries/AP_HAL_ChibiOS/UARTDriver.cpp:1111–1193  ·  view source on GitHub ↗

push any pending bytes to/from the serial port. This is called at 1kHz in the timer thread. Doing it this way reduces the system call overhead in the main task enormously. */

Source from the content-addressed store, hash-verified

1109 overhead in the main task enormously.
1110 */
1111void UARTDriver::_rx_timer_tick(void)
1112{
1113 if (!_rx_initialised || half_duplex) {
1114 return;
1115 }
1116
1117 WITH_SEMAPHORE(rx_sem);
1118
1119#if HAL_UART_STATS_ENABLED && CH_CFG_USE_EVENTS == TRUE
1120 if (!sdef.is_usb) {
1121 const auto err_flags = chEvtGetAndClearFlags(&err_listener);
1122 // count the number of errors
1123 if (err_flags & SD_FRAMING_ERROR) {
1124 _rx_stats_framing_errors++;
1125 }
1126 if (err_flags & SD_OVERRUN_ERROR) {
1127 _rx_stats_overrun_errors++;
1128 }
1129 if (err_flags & SD_NOISE_ERROR) {
1130 _rx_stats_noise_errors++;
1131 }
1132 }
1133#endif
1134
1135#ifndef HAL_UART_NODMA
1136 if (rx_dma_enabled && rxdma) {
1137 chSysLock();
1138 //Check if DMA is enabled
1139 //if not, it might be because the DMA interrupt was silenced
1140 //let's handle that here so that we can continue receiving
1141#if defined(STM32F3) || defined(STM32G4) || defined(STM32L4) || defined(STM32L4PLUS)
1142 bool enabled = (rxdma->channel->CCR & STM32_DMA_CR_EN);
1143#else
1144 bool enabled = (rxdma->stream->CR & STM32_DMA_CR_EN);
1145#endif
1146 if (!enabled) {
1147 uint8_t len = RX_BOUNCE_BUFSIZE - dmaStreamGetTransactionSize(rxdma);
1148 if (len != 0) {
1149 _readbuf.write(rx_bounce_buf[rx_bounce_idx], len);
1150 _rx_stats_bytes += len;
1151
1152 receive_timestamp_update();
1153 if (_rts_is_active) {
1154 update_rts_line();
1155 }
1156 }
1157 // DMA disabled by idle interrupt never got a chance to be handled
1158 // we will enable it here
1159 dmaStreamDisable(rxdma);
1160 dma_rx_enable();
1161 }
1162 chSysUnlock();
1163 }
1164#endif
1165
1166 // don't try IO on a disconnected USB port
1167 if (sdef.is_usb) {
1168#ifdef HAVE_USB_SERIAL

Callers 1

uart_rx_threadMethod · 0.80

Calls 4

set_usb_connectedMethod · 0.80
get_indexMethod · 0.80
writeMethod · 0.45
availableMethod · 0.45

Tested by

no test coverage detected