📄 test.c
字号:
* NOTES:
*
*F***************************************************************************/
Int16 TEST_mcbsp1()
{
/* Do an internal loopback test on McBSP1 */
return 0;
}
/*---------------------------END McBSP FUNCTIONS----------------------------------------------*/
/*---------------------------DIAGNOSTIC UTILITY FUNCTIONS-------------------------------------*/
/*---------------------OVERALL DIAGNOSTIC TESTS FUNCTIONS-----------------------------*/
/*F***************************************************************************
* NAME: TEST_intMemVersion()
*
* DESCRIPTION:Gets the board version and CPLD version for the target.
*
* NOTES:CALLED BY DSP DIAGNOSTICS IN THE DIAGNOSTIC UTILITY
*
*F***************************************************************************/
Int16 TEST_intMemVersion()
{
Int16 status = 0;
/* Store CPLD version */
databuf[2] = (DSK6455_rget(DSK6455_VERSION) >> 4) & 0xf;
/* Store board version */
databuf[3] = DSK6455_rget(DSK6455_VERSION) & 0x7;
return status;
}
/*F***************************************************************************
* NAME: TEST_extMem()
*
* DESCRIPTION:Test SDRAM by filling with both pattern and address values.
*
* NOTES:CALLED BY EXTERNAL MEMORY IN THE DIAGNOSTIC UTILITY
*
*F***************************************************************************/
Int16 TEST_extMem()
{
Int16 status = 0;
/* Check external memory (byte 0x40000 to byte 0x1000000) */
status |= MEM_test(0xe0000000, 0x1000000, 0);
status |= MEM_test(0xe0000000, 0x1000000, 1);
status |= MEM_walking(0xe0000000);
status |= MEM_walking(0xe0000004);
status |= MEM_bytestrobe(0xE0000000);
return status;
}
/*F***************************************************************************
* NAME: TEST_flash()
*
* DESCRIPTION:
*
* NOTES:CALLED BY FLASH DIAGNOSTICS IN THE DIAGNOSTIC UTILITY
*
*F***************************************************************************/
Int16 TEST_flash()
{
Uint16 i, j, k, page;
Uint32 startaddr, addr;
/* Check Flash IDs */
if (TEST_flashID())
return 1;
/* Program the Flash page by page, 256 words at a time */
for (page = 0; page < 1; page++)
{
/* Erase all of the Flash */
DSK6455_FLASH_erase(DSK6455_FLASH_BASE + DSK6455_FLASH_SECTORSIZE, DSK6455_FLASH_SECTORSIZE *8);
addr = DSK6455_FLASH_BASE + DSK6455_FLASH_SECTORSIZE;
for (i = 0; i < 8; i++)
{
for (j = 0; j < 128; j++)
{
startaddr = addr;
for (k = 0; k < 256; k++)
{
buffer[k] = addr + i + page;
addr += 2;
}
DSK6455_FLASH_write((Uint32)buffer, startaddr, 512);
}
}
}
/* Verify the Flash page by page, 256 words at a time */
for (page = 0; page < 1; page++)
{
addr = DSK6455_FLASH_BASE + DSK6455_FLASH_SECTORSIZE;
for (i = 0; i < 8 ; i++)
{
for (j = 0; j < 128; j++)
{
startaddr = addr;
DSK6455_FLASH_read(startaddr, (Uint32)buffer, 512);
for (k = 0; k < 256; k++)
{
if (buffer[k] != ((addr + i + page) & 0xffff))
return page + 1;
addr += 2;
}
}
}
}
return 0;
}
/*F***************************************************************************
* NAME: TEST_codec()
*
* DESCRIPTION:
*
* NOTES:CALLED BY CODEC DIAGNOSTICS IN THE DIAGNOSTIC UTILITY
*
*F***************************************************************************/
Int16 TEST_codec()
{
DSK6455_AIC23_CodecHandle hCodec;
Int16 i, j;
/* Start the codec */
hCodec = DSK6455_AIC23_openCodec(0, &config);
/* Generate a 1KHz sine wave for 1 second */
for (i = 0; i < 1000; i++)
{
for (j = 0; j < SINE_TABLE_SIZE; j++)
{
while (!DSK6455_AIC23_write32(hCodec, sinetable[j]));
while (!DSK6455_AIC23_write32(hCodec, sinetable[j]));
}
}
/* Close codec */
DSK6455_AIC23_closeCodec(hCodec);
return 0;
}
/*F***************************************************************************
* NAME: TEST_userIO()
*
* DESCRIPTION:
*
* NOTES:CALLED BY LED AND DIP SWITCH DIAGNOSTICS IN THE DIAGNOSTIC UTILITY
*
*F***************************************************************************/
Int16 TEST_userIO()
{
int i, j;
for (j = 0; j < 1; j++)
{
for (i = 0; i < 4; i++)
{
if (DSK6455_DIP_get(i) == 1)
DSK6455_LED_on(i);
else
DSK6455_LED_off(i);
}
TEST_sleep(10);
}
return 0;
}
/*---------------------END OVERALL DIAGNOSTIC TESTS FUNCTIONS-------------------------*/
/*---------------------ADVANCED DIAGNOSTIC TESTS FUNCTIONS-----------------------------*/
/*F***************************************************************************
* NAME: TEST_memPat()
*
* DESCRIPTION:Test SDRAM by filling with pattern values.
*
* NOTES:CALLED WHEN TESTING MEMORY IN THE ADVANCED TAB
*
*F***************************************************************************/
Int16 TEST_memPat()
{
Int16 status = 0;
/* Test external memory (SDRAM) */
status |= MEM_test(0xe0000000, 0x1000000, 0);
return status;
}
/*F***************************************************************************
* NAME: TEST_memAddr()
*
* DESCRIPTION:Test SDRAM by filling with address values.
*
* NOTES:CALLED WHEN TESTING MEMORY IN THE ADVANCED TAB
*
*F***************************************************************************/
Int16 TEST_memAddr()
{
Int16 status = 0;
/* Test external memory (SDRAM) */
status |= MEM_test(0xe0000000, 0x1000000, 1);
return status;
}
/*F***************************************************************************
* NAME: TEST_dsp()
*
* DESCRIPTION:Tests Timer,DMA,McBSP0 & McBSP1
*
* NOTES:CALLED WHEN TESTING DSP IN THE ADVANCED TAB
*
*F***************************************************************************/
Int16 TEST_dsp()
{
Int16 status = 0;
/* Call sub-tests */
if (TEST_dma())
status |= 0x01;
if (TEST_timer())
status |= 0x02;
if (TEST_mcbsp0())
status |= 0x04;
if (TEST_mcbsp1())
status |= 0x08;
return status;
}
/*F***************************************************************************
* NAME: TEST_readSwitch()
*
* DESCRIPTION:
*
* NOTES:CALLED WHEN TESTING LED/SWT IN THE ADVANCED TAB
*
*F***************************************************************************/
Int16 TEST_readSwitch()
{
Int16 i, n;
n = 0;
for (i = 3; i >= 0; i--)
n = (n << 1) | DSK6455_DIP_get(i);
LED_binary(n);
databuf[2] = n;
return 0;
}
/*F***************************************************************************
* NAME: TEST_codecLoopBack()
*
* DESCRIPTION:
*
* NOTES:CALLED WHEN TESTING CODEC IN THE ADVANCED TAB
*
*F***************************************************************************/
Int16 TEST_codecLoopBack()
{
DSK6455_AIC23_CodecHandle hCodec;
Int16 i, j, data;
Uint16 *pbuf;
/* Start the codec */
hCodec = DSK6455_AIC23_openCodec(0, &config);
/* Set volume */
DSK6455_AIC23_outGain(hCodec, cmdbuf[1] & 0x7f);
/* Set mute */
if (cmdbuf[2])
{
DSK6455_AIC23_mute(hCodec, TRUE);
} else
{
DSK6455_AIC23_mute(hCodec, FALSE);
}
if (cmdbuf[3])
{
/* Configure the codec for loopback mode*/
DSK6455_AIC23_loopback(hCodec,1);
} else
{
DSK6455_AIC23_loopback(hCodec,0);
}
/* Run for a second */
for (i = 0; i < 1000; i++)
{
pbuf = databuf + 2;
for (j = 0; j < SINE_TABLE_SIZE; j++)
{
while (!DSK6455_AIC23_write32(hCodec, sinetable[j]));
while (!DSK6455_AIC23_read32(hCodec, (Uint32 *)&data));
*pbuf++ = data;
while (!DSK6455_AIC23_write32(hCodec, sinetable[(j << 1) % SINE_TABLE_SIZE]));
while (!DSK6455_AIC23_read32(hCodec, (Uint32 *)&data));
*pbuf++ = data;
}
}
/* Close codec */
DSK6455_AIC23_closeCodec(hCodec);
return 0;
}
/*--------------------- END ADVANCED DIAGNOSTIC TESTS FUNCTIONS--------------------------*/
/*------------------------END OF DIAGNOSTIC UTILITY FUNCTIONS---------------------------------*/
/*F***************************************************************************
* NAME: TEST_execute()
*
* DESCRIPTION:
*
* NOTES:
*
*F***************************************************************************/
void TEST_execute(Int16 (*funchandle)(), Int16 ledmask, Int16 insertdelay)
{
Int16 status;
/* Display test ID */
LED_binary(ledmask);
/* Call test function */
status = funchandle();
/* Pause so LEDs can be read */
if (insertdelay)
TEST_sleep(100);
/* Check for test fail */
if (status)
LED_error(ledmask);
}
/*F***************************************************************************
* NAME: TEST_executeDiag()
*
* DESCRIPTION:
*
* NOTES:
*
*F***************************************************************************/
void TEST_executeDiag(Int16 (*funchandle)(), Int16 ledmask, Int16 insertdelay)
{
Int16 status;
/* Call test function */
status = funchandle();
databuf[0] = 0x1234;
databuf[1] = status;
}
/*------------------------------START OF MAIN FUNCTION--------------------------------*/
main()
{
/* Call BSL init */
DSK6455_init();
/* Initialize DIP switch and LEDs */
DSK6455_LED_init();
DSK6455_DIP_init();
#if defined( BUILD_DSK_DIAGS )
#if(0)
/* Iniitalize the command buffer for debug purposes */
cmdbuf[0] = 6;
cmdbuf[1] = 0x79;
cmdbuf[2] = 0;
cmdbuf[3] = 1;
#endif
/* Execute command for host */
switch(*cmdbuf)
{
case 0: /* Internal memory */
TEST_executeDiag(TEST_intMemVersion, 0, 0);
break;
case 1: /* External memory (typical) */
TEST_executeDiag(TEST_extMem, 0, 0);
break;
case 2: /* External memory (special); */
TEST_executeDiag(TEST_flashID, 0, 0);
break;
case 3: /* Codec test */
TEST_executeDiag(TEST_codec, 0, 0);
break;
case 4: /* LED and timer test */
TEST_executeDiag(TEST_timer, 0, 0);
break;
case 5: /* DIP switch test */
TEST_executeDiag(TEST_userIO, 0, 0);
break;
case 6: /* Test codec external loopback */
TEST_executeDiag(TEST_codecLoopBack, 0, 0);
break;
case 7: /* Test memory (fill pattern) */
TEST_executeDiag(TEST_memPat, 0, 0);
break;
case 8: /* Test DSP */
TEST_executeDiag(TEST_dsp, 0, 0);
break;
case 9: /* DIP switch read */
TEST_executeDiag(TEST_readSwitch, 0, 0);
break;
case 10: /* Test memory (address pattern) */
TEST_executeDiag(TEST_memAddr, 0, 0);
break;
case 11: /* External Flash */
TEST_executeDiag(TEST_flash, 0, 0);
break;
default:
break;
}
#endif
#if defined (_DEBUG )
TEST_execute(TEST_intMemVersion, 1, 0);
TEST_execute(TEST_extMem, 2, 0);
TEST_execute(TEST_flash, 3, 0);
TEST_execute(TEST_codec, 4, 0);
TEST_execute(TEST_userIO, 5, 0);
TEST_execute(TEST_memPat, 6, 0);
TEST_execute(TEST_memAddr, 7, 0);
TEST_execute(TEST_dsp, 8, 0);
TEST_execute(TEST_readSwitch, 9, 0);
TEST_execute(TEST_codecLoopBack, 10, 0);
/* All tests complete, board passes */
LED_blink(0xf, 3);
/* Leave all LEDs on */
LED_binary(0xf);
#endif
/* Set artificial breakpoint to return control to host */
asm( " .long 0x1001E000" );
while(1);
}
/*------------------------------END OF MAIN FUNCTION--------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -