daisy-embassy
daisy-embassy is a Rust crate for building embedded async audio applications on the Daisy Seed using the Embassy framework. It provides a streamlined interface to initialize and configure Daisy Seed hardware for both low-latency, non-blocking audio processing and powerful asynchronous application processing, making it an ideal starting point for embedded audio projects in Rust.
This crate is designed for developers familiar with embedded systems and audio processing, but new to Rust's embedded ecosystem. It enables safe and flexible audio application development, leveraging Rust's type system to prevent common peripheral configuration errors at compile time.
Key Features
- Audio Processing as an Integrated Task: You can treat audio processing as a dedicated task within the Embassy async runtime, ensuring low-latency, non-blocking audio output. This approach allows seamless integration with other system tasks, enabling efficient resource sharing and predictable performance for audio applications on the Daisy Seed.
- Asynchronous Application Processing: Leverage the power of Embassy's async framework to build responsive and efficient applications.
daisy-embassy(and embassy) supportsasynchandling of GPIO interrupts, MIDI message stream reading/writing, OLED display updates, AD/DA streaming, and other application logic, allowing developers to create complex, event-driven audio projects with ease. - Simplified Setup: Use the
new_daisy_board!macro to initialize Daisy Seed peripherals with minimal boilerplate. - Safe Configuration: Get sane clock defaults via
daisy_embassy::default_rcc, and avoid the usual headaches of manual peripheral and DMA setup. - Flexible API: Access peripherals through builder structs for safe defaults, or dive deeper with public accessors for custom configurations.
- Community-Inspired: Built on foundations from stm32h7xx-hal, daisy_bsp, zlosynth/daisy, and libdaisy-rust.
Quick Start: Audio Passthrough Example
To demonstrate the ease of use, here's a simplified version of the passthrough.rs example, which sets up an audio passthrough (input to output) using the new_daisy_board! macro:
// safe clock configuration
let config = default_rcc;
// initialize the "board"
let p = init;
let board: = new_daisy_board!;
// build the "interface"
let mut interface = board
.audio_peripherals
.prepare_interface
.await;
// start audio interface
let mut interface = unwrap!;
// start audio callback
unwrap!;
How It Works
- Macro Simplicity: The
new_daisy_board!macro moves necessary objects fromembassy_stm32::Peripheralsinto builders likedaisy_embassy::AudioPeripheralsordaisy_embassy::FlashBuilderand so on, streamlining peripheral initialization. - Builder Pattern: Peripherals are accessed via a
XXXBuilderstruct, which provides builder methods (in the case above,.prepare_interface()) for safe configuration. - Flexibility: Builders expose
pubaccessors, allowing advanced users to bypass our building and implement custom initialization logic for peripherals. - Safety: The API ensures memory safety and correct peripheral usage, aligning with Rust's guarantees.
See the examples/ directory for more demos, such as blinky.rs or triangle_wave_tx.rs.
Supported Daisy Boards
| Board | Revision | Codec | Status | Tested |
|---|---|---|---|---|
| Daisy Seed 1.1 | Rev5 | WM8731 | ✅ Supported | 0.2.3 |
| Daisy Seed 1.2 | Rev7 | PCM3060 | ✅ Supported | 0.2.2 |
| Daisy Seed (AK4556) | Rev4 | AK4556 | ✅ Supported | 0.2.3 |
| Daisy Patch SM | - | PCM3060 | ✅ Supported | 0.2.3 |
Test reports and confirmations for 0.2.3 on Daisy Seed 1.2 are very welcome.
Getting Started
Prerequisites
-
Rust Toolchain: Install via rustup:
-
probe-rs: For flashing and debugging, install probe-rs.
-
Hardware: Supported board (Daisy Seed Rev4, Rev5, or Rev7, or Daisy Patch SM), USB cable, and debug probe(e.g. ST-Link V3 MINIE).
Tip: If probe-rs fails, verify your board connection and check probe-rs docs.
Setup and Run
-
Clone the Repository:
-
Identify Your Board:
- Daisy Seed Rev5 (WM8731): Default, no extra flags.
- Daisy Seed Rev7 (PCM3060): Use
--features=seed_1_2 --no-default-features. - Daisy Patch SM: Use
--features=patch_sm --no-default-features.
-
Run an Example:
# Rev4: Passthrough example # Rev5: Blinky example # Rev7: Triangle wave example # Path SM: looper example -
Build and Customize:
- Explore
examples/for demos likepassthrough.rsortriangle_wave_tx.rs. - Modify examples to create custom audio applications.
- Debug issues using probe-rs logs.
- When you find a bug, need help, or have suggestions, open an Issue.
- Explore
Sample Projects
Announcements
- add Seed Rev4(AK4556) support(version
0.2.2) - add Daisy Patch SM support(version
0.2.1) - version
0.2.0(and0.1.0)
Resources
- Daisy
- Embassy Documentation
- probe-rs Guide
- Daisy Community Forum for hardware-related questions.
License
This project is licensed under the MIT License.