2016-02-17 21:25:26 -04:00
|
|
|
#pragma once
|
2013-01-03 06:30:35 -04:00
|
|
|
|
2015-08-11 03:28:43 -03:00
|
|
|
#include "AP_HAL_PX4.h"
|
2013-01-26 21:51:34 -04:00
|
|
|
#include <drivers/drv_rc_input.h>
|
|
|
|
#include <systemlib/perf_counter.h>
|
2013-12-31 07:24:55 -04:00
|
|
|
#include <pthread.h>
|
2017-03-09 19:41:06 -04:00
|
|
|
#include <AP_Radio/AP_Radio.h>
|
2013-01-03 06:30:35 -04:00
|
|
|
|
2015-11-25 19:10:32 -04:00
|
|
|
|
|
|
|
#ifndef RC_INPUT_MAX_CHANNELS
|
2018-04-26 20:15:08 -03:00
|
|
|
#define RC_INPUT_MAX_CHANNELS 18u
|
2015-11-25 19:10:32 -04:00
|
|
|
#endif
|
|
|
|
|
2013-01-03 06:30:35 -04:00
|
|
|
class PX4::PX4RCInput : public AP_HAL::RCInput {
|
|
|
|
public:
|
2016-11-02 23:16:16 -03:00
|
|
|
void init() override;
|
|
|
|
bool new_input() override;
|
|
|
|
uint8_t num_channels() override;
|
|
|
|
uint16_t read(uint8_t ch) override;
|
|
|
|
uint8_t read(uint16_t* periods, uint8_t len) override;
|
2013-01-03 06:30:35 -04:00
|
|
|
|
2017-06-20 00:12:58 -03:00
|
|
|
int16_t get_rssi(void) override {
|
|
|
|
return _rssi;
|
|
|
|
}
|
|
|
|
|
2013-01-26 21:51:34 -04:00
|
|
|
void _timer_tick(void);
|
|
|
|
|
2016-11-02 23:16:16 -03:00
|
|
|
bool rc_bind(int dsmMode) override;
|
2015-06-10 03:45:26 -03:00
|
|
|
|
2013-01-03 06:30:35 -04:00
|
|
|
private:
|
|
|
|
/* override state */
|
2013-01-26 21:51:34 -04:00
|
|
|
struct rc_input_values _rcin;
|
|
|
|
int _rc_sub;
|
2013-01-03 17:31:23 -04:00
|
|
|
uint64_t _last_read;
|
2013-01-26 21:51:34 -04:00
|
|
|
perf_counter_t _perf_rcin;
|
2013-12-31 07:24:55 -04:00
|
|
|
pthread_mutex_t rcin_mutex;
|
2017-06-20 00:12:58 -03:00
|
|
|
int16_t _rssi = -1;
|
2017-05-28 23:11:51 -03:00
|
|
|
|
|
|
|
uint8_t last_input_source = input_rc_s::RC_INPUT_SOURCE_UNKNOWN;
|
|
|
|
const char *input_source_name(uint8_t id) const;
|
2017-03-09 19:41:06 -04:00
|
|
|
|
2018-03-11 11:48:24 -03:00
|
|
|
#if HAL_RCINPUT_WITH_AP_RADIO
|
2017-03-09 19:41:06 -04:00
|
|
|
AP_Radio *radio;
|
|
|
|
uint32_t last_radio_us;
|
|
|
|
#endif
|
2013-01-03 06:30:35 -04:00
|
|
|
};
|