Subversion Repositories group.electronics

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7 pfowler 1
 
2
main.elf:     file format elf32-avr
3
 
4
Sections:
5
Idx Name          Size      VMA       LMA       File off  Algn
6
 
7
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
8
  1 .data         00000002  00800060  00000976  00000a2a  2**0
9
                  CONTENTS, ALLOC, LOAD, DATA
10
  2 .bss          00000039  00800062  00800062  00000a2c  2**0
11
                  ALLOC
12
  3 .fuse         00000003  00820000  00820000  00000a2c  2**0
13
                  CONTENTS, ALLOC, LOAD, DATA
14
  4 .stab         000019c8  00000000  00000000  00000a30  2**2
15
                  CONTENTS, READONLY, DEBUGGING
16
  5 .stabstr      00000145  00000000  00000000  000023f8  2**0
17
                  CONTENTS, READONLY, DEBUGGING
18
  6 .debug_aranges 00000040  00000000  00000000  0000253d  2**0
19
                  CONTENTS, READONLY, DEBUGGING
20
  7 .debug_pubnames 00000207  00000000  00000000  0000257d  2**0
21
                  CONTENTS, READONLY, DEBUGGING
22
  8 .debug_info   000012e3  00000000  00000000  00002784  2**0
23
                  CONTENTS, READONLY, DEBUGGING
24
  9 .debug_abbrev 00000549  00000000  00000000  00003a67  2**0
25
                  CONTENTS, READONLY, DEBUGGING
26
 10 .debug_line   00000976  00000000  00000000  00003fb0  2**0
27
                  CONTENTS, READONLY, DEBUGGING
28
 11 .debug_frame  00000080  00000000  00000000  00004928  2**2
29
                  CONTENTS, READONLY, DEBUGGING
30
 12 .debug_str    0000050f  00000000  00000000  000049a8  2**0
31
                  CONTENTS, READONLY, DEBUGGING
32
 13 .debug_loc    000008c0  00000000  00000000  00004eb7  2**0
33
                  CONTENTS, READONLY, DEBUGGING
34
 14 .debug_pubtypes 0000013a  00000000  00000000  00005777  2**0
35
                  CONTENTS, READONLY, DEBUGGING
36
 15 .debug_ranges 000002b0  00000000  00000000  000058b1  2**0
37
                  CONTENTS, READONLY, DEBUGGING
38
 
39
Disassembly of section .text:
40
 
41
00000000 <__vectors>:
42
   0:	5e c0       	rjmp	.+188    	; 0xbe <__ctors_end>
43
   2:	43 c3       	rjmp	.+1670   	; 0x68a <__vector_1>
44
   4:	77 c0       	rjmp	.+238    	; 0xf4 <__bad_interrupt>
45
   6:	76 c0       	rjmp	.+236    	; 0xf4 <__bad_interrupt>
46
   8:	75 c0       	rjmp	.+234    	; 0xf4 <__bad_interrupt>
47
   a:	74 c0       	rjmp	.+232    	; 0xf4 <__bad_interrupt>
48
   c:	73 c0       	rjmp	.+230    	; 0xf4 <__bad_interrupt>
49
   e:	72 c0       	rjmp	.+228    	; 0xf4 <__bad_interrupt>
50
  10:	71 c0       	rjmp	.+226    	; 0xf4 <__bad_interrupt>
51
  12:	70 c0       	rjmp	.+224    	; 0xf4 <__bad_interrupt>
52
  14:	6f c0       	rjmp	.+222    	; 0xf4 <__bad_interrupt>
53
  16:	6e c0       	rjmp	.+220    	; 0xf4 <__bad_interrupt>
54
  18:	6d c0       	rjmp	.+218    	; 0xf4 <__bad_interrupt>
55
  1a:	6c c0       	rjmp	.+216    	; 0xf4 <__bad_interrupt>
56
  1c:	6b c0       	rjmp	.+214    	; 0xf4 <__bad_interrupt>
57
 
58
0000001e <usbDescriptorHidReport>:
59
  1e:	05 01 09 05 a1 01 09 01 a1 00 09 30 09 31 15 00     ...........0.1..
60
  2e:	25 02 75 02 95 02 81 02 c0 05 09 19 01 29 04 15     %.u..........)..
61
  3e:	00 25 01 75 01 95 04 81 02 c0                       .%.u......
62
 
63
00000048 <usbDescriptorString0>:
64
  48:	04 03 09 04                                         ....
65
 
66
0000004c <usbDescriptorStringVendor>:
67
  4c:	16 03 76 00 69 00 6b 00 69 00 74 00 73 00 2e 00     ..v.i.k.i.t.s...
68
  5c:	63 00 6f 00 6d 00                                   c.o.m.
69
 
