📄 combi.lst
字号:
194 /*
195 ** the order of the bytes in this structure is important! These bytes are in the
196 ** proper order for a packet returned to a USB host in response to a Get_Report command.
197 */
198 typedef struct
199 {
200 char bChange; //set to 1 if mouse state has changed
201 char bButtons; //current state of mouse buttons
202 signed char bXcount; //current accumulation of X counts
203 signed char bYcount; //current accumulation of Y counts
204 signed char bZcount; //current accumulation of Z counts
205 }MOUSE_STATE;
206
207
208
209 /*
210 ** global variables used by both USB and PS2 interfaces
211 */
212
213 QUEUE_STRUCT OpticsQueue; //optics queue
214
215 ONE_MSEC_STATUS MsecStatus; //status of 1msec interrupt
216 OPTICS_STATE Optics; //current state of optics
217 MOUSE_STATE Mouse; //current state of mouse (buttons, x,y,z)
218 char bLastButtons;
219 char bDebounceCount;
220
221
C51 COMPILER V7.01 COMBI 04/14/2008 22:57:43 PAGE 5
222 char bOpticsArray[16]; //16-byte array used for optics queue data
223
224
225 const signed char quad_table[] =
226 /*
227 ;***
228 ; Quadrature state table. This table assists processing of quadrature state
229 ; transitions. The table index is calculated as:
230 ; [(last_state)*4 + current_state],
231 ; and the table entry at that point is 1, 0 or -1 indicating increment, hold
232 ; or decrement the count, respectively.
233 ;***
234 */
235 {
236 0, //;State 0 => state 0 (NoChange)
237 1, //; => state 1 (Increment)
238 0xff, //; => state 2 (Decrement)
239 0, //; => state 3 (Fault)
240
241 0xff, //;State 1 => state 0 (Decrement)
242 0, //; => state 1 (NoChange)
243 0, //; => state 2 (Fault)
244 1, //; => state 3 (Increment)
245
246 1, //;State 2 => state 0 (Increment)
247 0, //; => state 1 (Fault)
248 0, //; => state 2 (NoChange)
249 0xff, //; => state 3 (Decrement)
250
251 0, //;State 3 => state 0 (Fault)
252 0xff, //; => state 1 (Decrement)
253 1, //; => state 2 (Increment)
254 0 //; => state 3 (NoChange)
255 };
256
257 const signed char z_quad_table[] =
258 /*
259 ;***
260 ; Quadrature state table. This table assists processing of quadrature state
261 ; transitions. The table index is calculated as:
262 ; [(last_state)*4 + current_state],
263 ; and the table entry at that point is 1, 0 or -1 indicating increment, hold
264 ; or decrement the count, respectively.
265 ;***
266 */
267 {
268 0, //;State 0 => state 0 (NoChange)
269 0, //; => state 1 (NoChange)
270 0, //; => state 2 (NoChange)
271 0, //; => state 3 (Fault)
272
273 0, //;State 1 => state 0 (NoChange)
274 0, //; => state 1 (NoChange)
275 0, //; => state 2 (NoChange)
276 1, //; => state 3 (Increment)
277
278 1, //;State 2 => state 0 (Increment)
279 0, //; => state 1 (Fault)
280 0, //; => state 2 (NoChange)
281 0xff, //; => state 3 (Decrement)
282
283 0, //;State 3 => state 0 (Fault)
C51 COMPILER V7.01 COMBI 04/14/2008 22:57:43 PAGE 6
284 0xff, //; => state 1 (Decrement)
285 0, //; => state 2 (NoChange)
286 0 //; => state 3 (NoChange)
287 };
288 /*
289 ** function prototypes for shared functions
290 */
291 void main(void);
292 void ClearRam(void);
293 void Delay(char delay);
294 //void delay(void);
295
296 //*************************************************************************************************
297 //USB DECLARATIONS
298
299 #include "usb_desc.h" //include usb descriptors
300
301
302
303 #define SET_EP0_MODE(x) EP_A0_MODE = x //set mode register for EP0
304
305
306 /*
307 ** define a structure that will maintain the parameters of multibyte data that is returned
308 ** to the host in response to successive IN commands on endpoint 0 (descriptors, status, reports, etc).
309 */
310 typedef struct
311 {
312 char bLength; //length of data remaining to be returned
313 far char *p; //pointer to the data
314 char dummy; //padding -- compiler bug doesn't allocate enough space for a far *
315 }TRANSMIT_STRUCT;
316
317
318 /*
319 ** define a structure that contains the current USB device status
320 */
321 typedef struct
322 {
323 char bConfiguration; //configured or not
324 char bRemoteWakeup; //remote wakeup enabled or not
325 char bDeviceStatus; //spare, do not remove! this byte is a placeholder
326 //for the 2nd byte of device status.
327 char bEP1Stall; //endpoint 1 stalled or not
328 char bEPStatus; //spare, do not remove! this byte is a placeholder
329 //for the 2nd byte of device status
330 char bAddress; //current address
331 char bProtocol; //boot protocol or report protocol
332 }DEVICE_STATUS;
333
334
335 /*
336 ** define a structure for mouse transmit status
337 */
338
339 typedef struct
340 {
341 char bIdlePeriod; //current idle period setting
342 char bIdleCounter; //counter for idle period
343 }
344 MOUSE_STATUS;
345
C51 COMPILER V7.01 COMBI 04/14/2008 22:57:43 PAGE 7
346
347
348
349 MOUSE_STATUS MouseStatus; //status of mouse
350 TRANSMIT_STRUCT XmtBuff; //EP0 transmit buffer parameters
351
352 DEVICE_STATUS DeviceStatus; //device status
353 char bSuspendCounter; //counter for keeping track of suspend interval
354
355 //declare the following registers global. They are used by ISRs to avoid compiler issues.
356 char byte_count;
357 char byte_count1;
358 char bWakeupCount;
359
360
361 /*
362 ** USB function prototypes
363 */
364 void UsbReInitialize(void);
365 void MouseTask(void);
366 void Suspend(void);
367 void usbmain(void);
368 void HandleSetup(void);
369 void HandleIn(void);
370 void USB_control_read(void);
371 char LoadEP0Fifo(void);
372 void ClearRemoteWakeup(void);
373 void SetRemoteWakeup(void);
374 void SetConfiguration(void);
375 void SetAddress(void);
376 void ClearEndpointStall(void);
377 void SetEndpointStall(void);
378 void GetDeviceStatus(void);
379 void GetDescriptor(void);
380 void GetInterfaceStatus(void);
381 void GetEndpointStatus(void);
382 void SetIdle(void);
383 void SetProtocol(void);
384 void GetReport(void);
385 void GetIdle(void);
386 void GetProtocol(void);
387 void GetConfiguration(void);
388 void USB_Stall_In_Out(void);
389 char BusInactive(void);
390
391
392
393 //*************************************************************************************************
394 //PS2 DECLARATIONS
395
396
397 /*
398 ** define a structure that contains all mouse parameters that can be set via host commands
399 */
400 typedef struct
401 {
402 char bReportRate;
403 char bReportInterval;
404 char bScale;
405 char bStream;
406 char bResolution;
407 char bEnabled;
C51 COMPILER V7.01 COMBI 04/14/2008 22:57:43 PAGE 8
408 char bZmouse;
409 char bWrap;
410 }MOUSEPARMS;
411
412 /*
413 ** define a structure to hold messages to be sent back to the host. This can be either a mouse packet
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -