1 /*
2  * Copyright (c) 2023 - 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_INTERCONNECT_DPPIC_PPIB_LUMOS_H__
35 #define NRFX_INTERCONNECT_DPPIC_PPIB_LUMOS_H__
36 
37 #include <nrfx.h>
38 #include <nrfx_ppib.h>
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #define NRFX_INTERCONNECT_PPIB_TASKS_GET(PPIB_INDEX) \
45     (NRFX_CONCAT(PPIB, PPIB_INDEX, _NTASKSEVENTS_MAX) + 1UL)
46 
47 #define NRFX_INTERCONNECT_PPIB(FIRST_PPIB_INDEX, SECOND_PPIB_INDEX)                                \
48 {                                                                                                  \
49     .ppib = NRFX_PPIB_INTERCONNECT_INSTANCE(FIRST_PPIB_INDEX, SECOND_PPIB_INDEX),                  \
50 }
51 
52 #if NRFX_API_VER_AT_LEAST(3, 8, 0)
53 #define DPPI_INSTANCE(idx) .dppic = NRFX_DPPI_INSTANCE(idx)
54 #else
55 #define DPPI_INSTANCE(idx)                                          \
56     .dppic         = NRFX_CONCAT(NRF_DPPIC, idx),                   \
57     .channels_mask = NRFX_BIT_MASK(NRFX_CONCAT(DPPIC, idx, _CH_NUM))
58 #endif
59 
60 #if defined(NRF54L_SERIES) || defined(NRF7120_ENGA_XXAA)
61 
62 #define NRFX_INTERCONNECT_PPIB_MAP  \
63 {                                   \
64     NRFX_INTERCONNECT_PPIB(00, 10), \
65     NRFX_INTERCONNECT_PPIB(11, 21), \
66     NRFX_INTERCONNECT_PPIB(22, 30), \
67     NRFX_INTERCONNECT_PPIB(01, 20), \
68 }
69 
70 #define NRFX_INTERCONNECT_DPPIC_PPIB_MAP \
71 {                                        \
72     {                                    \
73         .dppic = NRF_DPPIC00,            \
74         .ppib  = NRF_PPIB00,             \
75     },                                   \
76     {                                    \
77         .dppic = NRF_DPPIC00,            \
78         .ppib  = NRF_PPIB01,             \
79     },                                   \
80     {                                    \
81         .dppic = NRF_DPPIC10,            \
82         .ppib  = NRF_PPIB10,             \
83     },                                   \
84     {                                    \
85         .dppic = NRF_DPPIC10,            \
86         .ppib  = NRF_PPIB11,             \
87     },                                   \
88     {                                    \
89         .dppic = NRF_DPPIC20,            \
90         .ppib  = NRF_PPIB20,             \
91     },                                   \
92     {                                    \
93         .dppic = NRF_DPPIC20,            \
94         .ppib  = NRF_PPIB21,             \
95     },                                   \
96     {                                    \
97         .dppic = NRF_DPPIC20,            \
98         .ppib  = NRF_PPIB22,             \
99     },                                   \
100     {                                    \
101         .dppic = NRF_DPPIC30,            \
102         .ppib  = NRF_PPIB30,             \
103     },                                   \
104 }
105 
106 #define NRFX_INTERCONNECT_DPPIC_MAP                        \
107 {                                                          \
108     {                                                      \
109         .apb_index     = NRF_APB_INDEX_MCU,                \
110         DPPI_INSTANCE(00),                                 \
111         .apb_size      = 0x40000                           \
112     },                                                     \
113     {                                                      \
114         .apb_index     = NRF_APB_INDEX_RADIO,              \
115         DPPI_INSTANCE(10),                                 \
116         .apb_size      = 0x40000                           \
117     },                                                     \
118     {                                                      \
119         .apb_index     = NRF_APB_INDEX_PERI,               \
120         DPPI_INSTANCE(20),                                 \
121         .apb_size      = 0x40000                           \
122     },                                                     \
123     {                                                      \
124         .apb_index     = NRF_APB_INDEX_LP,                 \
125         DPPI_INSTANCE(30),                                 \
126         .apb_size      = 0x40000                           \
127     },                                                     \
128 }
129 
130 #endif
131 
132 #define NRFX_INTERCONNECT_DPPIC_COUNT      DPPIC_COUNT
133 #define NRFX_INTERCONNECT_DPPIC_PPIB_COUNT PPIB_COUNT
134 #define NRFX_INTERCONNECT_PPIB_COUNT       (NRFX_INTERCONNECT_DPPIC_PPIB_COUNT / 2)
135 
136 #ifdef __cplusplus
137 }
138 #endif
139 
140 #endif // NRFX_INTERCONNECT_DPPIC_PPIB_LUMOS_H__
141