Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Dicklessgreat/daisy-embassy

Repository files navigation

NOTE!! This repository has been moved!!

The project has moved to a new location: daisy-embassy/daisy-embassy.

Please visit the new repository for the latest updates and development, and please update any git references in your Cargo.toml or other tooling.

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) supports async handling 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 = daisy_embassy::default_rcc();
// initialize the "board"
let p = hal::init(config);
let board: DaisyBoard<'_> = new_daisy_board!(p);

// build the "interface"
let mut interface = board
    .audio_peripherals
    .prepare_interface(Default::default())
    .await;

// start audio callback
interface
    .start(|input, output| {
        // process audio data
        // here we just copy input to output
        output.copy_from_slice(input);
    })
    .await;

How It Works

  • Macro Simplicity: The new_daisy_board! macro moves necessary objects from embassy::Peripherals into builders like daisy_embassy::AudioPeripherals or daisy_embassy::FlashBuilder and so on, streamlining peripheral initialization.
  • Builder Pattern: Peripherals are accessed via a XXXBuilder struct, which provides builder methods (in the case above, .prepare_interface()) for safe configuration.
  • Flexibility: Builders expose pub accessors, 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
Daisy Seed 1.1 Rev5 WM8731 ✅ Supported
Daisy Seed 1.2 Rev7 PCM3060 ✅ Supported
Daisy Seed (AK4556) - AK4556 🚧 Not yet
Daisy Patch SM - - 🚧 Not yet

Note: Additional board support is planned. Contributions are welcome; see the Issues page for details.


Getting Started

Prerequisites

  • Rust Toolchain: Install via rustup:

    rustup target add thumbv7em-none-eabihf
  • probe-rs: For flashing and debugging, install probe-rs.

  • Daisy Seed: Supported board (Rev5 or Rev7) and USB cable.

Tip: If probe-rs fails, verify your board connection and check probe-rs docs.

Setup and Run

  1. Clone the Repository:

    git clone https://github.com/Dicklessgreat/daisy-embassy.git
    cd daisy-embassy
  2. Identify Your Board:

    • Rev5 (WM8731): Default, no extra flags.
    • Rev7 (PCM3060): Use --features=seed_1_2 --no-default-features.
  3. Run an Example:

    # Rev5: Blinky example
    cargo run --example blinky --release
    
    # Rev7: Triangle wave example
    cargo run --example triangle_wave_tx --features=seed_1_2 --no-default-features --release
  4. Build and Customize:

    • Explore examples/ for demos like passthrough.rs or triangle_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.

Resources


License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •