Skip to content

Commit

Permalink
samples: mbox: Align to NO MULTITHREADING
Browse files Browse the repository at this point in the history
Removed k_sleep dependencies in non-multithreaded runs.

Signed-off-by: Jakub Zymelka <[email protected]>
  • Loading branch information
jaz1-nordic committed Jun 17, 2024
1 parent 5eb09a0 commit c560d2e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
17 changes: 13 additions & 4 deletions samples/drivers/mbox/remote/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ int main(void)
{
int ret;

printk("Hello from REMOTE\n");
printk("Hello from REMOTE - %s\n",
#ifdef CONFIG_MULTITHREADING
"MULTITHREADING"
#else
"SINGLETHREAD"
#endif
);

#ifdef CONFIG_RX_ENABLED
const struct mbox_dt_spec rx_channel = MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx);
Expand All @@ -46,17 +52,20 @@ int main(void)
const struct mbox_dt_spec tx_channel = MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), tx);

while (1) {
#if defined(CONFIG_MULTITHREADING)
k_sleep(K_MSEC(3000));
#else
k_busy_wait(3000000);
#endif

printk("Ping (on channel %d)\n", tx_channel.channel_id);

ret = mbox_send_dt(&tx_channel, NULL);
if (ret < 0) {
printk("Could not send (%d)\n", ret);
return 0;
}

k_sleep(K_MSEC(3000));
}
#endif /* CONFIG_TX_ENABLED */

return 0;
}
18 changes: 18 additions & 0 deletions samples/drivers/mbox/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,21 @@ tests:
regex:
- "Ping \\(on channel 16\\)"
- "Pong \\(on channel 15\\)"

sample.drivers.mbox.nrf54l15_no_multithreading:
platform_allow:
- nrf54l15pdk/nrf54l15/cpuapp
integration_platforms:
- nrf54l15pdk/nrf54l15/cpuapp
extra_args:
mbox_SNIPPET=nordic-flpr
mbox_CONFIG_MULTITHREADING=n
remote_CONFIG_MULTITHREADING=n
sysbuild: true
harness: console
harness_config:
type: multi_line
ordered: false
regex:
- "Ping \\(on channel 16\\)"
- "Pong \\(on channel 15\\)"
12 changes: 11 additions & 1 deletion samples/drivers/mbox/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ int main(void)
{
int ret;

printk("Hello from APP\n");
printk("Hello from APP - %s\n",
#ifdef CONFIG_MULTITHREADING
"MULTITHREADING"
#else
"SINGLETHREAD"
#endif
);

#ifdef CONFIG_RX_ENABLED
const struct mbox_dt_spec rx_channel = MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx);
Expand All @@ -42,7 +48,11 @@ int main(void)
const struct mbox_dt_spec tx_channel = MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), tx);

while (1) {
#if defined(CONFIG_MULTITHREADING)
k_sleep(K_MSEC(2000));
#else
k_busy_wait(2000000);
#endif

printk("Ping (on channel %d)\n", tx_channel.channel_id);

Expand Down

0 comments on commit c560d2e

Please sign in to comment.