Skip to content

Commit 61f78d6

Browse files
committed
samples: peripheral: radio_test: Adapt to the new GPPI
Adapt radio_test sample to the new GPPI API. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 3ed6ffd commit 61f78d6

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

samples/peripheral/radio_test/src/radio_test.c

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static bool sweep_processing;
105105
static uint16_t total_payload_size;
106106

107107
/* PPI channel for starting radio */
108-
static uint8_t ppi_radio_start;
108+
static nrfx_gppi_handle_t ppi_radio_start;
109109

110110
/* PPI endpoint status.*/
111111
static atomic_t endpoint_state;
@@ -429,57 +429,56 @@ static void radio_power_set(nrf_radio_mode_t mode, uint8_t channel, int8_t power
429429
static void endpoints_clear(void)
430430
{
431431
if (atomic_test_and_clear_bit(&endpoint_state, ENDPOINT_FORK_EGU_TIMER)) {
432-
nrfx_gppi_fork_endpoint_clear(ppi_radio_start,
433-
nrf_timer_task_address_get(timer.p_reg, NRF_TIMER_TASK_START));
432+
nrfx_gppi_ep_clear(nrf_timer_task_address_get(timer.p_reg, NRF_TIMER_TASK_START));
434433
}
435434
if (atomic_test_and_clear_bit(&endpoint_state, ENDPOINT_EGU_RADIO_TX)) {
436-
nrfx_gppi_channel_endpoints_clear(ppi_radio_start,
437-
nrf_egu_event_address_get(RADIO_TEST_EGU, RADIO_TEST_EGU_EVENT),
438-
nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
435+
nrfx_gppi_ep_clear(
436+
nrf_egu_event_address_get(RADIO_TEST_EGU, RADIO_TEST_EGU_EVENT));
437+
nrfx_gppi_ep_clear(nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
439438
}
440439
if (atomic_test_and_clear_bit(&endpoint_state, ENDPOINT_EGU_RADIO_RX)) {
441-
nrfx_gppi_channel_endpoints_clear(ppi_radio_start,
442-
nrf_egu_event_address_get(RADIO_TEST_EGU, RADIO_TEST_EGU_EVENT),
443-
nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_RXEN));
440+
nrfx_gppi_ep_clear(
441+
nrf_egu_event_address_get(RADIO_TEST_EGU, RADIO_TEST_EGU_EVENT));
442+
nrfx_gppi_ep_clear(nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_RXEN));
444443
}
445444
if (atomic_test_and_clear_bit(&endpoint_state, ENDPOINT_TIMER_RADIO_TX)) {
446-
nrfx_gppi_channel_endpoints_clear(ppi_radio_start,
447-
nrf_timer_event_address_get(timer.p_reg, NRF_TIMER_EVENT_COMPARE0),
448-
nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
445+
nrfx_gppi_ep_clear(
446+
nrf_timer_event_address_get(timer.p_reg, NRF_TIMER_EVENT_COMPARE0));
447+
nrfx_gppi_ep_clear(nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
449448
}
450449
}
451450

452451
static void radio_ppi_config(bool rx)
453452
{
454453
endpoints_clear();
455454

456-
nrfx_gppi_channel_endpoints_setup(ppi_radio_start,
457-
nrf_egu_event_address_get(RADIO_TEST_EGU, RADIO_TEST_EGU_EVENT),
455+
nrfx_gppi_ep_attach(ppi_radio_start,
456+
nrf_egu_event_address_get(RADIO_TEST_EGU, RADIO_TEST_EGU_EVENT));
457+
nrfx_gppi_ep_attach(ppi_radio_start,
458458
nrf_radio_task_address_get(NRF_RADIO,
459459
rx ? NRF_RADIO_TASK_RXEN : NRF_RADIO_TASK_TXEN));
460460
atomic_set_bit(&endpoint_state, (rx ? ENDPOINT_EGU_RADIO_RX : ENDPOINT_EGU_RADIO_TX));
461461

462-
nrfx_gppi_fork_endpoint_setup(ppi_radio_start,
462+
nrfx_gppi_ep_attach(ppi_radio_start,
463463
nrf_timer_task_address_get(timer.p_reg, NRF_TIMER_TASK_START));
464464
atomic_set_bit(&endpoint_state, ENDPOINT_FORK_EGU_TIMER);
465465

466-
nrfx_gppi_channels_enable(BIT(ppi_radio_start));
466+
nrfx_gppi_conn_enable(ppi_radio_start);
467467
}
468468

469469
static void radio_ppi_tx_reconfigure(void)
470470
{
471-
if (nrfx_gppi_channel_check(ppi_radio_start)) {
472-
nrfx_gppi_channels_disable(BIT(ppi_radio_start));
473-
}
471+
nrfx_gppi_conn_disable(ppi_radio_start);
474472

475473
endpoints_clear();
476474

477-
nrfx_gppi_channel_endpoints_setup(ppi_radio_start,
478-
nrf_timer_event_address_get(timer.p_reg, NRF_TIMER_EVENT_COMPARE1),
475+
nrfx_gppi_ep_attach(ppi_radio_start,
476+
nrf_timer_event_address_get(timer.p_reg, NRF_TIMER_EVENT_COMPARE1));
477+
nrfx_gppi_ep_attach(ppi_radio_start,
479478
nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
480479
atomic_set_bit(&endpoint_state, ENDPOINT_TIMER_RADIO_TX);
481480

482-
nrfx_gppi_channels_enable(BIT(ppi_radio_start));
481+
nrfx_gppi_conn_enable(ppi_radio_start);
483482
}
484483

485484
#if CONFIG_FEM
@@ -1103,10 +1102,7 @@ static void cancel(void)
11031102

11041103
sweep_processing = false;
11051104

1106-
if (nrfx_gppi_channel_check(ppi_radio_start)) {
1107-
nrfx_gppi_channels_disable(BIT(ppi_radio_start));
1108-
}
1109-
1105+
nrfx_gppi_conn_disable(ppi_radio_start);
11101106
endpoints_clear();
11111107
radio_disable();
11121108

@@ -1298,6 +1294,7 @@ void radio_handler(const void *context)
12981294
int radio_test_init(struct radio_test_config *config)
12991295
{
13001296
nrfx_err_t nrfx_err;
1297+
uint32_t rad_domain = nrfx_gppi_domain_id_get((uint32_t)NRF_RADIO);
13011298

13021299
timer_init(config);
13031300
IRQ_CONNECT(RADIO_TEST_TIMER_IRQn, IRQ_PRIO_LOWEST,
@@ -1306,7 +1303,7 @@ int radio_test_init(struct radio_test_config *config)
13061303
irq_connect_dynamic(RADIO_TEST_RADIO_IRQn, IRQ_PRIO_LOWEST, radio_handler, config, 0);
13071304
irq_enable(RADIO_TEST_RADIO_IRQn);
13081305

1309-
nrfx_err = nrfx_gppi_channel_alloc(&ppi_radio_start);
1306+
nrfx_err = nrfx_gppi_domain_conn_alloc(rad_domain, rad_domain, &ppi_radio_start);
13101307
if (nrfx_err != NRFX_SUCCESS) {
13111308
printk("Failed to allocate gppi channel.\n");
13121309
return -EFAULT;

0 commit comments

Comments
 (0)