📄 usbdma.lst
字号:
ARM COMPILER V2.53, USBdma 28/06/07 09:54:12 PAGE 1
ARM COMPILER V2.53, COMPILATION OF MODULE USBdma
OBJECT MODULE PLACED IN USBdma.OBJ
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe USBdma.c THUMB OPTIMIZE(0,SPEED) BROWSE DEBUG TABS(4)
stmt level source
1 /****************************************Copyright (c)**************************************************
2 ** Guangzou ZLG-MCU Development Co.,LTD.
3 ** graduate school
4 ** http://www.zlgmcu.com
5 **
6 **--------------File Info-------------------------------------------------------------------------------
7 ** File name: USBdma.c
8 ** Last modified Date: 2005-8-6
9 ** Last Version: V1.0
10 ** Descriptions: LPC2148 USB DMA 控制器相关, 本文件只使能了物理端点 2 ~ 5 的 DMA 功能
11 ** LPC2148 USB DMA controller, the file only enable the DMA function of physical endpoint 2 ~ 5
12 **------------------------------------------------------------------------------------------------------
13 ** Created by: 郑明远 MingYuan Zheng
14 ** Created date: 2005-8-6
15 ** Version: V1.0
16 ** Descriptions: 初始版本 The original version
17 **
18 **------------------------------------------------------------------------------------------------------
19 ** Modified by:
20 ** Modified date:
21 ** Version:
22 ** Descriptions:
23 **
24 **------------------------------------------------------------------------------------------------------
25 ** Modified by:
26 ** Modified date:
27 ** Version:
28 ** Descriptions:
29 **
30 ********************************************************************************************************/
31
32 //#include "config.h"
33
34 #include "USBConfig.h" #include "USBCI.h"
35 #include "descriptor.h"
36
37 #include "USBDriver.h"
38 #include "USBdma.h"
39 #include "string.h"
40 #include "target.h"
41 #if DMA_ENGINE_EN
/*
***********************************************************************
* 用户可使用的API函数 API Function
***********************************************************************
*/
/********************************************************************************************************
-****
** 函数名称: USB_DMAInit() Name : USB_DMAInit()
** 功能描述: LPC214x DMA引擎初始化 Function : Initialize DMA engine of LPC214x USB
*********************************************************************************************************
-***/
void USB_DMAInit(void)
{
USB_InitUdcaTable(); /* 初始化UDCA表 Initialize the UDCA table */
USB_InitEndpointDD(2); /* 初始化各端点的DD Initialize the DD of each endpoint */
ARM COMPILER V2.53, USBdma 28/06/07 09:54:12 PAGE 2
USB_InitEndpointDD(3);
USB_InitEndpointDD(4);
USB_InitEndpointDD(5);
/* Enable System error, New DD Request and End of Transfer Interrupt of DMA */
USBDMAIntEn = USBDMA_EOT_INT | USBDMA_NDD_INT | USBDMA_ERR_INT; /* 使能DMA的系统错误中断, 新DD请求中断
-, 传输结束中断 */
USBEpDMAEn = (0x01 << 2) | (0x01 << 3) | (0x01 << 4) | (0x01 << 5);
/* 使能端点DMA功能 Enable Endpoint DMA */
}
/********************************************************************************************************
-****
** 函数名称: USB_DMASetTransLength() Name : USB_DMASetTransLength()
** 功能描述: 设置 DMA 传输长度 Function : Config DMA transfer length
** 输 入: INT8U endp: 物理端点号 Input : INT8U endp: physical endpoint
INT16U len: 传输字节长度 INT16U len: transfer byte length
** 输 出: 实际 DMA 传输长度 Output : the actual transfer length
*********************************************************************************************************
-***/
INT32U USB_DMASetTransLength(INT8U endp, INT32U len)
{
DD_DESCRIPTOR *pDD = USB_GetDDPointer(endp); /* 取得 DD 指针 Get the DD pointer of the endpoint */
USB_InitEndpointDD(endp); /* 初始化DD Initialize the DD */
if (len > (pDD->control >> 16)) /* 长度超过本端点DMA缓冲区 len is beyond the dma buffer of the endp
-oint*/
len = pDD->control >> 16;
pDD->control &= 0x0000FFFF;
pDD->control |= (len << 16); /* 将len写入DD Write the len into DD */
return len;
}
/********************************************************************************************************
-****
** 函数名称: USB_DMAStart_IN() Name : USB_DMAStart_IN()
** 功能描述: 启动 IN 端点的 DMA 传输 Function : start the DMA transfer of IN endpoint
** 输 入: INT8U endp: 物理端点号 Input : INT8U endp: physical endpoint
** 输 出: 无 Output : NULL
*********************************************************************************************************
-***/
void USB_DMAStart_IN(INT8U endp)
{
USBEPIntEn &= ~(0x01 << endp); /* 清0 从机端点中断使能寄存器来启动 IN 传输 */
} /* clear slave endpoint interrupt enable register to start IN transfer */
/********************************************************************************************************
-****
** 函数名称: USB_DMAGetBuffer() Name : USB_DMAGetBuffer()
** 功能描述: 得到DMA缓冲区首址 Function : Initialize DMA engine of LPC214x USB
*********************************************************************************************************
-***/
INT8U* USB_DMAGetBuffer(INT8U endp)
{
const INT32U DmaTbl[4] = {DMA_BUFFER_ADDR_EP02, DMA_BUFFER_ADDR_EP03,
DMA_BUFFER_ADDR_EP04, DMA_BUFFER_ADDR_EP05};
return (INT8U *)((INT32U *)DmaTbl[endp - 2]); /* 返回缓冲区字节指针 return the byte buffer pointer */
}
ARM COMPILER V2.53, USBdma 28/06/07 09:54:12 PAGE 3
/*
***********************************************************************
* DMA 中断服务程序 The Interrupt Service of the DMA
***********************************************************************
*/
/********************************************************************************************************
-****
** 函数名称: Usb_DMAService() Name : Usb_DMAService()
** 功能描述: DMA 中断服务程序 Function : USB DMA Interrupt Service Program
*********************************************************************************************************
-***/
void USB_DMAService(void)
{
INT32U dma_st;
dma_st = USBDMAIntSt; /* 读DMA中断状态寄存器 Read USBDMAIntSt */
if (dma_st & USBDMA_EOT_INT)
USB_DMATransferEnd(); /* 传输结束中断 End of Transfer Interrupt */
if (dma_st & USBDMA_NDD_INT)
USB_DMANewDDRequest(); /* 新DD请求中断 New DD Request Interrupt */
if (dma_st & USBDMA_ERR_INT)
USB_DMASystemError(); /* 系统错误中断 System Error Interrupt */
}
/********************************************************************************************************
-****
** 函数名称: USB_DMATransferEnd() Name : USB_DMATransferEnd()
** 功能描述: DMA 传输结束中断处理 Function : Process End of DMA Transfer Interrupt
*********************************************************************************************************
-***/
void USB_DMATransferEnd(void)
{
INT32U ep_st, endp;
DD_DESCRIPTOR *pDD;
ep_st = USBEoTIntSt; /* 读传输结束中断寄存器 read End of Transfer Interrupt register */
for (endp = 2; endp <= 5; endp++)
{
if(ep_st & (0x01 << endp))
{ /* endp 端点中断传输结束 endp endpoint Interrupt transfer end */
pDD = USB_GetDDPointer(endp);
if ((pDD->status & 0x1F) == DDS_OVER_RUN) /* DMA错误 DMA error */
USBEpDMAEn = (0x01 << endp); /* 重新使能该端点的DMA功能 re-enable Endpoint DMA */
if ((pDD->status & 0x1F) == DDS_NORMAL_COMP) /* DMA正常结束 DMA normal complete */
{
if (endp == 2)
bEPPflags.bits.ep1_rxdma = 1; /* 标志逻辑端点1 DMA接收成功 Flag logic ep0 DMA receiving sucessful
-ly */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -