cac0bd957e9e18d9647dffe1d68a26970b4195d6
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)
23 /*-----------------------------------------------------------------------*/
24 /* Read Partial Sector */
25 /*-----------------------------------------------------------------------*/
28 BYTE
* dest
, /* Pointer to the destination object */
29 DWORD sector
, /* Sector number (LBA) */
30 WORD sofs
, /* Offset in the sector */
31 WORD count
/* Byte count (bit15:destination) */
34 DRESULT ErrorCode
= RES_OK
;
35 uint8_t BlockTemp
[512];
37 if (USB_CurrentMode
== USB_MODE_Host
)
39 #if defined(USB_CAN_BE_HOST)
40 if (USB_HostState
!= HOST_STATE_Configured
)
41 ErrorCode
= RES_NOTRDY
;
42 else if (MS_Host_ReadDeviceBlocks(&DiskHost_MS_Interface
, 0, sector
, 1, 512, BlockTemp
))
43 ErrorCode
= RES_ERROR
;
48 #if defined(USB_CAN_BE_DEVICE)
49 DataflashManager_ReadBlocks_RAM(sector
, 1, BlockTemp
);
53 memcpy(dest
, &BlockTemp
[sofs
], count
);