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_APB_H__
35 #define NRFX_INTERCONNECT_APB_H__
36 
37 #include <nrfx.h>
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /**
44  * @defgroup nrfx_interconnect_apb APB bus support
45  * @{
46  * @ingroup nrfx
47  * @brief   Support for APB bus services.
48  */
49 
50 /** @brief APB bus properties structure. */
51 typedef struct {
52     NRF_DPPIC_Type * p_dppi;                 ///< DPPIC peripheral that belongs to given APB.
53     nrfx_atomic_t  * p_dppi_channels;        ///< Pointer to the mask of available DPPI channels.
54     uint32_t         dppi_pub_channels_mask; ///< Mask of configurable DPPI publish channels.
55     uint32_t         dppi_sub_channels_mask; ///< Mask of configurable DPPI subscribe channels.
56     NRF_PPIB_Type  * p_ppib;                 ///< PPIB peripheral that belongs to given APB.
57     size_t           size;                   ///< Size of APB.
58 } nrfx_interconnect_apb_t;
59 
60 
61 /**
62  * @brief Function for getting the domain to which the specified APB bus belongs.
63  *
64  * @param[in] p_apb_prop Pointer to APB properties structure.
65  *
66  * @return Domain that includes the specified APB.
67  */
68 nrf_domain_t nrfx_interconnect_apb_domain_get(nrfx_interconnect_apb_t const * p_apb_prop);
69 
70 /**
71  * @brief Function for getting the main APB interconnection.
72  *
73  * @note In some domains the connection between different APBs is realized via additional
74  *       bus which is called here `main_apb_connection`
75  *
76  * @return Pointer to the properties structure that represents the main APB interconnection.
77  */
78 nrfx_interconnect_apb_t const * nrfx_interconnect_apb_main_get(void);
79 
80 /**
81  * @brief Function for getting APB bus properties structure by address of any peripheral
82  *        that is included in.
83  *
84  * @param[in] addr Address of the peripheral.
85  *
86  * @return Pointer to the properties structure that represents the main APB interconnection
87  *         or NULL if provided address is invalid.
88  */
89 nrfx_interconnect_apb_t const * nrfx_interconnect_apb_get(uint32_t addr);
90 
91 /**
92  * @brief Function for getting number entries for global domain in APB bus properties array.
93  *
94  * @note The number of entries is equal to number of APB buses in global domain which contain
95  *       DPPIC peripheral.
96  *
97  * @return Number of entries in APB properties array.
98  */
99 size_t nrfx_interconnect_apb_global_num_of_get(void);
100 
101 /**
102  * @brief Function for getting APB bus properties structure by index of APB bus properties array.
103  *
104  * @param[in] idx Index of entry in APB bus properties array.
105  *
106  * @return Pointer to the properties structure that represents APB assigned to given index.
107  */
108 nrfx_interconnect_apb_t const * nrf_apb_interconnect_by_idx_global_get(uint8_t idx);
109 
110 /** @} */
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif // NRFX_INTERCONNECT_APB_H__
117