1 /*-----------------------------------------------------------------------*/
2 /* Low level disk I/O module skeleton for Petit FatFs (C)ChaN, 2009 */
3 /*-----------------------------------------------------------------------*/
8 #include <LUFA/Drivers/USB/Class/MassStorage.h>
9 #include "../DataflashManager.h"
10 #include "../../DiskHost.h"
12 /*-----------------------------------------------------------------------*/
13 /* Initialize Disk Drive */
14 /*-----------------------------------------------------------------------*/
16 DSTATUS
disk_initialize (void)
27 /*-----------------------------------------------------------------------*/
28 /* Read Partial Sector */
29 /*-----------------------------------------------------------------------*/
32 void* dest
, /* Pointer to the destination object */
33 DWORD sector
, /* Sector number (LBA) */
34 WORD sofs
, /* Offset in the sector */
35 WORD count
/* Byte count (bit15:destination) */
38 DRESULT ErrorCode
= RES_OK
;
39 uint8_t BlockTemp
[512];
41 if (USB_CurrentMode
== USB_MODE_HOST
)
43 #if defined(USB_CAN_BE_HOST)
44 if (USB_HostState
!= HOST_STATE_Configured
)
45 ErrorCode
= RES_NOTRDY
;
46 else if (MS_Host_ReadDeviceBlocks(&DiskHost_MS_Interface
, 0, sector
, 1, 512, BlockTemp
))
47 ErrorCode
= RES_ERROR
;
49 printf("BLOCK READ #%lu Ret %d\r\n", sector
, MS_Host_ReadDeviceBlocks(&DiskHost_MS_Interface
, 0, sector
, 1, 512, BlockTemp
));
54 #if defined(USB_CAN_BE_DEVICE)
55 DataflashManager_ReadBlocks_RAM(sector
, 1, BlockTemp
);
59 memcpy(dest
, &BlockTemp
[sofs
], count
);