Line data Source code
1 0 : /* 2 : * Copyright (c) 2021 Teslabs Engineering S.L. 3 : * 4 : * SPDX-License-Identifier: Apache-2.0 5 : */ 6 : 7 : #ifndef ZEPHYR_INCLUDE_DRIVERS_INTERRUPT_CONTROLLER_GD32_EXTI_H_ 8 : #define ZEPHYR_INCLUDE_DRIVERS_INTERRUPT_CONTROLLER_GD32_EXTI_H_ 9 : 10 : #include <stdint.h> 11 : 12 : #include <zephyr/sys/util_macro.h> 13 : 14 : /** 15 : * @name EXTI trigger modes. 16 : * @anchor GD32_EXTI_TRIG 17 : * @{ 18 : */ 19 : 20 : /** No trigger */ 21 1 : #define GD32_EXTI_TRIG_NONE 0U 22 : /** Trigger on rising edge */ 23 1 : #define GD32_EXTI_TRIG_RISING BIT(0) 24 : /** Trigger on falling edge */ 25 1 : #define GD32_EXTI_TRIG_FALLING BIT(1) 26 : /** Trigger on rising and falling edge */ 27 1 : #define GD32_EXTI_TRIG_BOTH (GD32_EXTI_TRIG_RISING | GD32_EXTI_TRIG_FALLING) 28 : 29 : /** @} */ 30 : 31 : /** Callback for EXTI interrupt. */ 32 1 : typedef void (*gd32_exti_cb_t)(uint8_t line, void *user); 33 : 34 : /** 35 : * @brief Enable EXTI interrupt for the given line. 36 : * 37 : * @param line EXTI line. 38 : */ 39 1 : void gd32_exti_enable(uint8_t line); 40 : 41 : /** 42 : * @brief Disable EXTI interrupt for the given line. 43 : * 44 : * @param line EXTI line. 45 : */ 46 1 : void gd32_exti_disable(uint8_t line); 47 : 48 : /** 49 : * @brief Configure EXTI interrupt trigger mode for the given line. 50 : * 51 : * @param line EXTI line. 52 : * @param trigger Trigger mode (see @ref GD32_EXTI_TRIG). 53 : */ 54 1 : void gd32_exti_trigger(uint8_t line, uint8_t trigger); 55 : 56 : /** 57 : * @brief Configure EXTI interrupt callback. 58 : * 59 : * @param line EXTI line. 60 : * @param cb Callback (NULL to disable). 61 : * @param user User data (optional). 62 : * 63 : * @retval 0 On success. 64 : * @retval -EALREADY If callback is already set and @p cb is not NULL. 65 : */ 66 1 : int gd32_exti_configure(uint8_t line, gd32_exti_cb_t cb, void *user); 67 : 68 : #endif /* ZEPHYR_INCLUDE_DRIVERS_INTERRUPT_CONTROLLER_GD32_EXTI_H_ */