|
8 | 8 | #include "hal/nrf_rng.h" |
9 | 9 | #include "bs_tracing.h" |
10 | 10 | #include "NRF_RNG.h" |
| 11 | +#if defined(DPPI_PRESENT) |
| 12 | +#include "NRF_DPPI.h" |
| 13 | +#endif |
11 | 14 |
|
12 | 15 | void nrf_rng_task_trigger(NRF_RNG_Type * p_reg, nrf_rng_task_t rng_task) |
13 | 16 | { |
@@ -35,3 +38,52 @@ void nrf_rng_int_disable(NRF_RNG_Type * p_reg, uint32_t mask) |
35 | 38 | NRF_RNG_regs.INTENCLR = mask; |
36 | 39 | nrf_rng_regw_sideeffects_INTENCLEAR(); |
37 | 40 | } |
| 41 | + |
| 42 | +#if defined(DPPI_PRESENT) |
| 43 | +void nrf_rng_subscriber_add(nrf_rng_task_t task, uint8_t channel) |
| 44 | +{ |
| 45 | + switch(task) |
| 46 | + { |
| 47 | + case NRF_RNG_TASK_START: |
| 48 | + nrf_dppi_subscriber_add(channel, nrf_rng_task_start); |
| 49 | + break; |
| 50 | + case NRF_RNG_TASK_STOP: |
| 51 | + nrf_dppi_subscriber_add(channel, nrf_rng_task_stop); |
| 52 | + break; |
| 53 | + default: |
| 54 | + break; |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +void nrf_rng_subscriber_remove(nrf_rng_task_t task) |
| 59 | +{ |
| 60 | + switch(task) |
| 61 | + { |
| 62 | + case NRF_RNG_TASK_START: |
| 63 | + nrf_dppi_subscriber_remove(nrf_rng_task_start); |
| 64 | + break; |
| 65 | + case NRF_RNG_TASK_STOP: |
| 66 | + nrf_dppi_subscriber_remove(nrf_rng_task_stop); |
| 67 | + break; |
| 68 | + default: |
| 69 | + break; |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | +void nrf_rng_subscribe_set(NRF_RNG_Type * p_reg, |
| 74 | + nrf_rng_task_t task, |
| 75 | + uint8_t channel) |
| 76 | +{ |
| 77 | + *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = |
| 78 | + ((uint32_t)channel | RNG_SUBSCRIBE_START_EN_Msk); |
| 79 | + nrf_rng_subscriber_add(task, channel); |
| 80 | +} |
| 81 | + |
| 82 | + |
| 83 | +void nrf_rng_subscribe_clear(NRF_RNG_Type * p_reg, |
| 84 | + nrf_rng_task_t task) |
| 85 | +{ |
| 86 | + *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0; |
| 87 | + nrf_rng_subscriber_remove(task); |
| 88 | +} |
| 89 | +#endif // defined(DPPI_PRESENT) |
0 commit comments