From 4a2f8e35bd487117e72a67da5bcf21ceae2b0094 Mon Sep 17 00:00:00 2001 From: Dickless <011001nobuo@gmail.com> Date: Mon, 9 Sep 2024 01:12:02 +0900 Subject: [PATCH] add codec_pins! macro wifh #[cfg] macro to fix #21 --- src/lib.rs | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6d05720..89de9d4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -92,6 +92,36 @@ pub fn default_rcc() -> hal::Config { config } +#[cfg(feature = "seed_1_1")] +#[macro_export] +macro_rules! codec_pins { + ($p:ident) => { + daisy_embassy::CodecPins { + // For audio, I2C only needed for WM8731 + SCL: $p.PH4, + SDA: $p.PB11, + + MCLK_A: $p.PE2, + SCK_A: $p.PE5, + FS_A: $p.PE4, + SD_A: $p.PE6, + SD_B: $p.PE3, + } + }; +} +#[cfg(feature = "seed_1_2")] +#[macro_export] +macro_rules! codec_pins { + ($p:ident) => { + daisy_embassy::CodecPins { + MCLK_A: $p.PE2, + SCK_A: $p.PE5, + FS_A: $p.PE4, + SD_A: $p.PE6, + SD_B: $p.PE3, + } + }; +} #[macro_export] macro_rules! new_daisy_board { ($p:ident) => { @@ -133,19 +163,7 @@ macro_rules! new_daisy_board { audio_peripherals: daisy_embassy::audio::AudioPeripherals { codec: daisy_embassy::Codec {}, - codec_pins: daisy_embassy::CodecPins { - // For audio, I2C only needed for WM8731 - #[cfg(feature = "seed_1_1")] - SCL: $p.PH4, - #[cfg(feature = "seed_1_1")] - SDA: $p.PB11, - - MCLK_A: $p.PE2, - SCK_A: $p.PE5, - FS_A: $p.PE4, - SD_A: $p.PE6, - SD_B: $p.PE3, - }, + codec_pins: daisy_embassy::codec_pins!($p), sai1: $p.SAI1, i2c2: $p.I2C2, dma1_ch0: $p.DMA1_CH0,