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

📄 bbu_dd_post.c

📁 DSP芯片自检测程序
💻 C
📖 第 1 页 / 共 4 页
字号:
        
        if (buffer2[i+2] != inter[2])
        {
            result = POST_ERROR;
            *memErrPosition = (Uint32)(&buffer2[i+2]);
            break;
        }
        
        if (buffer2[i+3] != inter[3])
        {
            result = POST_ERROR;
            *memErrPosition = (Uint32)(&buffer2[i+3]);
            break;
        }
    }
    
    return result;
}
/*----------------------------------------------------------------------------*/

/*******************************************************************************
* 函数名称: POST_mcbspTest      				            		           *
* 函数描述: Start McBSP Device Test                                            *
* 相关文档:                                                                    *
* 参数描述:  						                    			           *
* 参数名		     类型		输入/输出 	   描述	       			           *
* -------- 		     ---- 		---------	-----------    			           *
* portNum           Sint32         in		Mcbsp Port Number                  *
*                                                                              *
* 返回值: 0 -- POST_OK, -1 -- POST_ERROR		                               *
* 说明:			                         		                           *
*******************************************************************************/
CSLAPI Sint32 POST_mcbspTest(Sint32 portNum)
{
Uint32 i;
MCBSP_Handle *hMcbspPort; 
EDMA_McbspRConfig rConfig;
EDMA_McbspXConfig xConfig;
Uint32 *tempPtr;
Uint32 count;

    mcbspTxIntFlag = 0;
    mcbspRxIntFlag = 0;
    
    /* clear receiving ping and pong buffer */
    for(i=0;i<MCBSP_RX_BUFFER_SIZE;i++)
    {
        mcbspRxBufPing[portNum][i] = 0;
        mcbspRxBufPong[portNum][i] = 0;
    }
    
    /* fill the transmit buffer and clear receive buffer */
    for(i=0;i<MCBSP_TX_BUFFER_SIZE;i++)
    {
        mcbspTxBuf[portNum][i] = 100 + i;
        mcbspRxBuf[portNum][i] = 0;
    }
    mcbspTxBuf[portNum][MCBSP_TX_BUFFER_SIZE-1] = 0;
    
    /* initilizing the Mcbsp device */
    hMcbspPort = (MCBSP_Handle *)MCBSP_init(portNum); 
    if (hMcbspPort == MCBSP_HINV)
    {
        switch (portNum)
        {
            case MCBSP_PORT0: postTestResult.errorCode = POST_MCBSP0_INIT_ERR;
                              break;
            case MCBSP_PORT1: postTestResult.errorCode = POST_MCBSP1_INIT_ERR;
                              break;
            case MCBSP_PORT2: postTestResult.errorCode = POST_MCBSP2_INIT_ERR;
                              break;
        }                        
        return POST_ERROR;           
    }
    
    /* start EDMA channel for McBSP Device receiving data */     
    if(portNum == MCBSP_PORT0)
    {
        rConfig.priority = EDMA_MCBSP0R_PRI; 
        xConfig.priority = EDMA_MCBSP0X_PRI;
    }
    if(portNum == MCBSP_PORT1)
    {
        rConfig.priority = EDMA_MCBSP1R_PRI; 
        xConfig.priority = EDMA_MCBSP1X_PRI;
    }
    if(portNum == MCBSP_PORT2)
    {
        rConfig.priority = EDMA_MCBSP2R_PRI; 
        xConfig.priority = EDMA_MCBSP2X_PRI;
    }                   
    rConfig.sourAdd = (Uint32)hMcbspPort->drrAddr;
    rConfig.pingAdd = (Uint32)(&mcbspRxBufPing[portNum][0]);
    rConfig.pongAdd = (Uint32)(&mcbspRxBufPong[portNum][0]);
    rConfig.frameCount = 0;
    rConfig.eleCount = MCBSP_RX_BUFFER_SIZE & 0x0000FFFF; 
    rConfig.hLEdma1 = edmaMcbspRLHandle1[portNum];
    rConfig.hLEdma2 = edmaMcbspRLHandle2[portNum];
    MCBSP_startEdmaR(edmaMcbspRHandle[portNum], &rConfig);    
    MCBSP_enableRcv(hMcbspPort); 
    
    /* start EDMA channel for McBSP Device transmiting data */
    xConfig.sourAdd = (Uint32)(&mcbspTxBuf[portNum][0]);
    xConfig.destAdd = (Uint32)hMcbspPort->dxrAddr;
    xConfig.frameCount = 0;
    xConfig.eleCount = MCBSP_TX_BUFFER_SIZE & 0x0000FFFF;  
    MCBSP_startEdmaX(edmaMcbspXHandle[portNum],&xConfig);
    MCBSP_enableXmt(hMcbspPort);        /* Start transmitter */
    while (MCBSP_xEmpty(hMcbspPort) != MCBSP_SPCR_XEMPTY_NO); /* Write to DXR,then
                                                            XSR is not empty */ 
    MCBSP_enableFSync(hMcbspPort);        

    /* Receiving the data by Interrupt notification */
    count = 0;
    do
    {
        if(mcbspTxIntFlag == 1)
        {
            while (MCBSP_xEmpty(hMcbspPort) != MCBSP_SPCR_XEMPTY_YES);    
            MCBSP_disableXmt(hMcbspPort);
        }
        
        if(mcbspRxIntFlag != 0)
        {
            if(mcbspRxIntFlag == 1)                     /*ping Buffer */
            {
        	    tempPtr = &mcbspRxBufPing[portNum][0];
        	}
        	else                                        /*pong Buffer */
            {
        	    tempPtr = &mcbspRxBufPong[portNum][0];
        	}    
        	
        	if(tempPtr[0] != 0)
	    	{
	    	    for(i=0;i<MCBSP_RX_BUFFER_SIZE;i++)
	            {
	    	        mcbspRxBuf[portNum][count] = tempPtr[i];
	    	        count++;
	    	    }
	    	}
	    	mcbspRxIntFlag = 0;
        }
        if(count >= MCBSP_TX_BUFFER_SIZE)   break;
    }while(1);
    
    /* close McBSP Device and close transmiting and receiving EDMA channel */ 
    MCBSP_close(hMcbspPort);
    EDMA_close(edmaMcbspXHandle[portNum]);
    EDMA_close(edmaMcbspRHandle[portNum]);
    
    /* compare the received data with transmiting buffer */
    for(i=0;i<MCBSP_TX_BUFFER_SIZE;i++)
    {
        if(mcbspTxBuf[portNum][i] != mcbspRxBuf[portNum][i]) 
        {
            switch (portNum)
            {
                case MCBSP_PORT0: postTestResult.errorCode = POST_MCBSP0_ERR;
                                  break;
                case MCBSP_PORT1: postTestResult.errorCode = POST_MCBSP1_ERR;
                                  break;
                case MCBSP_PORT2: postTestResult.errorCode = POST_MCBSP2_ERR;
                                  break;
            }                        
            return POST_ERROR;
        }                    
    }
    
    return POST_OK;
}    
/*----------------------------------------------------------------------------*/  

