Line data Source code
1 : #pragma once 2 : 3 : #include "AP_HAL_Namespace.h" 4 : 5 : #define RC_INPUT_MIN_PULSEWIDTH 900 6 : #define RC_INPUT_MAX_PULSEWIDTH 2100 7 : 8 : class AP_HAL::RCInput { 9 : public: 10 : /** 11 : * Call init from the platform hal instance init, so that both the type of 12 : * the RCInput implementation and init argument (e.g. ISRRegistry) are 13 : * known to the programmer. (It's too difficult to describe this dependency 14 : * in the C++ type system.) 15 : */ 16 : virtual void init() = 0; 17 0 : virtual void teardown() {}; 18 : 19 : /** 20 : * Return true if there has been new input since the last call to new_input() 21 : */ 22 : virtual bool new_input(void) = 0; 23 : 24 : /** 25 : * Return the number of valid channels in the last read 26 : */ 27 : virtual uint8_t num_channels() = 0; 28 : 29 : /* Read a single channel at a time */ 30 : virtual uint16_t read(uint8_t ch) = 0; 31 : 32 : /* Read an array of channels, return the valid count */ 33 : virtual uint8_t read(uint16_t* periods, uint8_t len) = 0; 34 : 35 : /* get receiver based RSSI if available. -1 for unknown, 0 for no link, 255 for maximum link */ 36 0 : virtual int16_t get_rssi(void) { return -1; } 37 0 : virtual int16_t get_rx_link_quality(void) { return -1; } 38 : /* Return string describing method RC input protocol */ 39 0 : virtual const char *protocol() const { return nullptr; } 40 : 41 : /** 42 : * Overrides: these are really grody and don't belong here but we need 43 : * them at the moment to make the port work. 44 : * case v of: 45 : * v == -1 -> no change to this channel 46 : * v == 0 -> do not override this channel 47 : * v > 0 -> set v as override. 48 : */ 49 : 50 : /* enable or disable pulse input for RC input. This is used to 51 : reduce load when we are decoding R/C via a UART */ 52 0 : virtual void pulse_input_enable(bool enable) { } 53 : };