| 125 | } |
| 126 | |
| 127 | void RCInput::_timer_tick(void) |
| 128 | { |
| 129 | if (!_init) { |
| 130 | return; |
| 131 | } |
| 132 | #ifndef HAL_NO_UARTDRIVER |
| 133 | const char *rc_protocol = nullptr; |
| 134 | RCSource source = last_source; |
| 135 | #endif |
| 136 | |
| 137 | #if AP_RCPROTOCOL_ENABLED |
| 138 | AP_RCProtocol &rcprot = AP::RC(); |
| 139 | |
| 140 | #if HAL_USE_ICU == TRUE |
| 141 | if (pulse_input_enabled) { |
| 142 | const uint32_t *p; |
| 143 | uint32_t n; |
| 144 | while ((p = (const uint32_t *)sig_reader.sigbuf.readptr(n)) != nullptr) { |
| 145 | rcprot.process_pulse_list(p, n*2, sig_reader.need_swap); |
| 146 | sig_reader.sigbuf.advance(n); |
| 147 | } |
| 148 | } |
| 149 | #endif |
| 150 | |
| 151 | #if HAL_USE_EICU == TRUE |
| 152 | if (pulse_input_enabled) { |
| 153 | uint32_t width_s0, width_s1; |
| 154 | while(sig_reader.read(width_s0, width_s1)) { |
| 155 | rcprot.process_pulse(width_s0, width_s1); |
| 156 | } |
| 157 | } |
| 158 | #endif |
| 159 | |
| 160 | #endif // AP_RCPROTOCOL_ENABLED |
| 161 | |
| 162 | #if HAL_WITH_IO_MCU |
| 163 | uint32_t now = AP_HAL::millis(); |
| 164 | const bool have_iocmu_rc = (_rcin_last_iomcu_ms != 0 && now - _rcin_last_iomcu_ms < 400); |
| 165 | if (!have_iocmu_rc) { |
| 166 | _rcin_last_iomcu_ms = 0; |
| 167 | } |
| 168 | #elif AP_RCPROTOCOL_ENABLED |
| 169 | const bool have_iocmu_rc = false; |
| 170 | #endif |
| 171 | |
| 172 | #if AP_RCPROTOCOL_ENABLED |
| 173 | if (rcprot.new_input() && !have_iocmu_rc) { |
| 174 | WITH_SEMAPHORE(rcin_mutex); |
| 175 | _rcin_timestamp_last_signal = AP_HAL::micros(); |
| 176 | _num_channels = rcprot.num_channels(); |
| 177 | _num_channels = MIN(_num_channels, RC_INPUT_MAX_CHANNELS); |
| 178 | rcprot.read(_rc_values, _num_channels); |
| 179 | _rssi = rcprot.get_RSSI(); |
| 180 | _rx_link_quality = rcprot.get_rx_link_quality(); |
| 181 | #ifndef HAL_NO_UARTDRIVER |
| 182 | rc_protocol = rcprot.protocol_name(); |
| 183 | source = rcprot.using_uart() ? RCSource::RCPROT_BYTES : RCSource::RCPROT_PULSES; |
| 184 | #endif |
no test coverage detected