Line data Source code
1 0 : /*
2 : * Copyright (c) 2025 Michael Hope <michaelh@juju.nz>
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : #ifndef ZEPHYR_INCLUDE_DRIVERS_INTERRUPT_CONTROLLER_WCH_EXTI_H_
8 : #define ZEPHYR_INCLUDE_DRIVERS_INTERRUPT_CONTROLLER_WCH_EXTI_H_
9 :
10 : #include <stdint.h>
11 :
12 : #include <zephyr/sys/util_macro.h>
13 :
14 : /* Callback for EXTI interrupt. */
15 0 : typedef void (*wch_exti_callback_handler_t)(uint8_t line, void *user);
16 :
17 0 : enum wch_exti_trigger {
18 : /*
19 : * Note that this is a flag set and these values can be ORed to trigger on
20 : * both edges.
21 : */
22 :
23 : /* Trigger on rising edge */
24 : WCH_EXTI_TRIGGER_RISING_EDGE = BIT(0),
25 : /* Trigger on falling edge */
26 : WCH_EXTI_TRIGGER_FALLING_EDGE = BIT(1),
27 : };
28 :
29 : /* Enable the EXTI interrupt for `line` */
30 0 : void wch_exti_enable(uint8_t line);
31 :
32 : /* Disable the EXTI interrupt for `line` */
33 0 : void wch_exti_disable(uint8_t line);
34 :
35 : /* Set the trigger mode for `line` */
36 0 : void wch_exti_set_trigger(uint8_t line, enum wch_exti_trigger trigger);
37 :
38 : /* Register a callback for `line` */
39 0 : int wch_exti_configure(uint8_t line, wch_exti_callback_handler_t callback, void *user);
40 :
41 : #endif /* ZEPHYR_INCLUDE_DRIVERS_INTERRUPT_CONTROLLER_WCH_EXTI_H_ */
|