📄 cnfdsp.c
字号:
#endif
ICR = IFR | 0x4000;
IER |= 0x4002; // enable int 14 (timer0)
CSR |= 1;
flag = 0;
timer0_init();
while (flag == 0); // wait int change flag to 1
timer0_init();
while (flag == 1); // wait int change flag to 0
IER = 0;
handShakingBuffer[5]=TIMER_OK;
break;
/*-------------------------------------------------------------------*/
/* Run the QDMA test and return information if(error) */
/*-------------------------------------------------------------------*/
case QDMA:
#if PRINT
printf("QDMA\n");
#endif
ICR = IFR | 0x100;
IER |= 0x102; // enable int 8 (qdma)
CSR |= 1;
flag = 0;
src = 0x80000000;
dst = 0xf000;
size = 500;
qdma_start(src,dst,size);
while (flag == 0); // wait int change flag to 1
error = qdma_check(src,dst,size);
if(error != 0)
{
handShakingBuffer[0]=error;
handShakingBuffer[5]=QDMA_ERROR;
}
else
handShakingBuffer[5]=QDMA_OK;
break;
/*-------------------------------------------------------------------*/
/* Run the LEDS test and return information for debug */
/*-------------------------------------------------------------------*/
case LEDS:
#if PRINT
printf("LEDS\n");
#endif
/*-----------------------------------------------------------------*/
/* Simultaneous menu and debug modes allow user to enter values */
/*-----------------------------------------------------------------*/
#if PRINT
printf(" Flash %d times with %d msec period.\n",
handShakingBuffer[0],handShakingBuffer[1]);
#endif
// configure CE1 as 32 bit async interface
*(unsigned volatile int *)EMIF_CE1 = CE1_32;// EMIF CE1 control, 32bit async
led_blink(handShakingBuffer[0],handShakingBuffer[1],handShakingBuffer[2]);
handShakingBuffer[5]=LEDS_OK;
// reset CE1 to 8 bit async interface
*(unsigned volatile int *)EMIF_CE1 = CE1_8;// EMIF CE1 control, 8bit async
break;
/*-------------------------------------------------------------------*/
/* Run the CODEC test and return status */
/*-------------------------------------------------------------------*/
case CODEC:
#if PRINT
printf("CODEC\n");
#endif
if(handShakingBuffer[2]) /* handShakingBuffer[2]=JP1Installed */
{
handShakingBuffer[5]=TEST_DISABLED;
}
else
{
mcbsp0_init();
#if PRINT
printf(" Play 1KHz tone.\n");
#endif
if((errortone=play_codec(handShakingBuffer[0], 1)) != 0)
{
handShakingBuffer[0]=errortone;
handShakingBuffer[5]=CODEC_ERRTN;
}
else
handShakingBuffer[5] =CODEC_OK;
mcbsp0_init();
#if PRINT
printf(" Play CD/MIC input.\n");
#endif
if((error=play_codec(handShakingBuffer[1], 0)) != 0)
{
handShakingBuffer[1]=error;
handShakingBuffer[5] |=CODEC_ERRCD;
}
else
handShakingBuffer[5] |=CODEC_OK;
} /* Test Disabled if JP1Installed (-j)*/
break;
/*-------------------------------------------------------------------*/
/* Run the PGMEM test and return information for debug */
/*-------------------------------------------------------------------*/
case PGMEM:
#if PRINT
printf("PGMEM\n");
#endif
/*-----------------------------------------------------------------*/
/* Simultaneous menu and debug modes allow user to enter values */
/*-----------------------------------------------------------------*/
#if PRINT
printf(" Write 0x%08x to 0x%08x for 0x%08x words.\n",
handShakingBuffer[0],(EXTERNAL_MEM_START+handShakingBuffer[1]),
handShakingBuffer[2]);
#endif
if((error=mem_test(handShakingBuffer[0],(EXTERNAL_MEM_START+handShakingBuffer[1]),
handShakingBuffer[2])) != 0)
{
handShakingBuffer[0]=error;
handShakingBuffer[5]=PGMEM_ERROR;
}
else
{
handShakingBuffer[1]+=EXTERNAL_MEM_START;
handShakingBuffer[5]=PGMEM_OK;
}
break;
/*-------------------------------------------------------------------*/
/* If user adds new command with out a case ... it winds up here */
/*-------------------------------------------------------------------*/
default:
#if PRINT
printf("ERROR\n");
#endif
handShakingBuffer[5]=DEFAULT_ERROR;
break;
}
/*---------------------------------------------------------------------*/
/* Tell the HOST that DSP processing is done for this command */
/*---------------------------------------------------------------------*/
handShakingBuffer[4] = DSP_STATUS_OUTPUT_READY;
}
/*-----------------------------------------------------------------------*/
/* Wrap it up */
/*-----------------------------------------------------------------------*/
#if PRINT
printf("\nThat's All Folks!\n");
#endif
return(0);
}
/*-------------------------------------------------------------------------*/
/* mem_test() - used to test internal SRAM and external SDRAM */
/*-------------------------------------------------------------------------*/
int mem_test (int pattern, int start_address, int size_in_word )
{
int i;
int temp;
int error = 0;
int *mem_ptr = (int *)start_address;
for(i=0;i<size_in_word;i++) /* write pattern to the memory */
{
*mem_ptr++ = pattern;
}
mem_ptr = (int *)start_address;
for(i=0;i<size_in_word;i++) /* read data back from memory */
{
temp = *mem_ptr++;
#if SPECIAL==ENDPNT
if(i==0)
printf(" Read=0x%08x at Address=0x%08x\n",temp,(mem_ptr-1));
else if((i==size_in_word-1))
printf(" Read=0x%08x at Address=0x%08x\n",temp,(mem_ptr-1));
#endif
#if SPECIAL==INTERV
if(!(i%(1024*256)))
printf(" Read=0x%08x at Address=0x%08x\n",temp,(mem_ptr-1));
#endif
if ( temp != pattern)
{
error++;
#if SPECIAL==MEMTST
if(error<25)
printf(" Read=0x%08x at Address=0x%08x\n",temp,(mem_ptr-1));
#endif
}
}
return error;
}
/*-------------------------------------------------------------------------*/
/* mem_test_alt() - used to test internal SRAM and external SDRAM */
/*-------------------------------------------------------------------------*/
int mem_test_alt (int pattern, int start_address, int size_in_word )
{
int i;
int temp_read,temp_expected;
int error = 0;
int *mem_ptr = (int *)start_address;
for(i=0;i<size_in_word;i++) /* write pattern to the memory */
{
if(i%2)
*mem_ptr++ = ~pattern; /* flip alternating bits */
else
*mem_ptr++ = pattern;
}
mem_ptr = (int *)start_address;
for(i=0;i<size_in_word;i++) /* read data back from memory */
{
temp_read = *mem_ptr++;
#if SPECIAL==ENDPNT
if(i==0)
printf(" Read=0x%08x at Address=0x%08x\n",temp_read,(mem_ptr-1));
else if((i==size_in_word-1))
printf(" Read=0x%08x at Address=0x%08x\n",temp_read,(mem_ptr-1));
#endif
#if SPECIAL==INTERV
if(!(i%(1024*256)))
printf(" Read=0x%08x at Address=0x%08x\n",temp_read,(mem_ptr-1));
#endif
if(i%2)
{
temp_expected = ~pattern; /* flip alternating bits */
}
else
{
temp_expected = pattern;
}
if ( temp_read != temp_expected )
{
error++;
#if SPECIAL==MEMTST
if(error<25)
printf(" Read=0x%08x at Address=0x%08x\n",temp_read,(mem_ptr-1));
#endif
}
}
return error;
}
/*-------------------------------------------------------------------------*/
/* flash_page_prog() - used to program FLASH */
/*-------------------------------------------------------------------------*/
int flash_page_prog( char pattern, char *start_address, int page_size)
{
int i;
char temp;
char *flash_ptr = start_address;
*(char *)FLASH_ADR1 = FLASH_KEY1;
*(char *)FLASH_ADR2 = FLASH_KEY2;
*(char *)FLASH_ADR1 = FLASH_KEY3;
for (i=0;i<page_size;i++)
*flash_ptr++ = pattern;
temp = *--flash_ptr;
while ( temp != pattern)
{
temp = *flash_ptr;
}
return 0;
}
/*-------------------------------------------------------------------------*/
/* flash_test() - used to test external FLASH */
/*-------------------------------------------------------------------------*/
int flash_test( char pattern, int start_address, int size_in_byte)
{
int i = 0;
int error = 0;
char *flash_ptr = (char *)start_address;
i=0;
while(i < size_in_byte) /* write to flash */
{
flash_page_prog ( pattern, flash_ptr, 128);
i = i+128;
flash_ptr = flash_ptr + 128;
}
flash_ptr = (char *)start_address;
for(i=0;i<size_in_byte;i++)
{
if( *flash_ptr++ != pattern)
{
error++;
#if SPECIAL==FLATST
if(error<25)
printf(" Read=0x%08x at Address=0x%08x\n",*flash_ptr,(flash_ptr-1));
#endif
}
}
return error;
}
/*-------------------------------------------------------------------------*/
/* flash_checksum() - used to test checksum in POST on external FLASH */
/*-------------------------------------------------------------------------*/
/*int flash_checksum (int start_address, int size_in_byte)
{
int i = 0, error = 0;
int checksum,*checksum_ptr;
char *flash_ptr = (char *)start_address;
int temp;
i=0;
checksum = 0;
while(i < size_in_byte-4)
{
temp = *flash_ptr++;
temp &= 0xff;
checksum = checksum + temp;
i++;
}
checksum_ptr = (int *)flash_ptr;
exp_chksum=*checksum_ptr;
cmp_chksum=checksum;
if( exp_chksum != cmp_chksum) error = 1;
// if( *checksum_ptr != checksum) error = 1;
return error;
}
*/
/*-------------------------------------------------------------------------*/
/* mcbsp0_init() - used to initialize McBSP0 */
/*-------------------------------------------------------------------------*/
void mcbsp0_init()
{
volatile unsigned int temp =0;
/* set up McBSP0 */
*(unsigned volatile int *)McBSP0_SPCR = 0; /* reset serial port */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -