Line data Source code
1 : #pragma once 2 : 3 : #include <inttypes.h> 4 : 5 : #include "AP_HAL_Namespace.h" 6 : #include "AP_HAL_Boards.h" 7 : 8 : class AP_HAL::AnalogSource { 9 : public: 10 : virtual float read_average() = 0; 11 : virtual float read_latest() = 0; 12 : virtual bool set_pin(uint8_t p) WARN_IF_UNUSED = 0; 13 : 14 : // return a voltage from 0.0 to 5.0V, scaled 15 : // against a reference voltage 16 : virtual float voltage_average() = 0; 17 : 18 : // return a voltage from 0.0 to 5.0V, scaled 19 : // against a reference voltage 20 : virtual float voltage_latest() = 0; 21 : 22 : // return a voltage from 0.0 to 5.0V, assuming a ratiometric 23 : // sensor 24 : virtual float voltage_average_ratiometric() = 0; 25 : }; 26 : 27 : class AP_HAL::AnalogIn { 28 : public: 29 : virtual void init() = 0; 30 : virtual AP_HAL::AnalogSource* channel(int16_t n) = 0; 31 : 32 0 : virtual bool valid_analog_pin(uint16_t pin) const { return false; } 33 : 34 : // board 5V rail voltage in volts 35 : virtual float board_voltage(void) = 0; 36 : 37 : // servo rail voltage in volts, or 0 if unknown 38 1116845 : virtual float servorail_voltage(void) { return 0; } 39 : 40 : // power supply status flags, see MAV_POWER_STATUS 41 1116845 : virtual uint16_t power_status_flags(void) { return 0; } 42 : 43 : // bitmask of all _power_flags bits ever set, so transient 44 : // failures can still be diagnosed 45 0 : virtual uint16_t accumulated_power_status_flags(void) const { return 0; } 46 : 47 : // this enum class is 1:1 with MAVLink's MAV_POWER_STATUS enumeration! 48 : enum class PowerStatusFlag : uint16_t { 49 : BRICK_VALID = 1, // main brick power supply valid 50 : SERVO_VALID = 2, // main servo power supply valid for FMU 51 : USB_CONNECTED = 4, // USB power is connected 52 : PERIPH_OVERCURRENT = 8, // peripheral supply is in over-current state 53 : PERIPH_HIPOWER_OVERCURRENT = 16, // hi-power peripheral supply is in over-current state 54 : CHANGED = 32, // Power status has changed since boot 55 : }; 56 : 57 : #if HAL_WITH_MCU_MONITORING 58 : virtual float mcu_temperature(void) { return 0; } 59 : virtual float mcu_voltage(void) { return 0; } 60 : virtual float mcu_voltage_max(void) { return 0; } 61 : virtual float mcu_voltage_min(void) { return 0; } 62 : #endif 63 : }; 64 : 65 : #define ANALOG_INPUT_BOARD_VCC 254 66 : #define ANALOG_INPUT_NONE 255