Micron MT29F NAND driver
|
MT_uint8 NAND_Page_Read | ( | nand_addr_t | addr, |
flash_width * | buffer, | ||
MT_uint32 | lenght | ||
) |
The READ PAGE (00h–30h) command copies a page from the NAND Flash array to its respective cache register and enables data output. This command is accepted by the die (LUN) when it is ready (RDY = 1, ARDY = 1).
[in] | nand_addr_t | addr: address where to start reading |
[in] | MT_uint32 | lenght: number of byte (or word if x16 device) to read |
[out] | flash_width | *buffer: the buffer contains the data read from the flash |
DRIVER_STATUS_NOT_INITIALIZED | |
NAND_INVALID_NAND_ADDRESS | |
NAND_READ_FAILED | |
NAND_SUCCESS | |
NAND_TIMEOUT |
Definition at line 683 of file nand_MT29F_lld.c.
References __build_cycle_addr(), __is_valid_addr(), __wait_for_ready(), CMD_READ_CONFIRM, CMD_READ_MODE, parameter_page_t::data_bytes_per_page, device_info, driver_status, DRIVER_STATUS_INITIALIZED, DRIVER_STATUS_NOT_INITIALIZED, parameter_page_t::feature, NAND_INVALID_LENGHT, NAND_INVALID_NAND_ADDRESS, NAND_READ_FAILED, NAND_Read_Status(), NAND_SUCCESS, NUM_OF_ADDR_CYCLE, PLATFORM_Close(), PLATFORM_Open(), PLATFORM_ReadData(), PLATFORM_SendAddr(), PLATFORM_SendCmd(), STATUS_FAIL, and SUPPORTED_16_BIT_DATA_BUS_WIDTH.
{ MT_uint8 row_address[5]; MT_uint8 status_reg; MT_uint8 ret; int i; /* verify if driver is initialized */ if(DRIVER_STATUS_INITIALIZED != driver_status) return DRIVER_STATUS_NOT_INITIALIZED; /* check input parameters */ if(NAND_SUCCESS != __is_valid_addr(addr)) return NAND_INVALID_NAND_ADDRESS; /* x16 */ if((device_info.feature & SUPPORTED_16_BIT_DATA_BUS_WIDTH) != 0) { if(lenght > (device_info.data_bytes_per_page >> 1) ) return NAND_INVALID_LENGHT; } /* x8 */ if(lenght > device_info.data_bytes_per_page) return NAND_INVALID_LENGHT; __build_cycle_addr(addr, row_address); /* init board transfer */ PLATFORM_Open(); /* send command */ PLATFORM_SendCmd(CMD_READ_MODE); /* send address */ for(i=0; i<NUM_OF_ADDR_CYCLE; i++) PLATFORM_SendAddr(row_address[i]); /* return to read mode */ PLATFORM_SendCmd(CMD_READ_CONFIRM); /* wait */ ret = __wait_for_ready(); /* return if timeout */ if (NAND_SUCCESS != ret) return ret; /* read data */ for(i=0; i<lenght; i++) buffer[i] = PLATFORM_ReadData(); /* read status register on exit */ status_reg = NAND_Read_Status(); /* close board transfer */ PLATFORM_Close(); if(status_reg & STATUS_FAIL) return NAND_READ_FAILED; return ret; }