Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.

Commit 4b31027

Browse files
committed
ccm: Add support for DPPI to CCM
Add use of DPPI to CCM if DPPI is defined. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
1 parent a78614e commit 4b31027

File tree

2 files changed

+100
-1
lines changed

2 files changed

+100
-1
lines changed

src/HW_models/NRF_AES_CCM.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
#include <stdbool.h>
3535
#include "time_machine_if.h"
3636
#include "NRF_HW_model_top.h"
37+
#if defined(PPI_PRESENT)
3738
#include "NRF_PPI.h"
39+
#elif defined(DPPI_PRESENT)
40+
#include "NRF_DPPI.h"
41+
#endif
3842
#include "irq_ctrl.h"
3943
#include "irq_sources.h"
4044
#include "bs_tracing.h"
@@ -180,7 +184,16 @@ static void nrf_ccm_decrypt_rx(bool crc_error) {
180184

181185
static void signal_EVENTS_ENDKSGEN() {
182186
NRF_CCM_regs.EVENTS_ENDKSGEN = 1;
187+
188+
#if !defined(DPPI_PRESENT)
183189
nrf_ppi_event(CCM_EVENTS_ENDKSGEN);
190+
#else
191+
if (NRF_CCM_regs.PUBLISH_ENDKSGEN & CCM_PUBLISH_ENDKSGEN_EN_Msk)
192+
{
193+
uint8_t channel = NRF_CCM_regs.PUBLISH_ENDKSGEN & CCM_PUBLISH_ENDKSGEN_CHIDX_Msk;
194+
nrf_dppi_publish(channel);
195+
}
196+
#endif
184197

185198
if (CCM_INTEN & CCM_INTENSET_ENDKSGEN_Msk) {
186199
hw_irq_ctrl_set_irq(NRF5_IRQ_CCM_AAR_IRQn);
@@ -193,7 +206,16 @@ static void signal_EVENTS_ENDKSGEN() {
193206

194207
static void signal_EVENTS_ENDCRYPT(){
195208
NRF_CCM_regs.EVENTS_ENDCRYPT = 1;
209+
210+
#if !defined(DPPI_PRESENT)
196211
nrf_ppi_event(CCM_EVENTS_ENDCRYPT);
212+
#else
213+
if (NRF_CCM_regs.PUBLISH_ENDCRYPT & CCM_PUBLISH_ENDCRYPT_EN_Msk)
214+
{
215+
uint8_t channel = NRF_CCM_regs.PUBLISH_ENDCRYPT & CCM_PUBLISH_ENDCRYPT_CHIDX_Msk;
216+
nrf_dppi_publish(channel);
217+
}
218+
#endif
197219

198220
if (CCM_INTEN & CCM_INTENSET_ENDCRYPT_Msk) {
199221
hw_irq_ctrl_set_irq(NRF5_IRQ_CCM_AAR_IRQn);
@@ -202,7 +224,16 @@ static void signal_EVENTS_ENDCRYPT(){
202224

203225
/* static void signal_EVENTS_ERROR(){
204226
NRF_CCM_regs.EVENTS_ERROR = 1;
205-
NRF_PPI_Event(CCM_EVENTS_ERROR);
227+
228+
#if !defined(DPPI_PRESENT)
229+
nrf_ppi_event(CCM_EVENTS_ERROR);
230+
#else
231+
if (NRF_CCM_regs.PUBLISH_ERROR & CCM_PUBLISH_ERROR_EN_Msk)
232+
{
233+
uint8_t channel = NRF_CCM_regs.PUBLISH_ERROR & CCM_PUBLISH_ERROR_CHIDX_Msk;
234+
nrf_dppi_publish(channel);
235+
}
236+
#endif
206237
207238
if (CCM_INTEN & CCM_INTENSET_ERROR_Msk) {
208239
hw_irq_ctrl_set_irq(NRF5_IRQ_CCM_AAR_IRQn);

src/nrfx/hal/nrf_ccm.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
#include "hal/nrf_ccm.h"
99
#include "bs_tracing.h"
1010
#include "NRF_AES_CCM.h"
11+
#if defined(DPPI_PRESENT)
12+
#include "NRF_DPPI.h"
13+
#endif
1114

1215
void nrf_ccm_task_trigger(NRF_CCM_Type * p_reg, nrf_ccm_task_t task)
1316
{
@@ -34,3 +37,68 @@ void nrf_ccm_int_disable(NRF_CCM_Type * p_reg, uint32_t mask)
3437
nrf_ccm_regw_sideeffects_INTENCLR();
3538
}
3639

40+
#if defined(DPPI_PRESENT)
41+
42+
void nrf_ccm_subscriber_add(nrf_ccm_task_t task, uint8_t channel)
43+
{
44+
switch(task)
45+
{
46+
case NRF_CCM_TASK_KSGEN:
47+
nrf_dppi_subscriber_add(channel, nrf_ccm_TASK_KSGEN);
48+
break;
49+
case NRF_CCM_TASK_CRYPT:
50+
nrf_dppi_subscriber_add(channel, nrf_ccm_TASK_CRYPT);
51+
break;
52+
case NRF_CCM_TASK_STOP:
53+
nrf_dppi_subscriber_add(channel, nrf_ccm_TASK_STOP);
54+
break;
55+
#if defined(CCM_RATEOVERRIDE_RATEOVERRIDE_Pos) || defined(__NRFX_DOXYGEN__)
56+
case NRF_CCM_TASK_RATEOVERRIDE:
57+
nrf_dppi_subscriber_add(channel, nrf_ccm_TASK_RATEOVERRIDE);
58+
break;
59+
#endif
60+
default:
61+
break;
62+
}
63+
}
64+
65+
void nrf_ccm_subscriber_remove(nrf_ccm_task_t task)
66+
{
67+
switch(task)
68+
{
69+
case NRF_CCM_TASK_KSGEN:
70+
nrf_dppi_subscriber_remove(nrf_ccm_TASK_KSGEN);
71+
break;
72+
case NRF_CCM_TASK_CRYPT:
73+
nrf_dppi_subscriber_remove(nrf_ccm_TASK_CRYPT);
74+
break;
75+
case NRF_CCM_TASK_STOP:
76+
nrf_dppi_subscriber_remove(nrf_ccm_TASK_STOP);
77+
break;
78+
#if defined(CCM_RATEOVERRIDE_RATEOVERRIDE_Pos) || defined(__NRFX_DOXYGEN__)
79+
case NRF_CCM_TASK_RATEOVERRIDE:
80+
nrf_dppi_subscriber_remove(nrf_ccm_TASK_RATEOVERRIDE);
81+
break;
82+
#endif
83+
default:
84+
break;
85+
}
86+
}
87+
88+
void nrf_ccm_subscribe_set(NRF_CCM_Type * p_reg,
89+
nrf_ccm_task_t task,
90+
uint8_t channel)
91+
{
92+
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
93+
((uint32_t)channel | CCM_SUBSCRIBE_KSGEN_EN_Msk);
94+
nrf_ccm_subscriber_add(task, channel);
95+
}
96+
97+
void nrf_ccm_subscribe_clear(NRF_CCM_Type * p_reg,
98+
nrf_ccm_task_t task)
99+
{
100+
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
101+
nrf_ccm_subscriber_remove(task);
102+
}
103+
104+
#endif // defined(DPPI_PRESENT)

0 commit comments

Comments
 (0)