在嵌入式系统中,sdr sdram控制器对于用户来讲是透明的,即用户在功能使用上没有初始化、刷新等操作,直接IO读写函数读写相应的地址即可。基本的IO读写函数在文件io.h中定义,其本质就是简单的指针赋值语句,32bit位宽的读写函数如下所示:
#define XIo_In32(InputPtr)(*(volatile Xunit32*)(InputPtr))
#define XIo_Out32(OutputPtr,Value) (*(volatile Xuint32*)((OutputPtr))=(Value))
因此在操作sdram时,只需添加下列两个头文件,其中,xio.h定义了端口操作函数,xparameters.h文件则给出了sdram存储器的基地址
#include "xio.h"
#include "xparameters.h"
/*****************************************************************************/
/**
*
* Performs an input operation for a 32-bit memory location by reading from the
* specified address and returning the value read from that address.
*
* @param InputPtr contains the address to perform the input operation at.
*
* @return The value read from the specified input address.
*
* @note None.
*
******************************************************************************/
#define XIo_In32(InputPtr) (*(volatile u32 *)(InputPtr))
/*****************************************************************************/
/**
*
* Performs an output operation for a 32-bit memory location by writing the
* specified value to the the specified address.
*
* @param OutputPtr contains the address to perform the output operation
* at.
* @param Value contains the value to be output at the specified address.
*
* @return None
*
* @note None.
*
******************************************************************************/
#define XIo_Out32(OutputPtr, Value) \
(*(volatile u32 *)((OutputPtr)) = (Value))