Skip to content

Commit 3ed6ffd

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 94e2100 commit 3ed6ffd

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
@@ -411,7 +411,7 @@ static struct dtm_instance {
411411
#endif
412412

413413
/* Radio Enable PPI channel. */
414-
uint8_t ppi_radio_start;
414+
nrfx_gppi_handle_t ppi_radio_start;
415415

416416
/* PPI endpoint status.*/
417417
atomic_t endpoint_state;
@@ -849,11 +849,12 @@ static int anomaly_timer_init(void)
849849
static int gppi_init(void)
850850
{
851851
nrfx_err_t err;
852+
uint32_t rad_domain = nrfx_gppi_domain_id_get((uint32_t)NRF_RADIO);
852853

853-
err = nrfx_gppi_channel_alloc(&dtm_inst.ppi_radio_start);
854-
if (err != NRFX_SUCCESS) {
855-
printk("nrfx_gppi_channel_alloc failed with: %d\n", err);
856-
return -EAGAIN;
854+
err = nrfx_gppi_domain_conn_alloc(rad_domain, rad_domain, &dtm_inst.ppi_radio_start);
855+
if (err < 0) {
856+
printk("nrfx_gppi_domain_conn_alloc failed with: %d\n", err);
857+
return err;
857858
}
858859

859860
return 0;
@@ -1144,9 +1145,7 @@ static void radio_tx_power_set(uint8_t channel, int8_t tx_power, nrf_radio_mode_
11441145

11451146
static void radio_reset(void)
11461147
{
1147-
if (nrfx_gppi_channel_check(dtm_inst.ppi_radio_start)) {
1148-
nrfx_gppi_channels_disable(BIT(dtm_inst.ppi_radio_start));
1149-
}
1148+
nrfx_gppi_conn_disable(dtm_inst.ppi_radio_start);
11501149

11511150
nrf_radio_shorts_set(NRF_RADIO, 0);
11521151
nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
@@ -1618,34 +1617,27 @@ static void errata_191_handle(bool enable)
16181617
static void endpoints_clear(void)
16191618
{
16201619
if (atomic_test_and_clear_bit(&dtm_inst.endpoint_state, ENDPOINT_FORK_EGU_TIMER)) {
1621-
nrfx_gppi_fork_endpoint_clear(dtm_inst.ppi_radio_start,
1620+
nrfx_gppi_ep_clear(
16221621
nrf_timer_task_address_get(dtm_inst.timer.p_reg, NRF_TIMER_TASK_START));
16231622
}
16241623
if (atomic_test_and_clear_bit(&dtm_inst.endpoint_state, ENDPOINT_EGU_RADIO_TX)) {
1625-
nrfx_gppi_channel_endpoints_clear(
1626-
dtm_inst.ppi_radio_start,
1627-
nrf_egu_event_address_get(DTM_EGU, DTM_EGU_EVENT),
1628-
nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
1624+
nrfx_gppi_ep_clear(nrf_egu_event_address_get(DTM_EGU, DTM_EGU_EVENT));
1625+
nrfx_gppi_ep_clear(nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
16291626
}
16301627
if (atomic_test_and_clear_bit(&dtm_inst.endpoint_state, ENDPOINT_EGU_RADIO_RX)) {
1631-
nrfx_gppi_channel_endpoints_clear(
1632-
dtm_inst.ppi_radio_start,
1633-
nrf_egu_event_address_get(DTM_EGU, DTM_EGU_EVENT),
1634-
nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_RXEN));
1628+
nrfx_gppi_ep_clear(nrf_egu_event_address_get(DTM_EGU, DTM_EGU_EVENT));
1629+
nrfx_gppi_ep_clear(nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_RXEN));
16351630
}
16361631
if (atomic_test_and_clear_bit(&dtm_inst.endpoint_state, ENDPOINT_TIMER_RADIO_TX)) {
1637-
nrfx_gppi_channel_endpoints_clear(
1638-
dtm_inst.ppi_radio_start,
1639-
nrf_timer_event_address_get(dtm_inst.timer.p_reg, NRF_TIMER_EVENT_COMPARE0),
1640-
nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
1632+
nrfx_gppi_ep_clear(
1633+
nrf_timer_event_address_get(dtm_inst.timer.p_reg, NRF_TIMER_EVENT_COMPARE0));
1634+
nrfx_gppi_ep_clear(nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
16411635
}
16421636
}
16431637

16441638
static void radio_ppi_clear(void)
16451639
{
1646-
if (nrfx_gppi_channel_check(dtm_inst.ppi_radio_start)) {
1647-
nrfx_gppi_channels_disable(BIT(dtm_inst.ppi_radio_start));
1648-
}
1640+
nrfx_gppi_conn_disable(dtm_inst.ppi_radio_start);
16491641

16501642
nrf_egu_event_clear(DTM_EGU, DTM_EGU_EVENT);
16511643

@@ -1655,19 +1647,19 @@ static void radio_ppi_clear(void)
16551647

16561648
static void radio_ppi_configure(bool rx, uint32_t timer_short_mask)
16571649
{
1658-
nrfx_gppi_channel_endpoints_setup(
1659-
dtm_inst.ppi_radio_start,
1660-
nrf_egu_event_address_get(DTM_EGU, DTM_EGU_EVENT),
1661-
nrf_radio_task_address_get(NRF_RADIO,
1650+
nrfx_gppi_ep_attach(dtm_inst.ppi_radio_start,
1651+
nrf_egu_event_address_get(DTM_EGU, DTM_EGU_EVENT));
1652+
nrfx_gppi_ep_attach(dtm_inst.ppi_radio_start,
1653+
nrf_radio_task_address_get(NRF_RADIO,
16621654
rx ? NRF_RADIO_TASK_RXEN : NRF_RADIO_TASK_TXEN));
16631655
atomic_set_bit(&dtm_inst.endpoint_state,
16641656
(rx ? ENDPOINT_EGU_RADIO_RX : ENDPOINT_EGU_RADIO_TX));
16651657

1666-
nrfx_gppi_fork_endpoint_setup(dtm_inst.ppi_radio_start,
1658+
nrfx_gppi_ep_attach(dtm_inst.ppi_radio_start,
16671659
nrf_timer_task_address_get(dtm_inst.timer.p_reg, NRF_TIMER_TASK_START));
16681660
atomic_set_bit(&dtm_inst.endpoint_state, ENDPOINT_FORK_EGU_TIMER);
16691661

1670-
nrfx_gppi_channels_enable(BIT(dtm_inst.ppi_radio_start));
1662+
nrfx_gppi_conn_enable(dtm_inst.ppi_radio_start);
16711663

16721664
if (timer_short_mask) {
16731665
nrf_timer_shorts_set(dtm_inst.timer.p_reg, timer_short_mask);
@@ -1676,18 +1668,16 @@ static void radio_ppi_configure(bool rx, uint32_t timer_short_mask)
16761668

16771669
static void radio_tx_ppi_reconfigure(void)
16781670
{
1679-
if (nrfx_gppi_channel_check(dtm_inst.ppi_radio_start)) {
1680-
nrfx_gppi_channels_disable(BIT(dtm_inst.ppi_radio_start));
1681-
}
1671+
nrfx_gppi_conn_disable(dtm_inst.ppi_radio_start);
16821672

16831673
endpoints_clear();
16841674

1685-
nrfx_gppi_channel_endpoints_setup(
1686-
dtm_inst.ppi_radio_start,
1687-
nrf_timer_event_address_get(dtm_inst.timer.p_reg, NRF_TIMER_EVENT_COMPARE0),
1675+
nrfx_gppi_ep_attach(dtm_inst.ppi_radio_start,
1676+
nrf_timer_event_address_get(dtm_inst.timer.p_reg, NRF_TIMER_EVENT_COMPARE0));
1677+
nrfx_gppi_ep_attach(dtm_inst.ppi_radio_start,
16881678
nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
16891679
atomic_set_bit(&dtm_inst.endpoint_state, ENDPOINT_TIMER_RADIO_TX);
1690-
nrfx_gppi_channels_enable(BIT(dtm_inst.ppi_radio_start));
1680+
nrfx_gppi_conn_enable(dtm_inst.ppi_radio_start);
16911681
}
16921682

16931683
static void dtm_test_done(void)

0 commit comments

Comments
 (0)