Skip to content

Commit 644f795

Browse files
author
Seppo Takalo
authored
Merge pull request #11151 from kyle-cypress/pr/gpio-inout-fix
Fix PSoC 6 inout pins
2 parents 46a56fb + 33b06d4 commit 644f795

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/cy_gpio_api.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,16 @@ void gpio_mode(gpio_t *obj, PinMode mode)
6060
}
6161
}
6262

63-
void gpio_dir(MBED_UNUSED gpio_t *obj, MBED_UNUSED PinDirection direction)
63+
void gpio_dir(gpio_t *obj, PinDirection direction)
6464
{
65-
// mbed reads from input buffer instead of DR even for output pins so always leave input buffer enabled
65+
if (direction == PIN_INPUT) {
66+
cyhal_gpio_direction(obj->pin, CYHAL_GPIO_DIR_INPUT);
67+
gpio_mode(obj, CYHAL_GPIO_DRIVE_ANALOG);
68+
} else if (direction == PIN_OUTPUT) {
69+
// mbed reads from input buffer instead of DR even for output pins so always leave input buffer enabled
70+
cyhal_gpio_direction(obj->pin, CYHAL_GPIO_DIR_BIDIRECTIONAL);
71+
gpio_mode(obj, CYHAL_GPIO_DRIVE_STRONG);
72+
}
6673
}
6774

6875
#ifdef __cplusplus

0 commit comments

Comments
 (0)