1 /*
2  * Copyright (c) 2024 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Note that the function prototypes are taken from the NRFx HAL
7  */
8 
9 #include <stdint.h>
10 #include <nrfx.h>
11 #if ( (defined(NRFX_RELEASE_VER_AT_LEAST) && NRFX_RELEASE_VER_AT_LEAST(3,10,0)) )
12 #include "hal/nrf_cracen_rng.h"
13 #include "bs_tracing.h"
14 #include "NHW_CRACEN_RNG.h"
15 
nrf_cracen_rng_control_set(NRF_CRACENCORE_Type * p_reg,nrf_cracen_rng_control_t const * p_config)16 void nrf_cracen_rng_control_set(NRF_CRACENCORE_Type *            p_reg,
17                                 nrf_cracen_rng_control_t const * p_config)
18 {
19     p_reg->RNGCONTROL.CONTROL =
20           ((p_config->enable << CRACENCORE_RNGCONTROL_CONTROL_ENABLE_Pos)
21            & CRACENCORE_RNGCONTROL_CONTROL_ENABLE_Msk)
22         | ((p_config->fifo_full_int_en << CRACENCORE_RNGCONTROL_CONTROL_INTENFULL_Pos)
23             & CRACENCORE_RNGCONTROL_CONTROL_INTENFULL_Msk)
24         | ((p_config->soft_reset << CRACENCORE_RNGCONTROL_CONTROL_SOFTRST_Pos)
25             & CRACENCORE_RNGCONTROL_CONTROL_SOFTRST_Msk)
26         | ((p_config->number_128_blocks << CRACENCORE_RNGCONTROL_CONTROL_NB128BITBLOCKS_Pos)
27             & CRACENCORE_RNGCONTROL_CONTROL_NB128BITBLOCKS_Msk);
28     nhw_CRACEN_RNG_regw_sideeffects_CONTROL();
29 }
30 
nrf_cracen_rng_fifo_get(NRF_CRACENCORE_Type const * p_reg)31 uint32_t nrf_cracen_rng_fifo_get(NRF_CRACENCORE_Type const * p_reg)
32 {
33     nhw_CRACEN_RNG_regr_sideeffects_FIFO();
34     return p_reg->RNGCONTROL.FIFO[0];
35 }
36 
37 #endif
38