From 759a9411aa30960204c7c952c339a0d98820ac2c Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Thu, 6 Aug 2026 11:41:36 -0700 Subject: [PATCH 1/2] add version detection for seed3 --- src/daisy_seed.cpp | 18 ++++++++++++++---- src/daisy_seed.h | 32 ++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/daisy_seed.cpp b/src/daisy_seed.cpp index 88e74ce4e..769d5c3d8 100644 --- a/src/daisy_seed.cpp +++ b/src/daisy_seed.cpp @@ -303,6 +303,7 @@ void DaisySeed::ConfigureAudio() case BoardVersion::DAISY_SEED: default: { + // Same configuration used for Seed Rev4, Seed Rev7 (1.2), and Seed3 // Data Line Directions sai_config.a_dir = SaiHandle::Config::Direction::TRANSMIT; sai_config.pin_config.sa = Pin(PORTE, 6); @@ -342,22 +343,31 @@ DaisySeed::BoardVersion DaisySeed::CheckBoardVersion() { /** Version Checks: * * Fall through is Daisy Seed v1 (aka Daisy Seed rev4) - * * PD3 tied to gnd is Daisy Seed v1.1 (aka Daisy Seed rev5) - * * PD4 tied to gnd reserved for future hardware + * * PD3 tied to GND is Daisy Seed 1.1 (aka Daisy Seed rev5) + * * PD4 tied to GND is Daisy Seed2 DFM + * * PD5 tied to GND is Daisy Seed 1.2 (aka Daisy Seed rev7) + * * PH6 tied to GND is Daisy Seed 3 */ /** Initialize GPIO */ - GPIO s2dfm_gpio, seed_1_1_gpio; + GPIO s2dfm_gpio, seed_1_1_gpio, seed_1_2_gpio, seed_3_gpio; Pin seed_1_1_pin(PORTD, 3); Pin s2dfm_pin(PORTD, 4); + Pin seed_1_2_pin(PORTD, 5); + Pin seed_3_pin(PORTH, 6); seed_1_1_gpio.Init(seed_1_1_pin, GPIO::Mode::INPUT, GPIO::Pull::PULLUP); s2dfm_gpio.Init(s2dfm_pin, GPIO::Mode::INPUT, GPIO::Pull::PULLUP); + seed_1_2_gpio.Init(seed_1_2_pin, GPIO::Mode::INPUT, GPIO::Pull::PULLUP); + seed_3_gpio.Init(seed_3_pin, GPIO::Mode::INPUT, GPIO::Pull::PULLUP); - /** Perform Check */ if(!seed_1_1_gpio.Read()) return BoardVersion::DAISY_SEED_1_1; else if(!s2dfm_gpio.Read()) return BoardVersion::DAISY_SEED_2_DFM; + else if(!seed_1_2_gpio.Read()) + return BoardVersion::DAISY_SEED_1_2; + else if(!seed_3_gpio.Read()) + return BoardVersion::DAISY_SEED_3; else return BoardVersion::DAISY_SEED; } diff --git a/src/daisy_seed.h b/src/daisy_seed.h index af449ce26..0404c9db8 100644 --- a/src/daisy_seed.h +++ b/src/daisy_seed.h @@ -10,7 +10,7 @@ namespace daisy { /** - @brief This is the higher-level interface for the Daisy board. \n + @brief This is the higher-level interface for the Daisy board. \n All basic peripheral configuration/initialization is setup here. \n @ingroup boards @@ -21,12 +21,12 @@ class DaisySeed DaisySeed() {} ~DaisySeed() {} - /** This function used to provide a pre-initialization configuraiton + /** This function used to provide a pre-initialization configuraiton * it has since been deprecated, and does nothing. */ void Configure(); - /** + /** Initializes the Daisy Seed and the following peripherals: SDRAM, QSPI, 24-bit 48kHz Audio via AK4556, Internal USB, as well as the built-in LED and Testpoint. @@ -37,18 +37,18 @@ class DaisySeed */ void Init(bool boost = false); - /** + /** Deinitializes all peripherals automatically handled by `Init`. */ void DeInit(); - /** + /** Wait some ms before going on. \param del Delay time in ms. */ void DelayMs(size_t del); - /** + /** Returns the gpio_pin corresponding to the index 0-31. For the given GPIO on the Daisy Seed (labeled 1-32 in docs). */ @@ -97,9 +97,9 @@ class DaisySeed /** Returns the rate in Hz that the Audio callback is called */ float AudioCallbackRate() const; - /** Returns the SAI Handle for the Daisy Seed + /** Returns the SAI Handle for the Daisy Seed * This can be useful when adding a secondary codec, - * the result of this function can be passed to the audio reinit + * the result of this function can be passed to the audio reinit * with an SAI2 configuration */ const SaiHandle& AudioSaiHandle() const; @@ -149,7 +149,7 @@ class DaisySeed System system; Ak4556 codec; - /** Internal indices for DaisySeed-equivalent devices + /** Internal indices for DaisySeed-equivalent devices * This shouldn't have any effect on user-facing code, * and only needs to be checked to properly initialize * the onboard-circuits. @@ -168,6 +168,18 @@ class DaisySeed * as well as an improved audio codec (PCM3060) */ DAISY_SEED_2_DFM, + /** Daisy Seed 1.2 (aka Daisy Seed Rev7) + * Pin-compatible version of the Daisy Seed that uses + * the PCM3060 audio codec + */ + DAISY_SEED_1_2, + /** Daisy Seed3 + * Pin-compatible version of the Daisy Seed that uses + * the TAC5242, has a USB-C connector, and replaced + * the SMT Debug connector with pads for installing a + * through-hole connector. + */ + DAISY_SEED_3, }; /** Returns the BoardVersion detected during intiialization */ @@ -189,7 +201,7 @@ class DaisySeed SaiHandle sai_1_handle_; }; -/** seed namespace contains pinout constants for addressing +/** seed namespace contains pinout constants for addressing * the pins on the Daisy Seed SOM. */ namespace seed From e1f740a5a7fe38e6d6d41281bf99fe7a2bb3827b Mon Sep 17 00:00:00 2001 From: Stephen Hensley Date: Thu, 6 Aug 2026 11:41:58 -0700 Subject: [PATCH 2/2] add 192kHz samplerate to sai --- src/per/sai.cpp | 5 +++++ src/per/sai.h | 29 +++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/per/sai.cpp b/src/per/sai.cpp index 95e56330a..f6067444a 100644 --- a/src/per/sai.cpp +++ b/src/per/sai.cpp @@ -113,6 +113,10 @@ SaiHandle::Result SaiHandle::Impl::Init(const SaiHandle::Config& config) sai_a_handle_.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_96K; sai_b_handle_.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_96K; break; + case Config::SampleRate::SAI_192KHZ: + sai_a_handle_.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_192K; + sai_b_handle_.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_192K; + break; default: break; } const bool both_blocks_slave = config.a_sync == Config::Sync::SLAVE @@ -362,6 +366,7 @@ float SaiHandle::Impl::GetSampleRate() case Config::SampleRate::SAI_32KHZ: return 32000.f; case Config::SampleRate::SAI_48KHZ: return 48000.f; case Config::SampleRate::SAI_96KHZ: return 96000.f; + case Config::SampleRate::SAI_192KHZ: return 192000.f; default: return 48000.f; } } diff --git a/src/per/sai.h b/src/per/sai.h index 54c0e72a9..e4c6b1b90 100644 --- a/src/per/sai.h +++ b/src/per/sai.h @@ -7,20 +7,20 @@ namespace daisy { -/** +/** * Support for I2S Audio Protocol with different bit-depth, samplerate options - * Allows for master or slave, as well as freedom of selecting direction, + * Allows for master or slave, as well as freedom of selecting direction, * and other behavior for each peripheral, and block. - * + * * DMA Transfer commands must use buffers located within non-cached memory or use cache maintenance * To declare an unitialized global element in the DMA memory section: * int32_t DSY_DMA_BUFFER_SECTOR my_buffer[96]; * - * Callback functions will be called once per half of the buffer. In the above example, + * Callback functions will be called once per half of the buffer. In the above example, * the callback function would be called once for every 48 samples. - * + * * Use SAI Handle like this: - * + * * SaiHandle::Config sai_config; * sai_config.periph = SaiHandle::Config::Peripheral::SAI_1; * sai_config.sr = SaiHandle::Config::SampleRate::SAI_48KHZ; @@ -61,6 +61,7 @@ class SaiHandle SAI_32KHZ, SAI_48KHZ, SAI_96KHZ, + SAI_192KHZ, }; /** Bit Depth that the hardware expects to be transferred to/from the device. */ @@ -71,7 +72,7 @@ class SaiHandle SAI_32BIT, }; - /** Specifies whether a particular block is the master or the slave + /** Specifies whether a particular block is the master or the slave ** If both are set to slave, no MCLK signal will be used, and it is ** expected that the codec will have its own xtal. */ @@ -119,16 +120,16 @@ class SaiHandle /** Returns the current configuration */ const Config& GetConfig() const; - /** Callback Function to be called when DMA transfer is complete and half complete. + /** Callback Function to be called when DMA transfer is complete and half complete. ** This callback is prepared however the data is transmitted/received from the device. ** For example, using an AK4556 the data will be interleaved 24bit MSB Justified - ** + ** ** The hid/audio class will be allow for type conversions, de-interleaving, etc. */ typedef void (*CallbackFunctionPtr)(int32_t* in, int32_t* out, size_t size); - /** Starts Rx and Tx in Circular Buffer Mode - ** The callback will be called when half of the buffer is ready, + /** Starts Rx and Tx in Circular Buffer Mode + ** The callback will be called when half of the buffer is ready, ** and will handle size/2 samples per callback. */ Result StartDma(int32_t* buffer_rx, @@ -142,12 +143,12 @@ class SaiHandle /** Returns the samplerate based on the current configuration */ float GetSampleRate(); - /** Returns the number of samples per audio block + /** Returns the number of samples per audio block ** Calculated as Buffer Size / 2 / number of channels */ size_t GetBlockSize(); - /** Returns the Block Rate of the current stream based on the size - ** of the buffer passed in, and the current samplerate. + /** Returns the Block Rate of the current stream based on the size + ** of the buffer passed in, and the current samplerate. */ float GetBlockRate();