sram_test.c
来自「LPC-H2214-test_mem.zip 这是一款LPC2214开发板的示例」· C语言 代码 · 共 59 行
C
59 行
//sram_test.c
#include "sram_test.h"
#include "uart.h"
void WriteByteSRAM(unsigned long* Add, unsigned char uiData)
{
//later
}
unsigned char ReadByteSRAM(unsigned long* Add)
{
//later
return 0;
}
void WriteSRAM(unsigned long* Add, unsigned long uiData)
{
*Add = uiData;
}
unsigned long ReadSRAM(unsigned long* Add)
{
return *Add;
}
void TestSRAM()
{
//write to UART
UART0WriteTxt("Testing SRAM \n\r");
unsigned long i = 0; //need for cycles
unsigned long* pAdd = 0; //pointer to SRAM
//write data to SRAM
UART0WriteTxt("Writing data to SRAM \n\r");
for(i=0, pAdd=(unsigned long *)SRAM_BASE; pAdd < (unsigned long *)SRAM_BASE+SRAM_SIZE/4; ++pAdd,++i)
{
WriteSRAM(pAdd, i);
}
//read data from SRAM
UART0WriteTxt("Reading data from SRAM \n\r");
for(i=0, pAdd=(unsigned long *)SRAM_BASE; pAdd < (unsigned long *)SRAM_BASE+SRAM_SIZE/4; ++pAdd,++i)
{
if (*pAdd != i) break;
}
//compare read and write data
//if data is same pAdd will reach last address
if (pAdd >= (unsigned long *)SRAM_BASE+SRAM_SIZE/4)
{
UART0WriteTxt("Veryfied data is OK! \n\r");
}
else UART0WriteTxt("Veryfied is NOT OK! \n\r");
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?