APM:Libraries
RCInput.h
Go to the documentation of this file.
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 #pragma once
18 
19 #include "AP_HAL_ChibiOS.h"
20 #include "Semaphores.h"
21 
22 #if HAL_RCINPUT_WITH_AP_RADIO
23 #include <AP_Radio/AP_Radio.h>
24 #endif
25 
26 #if HAL_USE_ICU == TRUE
27 #include "SoftSigReader.h"
29 #endif
30 
31 #if HAL_USE_EICU == TRUE
32 #include "SoftSigReaderInt.h"
34 #endif
35 
36 
37 #ifndef RC_INPUT_MAX_CHANNELS
38 #define RC_INPUT_MAX_CHANNELS 18
39 #endif
40 
42 public:
43  void init() override;
44  bool new_input() override;
45  uint8_t num_channels() override;
46  uint16_t read(uint8_t ch) override;
47  uint8_t read(uint16_t* periods, uint8_t len) override;
48 
49  int16_t get_rssi(void) override {
50  return _rssi;
51  }
52 
53 
54  bool set_override(uint8_t channel, int16_t override) override;
55  void clear_overrides() override;
56 
57  void _timer_tick(void);
58  bool rc_bind(int dsmMode) override;
59 
60 private:
61  /* override state */
64 
65  uint64_t _last_read;
67  uint8_t _num_channels;
69  int16_t _rssi = -1;
71  bool _init;
72 #if HAL_RCINPUT_WITH_AP_RADIO
73  bool _radio_init;
74  AP_Radio *radio;
75  uint32_t last_radio_us;
76 #endif
77 
78 #if HAL_USE_ICU == TRUE
81 #endif
82 
83 #if HAL_USE_EICU == TRUE
86 #endif
87 
88 #if HAL_WITH_IO_MCU
89  uint32_t last_iomcu_us;
90 #endif
91 };
ChibiOS::SoftSigReader sig_reader
Definition: RCInput.h:79
void _timer_tick(void)
Definition: RCInput.cpp:157
bool _override_valid
Definition: RCInput.h:66
uint64_t _last_read
Definition: RCInput.h:65
void init() override
Definition: RCInput.cpp:31
uint16_t _override[RC_INPUT_MAX_CHANNELS]
Definition: RCInput.h:62
uint16_t _rc_values[RC_INPUT_MAX_CHANNELS]
Definition: RCInput.h:63
bool rc_bind(int dsmMode) override
Definition: RCInput.cpp:210
int16_t get_rssi(void) override
Definition: RCInput.h:49
bool new_input() override
Definition: RCInput.cpp:47
bool set_override(uint8_t channel, int16_t override) override
Definition: RCInput.cpp:129
uint8_t num_channels() override
Definition: RCInput.cpp:77
void clear_overrides() override
Definition: RCInput.cpp:149
uint8_t _num_channels
Definition: RCInput.h:67
Semaphore rcin_mutex
Definition: RCInput.h:68
uint16_t read(uint8_t ch) override
Definition: RCInput.cpp:85
int16_t _rssi
Definition: RCInput.h:69
ChibiOS::SoftSigReaderInt sig_reader
Definition: RCInput.h:84
#define RC_INPUT_MAX_CHANNELS
Definition: RCInput.h:38
AP_RCProtocol rcin_prot
Definition: RCInput.h:80
uint32_t _rcin_timestamp_last_signal
Definition: RCInput.h:70