-
Notifications
You must be signed in to change notification settings - Fork 8.2k
[TOPIC-GPIO] boards: nrf52840_pca10090: Convert to use the new GPIO API #20184
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,20 +176,16 @@ static int pins_configure(struct device *port, const struct pin_config cfg[], | |
| { | ||
| int err; | ||
|
|
||
| /* Write to the pins before configuring them as output, | ||
| * to make sure we are driving them to the correct level | ||
| * right after they are configured. | ||
| */ | ||
| for (size_t i = 0; i < pins; i++) { | ||
| /* The swiches on the board are active low, so we need | ||
| * to negate the IS_ENABLED() value from the tables. | ||
| /* A given pin controlling the switch needs to be driven | ||
| * to the low state to activate the routing indicated by | ||
| * the corresponding IS_ENABLED() macro in the table, | ||
| * so configure the pin as output with the proper initial | ||
| * state. | ||
| */ | ||
| err = gpio_pin_set(port, cfg[i].pin, !cfg[i].val); | ||
| if (err) { | ||
| return cfg[i].pin; | ||
| } | ||
|
|
||
| err = gpio_pin_configure(port, cfg[i].pin, GPIO_OUTPUT); | ||
| u32_t flag = (cfg[i].val ? GPIO_OUTPUT_LOW | ||
| : GPIO_OUTPUT_HIGH); | ||
| err = gpio_pin_configure(port, cfg[i].pin, flag); | ||
| if (err) { | ||
| return cfg[i].pin; | ||
| } | ||
|
|
@@ -218,7 +214,7 @@ static void reset_pin_wait_low(struct device *port, u32_t pin) | |
|
|
||
| /* Wait until the pin is pulled low */ | ||
| do { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... here do: Other boards might include pins that are active-high, and using the logic level rather than physical level would make the code more consistent.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I now see the original comment about using
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This reset pin here is in fact active high. And the above loop waits until it becomes inactive. As the accompanying comment says, this "lets the other side ensure that they are ready". |
||
| val = gpio_pin_get(port, pin); | ||
| val = gpio_pin_get_raw(port, pin); | ||
| } while (val > 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.
So this new API will configure the pin as output and also set its state to low/high?
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.
Yes, that's what those flags do. Unfortunately there aren't
OUTPUT_INIT_ACTIVEandOUTPUT_INIT_INACTIVE.Since the pins are documented as being active low, and the new API supports operating on logical level, I think it would be more clear to have this be:
then...
Uh oh!
There was an error while loading. Please reload this page.
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.
Well, in fact these pins are not documented as being active low. The DK documentation says only about the default destination and the optional destination, activated when a given pin is set as output and driven low or high, respectively. These pins are described as having active-low logic only in the comment before definitions of
pins_on_p0andpins_on_p1tables (and I left that comment as it was, treating it as to be considered in the context of these tables only; should I change it?). They were also mentioned as being active low in the comment that I reworded, and I intentionally got rid of this "are active low" statement.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.
OK then.
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.
This comment is still in the code, which is part of why I asked for the change:
However that's clear enough, so I'm ok with using the negative logic physical value.