disk_read

The disk_read function reads sector(s) from the disk drive.

DRESULT disk_read (
  BYTE Drive,          /* Physical drive number */
  BYTE* Buffer,        /* Pointer to the read data buffer */
  DWORD SectorNumber,  /* Start sector number */
  BYTE SectorCount     /* Number of sectros to read */
);

Parameters

Drive
Specifies the physical drive number.
Buffer
Pointer to the byte array to store the read data. The size of buffer must be in sector size * sector count.
SectorNumber
Specifies the start sector number in logical block address (LBA).
SectorCount
Specifies number of sectors to read. The value can be 1 to 128. Generally, a multiple sector transfer request must not be split into single sector transactions to the device, or you may not get good read performance.

Return Value

RES_OK (0)
The function succeeded.
RES_ERROR
Any hard error occured during the read operation and could not recover it.
RES_PARERR
Invalid parameter.
RES_NOTRDY
The disk drive has not been initialized.

Description

The specified memory address is not that always aligned to word boundary because the type of pointer is defined as BYTE. The misaligned read/write request can occure at direct transfer. If the bus architecture, especially DMA controller, does not allow misaligned memory access, it should be solved in this function. There are some workarounds below to avoid this problem.

Return