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

📄 usb_hwinterface_layer.c

📁 freescale atk source code
💻 C
📖 第 1 页 / 共 4 页
字号:
	| 				 |	 ------------------------	dQH0ARGUMENTS PASSED:	U32 dqh_base - Base Address of the dQH	U8 	zlt - zero lengh packet termination (enable - ZLT_ENABLE; disable - ZLT_DISABLE)	U16 mps - Max packet length	U8 	ios - interrupt on Setup	U32 next_link_ptr - Next Link Pointer, 	U8 	terminate - terminate - TERMINATE; not terminate - NOT_TERMINATE	U16 total_bytes - Total Bytes to be transfered in this dQH	U8 	ioc - interrupt on complete, set - IOC_SET, not set - IOC_NOTSET	U8 	status - status 	U32 buffer_ptr0 - Buffer Pointer page 0	U16 current_offset - current offset	U32 buffer_ptr1 - Buffer Pointer page 1	U32 buffer_ptr2 - Buffer Pointer page 1	U32 buffer_ptr3 - Buffer Pointer page 1	U32 buffer_ptr4 - Buffer Pointer page 1	  RETURN VALUE:	None		IMPORTANT NOTES:	None		==================================================================================================*/void ipl_setup_qhead(struct dqh_t* qhead){    volatile struct dqh_setup_t* dqh_word = (volatile struct dqh_setup_t*) qhead->dqh_base;    /*======    0x0    ======    Bit31:30 Mult; Bit29 zlt; Bit26:16 mps; Bit15 ios */    dqh_word->dqh_word0 = (((U32)(qhead->zlt) << 29)|((U32)(qhead->mps) <<16) | ((U32)(qhead->ios) <<15));    /*======    0x4    ======    Current dTD Pointer => for hw use, not modified by DCD software */    dqh_word->dqh_word1 = 0x0;	    /*======    0x8    ======    Next dTD Pointer */    dqh_word->dqh_word2 = (((qhead->next_link_ptr) & 0xFFFFFFE0) | qhead->terminate);	    /*======    0xC    ======    Bit30:16 total_bytes; Bit15 ioc; Bit11:10 MultO; Bit7:0 status */	    dqh_word->dqh_word3 = ((((U32)(qhead->total_bytes) & 0x7FFF)  << 16) | ((U32)(qhead->ioc) <<15) | (qhead->status));    /*======    0x10    ======    Bit31:12 Buffer Pointer (Page 0) */    dqh_word->dqh_word4 = ((qhead->buffer_ptr0 & 0xFFFFF000) | (qhead->current_offset & 0xFFF));    /*======    0x14    ======    Bit31:12 Buffer Pointer (Page 1) */    dqh_word->dqh_word5 = (qhead->buffer_ptr1 & 0xFFFFF000);	    /*======    0x18    ======    Bit31:12 Buffer Pointer (Page 2) */    dqh_word->dqh_word6 = (qhead->buffer_ptr2 & 0xFFFFF000);    /*======    0x1C    ======    Bit31:12 Buffer Pointer (Page 3) */    dqh_word->dqh_word7 = (qhead->buffer_ptr3 & 0xFFFFF000);	    /*======    0x20    ======    Bit31:12 Buffer Pointer (Page 4) */    dqh_word->dqh_word8 = (qhead->buffer_ptr4 & 0xFFFFF000);    /*======    0x24    ======    Reserved */    dqh_word->dqh_word9 = 0;    /*======    0x28    ======    Setup Buffer 0 */    dqh_word->dqh_word10 = 0;    /*======    0x2C    ======    Setup Buffer 1 */    dqh_word->dqh_word11 = 0;}/*==================================================================================================FUNCTION: ipl_get_dqhDESCRIPTION:    	This function return the qHD pointer for the required endpoint and direction ARGUMENTS PASSED:	U8 endpt_number -	Endpoint Number .		U8 direction -	IN : qHD of IN EndPoint is to be returned			OUT: qHD of OUT EndPoint is to be returned  RETURN VALUE:	U32 Address : This function return the base address of the qHead structure of the requested Endpoint.		IMPORTANT NOTES:	None		==================================================================================================*/U32 ipl_get_dqh(U8 endpt_number , U8 direction){    /* direction OUT = 0 and IN = 1 */    return (g_buffer_map.ep_dqh_base_addrs + (SIZE_OF_QHD * (endpt_number * 2 + direction)));}/*==================================================================================================FUNCTION: ipl_get_dtdDESCRIPTION:    	This function return the dTD pointer for the required endpoint and direction ARGUMENTS PASSED:	U8 endpt_number -	Endpoint Number .		U8 direction -	IN : dTD of IN EndPoint is to be returned			OUT: dTD of OUT EndPoint is to be returned  RETURN VALUE:	None	IMPORTANT NOTES:	None		==================================================================================================*/U32ipl_get_dtd(U8 endpt_number, U8 direction){    /* If Maximum EPs supported in n then EPno will range from 0 to (n-1) */    return (g_buffer_map.ep_dtd_base_addrs + (SIZE_OF_DTD0 + SIZE_OF_DTD1) * ( endpt_number * 2 + direction));}/*==================================================================================================FUNCTION: alloc_bufferDESCRIPTION:    	This function allocate the free buffer availableARGUMENTS PASSED: 	NoneRETURN VALUE:	U32 address : address of the allocated buffer		IMPORTANT NOTES:	If Buffer1 is FREE then return Buffer1 and mark this as Busy else check for buffer2 . If 	none of the buffer is free then return NULL.		==================================================================================================*/U32 alloc_buffer(void){    U32 buffer_addr = NULL;        /* Check if buffer1 is free then mark it busy and return address */     if (g_buffer_map.buffer1_status == BUFFER_FREE )    {        buffer_addr = g_buffer_map.buffer1_address;	g_buffer_map.buffer1_status = BUFFER_IN_USE;    }    /* Check if buffer2 is free then mark it busy and return address */     else if(g_buffer_map.buffer2_status == BUFFER_FREE)    {        buffer_addr = g_buffer_map.buffer2_address;	g_buffer_map.buffer2_status = BUFFER_IN_USE;    }        return buffer_addr ;}/*==================================================================================================FUNCTION: free_bufferDESCRIPTION:    	This function put the buffer in free state.ARGUMENTS PASSED:	U32 address : address of the buffer . 	RETURN VALUE: 	None	IMPORTANT NOTES:	None		==================================================================================================*/void free_buffer(U32 address){    if( address == g_buffer_map.buffer1_address )    {        g_buffer_map.buffer1_status = BUFFER_FREE;    }    else if ( address == g_buffer_map.buffer2_address )    {        g_buffer_map.buffer2_status = BUFFER_FREE;    }}/*==================================================================================================FUNCTION: get_rxd_bufferDESCRIPTION:    	This function return the buffer in which data was received.ARGUMENTS PASSED: 	NoneRETURN VALUE:	U32 address : address of the buffer . 		IMPORTANT NOTES:        Whenever this function is called one of the buffer will be busy and other should be free. 			==================================================================================================*/U32 get_rxd_buffer(void){    U32 address = NULL;        /* check if the buffer1 was used for receiving data */    if( g_buffer_map.buffer1_status == BUFFER_IN_USE)    {        address = g_buffer_map.buffer1_address;    }    /* check if the buffer2 was used for receiving data */    else if( g_buffer_map.buffer2_status == BUFFER_IN_USE)    {        address = g_buffer_map.buffer2_address ;    }    return address;}/*==================================================================================================FUNCTION: copy_from_bufferDESCRIPTION:    	This function return the buffer in which data was received.ARGUMENTS PASSED: 	NoneRETURN VALUE: 	None	IMPORTANT NOTES:	None		==================================================================================================*/voidcopy_from_buffer(U32* src,U8* dest,U32 size){    U32 temp;    U8 i;    U8 j;/* Copy data */    while(size/4)    {	temp =  *src;	#ifdef SIMULATOR_TESTING	*dest++ = ((temp >> 24) & 0xFF);	*dest++ = ((temp >> 16) & 0xFF);	*dest++ = ((temp >> 8) & 0xFF);    *dest++ = (temp & 0xFF);    #else	*dest++ = (temp & 0xFF);	*dest++ = ((temp >> 8) & 0xFF);	*dest++ = ((temp >> 16) & 0xFF);	*dest++ = ((temp >> 24) & 0xFF);	#endif	src++;	size-=4;    }    /* copy rest of data bytes */    i=(size%4);    #ifdef SIMULATOR_TESTING    j=3;#else      j=0;#endif        while(i)    {    temp = *src;	*dest++ = (temp >> (j*0x8) & 0xFF);	#ifdef SIMULATOR_TESTING        j--;#else    	j++;#endif		i--;    }} /*==================================================================================================FUNCTION: copy_to_bufferDESCRIPTION:    	This function return the buffer in which data was received.ARGUMENTS PASSED: 	NoneRETURN VALUE: 	None	IMPORTANT NOTES:	None		==================================================================================================*/voidcopy_to_buffer(U8* src, U32* dest, U32 size){    U32 temp = 0;    U8 i , j;/* Copy data */    while(size/4)    {	temp = 0x0;	#ifdef SIMULATOR_TESTING    temp |=  ( *src++ << 24 );	temp |=  ( *src++ << 16 );	temp |=  ( *src++ << 8 );	temp |=  *src++;#else	temp |=  *src++;	temp |=  ( *src++ << 8 );	temp |=  ( *src++ << 16 );	temp |=  ( *src++ << 24 );#endif	*dest = temp;	dest++;	size-=4;    }    /* copy rest of data bytes */    i=(size%4);    #ifdef SIMULATOR_TESTING    j=3 ;#else        j=0;#endif        temp = 0x0;    if(i)    {        while(i)        {            temp |= ( *src++ << ( j * 8));	    i--;	    #ifdef SIMULATOR_TESTING	    	    j--;#else	            j++;#endif                }        *dest = temp;    }} 

⌨️ 快捷键说明

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