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/>.
|
|
|
|
*
|
|
|
|
* Code by Andrew Tridgell and Siddharth Bharat Purohit
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AP_HAL/AP_HAL.h>
|
|
|
|
#include <AP_Common/AP_Common.h>
|
|
|
|
|
|
|
|
#define MAX_RCIN_CHANNELS 16
|
|
|
|
#define MIN_RCIN_CHANNELS 5
|
|
|
|
|
|
|
|
class AP_RCProtocol_Backend;
|
|
|
|
class AP_RCProtocol {
|
|
|
|
public:
|
|
|
|
enum rcprotocol_t{
|
|
|
|
PPM = 0,
|
|
|
|
SBUS,
|
2018-05-23 19:00:16 -03:00
|
|
|
SBUS_NI,
|
2018-01-17 15:31:11 -04:00
|
|
|
DSM,
|
|
|
|
NONE //last enum always is None
|
|
|
|
};
|
|
|
|
void init();
|
|
|
|
void process_pulse(uint32_t width_s0, uint32_t width_s1);
|
|
|
|
enum rcprotocol_t protocol_detected() { return _detected_protocol; }
|
|
|
|
uint8_t num_channels();
|
|
|
|
uint16_t read(uint8_t chan);
|
|
|
|
bool new_input();
|
2018-04-10 03:14:54 -03:00
|
|
|
void start_bind(void);
|
|
|
|
|
2018-01-17 15:31:11 -04:00
|
|
|
private:
|
|
|
|
enum rcprotocol_t _detected_protocol = NONE;
|
|
|
|
AP_RCProtocol_Backend *backend[NONE];
|
|
|
|
bool _new_input = false;
|
2018-01-17 19:12:16 -04:00
|
|
|
uint32_t _last_input_ms;
|
2018-01-17 15:31:11 -04:00
|
|
|
};
|
|
|
|
|
2018-01-17 19:12:16 -04:00
|
|
|
#include "AP_RCProtocol_Backend.h"
|