Lines Matching +full:sense +full:- +full:edge +full:- +full:mask
4 * SPDX-License-Identifier: Apache-2.0
12 #include <zephyr/dt-bindings/gpio/nordic-nrf-gpio.h>
41 return port->data; in get_port_data()
46 return port->config; in get_port_cfg()
51 return cfg->gpiote.p_reg != NULL; in has_gpiote()
65 static int gpio_nrfx_gpd_retain_set(const struct device *port, uint32_t mask, gpio_flags_t flags) in gpio_nrfx_gpd_retain_set() argument
70 if (cfg->pad_pd == NRF_GPD_FAST_ACTIVE1) { in gpio_nrfx_gpd_retain_set()
74 nrf_gpio_port_retain_enable(cfg->port, mask); in gpio_nrfx_gpd_retain_set()
84 ARG_UNUSED(mask); in gpio_nrfx_gpd_retain_set()
91 static int gpio_nrfx_gpd_retain_clear(const struct device *port, uint32_t mask) in gpio_nrfx_gpd_retain_clear() argument
96 if (cfg->pad_pd == NRF_GPD_FAST_ACTIVE1) { in gpio_nrfx_gpd_retain_clear()
104 nrf_gpio_port_retain_disable(cfg->port, mask); in gpio_nrfx_gpd_retain_clear()
108 ARG_UNUSED(mask); in gpio_nrfx_gpd_retain_clear()
122 nrfx_gpiote_pin_t abs_pin = NRF_GPIO_PIN_MAP(cfg->port_num, pin); in gpio_nrfx_pin_configure()
152 return -EINVAL; in gpio_nrfx_pin_configure()
161 nrf_gpio_port_out_set(cfg->port, BIT(pin)); in gpio_nrfx_pin_configure()
163 nrf_gpio_port_out_clear(cfg->port, BIT(pin)); in gpio_nrfx_pin_configure()
183 err = nrfx_gpiote_channel_get(&cfg->gpiote, abs_pin, &ch); in gpio_nrfx_pin_configure()
189 (void)nrfx_gpiote_pin_uninit(&cfg->gpiote, abs_pin); in gpio_nrfx_pin_configure()
200 err = nrfx_gpiote_input_configure(&cfg->gpiote, in gpio_nrfx_pin_configure()
203 ret = -EINVAL; in gpio_nrfx_pin_configure()
217 err = nrfx_gpiote_output_configure(&cfg->gpiote, in gpio_nrfx_pin_configure()
224 err = nrfx_gpiote_input_configure(&cfg->gpiote, in gpio_nrfx_pin_configure()
229 ret = -EINVAL; in gpio_nrfx_pin_configure()
235 err = nrfx_gpiote_channel_free(&cfg->gpiote, ch); in gpio_nrfx_pin_configure()
247 NRF_GPIO_Type *reg = get_port_cfg(port)->port; in gpio_nrfx_port_get_raw()
255 gpio_port_pins_t mask, in gpio_nrfx_port_set_masked_raw() argument
258 NRF_GPIO_Type *reg = get_port_cfg(port)->port; in gpio_nrfx_port_set_masked_raw()
261 const uint32_t set_mask = value & mask; in gpio_nrfx_port_set_masked_raw()
262 const uint32_t clear_mask = (~set_mask) & mask; in gpio_nrfx_port_set_masked_raw()
264 ret = gpio_nrfx_gpd_retain_clear(port, mask); in gpio_nrfx_port_set_masked_raw()
272 return gpio_nrfx_gpd_retain_set(port, mask, GPIO_OUTPUT); in gpio_nrfx_port_set_masked_raw()
276 gpio_port_pins_t mask) in gpio_nrfx_port_set_bits_raw() argument
278 NRF_GPIO_Type *reg = get_port_cfg(port)->port; in gpio_nrfx_port_set_bits_raw()
281 ret = gpio_nrfx_gpd_retain_clear(port, mask); in gpio_nrfx_port_set_bits_raw()
286 nrf_gpio_port_out_set(reg, mask); in gpio_nrfx_port_set_bits_raw()
288 return gpio_nrfx_gpd_retain_set(port, mask, GPIO_OUTPUT); in gpio_nrfx_port_set_bits_raw()
292 gpio_port_pins_t mask) in gpio_nrfx_port_clear_bits_raw() argument
294 NRF_GPIO_Type *reg = get_port_cfg(port)->port; in gpio_nrfx_port_clear_bits_raw()
297 ret = gpio_nrfx_gpd_retain_clear(port, mask); in gpio_nrfx_port_clear_bits_raw()
302 nrf_gpio_port_out_clear(reg, mask); in gpio_nrfx_port_clear_bits_raw()
304 return gpio_nrfx_gpd_retain_set(port, mask, GPIO_OUTPUT); in gpio_nrfx_port_clear_bits_raw()
308 gpio_port_pins_t mask) in gpio_nrfx_port_toggle_bits() argument
310 NRF_GPIO_Type *reg = get_port_cfg(port)->port; in gpio_nrfx_port_toggle_bits()
311 const uint32_t value = nrf_gpio_port_out_read(reg) ^ mask; in gpio_nrfx_port_toggle_bits()
312 const uint32_t set_mask = value & mask; in gpio_nrfx_port_toggle_bits()
313 const uint32_t clear_mask = (~value) & mask; in gpio_nrfx_port_toggle_bits()
316 ret = gpio_nrfx_gpd_retain_clear(port, mask); in gpio_nrfx_port_toggle_bits()
324 return gpio_nrfx_gpd_retain_set(port, mask, GPIO_OUTPUT); in gpio_nrfx_port_toggle_bits()
347 uint32_t abs_pin = NRF_GPIO_PIN_MAP(cfg->port_num, pin); in gpio_nrfx_pin_interrupt_configure()
352 return -ENOTSUP; in gpio_nrfx_pin_interrupt_configure()
356 nrfx_gpiote_trigger_disable(&cfg->gpiote, abs_pin); in gpio_nrfx_pin_interrupt_configure()
368 /* If edge mode is to be used and pin is not configured to use sense for in gpio_nrfx_pin_interrupt_configure()
369 * edge use IN event. in gpio_nrfx_pin_interrupt_configure()
371 if (!(BIT(pin) & cfg->edge_sense) && in gpio_nrfx_pin_interrupt_configure()
374 err = nrfx_gpiote_channel_get(&cfg->gpiote, abs_pin, &ch); in gpio_nrfx_pin_interrupt_configure()
376 err = nrfx_gpiote_channel_alloc(&cfg->gpiote, &ch); in gpio_nrfx_pin_interrupt_configure()
378 return -ENOMEM; in gpio_nrfx_pin_interrupt_configure()
385 err = nrfx_gpiote_input_configure(&cfg->gpiote, abs_pin, &input_pin_config); in gpio_nrfx_pin_interrupt_configure()
387 return -EINVAL; in gpio_nrfx_pin_interrupt_configure()
390 nrfx_gpiote_trigger_enable(&cfg->gpiote, abs_pin, true); in gpio_nrfx_pin_interrupt_configure()
399 return gpio_manage_callback(&get_port_data(port)->callbacks, in gpio_nrfx_manage_callback()
411 NRF_GPIO_Type *reg = cfg->port; in gpio_nrfx_port_get_direction()
413 map &= cfg->common.port_pin_mask; in gpio_nrfx_port_get_direction()
416 *outputs = map & nrf_gpio_port_dir_read(cfg->port); in gpio_nrfx_port_get_direction()
423 uint32_t pin_cnf = reg->PIN_CNF[pin]; in gpio_nrfx_port_get_direction()
473 sys_slist_t *list = &data->callbacks; in nrfx_gpio_handler()
492 if (nrfx_gpiote_init_check(&cfg->gpiote)) { in gpio_nrfx_init()
496 err = nrfx_gpiote_init(&cfg->gpiote, 0 /*not used*/); in gpio_nrfx_init()
498 return -EIO; in gpio_nrfx_init()
502 nrfx_gpiote_global_callback_set(&cfg->gpiote, nrfx_gpio_handler, NULL); in gpio_nrfx_init()