Skip to content

Commit 64c9b91

Browse files
committed
samples: drivers: video: add DT_HAS_CHOSEN() safeguards
Add macros giving hints to users using #error, about what might be missing to build and run the samples, such as a missing "chosen" devicetree node. Signed-off-by: Josuah Demangeon <me@josuah.net>
1 parent ad4c3e3 commit 64c9b91

File tree

2 files changed

+12
-0
lines changed
  • samples/drivers/video

2 files changed

+12
-0
lines changed

samples/drivers/video/capture/src/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ LOG_MODULE_REGISTER(main, LOG_LEVEL_DBG);
2222
LOG_MODULE_REGISTER(main, CONFIG_LOG_DEFAULT_LEVEL);
2323
#endif
2424

25+
#if !DT_HAS_CHOSEN(zephyr_camera)
26+
#error No camera chosen in devicetree. Missing "--shield" or "--snippet video-sw-generator" flag?
27+
#endif
28+
2529
#if DT_HAS_CHOSEN(zephyr_display)
2630
static inline int display_setup(const struct device *const display_dev, const uint32_t pixfmt)
2731
{

samples/drivers/video/capture_to_lvgl/src/main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414

1515
LOG_MODULE_REGISTER(main, CONFIG_LOG_DEFAULT_LEVEL);
1616

17+
#if !DT_HAS_CHOSEN(zephyr_camera)
18+
#error No camera chosen in devicetree. Missing "--shield" or "--snippet video-sw-generator" flag?
19+
#endif
20+
21+
#if !DT_HAS_CHOSEN(zephyr_display)
22+
#error No display chosen in devicetree. Missing "--shield" flag?
23+
#endif
24+
1725
int main(void)
1826
{
1927
struct video_buffer *buffers[2];

0 commit comments

Comments
 (0)