From 89f9b48073dc0f6def3c5af715359ce6626f9f6b Mon Sep 17 00:00:00 2001 From: occheung Date: Thu, 17 Sep 2020 10:21:50 +0800 Subject: [PATCH] fpga config: fix spi transmission --- examples/fpga_config.rs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/examples/fpga_config.rs b/examples/fpga_config.rs index ddc069f..18ddfe2 100644 --- a/examples/fpga_config.rs +++ b/examples/fpga_config.rs @@ -1,8 +1,9 @@ #![no_main] #![no_std] -#[macro_use] extern crate log; +use log::debug; + use stm32h7xx_hal::hal::digital::v2::{ InputPin, OutputPin, @@ -108,19 +109,13 @@ fn main() -> ! { // Drive SPI_SS_B low fpga_ss.set_low().unwrap(); - let config_data = include_bytes!("../build/top.bin"); - fpga_cfg_spi.transfer(&config_data).unwrap(); - // Send the whole image without interruption - // let base_address = 0x08100000; - // let size = 135100; - // for index in 0..size { - // unsafe { - // let data :u8 = ptr::read_volatile((base_address + index) as *const u8); - // block!(fpga_cfg_spi.send(data)).unwrap(); - // block!(fpga_cfg_spi.read()).unwrap(); - // } - // } + let config_data = include_bytes!("../build/top.bin"); + + for byte in config_data.into_iter() { + block!(fpga_cfg_spi.send(*byte)).unwrap(); + block!(fpga_cfg_spi.read()).unwrap(); + } // Drive SPI_SS_B high fpga_ss.set_high().unwrap();