drivers: gpio_mcux: fix handling of unsupported configurations

The MCUX GPIO peripheral must be configured as either input or output.
Reject attempts to configure disconnected or bidirectional.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2019-10-02 16:11:36 -05:00 committed by Carles Cufí
commit 79c04b4ea6

View file

@ -105,15 +105,20 @@ static int gpio_mcux_configure(struct device *dev,
*/
if (access_op == GPIO_ACCESS_BY_PIN) {
if ((flags & GPIO_INPUT) != 0) {
switch (flags & GPIO_DIR_MASK) {
case GPIO_INPUT:
gpio_base->PDDR &= ~BIT(pin);
} else { /* GPIO_OUTPUT */
break;
case GPIO_OUTPUT:
if ((flags & GPIO_OUTPUT_INIT_HIGH) != 0) {
gpio_base->PSOR = BIT(pin);
} else if ((flags & GPIO_OUTPUT_INIT_LOW) != 0) {
gpio_base->PCOR = BIT(pin);
}
gpio_base->PDDR |= BIT(pin);
break;
default:
return -ENOTSUP;
}
} else { /* GPIO_ACCESS_BY_PORT */
if ((flags & GPIO_INPUT) != 0) {