Skip to content

Commit f5e8cc9

Browse files
mib1-nordicjukkar
authored andcommitted
[nrf fromlist] tests: boards: nrf: qdec: Fix test for nRF54L15
Added additional cleanups between tests, which fixed the issue of a failing testcase on nRF54L15. Upstream PR #: 93927 Signed-off-by: Michał Bainczyk <[email protected]> (cherry picked from commit d24c26f)
1 parent 761c366 commit f5e8cc9

File tree

1 file changed

+12
-2
lines changed
  • tests/boards/nrf/qdec/src

1 file changed

+12
-2
lines changed

tests/boards/nrf/qdec/src/main.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ static void qdec_trigger_handler(const struct device *dev, const struct sensor_t
6060

6161
static void qenc_emulate_work_handler(struct k_work *work)
6262
{
63+
/* Check if emulation has been stopped after submitting this work item. */
64+
if (loopback_currently_under_test == NULL) {
65+
return;
66+
}
67+
6368
if (toggle_a) {
6469
gpio_pin_toggle_dt(&loopback_currently_under_test->qenc_phase_a);
6570
} else {
@@ -113,6 +118,8 @@ static void qenc_emulate_stop(void)
113118
k_timer_stop(&qenc_emulate_timer);
114119
qenc_emulate_reset_pin(&loopback_currently_under_test->qenc_phase_a);
115120
qenc_emulate_reset_pin(&loopback_currently_under_test->qenc_phase_b);
121+
122+
loopback_currently_under_test = NULL;
116123
}
117124
}
118125

@@ -218,6 +225,9 @@ static void sensor_trigger_set_and_disable(struct qdec_qenc_loopback *loopback)
218225
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
219226
pm_device_runtime_put(loopback->qdec);
220227
}
228+
229+
qenc_emulate_stop();
230+
k_sem_reset(&sem);
221231
}
222232

223233
/**
@@ -270,8 +280,7 @@ static void sensor_trigger_set_test(struct qdec_qenc_loopback *loopback)
270280
}
271281

272282
qenc_emulate_stop();
273-
/* emulation not working, but there may be old trigger which needs to be cleaned up */
274-
rc = k_sem_take(&sem, K_MSEC(200));
283+
k_sem_reset(&sem);
275284
}
276285

277286
/**
@@ -571,6 +580,7 @@ static void after(void *fixture)
571580
ARG_UNUSED(fixture);
572581

573582
qenc_emulate_stop();
583+
k_sem_reset(&sem);
574584
}
575585

576586
ZTEST_SUITE(qdec_sensor, NULL, setup, before, after, NULL);

0 commit comments

Comments
 (0)