📄 f3xx_usb0_reporthandler.lst
字号:
C51 COMPILER V8.17 F3XX_USB0_REPORTHANDLER 03/18/2009 09:55:18 PAGE 1
C51 COMPILER V8.17, COMPILATION OF MODULE F3XX_USB0_REPORTHANDLER
OBJECT MODULE PLACED IN F3xx_USB0_ReportHandler.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE F3xx_USB0_ReportHandler.c BROWSE DEBUG OBJECTEXTEND
line level source
1 //-----------------------------------------------------------------------------
2 // F3xx_USB0_ReportHandler.c
3 //-----------------------------------------------------------------------------
4 // Copyright 2008 Silicon Laboratories, Inc.
5 // http://www.silabs.com
6 //
7 // Program Description:
8 //
9 // Stub file for Firmware Template.
10 //
11 //
12 // How To Test: See Readme.txt
13 //
14 //
15 // FID
16 // Target: C8051F32x/C8051F340
17 // Tool chain: Keil C51 7.50 / Keil EVAL C51
18 // Silicon Laboratories IDE version 2.6
19 // Command Line: See Readme.txt
20 // Project Name: HIDtoUART
21 //
22 // Release 1.0
23 // -Initial Revision (PD)
24 // -04 JUN 2008
25 //
26
27
28 // ----------------------------------------------------------------------------
29 // Header files
30 // ----------------------------------------------------------------------------
31
32 #include "F3xx_USB0_ReportHandler.h"
33 #include "F3xx_USB0_InterruptServiceRoutine.h"
34 #include "F3xx_HIDtoUART.h"
35 #include "c8051f3xx.h"
36 // ----------------------------------------------------------------------------
37 // Local Function Prototypes
38 // ----------------------------------------------------------------------------
39 void IN_Control (void);
40 void OUT_Control (void);
41 void IN_Data (void);
42 void OUT_Data (void);
43
44 // ----------------------------------------------------------------------------
45 // Local Definitions
46 // ----------------------------------------------------------------------------
47
48 // ****************************************************************************
49 // Set Definitions to sizes corresponding to the number of reports
50 // ****************************************************************************
51
52 #define IN_VECTORTABLESize 2
53 #define OUT_VECTORTABLESize 2
54
55 // ----------------------------------------------------------------------------
C51 COMPILER V8.17 F3XX_USB0_REPORTHANDLER 03/18/2009 09:55:18 PAGE 2
56 // Global Constant Declaration
57 // ----------------------------------------------------------------------------
58
59
60 // ****************************************************************************
61 // Link all Report Handler functions to corresponding Report IDs
62 // ****************************************************************************
63
64 const VectorTableEntry IN_VECTORTABLE[IN_VECTORTABLESize] =
65 {
66 // FORMAT: Report ID, Report Handler
67 IN_DATA, IN_Data,
68 IN_CONTROL, IN_Control
69
70 };
71
72 // ****************************************************************************
73 // Link all Report Handler functions to corresponding Report IDs
74 // ****************************************************************************
75 const VectorTableEntry OUT_VECTORTABLE[OUT_VECTORTABLESize] =
76 {
77 // FORMAT: Report ID, Report Handler
78 OUT_DATA, OUT_Data,
79 OUT_CONTROL, OUT_Control
80 };
81
82
83 // ----------------------------------------------------------------------------
84 // Global Variable Declaration
85 // ----------------------------------------------------------------------------
86
87 BufferStructure IN_BUFFER, OUT_BUFFER;
88
89 // ----------------------------------------------------------------------------
90 // Local Variable Declaration
91 // ----------------------------------------------------------------------------
92
93 // ----------------------------------------------------------------------------
94 // Local Functions
95 // ----------------------------------------------------------------------------
96
97 // ****************************************************************************
98 // Add all Report Handler routines here
99 // ****************************************************************************
100
101
102 // ****************************************************************************
103 // For Input Reports:
104 // Point IN_BUFFER.Ptr to the buffer containing the report
105 // Set IN_BUFFER.Length to the number of bytes that will be
106 // transmitted.
107 //
108 // REMINDER:
109 // Systems using more than one report must define Report IDs
110 // for each report. These Report IDs must be included as the first
111 // byte of an IN report.
112 // Systems with Report IDs should set the FIRST byte of their buffer
113 // to the value for the Report ID
114 // AND
115 // must transmit Report Size + 1 to include the full report PLUS
116 // the Report ID.
117 //
C51 COMPILER V8.17 F3XX_USB0_REPORTHANDLER 03/18/2009 09:55:18 PAGE 3
118 // ****************************************************************************
119 void IN_Control (void)
120 {
121 1 #ifndef BAUDRATE_HARDCODED
122 1 ULONG baud_rate;
123 1 baud_rate.L = BaudRate;
124 1 // Transmit system configuration to host
125 1 IN_PACKET[0] = IN_CONTROL;
126 1 IN_PACKET[1] = baud_rate.C[0];
127 1 IN_PACKET[2] = baud_rate.C[1];
128 1 IN_PACKET[3] = baud_rate.C[2];
129 1 IN_PACKET[4] = baud_rate.C[3];
130 1
131 1 IN_BUFFER.Ptr = IN_PACKET;
132 1 IN_BUFFER.Length = IN_CONTROL + 1;
133 1 #endif
134 1 }
135
136 void IN_Data (void)
137 {
138 1 unsigned char index,terminal_value;
139 1
140 1 IN_PACKET[0] = IN_DATA;
141 1
142 1 // EA = 0;
143 1 // critical section for UART buffer
144 1 // first byte after report ID shows how many valid bytes contained
145 1 // within buffer
146 1 IN_PACKET[1] = UART_INPUT_SIZE;
147 1 // EA = 1;
148 1
149 1 index = 2;
150 1 terminal_value = IN_PACKET[1];
151 1 while (terminal_value != 0)
152 1 {
153 2 // Enter critical section
154 2 // EA = 0;
155 2 // Increment pointer and wrap if necessary
156 2 UART_INPUT_LAST++;
157 2 UART_INPUT_LAST &= ~0x80;
158 2 // Add byte to report to be transmitted
159 2 IN_PACKET[index++] = UART_INPUT[UART_INPUT_LAST];
160 2 // Decrement size and
161 2 UART_INPUT_SIZE--;
162 2 terminal_value--;
163 2 // Leave critical section
164 2 // EA = 1;
165 2 }
166 1
167 1 IN_BUFFER.Ptr = IN_PACKET;
168 1 IN_BUFFER.Length = IN_DATA_SIZE + 1;
169 1
170 1 }
171
172
173 // ****************************************************************************
174 // For Output Reports:
175 // Data contained in the buffer OUT_BUFFER.Ptr will not be
176 // preserved after the Report Handler exits.
177 // Any data that needs to be preserved should be copyed from
178 // the OUT_BUFFER.Ptr and into other user-defined memory.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -