1 /*
2  * Copyright (c) 2021 - 2025, Nordic Semiconductor ASA
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  *    list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  *    contributors may be used to endorse or promote products derived from this
19  *    software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef NRFX_VEVIF_H__
35 #define NRFX_VEVIF_H__
36 
37 #include <nrfx.h>
38 
39 #include <hal/nrf_vpr_clic.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 #define NRFX_VEVIF_IRQ_HANDLER_DECLARE(idx, _) \
46 void nrfx_vevif_##idx##_irq_handler(void);
47 
48 /**
49  * @defgroup nrfx_vevif VEVIF driver
50  * @{
51  * @ingroup nrf_vpr
52  * @brief   VPR Event Interface (VEVIF) mechanism driver.
53  */
54 
55 /**
56  * @brief VEVIF event handler callback.
57  *
58  * @param[in] event_idx VEVIF event index.
59  * @param[in] p_context Context passed to the event handler. Set on initialization.
60  */
61 typedef void (*nrfx_vevif_event_handler_t)(uint8_t event_idx, void * p_context);
62 
63 /**
64  * @brief Function for initializing the VEVIF driver.
65  *
66  * @param[in] interrupt_priority Interrupt priority.
67  * @param[in] event_handler      Function to be called on interrupt.
68  *                               Must not be NULL.
69  * @param[in] p_context          Context passed to the event handler.
70  *
71  * @retval NRFX_SUCCESS             Driver successfully initialized.
72  * @retval NRFX_ERROR_ALREADY       The driver is already initialized.
73  * @retval NRFX_ERROR_INVALID_STATE The driver is already initialized.
74  *                                  Deprecated - use @ref NRFX_ERROR_ALREADY instead.
75  */
76 nrfx_err_t nrfx_vevif_init(uint8_t                    interrupt_priority,
77                            nrfx_vevif_event_handler_t event_handler,
78                            void *                     p_context);
79 
80 /** @brief Function for uninitializing the VEVIF driver. */
81 void nrfx_vevif_uninit(void);
82 
83 /**
84  * @brief Function for checking if the VEVIF driver is initialized.
85  *
86  * @retval true  Driver is already initialized.
87  * @retval false Driver is not initialized.
88  */
89 bool nrfx_vevif_init_check(void);
90 
91 /**
92  * @brief Function for enabling interrupts on specified VEVIF events.
93  *
94  * @param[in] mask Mask of interrupts to be enabled.
95  */
96 void nrfx_vevif_int_enable(uint32_t mask);
97 
98 /**
99  * @brief Function for disabling interrupts on specified VEVIF events.
100  *
101  * @param[in] mask Mask of interrupts to be disabled.
102  */
103 void nrfx_vevif_int_disable(uint32_t mask);
104 
105 /** @} */
106 
107 /* Declare interrupt handlers for 0..31 NRF_VEVIF driver instances. */
108 NRFX_LISTIFY(32, NRFX_VEVIF_IRQ_HANDLER_DECLARE, (;), _)
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #endif // NRFX_VEVIF_H__
115