-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
drivers: gpio: nrfx: Implementation based on new nrfx_gpiote driver #37528
Conversation
26c5add
to
be1c550
Compare
drivers/gpio/gpio_nrfx.c
Outdated
const struct device *port = pin2dev(abs_pin); | ||
uint32_t pin_mask = BIT(abs2pin(abs_pin)); |
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 use nrf_gpio_pin_port_number_extract()
here instead of introducing pin2dev()
and abs2pin()
.
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.
still need to kept function for translating port id to device handle. Not sure if there is already defined way how to do that.
be1c550
to
9b9d061
Compare
@anangl comments resolved. |
drivers/gpio/gpio_nrfx.c
Outdated
NRF_GPIOTE_EVENT_PORT); | ||
|
||
if (port_event) { | ||
#ifdef CONFIG_GPIO_NRF_P0 |
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.
I've just realized that so far it was possible to disable support for P0 or P1 in Kconfig. I'm not sure whether this possibility was actually used, but I guess it should be kept, so get_dev()
should be reworked a bit.
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.
rebased on #38995 and updated get_dev()
to use device tree.
9b9d061
to
2b6a9f2
Compare
9479f5b
to
eee0f14
Compare
eee0f14
to
52bd123
Compare
It's now based on nrfx2.6, taking out of draft. |
@anangl @nika-nordic please review |
drivers/gpio/gpio_nrfx.c
Outdated
return trig == GPIO_INT_TRIG_BOTH ? | ||
NRFX_GPIOTE_TRIGGER_TOGGLE : | ||
(trig == GPIO_INT_TRIG_LOW ? NRFX_GPIOTE_TRIGGER_HITOLO : | ||
NRFX_GPIOTE_TRIGGER_LOTOHI); |
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.
What about putting it this way:
return trig == GPIO_INT_TRIG_BOTH ? NRFX_GPIOTE_TRIGGER_TOGGLE :
trig == GPIO_INT_TRIG_LOW ? NRFX_GPIOTE_TRIGGER_HITOLO :
NRFX_GPIOTE_TRIGGER_LOTOHI;
and similarly the construct for mode == GPIO_INT_MODE_LEVEL
?
drivers/gpio/gpio_nrfx.c
Outdated
NRFX_GPIOTE_TRIGGER_TOGGLE : | ||
(trig == GPIO_INT_TRIG_LOW ? NRFX_GPIOTE_TRIGGER_HITOLO : | ||
NRFX_GPIOTE_TRIGGER_LOTOHI); | ||
|
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.
Unnecessary empty line.
*/ | ||
return -ENOTSUP; | ||
(nrf_gpio_pin_dir_get(abs_pin) == NRF_GPIO_PIN_DIR_INPUT)) { | ||
err = nrfx_gpiote_channel_get(abs_pin, &ch); |
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.
uint8_t ch;
can be moved to right before this line.
drivers/gpio/gpio_nrfx.c
Outdated
} | ||
} | ||
|
||
|
||
#define GPIOTE_NODE DT_INST(0, nordic_nrf_gpiote) | ||
|
||
static int gpio_nrfx_init(const struct device *port) | ||
{ | ||
static bool gpio_initialized; |
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 variable is not needed anymore.
drivers/gpio/gpio_nrfx.c
Outdated
nrfx_gpiote_global_callback_set(nrfx_gpio_handler, NULL); | ||
|
||
IRQ_CONNECT(DT_IRQN(GPIOTE_NODE), DT_IRQ(GPIOTE_NODE, priority), | ||
nrfx_gpiote_irq_handler, NULL, 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.
nrfx_gpiote_irq_handler, NULL, 0); | |
nrfx_isr, nrfx_gpiote_irq_handler, 0); |
so that we stay consistent with other nrfx driver shims.
Converting driver to shim which is using nrfx_gpiote driver underneath. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
52bd123
to
0099f1a
Compare
@anangl comments applied. |
Converting driver to shim which is using nrfx_gpiote driver
underneath.
This is based on preliminary version of the nrfx_gpiote driver.
Implementation is passing
gpio_api_1pin
andgpio_basic_api
suites.Signed-off-by: Krzysztof Chruscinski krzysztof.chruscinski@nordicsemi.no