diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32f4/src/bin/i2s_dma.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/stm32f4/src/bin/i2s_dma.rs b/examples/stm32f4/src/bin/i2s_dma.rs new file mode 100644 index 000000000..e8d7b5f77 --- /dev/null +++ b/examples/stm32f4/src/bin/i2s_dma.rs | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use core::fmt::Write; | ||
| 6 | |||
| 7 | use defmt::*; | ||
| 8 | use embassy_executor::Spawner; | ||
| 9 | use embassy_stm32::i2s::{Config, I2S}; | ||
| 10 | use embassy_stm32::time::Hertz; | ||
| 11 | use heapless::String; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | ||
| 13 | |||
| 14 | #[embassy_executor::main] | ||
| 15 | async fn main(_spawner: Spawner) { | ||
| 16 | let p = embassy_stm32::init(Default::default()); | ||
| 17 | info!("Hello World!"); | ||
| 18 | |||
| 19 | let mut i2s = I2S::new( | ||
| 20 | p.SPI2, | ||
| 21 | p.PC3, // sd | ||
| 22 | p.PB12, // ws | ||
| 23 | p.PB10, // ck | ||
| 24 | p.PC6, // mck | ||
| 25 | p.DMA1_CH4, | ||
| 26 | p.DMA1_CH3, | ||
| 27 | Hertz(1_000_000), | ||
| 28 | Config::default(), | ||
| 29 | ); | ||
| 30 | |||
| 31 | for n in 0u32.. { | ||
| 32 | let mut write: String<128> = String::new(); | ||
| 33 | core::write!(&mut write, "Hello DMA World {}!\r\n", n).unwrap(); | ||
| 34 | i2s.write(&mut write.as_bytes()).await.ok(); | ||
| 35 | } | ||
| 36 | } | ||
