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

📄 m54455evb_ulpi_test.c

📁 Freescale MCF5445evb 参考测试代码
💻 C
字号:
/*! * \file    m54455evb_ulpi_test.c * \brief   Test the ULPI interface on the M54455EVB (aka Jamaica) * \version $Revision: 1.2 $ * \author  Michael Norman * * Test the SMSC USB3300 connectivity */ #include "common.h"#include "m54455evb_fat.h"                /********************************************************************//*! * \brief   ULPI Test * \return  0 if the tests was successful; non-zero otherwise */intulpi_test(void){    int i, err_cnt = 0;    uint8 data;    /* Make sure the transceiver is enabled */    CPLD_CONTROL &= ~CPLD_CONTROL_ULPI_RESET;    	/* Initialize the USB Clock, use ext clk if PLL isn't a multiple of 60MHz */	if (FSYS_MHZ % 60)	{	    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;	}	else	{	    MCF_CCM_MISCCR |= MCF_CCM_MISCCR_USBSRC;	}		/* 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();        /* 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)	    return 1;    return 0;}/********************************************************************/

⌨️ 快捷键说明

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