Line data Source code
1 0 : /* 2 : * Copyright 2023 NXP 3 : * 4 : * SPDX-License-Identifier: Apache-2.0 5 : */ 6 : 7 : /** 8 : * @brief Driver for Pin interrupt and pattern match engine in NXP MCUs 9 : * 10 : * The Pin interrupt and pattern match engine (PINT) supports 11 : * sourcing inputs from any pins on GPIO ports 0 and 1 of NXP MCUs 12 : * featuring the module, and generating interrupts based on these inputs. 13 : * Pin inputs can generate separate interrupts to the NVIC, or be combined 14 : * using the PINT's boolean logic based pattern match engine. 15 : * This driver currently only supports the pin interrupt feature of 16 : * the PINT. 17 : */ 18 : 19 : #ifndef ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_NXP_PINT_H_ 20 : #define ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_NXP_PINT_H_ 21 : 22 : #include <fsl_pint.h> 23 : 24 : /** 25 : * @brief Pin interrupt sources 26 : * 27 : * Pin interrupt sources available for use. 28 : */ 29 0 : enum nxp_pint_trigger { 30 : /* Do not generate Pin Interrupt */ 31 : NXP_PINT_NONE = kPINT_PinIntEnableNone, 32 : /* Generate Pin Interrupt on rising edge */ 33 : NXP_PINT_RISING = kPINT_PinIntEnableRiseEdge, 34 : /* Generate Pin Interrupt on falling edge */ 35 : NXP_PINT_FALLING = kPINT_PinIntEnableFallEdge, 36 : /* Generate Pin Interrupt on both edges */ 37 : NXP_PINT_BOTH = kPINT_PinIntEnableBothEdges, 38 : /* Generate Pin Interrupt on low level */ 39 : NXP_PINT_LOW = kPINT_PinIntEnableLowLevel, 40 : /* Generate Pin Interrupt on high level */ 41 : NXP_PINT_HIGH = kPINT_PinIntEnableHighLevel 42 : }; 43 : 44 : /* Callback for NXP PINT interrupt */ 45 0 : typedef void (*nxp_pint_cb_t) (uint8_t pin, void *user); 46 : 47 : /** 48 : * @brief Enable PINT interrupt source. 49 : * 50 : * @param pin: pin to use as interrupt source 51 : * 0-64, corresponding to GPIO0 pin 1 - GPIO1 pin 31) 52 : * @param trigger: one of nxp_pint_trigger flags 53 : * @param wake: indicates if the pin should wakeup the system 54 : */ 55 1 : int nxp_pint_pin_enable(uint8_t pin, enum nxp_pint_trigger trigger, bool wake); 56 : 57 : 58 : /** 59 : * @brief disable PINT interrupt source. 60 : * 61 : * @param pin: pin interrupt source to disable 62 : */ 63 1 : void nxp_pint_pin_disable(uint8_t pin); 64 : 65 : /** 66 : * @brief Install PINT callback 67 : * 68 : * @param pin: interrupt source to install callback for 69 : * @param cb: callback to install 70 : * @param data: user data to include in callback 71 : * @return 0 on success, or negative value on error 72 : */ 73 1 : int nxp_pint_pin_set_callback(uint8_t pin, nxp_pint_cb_t cb, void *data); 74 : 75 : /** 76 : * @brief Remove PINT callback 77 : * 78 : * @param pin: interrupt source to remove callback for 79 : */ 80 1 : void nxp_pint_pin_unset_callback(uint8_t pin); 81 : 82 : 83 : #endif /* ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_NXP_PINT_H_ */