1 /* 2 * Copyright 2023-2024 NXP 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @brief Driver for Wake-up interrupt/event controller in NXP S32 MCUs 9 */ 10 11 #ifndef ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_WKPU_NXP_S32_H_ 12 #define ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_WKPU_NXP_S32_H_ 13 14 /** NXP WKPU callback */ 15 typedef void (*wkpu_nxp_s32_callback_t)(uint8_t pin, void *arg); 16 17 /** 18 * @brief NXP WKPU pin activation type 19 */ 20 enum wkpu_nxp_s32_trigger { 21 /** Interrupt triggered on rising edge */ 22 WKPU_NXP_S32_RISING_EDGE, 23 /** Interrupt triggered on falling edge */ 24 WKPU_NXP_S32_FALLING_EDGE, 25 /** Interrupt triggered on either edge */ 26 WKPU_NXP_S32_BOTH_EDGES, 27 }; 28 29 /** 30 * @brief Unset WKPU callback for line 31 * 32 * @param dev WKPU device 33 * @param irq WKPU interrupt number 34 */ 35 void wkpu_nxp_s32_unset_callback(const struct device *dev, uint8_t irq); 36 37 /** 38 * @brief Set WKPU callback for line 39 * 40 * @param dev WKPU device 41 * @param irq WKPU interrupt number 42 * @param pin GPIO pin 43 * @param cb Callback 44 * @param arg Callback data 45 * 46 * @retval 0 on SUCCESS 47 * @retval -EBUSY if callback for the line is already set 48 */ 49 int wkpu_nxp_s32_set_callback(const struct device *dev, uint8_t irq, uint8_t pin, 50 wkpu_nxp_s32_callback_t cb, void *arg); 51 52 /** 53 * @brief Set edge event and enable interrupt for WKPU line 54 * 55 * @param dev WKPU device 56 * @param irq WKPU interrupt number 57 * @param trigger pin activation trigger 58 */ 59 void wkpu_nxp_s32_enable_interrupt(const struct device *dev, uint8_t irq, 60 enum wkpu_nxp_s32_trigger trigger); 61 62 /** 63 * @brief Disable interrupt for WKPU line 64 * 65 * @param dev WKPU device 66 * @param irq WKPU interrupt number 67 */ 68 void wkpu_nxp_s32_disable_interrupt(const struct device *dev, uint8_t irq); 69 70 /** 71 * @brief Get pending interrupt for WKPU device 72 * 73 * @param dev WKPU device 74 * @return A bitmask containing pending interrupts 75 */ 76 uint64_t wkpu_nxp_s32_get_pending(const struct device *dev); 77 78 #endif /* ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_WKPU_NXP_S32_H_ */ 79