Skip to content

Commit 6b026c5

Browse files
nordic-krchcarlescufi
authored andcommitted
tests: drivers: timer: nrf_rtc_timer: Minor fixes
Changed chan type to int in the test_timeout function which follows change in the api to always use int for channel parameter. Added assert to check that channel was successfully allocated in test_resetting_cc(). Signed-off-by: Krzysztof Chruscinski <[email protected]>
1 parent ab49673 commit 6b026c5

File tree

1 file changed

+12
-10
lines changed
  • tests/drivers/timer/nrf_rtc_timer/src

1 file changed

+12
-10
lines changed

tests/drivers/timer/nrf_rtc_timer/src/main.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static void stop_zli_timer0(void)
5353
nrf_timer_task_trigger(NRF_TIMER0, NRF_TIMER_TASK_STOP);
5454
}
5555

56-
static void timeout_handler(uint32_t id, uint32_t cc_value, void *user_data)
56+
static void timeout_handler(int32_t id, uint32_t cc_value, void *user_data)
5757
{
5858
struct test_data *data = user_data;
5959
uint32_t now = z_nrf_rtc_timer_read();
@@ -70,7 +70,7 @@ static void timeout_handler(uint32_t id, uint32_t cc_value, void *user_data)
7070
timeout_handler_cnt++;
7171
}
7272

73-
static void test_timeout(uint32_t chan, k_timeout_t t, bool ext_window)
73+
static void test_timeout(int32_t chan, k_timeout_t t, bool ext_window)
7474
{
7575
int32_t cc_val = z_nrf_rtc_timer_get_ticks(t);
7676
struct test_data test_data = {
@@ -92,7 +92,7 @@ static void test_timeout(uint32_t chan, k_timeout_t t, bool ext_window)
9292

9393
static void test_basic(void)
9494
{
95-
int chan = z_nrf_rtc_timer_chan_alloc();
95+
int32_t chan = z_nrf_rtc_timer_chan_alloc();
9696

9797
zassert_true(chan >= 0, "Failed to allocate RTC channel (%d).", chan);
9898

@@ -139,7 +139,7 @@ static void test_int_disable_enabled(void)
139139
.err = -EINVAL
140140
};
141141
bool key;
142-
int chan;
142+
int32_t chan;
143143

144144
chan = z_nrf_rtc_timer_chan_alloc();
145145
zassert_true(chan >= 0, "Failed to allocate RTC channel.");
@@ -192,7 +192,7 @@ static void test_get_ticks(void)
192192
}
193193

194194

195-
static void sched_handler(uint32_t id, uint32_t cc_val, void *user_data)
195+
static void sched_handler(int32_t id, uint32_t cc_val, void *user_data)
196196
{
197197
int64_t now = sys_clock_tick_get();
198198
int rtc_ticks_now =
@@ -209,7 +209,7 @@ static void test_absolute_scheduling(void)
209209
uint64_t target_us = now_us + 5678;
210210
uint64_t evt_uptime_us;
211211
int rtc_ticks;
212-
int chan;
212+
int32_t chan;
213213

214214
chan = z_nrf_rtc_timer_chan_alloc();
215215
zassert_true(chan >= 0, "Failed to allocate RTC channel.");
@@ -246,8 +246,8 @@ static void test_absolute_scheduling(void)
246246

247247
static void test_alloc_free(void)
248248
{
249-
int chan[CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT];
250-
int inv_ch;
249+
int32_t chan[CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT];
250+
int32_t inv_ch;
251251

252252
for (int i = 0; i < CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT; i++) {
253253
chan[i] = z_nrf_rtc_timer_chan_alloc();
@@ -267,7 +267,7 @@ static void test_stress(void)
267267
int x = 0;
268268
uint32_t start = k_uptime_get_32();
269269
uint32_t test_time = 5000;
270-
int chan = z_nrf_rtc_timer_chan_alloc();
270+
int32_t chan = z_nrf_rtc_timer_chan_alloc();
271271

272272
zassert_true(chan >= 0, "Failed to allocate RTC channel.");
273273
start_zli_timer0();
@@ -293,10 +293,12 @@ static void test_reseting_cc(void)
293293
{
294294
uint32_t start = k_uptime_get_32();
295295
uint32_t test_time = 1000;
296-
int chan = z_nrf_rtc_timer_chan_alloc();
296+
int32_t chan = z_nrf_rtc_timer_chan_alloc();
297297
int i = 0;
298298
int cnt = 0;
299299

300+
zassert_true(chan >= 0, "Failed to allocate RTC channel.");
301+
300302
timeout_handler_cnt = 0;
301303

302304
do {

0 commit comments

Comments
 (0)