?? pdiusbd12.lst
字號(hào):
C51 COMPILER V8.05a PDIUSBD12 04/21/2009 19:44:21 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE PDIUSBD12
OBJECT MODULE PLACED IN PDIUSBD12.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE PDIUSBD12.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /******************************************************************
2 本程序只供學(xué)習(xí)使用,未經(jīng)作者許可,不得用于其它任何用途
3
4 歡迎訪問(wèn)我的USB專(zhuān)區(qū):http://group.ednchina.com/93/
5 歡迎訪問(wèn)我的blog: http://www.ednchina.com/blog/computer00
6 http://computer00.21ic.org
7
8 感謝PCB贊助商——電子園: http://bbs.cepark.com/
9
10 PDIUSBD12.C file
11
12 作者:電腦圈圈
13 建立日期: 2008.06.27
14 修改日期: 2008.07.10
15 版本:V1.1
16 版權(quán)所有,盜版必究。
17 Copyright(C) 電腦圈圈 2008-2018
18 All rights reserved
19 *******************************************************************/
20
21 #include <AT89x52.H>
22 #include "MyType.h"
23 #include "PDIUSBD12.H"
24 #include "config.h"
25 #include "UART.h"
26
27 /********************************************************************
28 函數(shù)功能:D12寫(xiě)命令。
29 入口參數(shù):Command:一字節(jié)命令。
30 返 回:無(wú)。
31 備 注:無(wú)。
32 ********************************************************************/
33 void D12WriteCommand(uint8 Command)
34 {
35 1 D12SetCommandAddr(); //設(shè)置為命令地址
36 1 D12ClrWr(); //WR置低
37 1 D12SetPortOut(); //將數(shù)據(jù)口設(shè)置為輸出狀態(tài)(注意這里為空宏,移植時(shí)可能有用)
38 1 D12SetData(Command); //輸出命令到數(shù)據(jù)口上
39 1 D12SetWr(); //WR置高
40 1 D12SetPortIn(); //將數(shù)據(jù)口設(shè)置為輸入狀態(tài),以備后面輸入使用
41 1 }
42 ////////////////////////End of function//////////////////////////////
43
44 /********************************************************************
45 函數(shù)功能:讀一字節(jié)D12數(shù)據(jù)。
46 入口參數(shù):無(wú)。
47 返 回:讀回的一字節(jié)。
48 備 注:無(wú)。
49 ********************************************************************/
50 uint8 D12ReadByte(void)
51 {
52 1 uint8 temp;
53 1 D12SetDataAddr(); //設(shè)置為數(shù)據(jù)地址
54 1 D12ClrRd(); //RD置低
55 1 temp=D12GetData(); //讀回?cái)?shù)據(jù)
C51 COMPILER V8.05a PDIUSBD12 04/21/2009 19:44:21 PAGE 2
56 1 D12SetRd(); //RD置高
57 1 return temp; //返回讀到數(shù)據(jù)
58 1 }
59 ////////////////////////End of function//////////////////////////////
60
61 /********************************************************************
62 函數(shù)功能:讀D12的ID。
63 入口參數(shù):無(wú)。
64 返 回:D12的ID。
65 備 注:無(wú)。
66 ********************************************************************/
67 uint16 D12ReadID(void)
68 {
69 1 uint16 id;
70 1 D12WriteCommand(Read_ID); //寫(xiě)讀ID命令
71 1 id=D12ReadByte(); //讀回ID號(hào)低字節(jié)
72 1 id|=((uint16)D12ReadByte())<<8; //讀回ID號(hào)高字節(jié)
73 1 return id;
74 1 }
75 ////////////////////////End of function//////////////////////////////
76
77 /********************************************************************
78 函數(shù)功能:寫(xiě)一字節(jié)D12數(shù)據(jù)。
79 入口參數(shù):Value:要寫(xiě)的一字節(jié)數(shù)據(jù)。
80 返 回:無(wú)。
81 備 注:無(wú)。
82 ********************************************************************/
83 void D12WriteByte(uint8 Value)
84 {
85 1 D12SetDataAddr(); //設(shè)置為數(shù)據(jù)地址
86 1 D12ClrWr(); //WR置低
87 1 D12SetPortOut(); //將數(shù)據(jù)口設(shè)置為輸出狀態(tài)(注意這里為空宏,移植時(shí)可能有用)
88 1 D12SetData(Value); //寫(xiě)出數(shù)據(jù)
89 1 D12SetWr(); //WR置高
90 1 D12SetPortIn(); //將數(shù)據(jù)口設(shè)置為輸入狀態(tài),以備后面輸入使用
91 1 }
92 ////////////////////////End of function//////////////////////////////
93
94 /********************************************************************
95 函數(shù)功能:讀取D12最后傳輸狀態(tài)寄存器的函數(shù)。
96 入口參數(shù):Endp:端點(diǎn)號(hào)。
97 返 回:端點(diǎn)的最后傳輸狀態(tài)。
98 備 注:該操作將清除該端點(diǎn)的中斷標(biāo)志位。
99 ********************************************************************/
100 uint8 D12ReadEndpointLastStatus(uint8 Endp)
101 {
102 1 D12WriteCommand(0x40+Endp); //讀取端點(diǎn)最后狀態(tài)的命令
103 1 return D12ReadByte();
104 1 }
105 ////////////////////////End of function//////////////////////////////
106
107 /********************************************************************
108 函數(shù)功能:選擇端點(diǎn)的函數(shù),選擇一個(gè)端點(diǎn)后才能對(duì)它進(jìn)行數(shù)據(jù)操作。
109 入口參數(shù):Endp:端點(diǎn)號(hào)。
110 返 回:無(wú)。
111 備 注:無(wú)。
112 ********************************************************************/
113 void D12SelectEndpoint(uint8 Endp)
114 {
115 1 D12WriteCommand(0x00+Endp); //選擇端點(diǎn)的命令
116 1 }
117 ////////////////////////End of function//////////////////////////////
C51 COMPILER V8.05a PDIUSBD12 04/21/2009 19:44:21 PAGE 3
118
119 /********************************************************************
120 函數(shù)功能:清除接收端點(diǎn)緩沖區(qū)的函數(shù)。
121 入口參數(shù):無(wú)。
122 返 回:無(wú)。
123 備 注:只有使用該函數(shù)清除端點(diǎn)緩沖后,該接收端點(diǎn)才能接收新的數(shù)據(jù)包。
124 ********************************************************************/
125 void D12ClearBuffer(void)
126 {
127 1 D12WriteCommand(D12_CLEAR_BUFFER);
128 1 }
129 ////////////////////////End of function//////////////////////////////
130
131 /********************************************************************
132 函數(shù)功能:應(yīng)答建立包的函數(shù)。
133 入口參數(shù):無(wú)。
134 返 回:無(wú)。
135 備 注:無(wú)。
136 ********************************************************************/
137 void D12AcknowledgeSetup(void)
138 {
139 1 D12SelectEndpoint(1); //選擇端點(diǎn)0輸入
140 1 D12WriteCommand(D12_ACKNOWLEDGE_SETUP); //發(fā)送應(yīng)答設(shè)置到端點(diǎn)0輸入
141 1 D12SelectEndpoint(0); //選擇端點(diǎn)0輸出
142 1 D12WriteCommand(D12_ACKNOWLEDGE_SETUP); //發(fā)送應(yīng)答設(shè)置到端點(diǎn)0輸出
143 1 }
144 ////////////////////////End of function//////////////////////////////
145
146 /********************************************************************
147 函數(shù)功能:讀取端點(diǎn)緩沖區(qū)函數(shù)。
148 入口參數(shù):Endp:端點(diǎn)號(hào);Len:需要讀取的長(zhǎng)度;Buf:保存數(shù)據(jù)的緩沖區(qū)。
149 返 回:實(shí)際讀到的數(shù)據(jù)長(zhǎng)度。
150 備 注:無(wú)。
151 ********************************************************************/
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -