/* Function: MX25_QREAD Arguments: flash_address, 32 bit flash memory address target_address, buffer address to store returned data byte_length, length of returned data in byte unit Description: The QREAD instruction enable quad throughput of Serial Flash in read mode. Return Message: FlashAddressInvalid, FlashQuadNotEnable, FlashOperationSuccess  */
ReturnMsg MX25_QREAD(uint32_t flash_address, uint8_t *target_address, uint32_t byte_length)
/* Function: MX25_QREAD Arguments: flash_address, 32 bit flash memory address target_address, buffer address to store returned data byte_length, length of returned data in byte unit Description: The QREAD instruction enable quad throughput of Serial Flash in read mode. Return Message: FlashAddressInvalid, FlashQuadNotEnable, FlashOperationSuccess  */
ReturnMsg MX25_QREAD(uint32_t flash_address, uint8_t *target_address, uint32_t byte_length)
{
    uint32_t index=0;
    uint8_t  addr_4byte_mode;
    uint8_t  dc;
    if( flash_address > FlashSize ) return FlashAddressInvalid;
    if( IsFlashQIO() != TRUE )  return FlashQuadNotEnable;
    if( IsFlash4Byte() )
        addr_4byte_mode = TRUE;
    else
        addr_4byte_mode = FALSE;
    dc = GetDummyCycle( DUMMY_CONF_QREAD );
    CS_Low();
    SendByte( FLASH_CMD_QREAD, SIO );
    SendFlashAddr( flash_address, SIO, addr_4byte_mode );
    InsertDummyCycle ( dc );
    for( index=0; index < byte_length; index=index+1)
    {
        *(target_address + index) = GetByte( QIO );
    }
    CS_High();
    return FlashOperationSuccess;
}