/*******************************************************************************
* 函数名称: POST_timerTest      				            		           *
* 函数描述: Timer Test                                                         *
* 相关文档:                                                                    *
* 参数描述:  						                    			           *
* 参数名		     类型		输入/输出 	   描述	       			           *
* -------- 		     ---- 		---------	-----------    			           *
* timerNum           Sint32        in		TIMER Device Number                *
*                                                                              *
* 返回值: 0 -- POST_OK, -1 -- POST_ERROR		                               *
* 说明: 			                         		                           *
*******************************************************************************/
CSLAPI Sint32 POST_timerTest(Sint32 timerNum)
{
TIMER_Handle *hTimer; 
Uint32 count,flag;
Uint32 testNum;

    timerIntCount[timerNum] = 0;
    count = 0;
    flag = 0;
    testNum = 200;
    
    /* initilizing the TIMER device */
    hTimer = (TIMER_Handle *)TIMER_init(timerNum); 
    if (hTimer == TIMER_HINV)
    {
        switch (timerNum)
        {
            case TIMER_DEV0: postTestResult.errorCode = POST_TIMER0_INIT_ERR;
                             break;
            case TIMER_DEV1: postTestResult.errorCode = POST_TIMER1_INIT_ERR;
                             break;
            case TIMER_DEV2: postTestResult.errorCode = POST_TIMER2_INIT_ERR;
                             break;
        }                        
        return POST_ERROR;        
    }
    
    /* start the Timer Device */        
    TIMER_start(hTimer);

    do
    {
        if(TIMER_RGETH(hTimer,CNT) >  (TIMER_RGETH(hTimer,PRD)- 24))
        {
            if(flag == 0)
            {
                count++;
                flag = 1;
            }   
        }
        else
        {
            flag = 0;
        }                       
        
        if(count > testNum)
        {
            break;
        }       
        if(timerIntCount[timerNum] >= testNum)
        {
            break;
        }
    }while(1);
    
    /* close the TIMER Device */ 
    TIMER_close(hTimer);
    
    /* judge if timer is good */
    if(count != timerIntCount[timerNum])
    {
        switch (timerNum)
        {
            case TIMER_DEV0: postTestResult.errorCode = POST_TIMER0_ERR;
                             break;
            case TIMER_DEV1: postTestResult.errorCode = POST_TIMER1_ERR;
                             break;
            case TIMER_DEV2: postTestResult.errorCode = POST_TIMER2_ERR;
                             break;
        }                        
        return POST_ERROR;
    }
    else
    {
        return POST_OK;
    }    
}    
/*----------------------------------------------------------------------------*/  

