tests: drivers: timer: nrf_rtc_timer: Adapt test to nrf52_bsim

Adapted test to be able to run on nrf52_bsim

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2020-12-09 12:16:01 +01:00 committed by Anas Nashif
commit 0de0233eac
3 changed files with 13 additions and 4 deletions

View file

@ -1,6 +1,6 @@
CONFIG_ZTEST=y CONFIG_ZTEST=y
CONFIG_ZERO_LATENCY_IRQS=y
CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT=2 CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT=2
CONFIG_SYS_CLOCK_TICKS_PER_SEC=32768
# Debug build # Debug build
# CONFIG_NO_OPTIMIZATIONS=y # CONFIG_NO_OPTIMIZATIONS=y

View file

@ -37,7 +37,9 @@ static void init_zli_timer0(void)
NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK); NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK);
IRQ_DIRECT_CONNECT(TIMER0_IRQn, 0, IRQ_DIRECT_CONNECT(TIMER0_IRQn, 0,
timer0_isr_wrapper, IRQ_ZERO_LATENCY); timer0_isr_wrapper,
COND_CODE_1(CONFIG_ZERO_LATENCY_IRQS,
(IRQ_ZERO_LATENCY), (0)));
irq_enable(TIMER0_IRQn); irq_enable(TIMER0_IRQn);
} }
@ -80,8 +82,8 @@ static void test_timeout(uint32_t chan, k_timeout_t t, bool ext_window)
z_nrf_rtc_timer_compare_set(chan, cc_val, timeout_handler, &test_data); z_nrf_rtc_timer_compare_set(chan, cc_val, timeout_handler, &test_data);
/* wait at least 2 ticks. */ /* wait additional arbitrary time. */
k_busy_wait(60); k_busy_wait(1000);
k_sleep(t); k_sleep(t);
zassert_equal(test_data.err, 0, "Unexpected err: %d", test_data.err); zassert_equal(test_data.err, 0, "Unexpected err: %d", test_data.err);
@ -152,6 +154,7 @@ static void test_int_disable_enabled(void)
zassert_equal(data.err, -EINVAL, "Unexpected err: %d", data.err); zassert_equal(data.err, -EINVAL, "Unexpected err: %d", data.err);
z_nrf_rtc_timer_compare_int_unlock(chan, key); z_nrf_rtc_timer_compare_int_unlock(chan, key);
k_busy_wait(100);
zassert_equal(data.err, 0, "Unexpected err: %d", data.err); zassert_equal(data.err, 0, "Unexpected err: %d", data.err);
z_nrf_rtc_timer_chan_free(chan); z_nrf_rtc_timer_chan_free(chan);

View file

@ -2,3 +2,9 @@ tests:
drivers.timer.nrf_rtc_timer: drivers.timer.nrf_rtc_timer:
tags: drivers tags: drivers
platform_allow: nrf52dk_nrf52832 nrf52840dk_nrf52840 platform_allow: nrf52dk_nrf52832 nrf52840dk_nrf52840
extra_configs:
- CONFIG_ZERO_LATENCY_IRQS=y
drivers.timer.nrf_rtc_timer_no_zli:
tags: drivers
platform_allow: nrf52dk_nrf52832 nrf52840dk_nrf52840 nrf52_bsim