70
00000062 <usbDescriptorStringDevice>:
71
  62:	28 03 55 00 53 00 42 00 20 00 4e 00 45 00 53 00     (.U.S.B. .N.E.S.
72
  72:	20 00 50 00 61 00 64 00 20 00 61 00 64 00 61 00      .P.a.d. .a.d.a.
73
  82:	70 00 74 00 65 00 72 00                             p.t.e.r.
74
 
75
0000008a <usbDescriptorDevice>:
76
  8a:	12 01 10 01 00 00 00 08 ea 1d 07 10 00 01 01 02     ................
77
  9a:	00 01                                               ..
78
 
79
0000009c <usbDescriptorConfiguration>:
80
  9c:	09 02 22 00 01 01 00 80 32 09 04 00 00 01 03 00     ..".....2.......
81
  ac:	00 00 09 21 01 01 00 01 22 2a 00 07 05 81 03 08     ...!...."*......
82
  bc:	00 0a                                               ..
83
 
84
000000be <__ctors_end>:
85
  be:	11 24       	eor	r1, r1
86
  c0:	1f be       	out	0x3f, r1	; 63
87
  c2:	cf e5       	ldi	r28, 0x5F	; 95
88
  c4:	d2 e0       	ldi	r29, 0x02	; 2
89
  c6:	de bf       	out	0x3e, r29	; 62
90
  c8:	cd bf       	out	0x3d, r28	; 61
91
 
92
000000ca <__do_copy_data>:
93
  ca:	10 e0       	ldi	r17, 0x00	; 0
94
  cc:	a0 e6       	ldi	r26, 0x60	; 96
95
  ce:	b0 e0       	ldi	r27, 0x00	; 0
96
  d0:	e6 e7       	ldi	r30, 0x76	; 118
97
  d2:	f9 e0       	ldi	r31, 0x09	; 9
98
  d4:	02 c0       	rjmp	.+4      	; 0xda <__do_copy_data+0x10>
99
  d6:	05 90       	lpm	r0, Z+
100
  d8:	0d 92       	st	X+, r0
101
  da:	a2 36       	cpi	r26, 0x62	; 98
102
  dc:	b1 07       	cpc	r27, r17
103
  de:	d9 f7       	brne	.-10     	; 0xd6 <__do_copy_data+0xc>
104
 
105
000000e0 <__do_clear_bss>:
106
  e0:	10 e0       	ldi	r17, 0x00	; 0
107
  e2:	a2 e6       	ldi	r26, 0x62	; 98
108
  e4:	b0 e0       	ldi	r27, 0x00	; 0
109
  e6:	01 c0       	rjmp	.+2      	; 0xea <.do_clear_bss_start>
110
 
111
000000e8 <.do_clear_bss_loop>:
112
  e8:	1d 92       	st	X+, r1
113
 
114
000000ea <.do_clear_bss_start>:
115
  ea:	ab 39       	cpi	r26, 0x9B	; 155
116
  ec:	b1 07       	cpc	r27, r17
117
  ee:	e1 f7       	brne	.-8      	; 0xe8 <.do_clear_bss_loop>
118
  f0:	56 d0       	rcall	.+172    	; 0x19e <main>
119
  f2:	3f c4       	rjmp	.+2174   	; 0x972 <_exit>
120
 
121
000000f4 <__bad_interrupt>:
122
  f4:	85 cf       	rjmp	.-246    	; 0x0 <__vectors>
123
 
124
000000f6 <usbFunctionSetup>:
125
 
126
usbMsgLen_t usbFunctionSetup(uchar data[8]) {
127
  usbRequest_t *req = (void *)data;
128
 
129
  return 0; // Nothing implemented
130
}
131
  f6:	80 e0       	ldi	r24, 0x00	; 0
132
  f8:	08 95       	ret
133
 
134
000000fa <hadUsbReset>:
135
For version 5.x RC oscillators (those with a split range of 2x128 steps, e.g.
136
ATTiny25, ATTiny45, ATTiny85), it may be useful to search for the optimum in
137
both regions.
138
*/
139
 
140
void hadUsbReset(void) {
141
  fa:	af 92       	push	r10
142
  fc:	bf 92       	push	r11
143
  fe:	df 92       	push	r13
144
 100:	ef 92       	push	r14
145
 102:	ff 92       	push	r15
146
 104:	0f 93       	push	r16
147
 106:	1f 93       	push	r17
148
 108:	cf 93       	push	r28
149
 10a:	df 93       	push	r29
150
 10c:	08 e0       	ldi	r16, 0x08	; 8
151
 10e:	10 e0       	ldi	r17, 0x00	; 0
152
 * experimental purposes only!
153
 */
154
static void calibrateOscillator(void)
155
{
156
uchar       step = 128;
157
uchar       trialValue = 0, optimumValue;
158
 110:	ee 24       	eor	r14, r14
159
 * the 12 MHz clock! Use the RC oscillator calibrated to 12 MHz for
160
 * experimental purposes only!
161
 */
162
static void calibrateOscillator(void)
163
{
164
uchar       step = 128;
165
 112:	80 e8       	ldi	r24, 0x80	; 128
166
 114:	f8 2e       	mov	r15, r24
167
uchar       trialValue = 0, optimumValue;
168
int         x, optimumDev, targetValue = (unsigned)(1499 * (double)F_CPU / 10.5e6 + 0.5);
169
 
170
    /* do a binary search: */
171
    do{
172
        OSCCAL = trialValue + step;
173
 116:	df 2c       	mov	r13, r15
174
 118:	de 0c       	add	r13, r14
175
 11a:	d1 be       	out	0x31, r13	; 49
176
        x = usbMeasureFrameLength();    /* proportional to current real frequency */
177
 11c:	a3 d2       	rcall	.+1350   	; 0x664 <usbMeasureFrameLength>
178
 11e:	a8 2e       	mov	r10, r24
179
 120:	e5 01       	movw	r28, r10
180
 122:	5e 01       	movw	r10, r28
181
 124:	b9 2e       	mov	r11, r25
182
 126:	e5 01       	movw	r28, r10
183
        if(x < targetValue)             /* frequency still too low */
184
 128:	99 e0       	ldi	r25, 0x09	; 9
185
 12a:	c4 33       	cpi	r28, 0x34	; 52
186
 12c:	d9 07       	cpc	r29, r25
187
 12e:	0c f4       	brge	.+2      	; 0x132 <hadUsbReset+0x38>
188
            trialValue += step;
189
 130:	ed 2c       	mov	r14, r13
190
        step >>= 1;
191
 132:	f6 94       	lsr	r15
192
 134:	01 50       	subi	r16, 0x01	; 1
193
 136:	10 40       	sbci	r17, 0x00	; 0
194
    }while(step > 0);
195
 138:	71 f7       	brne	.-36     	; 0x116 <hadUsbReset+0x1c>
196
    /* We have a precision of +/- 1 for optimum OSCCAL here */
197
    /* now do a neighborhood search for optimum value */
198
    optimumValue = trialValue;
199
    optimumDev = x; /* this is certainly far away from optimum */
200
    for(OSCCAL = trialValue - 1; OSCCAL <= trialValue + 1; OSCCAL++){
201
 13a:	8e 2d       	mov	r24, r14
202
 13c:	81 50       	subi	r24, 0x01	; 1
203
 13e:	81 bf       	out	0x31, r24	; 49
204
 140:	81 b7       	in	r24, 0x31	; 49
205
 142:	0e 2d       	mov	r16, r14
206
 144:	10 e0       	ldi	r17, 0x00	; 0
207
 146:	0f 5f       	subi	r16, 0xFF	; 255
208
 148:	1f 4f       	sbci	r17, 0xFF	; 255
209
 14a:	90 e0       	ldi	r25, 0x00	; 0
210
 14c:	08 17       	cp	r16, r24
211
 14e:	19 07       	cpc	r17, r25
212
 150:	74 f4       	brge	.+28     	; 0x16e <hadUsbReset+0x74>
213
 152:	16 c0       	rjmp	.+44     	; 0x180 <hadUsbReset+0x86>
214
        x = usbMeasureFrameLength() - targetValue;
215
        if(x < 0)
216
            x = -x;
217
        if(x < optimumDev){
218
 154:	8c 17       	cp	r24, r28
219
 156:	9d 07       	cpc	r25, r29
220
 158:	14 f4       	brge	.+4      	; 0x15e <hadUsbReset+0x64>
221
            optimumDev = x;
222
            optimumValue = OSCCAL;
223
 15a:	e1 b6       	in	r14, 0x31	; 49
224
 15c:	ec 01       	movw	r28, r24
225
    }while(step > 0);
226
    /* We have a precision of +/- 1 for optimum OSCCAL here */
227
    /* now do a neighborhood search for optimum value */
228
    optimumValue = trialValue;
229
    optimumDev = x; /* this is certainly far away from optimum */
230
    for(OSCCAL = trialValue - 1; OSCCAL <= trialValue + 1; OSCCAL++){
231
 15e:	81 b7       	in	r24, 0x31	; 49
232
 160:	8f 5f       	subi	r24, 0xFF	; 255
233
 162:	81 bf       	out	0x31, r24	; 49
234
 164:	81 b7       	in	r24, 0x31	; 49
235
 166:	90 e0       	ldi	r25, 0x00	; 0
236
 168:	08 17       	cp	r16, r24
237
 16a:	19 07       	cpc	r17, r25
238
 16c:	4c f0       	brlt	.+18     	; 0x180 <hadUsbReset+0x86>
239
        x = usbMeasureFrameLength() - targetValue;
240
 16e:	7a d2       	rcall	.+1268   	; 0x664 <usbMeasureFrameLength>
241
 170:	84 53       	subi	r24, 0x34	; 52
242
 172:	99 40       	sbci	r25, 0x09	; 9
243
 174:	97 ff       	sbrs	r25, 7
244
 176:	ee cf       	rjmp	.-36     	; 0x154 <hadUsbReset+0x5a>
245
 178:	90 95       	com	r25
246
 17a:	81 95       	neg	r24
247
 17c:	9f 4f       	sbci	r25, 0xFF	; 255
248
 17e:	ea cf       	rjmp	.-44     	; 0x154 <hadUsbReset+0x5a>
249
        if(x < optimumDev){
250
            optimumDev = x;
251
            optimumValue = OSCCAL;
252
        }
253
    }
254
    OSCCAL = optimumValue;
255
 180:	e1 be       	out	0x31, r14	; 49
256
both regions.
257
*/
258
 
259
void hadUsbReset(void) {
260
  calibrateOscillator();
261
  eeprom_write_byte(0, OSCCAL);   /* store the calibrated value in EEPROM */
262
 182:	61 b7       	in	r22, 0x31	; 49
263
 184:	80 e0       	ldi	r24, 0x00	; 0
264
 186:	90 e0       	ldi	r25, 0x00	; 0
265
 188:	e6 d3       	rcall	.+1996   	; 0x956 <__eewr_byte_tn85>
266
}
267
 18a:	df 91       	pop	r29
268
 18c:	cf 91       	pop	r28
269
 18e:	1f 91       	pop	r17
270
 190:	0f 91       	pop	r16
271
 192:	ff 90       	pop	r15
272
 194:	ef 90       	pop	r14
273
 196:	df 90       	pop	r13
274
 198:	bf 90       	pop	r11
275
 19a:	af 90       	pop	r10
276
 19c:	08 95       	ret
277
 
278
0000019e <main>:
279
#define STROBE_CLK() sbi(NES_PORT, CLK); \
280
                     _delay_us(1); \
281
                     cbi(NES_PORT, CLK); \
282
                     _delay_us(1); 
283
 
284
int main(void) {
285
 19e:	0f 93       	push	r16
286
 1a0:	1f 93       	push	r17
287
  uchar calibrationValue;
288
  while (!eeprom_is_ready());
289
 1a2:	e1 99       	sbic	0x1c, 1	; 28
290
 1a4:	fe cf       	rjmp	.-4      	; 0x1a2 <main+0x4>
291
  calibrationValue = eeprom_read_byte(0); /* calibration value from last time */
292
 1a6:	80 e0       	ldi	r24, 0x00	; 0
293
 1a8:	90 e0       	ldi	r25, 0x00	; 0
294
 1aa:	cd d3       	rcall	.+1946   	; 0x946 <__eerd_byte_tn85>
295
  if(calibrationValue != 0xff) {
296
 1ac:	8f 3f       	cpi	r24, 0xFF	; 255
297
 1ae:	09 f0       	breq	.+2      	; 0x1b2 <main+0x14>
298
    OSCCAL = calibrationValue;
299
 1b0:	81 bf       	out	0x31, r24	; 49
300
	#else
301
		//round up by default
302
		__ticks_dc = (uint32_t)(ceil(fabs(__tmp)));
303
	#endif
304
 
305
	__builtin_avr_delay_cycles(__ticks_dc);
306
 1b2:	81 e2       	ldi	r24, 0x21	; 33
307
 1b4:	91 ea       	ldi	r25, 0xA1	; 161
308
 1b6:	01 97       	sbiw	r24, 0x01	; 1
309
 1b8:	f1 f7       	brne	.-4      	; 0x1b6 <main+0x18>
310
 1ba:	00 c0       	rjmp	.+0      	; 0x1bc <main+0x1e>
311
 1bc:	00 00       	nop
312
  }
313
 
314
  _delay_ms(10);
315
  ACSR |= (1<<ACD); // Disable analog comparator
316
 1be:	47 9a       	sbi	0x08, 7	; 8
317
 
318
 
319
  usbDeviceDisconnect();  /* enforce re-enumeration, do this while interrupts are disabled! */
320
 1c0:	b8 9a       	sbi	0x17, 0	; 23
321
 1c2:	8f e4       	ldi	r24, 0x4F	; 79
322
 1c4:	9d e2       	ldi	r25, 0x2D	; 45
323
 1c6:	a9 e1       	ldi	r26, 0x19	; 25
324
 1c8:	81 50       	subi	r24, 0x01	; 1
325
 1ca:	90 40       	sbci	r25, 0x00	; 0
326
 1cc:	a0 40       	sbci	r26, 0x00	; 0
327
 1ce:	e1 f7       	brne	.-8      	; 0x1c8 <main+0x2a>
328
 1d0:	00 c0       	rjmp	.+0      	; 0x1d2 <main+0x34>
329
 1d2:	00 00       	nop
330
  _delay_ms(500);
331
  usbDeviceConnect();
332
 1d4:	b8 98       	cbi	0x17, 0	; 23
333
 
334
  wdt_enable(WDTO_1S);
335
 1d6:	2e e0       	ldi	r18, 0x0E	; 14
336
 1d8:	88 e1       	ldi	r24, 0x18	; 24
337
 1da:	90 e0       	ldi	r25, 0x00	; 0
338
 1dc:	0f b6       	in	r0, 0x3f	; 63
339
 1de:	f8 94       	cli
340
 1e0:	a8 95       	wdr
341
 1e2:	81 bd       	out	0x21, r24	; 33
342
 1e4:	0f be       	out	0x3f, r0	; 63
343
 1e6:	21 bd       	out	0x21, r18	; 33
344
  usbInit();
345
 1e8:	17 d2       	rcall	.+1070   	; 0x618 <usbInit>
346
  sei();
347
 1ea:	78 94       	sei
348
 
349
  sbi(NES_DDR, CLK);
350
 1ec:	bb 9a       	sbi	0x17, 3	; 23
351
  cbi(NES_DDR, OUT);
352
 1ee:	b9 98       	cbi	0x17, 1	; 23
353
  sbi(NES_DDR, LATCH);
354
 1f0:	bc 9a       	sbi	0x17, 4	; 23
355
 
356
  cbi(NES_PORT, CLK);
357
 1f2:	c3 98       	cbi	0x18, 3	; 24
358
  cbi(NES_PORT, LATCH);
359
 1f4:	c4 98       	cbi	0x18, 4	; 24
360
  for(;;) {
361
    wdt_reset();
362
    usbPoll();
363
    if(usbInterruptIsReady()){
364
 
365
      reportBuffer.data = 0x05; // Center pad, little endian
366
 1f6:	15 e0       	ldi	r17, 0x05	; 5
367
      _delay_us(1); // Latch pulse width >= 500ns
368
      cbi(NES_PORT, LATCH);
369
      _delay_us(1); // Propagation time <= 1000ns
370
 
371
      if(bit_is_clear(NES_PIN, OUT))
372
        reportBuffer.A = 1;
373
 1f8:	05 e2       	ldi	r16, 0x25	; 37
374
 
375
  cbi(NES_PORT, CLK);
376
  cbi(NES_PORT, LATCH);
377
 
378
  for(;;) {
379
    wdt_reset();
380
 1fa:	a8 95       	wdr
381
    usbPoll();
382
 1fc:	cf d0       	rcall	.+414    	; 0x39c <usbPoll>
383
    if(usbInterruptIsReady()){
384
 1fe:	80 91 70 00 	lds	r24, 0x0070
385
 202:	84 ff       	sbrs	r24, 4
386
 204:	fa cf       	rjmp	.-12     	; 0x1fa <main+0x5c>
387
 
388
      reportBuffer.data = 0x05; // Center pad, little endian
389
 206:	10 93 64 00 	sts	0x0064, r17
390
 
391
      sbi(NES_PORT, LATCH);
392
 20a:	c4 9a       	sbi	0x18, 4	; 24
393
	#else
394
		//round up by default
395
		__ticks_dc = (uint32_t)(ceil(fabs(__tmp)));
396
	#endif
397
 
398
	__builtin_avr_delay_cycles(__ticks_dc);
399
 20c:	95 e0       	ldi	r25, 0x05	; 5
400
 20e:	9a 95       	dec	r25
401
 210:	f1 f7       	brne	.-4      	; 0x20e <main+0x70>
402
 212:	00 c0       	rjmp	.+0      	; 0x214 <main+0x76>
403
      _delay_us(1); // Latch pulse width >= 500ns
404
      cbi(NES_PORT, LATCH);
405
 214:	c4 98       	cbi	0x18, 4	; 24
406
 216:	a5 e0       	ldi	r26, 0x05	; 5
407
 218:	aa 95       	dec	r26
408
 21a:	f1 f7       	brne	.-4      	; 0x218 <main+0x7a>
409
 21c:	00 c0       	rjmp	.+0      	; 0x21e <main+0x80>
410
      _delay_us(1); // Propagation time <= 1000ns
411
 
412
      if(bit_is_clear(NES_PIN, OUT))
413
 21e:	b1 99       	sbic	0x16, 1	; 22
414
 220:	02 c0       	rjmp	.+4      	; 0x226 <main+0x88>
415
        reportBuffer.A = 1;
416
 222:	00 93 64 00 	sts	0x0064, r16
417
 
418
      STROBE_CLK();
419
 226:	c3 9a       	sbi	0x18, 3	; 24
420
 228:	b5 e0       	ldi	r27, 0x05	; 5
421
 22a:	ba 95       	dec	r27
422
 22c:	f1 f7       	brne	.-4      	; 0x22a <main+0x8c>
423
 22e:	00 c0       	rjmp	.+0      	; 0x230 <main+0x92>
424
 230:	c3 98       	cbi	0x18, 3	; 24
425
 232:	85 e0       	ldi	r24, 0x05	; 5
426
 234:	8a 95       	dec	r24
427
 236:	f1 f7       	brne	.-4      	; 0x234 <main+0x96>
428
 238:	00 c0       	rjmp	.+0      	; 0x23a <main+0x9c>
429
 
430
      if(bit_is_clear(NES_PIN, OUT))
431
 23a:	b1 99       	sbic	0x16, 1	; 22
432
 23c:	05 c0       	rjmp	.+10     	; 0x248 <main+0xaa>
433
        reportBuffer.B = 1;
434
 23e:	80 91 64 00 	lds	r24, 0x0064
435
 242:	80 61       	ori	r24, 0x10	; 16
436
 244:	80 93 64 00 	sts	0x0064, r24
437
 
438
      STROBE_CLK();
439
 248:	c3 9a       	sbi	0x18, 3	; 24
440
 24a:	95 e0       	ldi	r25, 0x05	; 5
441
 24c:	9a 95       	dec	r25
442
 24e:	f1 f7       	brne	.-4      	; 0x24c <main+0xae>
443
 250:	00 c0       	rjmp	.+0      	; 0x252 <main+0xb4>
444
 252:	c3 98       	cbi	0x18, 3	; 24
445
 254:	a5 e0       	ldi	r26, 0x05	; 5
446
 256:	aa 95       	dec	r26
447
 258:	f1 f7       	brne	.-4      	; 0x256 <main+0xb8>
448
 25a:	00 c0       	rjmp	.+0      	; 0x25c <main+0xbe>
449
 
450
      if(bit_is_clear(NES_PIN, OUT))
451
 25c:	b1 99       	sbic	0x16, 1	; 22
452
 25e:	05 c0       	rjmp	.+10     	; 0x26a <__stack+0xb>
453
        reportBuffer.SELECT = 1;
454
 260:	80 91 64 00 	lds	r24, 0x0064
455
 264:	80 64       	ori	r24, 0x40	; 64
456
 266:	80 93 64 00 	sts	0x0064, r24
457
 
458
      STROBE_CLK();
459
 26a:	c3 9a       	sbi	0x18, 3	; 24
460
 26c:	b5 e0       	ldi	r27, 0x05	; 5
461
 26e:	ba 95       	dec	r27
462
 270:	f1 f7       	brne	.-4      	; 0x26e <__stack+0xf>
463
 272:	00 c0       	rjmp	.+0      	; 0x274 <__stack+0x15>
464
 274:	c3 98       	cbi	0x18, 3	; 24
465
 276:	85 e0       	ldi	r24, 0x05	; 5
466
 278:	8a 95       	dec	r24
467
 27a:	f1 f7       	brne	.-4      	; 0x278 <__stack+0x19>
468
 27c:	00 c0       	rjmp	.+0      	; 0x27e <__stack+0x1f>
469
 
470
      if(bit_is_clear(NES_PIN, OUT))
471
 27e:	b1 99       	sbic	0x16, 1	; 22
472
 280:	05 c0       	rjmp	.+10     	; 0x28c <__stack+0x2d>
473
        reportBuffer.START = 1;
474
 282:	80 91 64 00 	lds	r24, 0x0064
475
 286:	80 68       	ori	r24, 0x80	; 128
476
 288:	80 93 64 00 	sts	0x0064, r24
477
 
478
      STROBE_CLK();
479
 28c:	c3 9a       	sbi	0x18, 3	; 24
480
 28e:	95 e0       	ldi	r25, 0x05	; 5
481
 290:	9a 95       	dec	r25
482
 292:	f1 f7       	brne	.-4      	; 0x290 <__stack+0x31>
483
 294:	00 c0       	rjmp	.+0      	; 0x296 <__stack+0x37>
484
 296:	c3 98       	cbi	0x18, 3	; 24
485
 298:	a5 e0       	ldi	r26, 0x05	; 5
486
 29a:	aa 95       	dec	r26
487
 29c:	f1 f7       	brne	.-4      	; 0x29a <__stack+0x3b>
488
 29e:	00 c0       	rjmp	.+0      	; 0x2a0 <__stack+0x41>
489
 
490
      if(bit_is_clear(NES_PIN, OUT))
491
 2a0:	b1 99       	sbic	0x16, 1	; 22
492
 2a2:	0d c0       	rjmp	.+26     	; 0x2be <__stack+0x5f>
493
        reportBuffer.Y--;
494
 2a4:	90 91 64 00 	lds	r25, 0x0064
495
 2a8:	89 2f       	mov	r24, r25
496
 2aa:	86 95       	lsr	r24
497
 2ac:	86 95       	lsr	r24
498
 2ae:	8d 5f       	subi	r24, 0xFD	; 253
499
 2b0:	83 70       	andi	r24, 0x03	; 3
500
 2b2:	88 0f       	add	r24, r24
501
 2b4:	88 0f       	add	r24, r24
502
 2b6:	93 7f       	andi	r25, 0xF3	; 243
503
 2b8:	98 2b       	or	r25, r24
504
 2ba:	90 93 64 00 	sts	0x0064, r25
505
 
506
      STROBE_CLK();
507
 2be:	c3 9a       	sbi	0x18, 3	; 24
508
 2c0:	b5 e0       	ldi	r27, 0x05	; 5
509
 2c2:	ba 95       	dec	r27
510
 2c4:	f1 f7       	brne	.-4      	; 0x2c2 <__stack+0x63>
511
 2c6:	00 c0       	rjmp	.+0      	; 0x2c8 <__stack+0x69>
512
 2c8:	c3 98       	cbi	0x18, 3	; 24
513
 2ca:	85 e0       	ldi	r24, 0x05	; 5
514
 2cc:	8a 95       	dec	r24
515
 2ce:	f1 f7       	brne	.-4      	; 0x2cc <__stack+0x6d>
516
 2d0:	00 c0       	rjmp	.+0      	; 0x2d2 <__stack+0x73>
517
 
518
      if(bit_is_clear(NES_PIN, OUT))
519
 2d2:	b1 99       	sbic	0x16, 1	; 22
520
 2d4:	0d c0       	rjmp	.+26     	; 0x2f0 <__stack+0x91>
521
        reportBuffer.Y++;
522
 2d6:	90 91 64 00 	lds	r25, 0x0064
523
 2da:	89 2f       	mov	r24, r25
524
 2dc:	86 95       	lsr	r24
525
 2de:	86 95       	lsr	r24
526
 2e0:	8f 5f       	subi	r24, 0xFF	; 255
527
 2e2:	83 70       	andi	r24, 0x03	; 3
528
 2e4:	88 0f       	add	r24, r24
529
 2e6:	88 0f       	add	r24, r24
530
 2e8:	93 7f       	andi	r25, 0xF3	; 243
531
 2ea:	98 2b       	or	r25, r24
532
 2ec:	90 93 64 00 	sts	0x0064, r25
533
 
534
      STROBE_CLK();
535
 2f0:	c3 9a       	sbi	0x18, 3	; 24
536
 2f2:	95 e0       	ldi	r25, 0x05	; 5
537
 2f4:	9a 95       	dec	r25
538
 2f6:	f1 f7       	brne	.-4      	; 0x2f4 <__stack+0x95>
539
 2f8:	00 c0       	rjmp	.+0      	; 0x2fa <__stack+0x9b>
540
 2fa:	c3 98       	cbi	0x18, 3	; 24
541
 2fc:	a5 e0       	ldi	r26, 0x05	; 5
542
 2fe:	aa 95       	dec	r26
543
 300:	f1 f7       	brne	.-4      	; 0x2fe <__stack+0x9f>
544
 302:	00 c0       	rjmp	.+0      	; 0x304 <__stack+0xa5>
545
 
546
      if(bit_is_clear(NES_PIN, OUT))
547
 304:	b1 99       	sbic	0x16, 1	; 22
548
 306:	09 c0       	rjmp	.+18     	; 0x31a <__stack+0xbb>
549
        reportBuffer.X--;
550
 308:	80 91 64 00 	lds	r24, 0x0064
551
 30c:	98 2f       	mov	r25, r24
552
 30e:	9d 5f       	subi	r25, 0xFD	; 253
553
 310:	93 70       	andi	r25, 0x03	; 3
554
 312:	8c 7f       	andi	r24, 0xFC	; 252
555
 314:	89 2b       	or	r24, r25
556
 316:	80 93 64 00 	sts	0x0064, r24
557
 
558
      STROBE_CLK();
559
 31a:	c3 9a       	sbi	0x18, 3	; 24
560
 31c:	b5 e0       	ldi	r27, 0x05	; 5
561
 31e:	ba 95       	dec	r27
562
 320:	f1 f7       	brne	.-4      	; 0x31e <__stack+0xbf>
563
 322:	00 c0       	rjmp	.+0      	; 0x324 <__stack+0xc5>
564
 324:	c3 98       	cbi	0x18, 3	; 24
565
 326:	85 e0       	ldi	r24, 0x05	; 5
566
 328:	8a 95       	dec	r24
567
 32a:	f1 f7       	brne	.-4      	; 0x328 <__stack+0xc9>
568
 32c:	00 c0       	rjmp	.+0      	; 0x32e <__stack+0xcf>
569
 
570
      if(bit_is_clear(NES_PIN, OUT))
571
 32e:	b1 99       	sbic	0x16, 1	; 22
572
 330:	09 c0       	rjmp	.+18     	; 0x344 <__stack+0xe5>
573
        reportBuffer.X++;
574
 332:	80 91 64 00 	lds	r24, 0x0064
575
 336:	98 2f       	mov	r25, r24
576
 338:	9f 5f       	subi	r25, 0xFF	; 255
577
 33a:	93 70       	andi	r25, 0x03	; 3
578
 33c:	8c 7f       	andi	r24, 0xFC	; 252
579
 33e:	89 2b       	or	r24, r25
580
 340:	80 93 64 00 	sts	0x0064, r24
581
 
582
      /* called after every poll of the interrupt endpoint */
583
      usbSetInterrupt(&reportBuffer, sizeof(reportBuffer));
584
 344:	84 e6       	ldi	r24, 0x64	; 100
585
 346:	90 e0       	ldi	r25, 0x00	; 0
586
 348:	61 e0       	ldi	r22, 0x01	; 1
587
 34a:	01 d0       	rcall	.+2      	; 0x34e <usbSetInterrupt>
588
 34c:	56 cf       	rjmp	.-340    	; 0x1fa <main+0x5c>
589
 
590
0000034e <usbSetInterrupt>:
591
    txStatus->len = len + 4;    /* len must be given including sync byte */
592
    DBG2(0x21 + (((int)txStatus >> 3) & 3), txStatus->buffer, len + 3);
593
}
594
 
595
USB_PUBLIC void usbSetInterrupt(uchar *data, uchar len)
596
{
597
 34e:	1f 93       	push	r17
598
 350:	16 2f       	mov	r17, r22
599
 
600
#if USB_CFG_IMPLEMENT_HALT
601
    if(usbTxLen1 == USBPID_STALL)
602
        return;
603
#endif
604
    if(txStatus->len & 0x10){   /* packet buffer was empty */
605
 352:	20 91 70 00 	lds	r18, 0x0070
606
 356:	24 ff       	sbrs	r18, 4
607
 358:	1d c0       	rjmp	.+58     	; 0x394 <usbSetInterrupt+0x46>
608
        txStatus->buffer[0] ^= USBPID_DATA0 ^ USBPID_DATA1; /* toggle token */
609
 35a:	20 91 71 00 	lds	r18, 0x0071
610
 35e:	38 e8       	ldi	r19, 0x88	; 136
611
 360:	23 27       	eor	r18, r19
612
 362:	20 93 71 00 	sts	0x0071, r18
613
    }else{
614
        txStatus->len = USBPID_NAK; /* avoid sending outdated (overwritten) interrupt data */
615
 366:	a8 2f       	mov	r26, r24
616
 368:	b9 2f       	mov	r27, r25
617
    usbCrc16Append(&txStatus->buffer[1], len);
618
    txStatus->len = len + 4;    /* len must be given including sync byte */
619
    DBG2(0x21 + (((int)txStatus >> 3) & 3), txStatus->buffer, len + 3);
620
}
621
 
622
USB_PUBLIC void usbSetInterrupt(uchar *data, uchar len)
623
 36a:	81 2f       	mov	r24, r17
624
 36c:	81 50       	subi	r24, 0x01	; 1
625
 36e:	90 e0       	ldi	r25, 0x00	; 0
626
 370:	8d 58       	subi	r24, 0x8D	; 141
627
 372:	9f 4f       	sbci	r25, 0xFF	; 255
628
 374:	e2 e7       	ldi	r30, 0x72	; 114
629
 376:	f0 e0       	ldi	r31, 0x00	; 0
630
        txStatus->len = USBPID_NAK; /* avoid sending outdated (overwritten) interrupt data */
631
    }
632
    p = txStatus->buffer + 1;
633
    i = len;
634
    do{                         /* if len == 0, we still copy 1 byte, but that's no problem */
635
        *p++ = *data++;
636
 378:	2d 91       	ld	r18, X+
637
 37a:	21 93       	st	Z+, r18
638
    }while(--i > 0);            /* loop control at the end is 2 bytes shorter than at beginning */
639
 37c:	e8 17       	cp	r30, r24
640
 37e:	f9 07       	cpc	r31, r25
641
 380:	d9 f7       	brne	.-10     	; 0x378 <usbSetInterrupt+0x2a>
642
    usbCrc16Append(&txStatus->buffer[1], len);
643
 382:	82 e7       	ldi	r24, 0x72	; 114
644
 384:	90 e0       	ldi	r25, 0x00	; 0
645
 386:	61 2f       	mov	r22, r17
646
 388:	69 d1       	rcall	.+722    	; 0x65c <usbCrc16Append>
647
    txStatus->len = len + 4;    /* len must be given including sync byte */
648
 38a:	1c 5f       	subi	r17, 0xFC	; 252
649
 38c:	10 93 70 00 	sts	0x0070, r17
650
}
651
 
652
USB_PUBLIC void usbSetInterrupt(uchar *data, uchar len)
653
{
654
    usbGenericSetInterrupt(data, len, &usbTxStatus1);
655
}
656
 390:	1f 91       	pop	r17
657
 392:	08 95       	ret
658
        return;
659
#endif
660
    if(txStatus->len & 0x10){   /* packet buffer was empty */
661
        txStatus->buffer[0] ^= USBPID_DATA0 ^ USBPID_DATA1; /* toggle token */
662
    }else{
663
        txStatus->len = USBPID_NAK; /* avoid sending outdated (overwritten) interrupt data */
664
 394:	2a e5       	ldi	r18, 0x5A	; 90
665
 396:	20 93 70 00 	sts	0x0070, r18
666
 39a:	e5 cf       	rjmp	.-54     	; 0x366 <usbSetInterrupt+0x18>
667
 
668
0000039c <usbPoll>:
669
}
670
 
671
/* ------------------------------------------------------------------------- */
672
 
673
USB_PUBLIC void usbPoll(void)
674
{
675
 39c:	1f 93       	push	r17
676
 39e:	cf 93       	push	r28
677
 3a0:	df 93       	push	r29
678
schar   len;
679
uchar   i;
680
 
681
    len = usbRxLen - 3;
682
 3a2:	80 91 81 00 	lds	r24, 0x0081
683
 3a6:	83 50       	subi	r24, 0x03	; 3
684
    if(len >= 0){
685
 3a8:	87 fd       	sbrc	r24, 7
686
 3aa:	09 c0       	rjmp	.+18     	; 0x3be <usbPoll+0x22>
687
 * need data integrity checks with this driver, check the CRC in your app
688
 * code and report errors back to the host. Since the ACK was already sent,
689
 * retries must be handled on application level.
690
 * unsigned crc = usbCrc16(buffer + 1, usbRxLen - 3);
691
 */
692
        usbProcessRx(usbRxBuf + USB_BUFSIZE + 1 - usbInputBufOffset, len);
693
 3ac:	20 91 7e 00 	lds	r18, 0x007E
694
    if(usbRxToken < 0x10){  /* OUT to endpoint != 0: endpoint number in usbRxToken */
695
        usbFunctionWriteOut(data, len);
696
        return;
697
    }
698
#endif
699
    if(usbRxToken == (uchar)USBPID_SETUP){
700
 3b0:	90 91 7d 00 	lds	r25, 0x007D
701
 3b4:	9d 32       	cpi	r25, 0x2D	; 45
702
 3b6:	09 f4       	brne	.+2      	; 0x3ba <usbPoll+0x1e>
703
 3b8:	5d c0       	rjmp	.+186    	; 0x474 <usbPoll+0xd8>
704
        usbProcessRx(usbRxBuf + USB_BUFSIZE + 1 - usbInputBufOffset, len);
705
#if USB_CFG_HAVE_FLOWCONTROL
706
        if(usbRxLen > 0)    /* only mark as available if not inactivated */
707
            usbRxLen = 0;
708
#else
709
        usbRxLen = 0;       /* mark rx buffer as available */
710
 3ba:	10 92 81 00 	sts	0x0081, r1
711
#endif
712
    }
713
    if(usbTxLen & 0x10){    /* transmit system idle */
714
 3be:	80 91 60 00 	lds	r24, 0x0060
715
 3c2:	84 ff       	sbrs	r24, 4
716
 3c4:	39 c0       	rjmp	.+114    	; 0x438 <usbPoll+0x9c>
717
        if(usbMsgLen != USB_NO_MSG){    /* transmit data pending? */
718
 3c6:	60 91 61 00 	lds	r22, 0x0061
719
 3ca:	6f 3f       	cpi	r22, 0xFF	; 255
720
 3cc:	a9 f1       	breq	.+106    	; 0x438 <usbPoll+0x9c>
721
{
722
usbMsgLen_t wantLen;
723
uchar       len;
724
 
725
    wantLen = usbMsgLen;
726
    if(wantLen > 8)
727
 3ce:	69 30       	cpi	r22, 0x09	; 9
728
 3d0:	08 f4       	brcc	.+2      	; 0x3d4 <usbPoll+0x38>
729
 3d2:	7d c0       	rjmp	.+250    	; 0x4ce <usbPoll+0x132>
730
        wantLen = 8;
731
    usbMsgLen -= wantLen;
732
 3d4:	68 50       	subi	r22, 0x08	; 8
733
 3d6:	60 93 61 00 	sts	0x0061, r22
734
    usbTxBuf[0] ^= USBPID_DATA0 ^ USBPID_DATA1; /* DATA toggling */
735
 3da:	80 91 65 00 	lds	r24, 0x0065
736
 3de:	98 e8       	ldi	r25, 0x88	; 136
737
 3e0:	89 27       	eor	r24, r25
738
 3e2:	80 93 65 00 	sts	0x0065, r24
739
 3e6:	1c e0       	ldi	r17, 0x0C	; 12
740
usbMsgLen_t wantLen;
741
uchar       len;
742
 
743
    wantLen = usbMsgLen;
744
    if(wantLen > 8)
745
        wantLen = 8;
746
 3e8:	68 e0       	ldi	r22, 0x08	; 8
747
        if(usbMsgFlags & USB_FLG_USE_USER_RW){
748
            len = usbFunctionRead(data, len);
749
        }else
750
#endif
751
        {
752
            uchar i = len, *r = usbMsgPtr;
753
 3ea:	20 91 7f 00 	lds	r18, 0x007F
754
 3ee:	30 91 80 00 	lds	r19, 0x0080
755
            if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){    /* ROM data */
756
 3f2:	80 91 62 00 	lds	r24, 0x0062
757
 3f6:	86 ff       	sbrs	r24, 6
758
 3f8:	80 c0       	rjmp	.+256    	; 0x4fa <usbPoll+0x15e>
759
#endif
760
}
761
 
762
/* ------------------------------------------------------------------------- */
763
 
764
USB_PUBLIC void usbPoll(void)
765
 3fa:	46 2f       	mov	r20, r22
766
 3fc:	41 50       	subi	r20, 0x01	; 1
767
 3fe:	50 e0       	ldi	r21, 0x00	; 0
768
 400:	ca 01       	movw	r24, r20
769
 402:	89 59       	subi	r24, 0x99	; 153
770
 404:	9f 4f       	sbci	r25, 0xFF	; 255
771
 406:	f9 01       	movw	r30, r18
772
 408:	a6 e6       	ldi	r26, 0x66	; 102
773
 40a:	b0 e0       	ldi	r27, 0x00	; 0
774
#endif
775
        {
776
            uchar i = len, *r = usbMsgPtr;
777
            if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){    /* ROM data */
778
                do{
779
                    uchar c = USB_READ_FLASH(r);    /* assign to char size variable to enforce byte ops */
780
 40c:	74 91       	lpm	r23, Z+
781
                    *data++ = c;
782
 40e:	7d 93       	st	X+, r23
783
                    r++;
784
 410:	31 96       	adiw	r30, 0x01	; 1
785
                }while(--i);
786
 412:	a8 17       	cp	r26, r24
787
 414:	b9 07       	cpc	r27, r25
788
 416:	d1 f7       	brne	.-12     	; 0x40c <usbPoll+0x70>
789
#endif
790
}
791
 
792
/* ------------------------------------------------------------------------- */
793
 
794
USB_PUBLIC void usbPoll(void)
795
 418:	4f 5f       	subi	r20, 0xFF	; 255
796
 41a:	5f 4f       	sbci	r21, 0xFF	; 255
797
                    r++;
798
                }while(--i);
799
            }else{  /* RAM data */
800
                do{
801
                    *data++ = *r++;
802
                }while(--i);
803
 41c:	42 0f       	add	r20, r18
804
 41e:	53 1f       	adc	r21, r19
805
            }
806
            usbMsgPtr = r;
807
 420:	50 93 80 00 	sts	0x0080, r21
808
 424:	40 93 7f 00 	sts	0x007F, r20
809
        wantLen = 8;
810
    usbMsgLen -= wantLen;
811
    usbTxBuf[0] ^= USBPID_DATA0 ^ USBPID_DATA1; /* DATA toggling */
812
    len = usbDeviceRead(usbTxBuf + 1, wantLen);
813
    if(len <= 8){           /* valid data packet */
814
        usbCrc16Append(&usbTxBuf[1], len);
815
 428:	86 e6       	ldi	r24, 0x66	; 102
816
 42a:	90 e0       	ldi	r25, 0x00	; 0
817
 42c:	17 d1       	rcall	.+558    	; 0x65c <usbCrc16Append>
818
        len += 4;           /* length including sync byte */
819
        if(len < 12)        /* a partial package identifies end of message */
820
 42e:	1c 30       	cpi	r17, 0x0C	; 12
821
 430:	09 f0       	breq	.+2      	; 0x434 <usbPoll+0x98>
822
 432:	5d c0       	rjmp	.+186    	; 0x4ee <usbPoll+0x152>
823
            usbMsgLen = USB_NO_MSG;
824
    }else{
825
        len = USBPID_STALL;   /* stall the endpoint */
826
        usbMsgLen = USB_NO_MSG;
827
    }
828
    usbTxLen = len;
829
 434:	10 93 60 00 	sts	0x0060, r17
830
    if(usbTxLen & 0x10){    /* transmit system idle */
831
        if(usbMsgLen != USB_NO_MSG){    /* transmit data pending? */
832
            usbBuildTxBlock();
833
        }
834
    }
835
    for(i = 20; i > 0; i--){
836
 438:	94 e1       	ldi	r25, 0x14	; 20
837
        uchar usbLineStatus = USBIN & USBMASK;
838
 43a:	86 b3       	in	r24, 0x16	; 22
839
 43c:	85 70       	andi	r24, 0x05	; 5
840
        if(usbLineStatus != 0)  /* SE0 has ended */
841
 43e:	99 f4       	brne	.+38     	; 0x466 <usbPoll+0xca>
842
    if(usbTxLen & 0x10){    /* transmit system idle */
843
        if(usbMsgLen != USB_NO_MSG){    /* transmit data pending? */
844
            usbBuildTxBlock();
845
        }
846
    }
847
    for(i = 20; i > 0; i--){
848
 440:	91 50       	subi	r25, 0x01	; 1
849
 442:	d9 f7       	brne	.-10     	; 0x43a <usbPoll+0x9e>
850
        uchar usbLineStatus = USBIN & USBMASK;
851
        if(usbLineStatus != 0)  /* SE0 has ended */
852
            goto isNotReset;
853
    }
854
    /* RESET condition, called multiple times during reset */
855
    usbNewDeviceAddr = 0;
856
 444:	10 92 82 00 	sts	0x0082, r1
857
    usbDeviceAddr = 0;
858
 448:	10 92 7c 00 	sts	0x007C, r1
859
 44c:	11 e0       	ldi	r17, 0x01	; 1
860
{
861
#ifdef USB_RESET_HOOK
862
static uchar    wasReset;
863
uchar           isReset = !notResetState;
864
 
865
    if(wasReset != isReset){
866
 44e:	80 91 63 00 	lds	r24, 0x0063
867
 452:	18 17       	cp	r17, r24
868
 454:	21 f0       	breq	.+8      	; 0x45e <usbPoll+0xc2>
869
        USB_RESET_HOOK(isReset);
870
 456:	11 23       	and	r17, r17
871
 458:	59 f0       	breq	.+22     	; 0x470 <usbPoll+0xd4>
872
        wasReset = isReset;
873
 45a:	10 93 63 00 	sts	0x0063, r17
874
    usbDeviceAddr = 0;
875
    usbResetStall();
876
    DBG1(0xff, 0, 0);
877
isNotReset:
878
    usbHandleResetHook(i);
879
}
880
 45e:	df 91       	pop	r29
881
 460:	cf 91       	pop	r28
882
 462:	1f 91       	pop	r17
883
 464:	08 95       	ret
884
            usbBuildTxBlock();
885
        }
886
    }
887
    for(i = 20; i > 0; i--){
888
        uchar usbLineStatus = USBIN & USBMASK;
889
        if(usbLineStatus != 0)  /* SE0 has ended */
890
 466:	11 e0       	ldi	r17, 0x01	; 1
891
 468:	99 23       	and	r25, r25
892
 46a:	89 f3       	breq	.-30     	; 0x44e <usbPoll+0xb2>
893
 46c:	10 e0       	ldi	r17, 0x00	; 0
894
 46e:	ef cf       	rjmp	.-34     	; 0x44e <usbPoll+0xb2>
895
#ifdef USB_RESET_HOOK
896
static uchar    wasReset;
897
uchar           isReset = !notResetState;
898
 
899
    if(wasReset != isReset){
900
        USB_RESET_HOOK(isReset);
901
 470:	44 de       	rcall	.-888    	; 0xfa <hadUsbReset>
902
 472:	f3 cf       	rjmp	.-26     	; 0x45a <usbPoll+0xbe>
903
        usbFunctionWriteOut(data, len);
904
        return;
905
    }
906
#endif
907
    if(usbRxToken == (uchar)USBPID_SETUP){
908
        if(len != 8)    /* Setup size must be always 8 bytes. Ignore otherwise. */
909
 474:	88 30       	cpi	r24, 0x08	; 8
910
 476:	09 f0       	breq	.+2      	; 0x47a <usbPoll+0xde>
911
 478:	a0 cf       	rjmp	.-192    	; 0x3ba <usbPoll+0x1e>
912
 * need data integrity checks with this driver, check the CRC in your app
913
 * code and report errors back to the host. Since the ACK was already sent,
914
 * retries must be handled on application level.
915
 * unsigned crc = usbCrc16(buffer + 1, usbRxLen - 3);
916
 */
917
        usbProcessRx(usbRxBuf + USB_BUFSIZE + 1 - usbInputBufOffset, len);
918
 47a:	cc e0       	ldi	r28, 0x0C	; 12
919
 47c:	d0 e0       	ldi	r29, 0x00	; 0
920
 47e:	c2 1b       	sub	r28, r18
921
 480:	d1 09       	sbc	r29, r1
922
 482:	cb 57       	subi	r28, 0x7B	; 123
923
 484:	df 4f       	sbci	r29, 0xFF	; 255
924
#endif
925
    if(usbRxToken == (uchar)USBPID_SETUP){
926
        if(len != 8)    /* Setup size must be always 8 bytes. Ignore otherwise. */
927
            return;
928
        usbMsgLen_t replyLen;
929
        usbTxBuf[0] = USBPID_DATA0;         /* initialize data toggling */
930
 486:	83 ec       	ldi	r24, 0xC3	; 195
931
 488:	80 93 65 00 	sts	0x0065, r24
932
        usbTxLen = USBPID_NAK;              /* abort pending transmit */
933
 48c:	8a e5       	ldi	r24, 0x5A	; 90
934
 48e:	80 93 60 00 	sts	0x0060, r24
935
        usbMsgFlags = 0;
936
 492:	10 92 62 00 	sts	0x0062, r1
937
        uchar type = rq->bmRequestType & USBRQ_TYPE_MASK;
938
 496:	88 81       	ld	r24, Y
939
 498:	80 76       	andi	r24, 0x60	; 96
940
        if(type != USBRQ_TYPE_STANDARD){    /* standard requests are handled by driver */
941
 49a:	f1 f5       	brne	.+124    	; 0x518 <usbPoll+0x17c>
942
 */
943
static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq)
944
{
945
usbMsgLen_t len = 0;
946
uchar   *dataPtr = usbTxBuf + 9;    /* there are 2 bytes free space at the end of the buffer */
947
uchar   value = rq->wValue.bytes[0];
948
 49c:	9a 81       	ldd	r25, Y+2	; 0x02
949
#if USB_CFG_IMPLEMENT_HALT
950
uchar   index = rq->wIndex.bytes[0];
951
#endif
952
 
953
    dataPtr[0] = 0; /* default reply common to USBRQ_GET_STATUS and USBRQ_GET_INTERFACE */
954
 49e:	10 92 6e 00 	sts	0x006E, r1
955
    SWITCH_START(rq->bRequest)
956
 4a2:	89 81       	ldd	r24, Y+1	; 0x01
957
    SWITCH_CASE(USBRQ_GET_STATUS)           /* 0 */
958
 4a4:	88 23       	and	r24, r24
959
 4a6:	d9 f5       	brne	.+118    	; 0x51e <usbPoll+0x182>
960
            dataPtr[0] =  USB_CFG_IS_SELF_POWERED;
961
#if USB_CFG_IMPLEMENT_HALT
962
        if(recipient == USBRQ_RCPT_ENDPOINT && index == 0x81)   /* request status for endpoint 1 */
963
            dataPtr[0] = usbTxLen1 == USBPID_STALL;
964
#endif
965
        dataPtr[1] = 0;
966
 4a8:	10 92 6f 00 	sts	0x006F, r1
967
 * standard requests instead of class and custom requests.
968
 */
969
static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq)
970
{
971
usbMsgLen_t len = 0;
972
uchar   *dataPtr = usbTxBuf + 9;    /* there are 2 bytes free space at the end of the buffer */
973
 4ac:	2e e6       	ldi	r18, 0x6E	; 110
974
 4ae:	30 e0       	ldi	r19, 0x00	; 0
975
#if USB_CFG_IMPLEMENT_HALT
976
        if(recipient == USBRQ_RCPT_ENDPOINT && index == 0x81)   /* request status for endpoint 1 */
977
            dataPtr[0] = usbTxLen1 == USBPID_STALL;
978
#endif
979
        dataPtr[1] = 0;
980
        len = 2;
981
 4b0:	82 e0       	ldi	r24, 0x02	; 2
982
        usbResetStall();
983
#endif
984
    SWITCH_DEFAULT                          /* 7=SET_DESCRIPTOR, 12=SYNC_FRAME */
985
        /* Should we add an optional hook here? */
986
    SWITCH_END
987
    usbMsgPtr = dataPtr;
988
 4b2:	30 93 80 00 	sts	0x0080, r19
989
 4b6:	20 93 7f 00 	sts	0x007F, r18
990
            }
991
            usbMsgFlags = USB_FLG_USE_USER_RW;
992
        }else   /* The 'else' prevents that we limit a replyLen of USB_NO_MSG to the maximum transfer len. */
993
#endif
994
        if(sizeof(replyLen) < sizeof(rq->wLength.word)){ /* help compiler with optimizing */
995
            if(!rq->wLength.bytes[1] && replyLen > rq->wLength.bytes[0])    /* limit length to max */
996
 4ba:	9f 81       	ldd	r25, Y+7	; 0x07
997
 4bc:	99 23       	and	r25, r25
998
 4be:	21 f4       	brne	.+8      	; 0x4c8 <usbPoll+0x12c>
999
 4c0:	9e 81       	ldd	r25, Y+6	; 0x06
1000
 4c2:	98 17       	cp	r25, r24
1001
 4c4:	08 f4       	brcc	.+2      	; 0x4c8 <usbPoll+0x12c>
1002
 4c6:	89 2f       	mov	r24, r25
1003
                replyLen = rq->wLength.bytes[0];
1004
        }else{
1005
            if(replyLen > rq->wLength.word)     /* limit length to max */
1006
                replyLen = rq->wLength.word;
1007
        }
1008
        usbMsgLen = replyLen;
1009
 4c8:	80 93 61 00 	sts	0x0061, r24
1010
 4cc:	76 cf       	rjmp	.-276    	; 0x3ba <usbPoll+0x1e>
1011
uchar       len;
1012
 
1013
    wantLen = usbMsgLen;
1014
    if(wantLen > 8)
1015
        wantLen = 8;
1016
    usbMsgLen -= wantLen;
1017
 4ce:	10 92 61 00 	sts	0x0061, r1
1018
    usbTxBuf[0] ^= USBPID_DATA0 ^ USBPID_DATA1; /* DATA toggling */
1019
 4d2:	80 91 65 00 	lds	r24, 0x0065
1020
 4d6:	98 e8       	ldi	r25, 0x88	; 136
1021
 4d8:	89 27       	eor	r24, r25
1022
 4da:	80 93 65 00 	sts	0x0065, r24
1023
/* This function is similar to usbFunctionRead(), but it's also called for
1024
 * data handled automatically by the driver (e.g. descriptor reads).
1025
 */
1026
static uchar usbDeviceRead(uchar *data, uchar len)
1027
{
1028
    if(len > 0){    /* don't bother app with 0 sized reads */
1029
 4de:	66 23       	and	r22, r22
1030
 4e0:	09 f0       	breq	.+2      	; 0x4e4 <usbPoll+0x148>
1031
 4e2:	82 c0       	rjmp	.+260    	; 0x5e8 <usbPoll+0x24c>
1032
        wantLen = 8;
1033
    usbMsgLen -= wantLen;
1034
    usbTxBuf[0] ^= USBPID_DATA0 ^ USBPID_DATA1; /* DATA toggling */
1035
    len = usbDeviceRead(usbTxBuf + 1, wantLen);
1036
    if(len <= 8){           /* valid data packet */
1037
        usbCrc16Append(&usbTxBuf[1], len);
1038
 4e4:	86 e6       	ldi	r24, 0x66	; 102
1039
 4e6:	90 e0       	ldi	r25, 0x00	; 0
1040
 4e8:	60 e0       	ldi	r22, 0x00	; 0
1041
 4ea:	b8 d0       	rcall	.+368    	; 0x65c <usbCrc16Append>
1042
        len += 4;           /* length including sync byte */
1043
 4ec:	14 e0       	ldi	r17, 0x04	; 4
1044
        if(len < 12)        /* a partial package identifies end of message */
1045
            usbMsgLen = USB_NO_MSG;
1046
 4ee:	8f ef       	ldi	r24, 0xFF	; 255
1047
 4f0:	80 93 61 00 	sts	0x0061, r24
1048
    }else{
1049
        len = USBPID_STALL;   /* stall the endpoint */
1050
        usbMsgLen = USB_NO_MSG;
1051
    }
1052
    usbTxLen = len;
1053
 4f4:	10 93 60 00 	sts	0x0060, r17
1054
 4f8:	9f cf       	rjmp	.-194    	; 0x438 <usbPoll+0x9c>
1055
            if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){    /* ROM data */
1056
                do{
1057
                    uchar c = USB_READ_FLASH(r);    /* assign to char size variable to enforce byte ops */
1058
                    *data++ = c;
1059
                    r++;
1060
                }while(--i);
1061
 4fa:	d9 01       	movw	r26, r18
1062
#endif
1063
}
1064
 
1065
/* ------------------------------------------------------------------------- */
1066
 
1067
USB_PUBLIC void usbPoll(void)
1068
 4fc:	46 2f       	mov	r20, r22
1069
 4fe:	41 50       	subi	r20, 0x01	; 1
1070
 500:	50 e0       	ldi	r21, 0x00	; 0
1071
 502:	ca 01       	movw	r24, r20
1072
 504:	89 59       	subi	r24, 0x99	; 153
1073
 506:	9f 4f       	sbci	r25, 0xFF	; 255
1074
 508:	e6 e6       	ldi	r30, 0x66	; 102
1075
 50a:	f0 e0       	ldi	r31, 0x00	; 0
1076
                    *data++ = c;
1077
                    r++;
1078
                }while(--i);
1079
            }else{  /* RAM data */
1080
                do{
1081
                    *data++ = *r++;
1082
 50c:	7d 91       	ld	r23, X+
1083
 50e:	71 93       	st	Z+, r23
1084
                }while(--i);
1085
 510:	e8 17       	cp	r30, r24
1086
 512:	f9 07       	cpc	r31, r25
1087
 514:	d9 f7       	brne	.-10     	; 0x50c <usbPoll+0x170>
1088
 516:	80 cf       	rjmp	.-256    	; 0x418 <usbPoll+0x7c>
1089
        usbTxBuf[0] = USBPID_DATA0;         /* initialize data toggling */
1090
        usbTxLen = USBPID_NAK;              /* abort pending transmit */
1091
        usbMsgFlags = 0;
1092
        uchar type = rq->bmRequestType & USBRQ_TYPE_MASK;
1093
        if(type != USBRQ_TYPE_STANDARD){    /* standard requests are handled by driver */
1094
            replyLen = usbFunctionSetup(data);
1095
 518:	ce 01       	movw	r24, r28
1096
 51a:	ed dd       	rcall	.-1062   	; 0xf6 <usbFunctionSetup>
1097
 51c:	ce cf       	rjmp	.-100    	; 0x4ba <usbPoll+0x11e>
1098
        if(value == 0 && index == 0x81){    /* feature 0 == HALT for endpoint == 1 */
1099
            usbTxLen1 = rq->bRequest == USBRQ_CLEAR_FEATURE ? USBPID_NAK : USBPID_STALL;
1100
            usbResetDataToggling();
1101
        }
1102
#endif
1103
    SWITCH_CASE(USBRQ_SET_ADDRESS)          /* 5 */
1104
 51e:	85 30       	cpi	r24, 0x05	; 5
1105
 520:	71 f0       	breq	.+28     	; 0x53e <usbPoll+0x1a2>
1106
        usbNewDeviceAddr = value;
1107
        USB_SET_ADDRESS_HOOK();
1108
    SWITCH_CASE(USBRQ_GET_DESCRIPTOR)       /* 6 */
1109
 522:	86 30       	cpi	r24, 0x06	; 6
1110
 524:	91 f0       	breq	.+36     	; 0x54a <usbPoll+0x1ae>
1111
        len = usbDriverDescriptor(rq);
1112
        goto skipMsgPtrAssignment;
1113
    SWITCH_CASE(USBRQ_GET_CONFIGURATION)    /* 8 */
1114
 526:	88 30       	cpi	r24, 0x08	; 8
1115
 528:	01 f1       	breq	.+64     	; 0x56a <usbPoll+0x1ce>
1116
        dataPtr = &usbConfiguration;  /* send current configuration value */
1117
        len = 1;
1118
    SWITCH_CASE(USBRQ_SET_CONFIGURATION)    /* 9 */
1119
 52a:	89 30       	cpi	r24, 0x09	; 9
1120
 52c:	11 f1       	breq	.+68     	; 0x572 <usbPoll+0x1d6>
1121
        usbConfiguration = value;
1122
        usbResetStall();
1123
    SWITCH_CASE(USBRQ_GET_INTERFACE)        /* 10 */
1124
 52e:	8a 30       	cpi	r24, 0x0A	; 10
1125
 530:	71 f1       	breq	.+92     	; 0x58e <usbPoll+0x1f2>
1126
        len = 1;
1127
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
1128
    SWITCH_CASE(USBRQ_SET_INTERFACE)        /* 11 */
1129
 532:	8b 30       	cpi	r24, 0x0B	; 11
1130
 534:	81 f1       	breq	.+96     	; 0x596 <usbPoll+0x1fa>
1131
 * standard requests instead of class and custom requests.
1132
 */
1133
static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq)
1134
{
1135
usbMsgLen_t len = 0;
1136
uchar   *dataPtr = usbTxBuf + 9;    /* there are 2 bytes free space at the end of the buffer */
1137
 536:	2e e6       	ldi	r18, 0x6E	; 110
1138
 538:	30 e0       	ldi	r19, 0x00	; 0
1139
/* usbDriverSetup() is similar to usbFunctionSetup(), but it's used for
1140
 * standard requests instead of class and custom requests.
1141
 */
1142
static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq)
1143
{
1144
usbMsgLen_t len = 0;
1145
 53a:	80 e0       	ldi	r24, 0x00	; 0
1146
 53c:	ba cf       	rjmp	.-140    	; 0x4b2 <usbPoll+0x116>
1147
            usbTxLen1 = rq->bRequest == USBRQ_CLEAR_FEATURE ? USBPID_NAK : USBPID_STALL;
1148
            usbResetDataToggling();
1149
        }
1150
#endif
1151
    SWITCH_CASE(USBRQ_SET_ADDRESS)          /* 5 */
1152
        usbNewDeviceAddr = value;
1153
 53e:	90 93 82 00 	sts	0x0082, r25
1154
 * standard requests instead of class and custom requests.
1155
 */
1156
static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq)
1157
{
1158
usbMsgLen_t len = 0;
1159
uchar   *dataPtr = usbTxBuf + 9;    /* there are 2 bytes free space at the end of the buffer */
1160
 542:	2e e6       	ldi	r18, 0x6E	; 110
1161
 544:	30 e0       	ldi	r19, 0x00	; 0
1162
/* usbDriverSetup() is similar to usbFunctionSetup(), but it's used for
1163
 * standard requests instead of class and custom requests.
1164
 */
1165
static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq)
1166
{
1167
usbMsgLen_t len = 0;
1168
 546:	80 e0       	ldi	r24, 0x00	; 0
1169
 548:	b4 cf       	rjmp	.-152    	; 0x4b2 <usbPoll+0x116>
1170
    usbTxLen1 = USBPID_NAK;
1171
#if USB_CFG_HAVE_INTRIN_ENDPOINT3
1172
    usbTxLen3 = USBPID_NAK;
1173
#endif
1174
#endif
1175
}
1176
 54a:	8b 81       	ldd	r24, Y+3	; 0x03
1177
{
1178
usbMsgLen_t len = 0;
1179
uchar       flags = USB_FLG_MSGPTR_IS_ROM;
1180
 
1181
    SWITCH_START(rq->wValue.bytes[1])
1182
    SWITCH_CASE(USBDESCR_DEVICE)    /* 1 */
1183
 54c:	81 30       	cpi	r24, 0x01	; 1
1184
 54e:	b9 f0       	breq	.+46     	; 0x57e <usbPoll+0x1e2>
1185
        GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_DEVICE, usbDescriptorDevice)
1186
    SWITCH_CASE(USBDESCR_CONFIG)    /* 2 */
1187
 550:	82 30       	cpi	r24, 0x02	; 2
1188
 552:	91 f1       	breq	.+100    	; 0x5b8 <usbPoll+0x21c>
1189
        GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_CONFIGURATION, usbDescriptorConfiguration)
1190
    SWITCH_CASE(USBDESCR_STRING)    /* 3 */
1191
 554:	83 30       	cpi	r24, 0x03	; 3
1192
 556:	31 f1       	breq	.+76     	; 0x5a4 <usbPoll+0x208>
1193
                len = usbFunctionDescriptor(rq);
1194
            }
1195
        SWITCH_END
1196
#endif  /* USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC */
1197
#if USB_CFG_DESCR_PROPS_HID_REPORT  /* only support HID descriptors if enabled */
1198
    SWITCH_CASE(USBDESCR_HID)       /* 0x21 */
1199
 558:	81 32       	cpi	r24, 0x21	; 33
1200
 55a:	f1 f1       	breq	.+124    	; 0x5d8 <usbPoll+0x23c>
1201
        GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_HID, usbDescriptorConfiguration + 18)
1202
    SWITCH_CASE(USBDESCR_HID_REPORT)/* 0x22 */
1203
 55c:	82 32       	cpi	r24, 0x22	; 34
1204
 55e:	a1 f1       	breq	.+104    	; 0x5c8 <usbPoll+0x22c>
1205
/* usbDriverDescriptor() is similar to usbFunctionDescriptor(), but used
1206
 * internally for all types of descriptors.
1207
 */
1208
static inline usbMsgLen_t usbDriverDescriptor(usbRequest_t *rq)
1209
{
1210
usbMsgLen_t len = 0;
1211
 560:	80 e0       	ldi	r24, 0x00	; 0
1212
    SWITCH_DEFAULT
1213
        if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_DYNAMIC){
1214
            len = usbFunctionDescriptor(rq);
1215
        }
1216
    SWITCH_END
1217
    usbMsgFlags = flags;
1218
 562:	90 e4       	ldi	r25, 0x40	; 64
1219
 564:	90 93 62 00 	sts	0x0062, r25
1220
 568:	a8 cf       	rjmp	.-176    	; 0x4ba <usbPoll+0x11e>
1221
        USB_SET_ADDRESS_HOOK();
1222
    SWITCH_CASE(USBRQ_GET_DESCRIPTOR)       /* 6 */
1223
        len = usbDriverDescriptor(rq);
1224
        goto skipMsgPtrAssignment;
1225
    SWITCH_CASE(USBRQ_GET_CONFIGURATION)    /* 8 */
1226
        dataPtr = &usbConfiguration;  /* send current configuration value */
1227
 56a:	24 e8       	ldi	r18, 0x84	; 132
1228
 56c:	30 e0       	ldi	r19, 0x00	; 0
1229
        len = 1;
1230
 56e:	81 e0       	ldi	r24, 0x01	; 1
1231
 570:	a0 cf       	rjmp	.-192    	; 0x4b2 <usbPoll+0x116>
1232
    SWITCH_CASE(USBRQ_SET_CONFIGURATION)    /* 9 */
1233
        usbConfiguration = value;
1234
 572:	90 93 84 00 	sts	0x0084, r25
1235
 * standard requests instead of class and custom requests.
1236
 */
1237
static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq)
1238
{
1239
usbMsgLen_t len = 0;
1240
uchar   *dataPtr = usbTxBuf + 9;    /* there are 2 bytes free space at the end of the buffer */
1241
 576:	2e e6       	ldi	r18, 0x6E	; 110
1242
 578:	30 e0       	ldi	r19, 0x00	; 0
1243
/* usbDriverSetup() is similar to usbFunctionSetup(), but it's used for
1244
 * standard requests instead of class and custom requests.
1245
 */
1246
static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq)
1247
{
1248
usbMsgLen_t len = 0;
1249
 57a:	80 e0       	ldi	r24, 0x00	; 0
1250
 57c:	9a cf       	rjmp	.-204    	; 0x4b2 <usbPoll+0x116>
1251
usbMsgLen_t len = 0;
1252
uchar       flags = USB_FLG_MSGPTR_IS_ROM;
1253
 
1254
    SWITCH_START(rq->wValue.bytes[1])
1255
    SWITCH_CASE(USBDESCR_DEVICE)    /* 1 */
1256
        GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_DEVICE, usbDescriptorDevice)
1257
 57e:	8a e8       	ldi	r24, 0x8A	; 138
1258
 580:	90 e0       	ldi	r25, 0x00	; 0
1259
 582:	90 93 80 00 	sts	0x0080, r25
1260
 586:	80 93 7f 00 	sts	0x007F, r24
1261
 58a:	82 e1       	ldi	r24, 0x12	; 18
1262
 58c:	ea cf       	rjmp	.-44     	; 0x562 <usbPoll+0x1c6>
1263
 * standard requests instead of class and custom requests.
1264
 */
1265
static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq)
1266
{
1267
usbMsgLen_t len = 0;
1268
uchar   *dataPtr = usbTxBuf + 9;    /* there are 2 bytes free space at the end of the buffer */
1269
 58e:	2e e6       	ldi	r18, 0x6E	; 110
1270
 590:	30 e0       	ldi	r19, 0x00	; 0
1271
        len = 1;
1272
    SWITCH_CASE(USBRQ_SET_CONFIGURATION)    /* 9 */
1273
        usbConfiguration = value;
1274
        usbResetStall();
1275
    SWITCH_CASE(USBRQ_GET_INTERFACE)        /* 10 */
1276
        len = 1;
1277
 592:	81 e0       	ldi	r24, 0x01	; 1
1278
 594:	8e cf       	rjmp	.-228    	; 0x4b2 <usbPoll+0x116>
1279
/* ------------------------------------------------------------------------- */
1280
 
1281
static inline void  usbResetDataToggling(void)
1282
{
1283
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
1284
    USB_SET_DATATOKEN1(USB_INITIAL_DATATOKEN);  /* reset data toggling for interrupt endpoint */
1285
 596:	8b e4       	ldi	r24, 0x4B	; 75
1286
 598:	80 93 71 00 	sts	0x0071, r24
1287
 * standard requests instead of class and custom requests.
1288
 */
1289
static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq)
1290
{
1291
usbMsgLen_t len = 0;
1292
uchar   *dataPtr = usbTxBuf + 9;    /* there are 2 bytes free space at the end of the buffer */
1293
 59c:	2e e6       	ldi	r18, 0x6E	; 110
1294
 59e:	30 e0       	ldi	r19, 0x00	; 0
1295
/* usbDriverSetup() is similar to usbFunctionSetup(), but it's used for
1296
 * standard requests instead of class and custom requests.
1297
 */
1298
static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq)
1299
{
1300
usbMsgLen_t len = 0;
1301
 5a0:	80 e0       	ldi	r24, 0x00	; 0
1302
 5a2:	87 cf       	rjmp	.-242    	; 0x4b2 <usbPoll+0x116>
1303
        if(USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_RAM)
1304
            flags = 0;
1305
        len = usbFunctionDescriptor(rq);
1306
#else   /* USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC */
1307
        SWITCH_START(rq->wValue.bytes[0])
1308
        SWITCH_CASE(0)
1309
 5a4:	99 23       	and	r25, r25
1310
 5a6:	19 f5       	brne	.+70     	; 0x5ee <usbPoll+0x252>
1311
            GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_0, usbDescriptorString0)
1312
 5a8:	88 e4       	ldi	r24, 0x48	; 72
1313
 5aa:	90 e0       	ldi	r25, 0x00	; 0
1314
 5ac:	90 93 80 00 	sts	0x0080, r25
1315
 5b0:	80 93 7f 00 	sts	0x007F, r24
1316
 5b4:	84 e0       	ldi	r24, 0x04	; 4
1317
 5b6:	d5 cf       	rjmp	.-86     	; 0x562 <usbPoll+0x1c6>
1318
 
1319
    SWITCH_START(rq->wValue.bytes[1])
1320
    SWITCH_CASE(USBDESCR_DEVICE)    /* 1 */
1321
        GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_DEVICE, usbDescriptorDevice)
1322
    SWITCH_CASE(USBDESCR_CONFIG)    /* 2 */
1323
        GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_CONFIGURATION, usbDescriptorConfiguration)
1324
 5b8:	8c e9       	ldi	r24, 0x9C	; 156
1325
 5ba:	90 e0       	ldi	r25, 0x00	; 0
1326
 5bc:	90 93 80 00 	sts	0x0080, r25
1327
 5c0:	80 93 7f 00 	sts	0x007F, r24
1328
 5c4:	82 e2       	ldi	r24, 0x22	; 34
1329
 5c6:	cd cf       	rjmp	.-102    	; 0x562 <usbPoll+0x1c6>
1330
#endif  /* USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC */
1331
#if USB_CFG_DESCR_PROPS_HID_REPORT  /* only support HID descriptors if enabled */
1332
    SWITCH_CASE(USBDESCR_HID)       /* 0x21 */
1333
        GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_HID, usbDescriptorConfiguration + 18)
1334
    SWITCH_CASE(USBDESCR_HID_REPORT)/* 0x22 */
1335
        GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_HID_REPORT, usbDescriptorHidReport)
1336
 5c8:	8e e1       	ldi	r24, 0x1E	; 30
1337
 5ca:	90 e0       	ldi	r25, 0x00	; 0
1338
 5cc:	90 93 80 00 	sts	0x0080, r25
1339
 5d0:	80 93 7f 00 	sts	0x007F, r24
1340
 5d4:	8a e2       	ldi	r24, 0x2A	; 42
1341
 5d6:	c5 cf       	rjmp	.-118    	; 0x562 <usbPoll+0x1c6>
1342
            }
1343
        SWITCH_END
1344
#endif  /* USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC */
1345
#if USB_CFG_DESCR_PROPS_HID_REPORT  /* only support HID descriptors if enabled */
1346
    SWITCH_CASE(USBDESCR_HID)       /* 0x21 */
1347
        GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_HID, usbDescriptorConfiguration + 18)
1348
 5d8:	8e ea       	ldi	r24, 0xAE	; 174
1349
 5da:	90 e0       	ldi	r25, 0x00	; 0
1350
 5dc:	90 93 80 00 	sts	0x0080, r25
1351
 5e0:	80 93 7f 00 	sts	0x007F, r24
1352
 5e4:	89 e0       	ldi	r24, 0x09	; 9
1353
 5e6:	bd cf       	rjmp	.-134    	; 0x562 <usbPoll+0x1c6>
1354
/* This function is similar to usbFunctionRead(), but it's also called for
1355
 * data handled automatically by the driver (e.g. descriptor reads).
1356
 */
1357
static uchar usbDeviceRead(uchar *data, uchar len)
1358
{
1359
    if(len > 0){    /* don't bother app with 0 sized reads */
1360
 5e8:	16 2f       	mov	r17, r22
1361
 5ea:	1c 5f       	subi	r17, 0xFC	; 252
1362
 5ec:	fe ce       	rjmp	.-516    	; 0x3ea <usbPoll+0x4e>
1363
        len = usbFunctionDescriptor(rq);
1364
#else   /* USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC */
1365
        SWITCH_START(rq->wValue.bytes[0])
1366
        SWITCH_CASE(0)
1367
            GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_0, usbDescriptorString0)
1368
        SWITCH_CASE(1)
1369
 5ee:	91 30       	cpi	r25, 0x01	; 1
1370
 5f0:	59 f0       	breq	.+22     	; 0x608 <usbPoll+0x26c>
1371
            GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_VENDOR, usbDescriptorStringVendor)
1372
        SWITCH_CASE(2)
1373
 5f2:	92 30       	cpi	r25, 0x02	; 2
1374
 5f4:	09 f0       	breq	.+2      	; 0x5f8 <usbPoll+0x25c>
1375
 5f6:	b4 cf       	rjmp	.-152    	; 0x560 <usbPoll+0x1c4>
1376
            GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_PRODUCT, usbDescriptorStringDevice)
1377
 5f8:	82 e6       	ldi	r24, 0x62	; 98
1378
 5fa:	90 e0       	ldi	r25, 0x00	; 0
1379
 5fc:	90 93 80 00 	sts	0x0080, r25
1380
 600:	80 93 7f 00 	sts	0x007F, r24
1381
 604:	88 e2       	ldi	r24, 0x28	; 40
1382
 606:	ad cf       	rjmp	.-166    	; 0x562 <usbPoll+0x1c6>
1383
#else   /* USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC */
1384
        SWITCH_START(rq->wValue.bytes[0])
1385
        SWITCH_CASE(0)
1386
            GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_0, usbDescriptorString0)
1387
        SWITCH_CASE(1)
1388
            GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_VENDOR, usbDescriptorStringVendor)
1389
 608:	8c e4       	ldi	r24, 0x4C	; 76
1390
 60a:	90 e0       	ldi	r25, 0x00	; 0
1391
 60c:	90 93 80 00 	sts	0x0080, r25
1392
 610:	80 93 7f 00 	sts	0x007F, r24
1393
 614:	86 e1       	ldi	r24, 0x16	; 22
1394
 616:	a5 cf       	rjmp	.-182    	; 0x562 <usbPoll+0x1c6>
1395
 
1396
00000618 <usbInit>:
1397
/* ------------------------------------------------------------------------- */
1398
 
1399
USB_PUBLIC void usbInit(void)
1400
{
1401
#if USB_INTR_CFG_SET != 0
1402
    USB_INTR_CFG |= USB_INTR_CFG_SET;
1403
 618:	85 b7       	in	r24, 0x35	; 53
1404
 61a:	83 60       	ori	r24, 0x03	; 3
1405
 61c:	85 bf       	out	0x35, r24	; 53
1406
#endif
1407
#if USB_INTR_CFG_CLR != 0
1408
    USB_INTR_CFG &= ~(USB_INTR_CFG_CLR);
1409
#endif
1410
    USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT);
1411
 61e:	8b b7       	in	r24, 0x3b	; 59
1412
 620:	80 64       	ori	r24, 0x40	; 64
1413
 622:	8b bf       	out	0x3b, r24	; 59
1414
/* ------------------------------------------------------------------------- */
1415
 
1416
static inline void  usbResetDataToggling(void)
1417
{
1418
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
1419
    USB_SET_DATATOKEN1(USB_INITIAL_DATATOKEN);  /* reset data toggling for interrupt endpoint */
1420
 624:	8b e4       	ldi	r24, 0x4B	; 75
1421
 626:	80 93 71 00 	sts	0x0071, r24
1422
    USB_INTR_CFG &= ~(USB_INTR_CFG_CLR);
1423
#endif
1424
    USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT);
1425
    usbResetDataToggling();
1426
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
1427
    usbTxLen1 = USBPID_NAK;
1428
 62a:	8a e5       	ldi	r24, 0x5A	; 90
1429
 62c:	80 93 70 00 	sts	0x0070, r24
1430
#if USB_CFG_HAVE_INTRIN_ENDPOINT3
1431
    usbTxLen3 = USBPID_NAK;
1432
#endif
1433
#endif
1434
}
1435
 630:	08 95       	ret
1436
 
1437
00000632 <usbCrc16>:
1438
 632:	a8 2f       	mov	r26, r24
