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

📄 usbdma.h

📁 LPC2148 USB固件程序,是学习固件不可多的的范例.
💻 H
字号:
/****************************************Copyright (c)**************************************************
**                               Guangzou ZLG-MCU Development Co.,LTD.
**                                      graduate school
**                                 http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name:			USBdma.c
** Last modified Date:	2005-8-6
** Last Version:		V1.0
** Descriptions:		LPC2148 USB DMA 控制器头文件, 本文件只使能了物理端点 2 ~ 5 的 DMA 功能
**						LPC2148 USB DMA controller, the file only enable the DMA function of physical endpoint 2 ~ 5
**------------------------------------------------------------------------------------------------------
** Created by:			郑明远 		MingYuan Zheng
** Created date:		2005-8-6
** Version:				V1.0
** Descriptions:		初始版本	The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:			
** Modified date:
** Version:				
** Descriptions:
**
**------------------------------------------------------------------------------------------------------
** Modified by: 
** Modified date:
** Version:	
** Descriptions: 
**
********************************************************************************************************/

#ifndef __USBDMA_H__
#define __USBDMA_H__


/* LPC214x DMA 引擎 DD 描述符结构体  LPC214x DMA engine DD descriptor structure */
typedef struct non_iso_dd_tag
{
	INT32U next_dd_addr;		/* 下一个DD地址 			next DD address */
	INT32U control;				/* DD控制字     			DD control word	*/
	INT32U start_addr;			/* DMA 缓冲区起始地址		DMA buffer start address */
	INT32U status;				/* DMA 引擎状态				DMA engine status */
}DD_DESCRIPTOR;



/* 各端点 DMA 缓冲区大小, 用户可自行修改, 请注意总和不要大于 8K - 0.64K (LPC2148). 
   
   Each endpoint dma buffer size, user can modify it, please note the len can't be above 8K - 0.64K (LPC2148) */

#define EP02_DMA_BUFFER_LENGTH	 	512
#define EP03_DMA_BUFFER_LENGTH	 	512		
#define EP04_DMA_BUFFER_LENGTH	 	3072
#define EP05_DMA_BUFFER_LENGTH	 	3072


#define USB_RAM_ADDRESS 	0x7FD00000 									/* USB RAM 起始地址 	 Start address of USB RAM  */

#define DD_SIZE				sizeof(DD_DESCRIPTOR)						/* DD 结构体大小		 DD size  				   */									

#define DD_BASE_ADDRESS 	(USB_RAM_ADDRESS + (4 * 32))				/* 32: LPC214x 端点个数  32: the endpoint numbers  */
																
#define DD_ADDRESS_EP02		DD_BASE_ADDRESS								/* 物理端点2 DD地址		 DD address of endpoint 02 */
#define DD_ADDRESS_EP03		(DD_BASE_ADDRESS + (DD_SIZE * 1))			/* 物理端点3 DD地址		 DD address of endpoint 03 */
#define DD_ADDRESS_EP04		(DD_BASE_ADDRESS + (DD_SIZE * 2))			/* 物理端点4 DD地址 	 DD address of endpoint 04 */
#define DD_ADDRESS_EP05		(DD_BASE_ADDRESS + (DD_SIZE * 3))			/* 物理端点5 DD地址      DD address of endpoint 05 */


/* DMA 接收和发送缓冲区地址  DMA receive/transmit buffer address */ 
#define DMA_BUFFER_ADDR_EP02  	DD_BASE_ADDRESS + (DD_SIZE * 32)					/* 物理端点2 DMA缓冲区首址 */
#define DMA_BUFFER_ADDR_EP03  	DMA_BUFFER_ADDR_EP02 + EP02_DMA_BUFFER_LENGTH		/* 物理端点3 DMA缓冲区首址 */
	
#define DMA_BUFFER_ADDR_EP04  	DMA_BUFFER_ADDR_EP03 + EP03_DMA_BUFFER_LENGTH 		/* 物理端点4 DMA缓冲区首址 */
#define DMA_BUFFER_ADDR_EP05  	DMA_BUFFER_ADDR_EP04 + EP04_DMA_BUFFER_LENGTH		/* 物理端点5 DMA缓冲区首址 */


/* DMA 状态宏定义(包括DD_retired位)  DMA status marco define(include DD_retired bit) */
#define DDS_NOT_SERV		0x00					/* 没有服务			0,0000B */
#define DDS_BEING_SERV		0x02					/* 正在服务			0,0010B */
													
#define DDS_UNDER_RUN		0x07					/* 数据欠载(短包)   0,0111B */
#define DDS_OVER_RUN		0x11					/* 数据溢出			1,0001B */				

#define DDS_SYS_ERR			0x12					/* 系统错误		    1,0010B */

#define DDS_NORMAL_COMP		0x05					/* 正常结束	Normal completion  0,0101B */


/*
***********************************************************************
*		用户可使用的API函数    API Function
***********************************************************************
*/

extern void USB_DMAInit(void);

extern INT32U USB_DMASetTransLength(INT8U endp, INT32U len);

extern void USB_DMAStart_IN(INT8U endp);

extern INT8U* USB_DMAGetBuffer(INT8U endp);


/*
***********************************************************************
*		DMA 中断服务程序	 The Interrupt Service of the DMA 
***********************************************************************
*/
extern void USB_DMAService(void);

extern void USB_DMATransferEnd(void);
extern void USB_DMASystemError(void);
extern void USB_DMANewDDRequest(void);


/*
***********************************************************************
*		本文件用到的子程序	 The Subprogram used by this file 
***********************************************************************
*/

extern void USB_InitUdcaTable(void);

extern void USB_InitEndpointDD(INT8U endp);

extern DD_DESCRIPTOR *USB_GetDDPointer(INT8U endp);

#endif

⌨️ 快捷键说明

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