-
Notifications
You must be signed in to change notification settings - Fork 8
/
3DProasm.S
810 lines (626 loc) · 18.9 KB
/
3DProasm.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
;-------------------------------------------------------------------------------
;*******************************************************************************
;* File Name : 3DProasm.S
;* Project : Microsoft Sidewinder 3D Pro/PP/FFP to USB converter
;* Date : 2005/05/31, 2006/12/14, 2008/02/12, 2009/06/26
;* Version : 4.0 + MODS
;* Target MCU : AT90USB162/AT90USB82, ATMEGA16U4/ATMEGA32U4
;* Tool Chain : Atmel AVR Studio 4.17 666 / WinAVR 20090313
;* Author : Detlef "Grendel" Mueller
;* References : Sidewinder.c by Vojtech Pavlik
;* Patent #5628686, Apperatus and Method for Bidirectional
;* Data Communication in a Gameport, by Microsoft
;* Description : 3D Pro driver
;* Device : Microsoft SideWinder 3D Pro, Precision Pro, Force Feedback Pro
;*
;* Release Notes:
;* ================
;* WARNING: This version has been heavily modified to only support
;* Force Feedback Pro and ATmega32U4.
;* Do not use except for testing purposes!
;*
;* -- tloimu
;* ================
;*
;* Joystick button mapping
;* =======================
;*
;* B1 - PB0
;* B2 - PB1
;* B3 - PB2
;* B4 - PB3
;*
;* 3D Pro data packet structure (64bit)
;* ====================================
;*
;* 0 ****0 0 0 0 0 0 1
;* 6666555555555544444444443333333333222222222211111111110000000000
;* 3210987654321098765432109876543210987654321098765432109876543210
;* ----------------------------------------------------------------
;* sHHHccccsTTTTTTTsRRRRRRRsBBRRTTTsYYYYYYYsXXXXXXXsBBBBBBBsHXXXYYY
;* 210 6543210 6543210 8987987 6543210 6543210 7654321 3987987
;*
;* Bit Description Comment
;* === =========== =======
;* 00 Y7
;* 01 Y8
;* 02 Y9
;* 03 X7
;* 04 X8
;* 05 X9
;* 06 H3
;* 07 Sync always 1
;* 08 B1 Trigger (Buttons are low active !)
;* 09 B2 2nd trigger
;* 10 B3 Upper thumb
;* 11 B4 Lower thumb
;* 12 B5 Base 1
;* 13 B6 Base 2
;* 14 B7 Base 3
;* 15 Sync always 0
;* 16 X0 X-axis
;* 17 X1
;* 18 X2
;* 19 X3
;* 20 X4
;* 21 X5
;* 22 X6
;* 23 Sync always 0
;* 24 Y0 Y-axis
;* 25 Y1
;* 26 Y2
;* 27 Y3
;* 28 Y4
;* 29 Y5
;* 30 Y6
;* 31 Sync always 0
;* 32 T7
;* 33 T8
;* 34 T9
;* 35 Rz7
;* 36 Rz8
;* 37 B9 mode switch
;* 38 B8 Base 4
;* 39 Sync always 0
;* 40 Rz0 Rz-axis (twist)
;* 41 Rz1
;* 42 Rz2
;* 43 Rz3
;* 44 Rz4
;* 45 Rz5
;* 46 Rz6
;* 47 Sync always 0
;* 48 T0 Throttle slider
;* 49 T1
;* 50 T2
;* 51 T3
;* 52 T4
;* 53 T5
;* 54 T6
;* 55 Sync always 0
;* 56 chksum Sum of all nibbles = 0
;* 57 chksum
;* 58 chksum
;* 59 chksum
;* 60 H0 Hat switch
;* 61 H1
;* 62 H2
;* 63 Sync always 0
;*
;* Timer Trigger Signal
;* --+ +--....-------------------------------....-------------------------------
;* | |
;* | |
;* +--+
;*
;*
;* 3DP Clock Line (Button 1) w/ Button 1 Released
;*
;* --------....-------------------+ +----+ +----+ +-------------------
;* | | | | | |
;* | | | | | |
;* +----+ +-....-+ +----+
;* |<-....--- 100us -------->|<--------- 660us -------->|
;*
;*
;* 3DP Clock Line (Button 1) w/ Button 1 Pressed
;*
;* +--------------+ +----+ +----+ +--------------+
;* | | | | | | | |
;* | | | | | | | |
;* --------....----+ +----+ +-....-+ +----+ +----
;* |<-- 17.5us -->| |<-- 17.7us -->|
;* |<-....--- 100us -------->|<--------- 660us -------->|
;*
;*
;* 3DP Clock Line (Button 1) Detail
;*
;* |<-- start of packet 2 or 3
;* ----+ +----+ +------+ +----+
;* | | | | | | |
;* | | | | | | |
;* +----+ +----+ +----+ +----
;* |<-10us ->|<-12.5us ->|
;*
;*
;* Buttons 2-4 data is valid on rising edges of the clock. Buttons 1-4
;* are mapped to the button lines if no packet transfer is going on
;* (3D Pro only !)
;*
;* Calling conventions on gcc:
;* First parameter passed in R24/R25, second in R22/R23 and so on.
;* Callee must preserve R1-R17, R28/R29, result is passed in R24/R25.
;*
;* $Id: 3DProasm.S 1.5 2010/04/23 05:29:34 Detlef Exp Detlef $
;*******************************************************************************
;-------------------------------------------------------------------------------
#include "3DPro.h"
;-------------------------------------------------------------------------------
;*******************************************************************************
;-------------------------------------------------------------------------------
#define temp0 r21
#define temp1 r20
#define temp2 r19
#define temp3 r18
#define XL r26
#define XH r27
#define nop2 rjmp .+0 /* jump to next instruction */
#if F_CPU == 16000000UL
#define TRGWAIT lo8((48*(16000000/1000000))/3)
#endif
;-------------------------------------------------------------------------------
;*******************************************************************************
;-------------------------------------------------------------------------------
; Note: the following variables MUST be in the same 256 byte RAM segment !!
.section .bss,"aw",@nobits
.global sw_idbuf
.global sw_packet3
.global sw_packet2
.global sw_packet1
.global ffp_packet
.global sw_pktptr
.global sw_clkcnt
.skip 1,0
sw_idbuf:
.skip 60,0
sw_packet3: ; SideWinder 3D Pro packet buffers
.skip 8,0
sw_packet2:
.skip 8,0
sw_packet1:
.skip 2,0
ffp_packet:
.skip 6,0
sw_pktstart:
sw_pktptr: ; LSB of -> to current byte in buffer
.skip 1,0
sw_clkcnt: ; no. of clock ticks on B1
.skip 1,0
;-------------------------------------------------------------------------------
;*******************************************************************************
;-------------------------------------------------------------------------------
.text
;-------------------------------------------------------------------------------
;*******************************************************************************
; Receive, decode, and store a triplet from the 3DPro, PP, or FFP
;-------------------------------------------------------------------------------
.global INT0_vect
INT0_vect:
push temp0 ; Save temp0 2 +2
in temp0,SREG ; Save S register 1
push temp0 ; Save SREG 2
ldi temp0,T6TO100US ; 1
out TCNT0,temp0 ; Reset timeout timer 1
push temp1 ; Save temp1 2
push XL ; Save XL 2
push XH ; Save XH 2 +4
ldi XH,hi8(sw_pktstart) ; Load buffer pointer H !!! 1 +5
lds XL,sw_pktptr ; Load buffer pointer L 2 +4
lds temp0,sw_clkcnt ; Load clkcnt 2 +6
mov temp1,temp0 ; 1 +7
inc temp0 ; Maintain clkcnt 1
sts sw_clkcnt,temp0 ; Save new clkcnt 2 +9
in temp0,BUTPIN ; Read the button data 1
swap temp0 ; AT90USBX2 1
andi temp0,0b11100000 ; Mask B4-B2 1
andi temp1,7 ; 1 12+ 01234567
breq I0case0 ; 1/2 21111111
cpi temp1,5 ; 1 1111111
breq I0case5 ; 1/2 1111211
cpi temp1,2 ; 1 1111 11
breq I0case2 ; 1/2 1211 11
cpi temp1,3 ; 1 1 11 11
breq I0case3 ; 1/2 1 21 11
cpi temp1,6 ; 1 1 1 11
breq I0case6 ; 1/2 1 1 21
cpi temp1,1 ; 1 1 1 1
breq I0case1 ; 1/2 2 1 1
cpi temp1,4 ; 1 1 1
breq I0case4 ; 1/2 2 1
rjmp I0case7 ; 2 2
; 1 1 11
; 22684405
I0case0:
swap temp0 ; move b7-b5 (B4-B3) to b2-b0 1
lsr temp0 ; 1 -2
st -X,temp0 ; Store it 2
rjmp Int0End ; 2 8+2=10 +21=31
I0case2:
lsl temp0 ; store b7 in C, b6-b5 to b7-b6 1
ld temp1,X ; Get current byte 2
or temp0,temp1 ; 1
st X,temp0 ; Save to buffer 2
clr temp0 ; 1
rol temp0 ; b7 to b0 1
st -X,temp0 ; Save to buffer 2
rjmp Int0End ; 2 12+6=18 +21=39
I0case5:
bst temp0,7 ; store b7 in T 1
lsl temp0 ; drop b7 1
lsl temp0 ; store b6 in C, b5 to b7 1
ld temp1,X ; Get current byte 2
or temp0,temp1 ; 1
st X,temp0 ; Save to buffer 2
clr temp0 ; 1
rol temp0 ; b6 to b0 1
bld temp0,1 ; b7 to b1 1
st -X,temp0 ; Save to buffer 2
rjmp Int0End ; 2 15+4=19 +21=40
I0case3: ; b7-b5 to b3-b1 9+8=17 +21=38
lsr temp0 ; 1
I0case6: ; b7-b5 to b4-b2 8+10=18 +21=39
lsr temp0 ; 1
I0case1: ; b7-b5 to b5-b3 7+12=19 +21=40
lsr temp0 ; 1
I0case4: ; b7-b5 to b6-b4 6+14=20 +21=41
lsr temp0 ; 1
I0case7: ; b7-b5 are right 5+15=20 +21=41
ld temp1,X ; Get current byte 2
or temp0,temp1 ; 1
st X,temp0 ; Save to buffer 2
Int0End:
sts sw_pktptr,XL ; Save buffer pointer L 2
pop XH ; Restore XH 2 +11
pop XL ; Restore XL 2 +4
pop temp1 ; Restore temp1 2
pop temp0 ; Restore SREG 2
out SREG,temp0 ; Restore S register 1
pop temp0 ; Restore temp0 2 +13
reti ; 4 9+
;-------------------------------------------------------------------------------
;*******************************************************************************
; Decode the raw FFP/PP data and store it into sw_report
;
; Input:
; Pointer to start of packet to copy
;
; FFP/PP data packet structure
; ============================
;
; 44444444 33333333 33222222 22221111 11111100 00000000
; 76543210 98765432 10987654 32109876 54321098 76543210
; -------0 -------1 -------2 -------3 -------4 -------5
; ppHHHHRR RRRRTTTT TTTYYYYY YYYYYXXX XXXXXXXB BBBBBBBB
; 321054 32106543 21098765 43210987 65432109 87654321
;
; USB report data structure
; =========================
;
; -------0 -------1 -------2 -------3 -------4 -------5
; XXXXXXXX YYYYYYXX HHHHYYYY BBRRRRRR TBBBBBBB 00TTTTTT
; 76543210 54321098 32109876 21543210 09876543 654321
;
;-------------------------------------------------------------------------------
#define argPtrL r24
#define argPtrH r25
.global CopyFFPData
CopyFFPData:
movw XL,argPtrL
; X
ldi temp0,4
add XL,temp0
ld temp0,X ; xl:6543210-
com temp0
bst temp0,0 ; b:9
com temp0
subi XL,1
ld temp2,X ; xh:-----987
lsr temp2 ; xh:------98 [7]
ror temp0 ; xl:76543210
sts sw_report,temp0
ldi temp1,0b00000010
add temp2,temp1 ; Add -512
andi temp2,0b00000011 ; xh:------98
; Y
ld temp0,X ; yl:43210---
subi XL,1
ld temp1,X ; yh:---98765
lsr temp1 ; yh:----9876 [5]
ror temp0 ; yl:543210--
andi temp0,0b11111100
or temp0,temp2
sts sw_report+1,temp0
ldi temp2,0b00001000
add temp1,temp2 ; Add -512
andi temp1,0b00001111 ; yh:----9876
; Hat
subi XL,2
ld temp0,X ; h:--3210--
lsl temp0 ; h:-3210---
lsl temp0 ; h:3210----
subi temp0,0x10 ; -1
andi temp0,0b11110000
or temp0,temp1
sts sw_report+2,temp0
; Rz
ld temp2,X ; rh:------54
ldi temp1,0b00000010
add temp2,temp1 ; Add -32
andi temp2,0b00000011
inc XL
ld temp1,X ; rl:3210----
andi temp1,0b11110000
or temp2,temp1 ; r:3210--54
swap temp2 ; r:--543210
lsl temp2 ; r:-543210-
lsl temp2 ; r:543210--
; B1-9
ldi temp0,4
add XL,temp0
ld temp0,X ; b:87654321
com temp0
lsr temp0 ; b:-8765432 [1]
ror temp2 ; r:1543210-
lsr temp0 ; b:--876543 [2]
ror temp2 ; r:21543210
sts sw_report+3,temp2
bld temp0,6 ; b:-9876543
; Throttle
subi XL,3
ld temp1,X ; tl:210-----
bst temp1,5
bld temp0,7 ; b:09876543
sts sw_report+4,temp0
subi XL,1
ld temp0,X ; th:----6543
ldi temp2,0b00001000
add temp0,temp2 ; Add -64
andi temp0,0b00001111
lsl temp1 ; tl:1------- [2]
rol temp0 ; th:---65432
lsl temp1 ; tl:-------- [1]
rol temp0 ; th:--654321
sts sw_report+5,temp0
ret
;-------------------------------------------------------------------------------
;*******************************************************************************
; Decode the raw 3DPro data and store it into sw_report
;
; Input:
; Pointer to start of packet to copy
;
; 3D Pro data packet structure
; ============================
;
; 0 **** 0 0 0 0 0 0 1
; 66665555 55555544 44444444 33333333 33222222 22221111 11111100 00000000
; 32109876 54321098 76543210 98765432 10987654 32109876 54321098 76543210
; -------0 -------1 -------2 -------3 -------4 -------5 -------6 -------7
; sHHHcccc sTTTTTTT sRRRRRRR sBBRRTTT sYYYYYYY sXXXXXXX sBBBBBBB sHXXXYYY
; 210 6543210 6543210 8987987 6543210 6543210 7654321 3987987
;
; USB report data structure
; =========================
;
; -------0 -------1 -------2 -------3 -------4 -------5 -------6
; XXXXXXXX YYYYYYXX RRRRYYYY HHHRRRRR BBBBBBBH TTTTTTTB 00000TTT
; 76543210 54321098 32109876 21087654 76543213 65432108 987
;
;-------------------------------------------------------------------------------
.global Copy3DPData
Copy3DPData:
movw XL,argPtrL
; Get X
ldi temp1,5
add XL,temp1
ld temp0,X ; xl:-6543210
inc XL
inc XL
ld temp2,X
andi temp2,0b00111000 ; xh:--987---
lsl temp2 ; xh:-987----
swap temp2 ; xh:-----987
lsl temp0 ; xl:6543210-
lsr temp2 ; xh:------98 [7]
ror temp0 ; xl:76543210
ldi temp1,0xFE
add temp2,temp1 ; Add -512
andi temp2,0b00000011 ; xh:------98
sts sw_report,temp0
; Y
ld temp1,X
andi temp1,0b00000111 ; yh:-----987
subi XL,3
ld temp0,X ; yl:-6543210
lsl temp0 ; yl:6543210-
lsr temp1 ; yh:------98 [7]
ror temp0 ; yl:76543210
ldi temp3,0xFE
add temp1,temp3 ; Add -512
andi temp1,0b00000011 ; yh:------98
lsl temp0 ; yl:6543210-
rol temp1 ; yh:-----987
lsl temp0 ; yl:543210--
rol temp1 ; yh:----8976
or temp0,temp2
sts sw_report+1,temp0
mov temp2,temp1
; Rz
subi XL,2
ld temp0,X ; rl:-6543210
inc XL
ld temp1,X
andi temp1,0b00011000 ; rh:---87---
lsl temp0 ; rl:6543210-
lsl temp1 ; rh:--87----
swap temp1 ; rh:------87
lsr temp1 ; rh:-------8 [7]
ror temp0 ; rl:76543210
com temp1 ; Add -256
bst temp1,0
swap temp0 ; rl:32107654
mov temp1,temp0
andi temp1,0b11110000 ; rl:3210----
or temp1,temp2
sts sw_report+2,temp1
andi temp0,0b00001111 ; rh:----7654
bld temp0,4 ; rh:---87654
mov temp2,temp0
; Hat
subi XL,3
ld temp0,X
andi temp0,0b01110000 ; h:-210----
ldi temp1,7
add XL,temp1
ld temp1,X ; h:-3------
bst temp1,6
bld temp0,7 ; h:3210----
subi temp0,0x10
bst temp0,7
lsl temp0 ; h:210-----
or temp0,temp2
sts sw_report+3,temp0
clr temp2
bld temp2,0 ; h:-------3
; Buttons 1-8
dec XL
ld temp0,X ; b:-7654321
subi XL,3
ld temp1,X ; b:-89-----
bst temp1,6
bld temp0,7 ; b:87654321
com temp0
clr temp1
lsl temp0 ; b:7654321-
rol temp1 ; b:-------8
or temp0,temp2
sts sw_report+4,temp0
mov temp2,temp1
; Slider
subi XL,2
ld temp0,X ; sl:-6543210
inc XL
inc XL
ld temp1,X
andi temp1,0b00000111 ; sh:-----987
lsl temp0 ; sl:6543210-
lsr temp1 ; sh:------98 [7]
ror temp0 ; sl:76543210
ldi temp3,0xFE
add temp1,temp3 ; Add -512
andi temp1,0b00000011
bst temp0,7
lsl temp0 ; sl:6543210-
or temp0,temp2
sts sw_report+5,temp0
lsl temp1 ; sh:-----98-
bld temp1,0
sts sw_report+6,temp1
ret
;-------------------------------------------------------------------------------
;*******************************************************************************
; Initiate and monitor data transfer from a 3DP/FFP/PP.
; INT0 is left enabled upon exit.
;
; Input:
; temp1 0 for data packet, -n for ID kick
; temp2 No. of triplets to wait for
; Return:
; 1 - received, 0 - timed out
;-------------------------------------------------------------------------------
#define argSZ r22
#define argID r24
#define resOkL r24
.global QueryFFP
QueryFFP:
mov temp1,argID
mov temp2,argSZ
clr resOkL ; Default return 0
cli ; Disable interrupts
sbi EIFR,INTF0 ; Clear INT condition
sbi EIMSK,INT0 ; Enable INT
clr temp3
sbis BUTPIN,BUT1 ; Button 1 pressed ?
ser temp3 ; Yes, have to swallow 1st INT..
ldi temp0,_B1(PSRSYNC) ; reset prescaler
out GTCCR,temp0
ldi temp0,T6TO400US
out TCNT0,temp0 ; Set up initial timeout
sbi TIFR0,TOV0 ; Clear overflow flag
sts sw_clkcnt,temp3 ; Preset clock counter
ldi temp0,lo8(sw_pktstart) ; &ffp_packet[6]
sts sw_pktptr,temp0
sei ; 1
Ptrigger:
cbi TRGDDR,TRGX1BIT ; 2
cbi TRGDDR,TRGY2BIT ; 2
ldi temp0,TRGWAIT ; wait 48us
1: dec temp0
brne 1b
sbi TRGDDR,TRGX1BIT ; 2
sbi TRGDDR,TRGY2BIT ; 2
Ploop:
lds temp0,sw_clkcnt ; +2
cp temp0,temp3 ; Anything new ? 1
brne Pgotsome ; 1/2 = 2/3
sbis TIFR0,TOV0 ; Timeout ? Skip if TOV set 1/2
rjmp Ploop ; Wait some more 2 = 4
ret ; Signal timeout, return 0
Pgotsome:
lds temp0,sw_clkcnt ; 1 +1
sub temp0,temp3 ; # clk's that occured 1
add temp3,temp0 ; Correct clkcnt copy 1
cp temp3,temp2 ; Got all we need ? 1
brsh Pdone ; Yes, done 1/2 = 6
tst temp1 ; Kick pending ? 1
brpl Ploop ; Nope 1/2 = 8
add temp1,temp0 ; Kick due ? 1
brmi Ploop ; Nope 1/2 = 10
rjmp Ptrigger ; Yes, kick 2 = 11
Pdone: ; Packet arrived..
inc resOkL ; Signal Ok, return 1
ret
;-------------------------------------------------------------------------------
;*******************************************************************************
; Initiate and monitor data transfer from a 3DPro.
; INT0 is left enabled upon exit.
;
; Input:
; temp1 0 for data packet, -n for ID kick
; temp2 No. of triplets to wait for
; Return:
; 1 - received, 0 - timed out
;-------------------------------------------------------------------------------
.global Query3DP
Query3DP:
rcall QueryFFP
tst resOkL
breq Qexit
lds temp0,sw_clkcnt
cpi temp0,DATSZ3DP ; If it's a data packet..
brne Qexit
cli
clr temp0
sts sw_clkcnt,temp0 ; Correct SWclkcnt and ptr so the next
lds temp0,sw_pktptr
inc temp0 ; packet will allign w/ sw_packet2
sts sw_pktptr,temp0
sei
Qexit:
ret
;-------------------------------------------------------------------------------
;*******************************************************************************
;* End of file
;*******************************************************************************
;-------------------------------------------------------------------------------