Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions common/inc/lx_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -706,12 +706,20 @@ extern ULONG _lx_nor_flash_opened_cou
#define lx_nand_flash_open_extended _lx_nand_flash_open_extended
#define lx_nand_flash_page_ecc_check _lx_nand_flash_page_ecc_check
#define lx_nand_flash_page_ecc_compute _lx_nand_flash_page_ecc_compute
#define lx_nand_flash_sector_read _lx_nand_flash_sector_read
#define lx_nand_flash_sector_release _lx_nand_flash_sector_release
#define lx_nand_flash_sector_write _lx_nand_flash_sector_write
#define lx_nand_flash_sectors_read _lx_nand_flash_sectors_read
#define lx_nand_flash_sectors_release _lx_nand_flash_sectors_release
#define lx_nand_flash_sectors_write _lx_nand_flash_sectors_write
#define lx_nand_flash_page_read _lx_nand_flash_sector_read
#define lx_nand_flash_page_release _lx_nand_flash_sector_release
#define lx_nand_flash_page_write _lx_nand_flash_sector_write
#define lx_nand_flash_pages_read _lx_nand_flash_sectors_read
#define lx_nand_flash_pages_release _lx_nand_flash_sectors_release
#define lx_nand_flash_pages_write _lx_nand_flash_sectors_write

/* Both NAND API spellings use the same entry points. */
#define lx_nand_flash_sector_read lx_nand_flash_page_read
#define lx_nand_flash_sector_release lx_nand_flash_page_release
#define lx_nand_flash_sector_write lx_nand_flash_page_write
#define lx_nand_flash_sectors_read lx_nand_flash_pages_read
#define lx_nand_flash_sectors_release lx_nand_flash_pages_release
#define lx_nand_flash_sectors_write lx_nand_flash_pages_write
#define lx_nand_flash_256byte_ecc_check _lx_nand_flash_256byte_ecc_check
#define lx_nand_flash_256byte_ecc_compute _lx_nand_flash_256byte_ecc_compute

Expand Down Expand Up @@ -748,12 +756,12 @@ UINT _lx_nand_flash_open_extended(LX_NAND_FLASH *nand_flash, CHAR *name,
UINT _lx_nand_flash_page_ecc_check(LX_NAND_FLASH *nand_flash, UCHAR *page_buffer, UCHAR *ecc_buffer);
UINT _lx_nand_flash_page_ecc_compute(LX_NAND_FLASH *nand_flash, UCHAR *page_buffer, UCHAR *ecc_buffer);
UINT _lx_nand_flash_partial_defragment(LX_NAND_FLASH *nand_flash, UINT max_blocks);
UINT _lx_nand_flash_sector_read(LX_NAND_FLASH *nand_flash, ULONG logical_sector, VOID *buffer);
UINT _lx_nand_flash_sector_release(LX_NAND_FLASH *nand_flash, ULONG logical_sector);
UINT _lx_nand_flash_sector_write(LX_NAND_FLASH *nand_flash, ULONG logical_sector, VOID *buffer);
UINT _lx_nand_flash_sectors_read(LX_NAND_FLASH* nand_flash, ULONG logical_sector, VOID* buffer, ULONG sector_count);
UINT _lx_nand_flash_sectors_release(LX_NAND_FLASH* nand_flash, ULONG logical_sector, ULONG sector_count);
UINT _lx_nand_flash_sectors_write(LX_NAND_FLASH* nand_flash, ULONG logical_sector, VOID* buffer, ULONG sector_count);
UINT _lx_nand_flash_sector_read(LX_NAND_FLASH *nand_flash, ULONG logical_page, VOID *buffer);
UINT _lx_nand_flash_sector_release(LX_NAND_FLASH *nand_flash, ULONG logical_page);
UINT _lx_nand_flash_sector_write(LX_NAND_FLASH *nand_flash, ULONG logical_page, VOID *buffer);
UINT _lx_nand_flash_sectors_read(LX_NAND_FLASH* nand_flash, ULONG logical_page, VOID* buffer, ULONG page_count);
UINT _lx_nand_flash_sectors_release(LX_NAND_FLASH* nand_flash, ULONG logical_page, ULONG page_count);
UINT _lx_nand_flash_sectors_write(LX_NAND_FLASH* nand_flash, ULONG logical_page, VOID* buffer, ULONG page_count);

UINT _lx_nor_flash_close(LX_NOR_FLASH *nor_flash);
UINT _lx_nor_flash_defragment(LX_NOR_FLASH *nor_flash);
Expand Down
22 changes: 19 additions & 3 deletions test/regression/levelx_nand_flash_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/* SPDX-License-Identifier: MIT */
/***************************************************************************/

/* Portions of this file were generated with AI assistance. */

/* Basic NOR flash tests... */

#include <stdio.h>
Expand Down Expand Up @@ -163,7 +165,21 @@ UCHAR *byte_ptr;
for (j = 0; j < 512; j++)
buffer[j] = i;

status = lx_nand_flash_sector_write(&nand_sim_flash, i, buffer);
status = lx_nand_flash_page_write(&nand_sim_flash, i, buffer);

/* Check the multi-page API with two pages outside this range. */
if ((i == 0) && (status == LX_SUCCESS))
{
LX_MEMSET(buffer, 0x5A, 2 * nand_sim_flash.lx_nand_flash_bytes_per_page);
status = lx_nand_flash_pages_write(&nand_sim_flash, 600, buffer, 2);
if (status == LX_SUCCESS)
status = lx_nand_flash_pages_read(&nand_sim_flash, 600, readbuffer, 2);
if ((status == LX_SUCCESS) &&
(memcmp(buffer, readbuffer, 2 * nand_sim_flash.lx_nand_flash_bytes_per_page) != 0))
status = LX_ERROR;
if (status == LX_SUCCESS)
status = lx_nand_flash_pages_release(&nand_sim_flash, 600, 2);
}

if (status != LX_SUCCESS)
{
Expand Down Expand Up @@ -199,7 +215,7 @@ UCHAR *byte_ptr;
for (i = 0; i < 520; i++)
{

status = lx_nand_flash_sector_read(&nand_sim_flash, i, buffer);
status = lx_nand_flash_page_read(&nand_sim_flash, i, buffer);

if (status != LX_SUCCESS)
{
Expand Down Expand Up @@ -1624,7 +1640,7 @@ UCHAR *byte_ptr;
}
}

status = lx_nand_flash_sector_release(&nand_sim_flash, 7);
status = lx_nand_flash_page_release(&nand_sim_flash, 7);
if (status != LX_SUCCESS)
{
printf("FAILED!\n");
Expand Down