📄 usbdriver.lst
字号:
ARM COMPILER V2.53, USBDriver 28/06/07 09:54:12 PAGE 1
ARM COMPILER V2.53, COMPILATION OF MODULE USBDriver
OBJECT MODULE PLACED IN USBDriver.OBJ
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe USBDriver.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: USBDriver.c
8 ** Last modified Date: 2005-8-6
9 ** Last Version: V1.0
10 ** Descriptions: LPC214x USB 应用层
11 ** LPC214x USB Application
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
33
34 /****************************************Copyright (c)**************************************************
35 ** Guangzhou ZLG-MCU Development Co.,LTD.
36 ** graduate school
37 ** http://www.zlgmcu.com
38 **
39 **--------------File Info-------------------------------------------------------------------------------
40 ** File name: USBISR.c
41 ** Created by: MingYuan Zheng
42 ** Created date: 2005-1-6
43 ** Last modified Date:
44 ** Last Version: V1.0
45 ** Descriptions:
46 **
47 *******************************************************************************************************/
48
49 //#include "config.h"
50
51 #include "USBConfig.h"
52 #include "USBHAL.h"
53 #include "USBCI.h"
54
55 #include "Chap_9.h"
56 #include "Descriptor.h"
57 #include "USBDriver.h"
58 #include "LPC214x.h"
59 #include "target.h"
ARM COMPILER V2.53, USBDriver 28/06/07 09:54:12 PAGE 2
60
61 /* 定义全局变量 define global variable */
62 INT8U GenEpBuf[EP1_PACKET_SIZE]; /* 逻辑端点 1 接收缓冲区 receive buffer of logic ep01 */
63 INT8U EpBuf[EP2_PACKET_SIZE]; /* 逻辑端点 2 接收缓冲区 receive buffer of logic ep02 */
64
65 /* define USB event flag variable */
66 EPPFLAGS bEPPflags; /* 定义 USB 事件标志变量 */
67
68
69 /********************************************************************************************************
-*******
70 ** 函数名称 : USB_Initialize() Name : USB_Initialize()
71 ** 功能描述 : 初始化USB设备控制器 Function : Initialize the USB device controller
72 ** 输 入 : 无 Input : NULL
73 ** 输 出 : 0: 初始化成功 1: 初始化失败 Output : 0: Initialize sucessfully 1: Initialize fail
74 *********************************************************************************************************
-*******/
75 INT8U USB_Initialize(void)
76 {
77 1 USB_InitHareware(); /* 初始化硬件 Initialize hardware */
78 1
79 1 bEPPflags.value = 0; /* 置USB事件标志为0 set USB event flags to zero */
80 1
81 1 if (USB_ReadTestRegister() != 0xA50F) /* 读测试寄存器 read test register */
82 1 return 1; /* 初始化失败 initialize fail */
83 1
84 1 Init_USBInterrupt(); //配置USB中断向量
85 1
86 1 USB_ConfigEndpoint(); /* 配置端点 configure the endpoint */
87 1 USB_USBDevIntConfig(); /* 配置中断 configure the USB interrupt */
88 1
89 1
90 1
91 1 #if DMA_ENGINE_EN
USB_DMAInit(); /* 初始化USB DMA initialize the USB DMA */
USB_SetMode(0x28);
#else
95 1 USB_SetMode(0x00); /* 成功传输才产生中断generate interrupt only transmit sucessfully */
96 1 #endif
97 1
98 1
99 1 #if 1 /* Partial Manual Reset */
100 1 //USB_Reset();
101 1 USBEpIntClr = 0xFFFFFFFF;
102 1 USBEpIntEn = 0xFFFFFFFF;
103 1 USBDevIntClr = 0xFFFFFFFF;
104 1 USBDevIntEn = DEV_STAT | EP_SLOW; // Enable Device Status Interrupt & EP_SLOW
105 1 reconnect_USB(); /* 重新连接USB reconnect the USB */
106 1 USB_SetAddressEnable(0,1);
107 1 #endif
108 1 //个人设计中并未使用softconnect功能引脚,这里需要考虑如何修改
109 1
110 1 return 0; /* 初始化USB成功 Initialize USB sucessfully */
111 1 }
112
113
114 /********************************************************************************************************
-*******
115 ** 函数名称 : USB_ConfigEndpoint() Name : USB_ConfigEndpoint()
116 ** 功能描述 : 配置所有端点的最大包大小 Function : config the maxpacket size of all endpoint
117 ** 输 入 : 无 Input : NULL
118 ** 输 出 : 无 Output : NULL
119 *********************************************************************************************************
-*******/
120 void USB_ConfigEndpoint(void)
121 {
ARM COMPILER V2.53, USBDriver 28/06/07 09:54:12 PAGE 3
122 1 USB_ConfigMaxPaketSize(0,EP0_PACKET_SIZE);
123 1 USB_ConfigMaxPaketSize(1,EP0_PACKET_SIZE);
124 1
125 1 USB_ConfigMaxPaketSize(2,EP1_PACKET_SIZE);
126 1 USB_ConfigMaxPaketSize(3,EP1_PACKET_SIZE);
127 1
128 1 USB_ConfigMaxPaketSize(4,EP2_PACKET_SIZE);
129 1 USB_ConfigMaxPaketSize(5,EP2_PACKET_SIZE);
130 1
131 1
132 1 }
133
134
135 /********************************************************************************************************
-*******
136 ** 函数名称 : usbserve() Name : usbserve()
137 ** 功能描述 : USB事件处理 Function : USB Events service
138 ** 输 入 : 无 Input : NULL
139 ** 输 出 : 无 Output : NULL
140 *********************************************************************************************************
-*******/
141 void usbserve(void)
142 {
143 1 if (bEPPflags.bits.setup_packet)
144 1 { /* 收到 SETUP 包 receive SETUP packet*/
145 2 DISABLE();
146 2 bEPPflags.bits.setup_packet = 0;
147 2 control_handler(); /* 控制传输处理 process control transmission */
148 2 ENABLE();
149 2 } // if SETUP packet
150 1
151 1 if (bEPPflags.bits.bus_reset)
152 1 { /* USB总线复位处理 process USB bus reset */
153 2 DISABLE();
154 2 bEPPflags.bits.bus_reset = 0;
155 2 ENABLE();
156 2
157 2 } // if USB bus reset
158 1
159 1 if (bEPPflags.bits.suspend)
160 1 { /* USB总线挂起改变处理 process USB bus suspend change */
161 2 DISABLE();
162 2 bEPPflags.bits.suspend= 0;
163 2 ENABLE();
164 2 USB_SuspendChange();
165 2 } // if suspend change
166 1
167 1 if (bEPPflags.bits.con_change)
168 1 { /* USB总线连接改变处理 process USB bus connect change */
169 2 DISABLE();
170 2 bEPPflags.bits.con_change = 0;
171 2 ENABLE();
172 2 USB_ConnectChange();
173 2 } // if usb bus connect change
174 1
175 1 }
176
177 /********************************************************************************************************
-*******
178 ** 函数名称 : Usb_Exception() Name : Usb_Exception()
179 ** 功能描述 : USB 中断服务程序 Function : USB Interrupt Service Program
180 ** 输 入 : 无 Input : NULL
181 ** 输 出 : 无 Output : NULL
182 *********************************************************************************************************
-*******/
183 void Usb_Exception(void) __irq
ARM COMPILER V2.53, USBDriver 28/06/07 09:54:12 PAGE 4
184 {
185 1 INT32U usb_ints,dev_ints,devstatus;
186 1
187 1 bEPPflags.bits.in_isr = 1; /* 标识程序进入中断 flag the program enter interrupt */
188 1
189 1 /****** USB status interrupt ******/
190 1 dev_ints = USBDevIntSt;
191 1 if (dev_ints & DEVINT_STATUS_DEVSTAT)
192 1 { /* USB 总线复位,或挂起,或连接中断 */
193 2 devstatus = USB_GetDevStatus();
194 2 if ((devstatus & 0x10) != 0)
195 2 {
196 3 USB_BusReset();
197 3 bEPPflags.bits.bus_reset = 1; /* 标识总线复位 flag USB bus reset */
198 3 }
199 2
200 2 if ((devstatus & 0x08) != 0)
201 2 bEPPflags.bits.suspend = 1; /* 标识总线挂起改变 flag the bus suspend change */
202 2
203 2 if ((devstatus & 0x02) != 0)
204 2 bEPPflags.bits.con_change = 1; /* 标识总线连接改变 flag the bus connect change */
205 2
206 2 USBDevIntClr = DevStatusInterrupt;
207 2 goto USB_ISR_EXIT;
208 2 }
209 1
210 1 /****** data transmission interrupt ******/
211 1 usb_ints = USBIntSt & 0x7;
212 1 if (usb_ints != 0)
213 1 {
214 2 if (usb_ints & USBINT_STATUS_HP)
215 2 Usb_HPService(); /* 高优先级中断处理 process High priority Interrupt */
216 2
217 2 if (usb_ints & USBINT_STATUS_LP)
218 2 Usb_LPService(); /* 低优先级中断处理 process Slow priority Interrupt */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -