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

Commit e695b97

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

File tree

2 files changed

+198
-1
lines changed

2 files changed

+198
-1
lines changed

src/HW_models/NRF_RADIO.c

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
#include "time_machine_if.h"
1515
#include "NRF_RADIO.h"
1616
#include "NRF_HW_model_top.h"
17+
#if defined(PPI_PRESENT)
1718
#include "NRF_PPI.h"
19+
#elif defined(DPPI_PRESENT)
20+
#include "NRF_DPPI.h"
21+
#endif
1822
#include "NRF_AES_CCM.h"
1923
#include "irq_ctrl.h"
2024
#include "irq_sources.h"
@@ -414,7 +418,16 @@ void nrf_radio_regw_sideeffects_POWER(){
414418

415419
static void signal_READY(){
416420
NRF_RADIO_regs.EVENTS_READY = 1;
421+
422+
#if defined(PPI_PRESENT)
417423
nrf_ppi_event(RADIO_EVENTS_READY);
424+
#elif defined(DPPI_PRESENT)
425+
if (NRF_RADIO_regs.PUBLISH_READY & RADIO_PUBLISH_READY_EN_Msk)
426+
{
427+
uint8_t channel = NRF_RADIO_regs.PUBLISH_READY & RADIO_PUBLISH_READY_CHIDX_Msk;
428+
nrf_dppi_publish(channel);
429+
}
430+
#endif
418431

419432
if ( NRF_RADIO_regs.SHORTS & RADIO_SHORTS_READY_START_Msk ) {
420433
nrf_radio_tasks_start();
@@ -455,7 +468,16 @@ static void signal_RXREADY(){
455468

456469
static void signal_RSSIEND(){
457470
NRF_RADIO_regs.EVENTS_RSSIEND = 1;
471+
472+
#if defined(PPI_PRESENT)
458473
nrf_ppi_event(RADIO_EVENTS_RSSIEND);
474+
#elif defined(DPPI_PRESENT)
475+
if (NRF_RADIO_regs.PUBLISH_RSSIEND & RADIO_PUBLISH_RSSIEND_EN_Msk)
476+
{
477+
uint8_t channel = NRF_RADIO_regs.PUBLISH_RSSIEND & RADIO_PUBLISH_RSSIEND_CHIDX_Msk;
478+
nrf_dppi_publish(channel);
479+
}
480+
#endif
459481

460482
if ( RADIO_INTEN & RADIO_INTENSET_RSSIEND_Msk ){
461483
hw_irq_ctrl_set_irq(NRF5_IRQ_RADIO_IRQn);
@@ -464,7 +486,16 @@ static void signal_RSSIEND(){
464486

465487
static void signal_ADDRESS(){
466488
NRF_RADIO_regs.EVENTS_ADDRESS = 1;
489+
490+
#if defined(PPI_PRESENT)
467491
nrf_ppi_event(RADIO_EVENTS_ADDRESS);
492+
#elif defined(DPPI_PRESENT)
493+
if (NRF_RADIO_regs.PUBLISH_ADDRESS & RADIO_PUBLISH_ADDRESS_EN_Msk)
494+
{
495+
uint8_t channel = NRF_RADIO_regs.PUBLISH_ADDRESS & RADIO_PUBLISH_ADDRESS_CHIDX_Msk;
496+
nrf_dppi_publish(channel);
497+
}
498+
#endif
468499

469500
if ( NRF_RADIO_regs.SHORTS & RADIO_SHORTS_ADDRESS_RSSISTART_Msk ) {
470501
nrf_radio_tasks_rssistart();
@@ -480,7 +511,16 @@ static void signal_ADDRESS(){
480511

481512
static void signal_PAYLOAD(){
482513
NRF_RADIO_regs.EVENTS_PAYLOAD = 1;
514+
515+
#if defined(PPI_PRESENT)
483516
nrf_ppi_event(RADIO_EVENTS_PAYLOAD);
517+
#elif defined(DPPI_PRESENT)
518+
if (NRF_RADIO_regs.PUBLISH_PAYLOAD & RADIO_PUBLISH_PAYLOAD_EN_Msk)
519+
{
520+
uint8_t channel = NRF_RADIO_regs.PUBLISH_PAYLOAD & RADIO_PUBLISH_PAYLOAD_CHIDX_Msk;
521+
nrf_dppi_publish(channel);
522+
}
523+
#endif
484524

485525
if ( RADIO_INTEN & RADIO_INTENSET_PAYLOAD_Msk ){
486526
hw_irq_ctrl_set_irq(NRF5_IRQ_RADIO_IRQn);
@@ -489,7 +529,16 @@ static void signal_PAYLOAD(){
489529

490530
static void signal_CRCOK(){
491531
NRF_RADIO_regs.EVENTS_CRCOK = 1;
532+
533+
#if defined(PPI_PRESENT)
492534
nrf_ppi_event(RADIO_EVENTS_CRCOK);
535+
#elif defined(DPPI_PRESENT)
536+
if (NRF_RADIO_regs.PUBLISH_CRCOK & RADIO_PUBLISH_CRCOK_EN_Msk)
537+
{
538+
uint8_t channel = NRF_RADIO_regs.PUBLISH_CRCOK & RADIO_PUBLISH_CRCOK_CHIDX_Msk;
539+
nrf_dppi_publish(channel);
540+
}
541+
#endif
493542

494543
if ( RADIO_INTEN & RADIO_INTENSET_CRCOK_Msk ) {
495544
hw_irq_ctrl_set_irq(NRF5_IRQ_RADIO_IRQn);
@@ -498,7 +547,16 @@ static void signal_CRCOK(){
498547

499548
static void signal_CRCERROR(){
500549
NRF_RADIO_regs.EVENTS_CRCERROR = 1;
550+
551+
#if defined(PPI_PRESENT)
501552
nrf_ppi_event(RADIO_EVENTS_CRCERROR);
553+
#elif defined(DPPI_PRESENT)
554+
if (NRF_RADIO_regs.PUBLISH_CRCERROR & RADIO_PUBLISH_CRCERROR_EN_Msk)
555+
{
556+
uint8_t channel = NRF_RADIO_regs.PUBLISH_CRCERROR & RADIO_PUBLISH_CRCERROR_CHIDX_Msk;
557+
nrf_dppi_publish(channel);
558+
}
559+
#endif
502560

503561
if ( RADIO_INTEN & RADIO_INTENSET_CRCERROR_Msk ) {
504562
hw_irq_ctrl_set_irq(NRF5_IRQ_RADIO_IRQn);
@@ -509,7 +567,16 @@ static void signal_END(){
509567
nrf_radio_stop_bit_counter();
510568

511569
NRF_RADIO_regs.EVENTS_END = 1;
570+
571+
#if defined(PPI_PRESENT)
512572
nrf_ppi_event(RADIO_EVENTS_END);
573+
#elif defined(DPPI_PRESENT)
574+
if (NRF_RADIO_regs.PUBLISH_END & RADIO_PUBLISH_END_EN_Msk)
575+
{
576+
uint8_t channel = NRF_RADIO_regs.PUBLISH_END & RADIO_PUBLISH_END_CHIDX_Msk;
577+
nrf_dppi_publish(channel);
578+
}
579+
#endif
513580

514581
if ( NRF_RADIO_regs.SHORTS & RADIO_SHORTS_END_DISABLE_Msk ) {
515582
nrf_radio_tasks_disable();
@@ -527,7 +594,16 @@ static void signal_DISABLED(){
527594
nrf_radio_stop_bit_counter();
528595

529596
NRF_RADIO_regs.EVENTS_DISABLED = 1;
597+
598+
#if defined(PPI_PRESENT)
530599
nrf_ppi_event(RADIO_EVENTS_DISABLED);
600+
#elif defined(DPPI_PRESENT)
601+
if (NRF_RADIO_regs.PUBLISH_DISABLED & RADIO_PUBLISH_DISABLED_EN_Msk)
602+
{
603+
uint8_t channel = NRF_RADIO_regs.PUBLISH_DISABLED & RADIO_PUBLISH_DISABLED_CHIDX_Msk;
604+
nrf_dppi_publish(channel);
605+
}
606+
#endif
531607

532608
//These 2 are fake shortcuts meant to start a HW timer for the TIFS
533609
if ( NRF_RADIO_regs.SHORTS & RADIO_SHORTS_DISABLED_TXEN_Msk ) {
@@ -904,7 +980,7 @@ static void handle_Rx_response(int ret){
904980

905981
ongoing_rx_RADIO_status.ADDRESS_End_Time = address_time + get_Rx_chain_delay();
906982
uint length = rx_buf[1];
907-
uint max_length = (NRF_RADIO_regs.PCNF1 & NFCT_MAXLEN_MAXLEN_Msk) >> NFCT_MAXLEN_MAXLEN_Pos;
983+
uint max_length = (NRF_RADIO_regs.PCNF1 & RADIO_PCNF1_MAXLEN_Msk) >> RADIO_PCNF1_MAXLEN_Pos ;
908984
if (length > max_length){
909985
length = max_length;
910986
//TODO: check packet length. If too long the packet should be truncated and not accepted from the phy, [we already have it in the buffer and we will have a CRC error anyhow. And we cannot let the phy run for longer than we will]
@@ -1092,7 +1168,16 @@ static void Rx_Addr_received(){
10921168

10931169
static void signal_DEVMATCH() {
10941170
NRF_RADIO_regs.EVENTS_DEVMATCH = 1;
1171+
1172+
#if defined(PPI_PRESENT)
10951173
nrf_ppi_event(RADIO_EVENTS_DEVMATCH);
1174+
#elif defined(DPPI_PRESENT)
1175+
if (NRF_RADIO_regs.PUBLISH_DEVMATCH & RADIO_PUBLISH_DEVMATCH_EN_Msk)
1176+
{
1177+
uint8_t channel = NRF_RADIO_regs.PUBLISH_DEVMATCH & RADIO_PUBLISH_DEVMATCH_CHIDX_Msk;
1178+
nrf_dppi_publish(channel);
1179+
}
1180+
#endif
10961181

10971182
if (RADIO_INTEN & RADIO_INTENSET_DEVMATCH_Msk) {
10981183
hw_irq_ctrl_set_irq(NRF5_IRQ_RADIO_IRQn);
@@ -1101,7 +1186,16 @@ static void signal_DEVMATCH() {
11011186

11021187
static void signal_DEVMISS() {
11031188
NRF_RADIO_regs.EVENTS_DEVMISS = 1;
1189+
1190+
#if defined(PPI_PRESENT)
11041191
nrf_ppi_event(RADIO_EVENTS_DEVMISS);
1192+
#elif defined(DPPI_PRESENT)
1193+
if (NRF_RADIO_regs.PUBLISH_DEVMISS & RADIO_PUBLISH_DEVMISS_EN_Msk)
1194+
{
1195+
uint8_t channel = NRF_RADIO_regs.PUBLISH_DEVMISS & RADIO_PUBLISH_DEVMISS_CHIDX_Msk;
1196+
nrf_dppi_publish(channel);
1197+
}
1198+
#endif
11051199

11061200
if (RADIO_INTEN & RADIO_INTENSET_DEVMISS_Msk) {
11071201
hw_irq_ctrl_set_irq(NRF5_IRQ_RADIO_IRQn);
@@ -1151,7 +1245,16 @@ static void do_device_address_match() {
11511245

11521246
static void signal_BCMATCH() {
11531247
NRF_RADIO_regs.EVENTS_BCMATCH = 1;
1248+
1249+
#if defined(PPI_PRESENT)
11541250
nrf_ppi_event(RADIO_EVENTS_BCMATCH);
1251+
#elif defined(DPPI_PRESENT)
1252+
if (NRF_RADIO_regs.PUBLISH_BCMATCH & RADIO_PUBLISH_BCMATCH_EN_Msk)
1253+
{
1254+
uint8_t channel = NRF_RADIO_regs.PUBLISH_BCMATCH & RADIO_PUBLISH_BCMATCH_CHIDX_Msk;
1255+
nrf_dppi_publish(channel);
1256+
}
1257+
#endif
11551258

11561259
if (RADIO_INTEN & RADIO_INTENSET_BCMATCH_Msk) {
11571260
hw_irq_ctrl_set_irq(NRF5_IRQ_RADIO_IRQn);

src/nrfx/hal/nrf_radio.c

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

1215
void nrf_radio_task_trigger(NRF_RADIO_Type * p_reg, nrf_radio_task_t task)
1316
{
@@ -54,3 +57,94 @@ void nrf_radio_power_set(NRF_RADIO_Type * p_reg, bool radio_power)
5457
p_reg->POWER = (uint32_t) radio_power;
5558
nrf_radio_regw_sideeffects_POWER();
5659
}
60+
61+
#if defined(DPPI_PRESENT)
62+
void nrf_radio_subscriber_add(nrf_radio_task_t task, uint8_t channel)
63+
{
64+
switch(task)
65+
{
66+
case NRF_RADIO_TASK_TXEN:
67+
nrf_dppi_subscriber_add(channel, nrf_radio_tasks_txen);
68+
break;
69+
case NRF_RADIO_TASK_RXEN:
70+
nrf_dppi_subscriber_add(channel, nrf_radio_tasks_rxen);
71+
break;
72+
case NRF_RADIO_TASK_START:
73+
nrf_dppi_subscriber_add(channel, nrf_radio_tasks_start);
74+
break;
75+
case NRF_RADIO_TASK_STOP:
76+
nrf_dppi_subscriber_add(channel, nrf_radio_tasks_stop);
77+
break;
78+
case NRF_RADIO_TASK_DISABLE:
79+
nrf_dppi_subscriber_add(channel, nrf_radio_tasks_disable);
80+
break;
81+
case NRF_RADIO_TASK_RSSISTART:
82+
nrf_dppi_subscriber_add(channel, nrf_radio_tasks_rssistart);
83+
break;
84+
case NRF_RADIO_TASK_RSSISTOP:
85+
nrf_dppi_subscriber_add(channel, nrf_radio_tasks_rssistop);
86+
break;
87+
case NRF_RADIO_TASK_BCSTART:
88+
nrf_dppi_subscriber_add(channel, nrf_radio_tasks_bcstart);
89+
break;
90+
case NRF_RADIO_TASK_BCSTOP:
91+
nrf_dppi_subscriber_add(channel, nrf_radio_tasks_bcstop);
92+
break;
93+
default:
94+
break;
95+
}
96+
}
97+
98+
void nrf_radio_subscriber_remove(nrf_radio_task_t task)
99+
{
100+
switch(task)
101+
{
102+
case NRF_RADIO_TASK_TXEN:
103+
nrf_dppi_subscriber_remove(nrf_radio_tasks_txen);
104+
break;
105+
case NRF_RADIO_TASK_RXEN:
106+
nrf_dppi_subscriber_remove(nrf_radio_tasks_rxen);
107+
break;
108+
case NRF_RADIO_TASK_START:
109+
nrf_dppi_subscriber_remove(nrf_radio_tasks_start);
110+
break;
111+
case NRF_RADIO_TASK_STOP:
112+
nrf_dppi_subscriber_remove(nrf_radio_tasks_stop);
113+
break;
114+
case NRF_RADIO_TASK_DISABLE:
115+
nrf_dppi_subscriber_remove(nrf_radio_tasks_disable);
116+
break;
117+
case NRF_RADIO_TASK_RSSISTART:
118+
nrf_dppi_subscriber_remove(nrf_radio_tasks_rssistart);
119+
break;
120+
case NRF_RADIO_TASK_RSSISTOP:
121+
nrf_dppi_subscriber_remove(nrf_radio_tasks_rssistop);
122+
break;
123+
case NRF_RADIO_TASK_BCSTART:
124+
nrf_dppi_subscriber_remove(nrf_radio_tasks_bcstart);
125+
break;
126+
case NRF_RADIO_TASK_BCSTOP:
127+
nrf_dppi_subscriber_remove(nrf_radio_tasks_bcstop);
128+
break;
129+
default:
130+
break;
131+
}
132+
}
133+
134+
void nrf_radio_subscribe_set(NRF_RADIO_Type * p_reg,
135+
nrf_radio_task_t task,
136+
uint8_t channel)
137+
{
138+
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
139+
((uint32_t)channel | RADIO_SUBSCRIBE_TXEN_EN_Msk);
140+
nrf_radio_subscriber_add(task, channel);
141+
}
142+
143+
void nrf_radio_subscribe_clear(NRF_RADIO_Type * p_reg,
144+
nrf_radio_task_t task)
145+
{
146+
*((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
147+
nrf_radio_subscriber_remove(task);
148+
}
149+
150+
#endif // defined(DPPI_PRESENT)

0 commit comments

Comments
 (0)