?? d12ci.lst
字號:
C51 COMPILER V7.50 D12CI 03/24/2008 11:06:13 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE D12CI
OBJECT MODULE PLACED IN D12CI.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE D12CI.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include "D12HAL.h"
2 #include "d12ci.h"
3 #include "mytype.h"
4 #include "uart0.h"
5
6 /************************************************************
7 ** 函數名稱: uint16 readchipid(void)
8 ** 功能描述: 讀取芯片ID
9 ** 輸 入: 無
10 ** 輸 出: 芯片的ID號
11 ************************************************************/
12 uint16 readchipid(void)
13 {
14 1 uint8 idata i;
15 1 uint16 idata chipid;
16 1
17 1 WriteUsbCommand(0xfd); //發送讀PDIUSBD12芯片ID號命令
18 1 i = ReadUsbData(); //讀取ID號低字節
19 1 chipid = ReadUsbData(); //讀取ID號高位字節
20 1 chipid = (chipid << 8) + i; //組成16位的PDIUSBD12芯片ID號
21 1 #ifdef debug
PutString0("Read D12's ChipID. ID is: 0x",200);
PutUint320((uint32)chipid,16);
if(0 == chipid)
PutString0("0000. Error!",12);
NextLine0();
#endif
28 1 return chipid;
29 1 }
30
31 /*****************************************
32 與CPU 無關, 與 USB相關的函數
33 *****************************************/
34
35
36 /************************************************************
37 ** 函數名稱: void D12_SetAddressEnable(uint8 bAddress,uint8 bEnable)
38 ** 功能描述: 設置地址/使能
39 ** 輸 入: uint8 bAddress: 地址
40 uint8 bEnable : 0 --- 禁止
41 1 --- 使能
42 ** 輸 出: 無
43 ************************************************************/
44 void D12_SetAddressEnable(uint8 idata bAddress, uint8 idata bEnable)
45 {
46 1 WriteUsbCommand(0xD0); //輸出設置地址/使能指令
47 1 if(bEnable)
48 1 {
49 2 bAddress |= 0x80; //bit7置1,使能
50 2 #ifdef debug
PutString0("Set Address. Address : ",200);
if(bAddress != 0x80)
PutUint320((uint32)(bAddress & 0x7f),10);
else
PutChar0('0');
C51 COMPILER V7.50 D12CI 03/24/2008 11:06:13 PAGE 2
NextLine0();
#endif
58 2 }
59 1 WriteUsbData(bAddress); //輸出設置值
60 1 }
61
62
63 /************************************************************
64 ** 函數名稱: void D12_SetEndpointEnable(uint8 bEnable)
65 ** 功能描述: 設置端點使能
66 ** 輸 入: uint8 bEnable : 0 --- 禁止
67 1 --- 允許
68 ** 輸 出: 無
69 ************************************************************/
70 void D12_SetEndpointEnable(uint8 idata bEnable)
71 {
72 1 WriteUsbCommand(0xD8); //輸出設置端點使能指令
73 1 if(bEnable)
74 1 {
75 2 WriteUsbData(0x01); //設置端點允許
76 2 #ifdef debug
PutString0("Set Endpoint enable.\r\n",200);
#endif
79 2 }
80 1 else
81 1 {
82 2 WriteUsbData(0x00); //設置端點禁止
83 2 #ifdef debug
PutString0("Set Endpoint disable.\r\n",200);
#endif
86 2 }
87 1 }
88
89 /************************************************************
90 ** 函數名稱: void D12_SetMode(uint8 bConfig,uint8 bClkDiv)
91 ** 功能描述: 模式設置
92 ** 輸 入: uint8 bConfig: 配置字節信息
93 uint8 bClkDiv: 分頻系數
94 ** 輸 出: 無
95 ************************************************************/
96 void D12_SetMode(uint8 idata bConfig,uint8 idata bClkDiv)
97 {
98 1 WriteUsbCommand(0xF3); //輸出設置模式指令
99 1 WriteUsbData(bConfig); //輸出配置字節信息
100 1 WriteUsbData(bClkDiv); //輸出時鐘分頻因數字節
101 1 }
102
103 /************************************************************
104 ** 函數名稱: void D12_SetDMA(uint8 bMode)
105 ** 功能描述: 設置DMA工作方式設置
106 ** 輸 入: uint8 bMode: 設置值
107 ** 輸 出: 無
108 ************************************************************/
109 void D12_SetDMA(uint8 idata bMode)
110 {
111 1 WriteUsbCommand(0xFB); //設置DMA工作方命令
112 1 WriteUsbData(bMode); //輸出設置值
113 1 }
114
115 /************************************************************
116 ** 函數名稱: uint16 D12_ReadInterruptRegister(void)
117 ** 功能描述: 讀取中斷寄存器值
C51 COMPILER V7.50 D12CI 03/24/2008 11:06:13 PAGE 3
118 ** 輸 入: 無
119 ** 輸 出: 中斷寄存器值
120 ************************************************************/
121 uint16 D12_ReadInterruptRegister(void)
122 {
123 1 uint8 idata b1;
124 1 uint16 idata j;
125 1
126 1 WriteUsbCommand(0xF4); //讀取中斷寄存器命令
127 1 b1 = ReadUsbData(); //讀取低8位字節
128 1 j = ReadUsbData(); //讀取高8位字節
129 1
130 1 j = j << 8;
131 1 j += b1; //組合為16位
132 1 #ifdef debug
PutString0("Interrupt Register : 0x",200);
PutUint320((uint32)j,16); //以16進制顯示中斷寄存器
NextLine0();
#endif
137 1 return j;
138 1 }
139
140 /************************************************************
141 ** 函數名稱: uint8 D12_SelectEndpoint(uint8 bEndp)
142 ** 功能描述: 端點選擇,將內部指針初始化到選擇的緩沖區起始位置
143 ** 輸 入: uint8 bEndp: 端點索引號,取值0 ~ 5
144 ** 輸 出: 讀出的字節
145 ************************************************************/
146 uint8 D12_SelectEndpoint(uint8 idata bEndp)
147 {
148 1 uint8 idata c;
149 1
150 1 WriteUsbCommand(bEndp); //端點選擇
151 1 c = ReadUsbData(); //讀出一個字節
152 1
153 1 return c;
154 1 }
155
156 /************************************************************
157 ** 函數名稱: uint8 D12_ReadEndpointStatus(uint8 bEndp)
158 ** 功能描述: 讀取端點狀態
159 ** 輸 入: uint8 bEndp: 端點索引號,取值0 ~ 5
160 ** 輸 出: 端點狀態
161 ************************************************************/
162 uint8 D12_ReadEndpointStatus(uint8 idata bEndp)
163 {
164 1 uint8 c;
165 1
166 1 WriteUsbCommand(0x80 + bEndp); //讀取端點狀態命令
167 1 c = ReadUsbData(); //讀取端點狀態
168 1 return c;
169 1 }
170
171 /************************************************************
172 ** 函數名稱: uint8 D12_ReadLastTransactionStatus(uint8 bEndp)
173 ** 功能描述: 讀取最后處理狀態寄存器
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -