Close NAND flash instance
UINT lx_nand_flash_close(LX_NAND_FLASH *nand_flash);
This service closes the previously opened NAND flash instance.
Threads
/* Close NAND flash instance "my_nand_flash". */
status = lx_nand_flash_close(&my_nand_flash);
/* If status is LX_SUCCESS the request was successful. */
Defragment NAND flash instance
UINT lx_nand_flash_defragment(LX_NAND_FLASH *nand_flash);
This service is deprecated and not supported.
Threads
/* Defragment NAND flash instance "my_nand_flash". */
status = lx_nand_flash_defragment(&my_nand_flash);
/* If status is LX_SUCCESS the request was successful. */
Enable/disable extended NAND cache
UINT lx_nand_flash_extended_cache_enable(
LX_NAND_FLASH
*nand_flash,
VOID *memory,
ULONG size);
This service is deprecated and not supported.
Threads
/* Enable the NAND flash cache for the instance "my_nand_flash". */
status = lx_nand_flash_extended_cache_enable(&my_nand_flash,
&my_memory, sizeof(my_memory));
/* If status is LX_SUCCESS the request was successful. */
Format NAND flash instance
UINT _lx_nand_flash_format(LX_NAND_FLASH* nand_flash, CHAR* name,
UINT(*nand_driver_initialize)(LX_NAND_FLASH*),
ULONG* memory_ptr, UINT memory_size);
This service erase the NAND flash and formats the NAND flash instance with the specified name, driver initialization function. Note that the driver initialization function is responsible for installing various function pointers for reading, writing, and erasing blocks/pages of the NAND hardware associated with this NAND flash instance.
Threads
/* Format NAND flash instance "my_nand_flash". */
status = lx_nand_flash_format(&my_nand_flash, "my nand flash",
my_nand_driver_initialize, &my_memory, sizeof(my_memory));
/* If status is LX_SUCCESS the NAND is erased and initial format is built, it can be opened later by calling lx_nand_flash_open. */
Initialize NAND flash support
UINT lx_nand_flash_initialize(void);
This service initializes LevelX NAND flash support. It must be called before any other LevelX NAND APIs.
Initialization, Threads
/* Initialize NAND flash support. */
status = lx_nand_flash_initialize();
/* If status is LX_SUCCESS the request was successful. */
Open NAND flash instance
UINT lx_nand_flash_open(
LX_NAND_FLASH *nand_flash,
CHAR *name,
UINT (*nand_driver_initialize) (LX_NAND_FLASH *),
ULONG* memory_ptr,
UINT memory_size);
This service opens a NAND flash instance with the specified NAND flash control block and driver initialization function. Note that the driver initialization function is responsible for installing various function pointers for reading, writing, and erasing blocks/pages of the NAND hardware associated with this NAND flash instance.
Threads
/* Open NAND flash instance "my_nand_flash" with the driver "my_nand_driver_initialize". */
status = lx_nand_flash_open(&my_nand_flash,"my nand flash",
my_nand_driver_initialize, &my_memory, sizeof(my_memory));
/* If status is LX_SUCCESS the request was successful. */
Check page for ECC errors with correction
UINT lx_nand_flash_page_ecc_check(
LX_NAND_FLASH *nand_flash,
UCHAR *page_buffer,
UCHAR *ecc_buffer);
This service verifies the integrity of the supplied NAND page buffer with the supplied ECC. Page size (defined in the NAND flash instance pointer) is assumed to be a multiple of 256-bytes and the ECC code supplied is capable of correcting a 1 bit error in each 256-byte portion of the page.
LevelX Driver
/* Check the NAND page pointed to by "page_pointer" of the NAND flash instance "my_nand_flash" . */
status = lx_nand_flash_page_ecc_check(&my_nand_flash, page_pointer, ecc_pointer);
/* If status is LX_SUCCESS the page is valid. */
Compute ECC for page
UINT lx_nand_flash_page_ecc_compute(
LX_NAND_FLASH *nand_flash,
UCHAR *page_buffer,
UCHAR *ecc_buffer);
This service computes the ECC of the supplied NAND page buffer and returns the ECC in the supplied ECC buffer. Page size is assume to be a multiple of 256-bytes (defined in the NAND flash instance pointer). The ECC code is used to verify the integrity of the page when it is read at a later time.
LevelX Driver
/* Compute ECC for the NAND page pointed to by "page_pointer" of the NAND flash instance "my_nand_flash". */
status = lx_nand_flash_page_ecc_compute(&my_nand_flash, page_pointer, ecc_pointer);
/* If status is LX_SUCCESS the ECC was calculated and Can be found in the memory pointed to by "ecc_pointer." */
Partial defragment of NAND flash instance
UINT lx_nand_flash_partial_defragment(
LX_NAND_FLASH *nand_flash,
UINT max_blocks);
This service is deprecated and not supported.
Threads
/* Defragment 1 block of NAND flash instance "my_nand_flash". */
status = lx_nand_flash_partial_defragment(&my_nand_flash, 1);
/* If status is LX_SUCCESS the request was successful. */
Read NAND flash sector
UINT lx_nand_flash_sector_read(
LX_NAND_FLASH *nand_flash,
ULONG logical_sector,
VOID *buffer);
This service reads the logical sector from the NAND flash instance and if successful returns the contents in the supplied buffer. Note that NAND sector size is always the page size of the underlying NAND hardware.
Threads
/* Read logical sector 20 of the NAND flash instance "my_nand_flash" and place contents in "buffer". */
status = lx_nand_flash_sector_read(&my_nand_flash, 20, buffer);
/* If status is LX_SUCCESS, "buffer" contains the contents of logical sector 20. */
Read multiple NAND flash sectors
UINT lx_nand_flash_sectors_read(
LX_NAND_FLASH *nand_flash,
ULONG logical_sector,
VOID *buffer,
ULONG sector_count);
This service reads the specified number of logical sectors from the NAND flash instance and if successful returns the contents in the supplied buffer. Note that NAND sector size is always the page size of the underlying NAND hardware.
Threads
/* Read 10 logical sectors starting at logical sector 20 of the NAND flash instance "my_nand_flash" and place contents in "buffer". */
status = lx_nand_flash_sectors_read(&my_nand_flash, 20, buffer, 10);
/* If status is LX_SUCCESS, "buffer" contains the contents of logical sectors 20 through 29. */
Release NAND flash sector
UINT lx_nand_flash_sector_release(
LX_NAND_FLASH *nand_flash,
ULONG logical_sector);
This service releases the logical sector mapping in the NAND flash instance. Releasing a logical sector when not used makes the LevelX wear leveling more efficient.
Threads
/* Release logical sector 20 of the NAND flash instance "my_nand_flash". */
status = lx_nand_flash_sector_release(&my_nand_flash, 20);
/* If status is LX_SUCCESS, logical sector 20 has been released. */
Release multiple NAND flash sectors
UINT lx_nand_flash_sectors_release(
LX_NAND_FLASH *nand_flash,
ULONG logical_sector,
ULONG sector_count);
This service releases the specified number of logical sectors in the NAND flash instance. Releasing a logical sector when not used makes the LevelX wear leveling more efficient.
Threads
/* Release 10 logical sectors starting at logical sector 20 of the NAND flash instance "my_nand_flash". */
status = lx_nand_flash_sectors_release(&my_nand_flash, 20, 10);
/* If status is LX_SUCCESS, logical sectors 20 through 29 have been released. */
Write NAND flash sector
UINT lx_nand_flash_sector_write(
LX_NAND_FLASH *nand_flash,
ULONG logical_sector,
VOID *buffer);
This service writes the specified logical sector in the NAND flash instance.
Threads
/* Write logical sector 20 of the NAND flash instance "my_nand_flash" with the contents pointed to by "buffer". */
status = lx_nand_flash_sector_write(&my_nand_flash, 20, buffer);
/* If status is LX_SUCCESS, logical sector 20 has been written with the contents of "buffer". */
Write multiple NAND flash sectors
UINT lx_nand_flash_sectors_write(
LX_NAND_FLASH *nand_flash,
ULONG logical_sector,
VOID *buffer,
ULONG sector_count);
This service writes the specified number of logical sectors in the NAND flash instance.
Threads
/* Write 10 logical sectors starting at logical sector 20 of the NAND flash instance "my_nand_flash" with the contents pointed to by "buffer". */
status = lx_nand_flash_sectors_write(&my_nand_flash, 20, buffer, 10);
/* If status is LX_SUCCESS, logical sectors 20 through 29 have been written with the contents of "buffer". */