macro_rules! audio_player {
($($tt:tt)*) => { ... };
}Available on
target_os=none only.Expand description
Macro to generate an audio player struct type (includes syntax details). See
AudioPlayerGenerated
for a sample of a generated type.
See the audio_player module documentation for usage examples.
Syntax:
audio_player! {
[<visibility>] <Name> {
data_pin: <pin_ident>,
bit_clock_pin: <pin_ident>,
word_select_pin: <pin_ident>,
sample_rate_hz: <sample_rate_expr>,
pio: <pio_ident>, // optional
dma: <dma_ident>, // optional
max_clips: <usize_expr>, // optional
max_volume: <Volume_expr>, // optional
initial_volume: <Volume_expr>, // optional
}
}Inputs:
$vis- Optional generated type visibility (for example:pub,pub(crate),pub(self)). Defaults to private visibility when omitted.$name- Generated type name (for example:AudioPlayer10)
Required fields:
data_pin- GPIO pin carrying I²S data (DIN)bit_clock_pin- GPIO pin carrying I²S bit clock (BCLK)word_select_pin- GPIO pin carrying I²S word-select / LR clock (LRC/LRCLK)sample_rate_hz- Playback sample rate in hertz (for example:VOICE_22050_HZ)
Optional fields:
pio- PIO resource (default:PIO0)dma- DMA channel (default:DMA_CH0)max_clips- Maximum clips per queued play request (default:16)max_volume- Runtime volume ceiling (default:Volume::MAX)initial_volume- Initial runtime volume relative tomax_volume(default:Volume::MAX)
The generated type contains static resources and spawns its background device
task from new(...).