diff --git a/libraries/AP_HAL/GPIO.h b/libraries/AP_HAL/GPIO.h index 921f2329fc..73af3b2c78 100644 --- a/libraries/AP_HAL/GPIO.h +++ b/libraries/AP_HAL/GPIO.h @@ -27,6 +27,8 @@ public: virtual void pinMode(uint8_t pin, uint8_t output) = 0; virtual uint8_t read(uint8_t pin) = 0; virtual void write(uint8_t pin, uint8_t value) = 0; + virtual int8_t analogPinToDigitalPin(uint8_t pin) = 0; + /* Alternative interface: */ virtual AP_HAL::DigitalSource* channel(uint16_t n) = 0; diff --git a/libraries/AP_HAL_AVR/GPIO.cpp b/libraries/AP_HAL_AVR/GPIO.cpp index b916454a91..4ab8b65551 100644 --- a/libraries/AP_HAL_AVR/GPIO.cpp +++ b/libraries/AP_HAL_AVR/GPIO.cpp @@ -61,6 +61,11 @@ void AVRGPIO::pinMode(uint8_t pin, uint8_t mode) { } } +int8_t AVRGPIO::analogPinToDigitalPin(uint8_t pin) +{ + return analogInputToDigitalPin(pin); +} + uint8_t AVRGPIO::read(uint8_t pin) { uint8_t bit = digitalPinToBitMask(pin); uint8_t port = digitalPinToPort(pin); diff --git a/libraries/AP_HAL_AVR/GPIO.h b/libraries/AP_HAL_AVR/GPIO.h index 9e32c159e6..9d5f92bb87 100644 --- a/libraries/AP_HAL_AVR/GPIO.h +++ b/libraries/AP_HAL_AVR/GPIO.h @@ -22,6 +22,7 @@ public: AVRGPIO() {} void init() {} void pinMode(uint8_t pin, uint8_t output); + int8_t analogPinToDigitalPin(uint8_t pin); uint8_t read(uint8_t pin); void write(uint8_t pin, uint8_t value); AP_HAL::DigitalSource* channel(uint16_t); diff --git a/libraries/AP_HAL_Empty/GPIO.cpp b/libraries/AP_HAL_Empty/GPIO.cpp index 672ca292a5..8669851881 100644 --- a/libraries/AP_HAL_Empty/GPIO.cpp +++ b/libraries/AP_HAL_Empty/GPIO.cpp @@ -12,6 +12,11 @@ void EmptyGPIO::init() void EmptyGPIO::pinMode(uint8_t pin, uint8_t output) {} +int8_t EmptyGPIO::analogPinToDigitalPin(uint8_t pin) +{ + return -1; +} + uint8_t EmptyGPIO::read(uint8_t pin) { return 0; diff --git a/libraries/AP_HAL_Empty/GPIO.h b/libraries/AP_HAL_Empty/GPIO.h index da429d76c3..b8cef62012 100644 --- a/libraries/AP_HAL_Empty/GPIO.h +++ b/libraries/AP_HAL_Empty/GPIO.h @@ -9,6 +9,7 @@ public: EmptyGPIO(); void init(); void pinMode(uint8_t pin, uint8_t output); + int8_t analogPinToDigitalPin(uint8_t pin); uint8_t read(uint8_t pin); void write(uint8_t pin, uint8_t value); diff --git a/libraries/AP_HAL_SMACCM/GPIO.cpp b/libraries/AP_HAL_SMACCM/GPIO.cpp index 6fc2b23558..2c77bfb534 100644 --- a/libraries/AP_HAL_SMACCM/GPIO.cpp +++ b/libraries/AP_HAL_SMACCM/GPIO.cpp @@ -15,6 +15,11 @@ void SMACCMGPIO::pinMode(uint8_t pin, uint8_t output) { } +int8_t SMACCMGPIO::analogPinToDigitalPin(uint8_t pin) +{ + return -1; +} + uint8_t SMACCMGPIO::read(uint8_t pin) { return 0; diff --git a/libraries/AP_HAL_SMACCM/GPIO.h b/libraries/AP_HAL_SMACCM/GPIO.h index 570b145255..0d7367910a 100644 --- a/libraries/AP_HAL_SMACCM/GPIO.h +++ b/libraries/AP_HAL_SMACCM/GPIO.h @@ -9,6 +9,7 @@ public: SMACCMGPIO(); void init(); void pinMode(uint8_t pin, uint8_t output); + int8_t analogPinToDigitalPin(uint8_t pin); uint8_t read(uint8_t pin); void write(uint8_t pin, uint8_t value);