37
37
#include <nrfx.h>
38
38
#include <haly/nrfy_dppi.h>
39
39
40
+ /* On devices with single instance (with no ID) use instance 0. */
41
+ #if defined(NRF_DPPIC ) && defined(NRFX_DPPI_ENABLED ) && !defined(NRFX_DPPI0_ENABLED )
42
+ #define NRFX_DPPI0_ENABLED 1
43
+ #endif
44
+
40
45
/**
41
46
* @defgroup nrfx_dppi DPPI allocator
42
47
* @{
43
48
* @ingroup nrf_dppi
44
49
* @brief Distributed Programmable Peripheral Interconnect (DPPI) allocator.
45
50
*/
46
51
52
+ /** @brief Data structure of the Distributed programmable peripheral interconnect (DPPI) driver instance. */
53
+ typedef struct
54
+ {
55
+ NRF_DPPIC_Type * p_reg ; ///< Pointer to a structure containing DPPIC registers.
56
+ uint8_t drv_inst_idx ; ///< Index of the driver instance. For internal use only.
57
+ } nrfx_dppi_t ;
58
+
59
+ #ifndef __NRFX_DOXYGEN__
60
+ enum {
61
+ /* List all enabled driver instances (in the format NRFX_\<instance_name\>_INST_IDX). */
62
+ NRFX_INSTANCE_ENUM_LIST (DPPI )
63
+ NRFX_DPPI_ENABLED_COUNT
64
+ };
65
+ #endif
66
+
67
+ /** @brief Macro for creating an instance of the DPPIC driver. */
68
+ #define NRFX_DPPI_INSTANCE (id ) \
69
+ { \
70
+ .p_reg = NRFX_CONCAT(NRF_, DPPIC, id), \
71
+ .drv_inst_idx = NRFX_CONCAT(NRFX_DPPI, id, _INST_IDX), \
72
+ }
73
+
47
74
#ifdef __cplusplus
48
75
extern "C" {
49
76
#endif
50
77
51
- /** @brief Function for freeing all allocated channels and groups. */
52
- void nrfx_dppi_free (void );
78
+ #if NRFX_API_VER_AT_LEAST (3 , 8 , 0 ) || defined(__NRFX_DOXYGEN__ )
79
+
80
+ /**
81
+ * @brief Function for freeing all allocated channels and groups.
82
+ *
83
+ * @param[in] p_instance Pointer to the driver instance structure.
84
+ */
85
+ void nrfx_dppi_free (nrfx_dppi_t const * p_instance );
53
86
54
87
/**
55
88
* @brief Function for allocating a DPPI channel.
56
89
* @details This function allocates the first unused DPPI channel.
57
90
*
58
91
* @note Function is thread safe as it uses @ref nrfx_flag32_alloc.
59
92
*
60
- * @param[out] p_channel Pointer to the DPPI channel number that has been allocated.
93
+ * @param[in] p_instance Pointer to the driver instance structure.
94
+ * @param[out] p_channel Pointer to the DPPI channel number that has been allocated.
61
95
*
62
96
* @retval NRFX_SUCCESS The channel was successfully allocated.
63
97
* @retval NRFX_ERROR_NO_MEM There is no available channel to be used.
64
98
*/
65
- nrfx_err_t nrfx_dppi_channel_alloc (uint8_t * p_channel );
99
+ nrfx_err_t nrfx_dppi_channel_alloc (nrfx_dppi_t const * p_instance , uint8_t * p_channel );
66
100
67
101
/**
68
102
* @brief Function for freeing a DPPI channel.
@@ -71,125 +105,181 @@ nrfx_err_t nrfx_dppi_channel_alloc(uint8_t * p_channel);
71
105
*
72
106
* @note Function is thread safe as it uses @ref nrfx_flag32_free.
73
107
*
74
- * @param[in] channel DPPI channel to be freed.
108
+ * @param[in] p_instance Pointer to the driver instance structure.
109
+ * @param[in] channel DPPI channel to be freed.
75
110
*
76
111
* @retval NRFX_SUCCESS The channel was successfully freed.
77
112
* @retval NRFX_ERROR_INVALID_PARAM The specified channel is not allocated.
78
113
*/
79
- nrfx_err_t nrfx_dppi_channel_free (uint8_t channel );
114
+ nrfx_err_t nrfx_dppi_channel_free (nrfx_dppi_t const * p_instance , uint8_t channel );
80
115
81
116
/**
82
117
* @brief Function for enabling a DPPI channel.
83
118
*
84
- * @param[in] channel DPPI channel to be enabled.
119
+ * @param[in] p_instance Pointer to the driver instance structure.
120
+ * @param[in] channel DPPI channel to be enabled.
85
121
*
86
122
* @retval NRFX_SUCCESS The channel was successfully enabled.
87
123
* @retval NRFX_ERROR_INVALID_PARAM The specified channel is not allocated.
88
124
*/
89
- nrfx_err_t nrfx_dppi_channel_enable (uint8_t channel );
125
+ nrfx_err_t nrfx_dppi_channel_enable (nrfx_dppi_t const * p_instance , uint8_t channel );
90
126
91
127
/**
92
128
* @brief Function for disabling a DPPI channel.
93
129
*
94
130
* @note Disabling channel does not modify PUBLISH/SUBSCRIBE registers configured to use
95
131
* that channel.
96
132
*
97
- * @param[in] channel DPPI channel to be disabled.
133
+ * @param[in] p_instance Pointer to the driver instance structure.
134
+ * @param[in] channel DPPI channel to be disabled.
98
135
*
99
136
* @retval NRFX_SUCCESS The channel was successfully disabled.
100
137
* @retval NRFX_ERROR_INVALID_PARAM The specified channel is not allocated.
101
138
*/
102
- nrfx_err_t nrfx_dppi_channel_disable (uint8_t channel );
139
+ nrfx_err_t nrfx_dppi_channel_disable (nrfx_dppi_t const * p_instance , uint8_t channel );
103
140
104
141
/**
105
142
* @brief Function for allocating a DPPI channel group.
106
143
* @details This function allocates the first unused DPPI group.
107
144
*
108
145
* @note Function is thread safe as it uses @ref nrfx_flag32_alloc.
109
146
*
110
- * @param[out] p_group Pointer to the DPPI channel group that has been allocated.
147
+ * @param[in] p_instance Pointer to the driver instance structure.
148
+ * @param[out] p_group Pointer to the DPPI channel group that has been allocated.
111
149
*
112
150
* @retval NRFX_SUCCESS The channel group was successfully allocated.
113
151
* @retval NRFX_ERROR_NO_MEM There is no available channel group to be used.
114
152
*/
115
- nrfx_err_t nrfx_dppi_group_alloc (nrf_dppi_channel_group_t * p_group );
153
+ nrfx_err_t nrfx_dppi_group_alloc (nrfx_dppi_t const * p_instance ,
154
+ nrf_dppi_channel_group_t * p_group );
116
155
117
156
/**
118
157
* @brief Function for freeing a DPPI channel group.
119
158
* @details This function also disables the chosen group.
120
159
*
121
160
* @note Function is thread safe as it uses @ref nrfx_flag32_free.
122
161
*
123
- * @param[in] group DPPI channel group to be freed.
162
+ * @param[in] p_instance Pointer to the driver instance structure.
163
+ * @param[in] group DPPI channel group to be freed.
124
164
*
125
165
* @retval NRFX_SUCCESS The channel group was successfully freed.
126
166
* @retval NRFX_ERROR_INVALID_PARAM The specified group is not allocated.
127
167
*/
128
- nrfx_err_t nrfx_dppi_group_free (nrf_dppi_channel_group_t group );
168
+ nrfx_err_t nrfx_dppi_group_free (nrfx_dppi_t const * p_instance , nrf_dppi_channel_group_t group );
129
169
130
170
/**
131
171
* @brief Function for including a DPPI channel in a channel group.
132
172
*
133
- * @param[in] channel DPPI channel to be added.
134
- * @param[in] group Channel group in which to include the channel.
173
+ * @param[in] p_instance Pointer to the driver instance structure.
174
+ * @param[in] channel DPPI channel to be added.
175
+ * @param[in] group Channel group in which to include the channel.
135
176
*
136
177
* @warning Channel group configuration can be modified only if subscriptions for tasks
137
178
* associated with this group are disabled.
138
179
*
139
180
* @retval NRFX_SUCCESS The channel was successfully included.
140
181
* @retval NRFX_ERROR_INVALID_PARAM The specified group or channel is not allocated.
141
182
*/
142
- nrfx_err_t nrfx_dppi_channel_include_in_group (uint8_t channel ,
183
+ nrfx_err_t nrfx_dppi_channel_include_in_group (nrfx_dppi_t const * p_instance ,
184
+ uint8_t channel ,
143
185
nrf_dppi_channel_group_t group );
144
186
145
187
/**
146
188
* @brief Function for removing a DPPI channel from a channel group.
147
189
*
148
- * @param[in] channel DPPI channel to be removed.
149
- * @param[in] group Channel group from which to remove the channel.
190
+ * @param[in] p_instance Pointer to the driver instance structure.
191
+ * @param[in] channel DPPI channel to be removed.
192
+ * @param[in] group Channel group from which to remove the channel.
150
193
*
151
194
* @warning Channel group configuration can be modified only if subscriptions for tasks
152
195
* associated with this group are disabled.
153
196
*
154
197
* @retval NRFX_SUCCESS The channel was successfully removed.
155
198
* @retval NRFX_ERROR_INVALID_PARAM The specified group or channel is not allocated.
156
199
*/
157
- nrfx_err_t nrfx_dppi_channel_remove_from_group (uint8_t channel ,
200
+ nrfx_err_t nrfx_dppi_channel_remove_from_group (nrfx_dppi_t const * p_instance ,
201
+ uint8_t channel ,
158
202
nrf_dppi_channel_group_t group );
159
203
160
204
/**
161
205
* @brief Function for clearing a DPPI channel group.
162
206
*
163
- * @param[in] group Channel group to be cleared.
207
+ * @param[in] p_instance Pointer to the driver instance structure.
208
+ * @param[in] group Channel group to be cleared.
164
209
*
165
210
* @warning Channel group configuration can be modified only if subscriptions for tasks
166
211
* associated with this group are disabled.
167
212
*
168
213
* @retval NRFX_SUCCESS The group was successfully cleared.
169
214
* @retval NRFX_ERROR_INVALID_PARAM The specified group is not allocated.
170
215
*/
171
- nrfx_err_t nrfx_dppi_group_clear (nrf_dppi_channel_group_t group );
216
+ nrfx_err_t nrfx_dppi_group_clear (nrfx_dppi_t const * p_instance , nrf_dppi_channel_group_t group );
172
217
173
218
/**
174
219
* @brief Function for enabling a DPPI channel group.
175
220
*
176
- * @param[in] group Channel group to be enabled.
221
+ * @param[in] p_instance Pointer to the driver instance structure.
222
+ * @param[in] group Channel group to be enabled.
177
223
*
178
224
* @retval NRFX_SUCCESS The group was successfully enabled.
179
225
* @retval NRFX_ERROR_INVALID_PARAM The specified group is not allocated.
180
226
*/
181
- nrfx_err_t nrfx_dppi_group_enable (nrf_dppi_channel_group_t group );
227
+ nrfx_err_t nrfx_dppi_group_enable (nrfx_dppi_t const * p_instance ,
228
+ nrf_dppi_channel_group_t group );
182
229
183
230
/**
184
231
* @brief Function for disabling a DPPI channel group.
185
232
*
186
- * @param[in] group Channel group to be disabled.
233
+ * @param[in] p_instance Pointer to the driver instance structure.
234
+ * @param[in] group Channel group to be disabled.
187
235
*
188
236
* @retval NRFX_SUCCESS The group was successfully disabled.
189
237
* @retval NRFX_ERROR_INVALID_PARAM The specified group is not allocated.
190
238
*/
239
+ nrfx_err_t nrfx_dppi_group_disable (nrfx_dppi_t const * p_instance ,
240
+ nrf_dppi_channel_group_t group );
241
+
242
+ #else
243
+
244
+ #if !defined(NRF_DPPIC_INDEX )
245
+ /* Choose the instance to use in case of using deprecated single-instance driver variant. */
246
+ #if defined(HALTIUM_XXAA )
247
+ #define NRF_DPPIC_INDEX 130
248
+ #elif defined(LUMOS_XXAA )
249
+ #define NRF_DPPIC_INDEX 20
250
+ #else
251
+ #define NRF_DPPIC_INDEX 0
252
+ #endif
253
+ #endif
254
+
255
+ void nrfx_dppi_free (void );
256
+
257
+ nrfx_err_t nrfx_dppi_channel_alloc (uint8_t * p_channel );
258
+
259
+ nrfx_err_t nrfx_dppi_channel_free (uint8_t channel );
260
+
261
+ nrfx_err_t nrfx_dppi_channel_enable (uint8_t channel );
262
+
263
+ nrfx_err_t nrfx_dppi_channel_disable (uint8_t channel );
264
+
265
+ nrfx_err_t nrfx_dppi_group_alloc (nrf_dppi_channel_group_t * p_group );
266
+
267
+ nrfx_err_t nrfx_dppi_group_free (nrf_dppi_channel_group_t group );
268
+
269
+ nrfx_err_t nrfx_dppi_channel_include_in_group (uint8_t channel ,
270
+ nrf_dppi_channel_group_t group );
271
+
272
+ nrfx_err_t nrfx_dppi_channel_remove_from_group (uint8_t channel ,
273
+ nrf_dppi_channel_group_t group );
274
+
275
+ nrfx_err_t nrfx_dppi_group_clear (nrf_dppi_channel_group_t group );
276
+
277
+ nrfx_err_t nrfx_dppi_group_enable (nrf_dppi_channel_group_t group );
278
+
191
279
nrfx_err_t nrfx_dppi_group_disable (nrf_dppi_channel_group_t group );
192
280
281
+ #endif
282
+
193
283
/** @} */
194
284
195
285
#ifdef __cplusplus
0 commit comments