Skip to content

Commit 28a4417

Browse files
committed
samples: bluetooth: direct_test_mode: Adapt to the new GPPI API
Adapt to the new GPPI API. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 2b344fe commit 28a4417

File tree

1 file changed

+27
-37
lines changed
  • samples/bluetooth/direct_test_mode/src

1 file changed

+27
-37
lines changed

samples/bluetooth/direct_test_mode/src/dtm.c

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ static struct dtm_instance {
427427
#endif
428428

429429
/* Radio Enable PPI channel. */
430-
uint8_t ppi_radio_start;
430+
nrfx_gppi_handle_t ppi_radio_start;
431431

432432
/* PPI endpoint status.*/
433433
atomic_t endpoint_state;
@@ -865,11 +865,12 @@ static int anomaly_timer_init(void)
865865
static int gppi_init(void)
866866
{
867867
nrfx_err_t err;
868+
uint32_t rad_domain = nrfx_gppi_domain_id_get((uint32_t)NRF_RADIO);
868869

869-
err = nrfx_gppi_channel_alloc(&dtm_inst.ppi_radio_start);
870-
if (err != NRFX_SUCCESS) {
871-
printk("nrfx_gppi_channel_alloc failed with: %d\n", err);
872-
return -EAGAIN;
870+
err = nrfx_gppi_domain_conn_alloc(rad_domain, rad_domain, &dtm_inst.ppi_radio_start);
871+
if (err < 0) {
872+
printk("nrfx_gppi_domain_conn_alloc failed with: %d\n", err);
873+
return err;
873874
}
874875

875876
return 0;
@@ -1160,9 +1161,7 @@ static void radio_tx_power_set(uint8_t channel, int8_t tx_power, nrf_radio_mode_
11601161

11611162
static void radio_reset(void)
11621163
{
1163-
if (nrfx_gppi_channel_check(dtm_inst.ppi_radio_start)) {
1164-
nrfx_gppi_channels_disable(BIT(dtm_inst.ppi_radio_start));
1165-
}
1164+
nrfx_gppi_conn_disable(dtm_inst.ppi_radio_start);
11661165

11671166
nrf_radio_shorts_set(NRF_RADIO, 0);
11681167
nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
@@ -1634,34 +1633,27 @@ static void errata_191_handle(bool enable)
16341633
static void endpoints_clear(void)
16351634
{
16361635
if (atomic_test_and_clear_bit(&dtm_inst.endpoint_state, ENDPOINT_FORK_EGU_TIMER)) {
1637-
nrfx_gppi_fork_endpoint_clear(dtm_inst.ppi_radio_start,
1636+
nrfx_gppi_ep_clear(
16381637
nrf_timer_task_address_get(dtm_inst.timer.p_reg, NRF_TIMER_TASK_START));
16391638
}
16401639
if (atomic_test_and_clear_bit(&dtm_inst.endpoint_state, ENDPOINT_EGU_RADIO_TX)) {
1641-
nrfx_gppi_channel_endpoints_clear(
1642-
dtm_inst.ppi_radio_start,
1643-
nrf_egu_event_address_get(DTM_EGU, DTM_EGU_EVENT),
1644-
nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
1640+
nrfx_gppi_ep_clear(nrf_egu_event_address_get(DTM_EGU, DTM_EGU_EVENT));
1641+
nrfx_gppi_ep_clear(nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
16451642
}
16461643
if (atomic_test_and_clear_bit(&dtm_inst.endpoint_state, ENDPOINT_EGU_RADIO_RX)) {
1647-
nrfx_gppi_channel_endpoints_clear(
1648-
dtm_inst.ppi_radio_start,
1649-
nrf_egu_event_address_get(DTM_EGU, DTM_EGU_EVENT),
1650-
nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_RXEN));
1644+
nrfx_gppi_ep_clear(nrf_egu_event_address_get(DTM_EGU, DTM_EGU_EVENT));
1645+
nrfx_gppi_ep_clear(nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_RXEN));
16511646
}
16521647
if (atomic_test_and_clear_bit(&dtm_inst.endpoint_state, ENDPOINT_TIMER_RADIO_TX)) {
1653-
nrfx_gppi_channel_endpoints_clear(
1654-
dtm_inst.ppi_radio_start,
1655-
nrf_timer_event_address_get(dtm_inst.timer.p_reg, NRF_TIMER_EVENT_COMPARE0),
1656-
nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
1648+
nrfx_gppi_ep_clear(
1649+
nrf_timer_event_address_get(dtm_inst.timer.p_reg, NRF_TIMER_EVENT_COMPARE0));
1650+
nrfx_gppi_ep_clear(nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
16571651
}
16581652
}
16591653

16601654
static void radio_ppi_clear(void)
16611655
{
1662-
if (nrfx_gppi_channel_check(dtm_inst.ppi_radio_start)) {
1663-
nrfx_gppi_channels_disable(BIT(dtm_inst.ppi_radio_start));
1664-
}
1656+
nrfx_gppi_conn_disable(dtm_inst.ppi_radio_start);
16651657

16661658
nrf_egu_event_clear(DTM_EGU, DTM_EGU_EVENT);
16671659

@@ -1671,19 +1663,19 @@ static void radio_ppi_clear(void)
16711663

16721664
static void radio_ppi_configure(bool rx, uint32_t timer_short_mask)
16731665
{
1674-
nrfx_gppi_channel_endpoints_setup(
1675-
dtm_inst.ppi_radio_start,
1676-
nrf_egu_event_address_get(DTM_EGU, DTM_EGU_EVENT),
1677-
nrf_radio_task_address_get(NRF_RADIO,
1666+
nrfx_gppi_ep_attach(dtm_inst.ppi_radio_start,
1667+
nrf_egu_event_address_get(DTM_EGU, DTM_EGU_EVENT));
1668+
nrfx_gppi_ep_attach(dtm_inst.ppi_radio_start,
1669+
nrf_radio_task_address_get(NRF_RADIO,
16781670
rx ? NRF_RADIO_TASK_RXEN : NRF_RADIO_TASK_TXEN));
16791671
atomic_set_bit(&dtm_inst.endpoint_state,
16801672
(rx ? ENDPOINT_EGU_RADIO_RX : ENDPOINT_EGU_RADIO_TX));
16811673

1682-
nrfx_gppi_fork_endpoint_setup(dtm_inst.ppi_radio_start,
1674+
nrfx_gppi_ep_attach(dtm_inst.ppi_radio_start,
16831675
nrf_timer_task_address_get(dtm_inst.timer.p_reg, NRF_TIMER_TASK_START));
16841676
atomic_set_bit(&dtm_inst.endpoint_state, ENDPOINT_FORK_EGU_TIMER);
16851677

1686-
nrfx_gppi_channels_enable(BIT(dtm_inst.ppi_radio_start));
1678+
nrfx_gppi_conn_enable(dtm_inst.ppi_radio_start);
16871679

16881680
if (timer_short_mask) {
16891681
nrf_timer_shorts_set(dtm_inst.timer.p_reg, timer_short_mask);
@@ -1692,18 +1684,16 @@ static void radio_ppi_configure(bool rx, uint32_t timer_short_mask)
16921684

16931685
static void radio_tx_ppi_reconfigure(void)
16941686
{
1695-
if (nrfx_gppi_channel_check(dtm_inst.ppi_radio_start)) {
1696-
nrfx_gppi_channels_disable(BIT(dtm_inst.ppi_radio_start));
1697-
}
1687+
nrfx_gppi_conn_disable(dtm_inst.ppi_radio_start);
16981688

16991689
endpoints_clear();
17001690

1701-
nrfx_gppi_channel_endpoints_setup(
1702-
dtm_inst.ppi_radio_start,
1703-
nrf_timer_event_address_get(dtm_inst.timer.p_reg, NRF_TIMER_EVENT_COMPARE0),
1691+
nrfx_gppi_ep_attach(dtm_inst.ppi_radio_start,
1692+
nrf_timer_event_address_get(dtm_inst.timer.p_reg, NRF_TIMER_EVENT_COMPARE0));
1693+
nrfx_gppi_ep_attach(dtm_inst.ppi_radio_start,
17041694
nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
17051695
atomic_set_bit(&dtm_inst.endpoint_state, ENDPOINT_TIMER_RADIO_TX);
1706-
nrfx_gppi_channels_enable(BIT(dtm_inst.ppi_radio_start));
1696+
nrfx_gppi_conn_enable(dtm_inst.ppi_radio_start);
17071697
}
17081698

17091699
static void dtm_test_done(void)

0 commit comments

Comments
 (0)