📄 usbci.lst
字号:
ARM COMPILER V2.53, USBCI 28/06/07 09:54:12 PAGE 1
ARM COMPILER V2.53, COMPILATION OF MODULE USBCI
OBJECT MODULE PLACED IN USBCI.OBJ
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe USBCI.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: USBCI.c
8 ** Last modified Date: 2005-8-6
9 ** Last Version: V1.0
10 ** Descriptions: LPC214x USB 接口命令层
11 ** LPC214x USB Interface command layer
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 #include "USBConfig.h"
34 #include "USBCI.h"
35 #include "LPC214x.h"
36 #include "target.h"
37 /********************************************************
38
39 操作USB设备寄存器 operate USB device register
40
41 *********************************************************/
42
43 /********************************************************************************************************
-*******
44 ** 函数名称 : USB_ConfigMaxPaketSize(INT8U endp, INT32U packetsize) Name : USB_ConfigMaxPaketSize(INT8U
-endp, INT32U packetsize)
45 ** 功能描述 : 配置 USB 设备端点 Function : Configurate the endpoint of the USB
46 ** 输 入 : INT8U endp : 物理端点号 Input : INT8U endp: the physical endpoint number
47 INT8U packetsize: 该端点的最大包大小 INT8U packetsize: the max packet size of the endpoint
- INT8U packetsize: the max packet size of the endpoint
48 ** 输 出 : 无 Output : NULL
49 *********************************************************************************************************
-*******/
50 void USB_ConfigMaxPaketSize(INT8U endp, INT32U packetsize)
51 {
52 1 /* or with the existing value of the register */
53 1 USBReEp |= (INT32U)(0x01 << endp); /* 与原来存在的寄存器值做或操作 */
54 1
55 1 /* load endpoint index Reg with physical endpoint no. */
ARM COMPILER V2.53, USBCI 28/06/07 09:54:12 PAGE 2
56 1 USBEpInd = (INT32U)endp; /* 选择端点 */
57 1
58 1 /* load the max packet size Register */
59 1 USBMaxPSize = (INT32U)packetsize; /* 写入端点最大包长度值 */
60 1
61 1 /* check whether the EP_RLSED bit is set */
62 1 while((USBDevIntSt & EP_RLZEDINT) == 0); /* 等待处理完成 */
63 1
64 1 /* clear the EP_RLZED bit */
65 1 USBDevIntClr = EP_RLZEDINT; /* 清除中断标志位 */
66 1 }
67
68
69 /*********************************************************
70
71 协议引擎命令 Protocol Engine Command
72
73 **********************************************************/
74
75 /********************************************************************************************************
-*******
76 ** 函数名称 : USB_GetData() Name : USB_GetData()
77 ** 功能描述 : 从USB命令数据寄存器中读取数据 Function : Read data from USB Command Data Register
78 ** 输 入 : INT32U cmd : 命令 Input : INT32U cmd: command word
79 ** 输 出 : 读到的一个字节 Output : the read byte
80 *********************************************************************************************************
-*******/
81 INT8U USB_GetData(INT32U cmd)
82 {
83 1 /* command */
84 1 USBCmdCode = cmd; /* 写入命令字 */
85 1
86 1 /* wait for CDFULL = 1 */
87 1 while((USBDevIntSt & CDFULL) == 0); /* 等待USBDevIntSt寄存器的CDFULL位置1*/
88 1
89 1 /* clear the CDFULL bit */
90 1 USBDevIntClr = CDFULL; /* 清除CDFULL位 */
91 1
92 1 /* get the received data */
93 1 return USBCmdData; /* 读取数据 */
94 1 }
95
96
97 /********************************************************************************************************
-*******
98 ** 函数名称 : USB_SendCmd() Name : USB_SendCmd()
99 ** 功能描述 : 向USB命令代码寄存器写入命令 Function : write a command to Command Code Register
100 ** 输 入 : INT32U cmd : 命令 Input : INT32U cmd : command
101 INT32U data: 数据 INT32U data: data
102 ** 输 出 : 无 Output : NULL
103 *********************************************************************************************************
-*******/
104 void USB_SendCmd(INT32U cmd, INT32U data)
105 {
106 1 /* command */
107 1 USBCmdCode = cmd; /* 写入命令字 */
108 1
109 1 /* wait for CCEMPTY = 1 */
110 1 while((USBDevIntSt & CCEMPTY) == 0); /* 等待 USBDevIntSt 寄存器的 CCEMPTY 位置1 */
111 1
112 1 /* clear the CCEMPTY bit */
113 1 USBDevIntClr = CCEMPTY; /* 清除 CCEMPTY 位*/
114 1
115 1 if (data != 0) /* 如果还有数据阶段 */
116 1 {
117 2 /* command */
ARM COMPILER V2.53, USBCI 28/06/07 09:54:12 PAGE 3
118 2 USBCmdCode = data; /* 将数据编码写入命令代码寄存器 */
119 2
120 2 /* wait for CCEMPTY = 1 */
121 2 while((USBDevIntSt & CCEMPTY) == 0); /* 等待 USBDevIntSt 寄存器的 CCEMPTY 位置1 */
122 2
123 2 /* clear the CCEMPTY bit */
124 2 USBDevIntClr = CCEMPTY; /* 清除 CCEMPTY 位*/
125 2 }
126 1 }
127 /****************************************************************
128
129 LPC214x USB控制器相关命令 Related Command of LPC214x USB
130
131 *****************************************************************/
132
133 /********************************************************************************************************
-*******
134 ** 函数名称 : USB_ReadTestRegister() Name : USB_ReadTestRegister()
135 ** 功能描述 : 读测试寄存器 Function : Read the Test Register of USB
136 ** 输 入 : 无 Input : NULL
137 ** 输 出 : 测试寄存器的值 Output : the value of the Test Register
138 *********************************************************************************************************
-*******/
139 INT16U USB_ReadTestRegister(void)
140 {
141 1 INT16U temp;
142 1
143 1 USB_SendCmd(USBCMD_RDTEST_REG, 0);
144 1
145 1 temp = USB_GetData(USBDAT_RDTEST_REG); /* read LSB byte */
146 1 temp += (INT16U)USB_GetData(USBDAT_RDTEST_REG) << 8; /* read MSB byte */
147 1
148 1 return temp;
149 1 }
150
151
152 /********************************************************************************************************
-*******
153 ** 函数名称 : USB_SetAddressEnable() Name : USB_SetAddressEnable()
154 ** 功能描述 : 设置 USB 设备地址 Function : set the USB device address
155 ** 输 入 : INT8U bAddress: 主机分配的地址值 Input : INT8U bAddress: the address value
156 INT8U bEnable: 1 - 使能USB设备 INT8U bEnable: 1: enable the USB device
157 0 - 禁止USB设备 0: disable the device
158 ** 输 出 : 无 Output : NULL
159 *********************************************************************************************************
-*******/
160 void USB_SetAddressEnable(INT8U bAddress, INT8U bEnable)
161 {
162 1 if (bEnable)
163 1 bAddress |= 0x80;
164 1
165 1 USB_SendCmd(USBCMD_SET_ADDRESS, ((INT32U)(bAddress << 16)) | USBDAT_SET_ADDRESS);
166 1 }
167
168
169 /********************************************************************************************************
-*******
170 ** 函数名称 : USB_SetEndpointEnable() Name : USB_SetEndpointEnable()
171 ** 功能描述 : 设置 USB 设备 Function : Configure USB Device
172 ** 输 入 : INT8U bEnble: 1 - 器件已配置 Input : INT8U bEnble: 1 - have finished configuring
173 0 - 器件未配置 0 - have not configured
174 ** 输 出 : 无 Output : NULL
175 *********************************************************************************************************
-*******/
176 void USB_SetEndpointEnable(INT8U bEnble)
177 {
ARM COMPILER V2.53, USBCI 28/06/07 09:54:12 PAGE 4
178 1 USB_SendCmd(USBCMD_CONFIG_DEV, ((INT32U)(bEnble << 16)) | USBDAT_CONFIG_DEV);
179 1 }
180
181
182 /********************************************************************************************************
-*******
183 ** 函数名称 : USB_SetMode() Name : USB_SetMode()
184 ** 功能描述 : 设置模式 Function : Set Mode
185 ** 输 入 : INT8U value: 模式值 Input : INT8U value: the mode value
186 ** 输 出 : 无 Output : NULL
187 *********************************************************************************************************
-*******/
188 void USB_SetMode(INT8U value)
189 {
190 1 USB_SendCmd(USBCMD_SET_MODE, ((INT32U)(value << 16)) | USBDAT_SET_MODE);
191 1 }
192
193
194 /********************************************************************************************************
-*******
195 ** 函数名称 : USB_SetDevStatus() Name : USB_SetDevStatus()
196 ** 功能描述 : 设置设备状态 Function : Set Device Status
197 ** 输 入 : INT8U value: 状态值 Input : INT8U value: the Device Status
198 ** 输 出 : 无 Output : NULL
199 *********************************************************************************************************
-*******/
200 void USB_SetDevStatus(INT8U value)
201 {
202 1 USB_SendCmd(USBCMD_SET_DEVSTATUS, ((INT32U)(value << 16)) | USBDAT_SET_DEVSTATUS);
203 1 }
204
205
206 /********************************************************************************************************
-*******
207 ** 函数名称 : USB_GetDevStatus() Name : USB_GetDevStatus()
208 ** 功能描述 : 获取设备状态 Function : Get Device Status
209 ** 输 入 : NULL Input : NULL
210 ** 输 出 : USB 设备状态字节 Output : the USB device status byte
211 *********************************************************************************************************
-*******/
212 INT8U USB_GetDevStatus(void)
213 {
214 1 USB_SendCmd(USBCMD_GET_DEVSTATUS, 0);
215 1
216 1 return USB_GetData(USBDAT_GET_DEVSTATUS);
217 1 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -