Line data Source code
1 0 : /*
2 : * Copyright (c) 2019 Derek Hageman <hageman@inthat.cloud>
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 :
8 : #ifndef ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_SAM0_EIC_H_
9 : #define ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_SAM0_EIC_H_
10 :
11 : #include <zephyr/types.h>
12 :
13 : /* callback for EIC interrupt */
14 0 : typedef void (*sam0_eic_callback_t)(uint32_t pins, void *data);
15 :
16 : /**
17 : * @brief EIC trigger condition
18 : */
19 0 : enum sam0_eic_trigger {
20 : /* Rising edge */
21 : SAM0_EIC_RISING,
22 : /* Falling edge */
23 : SAM0_EIC_FALLING,
24 : /* Both edges */
25 : SAM0_EIC_BOTH,
26 : /* High level detection */
27 : SAM0_EIC_HIGH,
28 : /* Low level detection */
29 : SAM0_EIC_LOW,
30 : };
31 :
32 : /**
33 : * @brief Acquire an EIC interrupt for specific port and pin combination
34 : *
35 : * This acquires the EIC interrupt for a specific port and pin combination,
36 : * or returns an error if the required line is not available. Only a single
37 : * callback per port is supported and supplying a different one will
38 : * change it for all lines on that port.
39 : *
40 : * @param port port index (A=0, etc)
41 : * @param pin pin in the port
42 : * @param trigger trigger condition
43 : * @param filter enable filter
44 : * @param cb interrupt callback
45 : * @param data parameter to the interrupt callback
46 : */
47 1 : int sam0_eic_acquire(int port, int pin, enum sam0_eic_trigger trigger,
48 : bool filter, sam0_eic_callback_t cb, void *data);
49 :
50 : /**
51 : * @brief Release the EIC interrupt for a specific port and pin combination
52 : *
53 : * Release the EIC configuration for a specific port and pin combination.
54 : * No effect if that combination does not currently hold the associated
55 : * EIC line.
56 : *
57 : * @param port port index (A=0, etc)
58 : * @param pin pin in the port
59 : */
60 1 : int sam0_eic_release(int port, int pin);
61 :
62 : /**
63 : * @brief Enable the EIC interrupt for a specific port and pin combination
64 : *
65 : * @param port port index (A=0, etc)
66 : * @param pin pin in the port
67 : */
68 1 : int sam0_eic_enable_interrupt(int port, int pin);
69 :
70 : /**
71 : * @brief Disable the EIC interrupt for a specific port and pin combination
72 : *
73 : * @param port port index (A=0, etc)
74 : * @param pin pin in the port
75 : */
76 1 : int sam0_eic_disable_interrupt(int port, int pin);
77 :
78 : /**
79 : * @brief Test if there is an EIC interrupt pending for a port
80 : *
81 : * @param port port index (A=0, etc)
82 : */
83 1 : uint32_t sam0_eic_interrupt_pending(int port);
84 :
85 : #endif /* ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_SAM0_EIC_H_ */
|