2020
2121static struct spi_dt_spec spim_spec = SPI_DT_SPEC_GET (DT_NODELABEL (dut_spi_dt ), SPI_MODE , 0 );
2222NRF_SPIM_Type * spim_reg = (NRF_SPIM_Type * )DT_REG_ADDR (DT_NODELABEL (dut_spi ));
23- NRF_TIMER_Type * timer_reg = (NRF_TIMER_Type * )DT_REG_ADDR (DT_NODELABEL (tst_timer ));
23+
24+ static nrfx_timer_t test_timer = NRFX_TIMER_INSTANCE (DT_REG_ADDR (DT_NODELABEL (tst_timer )));
2425
2526#define MEMORY_SECTION (node ) \
2627 COND_CODE_1(DT_NODE_HAS_PROP(node, memory_regions), \
@@ -44,16 +45,20 @@ static void set_buffers(void)
4445 memset (rx_buffer , 0xFF , TEST_BUFFER_SIZE );
4546}
4647
47- static uint32_t configure_test_timer (NRF_TIMER_Type * preg )
48+ static uint32_t configure_test_timer (nrfx_timer_t * timer )
4849{
49- const nrfy_timer_config_t test_timer_config = {.prescaler = 1 ,
50- .mode = NRF_TIMER_MODE_COUNTER ,
51- .bit_width = NRF_TIMER_BIT_WIDTH_16 };
50+ uint32_t base_frequency = NRF_TIMER_BASE_FREQUENCY_GET (timer -> p_reg );
51+ nrfx_timer_config_t timer_config = NRFX_TIMER_DEFAULT_CONFIG (base_frequency );
52+
53+ timer_config .bit_width = NRF_TIMER_BIT_WIDTH_16 ;
54+ timer_config .mode = NRF_TIMER_MODE_COUNTER ;
55+
56+ TC_PRINT ("Timer base frequency: %d Hz\n" , base_frequency );
5257
53- nrfy_timer_periph_configure ( preg , & test_timer_config );
54- nrfy_timer_task_trigger ( preg , NRF_TIMER_TASK_START );
58+ zassert_ok ( nrfx_timer_init ( timer , & timer_config , NULL ), "Timer init failed\n" );
59+ nrfx_timer_enable ( timer );
5560
56- return nrfy_timer_task_address_get ( preg , NRF_TIMER_TASK_COUNT );
61+ return nrfx_timer_task_address_get ( timer , NRF_TIMER_TASK_COUNT );
5762}
5863
5964/*
@@ -95,7 +100,12 @@ ZTEST(spim_pan, test_spim_mltpan_8_workaround)
95100ZTEST (spim_pan , test_spim_mltpan_55_workaround )
96101{
97102 int err ;
103+
98104 uint8_t ppi_channel ;
105+
106+ uint32_t domain_id ;
107+ nrfx_gppi_handle_t gppi_handle ;
108+
99109 uint32_t timer_cc_before , timer_cc_after ;
100110
101111 uint32_t timer_task ;
@@ -109,19 +119,20 @@ ZTEST(spim_pan, test_spim_mltpan_55_workaround)
109119
110120 set_buffers ();
111121
112- err = nrfx_gppi_channel_alloc ( & ppi_channel );
113- zassert_equal ( nrfx_gppi_channel_alloc (& ppi_channel ), NRFX_SUCCESS ,
114- "Failed to allocate GPPI channel" );
122+ domain_id = nrfx_gppi_domain_id_get (( uint32_t ) test_timer . p_reg );
123+ ppi_channel = nrfx_gppi_channel_alloc (domain_id );
124+ zassert_true ( ppi_channel > 0 , "Failed to allocate GPPI channel" );
115125
116- timer_task = configure_test_timer (timer_reg );
126+ timer_task = configure_test_timer (& test_timer );
117127 spim_event = nrf_spim_event_address_get (spim_reg , NRF_SPIM_EVENT_END );
118128
119- nrfx_gppi_channel_endpoints_setup (ppi_channel , spim_event , timer_task );
120- nrfx_gppi_channels_enable (BIT (ppi_channel ));
129+ zassert_ok (nrfx_gppi_conn_alloc (spim_event , timer_task , & gppi_handle ),
130+ "Failled to allocate DPPI connection\n" );
131+ nrfx_gppi_conn_enable (gppi_handle );
121132
122- timer_cc_before = nrfy_timer_capture_get ( timer_reg , NRF_TIMER_CC_CHANNEL0 );
133+ timer_cc_before = nrfx_timer_capture ( & test_timer , NRF_TIMER_CC_CHANNEL0 );
123134 err = spi_transceive_dt (& spim_spec , & tx_spi_buf_set , & rx_spi_buf_set );
124- timer_cc_after = nrfy_timer_capture_get ( timer_reg , NRF_TIMER_CC_CHANNEL0 );
135+ timer_cc_after = nrfx_timer_capture ( & test_timer , NRF_TIMER_CC_CHANNEL0 );
125136
126137 TC_PRINT ("Timer count before: %u, timer count after: %u\n" , timer_cc_before ,
127138 timer_cc_after );
0 commit comments