Skip to content
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

Merged
merged 1 commit into from
Feb 7, 2018

Conversation

iha
Copy link
Contributor

@iha iha commented Jan 26, 2018

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

@iha iha mentioned this pull request Jan 26, 2018
@codecov-io
Copy link

codecov-io commented Jan 26, 2018

Codecov Report

Merging #5850 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 30824c9...1452d58. Read the comment docs.

@@ -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,
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Collaborator

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.

@nashif nashif added this to the v1.11.0 milestone Feb 7, 2018
Copy link
Collaborator

@lpereira lpereira left a 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]>
@nashif nashif merged commit 623c915 into zephyrproject-rtos:master Feb 7, 2018
@iha iha deleted the fix_pinmux branch February 7, 2018 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants