Lines Matching +full:start +full:- +full:line

2  * Copyright (c) 2016 Open-RnD Sp. z o.o.
4 * Copyright (c) 2019-23 Linaro Limited
6 * SPDX-License-Identifier: Apache-2.0
23 #include <zephyr/dt-bindings/pinctrl/stm32-pinctrl-common.h> /* For STM32L0 series */
30 /** @brief EXTI lines range mapped to a single interrupt line */
32 /** Start of the range */
33 uint8_t start; member
40 static IRQn_Type exti_irq_table[NUM_EXTI_LINES] = {[0 ... NUM_EXTI_LINES - 1] = 0xFF};
50 /* per-line callbacks */
66 /* Gives the LL_SBS_EXTI_LINEn corresponding to the line number */ in stm32_exti_linenum_to_src_cfg_line()
74 * @brief Checks interrupt pending bit for specified EXTI line
76 * @param line EXTI line number
78 static inline int stm32_exti_is_pending(stm32_gpio_irq_line_t line) in stm32_exti_is_pending() argument
81 return (LL_EXTI_IsActiveRisingFlag_0_31(line) || in stm32_exti_is_pending()
82 LL_EXTI_IsActiveFallingFlag_0_31(line)); in stm32_exti_is_pending()
84 return LL_C2_EXTI_IsActiveFlag_0_31(line); in stm32_exti_is_pending()
86 return LL_EXTI_IsActiveFlag_0_31(line); in stm32_exti_is_pending()
91 * @brief Clears interrupt pending bit for specified EXTI line
93 * @param line EXTI line number
95 static inline void stm32_exti_clear_pending(stm32_gpio_irq_line_t line) in stm32_exti_clear_pending() argument
98 LL_EXTI_ClearRisingFlag_0_31(line); in stm32_exti_clear_pending()
99 LL_EXTI_ClearFallingFlag_0_31(line); in stm32_exti_clear_pending()
101 LL_C2_EXTI_ClearFlag_0_31(line); in stm32_exti_clear_pending()
103 LL_EXTI_ClearFlag_0_31(line); in stm32_exti_clear_pending()
108 * @returns the LL_EXTI_LINE_n define for EXTI line number @p linenum
116 * @returns EXTI line number for LL_EXTI_LINE_n define
118 static inline gpio_pin_t ll_exti_line_to_linenum(stm32_gpio_irq_line_t line) in ll_exti_line_to_linenum() argument
120 return LOG2(line); in ll_exti_line_to_linenum()
133 struct stm32_exti_data *data = dev->data; in stm32_exti_isr()
135 stm32_gpio_irq_line_t line; in stm32_exti_isr() local
139 for (uint8_t i = 0; i <= range->len; i++) { in stm32_exti_isr()
140 line_num = range->start + i; in stm32_exti_isr()
141 line = linenum_to_ll_exti_line(line_num); in stm32_exti_isr()
144 if (stm32_exti_is_pending(line) != 0) { in stm32_exti_isr()
146 stm32_exti_clear_pending(line); in stm32_exti_isr()
149 if (!data->cb[line_num].cb) { in stm32_exti_isr()
153 /* `line` can be passed as-is because LL_EXTI_LINE_n is (1 << n) */ in stm32_exti_isr()
154 data->cb[line_num].cb(line, data->cb[line_num].data); in stm32_exti_isr()
192 static void stm32_fill_irq_table(int8_t start, int8_t len, int32_t irqn) in stm32_fill_irq_table() argument
195 exti_irq_table[start + i] = irqn; in stm32_fill_irq_table()
200 * - populates line_range_x from line_range dt property
201 * - fill exti_irq_table through stm32_fill_irq_table()
202 * - calls IRQ_CONNECT for each interrupt and matching line_range
209 stm32_fill_irq_table(line_range_##idx.start, \
258 void stm32_gpio_intc_enable_line(stm32_gpio_irq_line_t line) in stm32_gpio_intc_enable_line() argument
261 uint32_t line_num = ll_exti_line_to_linenum(line); in stm32_gpio_intc_enable_line()
265 /* Get matching exti irq provided line thanks to irq_table */ in stm32_gpio_intc_enable_line()
269 /* Enable requested line interrupt */ in stm32_gpio_intc_enable_line()
271 LL_C2_EXTI_EnableIT_0_31(line); in stm32_gpio_intc_enable_line()
273 LL_EXTI_EnableIT_0_31(line); in stm32_gpio_intc_enable_line()
280 void stm32_gpio_intc_disable_line(stm32_gpio_irq_line_t line) in stm32_gpio_intc_disable_line() argument
283 LL_C2_EXTI_DisableIT_0_31(line); in stm32_gpio_intc_disable_line()
285 LL_EXTI_DisableIT_0_31(line); in stm32_gpio_intc_disable_line()
289 void stm32_gpio_intc_select_line_trigger(stm32_gpio_irq_line_t line, uint32_t trg) in stm32_gpio_intc_select_line_trigger() argument
295 LL_EXTI_DisableRisingTrig_0_31(line); in stm32_gpio_intc_select_line_trigger()
296 LL_EXTI_DisableFallingTrig_0_31(line); in stm32_gpio_intc_select_line_trigger()
299 LL_EXTI_EnableRisingTrig_0_31(line); in stm32_gpio_intc_select_line_trigger()
300 LL_EXTI_DisableFallingTrig_0_31(line); in stm32_gpio_intc_select_line_trigger()
303 LL_EXTI_EnableFallingTrig_0_31(line); in stm32_gpio_intc_select_line_trigger()
304 LL_EXTI_DisableRisingTrig_0_31(line); in stm32_gpio_intc_select_line_trigger()
307 LL_EXTI_EnableRisingTrig_0_31(line); in stm32_gpio_intc_select_line_trigger()
308 LL_EXTI_EnableFallingTrig_0_31(line); in stm32_gpio_intc_select_line_trigger()
317 int stm32_gpio_intc_set_irq_callback(stm32_gpio_irq_line_t line, stm32_gpio_irq_cb_t cb, void *user) in stm32_gpio_intc_set_irq_callback() argument
320 struct stm32_exti_data *data = dev->data; in stm32_gpio_intc_set_irq_callback()
321 uint32_t line_num = ll_exti_line_to_linenum(line); in stm32_gpio_intc_set_irq_callback()
323 if ((data->cb[line_num].cb == cb) && (data->cb[line_num].data == user)) { in stm32_gpio_intc_set_irq_callback()
327 /* if callback already exists/maybe-running return busy */ in stm32_gpio_intc_set_irq_callback()
328 if (data->cb[line_num].cb != NULL) { in stm32_gpio_intc_set_irq_callback()
329 return -EBUSY; in stm32_gpio_intc_set_irq_callback()
332 data->cb[line_num].cb = cb; in stm32_gpio_intc_set_irq_callback()
333 data->cb[line_num].data = user; in stm32_gpio_intc_set_irq_callback()
338 void stm32_gpio_intc_remove_irq_callback(stm32_gpio_irq_line_t line) in stm32_gpio_intc_remove_irq_callback() argument
341 struct stm32_exti_data *data = dev->data; in stm32_gpio_intc_remove_irq_callback()
342 uint32_t line_num = ll_exti_line_to_linenum(line); in stm32_gpio_intc_remove_irq_callback()
344 data->cb[line_num].cb = NULL; in stm32_gpio_intc_remove_irq_callback()
345 data->cb[line_num].data = NULL; in stm32_gpio_intc_remove_irq_callback()
348 void stm32_exti_set_line_src_port(gpio_pin_t line, uint32_t port) in stm32_exti_set_line_src_port() argument
350 uint32_t ll_line = stm32_exti_linenum_to_src_cfg_line(line); in stm32_exti_set_line_src_port()
378 uint32_t stm32_exti_get_line_src_port(gpio_pin_t line) in stm32_exti_get_line_src_port() argument
380 uint32_t ll_line = stm32_exti_linenum_to_src_cfg_line(line); in stm32_exti_get_line_src_port()