X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/9b2011455585885748164ab76dfaae76fffb0ff9..aaa0bed556d0fa424b831418a7ce2531653a8b03:/Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs/diskio.c diff --git a/Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs/diskio.c b/Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs/diskio.c index 0084fa514..013467c25 100644 --- a/Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs/diskio.c +++ b/Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs/diskio.c @@ -5,7 +5,9 @@ #include "diskio.h" #include +#include #include "../DataflashManager.h" +#include "../../DiskHost.h" /*-----------------------------------------------------------------------*/ /* Initialize Disk Drive */ @@ -33,14 +35,29 @@ DRESULT disk_readp ( WORD count /* Byte count (bit15:destination) */ ) { - DRESULT res; - + DRESULT ErrorCode = RES_OK; uint8_t BlockTemp[512]; - DataflashManager_ReadBlocks_RAM(sector, 1, BlockTemp); - memcpy(dest, &BlockTemp[sofs], count); - res = RES_OK; + if (USB_CurrentMode == USB_MODE_HOST) + { + #if defined(USB_CAN_BE_HOST) + if (USB_HostState != HOST_STATE_Configured) + ErrorCode = RES_NOTRDY; + else if (MS_Host_ReadDeviceBlocks(&DiskHost_MS_Interface, 0, sector, 1, 512, BlockTemp)) + ErrorCode = RES_ERROR; + + printf("BLOCK READ #%lu Ret %d\r\n", sector, MS_Host_ReadDeviceBlocks(&DiskHost_MS_Interface, 0, sector, 1, 512, BlockTemp)); + #endif + } + else + { + #if defined(USB_CAN_BE_DEVICE) + DataflashManager_ReadBlocks_RAM(sector, 1, BlockTemp); + #endif + } + + memcpy(dest, &BlockTemp[sofs], count); - return res; + return ErrorCode; }