From 064e9b44bfd822187d703f55f3ce1d8ea1a2299b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Baptiste=20Th=C3=A9ou?= Date: Mon, 22 Jan 2024 22:15:58 +0800 Subject: [PATCH] spi-dma: fix warnings (#114) Signed-off-by: Jean-Baptiste Theou Co-authored-by: Jean-Baptiste Theou --- examples/spi-dma.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/spi-dma.rs b/examples/spi-dma.rs index c18f3e95..04533e3f 100644 --- a/examples/spi-dma.rs +++ b/examples/spi-dma.rs @@ -5,7 +5,6 @@ #![no_std] use crate::hal::{ - block, delay::DelayFromCountDownTimer, gpio::gpioa::PA5, gpio::gpioa::PA6, @@ -22,7 +21,6 @@ use crate::hal::{ }; use cortex_m_rt::entry; -use log::info; use stm32g4xx_hal as hal; use stm32g4xx_hal::dma::config::DmaConfig; use stm32g4xx_hal::dma::stream::DMAExt; @@ -49,18 +47,19 @@ fn main() -> ! { let miso: PA6> = gpioa.pa6.into_alternate(); let mosi: PA7> = gpioa.pa7.into_alternate(); - let mut spi = dp + let spi = dp .SPI1 .spi((sclk, miso, mosi), spi::MODE_0, 400.kHz(), &mut rcc); - let mut streams = dp.DMA1.split(&rcc); + let streams = dp.DMA1.split(&rcc); let config = DmaConfig::default() .transfer_complete_interrupt(false) .circular_buffer(true) .memory_increment(true); let mut buf: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE]; - for index in 0..BUFFER_SIZE { - buf[index] = index as u8; + /* Set a some datas */ + for (index, item) in buf.iter_mut().enumerate().take(BUFFER_SIZE) { + *item = index as u8; } let dma_buf = cortex_m::singleton!(: [u8; BUFFER_SIZE] = buf).unwrap(); let mut transfer_dma =