📄 f32x_usb_main.lst
字号:
C51 COMPILER V7.06 F32X_USB_MAIN 07/16/2008 15:35:21 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE F32X_USB_MAIN
OBJECT MODULE PLACED IN F32x_USB_Main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\c51.exe F32x_USB_Main.c DB OE
stmt level source
1 //-----------------------------------------------------------------------------
2 // F32x_USB_Main.c
3 //-----------------------------------------------------------------------------
4 // Copyright 2005 Silicon Laboratories, Inc.
5 // http://www.silabs.com
6 //
7 // Program Description:
8 //
9 // Source file for USB firmware. Includes main routine and
10 // all hardware initialization routines.
11 //
12 // This firmware is intended to work with the Silabs USB Bulk File Transfer example,
13 // implementing two Bulk pipes with 64-byte Maximum transfers. The endpoints
14 // used are as follows:
15 //
16 // Endpoint1 IN - BULK IN
17 // Endpoint2 OUT - BULK OUT
18 //
19 //
20 // How To Test: See Readme.txt
21 //
22 //
23 // FID: 32X000014
24 // Target: C8051F32x
25 // Tool chain: Keil C51 7.50 / Keil EVAL C51
26 // Silicon Laboratories IDE version 2.6
27 // Command Line: See Readme.txt
28 // Project Name: F32x_USB_Bulk
29 //
30 //
31 // Release 1.3
32 // -All changes by GP
33 // -21 NOV 2005
34 // -Changed revision number to match project revision
35 // No content changes to this file
36 // -Modified file to fit new formatting guidelines
37 // -Changed file name from main.c
38 //
39 //
40 // Release 1.2
41 // -Initial Revision (JS/CS/JM)
42 // -XX OCT 2003
43 //
44
45 //-----------------------------------------------------------------------------
46 // Includes
47 //-----------------------------------------------------------------------------
48
49 #include <c8051f320.h> // SFR declarations
50 #include "F32x_USB_Registers.h"
51 #include "F32x_USB_Structs.h"
52 #include "F32x_USB_Main.h"
53 #include "F32x_USB_Descriptors.h"
54
55 //-----------------------------------------------------------------------------
C51 COMPILER V7.06 F32X_USB_MAIN 07/16/2008 15:35:21 PAGE 2
56 // Global Constants
57 //-----------------------------------------------------------------------------
58
59 sbit Led1 = P2^2; // LED='1' means ON
60 sbit Led2 = P2^3; // blink to indicate data transmission
61
62
63 //-----------------------------------------------------------------------------
64 // Function Prototypes
65 //-----------------------------------------------------------------------------
66
67 void USB0_Init (void);
68 void USB0_Enable (void);
69 void PORT_Init (void);
70 void SYSCLK_Init (void);
71 void VDD_MON_Init(void); // Turn on VDD Monitor
72
73 //-----------------------------------------------------------------------------
74 // Globals Variables
75 //-----------------------------------------------------------------------------
76
77 DEVICE_STATUS gDeviceStatus;
78 EP_STATUS gEp0Status;
79 EP_STATUS gEp1InStatus;
80 EP_STATUS gEp2OutStatus;
81 EP0_COMMAND gEp0Command;
82
83 //-----------------------------------------------------------------------------
84 // MAIN Routine
85 //-----------------------------------------------------------------------------
86
87 void main (void)
88 {
89 1 PCA0MD &= ~0x40; // Disable Watchdog timer
90 1 PORT_Init (); // Initialize Crossbar and GPIO
91 1 SYSCLK_Init (); // Initialize oscillator
92 1 USB0_Init (); // Initialize USB0
93 1 VDD_MON_Init(); // Turn on VDD Monitor
94 1
95 1
96 1 EA = 1; // Enable global interrupts
97 1
98 1 USB0_Enable (); // Enable USB0
99 1
100 1 while (1);
101 1 }
102
103 //-----------------------------------------------------------------------------
104 // Initialization Subroutines
105 //-----------------------------------------------------------------------------
106
107 //-----------------------------------------------------------------------------
108 // SYSCLK_Init
109 //-----------------------------------------------------------------------------
110 //
111 // Return Value : None
112 // Parameters : None
113 //
114 // This function initializes the system clock and USB clock.
115 //
116 //-----------------------------------------------------------------------------
117 void SYSCLK_Init (void)
C51 COMPILER V7.06 F32X_USB_MAIN 07/16/2008 15:35:21 PAGE 3
118 {
119 1 unsigned char delay = 100;
120 1
121 1 OSCICN |= 0x03; // Configure internal oscillator for
122 1 // its maximum frequency
123 1
124 1 CLKMUL = 0x00; // Select internal oscillator as
125 1 // input to clock multiplier
126 1
127 1 CLKMUL |= 0x80; // Enable clock multiplier
128 1 while (delay--); // Delay for >5us
129 1 CLKMUL |= 0xC0; // Initialize the clock multiplier
130 1
131 1 while(!(CLKMUL & 0x20)); // Wait for multiplier to lock
132 1
133 1 CLKSEL |= USB_4X_CLOCK; // Select USB clock
134 1 CLKSEL |= SYS_4X_DIV_2; // Select SYSCLK as Clock Multiplier/2
135 1 }
136
137 //-----------------------------------------------------------------------------
138 // VDD_MON_Init
139 //-----------------------------------------------------------------------------
140 //
141 // Return Value : None
142 // Parameters : None
143 //
144 // This function initializes the VDD monitor
145 //
146 //-----------------------------------------------------------------------------
147 void VDD_MON_Init(void)
148 {
149 1 RSTSRC |= 0x02;
150 1 }
151
152 //-----------------------------------------------------------------------------
153 // USB0_Init
154 //-----------------------------------------------------------------------------
155 //
156 // Return Value : None
157 // Parameters : None
158 //
159 // - Initialize USB0
160 // - Enable USB0 interrupts
161 // - Enable USB0 transceiver
162 // - USB0 left disabled
163 //
164 //-----------------------------------------------------------------------------
165 void USB0_Init (void)
166 {
167 1 UWRITE_BYTE(POWER, 0x08); // Asynch. reset
168 1
169 1 UWRITE_BYTE(IN1IE, 0x0F); // Enable Endpoint0 Interrupt
170 1 UWRITE_BYTE(OUT1IE, 0x0F);
171 1 UWRITE_BYTE(CMIE, 0x04); // Enable Reset interrupt
172 1
173 1 USB0XCN = 0xC0; // Enable transceiver
174 1 USB0XCN |= FULL_SPEED; // Select device speed
175 1
176 1 UWRITE_BYTE(CLKREC, 0x80); // Enable clock recovery,
177 1 // single-step mode disabled
178 1
179 1 EIE1 |= 0x02; // Enable USB0 Interrupts
C51 COMPILER V7.06 F32X_USB_MAIN 07/16/2008 15:35:21 PAGE 4
180 1 }
181
182 //-----------------------------------------------------------------------------
183 // USB0_Enable
184 //-----------------------------------------------------------------------------
185 //
186 // Return Value : None
187 // Parameters : None
188 //
189 // This function enables the USB transceiver
190 //
191 //-----------------------------------------------------------------------------
192 void USB0_Enable (void)
193 {
194 1
195 1 UWRITE_BYTE(POWER, 0x00); // Enable USB0 by clearing the
196 1 // USB Inhibit bit
197 1 // Suspend mode disabled
198 1 }
199
200 //-----------------------------------------------------------------------------
201 // PORT_Init
202 //-----------------------------------------------------------------------------
203 //
204 // Return Value : None
205 // Parameters : None
206 //
207 // This function configures the crossbar and GPIO ports.
208 //
209 // P2.2 digital push-pull LED
210 // P2.3 digital push-pull LED
211 //
212 //-----------------------------------------------------------------------------
213 void PORT_Init(void)
214 {
215 1 P2MDOUT |= 0x0C; // P2.2 and P2.3 set to push-pull
216 1 Led1 = 0; // Start with both LEDs off
217 1 Led2 = 0;
218 1 XBR0 = 0x00;
219 1 XBR1 = 0x40; // Enable Crossbar
220 1 }
221
222 //-----------------------------------------------------------------------------
223 // End Of File
224 //-----------------------------------------------------------------------------
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 146 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 54 ----
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 + -