📄 test.c
字号:
while (MCASP_RGETH(EVMDM642_AIC23_hMcASP, GBLCTL) != 0x00000300);
for (i = 0; i < 1000; i++);
/* Enable transmit and receive clocks and serializers */
MCASP_RSETH(EVMDM642_AIC23_hMcASP, GBLCTL, 0x00000700);
while (MCASP_RGETH(EVMDM642_AIC23_hMcASP, GBLCTL) != 0x00000700);
/* Put some data in the transmit buffer */
MCASP_RSETH(EVMDM642_AIC23_hMcASP, XBUF2, 0);
/* Release transmit and receive state machines */
MCASP_RSETH(EVMDM642_AIC23_hMcASP, GBLCTL, 0x00000f00);
while (MCASP_RGETH(EVMDM642_AIC23_hMcASP, GBLCTL) != 0x00000f00);
/* Release transmit and receive state machines */
MCASP_RSETH(EVMDM642_AIC23_hMcASP, GBLCTL, 0x00001f00);
/* Generate 1KHz sine wave for 5 seconds*/
for (i = 0; i < 5000; i++)
{
for (j = 0; j < SINE_TABLE_SIZE; j++)
{
data = sinetable[j];
/* Wait until serializer ready to transmit */
while ((MCASP_RGETH(EVMDM642_AIC23_hMcASP, SRCTL2) & 0x10) == 0);
/* Transmit data */
MCASP_RSETH(EVMDM642_AIC23_hMcASP, XBUF2, data);
/* Wait until serializer ready to transmit */
while ((MCASP_RGETH(EVMDM642_AIC23_hMcASP, SRCTL2) & 0x10) == 0);
/* Transmit data */
MCASP_RSETH(EVMDM642_AIC23_hMcASP, XBUF2, data);
}
}
MCASP_close(EVMDM642_AIC23_hMcASP);
return 0;
}
Int16 TEST_audioclks()
{
Uint32 testtime;
Int16 status;
TIMER_Handle hTimer1;
TIMER_Config timerCfg1 = {
TIMER_FMKS(CTL, INVINP, NO) |
TIMER_FMKS(CTL, CLKSRC, CPUOVR8) |
TIMER_FMKS(CTL, CP, PULSE) |
TIMER_FMKS(CTL, HLD, YES) |
TIMER_FMKS(CTL, GO, NO) |
TIMER_FMKS(CTL, PWID, ONE) |
TIMER_FMKS(CTL, DATOUT, 0) |
TIMER_FMKS(CTL, INVOUT, NO) |
TIMER_FMKS(CTL, FUNC, TOUT),
TIMER_FMKS(PRD, PRD, OF(75)),
TIMER_FMKS(CNT, CNT, OF(0))
};
status = 0;
/* Enable GPIO on VDAC pin */
GPIO_pinEnable(EVMDM642_GPIO_hGPIO, GPIO_PIN8);
/* Configure as output */
GPIO_pinDirection(EVMDM642_GPIO_hGPIO, GPIO_PIN8, GPIO_OUTPUT);
/* Open the timer */
hTimer1 = TIMER_open(TIMER_DEV1, TIMER_OPEN_RESET);
/* Configure the timer in one-shot mode */
TIMER_config(hTimer1, &timerCfg1);
/* Get Event Id associated with Timer 1, for use with */
/* CSL interrupt enable functions. */
eventId1 = TIMER_getEventId(hTimer1);
/* Map the logical event to a physical interrupt */
IRQ_map(eventId1, 15);
/* Clear any pending Timer interrupts */
IRQ_clear(eventId1);
/* Enable timer interrupt */
IRQ_enable(eventId1);
/* Make sure global interrupts are enabled */
IRQ_globalEnable();
/* Start timer 1 */
TIMER_start(hTimer1);
/* Set audio PLL to 18.432 MHz, VDAC low */
EVMDM642_APLL_rset(EVMDM642_APLL_FSG0);
GPIO_pinWrite(EVMDM642_GPIO_hGPIO, GPIO_PIN8, 0);
sleepCount = 0;
/* Check test duration against timer */
TEST_spdif();
testtime = sleepCount;
printf(" Timer1 count -> %d\n", testtime);
if (testtime > 4999900)
{
status = 1;
goto SPDIF_END;
}
/* Drive VDAC high */
GPIO_pinWrite(EVMDM642_GPIO_hGPIO, GPIO_PIN8, 1);
sleepCount = 0;
/* Check test duration against timer */
TEST_spdif();
testtime = sleepCount;
printf(" Timer2 count -> %d\n", testtime);
if (testtime < 5000280)
{
status = 2;
goto SPDIF_END;
}
/* Set audio PLL to 16.9344 MHz */
EVMDM642_APLL_rset(EVMDM642_APLL_FSG1);
GPIO_pinWrite(EVMDM642_GPIO_hGPIO, GPIO_PIN8, 0);
sleepCount = 0;
/* Check test duration against timer */
TEST_spdif();
testtime = sleepCount;
printf(" Timer3 count -> %d\n", testtime);
if (testtime > 5442070)
{
status = 3;
goto SPDIF_END;
}
/* Drive VDAC high */
GPIO_pinWrite(EVMDM642_GPIO_hGPIO, GPIO_PIN8, 1);
sleepCount = 0;
/* Check test duration against timer */
TEST_spdif();
testtime = sleepCount;
printf(" Timer4 count -> %d\n", testtime);
if (testtime < 5442470)
{
status = 4;
goto SPDIF_END;
}
SPDIF_END:
TIMER_close(hTimer1);
return status;
}
Int16 TEST_flashAddr()
{
Int16 i;
for (i = 0; i < 8; i++)
{
EVMDM642_rset(EVMDM642_FLASHPAGE, i);
}
return 0;
}
Int16 TEST_eeprom()
{
Uint16 page, i;
Uint8 *pdata;
/* Write a pattern */
for (page = 0; page < 4; page++)
{
pdata = (Uint8 *)buffer;
for (i = 0; i < 64; i++)
*pdata++ = (page + i) & 0xff;
EVMDM642_EEPROM_write((Uint32)buffer, page << 6, 64);
}
/* Verify the pattern */
for (page = 0; page < 4; page++)
{
EVMDM642_EEPROM_read(page << 6, (Uint32)buffer, 64);
pdata = (Uint8 *)buffer;
for (i = 0; i < 64; i++)
if (*pdata++ != (page + i) & 0xff)
return 1; // Fail
}
return 0;
}
Int16 TEST_uartA()
{
Int16 i;
EVMDM642_UART_Handle hUart;
EVMDM642_UART_Config uartcfg = {
0x00, // IER
0x57, // FCR - FIFO Mode, 16 character trigger level
0x03, // LCR - 8 bits, no parity, 1 stop
0x00 // MCR
};
/* Open UART */
hUart = EVMDM642_UART_open(EVMDM642_UARTA, EVMDM642_UART_BAUD19200, &uartcfg);
/* Loop through 256 bytes */
for (i = 0; i < 256; i++)
{
EVMDM642_UART_putChar(hUart, (i + 1) & 0xff);
buffer[i] = EVMDM642_UART_getChar(hUart);
}
/* Verify data */
for (i = 0; i < 256; i++)
{
if (buffer[i] != ((i + 1) & 0xff))
return 1;
}
return 0;
}
Int16 TEST_uartB()
{
Int16 i;
EVMDM642_UART_Handle hUart;
EVMDM642_UART_Config uartcfg = {
0x00, // IER
0x57, // FCR - FIFO Mode, 16 character trigger level
0x03, // LCR - 8 bits, no parity, 1 stop
0x00 // MCR
};
/* Open UART */
hUart = EVMDM642_UART_open(EVMDM642_UARTB, EVMDM642_UART_BAUD19200, &uartcfg);
/* Loop through 256 bytes */
for (i = 0; i < 256; i++)
{
EVMDM642_UART_putChar(hUart, (i + 1) & 0xff);
buffer[i] = EVMDM642_UART_getChar(hUart);
}
/* Verify data */
for (i = 0; i < 256; i++)
{
if (buffer[i] != ((i + 1) & 0xff))
return 1;
}
return 0;
}
Int16 TEST_uart()
{
Int32 count = 0;
while(1)
{
if (TEST_uartA() != 0)
asm(" .long 0x10000000");
else
count++;
EVMDM642_LED_toggle(0);
}
}
Int16 TEST_pciregs()
{
Uint16 i, n;
Uint16 configregs[13] = {
0x104c, // 0
0x9065, // 1
0x0000, // 2
0xff00, // 3
0x1652, // 4
0x0642, // 5
0x0000, // 6
0x0000, // 7
0x0000, // 8
0x0000, // 9
0x0000, // 10
0x0000, // 11
0x0000 // 12
};
EVMDM642_PCI_config(configregs);
/* Read test values */
for (i = 0; i < 13; i++)
{
n = PCI_eepromRead(i);
if (n != configregs[i])
return 1;
}
return 0;
}
Int16 TEST_null()
{
return 0;
}
/* ------------------ Start Debug Code -------------------------------*/
void DEBUG_memLoop()
{
volatile Uint8 *pdata, data;
pdata = (Uint8 *)0x90080000;
while(1)
{
data = *pdata;
}
}
/* ------------------ End Debug Code --------------------------------*/
void TEST_execute(Int16 (*funchandle)(), char *testname, Int16 ledmask, Int16 insertdelay)
{
Int16 status;
/* Display test ID */
printf("%02d Testing %s...\n", ledmask, testname);
/* Call test function */
status = funchandle();
/* Check for test fail */
if (status > 0)
{
/* Print error message */
printf(" FAIL... error code %d... quitting\n", status, testname);
/* Software breakpoint */
asm(" .long 0x10000000");
} else
{
/* Print error message */
printf(" PASS\n", testname);
}
}
main()
{
/* Call BSL init */
EVMDM642_init();
/* Set initial LED state */
EVMDM642_LED_init();
/* Run the tests sequentially */
TEST_execute(TEST_led, "LEDs", 1, 0);
TEST_execute(TEST_audioclks, "SPDIF/APLL/VCXO", 2, 0);
TEST_execute(TEST_syncbus, "Sync Bus", 3, 0);
TEST_execute(TEST_extMem, "SDRAM", 4, 0);
TEST_execute(TEST_flashID, "Flash ID", 5, 1);
// TEST_execute(TEST_flashall, "Flash", 6, 0);
TEST_execute(TEST_eeprom, "I2C EEPROM", 7, 0);
// TEST_execute(TEST_uartA, "UARTA", 8, 0);
// TEST_execute(TEST_uartB, "UARTB", 9, 0);
// TEST_execute(TEST_pciregs, "PCI EEPROM", 10, 1);
/* Success */
printf("\n*** All tests PASS ***\n");
/* Disable interrupts */
IRQ_globalDisable();
/* Software breakpoint */
asm(" .long 0x10000000");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -