-
Notifications
You must be signed in to change notification settings - Fork 29
zephyrCommon: Implement attachInterrupt()/detachInterrupt() #51
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
Conversation
I'm testing with nrf52840 with this patch https://github.com/soburi/zephyr/tree/nrfx_gpio_get_config |
85a4871
to
d2c2059
Compare
d2c2059
to
e65b7bf
Compare
c01299f
to
98cd47f
Compare
samples/attach_interrupt/prj.conf
Outdated
@@ -0,0 +1,4 @@ | |||
CONFIG_GPIO=y | |||
CONFIG_CPLUSPLUS=y |
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.
The module Kconfig already takes care of CPP and GPIO configs, if ARDUI API is enabled, so this can be dropped from prj.conf
imply CPLUSPLUS
imply GPIO
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.
@soburi can you take a look at if this is required again please?
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.
Removed CONFIG_CPLUSPLUS and CONFIG_GPIO.
98cd47f
to
ef0fc41
Compare
cores/arduino/zephyrCommon.cpp
Outdated
} | ||
} | ||
|
||
void pinModeImpl(pin_size_t pinNumber, gpio_flags_t pinmode, voidFuncPtr callback, gpio_flags_t intmode) |
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 seems like this PR is doing much more than just Implementing attachInterrupt()/detachInterrupt, and thus in my opinion deserves to have it's own commit that separates the modifications that have been made in the way that pinMode was earlier implemented.
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.
Also if possible, the commit message should justify the use of new pinMode being better than earlier one and also the addition of GPIO_MODE_MASK
instead of directly using each individual GPIO_XX
flag as and when required?
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.
As a result of redesign, I was able to eliminate this.
It's just attachInterrupt/detachInterrupt and their internal implementation.
ef0fc41
to
3c9c270
Compare
Redesign based on #60. |
Any reason this is still a draft PR? Please mark as ready if you want it to be reviewed, |
3c9c270
to
9df6b4c
Compare
The internal data structure named `gpio_port_callback` stores GPIO callback handlers. The `gpio_port_callback` allocate the data per GPIO device. The `gpio_port_callback` has an array of function pointers to store handler. The largest count of the gpio pin count among the GPIO devices that using (which means it exists in the `digital-pin-gpios`) determines the array size. It calculates the data size at compile time. Signed-off-by: TOKITA Hiroshi <[email protected]>
Add a sample to demonstrate how to use attachInterrupt Signed-off-by: TOKITA Hiroshi <[email protected]>
9df6b4c
to
793c765
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.
Tested on my ble sense 33 and I was able to toggle LED by giving interrupts on D2 pin.
Hence,
Tested-by: Dhruva Gole
Thanks for this great feature addition @soburi !
This implementation depends on CONFIG_GPIO_GET_CONFIG
to keep the GPIO state already configured by pinMode().