Skip to content

Commit 72b0f08

Browse files
sylvioalvesdanieldegrasse
authored andcommitted
samples: i2s echo: guard audio_codec configuration
Ensure the I2S echo sample only configures the audio_codec driver when the `audio_codec` node is defined and enabled in the devicetree. Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
1 parent 24322c6 commit 72b0f08

File tree

1 file changed

+1
-2
lines changed
  • samples/drivers/i2s/echo/src

1 file changed

+1
-2
lines changed

samples/drivers/i2s/echo/src/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ int main(void)
258258
return 0;
259259
}
260260

261-
#else
261+
#elif DT_NODE_HAS_STATUS(DT_NODELABEL(audio_codec), okay)
262262
const struct device *const codec_dev = DEVICE_DT_GET(DT_NODELABEL(audio_codec));
263263
struct audio_codec_cfg audio_cfg;
264264

@@ -273,7 +273,6 @@ int main(void)
273273
audio_cfg.dai_cfg.i2s.block_size = BLOCK_SIZE;
274274
audio_codec_configure(codec_dev, &audio_cfg);
275275
k_msleep(1000);
276-
277276
#endif
278277

279278
if (!init_buttons()) {

0 commit comments

Comments
 (0)