1439
 634:	b9 2f       	mov	r27, r25
1440
 636:	80 e0       	ldi	r24, 0x00	; 0
1441
 638:	90 e0       	ldi	r25, 0x00	; 0
1442
 63a:	41 e0       	ldi	r20, 0x01	; 1
1443
 63c:	50 ea       	ldi	r21, 0xA0	; 160
1444
 63e:	60 95       	com	r22
1445
 640:	30 e0       	ldi	r19, 0x00	; 0
1446
 642:	09 c0       	rjmp	.+18     	; 0x656 <usbCrcLoopEntry>
1447
 
1448
00000644 <usbCrcByteLoop>:
1449
 644:	2d 91       	ld	r18, X+
1450
 646:	82 27       	eor	r24, r18
1451
 
1452
00000648 <usbCrcBitLoop>:
1453
 648:	97 95       	ror	r25
1454
 64a:	87 95       	ror	r24
1455
 64c:	10 f0       	brcs	.+4      	; 0x652 <usbCrcNoXor>
1456
 64e:	84 27       	eor	r24, r20
1457
 650:	95 27       	eor	r25, r21
1458
 
1459
00000652 <usbCrcNoXor>:
1460
 652:	30 5e       	subi	r19, 0xE0	; 224
1461
 654:	c8 f3       	brcs	.-14     	; 0x648 <usbCrcBitLoop>
