AP_IOMCU: valid_GPIO_pin checks if pin configured for GPIO

This commit is contained in:
Randy Mackay 2022-04-21 10:14:10 +09:00
parent caa2ed3294
commit b6e86eee49
2 changed files with 9 additions and 3 deletions

View File

@ -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

View File

@ -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