📄 usb_to_232.lss
字号:
1e2: ff 27 eor r31, r31
1e4: e6 55 subi r30, 0x56 ; 86
1e6: ff 4f sbci r31, 0xFF ; 255
1e8: 20 83 st Z, r18
1ea: 90 93 eb 00 sts 0x00EB, r25
1ee: 11 96 adiw r26, 0x01 ; 1
1f0: 61 50 subi r22, 0x01 ; 1
1f2: 66 23 and r22, r22
1f4: 59 f7 brne .-42 ; 0x1cc <usbFunctionWriteOut+0xa>
1f6: 08 95 ret
000001f8 <usbcdc_init>:
}
}
static void hardwareInit(void)
{
uchar i, j;
/* activate pull-ups except on USB lines */
USB_CFG_IOPORT = (uchar)~((1<<USB_CFG_DMINUS_BIT)|(1<<USB_CFG_DPLUS_BIT));
/* all pins input except USB (-> USB reset) */
#ifdef USB_CFG_PULLUP_IOPORT /* use usbDeviceConnect()/usbDeviceDisconnect() if available */
USBDDR = 0; /* we do RESET by deactivating pullup */
usbDeviceDisconnect();
#else
USBDDR = (1<<USB_CFG_DMINUS_BIT)|(1<<USB_CFG_DPLUS_BIT);
#endif
j = 0;
while(--j){ /* USB Reset by device only required on Watchdog Reset */
i = 0;
while(--i); /* delay >10ms for USB reset */
}
#ifdef USB_CFG_PULLUP_IOPORT
usbDeviceConnect();
#else
USBDDR = 0; /* remove USB reset condition */
#endif
#ifndef USE_MODEBUF
/* USART configuration */
baud.dword = UART_DEFAULT_BPS;
#endif
resetUart();
}
void usbcdc_poll()
{
uchar bytesRead, *data;
usbPoll();
/* usb -> rs232c: ready to receive? */
if( usbAllRequestsAreDisabled() && uartTxBytesFree()>=8 )
{
usbEnableAllRequests();
}
/* rs232c -> usb: transmit char */
if( usbInterruptIsReady() )
{
bytesRead = uartRxBytesAvailable(&data);
/* We limit the transaction size to 7 instead of 8 to indicate that
* this is the last transaction in the transfer. Otherwise the host
* would try to read more transactions which we would answer with NAK
* instead of a terminating zero sized block.
*/
if(bytesRead >= 8)
{
bytesRead = 8;
}
if (bytesRead > 0)
{
usbSetInterrupt(data, bytesRead);
uartRxDidReadBytes(bytesRead);
}
else if (sendEmptyFrame)
{
usbSetInterrupt(0, 0);
}
sendEmptyFrame = bytesRead;
}
#if USE_DCD_REPORTING
/* We need to report rx and tx carrier after open attempt */
if(usbInterruptIsReady3() && intr3Status != 0){
static const uchar serialStateNotification[8] = {0xa1, 0x20, 0, 0, 0, 0, 2, 0};
static const uchar serialStateData[2] = {3, 0};
if(intr3Status == 2){
usbSetInterrupt3(serialStateNotification, 8);
}else{
usbSetInterrupt3(serialStateData, 2);
}
intr3Status--;
}
#endif
}
void usbcdc_putc(char data)
{
uint8_t next = (iwptr+1) & RX_MASK;
while (next == urptr)
{
usbcdc_poll();
}
rx_buf[iwptr] = data;
iwptr = next;
}
char usbcdc_getc(void)
{
char ch;
uint8_t next = (irptr+1) & TX_MASK;
while (irptr == uwptr)
{
wdt_reset();
usbcdc_poll();
}
ch = tx_buf[irptr];
irptr = next;
return ch;
}
void usbcdc_init()
{
1f8: 8c ef ldi r24, 0xFC ; 252
1fa: 88 bb out 0x18, r24 ; 24
1fc: 83 e0 ldi r24, 0x03 ; 3
1fe: 87 bb out 0x17, r24 ; 23
200: 9e ef ldi r25, 0xFE ; 254
202: 8f ef ldi r24, 0xFF ; 255
204: 91 50 subi r25, 0x01 ; 1
206: f1 f7 brne .-4 ; 0x204 <usbcdc_init+0xc>
208: 81 50 subi r24, 0x01 ; 1
20a: e1 f7 brne .-8 ; 0x204 <usbcdc_init+0xc>
20c: 17 ba out 0x17, r1 ; 23
20e: 10 92 ec 00 sts 0x00EC, r1
212: 10 92 a9 00 sts 0x00A9, r1
216: 10 92 ea 00 sts 0x00EA, r1
21a: 10 92 eb 00 sts 0x00EB, r1
hardwareInit();
usbInit();
21e: 5d d2 rcall .+1210 ; 0x6da <usbInit>
sendEmptyFrame = 1;
220: 81 e0 ldi r24, 0x01 ; 1
222: 80 93 88 00 sts 0x0088, r24
226: 08 95 ret
00000228 <usbcdc_poll>:
228: 1f 93 push r17
22a: b5 d2 rcall .+1386 ; 0x796 <usbPoll>
22c: 80 91 16 01 lds r24, 0x0116
230: 87 ff sbrs r24, 7
232: 0b c0 rjmp .+22 ; 0x24a <usbcdc_poll+0x22>
234: 80 91 ec 00 lds r24, 0x00EC
238: 90 91 eb 00 lds r25, 0x00EB
23c: 89 1b sub r24, r25
23e: 81 50 subi r24, 0x01 ; 1
240: 8f 73 andi r24, 0x3F ; 63
242: 88 30 cpi r24, 0x08 ; 8
244: 10 f0 brcs .+4 ; 0x24a <usbcdc_poll+0x22>
246: 10 92 16 01 sts 0x0116, r1
24a: 80 91 69 00 lds r24, 0x0069
24e: 8f 3f cpi r24, 0xFF ; 255
250: 81 f5 brne .+96 ; 0x2b2 <usbcdc_poll+0x8a>
252: 20 91 ea 00 lds r18, 0x00EA
256: 90 91 a9 00 lds r25, 0x00A9
25a: 80 91 ea 00 lds r24, 0x00EA
25e: 98 17 cp r25, r24
260: 28 f0 brcs .+10 ; 0x26c <usbcdc_poll+0x44>
262: 80 91 a9 00 lds r24, 0x00A9
266: 90 91 ea 00 lds r25, 0x00EA
26a: 03 c0 rjmp .+6 ; 0x272 <usbcdc_poll+0x4a>
26c: 90 91 ea 00 lds r25, 0x00EA
270: 80 e2 ldi r24, 0x20 ; 32
272: 89 1b sub r24, r25
274: 99 27 eor r25, r25
276: 18 2f mov r17, r24
278: 88 30 cpi r24, 0x08 ; 8
27a: 10 f0 brcs .+4 ; 0x280 <usbcdc_poll+0x58>
27c: 18 e0 ldi r17, 0x08 ; 8
27e: 02 c0 rjmp .+4 ; 0x284 <usbcdc_poll+0x5c>
280: 88 23 and r24, r24
282: 69 f0 breq .+26 ; 0x29e <usbcdc_poll+0x76>
284: 82 2f mov r24, r18
286: 99 27 eor r25, r25
288: 61 2f mov r22, r17
28a: 87 57 subi r24, 0x77 ; 119
28c: 9f 4f sbci r25, 0xFF ; 255
28e: 5b d2 rcall .+1206 ; 0x746 <usbSetInterrupt>
290: 80 91 ea 00 lds r24, 0x00EA
294: 81 0f add r24, r17
296: 8f 71 andi r24, 0x1F ; 31
298: 80 93 ea 00 sts 0x00EA, r24
29c: 08 c0 rjmp .+16 ; 0x2ae <usbcdc_poll+0x86>
29e: 80 91 88 00 lds r24, 0x0088
2a2: 88 23 and r24, r24
2a4: 21 f0 breq .+8 ; 0x2ae <usbcdc_poll+0x86>
2a6: 60 e0 ldi r22, 0x00 ; 0
2a8: 80 e0 ldi r24, 0x00 ; 0
2aa: 90 e0 ldi r25, 0x00 ; 0
2ac: 4c d2 rcall .+1176 ; 0x746 <usbSetInterrupt>
2ae: 10 93 88 00 sts 0x0088, r17
2b2: 1f 91 pop r17
2b4: 08 95 ret
000002b6 <usbcdc_getc>:
2b6: 1f 93 push r17
2b8: 10 91 ec 00 lds r17, 0x00EC
2bc: 1f 5f subi r17, 0xFF ; 255
2be: 02 c0 rjmp .+4 ; 0x2c4 <usbcdc_getc+0xe>
2c0: a8 95 wdr
2c2: b2 df rcall .-156 ; 0x228 <usbcdc_poll>
2c4: 90 91 ec 00 lds r25, 0x00EC
2c8: 80 91 eb 00 lds r24, 0x00EB
2cc: 98 17 cp r25, r24
2ce: c1 f3 breq .-16 ; 0x2c0 <usbcdc_getc+0xa>
2d0: e0 91 ec 00 lds r30, 0x00EC
2d4: ff 27 eor r31, r31
2d6: e6 55 subi r30, 0x56 ; 86
2d8: ff 4f sbci r31, 0xFF ; 255
2da: 80 81 ld r24, Z
2dc: 1f 73 andi r17, 0x3F ; 63
2de: 10 93 ec 00 sts 0x00EC, r17
2e2: 99 27 eor r25, r25
2e4: 1f 91 pop r17
2e6: 08 95 ret
000002e8 <usbcdc_putc>:
2e8: 0f 93 push r16
2ea: 1f 93 push r17
2ec: 08 2f mov r16, r24
2ee: 10 91 a9 00 lds r17, 0x00A9
2f2: 1f 5f subi r17, 0xFF ; 255
2f4: 1f 71 andi r17, 0x1F ; 31
2f6: 01 c0 rjmp .+2 ; 0x2fa <usbcdc_putc+0x12>
2f8: 97 df rcall .-210 ; 0x228 <usbcdc_poll>
2fa: 80 91 ea 00 lds r24, 0x00EA
2fe: 18 17 cp r17, r24
300: d9 f3 breq .-10 ; 0x2f8 <usbcdc_putc+0x10>
302: e0 91 a9 00 lds r30, 0x00A9
306: ff 27 eor r31, r31
308: e7 57 subi r30, 0x77 ; 119
30a: ff 4f sbci r31, 0xFF ; 255
30c: 00 83 st Z, r16
30e: 10 93 a9 00 sts 0x00A9, r17
312: 1f 91 pop r17
314: 0f 91 pop r16
316: 08 95 ret
00000318 <usbFunctionWrite>:
318: 21 e0 ldi r18, 0x01 ; 1
31a: 20 93 15 01 sts 0x0115, r18
31e: 20 93 88 00 sts 0x0088, r18
322: a0 e6 ldi r26, 0x60 ; 96
324: b0 e0 ldi r27, 0x00 ; 0
326: fc 01 movw r30, r24
328: 87 e0 ldi r24, 0x07 ; 7
32a: 01 90 ld r0, Z+
32c: 0d 92 st X+, r0
32e: 81 50 subi r24, 0x01 ; 1
330: e1 f7 brne .-8 ; 0x32a <usbFunctionWrite+0x12>
332: 81 e0 ldi r24, 0x01 ; 1
334: 90 e0 ldi r25, 0x00 ; 0
336: 08 95 ret
00000338 <usbFunctionRead>:
338: fc 01 movw r30, r24
33a: a0 e6 ldi r26, 0x60 ; 96
33c: b0 e0 ldi r27, 0x00 ; 0
33e: 87 e0 ldi r24, 0x07 ; 7
340: 0d 90 ld r0, X+
342: 01 92 st Z+, r0
344: 81 50 subi r24, 0x01 ; 1
346: e1 f7 brne .-8 ; 0x340 <usbFunctionRead+0x8>
348: 87 e0 ldi r24, 0x07 ; 7
34a: 90 e0 ldi r25, 0x00 ; 0
34c: 08 95 ret
0000034e <__vector_1>:
34e: 0f 93 push r16
350: 0f b7 in r16, 0x3f ; 63
352: 0f 93 push r16
00000354 <waitForJ>:
354: b0 9b sbis 0x16, 0 ; 22
356: fe cf rjmp .-4 ; 0x354 <waitForJ>
358: b0 9b sbis 0x16, 0 ; 22
35a: 06 c0 rjmp .+12 ; 0x368 <foundK>
35c: b0 9b sbis 0x16, 0 ; 22
35e: 04 c0 rjmp .+8 ; 0x368 <foundK>
360: b0 9b sbis 0x16, 0 ; 22
362: 02 c0 rjmp .+4 ; 0x368 <foundK>
364: 00 00 nop
366: 00 c0 rjmp .+0 ; 0x368 <foundK>
00000368 <foundK>:
368: 1f 93 push r17
36a: 3f 93 push r19
36c: 2f 93 push r18
0000036e <shortcutEntry>:
36e: 31 e0 ldi r19, 0x01 ; 1
370: 12 e0 ldi r17, 0x02 ; 2
00000372 <waitNoChange>:
372: 06 b3 in r16, 0x16 ; 22
374: 10 27 eor r17, r16
376: 10 fd sbrc r17, 0
378: 32 e0 ldi r19, 0x02 ; 2
37a: 10 2f mov r17, r16
37c: 3a 95 dec r19
37e: c9 f7 brne .-14 ; 0x372 <waitNoChange>
380: 00 fd sbrc r16, 0
382: eb c0 rjmp .+470 ; 0x55a <sofError>
384: 06 b3 in r16, 0x16 ; 22
386: 10 27 eor r17, r16
388: 20 e0 ldi r18, 0x00 ; 0
38a: 10 fb bst r17, 0
38c: 20 f9 bld r18, 0
38e: df 93 push r29
390: 16 b3 in r17, 0x16 ; 22
392: 01 27 eor r16, r17
394: 00 fb bst r16, 0
396: 21 f9 bld r18, 1
398: cf 93 push r28
39a: c0 91 10 01 lds r28, 0x0110
39e: 06 b3 in r16, 0x16 ; 22
3a0: 10 27 eor r17, r16
3a2: 10 fb bst r17, 0
3a4: 22 f9 bld r18, 2
3a6: 3b e0 ldi r19, 0x0B ; 11
3a8: d0 e0 ldi r29, 0x00 ; 0
3aa: 4f 93 push r20
3ac: 16 b3 in r17, 0x16 ; 22
3ae: 01 27 eor r16, r17
3b0: 00 fb bst r16, 0
3b2: 23 f9 bld r18, 3
3b4: 4f ef ldi r20, 0xFF ; 255
3b6: 00 00 nop
3b8: 55 c0 rjmp .+170 ; 0x464 <rxbit4>
000003ba <shortcutToStart>:
3ba: b0 9b sbis 0x16, 0 ; 22
3bc: fe cf rjmp .-4 ; 0x3ba <shortcutToStart>
3be: b0 9b sbis 0x16, 0 ; 22
3c0: 06 c0 rjmp .+12 ; 0x3ce <foundK1>
3c2: b0 9b sbis 0x16, 0 ; 22
3c4: 04 c0 rjmp .+8 ; 0x3ce <foundK1>
3c6: b0 9b sbis 0x16, 0 ; 22
3c8: 02 c0 rjmp .+4 ; 0x3ce <foundK1>
3ca: 00 00 nop
3cc: 00 c0 rjmp .+0 ; 0x3ce <foundK1>
000003ce <foundK1>:
3ce: df 91 pop r29
3d0: 00 c0 rjmp .+0 ; 0x3d2 <foundK1+0x4>
3d2: cd cf rjmp .-102 ; 0x36e <shortcutEntry>
000003d4 <stuffed5>:
3d4: 16 b3 in r17, 0x16 ; 22
3d6: 13 70 andi r17, 0x03 ; 3
3d8: 79 f1 breq .+94 ; 0x438 <se0a>
3da: 4f 7d andi r20, 0xDF ; 223
3dc: 20 62 ori r18, 0x20 ; 32
3de: 13 c0 rjmp .+38 ; 0x406 <rxbit6>
000003e0 <stuffed6>:
3e0: 06 b3 in r16, 0x16 ; 22
3e2: 03 70 andi r16, 0x03 ; 3
3e4: 49 f1 breq .+82 ; 0x438 <se0a>
3e6: 4f 7b andi r20, 0xBF ; 191
3e8: 20 64 ori r18, 0x40 ; 64
3ea: 15 c0 rjmp .+42 ; 0x416 <rxbit7>
000003ec <stuffed7>:
3ec: 03 70 andi r16, 0x03 ; 3
3ee: 21 f1 breq .+72 ; 0x438 <se0a>
3f0: 10 2f mov r17, r16
3f2: 20 68 ori r18, 0x80 ; 128
3f4: 06 b3 in r16, 0x16 ; 22
3f6: 19 c0 rjmp .+50 ; 0x42a <unstuffed7>
000003f8 <stuffed0>:
3f8: 06 b3 in r16, 0x16 ; 22
3fa: 03 70 andi r16, 0x03 ; 3
3fc: e9 f0 breq .+58 ; 0x438 <se0a>
3fe: 4e 7f andi r20, 0xFE ; 254
400: 21 60 ori r18, 0x01 ; 1
402: 18 c0 rjmp .+48 ; 0x434 <rxbit1>
00000404 <rxLoop>:
404: 39 f3 breq .-50 ; 0x3d4 <stuffed5>
00000406 <rxbit6>:
406: 06 b3 in r16, 0x16 ; 22
408: 03 70 andi r16, 0x03 ; 3
40a: b1 f0 breq .+44 ; 0x438 <se0a>
40c: 10 27 eor r17, r16
40e: 10 fb bst r17, 0
410: 26 f9 bld r18, 6
412: 22 30 cpi r18, 0x02 ; 2
414: 28 f3 brcs .-54 ; 0x3e0 <stuffed6>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -