unofficial-rtos-docs

Chapter 4 - LevelX NAND APIs

lx_nand_flash_close

Close NAND flash instance

Prototype

UINT lx_nand_flash_close(LX_NAND_FLASH *nand_flash);

Description

This service closes the previously opened NAND flash instance.

Input Parameters

Return Values

Allowed From

Threads

Example

/* Close NAND flash instance "my_nand_flash". */
status = lx_nand_flash_close(&my_nand_flash);  
  
/* If status is LX_SUCCESS the request was successful. */

See Also

lx_nand_flash_defragment

Defragment NAND flash instance

Prototype

UINT lx_nand_flash_defragment(LX_NAND_FLASH *nand_flash);

Description

This service is deprecated and not supported.

Input Parameters

Return Values

Allowed From

Threads

Example

/* Defragment NAND flash instance "my_nand_flash". */  
status = lx_nand_flash_defragment(&my_nand_flash);  
  
/* If status is LX_SUCCESS the request was successful. */

See Also

lx_nand_flash_extended_cache_enable

Enable/disable extended NAND cache

Prototype

UINT lx_nand_flash_extended_cache_enable(
    LX_NAND_FLASH
    *nand_flash,  
    VOID *memory, 
    ULONG size);

Description

This service is deprecated and not supported.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

See Also

lx_nand_flash_format

Format NAND flash instance

Prototype

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);

Description

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.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

See Also

lx_nand_flash_initialize

Initialize NAND flash support

Prototype

UINT lx_nand_flash_initialize(void);

Description

This service initializes LevelX NAND flash support. It must be called before any other LevelX NAND APIs.

Input Parameters

Return Values

Allowed From

Initialization, Threads

Example

/* Initialize NAND flash support. */
status = lx_nand_flash_initialize();  
  
/* If status is LX_SUCCESS the request was successful. */

See Also

lx_nand_flash_open

Open NAND flash instance

Prototype

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);

Description

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.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

See Also

lx_nand_flash_page_ecc_check

Check page for ECC errors with correction

Prototype

UINT lx_nand_flash_page_ecc_check(
    LX_NAND_FLASH *nand_flash,  
    UCHAR *page_buffer, 
    UCHAR *ecc_buffer);

Description

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.

Input Parameters

Return Values

Allowed From

LevelX Driver

Example

/* 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. */

See Also

lx_nand_flash_page_ecc_compute

Compute ECC for page

Prototype

UINT lx_nand_flash_page_ecc_compute(
    LX_NAND_FLASH *nand_flash,  
    UCHAR *page_buffer, 
    UCHAR *ecc_buffer);

Description

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.

Input Parameters

Return Values

Allowed From

LevelX Driver

Example

/* 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." */

See Also

lx_nand_flash_partial_defragment

Partial defragment of NAND flash instance

Prototype

UINT lx_nand_flash_partial_defragment(
    LX_NAND_FLASH *nand_flash,  
    UINT max_blocks);

Description

This service is deprecated and not supported.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

See Also

lx_nand_flash_sector_read

Read NAND flash sector

Prototype

UINT lx_nand_flash_sector_read(
    LX_NAND_FLASH *nand_flash,  
    ULONG logical_sector, 
    VOID *buffer);

Description

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.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

See Also

lx_nand_flash_sectors_read

Read multiple NAND flash sectors

Prototype

UINT lx_nand_flash_sectors_read(
    LX_NAND_FLASH *nand_flash,  
    ULONG logical_sector, 
    VOID *buffer, 
    ULONG sector_count);

Description

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.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

lx_nand_flash_sector_release

Release NAND flash sector

Prototype

UINT lx_nand_flash_sector_release(
    LX_NAND_FLASH *nand_flash,
    ULONG logical_sector);

Description

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.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

See Also

lx_nand_flash_sectors_release

Release multiple NAND flash sectors

Prototype

UINT lx_nand_flash_sectors_release(
    LX_NAND_FLASH *nand_flash,
    ULONG logical_sector,
    ULONG sector_count);

Description

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.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

See Also

lx_nand_flash_sector_write

Write NAND flash sector

Prototype

UINT lx_nand_flash_sector_write(
    LX_NAND_FLASH *nand_flash,
    ULONG logical_sector, 
    VOID *buffer);

Description

This service writes the specified logical sector in the NAND flash instance.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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". */

See Also

lx_nand_flash_sectors_write

Write multiple NAND flash sectors

Prototype

UINT lx_nand_flash_sectors_write(
    LX_NAND_FLASH *nand_flash,
    ULONG logical_sector, 
    VOID *buffer, 
    ULONG sector_count);

Description

This service writes the specified number of logical sectors in the NAND flash instance.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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". */

See Also