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

Commit 5d85a21

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

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

src/HW_models/NRF_AES_ECB.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66
#include "NRF_AES_ECB.h"
7+
#if defined(PPI_PRESENT)
78
#include "NRF_PPI.h"
9+
#elif defined(DPPI_PRESENT)
10+
#include "NRF_DPPI.h"
11+
#endif
812
#include <string.h>
913
#include <stdbool.h>
1014
#include <stdint.h>
@@ -46,7 +50,15 @@ void nrf_aes_ecb_clean_up(){
4650

4751
static void signal_ENDECB(){
4852
NRF_ECB_regs.EVENTS_ENDECB = 1;
53+
#if defined(PPI_PRESENT)
4954
nrf_ppi_event(ECB_EVENTS_ENDECB);
55+
#elif defined(DPPI_PRESENT)
56+
if (NRF_ECB_regs.PUBLISH_ENDECB & ECB_PUBLISH_ENDECB_EN_Msk)
57+
{
58+
uint8_t channel = NRF_ECB_regs.PUBLISH_ENDECB & ECB_PUBLISH_ENDECB_CHIDX_Msk;
59+
nrf_dppi_publish(channel);
60+
}
61+
#endif
5062

5163
if (ECB_INTEN & ECB_INTENSET_ENDECB_Msk){
5264
hw_irq_ctrl_set_irq(NRF5_IRQ_ECB_IRQn);
@@ -55,7 +67,15 @@ static void signal_ENDECB(){
5567

5668
static void signal_ERRORECB(){
5769
NRF_ECB_regs.EVENTS_ERRORECB = 1;
70+
#if defined(PPI_PRESENT)
5871
nrf_ppi_event(ECB_EVENTS_ERRORECB);
72+
#elif defined(DPPI_PRESENT)
73+
if (NRF_ECB_regs.PUBLISH_ERRORECB & ECB_PUBLISH_ERRORECB_EN_Msk)
74+
{
75+
uint8_t channel = NRF_ECB_regs.PUBLISH_ERRORECB & ECB_PUBLISH_ERRORECB_CHIDX_Msk;
76+
nrf_dppi_publish(channel);
77+
}
78+
#endif
5979

6080
if (ECB_INTEN & ECB_INTENSET_ERRORECB_Msk){
6181
hw_irq_ctrl_set_irq(NRF5_IRQ_ECB_IRQn);

src/HW_models/NRF_AES_ECB.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ extern "C"{
1414

1515
void nrf_aes_ecb_init();
1616
void nrf_aes_ecb_clean_up();
17+
void nrf_ecb_TASK_STOPECB();
18+
void nrf_ecb_TASK_STARTECB();
1719
void nrf_ecb_timer_triggered();
1820
void nrf_ecb_regw_sideeffects_INTENSET();
1921
void nrf_ecb_regw_sideeffects_INTENCLEAR();

src/nrfx/hal/nrf_ecb.c

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

1215
void nrf_ecb_task_trigger(NRF_ECB_Type * p_reg, nrf_ecb_task_t task)
1316
{
@@ -34,3 +37,52 @@ void nrf_ecb_int_disable(NRF_ECB_Type * p_reg, uint32_t mask)
3437
p_reg->INTENCLR = mask;
3538
nrf_ecb_regw_sideeffects_INTENCLEAR();
3639
}
40+
41+
#if defined(DPPI_PRESENT)
42+
void nrf_ecb_subscriber_add(nrf_ecb_task_t task, uint8_t channel)
43+
{
44+
switch(task)
45+
{
46+
case NRF_ECB_TASK_STARTECB:
47+
nrf_dppi_subscriber_add(channel, NRF_ECB_TASK_STARTECB);
48+
break;
49+
case NRF_ECB_TASK_STOPECB:
50+
nrf_dppi_subscriber_add(channel, nrf_ecb_TASK_STOPECB);
51+
break;
52+
default:
53+
break;
54+
}
55+
}
56+
57+
void nrf_ecb_subscriber_remove(nrf_ecb_task_t task)
58+
{
59+
switch(task)
60+
{
61+
case NRF_ECB_TASK_STARTECB:
62+
nrf_dppi_subscriber_remove(nrf_ecb_TASK_STARTECB);
63+
break;
64+
case NRF_ECB_TASK_STOPECB:
65+
nrf_dppi_subscriber_remove(nrf_ecb_TASK_STOPECB);
66+
break;
67+
default:
68+
break;
69+
}
70+
}
71+
72+
void nrf_ecb_subscribe_set(NRF_ECB_Type * p_reg,
73+
nrf_ecb_task_t task,
74+
uint8_t channel)
75+
{
76+
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
77+
((uint32_t)channel | ECB_SUBSCRIBE_STARTECB_EN_Msk);
78+
nrf_ecb_subscriber_add(task, channel);
79+
}
80+
81+
void nrf_ecb_subscribe_clear(NRF_ECB_Type * p_reg,
82+
nrf_ecb_task_t task)
83+
{
84+
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
85+
nrf_ecb_subscriber_remove(task);
86+
}
87+
88+
#endif // defined(DPPI_PRESENT)

0 commit comments

Comments
 (0)