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

📄 ulpi_test.c

📁 Freescale MCF5445evb 参考测试代码
💻 C
字号:
/*! * \file    ulpi_test.c * \brief   Test the ULPI interface on M54451EVB * \version $Revision: 1.1 $ * \author  Michael Norman * * Test the SMSC USB3300 connectivity */ #include "common.h"#include "m54451evb_tests.h"                /********************************************************************//*! * \brief   ULPI Test * \return  ULPI_PASS or ULPI_FAIL */intulpi_test(void){    int i, err_cnt = 0;    uint8 data;	/* Initialize the USB Clock from USB_CLKIN pin */    MCF_CCM_MISCCR &= ~MCF_CCM_MISCCR_USBSRC;	MCF_GPIO_PAR_DMA = MCF_GPIO_PAR_DMA	    & MCF_GPIO_PAR_DMA_DREQ1_MASK	    | MCF_GPIO_PAR_DMA_DREQ1_USB_CLKIN;		/* Enable the required ULPI signals */    MCF_GPIO_PAR_DMA = MCF_GPIO_PAR_DMA        & MCF_GPIO_PAR_DMA_DACK1_MASK        | MCF_GPIO_PAR_DMA_DACK1_ULPI_DIR;    MCF_GPIO_PAR_USB = 0        | MCF_GPIO_PAR_USB_VBUSEN_ULPI_NXT        | MCF_GPIO_PAR_USB_VBUSOC_ULPI_STP;    MCF_GPIO_PAR_FEC = MCF_GPIO_PAR_FEC         & MCF_GPIO_PAR_FEC_FEC0_MASK        | MCF_GPIO_PAR_FEC_FEC0_RMII_ULPI;    	/* Enable Host mode */	MCF_USB_USBMODE = 0	    | MCF_USB_USBMODE_ES 	    | MCF_USB_USBMODE_CM_HOST;	/* Enable ULPI and apply power to the port */	MCF_USB_PORTSC = 0	    | MCF_USB_PORTSC_PTS_ULPI	    | MCF_USB_PORTSC_PP;	    /* Wait a bit; If this isn't here the first read is 0x00 instead of 0x24 */    for (i = 1000; i; i--)        nop();        for (i = 1000; i; i--)    {		/* Read the first register */	    		MCF_USB_ULPI_VIEWPORT = 0    		| MCF_USB_ULPI_VIEWPORT_ULPI_RUN    		| MCF_USB_ULPI_VIEWPORT_ULPI_ADDR(0x0);		while (MCF_USB_ULPI_VIEWPORT & MCF_USB_ULPI_VIEWPORT_ULPI_RUN);			data = MCF_USB_ULPI_VIEWPORT>>8 &0xFF;		if (data != 0x24)			err_cnt++;				/* Read the second register */	    		MCF_USB_ULPI_VIEWPORT = 0    		| MCF_USB_ULPI_VIEWPORT_ULPI_RUN    		| MCF_USB_ULPI_VIEWPORT_ULPI_ADDR(0x1);		while (MCF_USB_ULPI_VIEWPORT & MCF_USB_ULPI_VIEWPORT_ULPI_RUN);			data = MCF_USB_ULPI_VIEWPORT>>8 &0xFF;		if (data != 0x04)			err_cnt++;				/* Read the third register */	    		MCF_USB_ULPI_VIEWPORT = 0    		| MCF_USB_ULPI_VIEWPORT_ULPI_RUN    		| MCF_USB_ULPI_VIEWPORT_ULPI_ADDR(0x2);		while (MCF_USB_ULPI_VIEWPORT & MCF_USB_ULPI_VIEWPORT_ULPI_RUN);			data = MCF_USB_ULPI_VIEWPORT>>8 &0xFF;		if (data != 0x04)			err_cnt++;				/* Read the fourth register */	    		MCF_USB_ULPI_VIEWPORT = 0    		| MCF_USB_ULPI_VIEWPORT_ULPI_RUN    		| MCF_USB_ULPI_VIEWPORT_ULPI_ADDR(0x3);		while (MCF_USB_ULPI_VIEWPORT & MCF_USB_ULPI_VIEWPORT_ULPI_RUN);			data = MCF_USB_ULPI_VIEWPORT>>8 &0xFF;		if (data != 0x00)			err_cnt++;	}	if (err_cnt)	{	    #ifdef DEBUG_PRINT	    printf("ULPI: %d total errors\n",err_cnt);	    #endif	    return ULPI_FAIL;	}    return ULPI_PASS;}/********************************************************************/

⌨️ 快捷键说明

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