Skip to content
Snippets Groups Projects
Commit bbbc91f0 authored by fuchsi*'s avatar fuchsi*
Browse files

fix(gpio): use ADC mode when both IN and ADC modes are set

parent 6bf3fd5b
Branches
No related tags found
No related merge requests found
......@@ -48,7 +48,16 @@ int epic_gpio_set_pin_mode(uint8_t pin, uint8_t mode)
gpio_cfg_t *cfg = &gpio_configs[pin];
if (mode & EPIC_GPIO_MODE_IN) {
if (mode & EPIC_GPIO_MODE_ADC) {
if (s_adc_channels[pin] == -1) {
LOG_WARN("gpio", "ADC not available on pin %d", pin);
return -EINVAL;
}
cfg->func = GPIO_FUNC_ALT1;
if (mode & EPIC_GPIO_MODE_OUT) {
return -EINVAL;
}
} else if (mode & EPIC_GPIO_MODE_IN) {
cfg->func = GPIO_FUNC_IN;
if (mode & EPIC_GPIO_MODE_OUT) {
return -EINVAL;
......@@ -58,15 +67,6 @@ int epic_gpio_set_pin_mode(uint8_t pin, uint8_t mode)
if (mode & EPIC_GPIO_MODE_IN) {
return -EINVAL;
}
} else if (mode & EPIC_GPIO_MODE_ADC) {
if (s_adc_channels[pin] == -1) {
LOG_WARN("gpio", "ADC not available on pin %d", pin);
return -EINVAL;
}
cfg->func = GPIO_FUNC_ALT1;
if (mode & EPIC_GPIO_MODE_OUT) {
return -EINVAL;
}
} else {
return -EINVAL;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment