Skip to content

Commit 9209390

Browse files
nordic-krchkartben
authored andcommitted
tests: drivers: clock_control: nrf_onoff_and_bt: Extend test
Extend test to check simple sequential use of BT specific API and standard onoff API. Test case added as it was initially failing on nrf54l15. Additionally, increased startup time for nRF54LX were HFCLK start is combined with tuning and it takes longer. Added nrf54l15dk//cpuapp to the test. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent e1f9de7 commit 9209390

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

tests/drivers/clock_control/nrf_onoff_and_bt/src/main.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ LOG_MODULE_REGISTER(test);
1414

1515
#define TEST_TIME_MS 10000
1616

17+
#ifdef CONFIG_SOC_SERIES_NRF54LX
18+
#define HF_STARTUP_TIME_US 600
19+
#else
1720
#define HF_STARTUP_TIME_US 400
21+
#endif
1822

1923
static bool test_end;
2024

@@ -66,6 +70,7 @@ K_TIMER_DEFINE(timer1, bt_timeout_handler, NULL);
6670
static void check_hf_status(const struct device *dev, bool exp_on,
6771
bool sw_check)
6872
{
73+
uint32_t key = irq_lock();
6974
nrf_clock_hfclk_t type;
7075

7176
nrf_clock_is_running(NRF_CLOCK, NRF_CLOCK_DOMAIN_HFCLK, &type);
@@ -83,6 +88,7 @@ static void check_hf_status(const struct device *dev, bool exp_on,
8388
"%d: Unexpected status: %d", iteration, status);
8489
}
8590

91+
irq_unlock(key);
8692
}
8793

8894
/* Test controls HF clock from two contexts: thread and timer interrupt.
@@ -223,4 +229,45 @@ ZTEST(nrf_onoff_and_bt, test_bt_interrupted)
223229
k_msleep(100);
224230
check_hf_status(clock_dev, false, true);
225231
}
232+
233+
ZTEST(nrf_onoff_and_bt, test_onoff_following_bt)
234+
{
235+
int err;
236+
int res = -EIO;
237+
238+
z_nrf_clock_bt_ctlr_hf_request();
239+
240+
/* First start can take longer on some platforms due to the tuning. */
241+
k_busy_wait(HF_STARTUP_TIME_US + 6000);
242+
check_hf_status(clock_dev, true, false);
243+
244+
z_nrf_clock_bt_ctlr_hf_release();
245+
246+
for (int i = 0; i < 5; i++) {
247+
z_nrf_clock_bt_ctlr_hf_request();
248+
249+
k_busy_wait(HF_STARTUP_TIME_US + 1200);
250+
check_hf_status(clock_dev, true, false);
251+
252+
z_nrf_clock_bt_ctlr_hf_release();
253+
254+
check_hf_status(clock_dev, false, false);
255+
256+
sys_notify_init_spinwait(&cli.notify);
257+
err = onoff_request(hf_mgr, &cli);
258+
zassert_true(err >= 0, "Unexpected err: %d", err);
259+
260+
k_busy_wait(HF_STARTUP_TIME_US);
261+
err = sys_notify_fetch_result(&cli.notify, &res);
262+
zassert_equal(err, 0, "Unexpected err: %d", err);
263+
zassert_equal(res, 0, "Unexpected result: %d", res);
264+
check_hf_status(clock_dev, true, false);
265+
266+
err = onoff_release(hf_mgr);
267+
zassert_true(err >= 0, "Unexpected err: %d", err);
268+
269+
check_hf_status(clock_dev, false, false);
270+
}
271+
}
272+
226273
ZTEST_SUITE(nrf_onoff_and_bt, NULL, setup, NULL, NULL, NULL);

tests/drivers/clock_control/nrf_onoff_and_bt/testcase.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ tests:
77
- nrf51dk/nrf51822
88
- nrf52dk/nrf52832
99
- nrf52840dk/nrf52840
10+
- nrf54l15dk/nrf54l15/cpuapp
1011
integration_platforms:
11-
- nrf51dk/nrf51822
12+
- nrf54l15dk/nrf54l15/cpuapp

0 commit comments

Comments
 (0)