From a855e9f699b4b95f206dbcc15bce5e784e752076 Mon Sep 17 00:00:00 2001 From: occheung Date: Thu, 24 Sep 2020 17:15:07 +0800 Subject: [PATCH] flash: load data as static --- src/flash.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/flash.rs b/src/flash.rs index 21a6a3e..f705312 100644 --- a/src/flash.rs +++ b/src/flash.rs @@ -12,13 +12,15 @@ pub enum FPGAFlashError { ResetStatusError, } +const DATA: &'static [u8] = include_bytes!("../build/top.bin"); + // A public method to flash iCE40 FPGA on Humpback pub fn flash_ice40_fpga, SS: OutputPin, RST: OutputPin, DELAY: DelayUs, DONE: InputPin> - (mut spi: SPI, mut ss: SS, mut creset: RST, cdone: DONE, mut delay: DELAY, data: &[u8]) -> Result<(), FPGAFlashError> + (mut spi: SPI, mut ss: SS, mut creset: RST, cdone: DONE, mut delay: DELAY) -> Result<(), FPGAFlashError> { // Data buffer setup let mut dummy_byte :[u8; 1] = [0x00]; @@ -62,7 +64,7 @@ pub fn flash_ice40_fpga, .map_err(|_| FPGAFlashError::NegotiationError)?; // Send the whole image without interruption - for byte in data.into_iter() { + for byte in DATA.into_iter() { let mut single_byte_slice = [*byte]; spi.transfer(&mut single_byte_slice) .map_err(|_| FPGAFlashError::SPICommunicationError)?;