/*******************************************************************************
* 函数名称: POST_5msFrameTest      				            		           *
* 函数描述: 5ms frame input signal Test                                        *
* 相关文档:                                                                    *
* 参数描述: 无 						                    			           *
*                                                                              *
* 返回值: 0 -- POST_OK, -1 -- POST_ERROR		                               *
* 说明: 			                         		                           *
*******************************************************************************/
CSLAPI Sint32 POST_5msFrameTest(void)
{
TIMER_Handle *hTimer; 
Uint32 flag1;

    flag1 = 0;
    timerIntCount[TIMER_DEV0] = 0;
    
    /* initilizing the TIMER device */
    hTimer = (TIMER_Handle *)TIMER_init(TIMER_DEV0); 
    if (hTimer == TIMER_HINV)
    {
        postTestResult.errorCode = POST_TIMER0_INIT_ERR;
        return POST_ERROR;           
    }

    /* start the Timer Device */        
    TIMER_start(hTimer); 
        
    gpio5msFrameIntCount = 0;   
    IRQ_enable(IRQ_EVT_EXTINT6);    /* enable 5ms frame interrupt */
        
    do{
        if((gpio5msFrameIntCount > 1000) || (timerIntCount[TIMER_DEV0] > 1000)) /* 5 seconds */
        {
            break;
        }
        if((((Uint32)(gpio5msFrameIntCount/50) % 2) == 0) && (flag1 == 0))
        {
            GPIO_setLedOn(hCpbGpio,led1PinMask);
            flag1 = 1;
        }
        if((((Uint32)(gpio5msFrameIntCount/50) % 2) == 1) && (flag1 == 1))
        {
            GPIO_setLedOff(hCpbGpio,led1PinMask);
            flag1 = 0;            
        }           
    }while(1);         
            
    /* close the TIMER Device */ 
    TIMER_close(hTimer);
    IRQ_disable(IRQ_EVT_EXTINT6);   /* disable 5ms frame interrupt */
    
    if((gpio5msFrameIntCount > (timerIntCount[TIMER_DEV0] + 3)) || \
        (gpio5msFrameIntCount < (timerIntCount[TIMER_DEV0] - 3)))
    {

⌨️ 快捷键说明

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