Content originally posted in LPCWare by Muis on Thu Nov 22 08:12:55 MST 2012
I implemented multi-block read, but it didnt make a big difference. My main code looks like this:
if (count == 1) {/* Single block read */
if (send_cmd(CMD17, sector) == 0){ /* READ_SINGLE_BLOCK */
if (rcvr_datablock((void *)buffer, 512))
{
count = 0;
}
while(!Endpoint_IsReadWriteAllowed());
Endpoint_Write_Stream_LE((void *)buffer, 512, ((void *)0));
Endpoint_ClearIN();
}
}
else {/* Multiple block read */
if (send_cmd(CMD18, sector) == 0) {/* READ_MULTIPLE_BLOCK */
do
{
if (!rcvr_datablock((void *)buffer, 512))
{
//break;
}
while(!Endpoint_IsReadWriteAllowed());
Endpoint_Write_Stream_LE((void *)buffer, 512, ((void *)0));
Endpoint_ClearIN();
} while (--count);
send_cmd(CMD12, 0);/* STOP_TRANSMISSION */
}
}
It reads 512 byte blocks from SPI, and sends them to the USB endpoint. When waiting for the SPI block, it sends nothing to the USB endpoint, and when sending to the USB, it reads nothing from SPI. Would there be a simple way to make it operate synchronously?