Browse Source

AP_IOMCU: valid_GPIO_pin checks if pin configured for GPIO

apm_2208
Randy Mackay 3 years ago
parent
commit
b6e86eee49
  1. 10
      libraries/AP_IOMCU/AP_IOMCU.cpp
  2. 2
      libraries/AP_IOMCU/AP_IOMCU.h

10
libraries/AP_IOMCU/AP_IOMCU.cpp

@ -1064,10 +1064,16 @@ void AP_IOMCU::check_iomcu_reset(void) @@ -1064,10 +1064,16 @@ void AP_IOMCU::check_iomcu_reset(void)
last_rc_protocols = 0;
}
// Check if pin number is valid for GPIO
// Check if pin number is valid and configured for GPIO
bool AP_IOMCU::valid_GPIO_pin(uint8_t pin) const
{
return convert_pin_number(pin);
// sanity check pin number
if (!convert_pin_number(pin)) {
return false;
}
// check pin is enabled as GPIO
return ((GPIO.channel_mask & (1U << pin)) != 0);
}
// convert external pin numbers 101 to 108 to internal 0 to 7

2
libraries/AP_IOMCU/AP_IOMCU.h

@ -107,7 +107,7 @@ public: @@ -107,7 +107,7 @@ public:
bool setup_mixing(RCMapper *rcmap, int8_t override_chan,
float mixing_gain, uint16_t manual_rc_mask);
// Check if pin number is valid for GPIO
// Check if pin number is valid and configured for GPIO
bool valid_GPIO_pin(uint8_t pin) const;
// convert external pin numbers 101 to 108 to internal 0 to 7

Loading…
Cancel
Save