flash: load data as static
This commit is contained in:
parent
26c987bd04
commit
a855e9f699
@ -12,13 +12,15 @@ pub enum FPGAFlashError {
|
|||||||
ResetStatusError,
|
ResetStatusError,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DATA: &'static [u8] = include_bytes!("../build/top.bin");
|
||||||
|
|
||||||
// A public method to flash iCE40 FPGA on Humpback
|
// A public method to flash iCE40 FPGA on Humpback
|
||||||
pub fn flash_ice40_fpga<SPI: Transfer<u8>,
|
pub fn flash_ice40_fpga<SPI: Transfer<u8>,
|
||||||
SS: OutputPin,
|
SS: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs<u32>,
|
DELAY: DelayUs<u32>,
|
||||||
DONE: InputPin>
|
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
|
// Data buffer setup
|
||||||
let mut dummy_byte :[u8; 1] = [0x00];
|
let mut dummy_byte :[u8; 1] = [0x00];
|
||||||
@ -62,7 +64,7 @@ pub fn flash_ice40_fpga<SPI: Transfer<u8>,
|
|||||||
.map_err(|_| FPGAFlashError::NegotiationError)?;
|
.map_err(|_| FPGAFlashError::NegotiationError)?;
|
||||||
|
|
||||||
// Send the whole image without interruption
|
// Send the whole image without interruption
|
||||||
for byte in data.into_iter() {
|
for byte in DATA.into_iter() {
|
||||||
let mut single_byte_slice = [*byte];
|
let mut single_byte_slice = [*byte];
|
||||||
spi.transfer(&mut single_byte_slice)
|
spi.transfer(&mut single_byte_slice)
|
||||||
.map_err(|_| FPGAFlashError::SPICommunicationError)?;
|
.map_err(|_| FPGAFlashError::SPICommunicationError)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user