1462
 
1463
00000656 <usbCrcLoopEntry>:
1464
 656:	6f 5f       	subi	r22, 0xFF	; 255
1465
 658:	a8 f3       	brcs	.-22     	; 0x644 <usbCrcByteLoop>
1466
 
1467
0000065a <usbCrcReady>:
1468
 65a:	08 95       	ret
1469
 
1470
0000065c <usbCrc16Append>:
1471
 65c:	ea df       	rcall	.-44     	; 0x632 <usbCrc16>
1472
 65e:	8d 93       	st	X+, r24
1473
 660:	9d 93       	st	X+, r25
1474
 662:	08 95       	ret
1475
 
1476
00000664 <usbMeasureFrameLength>:
1477
 664:	a6 e0       	ldi	r26, 0x06	; 6
1478
 666:	88 27       	eor	r24, r24
1479
 668:	99 27       	eor	r25, r25
1480
 
1481
0000066a <usbMFTime16>:
1482
 66a:	aa 95       	dec	r26
1483
 66c:	69 f0       	breq	.+26     	; 0x688 <usbMFTimeout>
1484
 
1485
0000066e <usbMFWaitStrobe>:
1486
 66e:	01 97       	sbiw	r24, 0x01	; 1
1487
 670:	e1 f3       	breq	.-8      	; 0x66a <usbMFTime16>
