LCOV - code coverage report
Current view: top level - AP_HAL_Linux - RCInput.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 6 0.0 %
Date: 2026-09-09 11:02:08 Functions: 0 4 0.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <atomic>
       4             : 
       5             : #include "AP_HAL_Linux.h"
       6             : 
       7             : #ifndef AP_RCPROTOCOL_ZYNQ_ENABLED
       8             : #define AP_RCPROTOCOL_ZYNQ_ENABLED 0
       9             : #endif  // AP_RCPROTOCOL_ZYNQ_ENABLED
      10             : 
      11             : #define LINUX_RC_INPUT_NUM_CHANNELS 16
      12             : 
      13             : namespace Linux {
      14             : 
      15             : class RCInput : public AP_HAL::RCInput {
      16             : public:
      17             :     RCInput();
      18             : 
      19           0 :     static RCInput *from(AP_HAL::RCInput *rcinput) {
      20           0 :         return static_cast<RCInput*>(rcinput);
      21             :     }
      22             : 
      23             :     virtual void init() override;
      24             :     bool new_input() override;
      25             :     uint8_t num_channels() override;
      26             :     void set_num_channels(uint8_t num);
      27             :     uint16_t read(uint8_t ch) override;
      28             :     uint8_t read(uint16_t* periods, uint8_t len) override;
      29             : 
      30           0 :     int16_t get_rssi(void) override {
      31           0 :         return _rssi;
      32             :     }
      33             : 
      34           0 :     const char *protocol() const override { return "Unknown"; }
      35             : 
      36             :     // default empty _timer_tick, this is overridden by board
      37             :     // specific implementations
      38           0 :     virtual void _timer_tick() {}
      39             : 
      40             : protected:
      41             :     void _process_rc_pulse(uint16_t width_s0, uint16_t width_s1);
      42             :     void _update_periods(uint16_t *periods, uint8_t len);
      43             : 
      44             :     std::atomic<unsigned int> rc_input_count;
      45             :     std::atomic<unsigned int> last_rc_input_count;
      46             : 
      47             :     uint16_t _pwm_values[LINUX_RC_INPUT_NUM_CHANNELS];
      48             :     uint8_t  _num_channels;
      49             : 
      50             :     void _process_ppmsum_pulse(uint16_t width);
      51             :     void _process_sbus_pulse(uint16_t width_s0, uint16_t width_s1);
      52             :     void _process_dsm_pulse(uint16_t width_s0, uint16_t width_s1);
      53             :     void _process_pwm_pulse(uint16_t channel, uint16_t width_s0, uint16_t width_s1);
      54             : 
      55             :     // state of ppm decoder
      56             :     struct {
      57             :         int8_t _channel_counter;
      58             :         uint16_t _pulse_capt[LINUX_RC_INPUT_NUM_CHANNELS];
      59             :     } ppm_state;
      60             : 
      61             :     // state of SBUS bit decoder
      62             :     struct {
      63             :         uint16_t bytes[25]; // including start bit, parity and stop bits
      64             :         uint16_t bit_ofs;
      65             :     } sbus_state;
      66             : 
      67             :     // state of DSM decoder
      68             :     struct {
      69             :         uint16_t bytes[16]; // including start bit and stop bit
      70             :         uint16_t bit_ofs;
      71             :     } dsm_state;
      72             : 
      73             :     int16_t _rssi = -1;
      74             : };
      75             : 
      76             : }

Generated by: LCOV version 1.14