Hello Maximilian,
In fact there is a callback to tell when the data receive is finished. In this example, you can check the status in USB_DeviceMscBulkOut.
The KSDK USB stack provides a similar example, usb_device_composite_cdc_msc_sdcard_lite , which works with SD Card instead of SPI flash. You can refer to that example as well. This example may not exist in KL26Z256 package due to the hardware limitation. However, you could get the example’s source code from some other packages, e.g. FRDM-K64.
In disk_sdcard.c,
It writes data to SD card in the callback USB_DeviceMscBulkOut mentioned above.
usb_status_t USB_DeviceMscBulkOut(usb_device_handle deviceHandle,
usb_device_endpoint_callback_message_struct_t *event,
void *arg)
…
…
…
/*write the data to sd card*/
if (0 != event->length)
{
if (kStatus_Success != SD_WriteBlocks(usbDeviceMscCard, event->buffer, mscHandle->currentOffset,
event->length >> USB_DEVICE_SDCARD_BLOCK_SIZE_POWER))
{
g_deviceComposite->mscDisk.readWriteError = 1;
usb_echo(
"Write error, error = 0xx%x \t Please check write request buffer size(must be less than 128 "
"sectors)\r\n",
error);
error = kStatus_USB_Error;
}
}
I hope this helps you.
Best Regards,
Iva