@@ -48,13 +48,41 @@ extern "C" {
48
48
* Random Generator (RNG) peripheral.
49
49
*/
50
50
51
+ #if defined(CRACENCORE_RNGCONTROL_SWOFFTMRVAL_ResetValue ) || defined(__NRFX_DOXYGEN__ )
52
+ /** @brief Symbol indicating whether the TRNG FSM has an idle timer */
53
+ #define NRF_CRACEN_RNG_HAS_IDLETIMER 1
54
+ #else
55
+ #define NRF_CRACEN_RNG_HAS_IDLETIMER 0
56
+ #endif
57
+
58
+ #if defined(CRACENCORE_RNGCONTROL_CONTROL_BLENDINGMETHOD_Pos ) || defined(__NRFX_DOXYGEN__ )
59
+ /** @brief Symbol indicating whether the TRNG has entropy blending */
60
+ #define NRF_CRACEN_RNG_HAS_BLENDING 1
61
+ #else
62
+ #define NRF_CRACEN_RNG_HAS_BLENDING 0
63
+ #endif
64
+
65
+ #if NRF_CRACEN_RNG_HAS_BLENDING
66
+ /** @brief CRACEN entropy blending methods */
67
+ typedef enum
68
+ {
69
+ NRF_CRACEN_RNG_BLENDINGMETHOD_CONCATENATION = CRACENCORE_RNGCONTROL_CONTROL_BLENDINGMETHOD_CONCATENATION , /**< Collate all rings oscillators outputs */
70
+ NRF_CRACEN_RNG_BLENDINGMETHOD_XORLEVEL1 = CRACENCORE_RNGCONTROL_CONTROL_BLENDINGMETHOD_XORLEVEL1 , /**< XOR bits inside each ring oscillator set */
71
+ NRF_CRACEN_RNG_BLENDINGMETHOD_XORLEVEL2 = CRACENCORE_RNGCONTROL_CONTROL_BLENDINGMETHOD_XORLEVEL2 , /**< Also XOR bits in-between ring oscillator sets */
72
+ NRF_CRACEN_RNG_BLENDINGMETHOD_VONNEUMANN = CRACENCORE_RNGCONTROL_CONTROL_BLENDINGMETHOD_VONNEUMANN , /**< VON-NEUMANN debiasing */
73
+ } nrf_cracen_rng_blending_methods_t ;
74
+ #endif
75
+
51
76
/** @brief CRACEN random generator configuration */
52
77
typedef struct
53
78
{
54
- bool enable ; /**< Enable the RNG peripheral */
55
- bool fifo_full_int_en ; /**< Enable FIFO full interrupt */
56
- bool soft_reset ; /**< Soft reset the RNG peripheral */
57
- uint8_t number_128_blocks ; /**< Number of 128bit blocks used for AES conditioning. Must be at least 1 */
79
+ bool enable ; /**< Enable the RNG peripheral */
80
+ bool fifo_full_int_en ; /**< Enable FIFO full interrupt */
81
+ bool soft_reset ; /**< Soft reset the RNG peripheral */
82
+ uint8_t number_128_blocks ; /**< Number of 128bit blocks used for AES conditioning. Must be at least 1 */
83
+ #if NRF_CRACEN_RNG_HAS_BLENDING
84
+ nrf_cracen_rng_blending_methods_t blending_method ; /**< Which blending method to use */
85
+ #endif
58
86
} nrf_cracen_rng_control_t ;
59
87
60
88
/** @brief CRACEN random generator FSM state */
@@ -63,7 +91,9 @@ typedef enum
63
91
NRF_CRACEN_RNG_FSM_STATE_RESET = CRACENCORE_RNGCONTROL_STATUS_STATE_RESET , /**< RNG is not started */
64
92
NRF_CRACEN_RNG_FSM_STATE_STARTUP = CRACENCORE_RNGCONTROL_STATUS_STATE_STARTUP , /**< RNG is starting */
65
93
NRF_CRACEN_RNG_FSM_STATE_IDLE_READY = CRACENCORE_RNGCONTROL_STATUS_STATE_IDLERON , /**< RNG is idle, and ready to produce more data */
94
+ #if NRF_CRACEN_RNG_HAS_IDLETIMER
66
95
NRF_CRACEN_RNG_FSM_STATE_IDLE_STANDBY = CRACENCORE_RNGCONTROL_STATUS_STATE_IDLEROFF , /**< RNG is idle, with the ring oscillators off */
96
+ #endif
67
97
NRF_CRACEN_RNG_FSM_STATE_FILL_FIFO = CRACENCORE_RNGCONTROL_STATUS_STATE_FILLFIFO , /**< RNG is filling the FIFO with entropy */
68
98
NRF_CRACEN_RNG_FSM_STATE_ERROR = CRACENCORE_RNGCONTROL_STATUS_STATE_ERROR , /**< RNG has halted on an error. Reset is needed */
69
99
} nrf_cracen_rng_fsm_state_t ;
@@ -119,6 +149,7 @@ nrf_cracen_rng_fsm_state_t nrf_cracen_rng_fsm_state_get(NRF_CRACENCORE_Type cons
119
149
NRF_STATIC_INLINE void nrf_cracen_rng_init_wait_val_set (NRF_CRACENCORE_Type * p_reg ,
120
150
uint16_t value );
121
151
152
+ #if NRF_CRACEN_RNG_HAS_IDLETIMER
122
153
/**
123
154
* @brief Function for setting the switch off timer value
124
155
*
@@ -127,6 +158,7 @@ NRF_STATIC_INLINE void nrf_cracen_rng_init_wait_val_set(NRF_CRACENCORE_Type * p_
127
158
*/
128
159
NRF_STATIC_INLINE void nrf_cracen_rng_off_timer_set (NRF_CRACENCORE_Type * p_reg ,
129
160
uint16_t value );
161
+ #endif
130
162
131
163
/**
132
164
* @brief Function for setting the entropy subsampling rate register
@@ -137,7 +169,7 @@ NRF_STATIC_INLINE void nrf_cracen_rng_off_timer_set(NRF_CRACENCORE_Type * p_reg,
137
169
* @param[in] value Value to be written in the register.
138
170
*/
139
171
NRF_STATIC_INLINE void nrf_cracen_rng_clk_div_set (NRF_CRACENCORE_Type * p_reg ,
140
- uint8_t value );
172
+ uint16_t value );
141
173
142
174
/**
143
175
* @brief Function for getting a word from the entropy FIFO
@@ -163,6 +195,10 @@ NRF_STATIC_INLINE void nrf_cracen_rng_control_set(NRF_CRACENCORE_Type *
163
195
& CRACENCORE_RNGCONTROL_CONTROL_INTENFULL_Msk )
164
196
| ((p_config -> soft_reset << CRACENCORE_RNGCONTROL_CONTROL_SOFTRST_Pos )
165
197
& CRACENCORE_RNGCONTROL_CONTROL_SOFTRST_Msk )
198
+ #if NRF_CRACEN_RNG_HAS_BLENDING
199
+ | ((p_config -> blending_method << CRACENCORE_RNGCONTROL_CONTROL_BLENDINGMETHOD_Pos )
200
+ & CRACENCORE_RNGCONTROL_CONTROL_BLENDINGMETHOD_Msk )
201
+ #endif
166
202
| ((p_config -> number_128_blocks << CRACENCORE_RNGCONTROL_CONTROL_NB128BITBLOCKS_Pos )
167
203
& CRACENCORE_RNGCONTROL_CONTROL_NB128BITBLOCKS_Msk );
168
204
}
@@ -189,19 +225,29 @@ nrf_cracen_rng_fsm_state_t nrf_cracen_rng_fsm_state_get(NRF_CRACENCORE_Type cons
189
225
NRF_STATIC_INLINE void nrf_cracen_rng_init_wait_val_set (NRF_CRACENCORE_Type * p_reg ,
190
226
uint16_t value )
191
227
{
228
+ #if defined(CRACENCORE_RNGCONTROL_INITWAITVAL_ResetValue )
192
229
p_reg -> RNGCONTROL .INITWAITVAL = value ;
230
+ #else
231
+ p_reg -> RNGCONTROL .WARMUPPERIOD = value ;
232
+ #endif
193
233
}
194
234
235
+ #if NRF_CRACEN_RNG_HAS_IDLETIMER
195
236
NRF_STATIC_INLINE void nrf_cracen_rng_off_timer_set (NRF_CRACENCORE_Type * p_reg ,
196
237
uint16_t value )
197
238
{
198
239
p_reg -> RNGCONTROL .SWOFFTMRVAL = value ;
199
240
}
241
+ #endif
200
242
201
243
NRF_STATIC_INLINE void nrf_cracen_rng_clk_div_set (NRF_CRACENCORE_Type * p_reg ,
202
- uint8_t value )
244
+ uint16_t value )
203
245
{
246
+ #if defined(CRACENCORE_RNGCONTROL_CLKDIV_ResetValue )
204
247
p_reg -> RNGCONTROL .CLKDIV = value ;
248
+ #else
249
+ p_reg -> RNGCONTROL .SAMPLINGPERIOD = value ;
250
+ #endif
205
251
}
206
252
207
253
NRF_STATIC_INLINE uint32_t nrf_cracen_rng_fifo_get (NRF_CRACENCORE_Type const * p_reg )
0 commit comments