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

[TOPIC-GPIO] drivers: ht16k33: update to use new GPIO API #19641

Merged

Conversation

henrikbrixandersen
Copy link
Member

Update the HT16K33 LED driver, key-scan driver, and sample application to use the new GPIO API.

Copy link
Collaborator

@pabigot pabigot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix needed for validation of the supported I/O modes for the GPIO.

Also it's very confusing whether the interrupt is being configured for a logic level or a physical level. The devicetree uses a pull-up, and the interrupt seems to detect transition to low, but the devicetree defaults to active high. I would normally expect that pull configuration to indicate an active-low trigger on edge-to-active.

@@ -12,7 +12,7 @@
reg = <0x70>;
label = "HT16K33";
/* Uncomment to use IRQ instead of polling: */
/* irq-gpios = <&gpio1 8 (GPIO_PUD_PULL_UP | GPIO_INT_ACTIVE_LOW)>; */
/* irq-gpios = <&gpio1 8 GPIO_PUD_PULL_UP>; */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The (undocumented) consensus seems to be that active level should be made explicit, so this should add GPIO_ACTIVE_HIGH. Though that's not consistent with normal use of pull-up, so maybe it should be GPIO_ACTIVE_LOW. Except in the driver the interrupt is configured for edge-to-inactive.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pabigot My intention was to to use an IRQ which triggers on falling edges. I have updated it to explicitly specify the active level.

drivers/gpio/gpio_ht16k33.c Outdated Show resolved Hide resolved
@mnkp mnkp self-requested a review October 8, 2019 08:58
@mnkp
Copy link
Member

mnkp commented Oct 8, 2019

HT16K33 is not a General Purpose Input Output driver. I think it would be cleaner to move all the interrupt handling code directly into drivers/led/ht16k33.c and remove gpio_ht16k33.c driver.

@pabigot
Copy link
Collaborator

pabigot commented Oct 8, 2019

HT16K33 is not a General Purpose Input Output driver. I think it would be cleaner to move all the interrupt handling code directly into drivers/led/ht16k33.c and remove gpio_ht16k33.c driver.

I agree with this in principle, especially as it appears that there's additional programming necessary to configure and access the keypresses.

Since the LED driver doesn't support a keypress callback API taking that approach would require either a driver-specific API for the ht16k33 or an extension to the LED API to optionally support key presses (if this is not a unique feature of this controller).

For now, since it's already in-tree, I don't think its unreasonable to just make it work the way it has been.

@mnkp
Copy link
Member

mnkp commented Oct 10, 2019

Since the LED driver doesn't support a keypress callback API taking that approach would require either a driver-specific API for the ht16k33 or an extension to the LED API [...]

This is already the case. The GPIO API is used exclusively for its interrupt subsystem. We really should get rid of gpio_ht16k33.c driver.

@carlescufi
Copy link
Member

@henrikbrixandersen
The topic branch has been rebased. Could you please rebase this PR against it?

Implement the new GPIO driver APIs for the HT16K33 and update the
driver to use the new GPIO flags.

Signed-off-by: Henrik Brix Andersen <[email protected]>
Update the IRQ GPIO handling code of the HT16K33 LED driver to use the
new GPIO API.

Signed-off-by: Henrik Brix Andersen <[email protected]>
Update the HT16K33 driver sample application to use the new GPIO
flags.

Signed-off-by: Henrik Brix Andersen <[email protected]>
@henrikbrixandersen
Copy link
Member Author

Since the LED driver doesn't support a keypress callback API taking that approach would require either a driver-specific API for the ht16k33 or an extension to the LED API to optionally support key presses (if this is not a unique feature of this controller).

I have been meaning to introduce a simple key event input subsystem in Zephyr for a while. For now, the closest we have seems to be the GPIO interrupt + callback functionality, which is why the HT16K33 driver is implementing that API.

@henrikbrixandersen
Copy link
Member Author

@henrikbrixandersen
The topic branch has been rebased. Could you please rebase this PR against it?

@carlescufi Rebased and fixed (I hope) the issues brought up in the review so far.

Copy link
Collaborator

@pabigot pabigot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is OK, though of course I can't test it.

@carlescufi carlescufi merged commit 511dc13 into zephyrproject-rtos:topic-gpio Oct 15, 2019
@henrikbrixandersen henrikbrixandersen deleted the topic-gpio-ht16k33 branch October 22, 2019 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants