Code: Select all
void configFpga(client spi_master_async_if spi_if) {
char * movable txbuf;
char * movable rxbuf;
char * flashPage;
unsigned *ptr;
unsigned remainToSend = 5000;
unsigned fpgaConfigReadPageNumber = 1;
fl_connectToDevice(flashPorts, flashDevices, FLASH_NUM_DEVICES);
pageSize = fl_getPageSize();
txbuf = malloc(pageSize);
rxbuf = malloc(pageSize);
flashPage = malloc(pageSize);
fl_readDataPage(fpgaConfigReadPageNumber, flashPage))
memcpy(txbuf, flashPage, pageSize);
[...]
// loop: send data via SPI Master, meanwhile read more data into flashPage using libflash
// retrieve buffers when SPI Master has finished the transaction
// memcpy flashPage to txbuf as above, loop more data is available
free(flashPage);
// free(rxbuf); free(txbuf); //<-- needed or not needed?
}