@@ -306,6 +306,7 @@ struct uarte_nrfx_data {
306306#endif
307307#ifdef UARTE_ANY_ASYNC
308308 struct uarte_async_cb * async ;
309+ nrfx_timer_t timer ;
309310#endif
310311 atomic_val_t poll_out_lock ;
311312 atomic_t flags ;
@@ -448,7 +449,6 @@ struct uarte_nrfx_config {
448449 size_t bounce_buf_swap_len ;
449450 struct uarte_async_rx_cbwt * cbwt_data ;
450451#endif
451- nrfx_timer_t timer ;
452452 uint8_t * tx_cache ;
453453 uint8_t * rx_flush_buf ;
454454#endif
@@ -521,7 +521,7 @@ static void uarte_disable_locked(const struct device *dev, uint32_t dis_mask)
521521
522522#if defined(UARTE_ANY_ASYNC ) && !defined(CONFIG_UART_NRFX_UARTE_ENHANCED_RX )
523523 if (data -> async && HW_RX_COUNTING_ENABLED (config )) {
524- nrfx_timer_disable (& config -> timer );
524+ nrfx_timer_disable (& data -> timer );
525525 /* Timer/counter value is reset when disabled. */
526526 data -> async -> rx .total_byte_cnt = 0 ;
527527 data -> async -> rx .total_user_byte_cnt = 0 ;
@@ -878,7 +878,7 @@ static void uarte_periph_enable(const struct device *dev)
878878#ifdef UARTE_ANY_ASYNC
879879 if (data -> async ) {
880880 if (HW_RX_COUNTING_ENABLED (config )) {
881- const nrfx_timer_t * timer = & config -> timer ;
881+ nrfx_timer_t * timer = & data -> timer ;
882882
883883 nrfx_timer_enable (timer );
884884
@@ -1067,26 +1067,26 @@ static int uarte_nrfx_rx_counting_init(const struct device *dev)
10671067
10681068 if (HW_RX_COUNTING_ENABLED (cfg )) {
10691069 nrfx_timer_config_t tmr_config = NRFX_TIMER_DEFAULT_CONFIG (
1070- NRF_TIMER_BASE_FREQUENCY_GET (cfg -> timer .p_reg ));
1070+ NRF_TIMER_BASE_FREQUENCY_GET (data -> timer .p_reg ));
10711071 uint32_t evt_addr = nrf_uarte_event_address_get (uarte , NRF_UARTE_EVENT_RXDRDY );
1072- uint32_t tsk_addr = nrfx_timer_task_address_get (& cfg -> timer , NRF_TIMER_TASK_COUNT );
1072+ uint32_t tsk_addr = nrfx_timer_task_address_get (& data -> timer , NRF_TIMER_TASK_COUNT );
10731073
10741074 tmr_config .mode = NRF_TIMER_MODE_COUNTER ;
10751075 tmr_config .bit_width = NRF_TIMER_BIT_WIDTH_32 ;
1076- ret = nrfx_timer_init (& cfg -> timer ,
1076+ ret = nrfx_timer_init (& data -> timer ,
10771077 & tmr_config ,
10781078 timer_handler );
10791079 if (ret != NRFX_SUCCESS ) {
10801080 LOG_ERR ("Timer already initialized" );
10811081 return - EINVAL ;
10821082 }
10831083
1084- nrfx_timer_clear (& cfg -> timer );
1084+ nrfx_timer_clear (& data -> timer );
10851085
10861086 ret = nrfx_gppi_channel_alloc (& data -> async -> rx .cnt .ppi );
10871087 if (ret != NRFX_SUCCESS ) {
10881088 LOG_ERR ("Failed to allocate PPI Channel" );
1089- nrfx_timer_uninit (& cfg -> timer );
1089+ nrfx_timer_uninit (& data -> timer );
10901090 return - EINVAL ;
10911091 }
10921092
@@ -2258,7 +2258,7 @@ static void rx_timeout(struct k_timer *timer)
22582258 NRF_UARTE_INT_ENDRX_MASK );
22592259
22602260 if (HW_RX_COUNTING_ENABLED (cfg )) {
2261- read = nrfx_timer_capture (& cfg -> timer , 0 );
2261+ read = nrfx_timer_capture (& data -> timer , 0 );
22622262 } else {
22632263 read = async_rx -> cnt .cnt ;
22642264 }
@@ -3241,7 +3241,7 @@ static void uarte_pm_suspend(const struct device *dev)
32413241
32423242#if !defined(CONFIG_UART_NRFX_UARTE_ENHANCED_RX )
32433243 if (data -> async && HW_RX_COUNTING_ENABLED (cfg )) {
3244- nrfx_timer_disable (& cfg -> timer );
3244+ nrfx_timer_disable (& data -> timer );
32453245 /* Timer/counter value is reset when disabled. */
32463246 data -> async -> rx .total_byte_cnt = 0 ;
32473247 data -> async -> rx .total_user_byte_cnt = 0 ;
@@ -3597,6 +3597,9 @@ static int uarte_instance_deinit(const struct device *dev)
35973597 (.uart_config = UARTE_CONFIG(idx),)) \
35983598 IF_ENABLED(CONFIG_UART_##idx##_ASYNC, \
35993599 (.async = &uarte##idx##_async,)) \
3600+ IF_ENABLED(CONFIG_UART_##idx##_NRF_HW_ASYNC, \
3601+ (.timer = NRFX_TIMER_INSTANCE(NRF_TIMER_INST_GET( \
3602+ CONFIG_UART_##idx##_NRF_HW_ASYNC_TIMER)),)) \
36003603 IF_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN, \
36013604 (.int_driven = &uarte##idx##_int_driven,)) \
36023605 }; \
@@ -3638,9 +3641,6 @@ static int uarte_instance_deinit(const struct device *dev)
36383641 .rx_flush_buf = uarte##idx##_flush_buf,)) \
36393642 IF_ENABLED(CONFIG_UARTE_NRFX_UARTE_COUNT_BYTES_WITH_TIMER, \
36403643 (UARTE_COUNT_BYTES_WITH_TIMER_CONFIG(idx))) \
3641- IF_ENABLED(CONFIG_UART_##idx##_NRF_HW_ASYNC, \
3642- (.timer = NRFX_TIMER_INSTANCE( \
3643- CONFIG_UART_##idx##_NRF_HW_ASYNC_TIMER),)) \
36443644 IF_ENABLED(INSTANCE_IS_FAST(_, /*empty*/ , idx , _), \
36453645 (.clk_dev = DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(UARTE(idx))), \
36463646 .clk_spec = { \
0 commit comments