1 /*
2 * Copyright (c) 2012 - 2024, 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 NRF_ECB_H__
35 #define NRF_ECB_H__
36
37 #include <nrfx.h>
38 #ifdef EASYVDMA_PRESENT
39 #include <helpers/nrf_vdma.h>
40 #endif
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 /**
47 * @defgroup nrf_ecb_hal AES ECB encryption HAL
48 * @{
49 * @ingroup nrf_ecb
50 * @brief Hardware access layer (HAL) for managing the Advanced Encryption Standard (AES) Electronic Codebook (ECB) peripheral.
51 */
52
53 #if defined(NRF51) || defined(NRF52832_XXAA) || \
54 defined(ECB_TASKS_STARTECB_TASKS_STARTECB_Msk) || defined(__NRFX_DOXYGEN__)
55 /** @brief Presence of the STARTECB task. */
56 #define NRF_ECB_HAS_TASK_STARTECB 1
57 #else
58 #define NRF_ECB_HAS_TASK_STARTECB 0
59 #endif
60
61 #if defined(ECB_TASKS_START_TASKS_START_Msk) || defined(__NRFX_DOXYGEN__)
62 /** @brief Presence of the START task. */
63 #define NRF_ECB_HAS_TASK_START 1
64 #else
65 #define NRF_ECB_HAS_TASK_START 0
66 #endif
67
68 #if defined(NRF51) || defined(NRF52832_XXAA) || \
69 defined(ECB_TASKS_STOPECB_TASKS_STOPECB_Msk) || defined(__NRFX_DOXYGEN__)
70 /** @brief Presence of the STOPECB task. */
71 #define NRF_ECB_HAS_TASK_STOPECB 1
72 #else
73 #define NRF_ECB_HAS_TASK_STOPECB 0
74 #endif
75
76 #if defined(ECB_TASKS_STOP_TASKS_STOP_Msk) || defined(__NRFX_DOXYGEN__)
77 /** @brief Presence of the STOP task. */
78 #define NRF_ECB_HAS_TASK_STOP 1
79 #else
80 #define NRF_ECB_HAS_TASK_STOP 0
81 #endif
82
83 #if defined(NRF51) || defined(NRF52832_XXAA) || \
84 defined(ECB_EVENTS_ENDECB_EVENTS_ENDECB_Msk) || defined(__NRFX_DOXYGEN__)
85 /** @brief Presence of the ENDECB event. */
86 #define NRF_ECB_HAS_EVENT_ENDECB 1
87 #else
88 #define NRF_ECB_HAS_EVENT_ENDECB 0
89 #endif
90
91 #if defined(ECB_EVENTS_END_EVENTS_END_Msk) || defined(__NRFX_DOXYGEN__)
92 /** @brief Presence of the END event. */
93 #define NRF_ECB_HAS_EVENT_END 1
94 #else
95 #define NRF_ECB_HAS_EVENT_END 0
96 #endif
97
98 #if defined(NRF51) || defined(NRF52832_XXAA) || \
99 defined(ECB_EVENTS_ERRORECB_EVENTS_ERRORECB_Msk) || defined(__NRFX_DOXYGEN__)
100 /** @brief Presence of the ERRORECB event. */
101 #define NRF_ECB_HAS_EVENT_ERRORECB 1
102 #else
103 #define NRF_ECB_HAS_EVENT_ERRORECB 0
104 #endif
105
106 #if defined(ECB_EVENTS_ERROR_EVENTS_ERROR_Msk) || defined(__NRFX_DOXYGEN__)
107 /** @brief Presence of the ERROR event. */
108 #define NRF_ECB_HAS_EVENT_ERROR 1
109 #else
110 #define NRF_ECB_HAS_EVENT_ERROR 0
111 #endif
112
113 #if defined(ECB_KEY_VALUE_VALUE_Msk) || defined(__NRFX_DOXYGEN__)
114 /** @brief Presence of the KEY register. */
115 #define NRF_ECB_HAS_KEY 1
116 #else
117 #define NRF_ECB_HAS_KEY 0
118 #endif
119
120 #if defined(ECB_IN_PTR_PTR_Msk) || defined(__NRFX_DOXYGEN__)
121 /** @brief Presence of the IN.PTR register. */
122 #define NRF_ECB_HAS_IN_PTR 1
123 #else
124 #define NRF_ECB_HAS_IN_PTR 0
125 #endif
126
127 #if defined(ECB_IN_AMOUNT_AMOUNT_Msk) || defined(__NRFX_DOXYGEN__)
128 /** @brief Presence of the IN.AMOUNT register. */
129 #define NRF_ECB_HAS_IN_AMOUNT 1
130 #else
131 #define NRF_ECB_HAS_IN_AMOUNT 0
132 #endif
133
134 #if defined(ECB_OUT_PTR_PTR_Msk) || defined(__NRFX_DOXYGEN__)
135 /** @brief Presence of the OUT.PTR register. */
136 #define NRF_ECB_HAS_OUT_PTR 1
137 #else
138 #define NRF_ECB_HAS_OUT_PTR 0
139 #endif
140
141 #if defined(ECB_OUT_AMOUNT_AMOUNT_Msk) || defined(__NRFX_DOXYGEN__)
142 /** @brief Presence of the OUT.AMOUNT register. */
143 #define NRF_ECB_HAS_OUT_AMOUNT 1
144 #else
145 #define NRF_ECB_HAS_OUT_AMOUNT 0
146 #endif
147
148 #if defined(NRF51) || defined(NRF52832_XXAA) || \
149 defined(ECB_ECBDATAPTR_ECBDATAPTR_Msk) || defined(__NRFX_DOXYGEN__)
150 /** @brief Presence of the ECBDATAPTR register. */
151 #define NRF_ECB_HAS_ECBDATAPTR 1
152 #else
153 #define NRF_ECB_HAS_ECBDATAPTR 0
154 #endif
155
156 /** @brief ECB tasks. */
157 typedef enum
158 {
159 #if NRF_ECB_HAS_TASK_STARTECB
160 NRF_ECB_TASK_STARTECB = offsetof(NRF_ECB_Type, TASKS_STARTECB), /**< Task for starting the ECB block encryption. */
161 #endif
162 #if NRF_ECB_HAS_TASK_START
163 NRF_ECB_TASK_START = offsetof(NRF_ECB_Type, TASKS_START), /**< Task for starting the ECB block encryption. */
164 #endif
165 #if NRF_ECB_HAS_TASK_STOPECB
166 NRF_ECB_TASK_STOPECB = offsetof(NRF_ECB_Type, TASKS_STOPECB), /**< Task for stopping the ECB block encryption. */
167 #endif
168 #if NRF_ECB_HAS_TASK_STOP
169 NRF_ECB_TASK_STOP = offsetof(NRF_ECB_Type, TASKS_STOP), /**< Task for stopping the ECB block encryption. */
170 #endif
171 } nrf_ecb_task_t;
172
173 /** @brief ECB events. */
174 typedef enum
175 {
176 #if NRF_ECB_HAS_EVENT_ENDECB
177 NRF_ECB_EVENT_ENDECB = offsetof(NRF_ECB_Type, EVENTS_ENDECB), /**< ECB block encrypt complete. */
178 #endif
179 #if NRF_ECB_HAS_EVENT_ERRORECB
180 NRF_ECB_EVENT_ERRORECB = offsetof(NRF_ECB_Type, EVENTS_ERRORECB), /**< ECB block encrypt aborted because of a STOPECB task or due to an error. */
181 #endif
182 #if NRF_ECB_HAS_EVENT_END
183 NRF_ECB_EVENT_END = offsetof(NRF_ECB_Type, EVENTS_END), /**< ECB block encrypt complete. */
184 #endif
185 #if NRF_ECB_HAS_EVENT_ERROR
186 NRF_ECB_EVENT_ERROR = offsetof(NRF_ECB_Type, EVENTS_ERROR), /**< ECB block encrypt aborted because of a STOPECB task or due to an error. */
187 #endif
188 } nrf_ecb_event_t;
189
190 /** @brief ECB interrupts. */
191 typedef enum
192 {
193 #if NRF_ECB_HAS_EVENT_ENDECB
194 NRF_ECB_INT_ENDECB_MASK = ECB_INTENSET_ENDECB_Msk, ///< Interrupt on ENDECB event.
195 #endif
196 #if NRF_ECB_HAS_EVENT_ERRORECB
197 NRF_ECB_INT_ERRORECB_MASK = ECB_INTENSET_ERRORECB_Msk, ///< Interrupt on ERRORECB event.
198 #endif
199 #if NRF_ECB_HAS_EVENT_END
200 NRF_ECB_INT_END_MASK = ECB_INTENSET_END_Msk, ///< Interrupt on END event.
201 #endif
202 #if NRF_ECB_HAS_EVENT_ERROR
203 NRF_ECB_INT_ERROR_MASK = ECB_INTENSET_ERROR_Msk, ///< Interrupt on ERROR event.
204 #endif
205 } nrf_ecb_int_mask_t;
206
207
208 /**
209 * @brief Function for activating the specified ECB task.
210 *
211 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
212 * @param[in] task Task to be activated.
213 */
214 NRF_STATIC_INLINE void nrf_ecb_task_trigger(NRF_ECB_Type * p_reg, nrf_ecb_task_t task);
215
216 /**
217 * @brief Function for getting the address of the specified ECB task register.
218 *
219 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
220 * @param[in] task Requested task.
221 *
222 * @return Address of the specified task register.
223 */
224 NRF_STATIC_INLINE uint32_t nrf_ecb_task_address_get(NRF_ECB_Type const * p_reg,
225 nrf_ecb_task_t task);
226
227 /**
228 * @brief Function for clearing the specified ECB event.
229 *
230 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
231 * @param[in] event Event to clear.
232 */
233 NRF_STATIC_INLINE void nrf_ecb_event_clear(NRF_ECB_Type * p_reg, nrf_ecb_event_t event);
234
235 /**
236 * @brief Function for retrieving the state of the ECB event.
237 *
238 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
239 * @param[in] event Event to be checked.
240 *
241 * @retval true The event has been generated.
242 * @retval false The event has not been generated.
243 */
244 NRF_STATIC_INLINE bool nrf_ecb_event_check(NRF_ECB_Type const * p_reg, nrf_ecb_event_t event);
245
246 /**
247 * @brief Function for getting the address of the specified ECB event register.
248 *
249 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
250 * @param[in] event Requested event.
251 *
252 * @return Address of the specified event register.
253 */
254 NRF_STATIC_INLINE uint32_t nrf_ecb_event_address_get(NRF_ECB_Type const * p_reg,
255 nrf_ecb_event_t event);
256
257 /**
258 * @brief Function for enabling the specified interrupts.
259 *
260 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
261 * @param[in] mask Mask of interrupts to be enabled.
262 * Use @ref nrf_ecb_int_mask_t values for bit masking.
263 */
264 NRF_STATIC_INLINE void nrf_ecb_int_enable(NRF_ECB_Type * p_reg, uint32_t mask);
265
266 /**
267 * @brief Function for disabling the specified interrupts.
268 *
269 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
270 * @param[in] mask Mask of interrupts to be disabled.
271 * Use @ref nrf_ecb_int_mask_t values for bit masking.
272 */
273 NRF_STATIC_INLINE void nrf_ecb_int_disable(NRF_ECB_Type * p_reg, uint32_t mask);
274
275 /**
276 * @brief Function for checking if the specified interrupts are enabled.
277 *
278 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
279 * @param[in] mask Mask of interrupts to be checked.
280 * Use @ref nrf_ecb_int_mask_t values for bit masking.
281 *
282 * @return Mask of enabled interrupts.
283 */
284 NRF_STATIC_INLINE uint32_t nrf_ecb_int_enable_check(NRF_ECB_Type const * p_reg, uint32_t mask);
285
286 #if NRF_ECB_HAS_ECBDATAPTR
287 /**
288 * @brief Function for setting the pointer to the ECB data buffer.
289 *
290 * @note The buffer has to be placed in the Data RAM region.
291 * For description of the data structure in this buffer, see the Product Specification.
292 *
293 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
294 * @param[in] p_buffer Pointer to the ECB data buffer.
295 */
296 NRF_STATIC_INLINE void nrf_ecb_data_pointer_set(NRF_ECB_Type * p_reg, void const * p_buffer);
297
298 /**
299 * @brief Function for getting the pointer to the ECB data buffer.
300 *
301 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
302 *
303 * @return Pointer to the ECB data buffer.
304 */
305 NRF_STATIC_INLINE void * nrf_ecb_data_pointer_get(NRF_ECB_Type const * p_reg);
306 #endif // NRF_ECB_HAS_ECBDATAPTR
307
308 #if NRF_ECB_HAS_KEY
309 /**
310 * @brief Function for setting the AES key.
311 *
312 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
313 * @param[in] p_key Pointer to the AES 128-bit key value. The key shall be stored
314 * in big endian byte order.
315 */
316 NRF_STATIC_INLINE void nrf_ecb_key_set(NRF_ECB_Type * p_reg,
317 uint32_t const * p_key);
318 #endif // NRF_ECB_HAS_KEY
319
320 #if NRF_ECB_HAS_IN_PTR
321 /**
322 * @brief Function for setting the pointer to a job list containing unencrypted
323 * ECB data structure in Encryption mode or encrypted ECB data structure
324 * in Decryption mode.
325 *
326 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
327 * @param[in] p_job Pointer to a job list.
328 */
329 NRF_STATIC_INLINE void nrf_ecb_in_ptr_set(NRF_ECB_Type * p_reg,
330 nrf_vdma_job_t const * p_job);
331
332 /**
333 * @brief Function for getting the pointer to job list containing unencrypted
334 * ECB data structure in Encryption mode or encrypted ECB data structure
335 * in Decryption mode.
336 *
337 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
338 *
339 * @return Pointer to a job list.
340 */
341 NRF_STATIC_INLINE nrf_vdma_job_t * nrf_ecb_in_ptr_get(NRF_ECB_Type const * p_reg);
342 #endif // NRF_ECB_HAS_IN_PTR
343
344 #if NRF_ECB_HAS_IN_AMOUNT
345 /**
346 * @brief Function for getting number of bytes read from the input data,
347 * not including the job list structure.
348 *
349 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
350 *
351 * @return Number of bytes read from the input data.
352 */
353 NRF_STATIC_INLINE uint32_t nrf_ecb_in_amount_get(NRF_ECB_Type const * p_reg);
354 #endif // NRF_ECB_HAS_IN_AMOUNT
355
356 #if NRF_ECB_HAS_OUT_PTR
357 /**
358 * @brief Function for setting the pointer to a job list containing encrypted
359 * ECB data structure in Encryption mode or decrypted ECB data structure
360 * in Decryption mode.
361 *
362 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
363 * @param[in] p_job Pointer to a job list.
364 */
365 NRF_STATIC_INLINE void nrf_ecb_out_ptr_set(NRF_ECB_Type * p_reg,
366 nrf_vdma_job_t const * p_job);
367
368 /**
369 * @brief Function for getting the pointer to a job list containing encrypted
370 * ECB data structure in Encryption mode or decrypted ECB data structure
371 * in Decryption mode.
372 *
373 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
374 *
375 * @return Pointer to the job list.
376 */
377 NRF_STATIC_INLINE nrf_vdma_job_t * nrf_ecb_out_ptr_get(NRF_ECB_Type const * p_reg);
378 #endif // NRF_ECB_HAS_OUT_PTR
379
380 #if NRF_ECB_HAS_OUT_AMOUNT
381 /**
382 * @brief Function for getting number of bytes available in the output data,
383 * not including the job list structure.
384 *
385 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
386 *
387 * @return Number of bytes available in the output data.
388 */
389 NRF_STATIC_INLINE uint32_t nrf_ecb_out_amount_get(NRF_ECB_Type const * p_reg);
390 #endif // NRF_ECB_HAS_OUT_AMOUNT
391
392 #if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
393 /**
394 * @brief Function for setting the subscribe configuration for a given
395 * ECB task.
396 *
397 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
398 * @param[in] task Task for which to set the configuration.
399 * @param[in] channel Channel through which to subscribe events.
400 */
401 NRF_STATIC_INLINE void nrf_ecb_subscribe_set(NRF_ECB_Type * p_reg,
402 nrf_ecb_task_t task,
403 uint8_t channel);
404
405 /**
406 * @brief Function for clearing the subscribe configuration for a given
407 * ECB task.
408 *
409 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
410 * @param[in] task Task for which to clear the configuration.
411 */
412 NRF_STATIC_INLINE void nrf_ecb_subscribe_clear(NRF_ECB_Type * p_reg,
413 nrf_ecb_task_t task);
414
415 /**
416 * @brief Function for setting the publish configuration for a given
417 * ECB event.
418 *
419 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
420 * @param[in] event Event for which to set the configuration.
421 * @param[in] channel Channel through which to publish the event.
422 */
423 NRF_STATIC_INLINE void nrf_ecb_publish_set(NRF_ECB_Type * p_reg,
424 nrf_ecb_event_t event,
425 uint8_t channel);
426
427 /**
428 * @brief Function for clearing the publish configuration for a given
429 * ECB event.
430 *
431 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
432 * @param[in] event Event for which to clear the configuration.
433 */
434 NRF_STATIC_INLINE void nrf_ecb_publish_clear(NRF_ECB_Type * p_reg,
435 nrf_ecb_event_t event);
436 #endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
437
438 #ifndef NRF_DECLARE_ONLY
439
nrf_ecb_task_trigger(NRF_ECB_Type * p_reg,nrf_ecb_task_t task)440 NRF_STATIC_INLINE void nrf_ecb_task_trigger(NRF_ECB_Type * p_reg, nrf_ecb_task_t task)
441 {
442 *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
443 }
444
nrf_ecb_task_address_get(NRF_ECB_Type const * p_reg,nrf_ecb_task_t task)445 NRF_STATIC_INLINE uint32_t nrf_ecb_task_address_get(NRF_ECB_Type const * p_reg,
446 nrf_ecb_task_t task)
447 {
448 return ((uint32_t)p_reg + (uint32_t)task);
449 }
450
nrf_ecb_event_clear(NRF_ECB_Type * p_reg,nrf_ecb_event_t event)451 NRF_STATIC_INLINE void nrf_ecb_event_clear(NRF_ECB_Type * p_reg, nrf_ecb_event_t event)
452 {
453 *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
454 nrf_event_readback((uint8_t *)p_reg + (uint32_t)event);
455 }
456
nrf_ecb_event_check(NRF_ECB_Type const * p_reg,nrf_ecb_event_t event)457 NRF_STATIC_INLINE bool nrf_ecb_event_check(NRF_ECB_Type const * p_reg, nrf_ecb_event_t event)
458 {
459 return nrf_event_check(p_reg, event);
460 }
461
nrf_ecb_event_address_get(NRF_ECB_Type const * p_reg,nrf_ecb_event_t event)462 NRF_STATIC_INLINE uint32_t nrf_ecb_event_address_get(NRF_ECB_Type const * p_reg,
463 nrf_ecb_event_t event)
464 {
465 return ((uint32_t)p_reg + (uint32_t)event);
466 }
467
nrf_ecb_int_enable(NRF_ECB_Type * p_reg,uint32_t mask)468 NRF_STATIC_INLINE void nrf_ecb_int_enable(NRF_ECB_Type * p_reg, uint32_t mask)
469 {
470 p_reg->INTENSET = mask;
471 }
472
nrf_ecb_int_disable(NRF_ECB_Type * p_reg,uint32_t mask)473 NRF_STATIC_INLINE void nrf_ecb_int_disable(NRF_ECB_Type * p_reg, uint32_t mask)
474 {
475 p_reg->INTENCLR = mask;
476 }
477
nrf_ecb_int_enable_check(NRF_ECB_Type const * p_reg,uint32_t mask)478 NRF_STATIC_INLINE uint32_t nrf_ecb_int_enable_check(NRF_ECB_Type const * p_reg, uint32_t mask)
479 {
480 return p_reg->INTENSET & mask;
481 }
482
483 #if NRF_ECB_HAS_ECBDATAPTR
nrf_ecb_data_pointer_set(NRF_ECB_Type * p_reg,void const * p_buffer)484 NRF_STATIC_INLINE void nrf_ecb_data_pointer_set(NRF_ECB_Type * p_reg, void const * p_buffer)
485 {
486 p_reg->ECBDATAPTR = (uint32_t)p_buffer;
487 }
488
nrf_ecb_data_pointer_get(NRF_ECB_Type const * p_reg)489 NRF_STATIC_INLINE void * nrf_ecb_data_pointer_get(NRF_ECB_Type const * p_reg)
490 {
491 return (void *)(p_reg->ECBDATAPTR);
492 }
493 #endif // NRF_ECB_HAS_ECBDATAPTR
494
495 #if NRF_ECB_HAS_KEY
nrf_ecb_key_set(NRF_ECB_Type * p_reg,uint32_t const * p_key)496 NRF_STATIC_INLINE void nrf_ecb_key_set(NRF_ECB_Type * p_reg,
497 uint32_t const * p_key)
498 {
499 for (uint8_t i = 0; i < ECB_KEY_VALUE_MaxCount; i++)
500 {
501 p_reg->KEY.VALUE[i] = p_key[i];
502 }
503 }
504 #endif // NRF_ECB_HAS_KEY
505
506 #if NRF_ECB_HAS_IN_PTR
nrf_ecb_in_ptr_set(NRF_ECB_Type * p_reg,nrf_vdma_job_t const * p_job)507 NRF_STATIC_INLINE void nrf_ecb_in_ptr_set(NRF_ECB_Type * p_reg,
508 nrf_vdma_job_t const * p_job)
509 {
510 p_reg->IN.PTR = (uint32_t)p_job;
511 }
512
nrf_ecb_in_ptr_get(NRF_ECB_Type const * p_reg)513 NRF_STATIC_INLINE nrf_vdma_job_t * nrf_ecb_in_ptr_get(NRF_ECB_Type const * p_reg)
514 {
515 return (nrf_vdma_job_t *)(p_reg->IN.PTR);
516 }
517 #endif // NRF_ECB_HAS_IN_PTR
518
519 #if NRF_ECB_HAS_IN_AMOUNT
nrf_ecb_in_amount_get(NRF_ECB_Type const * p_reg)520 NRF_STATIC_INLINE uint32_t nrf_ecb_in_amount_get(NRF_ECB_Type const * p_reg)
521 {
522 return p_reg->IN.AMOUNT;
523 }
524 #endif // NRF_ECB_HAS_IN_AMOUNT
525
526 #if NRF_ECB_HAS_OUT_PTR
nrf_ecb_out_ptr_set(NRF_ECB_Type * p_reg,nrf_vdma_job_t const * p_job)527 NRF_STATIC_INLINE void nrf_ecb_out_ptr_set(NRF_ECB_Type * p_reg,
528 nrf_vdma_job_t const * p_job)
529 {
530 p_reg->OUT.PTR = (uint32_t)p_job;
531 }
532
nrf_ecb_out_ptr_get(NRF_ECB_Type const * p_reg)533 NRF_STATIC_INLINE nrf_vdma_job_t * nrf_ecb_out_ptr_get(NRF_ECB_Type const * p_reg)
534 {
535 return (nrf_vdma_job_t *)(p_reg->OUT.PTR);
536 }
537 #endif // NRF_ECB_HAS_OUT_PTR
538
539 #if NRF_ECB_HAS_OUT_AMOUNT
nrf_ecb_out_amount_get(NRF_ECB_Type const * p_reg)540 NRF_STATIC_INLINE uint32_t nrf_ecb_out_amount_get(NRF_ECB_Type const * p_reg)
541 {
542 return p_reg->OUT.AMOUNT;
543 }
544 #endif // NRF_ECB_HAS_OUT_AMOUNT
545
546 #if defined(DPPI_PRESENT)
nrf_ecb_subscribe_set(NRF_ECB_Type * p_reg,nrf_ecb_task_t task,uint8_t channel)547 NRF_STATIC_INLINE void nrf_ecb_subscribe_set(NRF_ECB_Type * p_reg,
548 nrf_ecb_task_t task,
549 uint8_t channel)
550 {
551 *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
552 ((uint32_t)channel | NRF_SUBSCRIBE_PUBLISH_ENABLE);
553 }
554
nrf_ecb_subscribe_clear(NRF_ECB_Type * p_reg,nrf_ecb_task_t task)555 NRF_STATIC_INLINE void nrf_ecb_subscribe_clear(NRF_ECB_Type * p_reg,
556 nrf_ecb_task_t task)
557 {
558 *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
559 }
560
nrf_ecb_publish_set(NRF_ECB_Type * p_reg,nrf_ecb_event_t event,uint8_t channel)561 NRF_STATIC_INLINE void nrf_ecb_publish_set(NRF_ECB_Type * p_reg,
562 nrf_ecb_event_t event,
563 uint8_t channel)
564 {
565 *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
566 ((uint32_t)channel | NRF_SUBSCRIBE_PUBLISH_ENABLE);
567 }
568
nrf_ecb_publish_clear(NRF_ECB_Type * p_reg,nrf_ecb_event_t event)569 NRF_STATIC_INLINE void nrf_ecb_publish_clear(NRF_ECB_Type * p_reg,
570 nrf_ecb_event_t event)
571 {
572 *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
573 }
574 #endif // defined(DPPI_PRESENT)
575
576 #endif // NRF_DECLARE_ONLY
577
578 /** @} */
579
580 #ifdef __cplusplus
581 }
582 #endif
583
584 #endif // NRF_ECB_H__
585
586