-
Notifications
You must be signed in to change notification settings - Fork 50
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 <tokita.hiroshi@fujitsu.com>
Add a sample to demonstrate how to use attachInterrupt Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
9df6b4c to
793c765
Compare
DhruvaG2000
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.
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 !
Resolves: zephyrproject-rtos#51 There is an IO pin on the NANO that that when turned on, enables most of the sensors on the BLE sense which are on SPI1. The MBED version, enables this pin as part of the main(). Which I am trying to emulate. There is code already in, that if you use at least one of the zephyr device drivers, will eanble this pin. However that does not help when you are using external libraries or the like. So I added details about this pin in our overlay file, in the zephyr,user section. I then added code to main.cpp, that is only included if your are building using an NRFX board. Currently the nano and one of the nicla boards. Could also specically only do this on the NANO, but probably does not matter as, the code tries to find that property and only if it is found, does it turn on the pin. Note: The MBED version turn on this pin with high drive. Which I emulated using the information, mentioned in the zephyr discussion. zephyrproject-rtos/zephyr#78710 In one of my sketches I verified that the pin pads configuration looks the same as mbed setup. With these changes I am able to access most of the sensors. Most of the testing has been done by @mjs513, with some by myself as well.
Resolves: zephyrproject-rtos#51 There is an IO pin on the NANO that that when turned on, enables most of the sensors on the BLE sense which are on SPI1. The MBED version, enables this pin as part of the main(). Which I am trying to emulate. There is code already in, that if you use at least one of the zephyr device drivers, will eanble this pin. However that does not help when you are using external libraries or the like. So I added details about this pin in our overlay file, in the zephyr,user section. I then added code to main.cpp, that is only included if your are building using an NRFX board. Currently the nano and one of the nicla boards. Could also specically only do this on the NANO, but probably does not matter as, the code tries to find that property and only if it is found, does it turn on the pin. Note: The MBED version turn on this pin with high drive. Which I emulated using the information, mentioned in the zephyr discussion. zephyrproject-rtos/zephyr#78710 In one of my sketches I verified that the pin pads configuration looks the same as mbed setup. With these changes I am able to access most of the sensors. Most of the testing has been done by @mjs513, with some by myself as well.
Resolves: zephyrproject-rtos#51 There is an IO pin on the NANO that that when turned on, enables most of the sensors on the BLE sense which are on SPI1. The MBED version, enables this pin as part of the main(). Which I am trying to emulate. There is code already in, that if you use at least one of the zephyr device drivers, will eanble this pin. However that does not help when you are using external libraries or the like. So I added details about this pin in our overlay file, in the zephyr,user section. I then added code to main.cpp, that is only included if your are building using an NRFX board. Currently the nano and one of the nicla boards. Could also specically only do this on the NANO, but probably does not matter as, the code tries to find that property and only if it is found, does it turn on the pin. Note: The MBED version turn on this pin with high drive. Which I emulated using the information, mentioned in the zephyr discussion. zephyrproject-rtos/zephyr#78710 In one of my sketches I verified that the pin pads configuration looks the same as mbed setup. With these changes I am able to access most of the sensors. Most of the testing has been done by @mjs513, with some by myself as well.
This implementation depends on CONFIG_GPIO_GET_CONFIG
to keep the GPIO state already configured by pinMode().