Skip to content

Commit 171fdce

Browse files
committed
tests: benchmarks: power_consumption: adc: fix suspend sync
Fix synchronization between suspending thread and adc operation. Signed-off-by: Piotr Kosycarz <[email protected]>
1 parent b2a08f9 commit 171fdce

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/benchmarks/power_consumption/adc/src/driver_test.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ static const struct device *adc = DEVICE_DT_GET(ADC_NODE);
1313
static const struct adc_channel_cfg channel_cfgs[] = {
1414
DT_FOREACH_CHILD_SEP(ADC_NODE, ADC_CHANNEL_CFG_DT, (,))};
1515

16+
static bool suspend_req;
17+
18+
bool self_suspend_req(void)
19+
{
20+
suspend_req = true;
21+
return true;
22+
}
23+
1624
void thread_definition(void)
1725
{
1826
uint16_t channel_reading[5];
@@ -39,6 +47,11 @@ void thread_definition(void)
3947
return;
4048
}
4149
while (1) {
50+
if (suspend_req) {
51+
suspend_req = false;
52+
k_thread_suspend(k_current_get());
53+
}
54+
4255
#if defined(CONFIG_ADC_ASYNC)
4356
ret = adc_read_async(adc, &sequence, NULL);
4457
#else

0 commit comments

Comments
 (0)