1488
 672:	b0 99       	sbic	0x16, 0	; 22
1489
 674:	fc cf       	rjmp	.-8      	; 0x66e <usbMFWaitStrobe>
1490
 
1491
00000676 <usbMFWaitIdle>:
1492
 676:	b0 9b       	sbis	0x16, 0	; 22
1493
 678:	fe cf       	rjmp	.-4      	; 0x676 <usbMFWaitIdle>
1494
 67a:	81 e0       	ldi	r24, 0x01	; 1
1495
 67c:	99 27       	eor	r25, r25
1496
 
1497
0000067e <usbMFWaitLoop>:
1498
 67e:	a6 b3       	in	r26, 0x16	; 22
1499
 680:	01 96       	adiw	r24, 0x01	; 1
1500
 682:	11 f0       	breq	.+4      	; 0x688 <usbMFTimeout>
1501
 684:	a5 70       	andi	r26, 0x05	; 5
1502
 686:	d9 f7       	brne	.-10     	; 0x67e <usbMFWaitLoop>
1503
 
1504
00000688 <usbMFTimeout>:
1505
 688:	08 95       	ret
1506
 
1507
0000068a <__vector_1>:
1508
 68a:	cf 93       	push	r28
1509
 68c:	cf b7       	in	r28, 0x3f	; 63
1510
 68e:	cf 93       	push	r28
1511
 
1512
00000690 <waitForJ>:
1513
 690:	c3 95       	inc	r28
1514
 692:	b0 9b       	sbis	0x16, 0	; 22
1515
 694:	e9 f7       	brne	.-6      	; 0x690 <waitForJ>
1516
 
1517
00000696 <waitForK>:
1518
 696:	b0 9b       	sbis	0x16, 0	; 22
1519
 698:	0b c0       	rjmp	.+22     	; 0x6b0 <foundK>
1520
 69a:	b0 9b       	sbis	0x16, 0	; 22
1521
 69c:	09 c0       	rjmp	.+18     	; 0x6b0 <foundK>
1522
 69e:	b0 9b       	sbis	0x16, 0	; 22
1523
 6a0:	07 c0       	rjmp	.+14     	; 0x6b0 <foundK>
1524
 6a2:	b0 9b       	sbis	0x16, 0	; 22
1525
 6a4:	05 c0       	rjmp	.+10     	; 0x6b0 <foundK>
1526
 6a6:	b0 9b       	sbis	0x16, 0	; 22
1527
 6a8:	03 c0       	rjmp	.+6      	; 0x6b0 <foundK>
1528
 6aa:	b0 9b       	sbis	0x16, 0	; 22
1529
 6ac:	01 c0       	rjmp	.+2      	; 0x6b0 <foundK>
1530
 6ae:	d5 c0       	rjmp	.+426    	; 0x85a <sofError>
1531
 
1532
000006b0 <foundK>:
1533
 6b0:	0f 92       	push	r0
1534
 6b2:	df 93       	push	r29
1535
 6b4:	c0 91 7e 00 	lds	r28, 0x007E
1536
 6b8:	dd 27       	eor	r29, r29
1537
 6ba:	cb 57       	subi	r28, 0x7B	; 123
1538
 6bc:	df 4f       	sbci	r29, 0xFF	; 255
1539
 6be:	01 2e       	mov	r0, r17
1540
 6c0:	b0 9b       	sbis	0x16, 0	; 22
1541
 6c2:	03 c0       	rjmp	.+6      	; 0x6ca <haveTwoBitsK>
1542
 6c4:	df 91       	pop	r29
1543
 6c6:	0f 90       	pop	r0
1544
 6c8:	e6 cf       	rjmp	.-52     	; 0x696 <waitForK>
1545
 
1546
000006ca <haveTwoBitsK>:
1547
 6ca:	2f 93       	push	r18
1548
 6cc:	0f 93       	push	r16
1549
 6ce:	1f 93       	push	r17
1550
 6d0:	4f 93       	push	r20
1551
 6d2:	2f ef       	ldi	r18, 0xFF	; 255
1552
 6d4:	4f 6f       	ori	r20, 0xFF	; 255
1553
 6d6:	06 b3       	in	r16, 0x16	; 22
1554
 6d8:	00 fb       	bst	r16, 0
1555
 6da:	20 f9       	bld	r18, 0
1556
 6dc:	5f 93       	push	r21
1557
 6de:	3f 93       	push	r19
1558
 6e0:	50 e0       	ldi	r21, 0x00	; 0
1559
 6e2:	3b e0       	ldi	r19, 0x0B	; 11
1560
 6e4:	65 c0       	rjmp	.+202    	; 0x7b0 <rxbit1>
1561
 
1562
000006e6 <continueWithBit5>:
1563
 6e6:	16 b3       	in	r17, 0x16	; 22
1564
 6e8:	01 26       	eor	r0, r17
1565
 6ea:	50 29       	or	r21, r0
1566
 6ec:	50 fd       	sbrc	r21, 0
1567
 6ee:	c8 95       	lpm
1568
 6f0:	56 b3       	in	r21, 0x16	; 22
1569
 6f2:	01 27       	eor	r16, r17
1570
 6f4:	00 fb       	bst	r16, 0
1571
 6f6:	25 f9       	bld	r18, 5
1572
 6f8:	2f 73       	andi	r18, 0x3F	; 63
1573
 6fa:	06 b3       	in	r16, 0x16	; 22
1574
 6fc:	b1 f0       	breq	.+44     	; 0x72a <unstuff5>
1575
 6fe:	50 27       	eor	r21, r16
1576
 700:	10 27       	eor	r17, r16
1577
 702:	10 fb       	bst	r17, 0
1578
 704:	26 f9       	bld	r18, 6
1579
 
1580
00000706 <didUnstuff6>:
1581
 706:	06 b2       	in	r0, 0x16	; 22
1582
 708:	22 30       	cpi	r18, 0x02	; 2
1583
 70a:	f0 f0       	brcs	.+60     	; 0x748 <unstuff6>
1584
 
1585
0000070c <didUnstuff5>:
1586
 70c:	00 c0       	rjmp	.+0      	; 0x70e <didUnstuff5+0x2>
1587
 70e:	16 b3       	in	r17, 0x16	; 22
1588
 710:	01 27       	eor	r16, r17
1589
 712:	00 fb       	bst	r16, 0
1590
 714:	27 f9       	bld	r18, 7
1591
 
1592
00000716 <didUnstuff7>:
1593
 716:	01 26       	eor	r0, r17
1594
 718:	50 29       	or	r21, r0
1595
 71a:	06 b2       	in	r0, 0x16	; 22
1596
 71c:	24 30       	cpi	r18, 0x04	; 4
1597
 71e:	e8 f5       	brcc	.+122    	; 0x79a <rxLoop>
1598
 
1599
00000720 <unstuff7>:
1600
 720:	4f 77       	andi	r20, 0x7F	; 127
1601
 722:	20 68       	ori	r18, 0x80	; 128
1602
 724:	16 b3       	in	r17, 0x16	; 22
1603
 726:	00 00       	nop
1604
 728:	f6 cf       	rjmp	.-20     	; 0x716 <didUnstuff7>
1605
 
1606
0000072a <unstuff5>:
1607
 72a:	50 27       	eor	r21, r16
1608
 72c:	4f 7d       	andi	r20, 0xDF	; 223
1609
 72e:	20 62       	ori	r18, 0x20	; 32
1610
 730:	06 b2       	in	r0, 0x16	; 22
1611
 732:	10 2f       	mov	r17, r16
1612
 734:	00 00       	nop
1613
 736:	00 c0       	rjmp	.+0      	; 0x738 <unstuff5+0xe>
1614
 738:	06 b3       	in	r16, 0x16	; 22
1615
 73a:	00 26       	eor	r0, r16
1616
 73c:	50 29       	or	r21, r0
1617
 73e:	10 27       	eor	r17, r16
1618
 740:	10 fb       	bst	r17, 0
1619
 742:	26 f9       	bld	r18, 6
1620
 744:	06 b2       	in	r0, 0x16	; 22
1621
 746:	e2 cf       	rjmp	.-60     	; 0x70c <didUnstuff5>
1622
 
1623
00000748 <unstuff6>:
1624
 748:	4f 7b       	andi	r20, 0xBF	; 191
1625
 74a:	06 b3       	in	r16, 0x16	; 22
1626
 74c:	20 64       	ori	r18, 0x40	; 64
1627
 74e:	00 c0       	rjmp	.+0      	; 0x750 <unstuff6+0x8>
1628
 750:	da cf       	rjmp	.-76     	; 0x706 <didUnstuff6>
1629
 
1630
00000752 <unstuff0>:
1631
 752:	01 26       	eor	r0, r17
1632
 754:	50 29       	or	r21, r0
1633
 756:	15 70       	andi	r17, 0x05	; 5
1634
 758:	06 b2       	in	r0, 0x16	; 22
1635
 75a:	69 f1       	breq	.+90     	; 0x7b6 <didUnstuff0>
1636
 75c:	4e 7f       	andi	r20, 0xFE	; 254
1637
 75e:	21 60       	ori	r18, 0x01	; 1
1638
 760:	01 2f       	mov	r16, r17
1639
 762:	16 b3       	in	r17, 0x16	; 22
1640
 764:	28 c0       	rjmp	.+80     	; 0x7b6 <didUnstuff0>
1641
 
1642
00000766 <unstuff1>:
1643
 766:	00 26       	eor	r0, r16
1644
 768:	50 29       	or	r21, r0
1645
 76a:	4d 7f       	andi	r20, 0xFD	; 253
1646
 76c:	06 b2       	in	r0, 0x16	; 22
1647
 76e:	22 60       	ori	r18, 0x02	; 2
1648
 770:	10 2f       	mov	r17, r16
1649
 772:	29 c0       	rjmp	.+82     	; 0x7c6 <didUnstuff1>
1650
 
1651
00000774 <unstuff2>:
1652
 774:	01 26       	eor	r0, r17
1653
 776:	50 29       	or	r21, r0
1654
 778:	4b 7f       	andi	r20, 0xFB	; 251
1655
 77a:	06 b2       	in	r0, 0x16	; 22
1656
 77c:	24 60       	ori	r18, 0x04	; 4
1657
 77e:	01 2f       	mov	r16, r17
1658
 780:	2d c0       	rjmp	.+90     	; 0x7dc <didUnstuff2>
1659
 
1660
00000782 <unstuff3>:
1661
 782:	16 b3       	in	r17, 0x16	; 22
1662
 784:	01 26       	eor	r0, r17
1663
 786:	50 29       	or	r21, r0
1664
 788:	47 7f       	andi	r20, 0xF7	; 247
1665
 78a:	28 60       	ori	r18, 0x08	; 8
1666
 78c:	00 00       	nop
1667
 78e:	06 b2       	in	r0, 0x16	; 22
1668
 790:	2e c0       	rjmp	.+92     	; 0x7ee <didUnstuff3>
1669
 
1670
00000792 <unstuff4>:
1671
 792:	4f 7e       	andi	r20, 0xEF	; 239
1672
 794:	06 b3       	in	r16, 0x16	; 22
1673
 796:	20 61       	ori	r18, 0x10	; 16
1674
 798:	30 c0       	rjmp	.+96     	; 0x7fa <didUnstuff4>
1675
 
1676
0000079a <rxLoop>:
1677
 79a:	42 27       	eor	r20, r18
1678
 79c:	06 b3       	in	r16, 0x16	; 22
1679
 79e:	49 93       	st	Y+, r20
1680
 7a0:	00 26       	eor	r0, r16
1681
 7a2:	50 29       	or	r21, r0
1682
 7a4:	10 27       	eor	r17, r16
1683
 7a6:	06 b2       	in	r0, 0x16	; 22
1684
 7a8:	4f ef       	ldi	r20, 0xFF	; 255
1685
 7aa:	10 fb       	bst	r17, 0
1686
 7ac:	20 f9       	bld	r18, 0
1687
 7ae:	29 7f       	andi	r18, 0xF9	; 249
1688
 
1689
000007b0 <rxbit1>:
1690
 7b0:	16 b3       	in	r17, 0x16	; 22
1691
 7b2:	79 f2       	breq	.-98     	; 0x752 <unstuff0>
1692
 7b4:	15 70       	andi	r17, 0x05	; 5
1693
 
1694
000007b6 <didUnstuff0>:
1695
 7b6:	59 f1       	breq	.+86     	; 0x80e <se0>
1696
 7b8:	01 26       	eor	r0, r17
1697
 7ba:	50 29       	or	r21, r0
1698
 7bc:	06 b2       	in	r0, 0x16	; 22
1699
 7be:	01 27       	eor	r16, r17
1700
 7c0:	00 fb       	bst	r16, 0
1701
 7c2:	21 f9       	bld	r18, 1
1702
 7c4:	23 7f       	andi	r18, 0xF3	; 243
1703
 
1704
000007c6 <didUnstuff1>:
1705
 7c6:	06 b3       	in	r16, 0x16	; 22
1706
 7c8:	71 f2       	breq	.-100    	; 0x766 <unstuff1>
1707
 7ca:	00 26       	eor	r0, r16
1708
 7cc:	50 29       	or	r21, r0
1709
 7ce:	31 50       	subi	r19, 0x01	; 1
1710
 7d0:	d0 f0       	brcs	.+52     	; 0x806 <overflow>
1711
 7d2:	06 b2       	in	r0, 0x16	; 22
1712
 7d4:	10 27       	eor	r17, r16
1713
 7d6:	10 fb       	bst	r17, 0
1714
 7d8:	22 f9       	bld	r18, 2
1715
 7da:	27 7e       	andi	r18, 0xE7	; 231
1716
 
1717
000007dc <didUnstuff2>:
1718
 7dc:	16 b3       	in	r17, 0x16	; 22
1719
 7de:	51 f2       	breq	.-108    	; 0x774 <unstuff2>
1720
 7e0:	01 26       	eor	r0, r17
1721
 7e2:	50 29       	or	r21, r0
1722
 7e4:	01 27       	eor	r16, r17
1723
 7e6:	00 fb       	bst	r16, 0
1724
 7e8:	06 b2       	in	r0, 0x16	; 22
1725
 7ea:	23 f9       	bld	r18, 3
