LCOV - code coverage report
Current view: top level - AP_RCProtocol - AP_RCProtocol_PPMSum.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 18 0.0 %
Date: 2026-09-09 11:02:08 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*
       2             :  * This file is free software: you can redistribute it and/or modify it
       3             :  * under the terms of the GNU General Public License as published by the
       4             :  * Free Software Foundation, either version 3 of the License, or
       5             :  * (at your option) any later version.
       6             :  *
       7             :  * This file is distributed in the hope that it will be useful, but
       8             :  * WITHOUT ANY WARRANTY; without even the implied warranty of
       9             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      10             :  * See the GNU General Public License for more details.
      11             :  *
      12             :  * You should have received a copy of the GNU General Public License along
      13             :  * with this program.  If not, see <http://www.gnu.org/licenses/>.
      14             :  *
      15             :  * Code by Andrew Tridgell and Siddharth Bharat Purohit
      16             :  */
      17             : 
      18             : #include "AP_RCProtocol_PPMSum.h"
      19             : 
      20             : #if AP_RCPROTOCOL_PPMSUM_ENABLED
      21             : 
      22             : /*
      23             :   process a PPM-sum pulse of the given width
      24             :  */
      25           0 : void AP_RCProtocol_PPMSum::process_pulse(uint32_t width_s0, uint32_t width_s1)
      26             : {
      27           0 :     if (width_s0 == 0 || width_s1 == 0) {
      28             :         //invalid data: reset frame
      29           0 :         ppm_state._channel_counter = -1;
      30           0 :         return;
      31             :     }
      32           0 :     uint32_t width_usec = width_s0 + width_s1;
      33           0 :     if (width_usec >= 2700) {
      34             :         // a long pulse indicates the end of a frame. Reset the
      35             :         // channel counter so next pulse is channel 0
      36           0 :         if (ppm_state._channel_counter >= MIN_RCIN_CHANNELS) {
      37           0 :             add_input(ppm_state._channel_counter, ppm_state._pulse_capt, false);
      38             :         }
      39           0 :         ppm_state._channel_counter = 0;
      40           0 :         return;
      41             :     }
      42           0 :     if (ppm_state._channel_counter == -1) {
      43             :         // we are not synchronised
      44           0 :         return;
      45             :     }
      46             : 
      47             :     /*
      48             :       we limit inputs to between 700usec and 2300usec. This allows us
      49             :       to decode SBUS on the same pin, as SBUS will have a maximum
      50             :       pulse width of 100usec
      51             :      */
      52           0 :     if (width_usec > 700 && width_usec < 2300) {
      53             :         // take a reading for the current channel
      54             :         // buffer these
      55           0 :         ppm_state._pulse_capt[ppm_state._channel_counter] = width_usec;
      56             : 
      57             :         // move to next channel
      58           0 :         ppm_state._channel_counter++;
      59             :     }
      60             : 
      61             :     // if we have reached the maximum supported channels then
      62             :     // mark as unsynchronised, so we wait for a wide pulse
      63           0 :     if (ppm_state._channel_counter >= MAX_RCIN_CHANNELS) {
      64           0 :         add_input(ppm_state._channel_counter, ppm_state._pulse_capt, false);
      65           0 :         ppm_state._channel_counter = -1;
      66             :     }
      67             : }
      68             : 
      69             : #endif  // AP_RCPROTOCOL_PPMSUM_ENABLED

Generated by: LCOV version 1.14