nandpsu
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Enumerations Enumerator Groups Pages
xnandpsu_example.c File Reference

Overview

This file contains a design example using the NAND driver (XNandPsu).

This example tests the erase, read and write features of the controller. The flash is erased and written. The data is read back and compared with the data written for correctness.

Note

None.

 MODIFICATION HISTORY:
 Ver   Who  Date        Changes


1.0 nm 05/06/2014 First release. ms 04/10/17 Modified Comment lines to follow doxygen rules. 1.4 nsk 10/04/2018 Added support for ICCARM Compiler. 1.6 sd 31/03/2020 Fixed a gcc warning. 1.9 akm 07/15/2021 Switch to best supported Data interface and Timing mode. 1.12 akm 06/27/2023 Add support for system device-tree flow for example. 1.16 vlt 12/18/25 Update Doxygen comments to include SDT flow details.

#include <stdio.h>
#include <stdlib.h>
#include <xil_types.h>
#include <xil_printf.h>
#include <xparameters.h>
#include "xnandpsu.h"

Functions

s32 NandReadWriteExample (UINTPTR BaseAddress)
 This function runs a test on the NAND flash device using the basic driver functions in polled mode. More...
 
int main (void)
 Main function to execute the Nand Flash read write example. More...
 

Variables

u8 ReadBuffer [TEST_BUF_SIZE]
 Block sized Read buffer. More...
 
u8 WriteBuffer [TEST_BUF_SIZE]
 Block sized write buffer. More...
 

Function Documentation

int main ( void  )

Main function to execute the Nand Flash read write example.

Returns
  • XST_SUCCESS if the example has completed successfully.
  • XST_FAILURE if the example has failed.
Note
None.

References NandReadWriteExample().

s32 NandReadWriteExample ( UINTPTR  BaseAddress)

This function runs a test on the NAND flash device using the basic driver functions in polled mode.

The function does the following tasks:

  • Initialize the driver.
  • Erase the flash.
  • Write data to the flash.
  • Read back the data from the flash.
  • Compare the data read against the data Written.
Parameters
BaseAddresscontains the base address of the device
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE if failed.
Note
In XSCT/classic flow, DeviceId is used to look up the device configuration.

References XNandPsu_Config::BaseAddress, XNandPsu_Geometry::BytesPerPage, XNandPsu::Geometry, ReadBuffer, WriteBuffer, XNandPsu_CfgInitialize(), XNandPsu_ChangeTimingMode(), XNandPsu_EnableDmaMode(), XNandPsu_Erase(), XNandPsu_LookupConfig(), XNandPsu_Read(), and XNandPsu_Write().

Referenced by main().

Variable Documentation

u8 ReadBuffer[TEST_BUF_SIZE]

Block sized Read buffer.

Referenced by NandReadWriteExample().

u8 WriteBuffer[TEST_BUF_SIZE]

Block sized write buffer.

Referenced by NandReadWriteExample().