1726
 7ec:	2f 7c       	andi	r18, 0xCF	; 207
1727
 
1728
000007ee <didUnstuff3>:
1729
 7ee:	49 f2       	breq	.-110    	; 0x782 <unstuff3>
1730
 7f0:	00 00       	nop
1731
 7f2:	06 b3       	in	r16, 0x16	; 22
1732
 7f4:	10 27       	eor	r17, r16
1733
 7f6:	10 fb       	bst	r17, 0
1734
 7f8:	24 f9       	bld	r18, 4
1735
 
1736
000007fa <didUnstuff4>:
1737
 7fa:	00 26       	eor	r0, r16
1738
 7fc:	50 29       	or	r21, r0
1739
 7fe:	06 b2       	in	r0, 0x16	; 22
1740
 800:	2f 79       	andi	r18, 0x9F	; 159
1741
 802:	39 f2       	breq	.-114    	; 0x792 <unstuff4>
1742
 804:	70 cf       	rjmp	.-288    	; 0x6e6 <continueWithBit5>
1743
 
1744
00000806 <overflow>:
1745
 806:	10 e4       	ldi	r17, 0x40	; 64
1746
 808:	1a bf       	out	0x3a, r17	; 58
1747
 
1748
0000080a <ignorePacket>:
1749
 80a:	00 27       	eor	r16, r16
1750
 80c:	19 c0       	rjmp	.+50     	; 0x840 <handleSetupOrOut>
1751
 
1752
0000080e <se0>:
1753
 80e:	3b 50       	subi	r19, 0x0B	; 11
1754
 810:	31 95       	neg	r19
1755
 812:	c3 1b       	sub	r28, r19
1756
 814:	d0 40       	sbci	r29, 0x00	; 0
1757
 816:	10 e4       	ldi	r17, 0x40	; 64
1758
 818:	1a bf       	out	0x3a, r17	; 58
1759
 81a:	08 81       	ld	r16, Y
1760
 81c:	03 3c       	cpi	r16, 0xC3	; 195
1761
 81e:	09 f1       	breq	.+66     	; 0x862 <handleData>
1762
 820:	0b 34       	cpi	r16, 0x4B	; 75
1763
 822:	f9 f0       	breq	.+62     	; 0x862 <handleData>
1764
 824:	20 91 7c 00 	lds	r18, 0x007C
1765
 828:	19 81       	ldd	r17, Y+1	; 0x01
1766
 82a:	11 0f       	add	r17, r17
1767
 82c:	12 13       	cpse	r17, r18
1768
 82e:	ed cf       	rjmp	.-38     	; 0x80a <ignorePacket>
1769
 830:	4a 81       	ldd	r20, Y+2	; 0x02
1770
 832:	44 1f       	adc	r20, r20
1771
 834:	09 36       	cpi	r16, 0x69	; 105
1772
 836:	51 f1       	breq	.+84     	; 0x88c <handleIn>
1773
 838:	0d 32       	cpi	r16, 0x2D	; 45
1774
 83a:	11 f0       	breq	.+4      	; 0x840 <handleSetupOrOut>
1775
 83c:	01 3e       	cpi	r16, 0xE1	; 225
1776
 83e:	29 f7       	brne	.-54     	; 0x80a <ignorePacket>
1777
 
1778
00000840 <handleSetupOrOut>:
1779
 840:	00 93 83 00 	sts	0x0083, r16
1780
 
1781
00000844 <doReturn>:
1782
 844:	3f 91       	pop	r19
1783
 846:	5f 91       	pop	r21
1784
 848:	4f 91       	pop	r20
1785
 84a:	1f 91       	pop	r17
1786
 84c:	0f 91       	pop	r16
1787
 84e:	2f 91       	pop	r18
1788
 850:	df 91       	pop	r29
1789
 852:	0f 90       	pop	r0
1790
 854:	ca b7       	in	r28, 0x3a	; 58
1791
 856:	c6 fd       	sbrc	r28, 6
1792
 858:	1b cf       	rjmp	.-458    	; 0x690 <waitForJ>
1793
 
1794
0000085a <sofError>:
1795
 85a:	cf 91       	pop	r28
1796
 85c:	cf bf       	out	0x3f, r28	; 63
1797
 85e:	cf 91       	pop	r28
1798
 860:	18 95       	reti
1799
 
1800
00000862 <handleData>:
1801
 862:	20 91 83 00 	lds	r18, 0x0083
1802
 866:	22 23       	and	r18, r18
1803
 868:	69 f3       	breq	.-38     	; 0x844 <doReturn>
1804
 86a:	10 91 81 00 	lds	r17, 0x0081
1805
 86e:	11 23       	and	r17, r17
1806
 870:	79 f5       	brne	.+94     	; 0x8d0 <sendNakAndReti>
1807
 872:	34 30       	cpi	r19, 0x04	; 4
1808
 874:	7a f1       	brmi	.+94     	; 0x8d4 <sendAckAndReti>
1809
 876:	30 93 81 00 	sts	0x0081, r19
1810
 87a:	20 93 7d 00 	sts	0x007D, r18
1811
 87e:	10 91 7e 00 	lds	r17, 0x007E
1812
 882:	3b e0       	ldi	r19, 0x0B	; 11
1813
 884:	31 1b       	sub	r19, r17
1814
 886:	30 93 7e 00 	sts	0x007E, r19
1815
 88a:	24 c0       	rjmp	.+72     	; 0x8d4 <sendAckAndReti>
1816
 
1817
0000088c <handleIn>:
1818
 88c:	00 91 81 00 	lds	r16, 0x0081
1819
 890:	01 30       	cpi	r16, 0x01	; 1
1820
 892:	f4 f4       	brge	.+60     	; 0x8d0 <sendNakAndReti>
1821
 894:	0a e5       	ldi	r16, 0x5A	; 90
1822
 896:	4f 70       	andi	r20, 0x0F	; 15
1823
 898:	49 f4       	brne	.+18     	; 0x8ac <handleIn1>
1824
 89a:	30 91 60 00 	lds	r19, 0x0060
1825
 89e:	34 fd       	sbrc	r19, 4
1826
 8a0:	1a c0       	rjmp	.+52     	; 0x8d6 <sendCntAndReti>
1827
 8a2:	00 93 60 00 	sts	0x0060, r16
1828
 8a6:	c5 e6       	ldi	r28, 0x65	; 101
1829
 8a8:	d0 e0       	ldi	r29, 0x00	; 0
1830
 8aa:	19 c0       	rjmp	.+50     	; 0x8de <usbSendAndReti>
1831
 
1832
000008ac <handleIn1>:
1833
 8ac:	30 91 70 00 	lds	r19, 0x0070
1834
 8b0:	34 fd       	sbrc	r19, 4
1835
 8b2:	11 c0       	rjmp	.+34     	; 0x8d6 <sendCntAndReti>
1836
 8b4:	00 93 70 00 	sts	0x0070, r16
1837
 8b8:	c1 e7       	ldi	r28, 0x71	; 113
1838
 8ba:	d0 e0       	ldi	r29, 0x00	; 0
1839
 8bc:	10 c0       	rjmp	.+32     	; 0x8de <usbSendAndReti>
1840
 
1841
000008be <bitstuff7>:
1842
 8be:	05 27       	eor	r16, r21
1843
 8c0:	10 e0       	ldi	r17, 0x00	; 0
1844
 8c2:	00 c0       	rjmp	.+0      	; 0x8c4 <bitstuff7+0x6>
1845
 8c4:	21 c0       	rjmp	.+66     	; 0x908 <didStuff7>
1846
 
1847
000008c6 <bitstuffN>:
1848
 8c6:	05 27       	eor	r16, r21
1849
 8c8:	10 e0       	ldi	r17, 0x00	; 0
1850
 8ca:	c8 95       	lpm
1851
 8cc:	08 bb       	out	0x18, r16	; 24
1852
 8ce:	14 c0       	rjmp	.+40     	; 0x8f8 <didStuffN>
1853
 
1854
000008d0 <sendNakAndReti>:
1855
 8d0:	3a e5       	ldi	r19, 0x5A	; 90
1856
 8d2:	01 c0       	rjmp	.+2      	; 0x8d6 <sendCntAndReti>
1857
 
1858
000008d4 <sendAckAndReti>:
1859
 8d4:	32 ed       	ldi	r19, 0xD2	; 210
1860
 
1861
000008d6 <sendCntAndReti>:
1862
 8d6:	03 2e       	mov	r0, r19
1863
 8d8:	c0 e0       	ldi	r28, 0x00	; 0
1864
 8da:	d0 e0       	ldi	r29, 0x00	; 0
1865
 8dc:	32 e0       	ldi	r19, 0x02	; 2
1866
 
1867
000008de <usbSendAndReti>:
1868
 8de:	17 b3       	in	r17, 0x17	; 23
1869
 8e0:	15 60       	ori	r17, 0x05	; 5
1870
 8e2:	c0 9a       	sbi	0x18, 0	; 24
1871
 8e4:	08 b3       	in	r16, 0x18	; 24
1872
 8e6:	17 bb       	out	0x17, r17	; 23
1873
 8e8:	55 e0       	ldi	r21, 0x05	; 5
1874
 8ea:	20 e8       	ldi	r18, 0x80	; 128
1875
 8ec:	4f ef       	ldi	r20, 0xFF	; 255
1876
 
1877
000008ee <bitloop>:
1878
 8ee:	20 ff       	sbrs	r18, 0
1879
 8f0:	05 27       	eor	r16, r21
1880
 8f2:	08 bb       	out	0x18, r16	; 24
1881
 8f4:	27 95       	ror	r18
1882
 8f6:	17 95       	ror	r17
1883
 
1884
000008f8 <didStuffN>:
1885
 8f8:	1c 3f       	cpi	r17, 0xFC	; 252
1886
 8fa:	28 f7       	brcc	.-54     	; 0x8c6 <bitstuffN>
1887
 8fc:	00 00       	nop
1888
 8fe:	45 52       	subi	r20, 0x25	; 37
1889
 900:	b0 f7       	brcc	.-20     	; 0x8ee <bitloop>
1890
 902:	20 ff       	sbrs	r18, 0
1891
 904:	05 27       	eor	r16, r21
1892
 906:	27 95       	ror	r18
1893
 
1894
00000908 <didStuff7>:
1895
 908:	08 bb       	out	0x18, r16	; 24
1896
 90a:	17 95       	ror	r17
1897
 90c:	1c 3f       	cpi	r17, 0xFC	; 252
1898
 90e:	b8 f6       	brcc	.-82     	; 0x8be <bitstuff7>
1899
 910:	29 91       	ld	r18, Y+
1900
 912:	3a 95       	dec	r19
1901
 914:	61 f7       	brne	.-40     	; 0x8ee <bitloop>
1902
 916:	0a 7f       	andi	r16, 0xFA	; 250
1903
 918:	10 91 82 00 	lds	r17, 0x0082
1904
 91c:	11 0f       	add	r17, r17
1905
 91e:	08 bb       	out	0x18, r16	; 24
1906
 920:	c2 50       	subi	r28, 0x02	; 2
1907
 922:	d0 40       	sbci	r29, 0x00	; 0
1908
 924:	11 f0       	breq	.+4      	; 0x92a <skipAddrAssign>
1909
 926:	10 93 7c 00 	sts	0x007C, r17
1910
 
1911
0000092a <skipAddrAssign>:
1912
 92a:	10 e4       	ldi	r17, 0x40	; 64
1913
 92c:	1a bf       	out	0x3a, r17	; 58
1914
 92e:	01 60       	ori	r16, 0x01	; 1
1915
 930:	17 b3       	in	r17, 0x17	; 23
1916
 932:	1a 7f       	andi	r17, 0xFA	; 250
1917
 934:	40 2f       	mov	r20, r16
1918
 936:	4a 7f       	andi	r20, 0xFA	; 250
1919
 938:	54 e0       	ldi	r21, 0x04	; 4
1920
 
1921
0000093a <se0Delay>:
1922
 93a:	5a 95       	dec	r21
1923
 93c:	f1 f7       	brne	.-4      	; 0x93a <se0Delay>
1924
 93e:	08 bb       	out	0x18, r16	; 24
1925
 940:	17 bb       	out	0x17, r17	; 23
1926
 942:	48 bb       	out	0x18, r20	; 24
1927
 944:	7f cf       	rjmp	.-258    	; 0x844 <doReturn>
1928
 
1929
00000946 <__eerd_byte_tn85>:
1930
 946:	e1 99       	sbic	0x1c, 1	; 28
1931
 948:	fe cf       	rjmp	.-4      	; 0x946 <__eerd_byte_tn85>
1932
 94a:	9f bb       	out	0x1f, r25	; 31
1933
 94c:	8e bb       	out	0x1e, r24	; 30
1934
 94e:	e0 9a       	sbi	0x1c, 0	; 28
1935
 950:	99 27       	eor	r25, r25
1936
 952:	8d b3       	in	r24, 0x1d	; 29
1937
 954:	08 95       	ret
1938
 
1939
00000956 <__eewr_byte_tn85>:
1940
 956:	26 2f       	mov	r18, r22
1941
 
1942
00000958 <__eewr_r18_tn85>:
1943
 958:	e1 99       	sbic	0x1c, 1	; 28
1944
 95a:	fe cf       	rjmp	.-4      	; 0x958 <__eewr_r18_tn85>
1945
 95c:	1c ba       	out	0x1c, r1	; 28
1946
 95e:	9f bb       	out	0x1f, r25	; 31
1947
 960:	8e bb       	out	0x1e, r24	; 30
1948
 962:	2d bb       	out	0x1d, r18	; 29
1949
 964:	0f b6       	in	r0, 0x3f	; 63
1950
 966:	f8 94       	cli
1951
 968:	e2 9a       	sbi	0x1c, 2	; 28
1952
 96a:	e1 9a       	sbi	0x1c, 1	; 28
1953
 96c:	0f be       	out	0x3f, r0	; 63
1954
 96e:	01 96       	adiw	r24, 0x01	; 1
1955
 970:	08 95       	ret
1956
 
1957
00000972 <_exit>:
1958
 972:	f8 94       	cli
1959
 
1960
00000974 <__stop_program>:
1961
 974:	ff cf       	rjmp	.-2      	; 0x974 <__stop_program>