daisy/
lib.rs

1#![no_std]
2
3//! Rust `no_std`, `embedded_hal` board support package for the Electro-Smith Daisy platform.
4//!
5//! * [Documentation](https://zlosynth.com/daisy)
6//! * [Crate (crates.io)](https://crates.io/crates/daisy)
7//! * [Repository (github.com)](https://github.com/zlosynth/daisy)
8//!
9//! # Supported boards
10//!
11//! Currently this library supports following boards:
12//!
13//! * [Daisy Seed](https://www.electro-smith.com/daisy/daisy) (codec AK4556), `seed`
14//! * [Daisy Seed 1.1](https://www.electro-smith.com/daisy/daisy) (codec WM8731), `seed_1_1`
15//! * [Daisy Seed 1.2](https://www.electro-smith.com/daisy/daisy) (codec PCM3060), `seed_1_2`
16//! * [Daisy Patch SM](https://www.electro-smith.com/daisy/patch-sm) (codec PCM3060), `patch_sm`
17//!
18//! Select the board by using its respective feature.
19//!
20//! # Sampling rate
21//!
22//! By default, the audio sampling rate is set to 48 kHz. This can be increased to
23//! 96 kHz by enabling the `sampling_rate_96khz` feature.
24//!
25//! # Block length
26//!
27//! By default, the audio block length is 32 frames. This can be increased to 64
28//! by enabling the `block_length_64` feature.
29//!
30//! # API stability
31//!
32//! I am still trying to figure out a good API for the project. Expect it to change.
33//! To mitigate breakage of your code on library update, use macros defined under
34//! `board.rs` to initialize resources whenever possible.
35//!
36//! # HAL compatibility
37//!
38//! This library is closely tied to [stm32h7xx-hal](https://github.com/stm32-rs/stm32h7xx-hal/).
39//! Make sure to use compatible versions in your `Cargo.toml`.
40//!
41//! | **Daisy**   | **HAL** |
42//! |-------------|---------|
43//! | `0.10`      | `0.16`  |
44//! | `0.9`       | `0.15`  |
45//! | `0.8`       | `0.14`  |
46//! | `0.2`-`0.7` | `0.12`  |
47//! | `0.1`       | `0.11`  |
48//!
49//! # Usage
50//!
51//! See the [examples/](https://github.com/zlosynth/daisy/tree/main/examples)
52//! directory to find usage examples:
53//!
54//! * [ADC](https://github.com/zlosynth/daisy/blob/main/examples/adc.rs)
55//! * [Audio](https://github.com/zlosynth/daisy/blob/main/examples/audio.rs)
56//! * [Audio with RTIC](https://github.com/zlosynth/daisy/blob/main/examples/audio_rtic.rs)
57//! * [Blinky](https://github.com/zlosynth/daisy/blob/main/examples/blinky.rs)
58//! * [Blinky with RTIC](https://github.com/zlosynth/daisy/blob/main/examples/blinky_rtic.rs)
59//! * [Flash storage](https://github.com/zlosynth/daisy/blob/main/examples/flash.rs)
60//! * [OLED display](https://github.com/zlosynth/daisy/blob/main/examples/oled.rs)
61//! * [SDRAM memory](https://github.com/zlosynth/daisy/blob/main/examples/sdram.rs)
62//! * [SD card](https://github.com/zlosynth/daisy/blob/main/examples/sdmmc.rs)
63//!
64//! ``` sh
65//! make flash-dfu WHAT=blinky BOARD=seed_1_1
66//! ```
67
68#[cfg(all(
69    feature = "seed_1_2",
70    any(feature = "seed_1_1", feature = "seed", feature = "patch_sm")
71))]
72compile_error!("only a single target board must be selected");
73
74#[cfg(all(
75    feature = "seed_1_1",
76    any(feature = "seed_1_2", feature = "seed", feature = "patch_sm")
77))]
78compile_error!("only a single target board must be selected");
79
80#[cfg(all(
81    feature = "seed",
82    any(feature = "seed_1_2", feature = "seed_1_1", feature = "patch_sm")
83))]
84compile_error!("only a single target board must be selected");
85
86#[cfg(all(
87    feature = "patch_sm",
88    any(feature = "seed_1_2", feature = "seed_1_1", feature = "seed")
89))]
90compile_error!("only a single target board must be selected");
91
92#[cfg(not(any(
93    feature = "seed_1_2",
94    feature = "seed_1_1",
95    feature = "seed",
96    feature = "patch_sm"
97)))]
98compile_error!(
99    "target board must be selected using a feature: \"seed_1_2\" | \"seed_1_1\" | \"seed\" | \"patch_sm\""
100);
101
102pub mod audio;
103pub mod board;
104pub mod clocks;
105pub mod flash;
106pub mod led;
107pub mod pins;
108pub mod sdram;
109
110pub use board::Board;
111pub use hal::pac;
112// Re-exported so it can be used from daisy macros.
113pub use stm32h7xx_hal as hal;