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

📄 usb_test.c

📁 dm270 source code
💻 C
字号:
/*
Module Name	: usb_test.c

Functions	: USB Init
    
Purpose		: 

Author		: Otis	Yu

Notes		: 

*/
/*--------------------------------------------------------------------------*
*	Local header files						 							    *
*--------------------------------------------------------------------------*/
#include 	<demo/uart270.h>
#include 	<demo/gio270.h>
#include 	<demo/sagiters.h>

/*--------------------------------------------------------------------------*
*	Extern global variables					 							    *
*--------------------------------------------------------------------------*/
extern volatile unsigned short	UART0IntFlag;

/*--------------------------------------------------------------------------*
*	Brief		:	API USB20-IN Detection									*
*	Return		:	None													*
*	Description	:															*
*--------------------------------------------------------------------------*/
BOOL	API_GIO_DetectUSB20( void )	//	0 = USB Plug IN
{
	short i, usbflag;
	for(i=0 ; i<=100 ; i++)
	{
		usbflag = GIO_getBit(GIO2);
	}
	return	usbflag;
}

/*--------------------------------------------------------------------------*
*	Brief		:	USB_TEST 	ND3260										*
*	Return		:	None													*
*	Description	:															*
*--------------------------------------------------------------------------*/
void USB_TEST(void) 
{
	BOOL usb_in=1;
	short i, cnt;
	
	UART_sendString( UART0, "\r\n ***************USB TEST***************" );
	UART_sendString( UART0, "\r\n Please insert USB in\r\n" );
	
	
	do
	{
		if(cnt<30000)			// time out 1 min after
		{
			for(i=0 ; i<1000 ; i++) asm("  NOP");
			usb_in = API_GIO_DetectUSB20( );
			cnt++;
		}
		else
		{
			goto time_out;
		}
		
	}
	while( usb_in == 1 );
	{
		UART_sendString( UART0, "\r\n USB IN DETACHED\r\n" );
		GIO_setBit(GIO29);		// nBUFF_OFF
		GIO_setBit(GIO19);		// USB POWER ON
	}
	
	
	UART_sendString( UART0, "\r\n Push Any Key(PC) Exit Test" );
	while(UART0IntFlag);
	UART0IntFlag = 1;		
	time_out:
	if(cnt == 30000)
	UART_sendString( UART0, "\r\n Still Not Insert USB Time Out Already" );				
	GIO_clearBit(GIO29);		// nBUFF_ON
	GIO_clearBit(GIO19);		// USB POWER OFF											
																	
}

⌨️ 快捷键说明

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