X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/702bec892da743c5b2d57b6a3fa2404d4d17e928..a8b66f318dda3cc18dfcedaa3af3d01ab68b82e8:/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 b40adf1d8..c2821a46a 100644 --- a/Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs/diskio.c +++ b/Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs/diskio.c @@ -1,59 +1,57 @@ -/*-----------------------------------------------------------------------*/ -/* Low level disk I/O module skeleton for Petit FatFs (C)ChaN, 2009 */ -/*-----------------------------------------------------------------------*/ - -#include "diskio.h" - -#include -#include -#include "../DataflashManager.h" -#include "../../DiskHost.h" - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize (void) -{ - return RES_OK; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Partial Sector */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_readp ( - void* dest, /* Pointer to the destination object */ - DWORD sector, /* Sector number (LBA) */ - WORD sofs, /* Offset in the sector */ - WORD count /* Byte count (bit15:destination) */ -) -{ - DRESULT ErrorCode = RES_OK; - uint8_t BlockTemp[512]; - - 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 ErrorCode; -} - +/*-----------------------------------------------------------------------*/ +/* Low level disk I/O module skeleton for Petit FatFs (C)ChaN, 2010 */ +/*-----------------------------------------------------------------------*/ + +#include "diskio.h" + +#include +#include +#include "../DataflashManager.h" +#include "../../DiskHost.h" + +/*-----------------------------------------------------------------------*/ +/* Initialize Disk Drive */ +/*-----------------------------------------------------------------------*/ + +DSTATUS disk_initialize (void) +{ + return RES_OK; +} + + + +/*-----------------------------------------------------------------------*/ +/* Read Partial Sector */ +/*-----------------------------------------------------------------------*/ + +DRESULT disk_readp ( + void* dest, /* Pointer to the destination object */ + DWORD sector, /* Sector number (LBA) */ + WORD sofs, /* Offset in the sector */ + WORD count /* Byte count (bit15:destination) */ +) +{ + DRESULT ErrorCode = RES_OK; + uint8_t BlockTemp[512]; + + 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; + #endif + } + else + { + #if defined(USB_CAN_BE_DEVICE) + DataflashManager_ReadBlocks_RAM(sector, 1, BlockTemp); + #endif + } + + memcpy(dest, &BlockTemp[sofs], count); + + return ErrorCode; +} +