-
Notifications
You must be signed in to change notification settings - Fork 8.2k
[topic-gpio] samples: reel_board: mesh_badge: Convert to the new GPIO API #22137
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
[topic-gpio] samples: reel_board: mesh_badge: Convert to the new GPIO API #22137
Conversation
|
Partially tested on the reel_board. @jhedberg could you please test it a bit more to make sure I haven't missed anything? |
|
All checks are passing now. checkpatch (informational only, not a failure)Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
22b8877 to
f0148fc
Compare
Use the flags included in the new GPIO API to describe the properties of LEDs and buttons in the device tree source files. Signed-off-by: Carles Cufi <[email protected]>
f0148fc to
7fd50f8
Compare
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.
It should be GPIO_INT_EDGE_BOTH, see the definition of EDGE, which is no longer needed BTW.
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.
Very well spotted. Fixed.
7fd50f8 to
6c83ce2
Compare
|
@jfischer-phytec-iot you might be interested to take a look as well |
pabigot
left a comment
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.
Only required change is handling an error return from gpio_pin_get(), which can be treated as "not pressed". Others are commentary.
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.
gpio_pin_t would save some space.
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.
Indeed, changed.
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.
You could just do DT_ALIAS_LED0_GPIOS which expands to the controller name, pin, and flags in a single initializer expression. Though without a pre-defined standard structure synchronized to generation of that expression it's technically more future-proof to spelling out each element.
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.
Oh, thanks for letting me know of this DT-generated macro. As you yourself mention, since this uses designated initializers I'd rather not change it at this point.
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.
Note gpio_pin_get can return a negative value to indicate a failure to read a value. There's also an essential type error here. gpio_pin_get(...) > 0 would be better.
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.
Agreed, fixed.
Convert to the new GPIO API using logical levels, and remove the duplicate implementation of LED control that existed. Signed-off-by: Carles Cufi <[email protected]>
6c83ce2 to
77ad2e8
Compare
See commit messages.