Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
card10
firmware
Commits
bbbc91f0
Commit
bbbc91f0
authored
Nov 10, 2019
by
fuchsi*
Browse files
fix(gpio): use ADC mode when both IN and ADC modes are set
parent
6bf3fd5b
Changes
1
Hide whitespace changes
Inline
Side-by-side
epicardium/modules/gpio.c
View file @
bbbc91f0
...
...
@@ -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
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment