⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.c

📁 dsp(tmsvc5502)flash写入程序(源代码)
💻 C
📖 第 1 页 / 共 3 页
字号:
        status |= MEM_fill(start, len, 0x00000000);
        status |= MEM_fill(start, len, 0x55555555);
        status |= MEM_fill(start, len, 0xAAAAAAAA);
        status |= MEM_fill(start, len, 0xFFFFFFFF);
    } else
    {
        /* Run the address tests */
        status |= MEM_addr(start, len);
        status |= MEM_addrInv(start, len);
    }
        
    return status;
}


/*
 *  POST tests
 */

Int16 TEST_intMem()
{
    Int16 status = 0;
    
    /* Check internal memory (byte 0x80000 to byte 0x10000) */
//    status |= MEM_test(0x4000, 0x004000, 0);
//    status |= MEM_test(0x4000, 0x004000, 1);
//   status |= MEM_walking(0x4000);

	status |= MEM_test(0x7000, 0x001000, 0);
	status |= MEM_test(0x7000, 0x001000, 1);
	status |= MEM_walking(0x7000);

    return status;
}

Int16 TEST_sdram()
{
    Int16 status = 0;
    
    /* Check external memory (byte 0x10000 to byte 0x400000) */
    status |= MEM_test(0x8000, 0x1F8000, 0);
    status |= MEM_test(0x8000, 0x1F8000, 1);
    status |= MEM_walking(0x8000);
     
    return status;
}

Int16 TEST_sbsram()
{
    Int16 status = 0;
    
    /* Check external memory (byte 0xc00000 to byte 0xd00000) */
    status |= MEM_test(0x600000, 0x80000, 0);
    status |= MEM_test(0x600000, 0x80000, 1);
    status |= MEM_walking(0x600000);
     
    return status;
}

Int16 TEST_flashID()
{
    Uint16 MfgId,DevId;
    Int16 i;
    
    /* Reset Flash */
    *((Uint16 *)EVM5502_FLASH_BASE) = 0xf0;
 
    /* Read Manufacturer ID */
    *((Uint16 *)EVM5502_FLASH_CTL555) = 0xaa;
    *((Uint16 *)EVM5502_FLASH_CTL2AA) = 0x55;
    *((Uint16 *)EVM5502_FLASH_CTL555) = 0x90; 
    
    /* Insert small delay for device to respond */
    for (i = 0; i < 10; i++);

    /* Read IDs */
    MfgId = *((Uint16 *)EVM5502_FLASH_BASE);
    DevId = *((Uint16 *)EVM5502_FLASH_BASE + 1);

    /* Reset Flash */
    *((Uint16 *)EVM5502_FLASH_BASE) = 0xf0;

    /* Check codes */
    if ((MfgId != 0x0001) || (DevId != 0x22b9))
        return 1;

    /* Test passed */
    return 0;
}

Int16 TEST_flash()
{
    Uint16 i, j, k;
    Uint32 startaddr, addr;
    
    /* Erase all of the Flash but first page */
    EVM5502_FLASH_erase(EVM5502_FLASH_BASE + EVM5502_FLASH_PAGESIZE,
        EVM5502_FLASH_PAGESIZE * 7);
    
    /* Program the Flash page by page, 256 words at a time */
    addr = EVM5502_FLASH_BASE + EVM5502_FLASH_PAGESIZE;
    for (i = 1; i < 8; i++)
    {
        for (j = 0; j < 128; j++)
        {
            startaddr = addr;
            for (k = 0; k < 256; k++)
            {
                buffer[k] = addr + i;
                addr++;
            }
            EVM5502_FLASH_write((Uint32)buffer, startaddr, 256);
        }
    }

    /* Verify the Flash page by page, 256 bytes at a time */
    addr = EVM5502_FLASH_BASE + EVM5502_FLASH_PAGESIZE;
    for (i = 1; i < 8; i++)
    {
        for (j = 0; j < 128; j++)
        {
            startaddr = addr;
            EVM5502_FLASH_read(startaddr, (Uint32)buffer, 256);
            for (k = 0; k < 256; k++)
            {
                if (buffer[k] != ((addr + i) & 0xffff))
                    return 2;
                addr++;
            }
        }
    }

    return 0;
}

Int16 TEST_mcbsp(Int16 devid, Int16 delayed)
{
    Int16 i;
    Uint16 receivedata;
    MCBSP_Handle hMcbsp;
    MCBSP_Config mcbspCfg_loopback = {
        0xa000,        /*  Serial Port Control Register 1   */
        0x0100,        /*  Serial Port Control Register 2   */
        0x0140,        /*  Receive Control Register 1   */
        0x0000,        /*  Receive Control Register 2   */
        0x0140,        /*  Transmit Control Register 1   */
        0x0000,        /*  Transmit Control Register 2   */
        0x0000,        /*  Sample Rate Generator Register 1   */
        0x2000,        /*  Sample Rate Generator Register 2   */
        0x0000,        /*  Multichannel Control Register 1   */
        0x0000,        /*  Multichannel Control Register 2   */
        0x0a03,        /*  Pin Control Register   */
        0x0000,        /*  Receive Channel Enable Register Partition A   */
        0x0000,        /*  Receive Channel Enable Register Partition B   */
        0x0000,        /*  Receive Channel Enable Register Partition C   */
        0x0000,        /*  Receive Channel Enable Register Partition D   */
        0x0000,        /*  Receive Channel Enable Register Partition E   */
        0x0000,        /*  Receive Channel Enable Register Partition F   */
        0x0000,        /*  Receive Channel Enable Register Partition G   */
        0x0000,        /*  Receive Channel Enable Register Partition H   */
        0x0000,        /*  Transmit Channel Enable Register Partition A   */
        0x0000,        /*  Transmit Channel Enable Register Partition B   */
        0x0000,        /*  Transmit Channel Enable Register Partition C   */
        0x0000,        /*  Transmit Channel Enable Register Partition D   */
        0x0000,        /*  Transmit Channel Enable Register Partition E   */
        0x0000,        /*  Transmit Channel Enable Register Partition F   */
        0x0000,        /*  Transmit Channel Enable Register Partition G   */
        0x0000         /*  Transmit Channel Enable Register Partition H   */
    };
        
    /* Initialize source data, zero dest */
    for (i = 0; i < N; i++) {
        src[i] = (i << 8) | i + 1;
        dst[i] = 0;
    }
    
    /* Open the McBSP */
    hMcbsp = MCBSP_open(devid, MCBSP_OPEN_RESET);

    /* Configure the McBSP for loopback mode */
    MCBSP_config(hMcbsp, &mcbspCfg_loopback);

    /* Start the McBSP */
    MCBSP_start(hMcbsp, 
        MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC |
        MCBSP_RCV_START | MCBSP_XMIT_START, 0x200);
        
    /* Data transfer loop */
    for (i = 0; i < (N + delayed); i++) {
        /* Wait for XRDY signal before writing data to DXR */
        while (!MCBSP_xrdy(hMcbsp));
                 
        /* Write 16 bit data value to DXR */
        MCBSP_write16(hMcbsp,src[i]);
        EVM5502_waitusec(1);
 
        /* Wait for RRDY signal to read data from DRR */
        while (!MCBSP_rrdy(hMcbsp));

        /* Read 16 bit value from DRR */
        receivedata = MCBSP_read16(hMcbsp);
        if (i >= delayed)
            dst[i - delayed] = receivedata;               
    }

    /* Close the McBSP */
    MCBSP_close(hMcbsp);
    
    /* Check data to make sure transfer was successful */
    for (i = 0; i < N; i++)
        if (dst[i] != src[i])
            return 1;
    
    /* Test passed */
    return 0;
}

Int16 TEST_mcbsp0()
{
    /* Do an internal loopback test on McBSP0 */
    return TEST_mcbsp(0, 1);
}

