1 /*
2  * Copyright (c) 2016 Open-RnD Sp. z o.o.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @brief Driver for External interrupt/event controller in STM32 MCUs
9  *
10  * Based on reference manuals:
11  *   RM0008 Reference Manual: STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx
12  *   and STM32F107xx advanced ARM(r)-based 32-bit MCUs
13  * and
14  *   RM0368 Reference manual STM32F401xB/C and STM32F401xD/E
15  *   advanced ARM(r)-based 32-bit MCUs
16  *
17  * Chapter 10.2: External interrupt/event controller (EXTI)
18  *
19  */
20 
21 #ifndef ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_EXTI_STM32_H_
22 #define ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_EXTI_STM32_H_
23 
24 #include <zephyr/types.h>
25 
26 /**
27  * @brief enable EXTI interrupt for specific line
28  *
29  * @param line EXTI# line
30  */
31 void stm32_exti_enable(int line);
32 
33 /**
34  * @brief disable EXTI interrupt for specific line
35  *
36  * @param line EXTI# line
37  */
38 void stm32_exti_disable(int line);
39 
40 /**
41  * @brief EXTI trigger flags
42  */
43 enum stm32_exti_trigger {
44 	/* clear trigger */
45 	STM32_EXTI_TRIG_NONE  = 0x0,
46 	/* trigger on rising edge */
47 	STM32_EXTI_TRIG_RISING  = 0x1,
48 	/* trigger on falling endge */
49 	STM32_EXTI_TRIG_FALLING = 0x2,
50 	/* trigger on falling endge */
51 	STM32_EXTI_TRIG_BOTH = 0x3,
52 };
53 
54 /**
55  * @brief set EXTI interrupt line triggers
56  *
57  * @param line EXTI# line
58  * @param trg  OR'ed stm32_exti_trigger flags
59  */
60 void stm32_exti_trigger(int line, int trg);
61 
62 /* callback for exti interrupt */
63 typedef void (*stm32_exti_callback_t) (int line, void *user);
64 
65 /**
66  * @brief set EXTI interrupt callback
67  *
68  * @param line EXI# line
69  * @param cb   user callback
70  * @param data user data
71  */
72 int stm32_exti_set_callback(int line, stm32_exti_callback_t cb, void *data);
73 
74 /**
75  * @brief unset EXTI interrupt callback
76  *
77  * @param line EXI# line
78  */
79 void stm32_exti_unset_callback(int line);
80 
81 #endif /* ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_EXTI_STM32_H_ */
82