📄 main.lst
字号:
C51 COMPILER V7.07 MAIN 03/24/2008 13:20:20 PAGE 1
C51 COMPILER V7.07, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\c51.exe main.c DB OE
stmt level source
1 #include <c8051f320.h> // SFR declarations
2 #include "usb_api.h"
3
4 sbit SDA = P2^2 ;
5 sbit SCL = P2^3 ;
6 sbit LED = P0^7; // LED='1' means ON
7
8
9 void Init_Sysclock (void);
10 void Init_Port (void);
11 void Ext_Interrupt_Init (void);
12
13 //-----------------------------------------------------------------------------
14 // Global VARIABLES
15 //-----------------------------------------------------------------------------
16
17
18 extern void Dab_Read_Register(int reg_addr,int *ptrdata);
19 extern void Dab_Write_Register(int reg_addr,int reg_data);
20
21
22 /*** [BEGIN] USB Descriptor Information [BEGIN] ***/
23 code const UINT USB_VID = 0x10C4;
24 code const UINT USB_PID = 0xEA61;
25 code const BYTE USB_MfrStr[] = {0x1A,0x03,'S',0,'i',0,'l',0,'i',0,'c',0,'o',0,'n',0,' ',0,'L',0,'a',0,'b',
-0,'s',0}; // Manufacturer String
26 code const BYTE USB_ProductStr[] = {0x10,0x03,'U',0,'S',0,'B',0,' ',0,'A',0,'P',0,'I',0}; // Product Desc.
- String
27 code const BYTE USB_SerialStr[] = {0x0A,0x03,'Z',0,'h',0,'o',0,'u',0};
28 code const BYTE USB_MaxPower = 15; // Max current = 30 mA (15 * 2)
29 code const BYTE USB_PwAttributes = 0x80; // Bus-powered, remote wakeup not supported
30 code const UINT USB_bcdDevice = 0x0100; // Device release number 1.00
31 /*** [ END ] USB Descriptor Information [ END ] ***/
32
33
34
35
36 unsigned char access_data_stream;
37 BYTE usb_write_flag;
38 xdata unsigned char command_packet[8];
39 xdata BYTE buffer_storage[512];
40
41
42 extern void DabFM_Init(void);
43
44 void main (void) {
45 1
46 1 int i;
47 1
48 1 PCA0MD &= ~0x40; // WDTE = 0 (Disable watchdog timer)
49 1
50 1
51 1 CLKMUL = 0x80;
52 1 for (i = 0; i < 200; i++); // Wait 5us for initialization
53 1 CLKMUL |= 0xC0;
C51 COMPILER V7.07 MAIN 03/24/2008 13:20:20 PAGE 2
54 1 while ((CLKMUL & 0x20) == 0);
55 1 CLKSEL = 0x02;
56 1 OSCICN = 0x83;
57 1
58 1
59 1 Init_Port();
60 1
61 1 USB_Clock_Start(); // Init USB clock *before* calling USB_Init
62 1 USB_Init(USB_VID,USB_PID,USB_MfrStr,USB_ProductStr,USB_SerialStr,USB_MaxPower,USB_PwAttributes,USB_bcdD
-evice);
63 1
64 1 CLKSEL|=0x02;
65 1 USB_Int_Enable();
66 1 EA=0;
67 1 Ext_Interrupt_Init();
68 1 EA=1;
69 1
70 1 //DabFM_Init();
71 1
72 1
73 1 for(;;) { // spin forever
74 2
75 2
76 2 if(access_data_stream==1)
77 2 {
78 3 if(usb_write_flag == 1) // half of fifo
79 3 {
80 4
81 4 usb_write_flag=0;
82 4 Block_Write(buffer_storage, 512);
83 4
84 4 }
85 3
86 3 }
87 2
88 2
89 2
90 2 }//end for(;;);
91 1
92 1
93 1 }
94
95
96
97 //-----------------------------------------------------------------------------
98 // Ext_Interrupt_Init
99 //-----------------------------------------------------------------------------
100 //
101 // Return Value : None
102 // Parameters : None
103 //
104 // This function configures and enables /INT0 (External Interrupts)
105 // as negative edge-triggered.
106 //
107 //-----------------------------------------------------------------------------
108 void Ext_Interrupt_Init(void)
109 {
110 1
111 1 TCON=0x00;//INT 0 level triggered
112 1 IT01CF = 0x06;//P0.6作为外部中断INT0 active low;
113 1
114 1 EX0 = 1; // Enable /INT0 interrupts
C51 COMPILER V7.07 MAIN 03/24/2008 13:20:20 PAGE 3
115 1
116 1 }
117
118
119
120 //-----------------------------------------------------------------------------
121 // Init_Port
122 //
123 // Configure the Crossbar and GPIO ports.
124 //
125 //
126 //-----------------------------------------------------------------------------
127
128 void Init_Port (void)
129 {
130 1 P0MDOUT = 0xbf;//
131 1 //P2MDOUT = 0x0C;
132 1 //P0MDOUT = 0xff;//
133 1 //////////////////////
134 1 P1MDIN= 0xff; // pins on P1 are digital
135 1 //十个并口线全部push-pull
136 1 P1MDOUT=0x00;
137 1 P1=0xff;
138 1 P2MDOUT=0x03;
139 1 //////////////////////////
140 1 P0SKIP = 0xcc;//
141 1 P1SKIP = 0xFF;
142 1 P2SKIP = 0x0F;//P2.0---P2.3 skip
143 1 ///important
144 1 XBR0 = 0x06;//p0.6跳过。分配为中断脚
145 1 XBR1 = 0x40;
146 1 //-----------------------------------------------------------------------------
147 1
148 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 210 ----
CONSTANT SIZE = 60 ----
XDATA SIZE = 520 ----
PDATA SIZE = ---- ----
DATA SIZE = 2 ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -