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 #define STM32_EXTI_LINE_NONE 0xFFFFFFFFU 27 28 /** 29 * @brief enable EXTI interrupt for specific line 30 * 31 * @param line EXTI# line 32 */ 33 void stm32_exti_enable(int line); 34 35 /** 36 * @brief disable EXTI interrupt for specific line 37 * 38 * @param line EXTI# line 39 */ 40 void stm32_exti_disable(int line); 41 42 /** 43 * @brief EXTI trigger flags 44 */ 45 enum stm32_exti_trigger { 46 /* clear trigger */ 47 STM32_EXTI_TRIG_NONE = 0x0, 48 /* trigger on rising edge */ 49 STM32_EXTI_TRIG_RISING = 0x1, 50 /* trigger on falling edge */ 51 STM32_EXTI_TRIG_FALLING = 0x2, 52 /* trigger on both rising & falling edge */ 53 STM32_EXTI_TRIG_BOTH = 0x3, 54 }; 55 56 /** 57 * @brief set EXTI interrupt line triggers 58 * 59 * @param line EXTI# line 60 * @param trg OR'ed stm32_exti_trigger flags 61 */ 62 void stm32_exti_trigger(int line, int trg); 63 64 /* callback for exti interrupt */ 65 typedef void (*stm32_exti_callback_t) (int line, void *user); 66 67 /** 68 * @brief set EXTI interrupt callback 69 * 70 * @param line EXI# line 71 * @param cb user callback 72 * @param data user data 73 */ 74 int stm32_exti_set_callback(int line, stm32_exti_callback_t cb, void *data); 75 76 /** 77 * @brief unset EXTI interrupt callback 78 * 79 * @param line EXI# line 80 */ 81 void stm32_exti_unset_callback(int line); 82 83 #endif /* ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_EXTI_STM32_H_ */ 84