2018-01-17 15:31:11 -04:00
|
|
|
/*
|
|
|
|
* This file is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2019-01-08 22:50:11 -04:00
|
|
|
*
|
2018-01-17 15:31:11 -04:00
|
|
|
* Code by Andrew Tridgell and Siddharth Bharat Purohit
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "AP_RCProtocol.h"
|
|
|
|
|
2019-01-08 22:50:11 -04:00
|
|
|
class AP_RCProtocol_Backend {
|
2018-01-17 15:31:11 -04:00
|
|
|
friend class AP_RCProtcol;
|
|
|
|
|
|
|
|
public:
|
|
|
|
AP_RCProtocol_Backend(AP_RCProtocol &_frontend);
|
2019-01-08 22:50:11 -04:00
|
|
|
virtual ~AP_RCProtocol_Backend() {}
|
|
|
|
virtual void process_pulse(uint32_t width_s0, uint32_t width_s1) {}
|
|
|
|
virtual void process_byte(uint8_t byte, uint32_t baudrate) {}
|
2018-01-17 15:31:11 -04:00
|
|
|
uint16_t read(uint8_t chan);
|
|
|
|
bool new_input();
|
|
|
|
uint8_t num_channels();
|
2018-01-18 17:40:07 -04:00
|
|
|
|
2018-04-10 03:14:54 -03:00
|
|
|
// support for receivers that have FC initiated bind support
|
|
|
|
virtual void start_bind(void) {}
|
|
|
|
|
|
|
|
// allow for backends that need regular polling
|
|
|
|
virtual void update(void) {}
|
2019-01-08 22:50:11 -04:00
|
|
|
enum {
|
|
|
|
PARSE_TYPE_SIGREAD,
|
|
|
|
PARSE_TYPE_SERIAL
|
|
|
|
};
|
|
|
|
|
|
|
|
// get number of frames, ignoring failsafe
|
|
|
|
uint32_t get_rc_frame_count(void) const {
|
|
|
|
return rc_frame_count;
|
|
|
|
}
|
2018-04-10 03:14:54 -03:00
|
|
|
|
2019-01-08 22:50:11 -04:00
|
|
|
// get number of frames, honoring failsafe
|
|
|
|
uint32_t get_rc_input_count(void) const {
|
|
|
|
return rc_input_count;
|
|
|
|
}
|
|
|
|
|
2018-01-17 15:31:11 -04:00
|
|
|
protected:
|
2018-01-18 17:40:07 -04:00
|
|
|
void add_input(uint8_t num_channels, uint16_t *values, bool in_failsafe);
|
2019-01-08 22:50:11 -04:00
|
|
|
|
2018-01-18 17:40:07 -04:00
|
|
|
private:
|
2018-01-17 15:31:11 -04:00
|
|
|
AP_RCProtocol &frontend;
|
2019-01-08 22:50:11 -04:00
|
|
|
uint32_t rc_input_count;
|
|
|
|
uint32_t last_rc_input_count;
|
|
|
|
uint32_t rc_frame_count;
|
2018-01-17 15:31:11 -04:00
|
|
|
|
2018-01-18 17:40:07 -04:00
|
|
|
uint16_t _pwm_values[MAX_RCIN_CHANNELS];
|
2018-01-17 15:31:11 -04:00
|
|
|
uint8_t _num_channels;
|
2018-01-18 17:40:07 -04:00
|
|
|
};
|