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

Commit a78614e

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

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

src/HW_models/NRF_AAR.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
#include <stdbool.h>
1313
#include "time_machine_if.h"
1414
#include "NRF_HW_model_top.h"
15+
#if defined(PPI_PRESENT)
1516
#include "NRF_PPI.h"
17+
#elif defined(DPPI_PRESENT)
18+
#include "NRF_DPPI.h"
19+
#endif
1620
#include "irq_ctrl.h"
1721
#include "irq_sources.h"
1822
#include "bs_tracing.h"
@@ -40,7 +44,16 @@ static int nrf_aar_resolve(int *good_irk);
4044

4145
static void signal_EVENTS_END(){
4246
NRF_AAR_regs.EVENTS_END = 1;
47+
48+
#if !defined(DPPI_PRESENT)
4349
nrf_ppi_event(AAR_EVENTS_END);
50+
#else
51+
if (NRF_AAR_regs.PUBLISH_END & AAR_PUBLISH_END_EN_Msk)
52+
{
53+
uint8_t channel = NRF_AAR_regs.PUBLISH_END & AAR_PUBLISH_END_CHIDX_Msk;
54+
nrf_dppi_publish(channel);
55+
}
56+
#endif
4457

4558
if (AAR_INTEN & AAR_INTENSET_END_Msk){
4659
hw_irq_ctrl_set_irq(NRF5_IRQ_CCM_AAR_IRQn);
@@ -49,7 +62,16 @@ static void signal_EVENTS_END(){
4962

5063
static void signal_EVENTS_RESOLVED(){
5164
NRF_AAR_regs.EVENTS_RESOLVED = 1;
65+
66+
#if !defined(DPPI_PRESENT)
5267
nrf_ppi_event(AAR_EVENTS_RESOLVED);
68+
#else
69+
if (NRF_AAR_regs.PUBLISH_RESOLVED & AAR_PUBLISH_RESOLVED_EN_Msk)
70+
{
71+
uint8_t channel = NRF_AAR_regs.PUBLISH_RESOLVED & AAR_PUBLISH_RESOLVED_CHIDX_Msk;
72+
nrf_dppi_publish(channel);
73+
}
74+
#endif
5375

5476
if (AAR_INTEN & AAR_INTENCLR_RESOLVED_Msk){
5577
hw_irq_ctrl_set_irq(NRF5_IRQ_CCM_AAR_IRQn);
@@ -58,7 +80,16 @@ static void signal_EVENTS_RESOLVED(){
5880

5981
static void signal_EVENTS_NOTRESOLVED(){
6082
NRF_AAR_regs.EVENTS_NOTRESOLVED = 1;
83+
84+
#if !defined(DPPI_PRESENT)
6185
nrf_ppi_event(AAR_EVENTS_NOTRESOLVED);
86+
#else
87+
if (NRF_AAR_regs.PUBLISH_NOTRESOLVED & AAR_PUBLISH_NOTRESOLVED_EN_Msk)
88+
{
89+
uint8_t channel = NRF_AAR_regs.PUBLISH_NOTRESOLVED & AAR_PUBLISH_NOTRESOLVED_CHIDX_Msk;
90+
nrf_dppi_publish(channel);
91+
}
92+
#endif
6293

6394
if (AAR_INTEN & AAR_INTENCLR_NOTRESOLVED_Msk){
6495
hw_irq_ctrl_set_irq(NRF5_IRQ_CCM_AAR_IRQn);

src/nrfx/hal/nrf_aar.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#include "hal/nrf_aar.h"
1010
#include "bs_tracing.h"
1111
#include "NRF_AAR.h"
12+
#if defined(DPPI_PRESENT)
13+
#include "NRF_DPPI.h"
14+
#endif
1215

1316
void nrf_aar_int_enable(NRF_AAR_Type * p_reg, uint32_t mask)
1417
{
@@ -34,3 +37,52 @@ void nrf_aar_task_trigger(NRF_AAR_Type * p_reg, nrf_aar_task_t task)
3437
bs_trace_error_line_time("Not supported task started in nrf_aar\n");
3538
}
3639
}
40+
41+
#if defined(DPPI_PRESENT)
42+
void nrf_aar_subscriber_add(nrf_aar_task_t task, uint8_t channel)
43+
{
44+
switch(task)
45+
{
46+
case NRF_AAR_TASK_START:
47+
nrf_dppi_subscriber_add(channel, nrf_aar_TASK_START);
48+
break;
49+
case NRF_AAR_TASK_STOP:
50+
nrf_dppi_subscriber_add(channel, nrf_aar_TASK_STOP);
51+
break;
52+
default:
53+
break;
54+
}
55+
}
56+
57+
void nrf_aar_subscriber_remove(nrf_aar_task_t task)
58+
{
59+
switch(task)
60+
{
61+
case NRF_AAR_TASK_START:
62+
nrf_dppi_subscriber_remove(nrf_aar_TASK_START);
63+
break;
64+
case NRF_AAR_TASK_STOP:
65+
nrf_dppi_subscriber_remove(nrf_aar_TASK_STOP);
66+
break;
67+
default:
68+
break;
69+
}
70+
}
71+
72+
NRF_STATIC_INLINE void nrf_aar_subscribe_set(NRF_AAR_Type * p_reg,
73+
nrf_aar_task_t task,
74+
uint8_t channel)
75+
{
76+
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
77+
((uint32_t)channel | AAR_SUBSCRIBE_START_EN_Msk);
78+
nrf_aar_subscriber_add(task, channel);
79+
}
80+
81+
NRF_STATIC_INLINE void nrf_aar_subscribe_clear(NRF_AAR_Type * p_reg,
82+
nrf_aar_task_t task)
83+
{
84+
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
85+
nrf_aar_subscriber_remove(task);
86+
}
87+
88+
#endif // defined(DPPI_PRESENT)

0 commit comments

Comments
 (0)