## f_read

The f_read function reads data from a file.

    FRESULT f_read (
      FIL* FileObject,    /* Pointer to the file object structure */
      void* Buffer,       /* Pointer to the buffer to store read data */
      UINT ByteToRead,    /* Number of bytes to read */
      UINT* ByteRead      /* Pointer to the variable to return number of bytes read */
    );

#### Parameters

FileObject
  Pointer to the open file object.
Buffer
  Pointer to the buffer to store read data
ByteToRead
  Number of bytes to read in range of UINT.
ByteRead
  Pointer to the UINT variable to return number of bytes read.

#### Return Values

FR_OK (0)
  The function succeeded.
FR_DENIED
  The function denied due to the file has been opened in non-read mode.
FR_DISK_ERR
  The function failed due to an error in the disk function.
FR_INT_ERR
  The function failed due to a wrong FAT structure or an internal error.
FR_NOT_READY
  The disk drive cannot work due to no medium in the drive or any other reason.
FR_INVALID_OBJECT
  The file object is invalid.

#### Description

The file pointer of the file object increases in number of bytes read. After the function succeeded, `*ByteRead` should be checked to detect end of file. In case of `*ByteRead < ByteToRead`, it means the R/W pointer reached end of file during read operation.

#### References

`f_open, fgets, f_write, f_close, FIL`

Return