Fix inout pins not functioning correctly

Update the drive mode when setting the GPIO direction.
pull/11151/head
Kyle Kearney 2019-07-31 11:51:04 -07:00
parent 417a9fe2fb
commit 33b06d4109
1 changed files with 9 additions and 2 deletions

View File

@ -60,9 +60,16 @@ void gpio_mode(gpio_t *obj, PinMode mode)
}
}
void gpio_dir(MBED_UNUSED gpio_t *obj, MBED_UNUSED PinDirection direction)
void gpio_dir(gpio_t *obj, PinDirection direction)
{
// mbed reads from input buffer instead of DR even for output pins so always leave input buffer enabled
if (direction == PIN_INPUT) {
cyhal_gpio_direction(obj->pin, CYHAL_GPIO_DIR_INPUT);
gpio_mode(obj, CYHAL_GPIO_DRIVE_ANALOG);
} else if (direction == PIN_OUTPUT) {
// mbed reads from input buffer instead of DR even for output pins so always leave input buffer enabled
cyhal_gpio_direction(obj->pin, CYHAL_GPIO_DIR_BIDIRECTIONAL);
gpio_mode(obj, CYHAL_GPIO_DRIVE_STRONG);
}
}
#ifdef __cplusplus