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 "hal/nrf_cracen.h"
11 #include "bs_tracing.h"
12 #include "NHW_CRACEN_wrap.h"
13 
nrf_cracen_int_enable(NRF_CRACEN_Type * p_reg,uint32_t mask)14 void nrf_cracen_int_enable(NRF_CRACEN_Type * p_reg, uint32_t mask)
15 {
16   p_reg->INTENSET = mask;
17   nhw_CRACEN_regw_sideeffects_INTENSET(0);
18 }
19 
nrf_cracen_int_disable(NRF_CRACEN_Type * p_reg,uint32_t mask)20 void nrf_cracen_int_disable(NRF_CRACEN_Type * p_reg, uint32_t mask)
21 {
22   p_reg->INTENCLR = mask;
23   nhw_CRACEN_regw_sideeffects_INTENCLR(0);
24 }
25 
nrf_cracen_event_clear(NRF_CRACEN_Type * p_reg,nrf_cracen_event_t event)26 void nrf_cracen_event_clear(NRF_CRACEN_Type *  p_reg,
27                             nrf_cracen_event_t event)
28 {
29   *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0;
30   if (event == NRF_CRACEN_EVENT_CRYPTOMASTER) {
31     nhw_CRACEN_regw_sideeffects_EVENTS_CRYPTOMASTER();
32   } else if (event == NRF_CRACEN_EVENT_RNG) {
33     nhw_CRACEN_regw_sideeffects_EVENTS_RNG();
34   } else if (event == NRF_CRACEN_EVENT_PKE_IKG) {
35     nhw_CRACEN_regw_sideeffects_EVENTS_PKEIKG();
36   } else {
37     bs_trace_error_time_line("Attempted to clear unknown event %i\n", event);
38   }
39 }
40