diff --git a/drivers/timer/nrf_rtc_timer.c b/drivers/timer/nrf_rtc_timer.c index 4f4b10bb83c..e5170f87bb1 100644 --- a/drivers/timer/nrf_rtc_timer.c +++ b/drivers/timer/nrf_rtc_timer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017 Nordic Semiconductor ASA + * Copyright (c) 2016-2021 Nordic Semiconductor ASA * Copyright (c) 2018 Intel Corporation * * SPDX-License-Identifier: Apache-2.0 @@ -123,6 +123,23 @@ uint32_t z_nrf_rtc_timer_compare_evt_address_get(int32_t chan) return nrf_rtc_event_address_get(RTC, nrf_rtc_compare_event_get(chan)); } +uint32_t z_nrf_rtc_timer_capture_task_address_get(int32_t chan) +{ +#if defined(RTC_TASKS_CAPTURE_TASKS_CAPTURE_Msk) + __ASSERT_NO_MSG(chan < CHAN_COUNT); + if (chan == 0) { + return 0; + } + + nrf_rtc_task_t task = offsetof(NRF_RTC_Type, TASKS_CAPTURE[chan]); + + return nrf_rtc_task_address_get(RTC, task); +#else + ARG_UNUSED(chan); + return 0; +#endif +} + static bool compare_int_lock(int32_t chan) { atomic_val_t prev = atomic_and(&int_mask, ~BIT(chan)); diff --git a/include/drivers/timer/nrf_rtc_timer.h b/include/drivers/timer/nrf_rtc_timer.h index a23589ac136..8ec5228e8eb 100644 --- a/include/drivers/timer/nrf_rtc_timer.h +++ b/include/drivers/timer/nrf_rtc_timer.h @@ -65,6 +65,18 @@ uint64_t z_nrf_rtc_timer_read(void); */ uint32_t z_nrf_rtc_timer_compare_evt_address_get(int32_t chan); +/** @brief Get CAPTURE task register address. + * + * Address can be used for (D)PPI. + * + * @note Not all platforms have CAPTURE task. + * + * @param chan Channel ID between 1 and CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT. + * + * @return Register address. + */ +uint32_t z_nrf_rtc_timer_capture_task_address_get(int32_t chan); + /** @brief Safely disable compare event interrupt. * * Function returns key indicating whether interrupt was already disabled.