Int16 TEST_dma()
{
    Int16 i;
    DMA_Handle hDma0;
    DMA_Config dmaCfg0 = {
        0x0205,           /*  Source Destination Register (CSDP)  */
        0x5060,           /*  Control Register (CCR)  */
        0x0008,           /*  Interrupt Control Register (CICR)  */
        0, /*  Lower Source Address (CSSA_L) - Symbolic(Byte Address)  */
        NULL,             /*  Upper Source Address (CSSA_U) - Symbolic(Byte Address)  */
        0, /*  Lower Destination Address (CDSA_L) - Symbolic(Byte Address)  */
        NULL,             /*  Upper Destination Address (CDSA_U) - Symbolic(Byte Address)  */
        0x0010,           /*  Element Number (CEN)  */
        0x0001,           /*  Frame Number (CFN)  */
        0x0000,           /*  Frame Index (CFI)  */
        0x0000            /*  Element Index (CEI)  */
    };
    
    /* Set src and dst addresses (in bytes instead of 16-bit words) */
    dmaCfg0.dmacssal = (DMA_AdrPtr)(((Uint32)(&src) << 1) & 0xFFFF);
    dmaCfg0.dmacssau = (Uint16)((Uint32)(&src) >> 15);
    dmaCfg0.dmacdsal = (DMA_AdrPtr)(((Uint32)(&dst) << 1) & 0xFFFF);
    dmaCfg0.dmacdsau = (Uint16)((Uint32)(&dst) >> 15);
    
    /* Set src values and clear destination */
    for (i = 0; i < N; i++) {
        src[i] = i;                   
        dst[i] = 0;
    }

    /* Open DMA channel */
    hDma0 = DMA_open(DMA_CHA0, DMA_OPEN_RESET);

    /* Configure the DMA */
    DMA_config(hDma0, &dmaCfg0);
        
    /* Call DMA_start to begin the data transfer */
    DMA_start(hDma0);
    
    /* Read the status register to clear it */
    i = DMA_RGET(DMACSR0);      

    /* Poll DMA status too see if its done */
    while (!DMA_FGETH(hDma0, DMACSR, FRAME))
    {
    	;
    }

    /* We are done, so close DMA channel */
    DMA_close(hDma0);
    
    /* Check data */
    for (i = 0; i < N; i++)
        if (dst[i] != src[i])
            return 1;

    /* Test passed */
    return 0; 
}

Int16 TEST_eeprom()
{
    Uint16 page, i, *pdata;
    
    /* Write a pattern */
    for (page = 0; page < (EVM5502_EEPROM_SIZE >> 6); page++)
    {
        pdata = (Uint16 *)buffer;
        for (i = 0; i < 64; i++)
            *pdata++ = (page + i) & 0xff;
        EVM5502_EEPROM_write((Uint32)buffer, page << 6, 64);
    }
    
    for (i = 0; i < 64; i++)
        buffer[i] = 0;
    
    /* Verify the pattern */
    for (page = 0; page < (EVM5502_EEPROM_SIZE >> 6); page++)
    {
        EVM5502_EEPROM_read(page << 6, (Uint32)buffer, 64);
        pdata = (Uint16 *)buffer;
        for (i = 0; i < 64; i++)
            if (*pdata++ != ((page + i) & 0xff))
                return 1;  // Fail
    }
    
    return 0;
}

Int16 TEST_codec()
{
    EVM5502_AIC23_CodecHandle hCodec;
    Int16 i, j;
    
    /* Start the codec */
    hCodec = EVM5502_AIC23_openCodec(0, &config);
    
    /* Generate a 1KHz sine wave for 10 second */
    for (i = 0; i < 10000; i++)
    {
        for (j = 0; j < SINE_TABLE_SIZE; j++)
        {       
            while (!EVM5502_AIC23_write16(hCodec, sinetable[j]));
            while (!EVM5502_AIC23_write16(hCodec, sinetable[j]));
        }
    }
    
    /* Close codec */
    EVM5502_AIC23_closeCodec(hCodec);

    return 0;
}

Int16 TEST_uart()
{
    Int16 i;
    EVM5502_UART_Handle hUart;
    EVM5502_UART_Config uartcfg = {
        0x00,  // IER
        0x00,  // FCR
        0x03,  // LCR
        0x00   // MCR
    };
    
    /* Open UART */
    hUart = EVM5502_UART_open(0, EVM5502_UART_BAUD_19200, &uartcfg);
    
    /* Loop through 256 bytes */
    for (i = 0; i < 256; i++)
    {
        EVM5502_UART_putChar(hUart, (i + 1) & 0xff);
        buffer[i] = EVM5502_UART_getChar(hUart);
    }
    
    /* Verify data */
    for (i = 0; i < 256; i++)
    {
        if (buffer[i] != ((i + 1) & 0xff))
            return 1;
    }
    
    return 0;
}

Int16 TEST_srom()
{
    Uint16 page, i, *pdata;

    /* Initialize SROM API */
    EVM5502_SROM_init();

    /* Erase SROM */
    EVM5502_SROM_erase(EVM5502_SROM_BASE, EVM5502_SROM_SIZE);
    
    /* Write a pattern */
    for (page = 0; page < EVM5502_SROM_SIZE >> 8 ; page++)
    {
        pdata = (Uint16 *)buffer;
        for (i = 0; i < 256; i++)
            *pdata++ = (page + i) & 0xff;
        EVM5502_SROM_write((Uint32)buffer, page << 8, 256);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -