-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: pinmux: esp32: Fix using gpio as IO at the same time. #5850
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5850 +/- ##
=======================================
Coverage 52.51% 52.51%
=======================================
Files 406 406
Lines 39683 39683
Branches 7715 7715
=======================================
Hits 20839 20839
Misses 15663 15663
Partials 3181 3181 Continue to review full report at Codecov.
|
@@ -123,16 +123,19 @@ static int pinmux_input(struct device *dev, u32_t pin, u8_t func) | |||
volatile u32_t *reg; | |||
int r; | |||
|
|||
/* Since PINMUX_INPUT_ENABLED == 1 and PINMUX_OUTPUT_ENABLED == 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would happen if one wanted a pin to be used as output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the gpio sample and it worked, but I'm not sure if there will be problems under other conditions. I'm going to try another approach to using pins as IO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I add the flags below so we can set the pin as IO and avoid the workaround?
#define GPIO_DIR_IN_OUT (1 << 18)
on gpio.h
#define PINMUX_INPUT_OUTPUT_ENABLED (0x2)
on pinmux.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that API changes at this level requires some more input. We're reviewing a lot of our APIs, so it's good to have feedback like this. Please open an issue and link it to #5697.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Since PINMUX_INPUT_ENABLED == 1 and PINMUX_OUTPUT_ENABLED == 0, we can not set a gpio port as input and output at the same time, So we always set the gpio as input. Thus, the gpio can be used on I2C drivers for example. Signed-off-by: Vitor Massaru Iha <[email protected]>
Since PINMUX_INPUT_ENABLED == 1 and PINMUX_OUTPUT_ENABLED == 0,
we can not set a gpio port as input and output at the same time,
So we always set the gpio as input. Thus, the gpio can be used on
I2C drivers for example.
Signed-off-by: Vitor Massaru Iha [email protected]
Fixes #5650