/* Data Width : 16bits, Data Size : 128K */
/* 1. One Byte Write */
/* 2. Half Word Write */
/* 3. One Word Write */
void SRAM_BS616LV4017(void)
{
uint8_t *pu8DevPtr;
uint16_t *pu16DevPtr;
uint32_t *pu32DevPtr;
uint32_t u32WriteData;
uint32_t u32Idx, u32DataIdx;
uint32_t u32EBIsize;
u32EBIsize = EBI_MAX_SIZE;
printf(" >> Data Width use 16bits and Data Size is %dKB << \n", (u32EBIsize / 1024));
/* One Byte Write */
printf("[[ One Byte Write test ]]\n");
u32DataIdx = 0;
while(u32DataIdx < 5)
{
if(u32DataIdx < 4)
{
// Fixed data pattern
// Write to SRAM
u32Idx = 0;
pu8DevPtr = (uint8_t *)EBI_BASE_ADDR;
u32WriteData = g_au32DataArrary[u32DataIdx];
printf(" All 0x%X Access ... ", (uint8_t)u32WriteData);
while(u32Idx < u32EBIsize)
{
*pu8DevPtr++ = (uint8_t)(u32WriteData);
u32Idx = u32Idx + 1;
}
// Read from SRAM and compare data
SRAM_CompareFunction(u32DataIdx, u32EBIsize, 0, 0); // param3:0, Byte Write
printf("PASS\n");
}
else
{
// Unfixed data pattern
// Write to SRAM
u32Idx = 0;
u32WriteData = 0;
pu8DevPtr = (uint8_t *)EBI_BASE_ADDR;
printf(" 0x0, 0x1, 0x2, 0x3, 0x4 ... Access with offset(0x%X) ... ", (uint32_t)&u32Idx);
while(u32Idx < u32EBIsize)
{
*pu8DevPtr++ = (uint8_t)(u32WriteData + (uint32_t)&u32Idx);
u32Idx = u32Idx + 1;
u32WriteData++;
}
SRAM_CompareFunction(u32DataIdx, u32EBIsize, (uint32_t)&u32Idx, 0); // param3:0, Byte Write
printf("PASS\n\n");
}
u32DataIdx++;
}
/* Half Word Write */
printf("[[ Half Word Write test]]\n");
u32DataIdx = 0;
while(u32DataIdx < 5)
{
if(u32DataIdx < 4)
{
// Fixed data pattern
// Write to SRAM
u32Idx = 0;
pu16DevPtr = (uint16_t *)EBI_BASE_ADDR;
u32WriteData = g_au32DataArrary[u32DataIdx];
printf(" All 0x%X Access ... ", (uint16_t)u32WriteData);
while(u32Idx < u32EBIsize)
{
*pu16DevPtr++ = (uint16_t)(u32WriteData);
u32Idx = u32Idx + 2;
}
// Read from SRAM and compare data
SRAM_CompareFunction(u32DataIdx, u32EBIsize, 0, 1); // param3:1, Half Word Write
printf("PASS\n");
}
else
{
// Unfixed data pattern
// Write to SRAM
u32Idx = 0;
u32WriteData = 0;
pu16DevPtr = (uint16_t *)EBI_BASE_ADDR;
printf(" 0x0, 0x1, 0x2, 0x3, 0x4 ... Access with offset(0x%X) ... ", (uint32_t)&u32Idx);
while(u32Idx < u32EBIsize)
{
*pu16DevPtr++ = (uint16_t)(u32WriteData + (uint32_t)&u32Idx);
u32Idx = u32Idx + 2;
u32WriteData++;
}
SRAM_CompareFunction(u32DataIdx, u32EBIsize, (uint32_t)&u32Idx, 1); // param3:1, Half Word Write
printf("PASS\n\n");
}
u32DataIdx++;
}
/* One Word Write */
printf("[[ One Word Write test ]]\n");
u32DataIdx = 0;
while(u32DataIdx < 5)
{
if(u32DataIdx < 4)
{
// Fixed data pattern
// Write to SRAM
u32Idx = 0;
pu32DevPtr = (uint32_t *)EBI_BASE_ADDR;
u32WriteData = g_au32DataArrary[u32DataIdx];
printf(" All 0x%X Access ... ", (uint32_t)u32WriteData);
while(u32Idx < u32EBIsize)
{
*pu32DevPtr++ = (uint32_t)(u32WriteData);
u32Idx = u32Idx + 4;
}
// Read from SRAM and compare data
SRAM_CompareFunction(u32DataIdx, u32EBIsize, 0, 2); // param3:2, Word Write
printf("PASS\n");
}
else
{
// Unfixed data pattern
// Write to SRAM
u32Idx = 0;
u32WriteData = 0;
pu32DevPtr = (uint32_t *)EBI_BASE_ADDR;
printf(" 0x0, 0x1, 0x2, 0x3, 0x4 ... Access with offset(0x%X) ... ", (uint32_t)&u32Idx);
while(u32Idx < u32EBIsize)
{
*pu32DevPtr++ = (uint32_t)(u32WriteData + (uint32_t)&u32Idx);
u32Idx = u32Idx + 4;
u32WriteData++;
}
SRAM_CompareFunction(u32DataIdx, u32EBIsize, (uint32_t)&u32Idx, 2); // param3:2, Word Write
printf("PASS\n\n");
}
u32DataIdx++;
}
}