diff --git a/Firmware/Chameleon-Mini/Chameleon-Mini.lss b/Firmware/Chameleon-Mini/Chameleon-Mini.lss deleted file mode 100644 index 78dd927..0000000 --- a/Firmware/Chameleon-Mini/Chameleon-Mini.lss +++ /dev/null @@ -1,19017 +0,0 @@ - -Chameleon-Mini.elf: file format elf32-avr - -Sections: -Idx Name Size VMA LMA File off Algn - 0 .text 00005eea 00000000 00000000 000000b4 2**1 - CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .data 00000092 00802000 00005eea 00005f9e 2**0 - CONTENTS, ALLOC, LOAD, DATA - 2 .bss 00000e37 00802092 00802092 00006030 2**0 - ALLOC - 3 .eeprom 00000033 00810000 00810000 00006030 2**0 - CONTENTS, ALLOC, LOAD, DATA - 4 .comment 0000008b 00000000 00000000 00006063 2**0 - CONTENTS, READONLY - 5 .debug_aranges 00000970 00000000 00000000 000060ee 2**0 - CONTENTS, READONLY, DEBUGGING - 6 .debug_info 000153c4 00000000 00000000 00006a5e 2**0 - CONTENTS, READONLY, DEBUGGING - 7 .debug_abbrev 00004448 00000000 00000000 0001be22 2**0 - CONTENTS, READONLY, DEBUGGING - 8 .debug_line 00008de3 00000000 00000000 0002026a 2**0 - CONTENTS, READONLY, DEBUGGING - 9 .debug_frame 000019fc 00000000 00000000 00029050 2**2 - CONTENTS, READONLY, DEBUGGING - 10 .debug_str 000063bb 00000000 00000000 0002aa4c 2**0 - CONTENTS, READONLY, DEBUGGING - 11 .debug_loc 0000ad30 00000000 00000000 00030e07 2**0 - CONTENTS, READONLY, DEBUGGING - 12 .debug_ranges 00001568 00000000 00000000 0003bb37 2**0 - CONTENTS, READONLY, DEBUGGING - -Disassembly of section .text: - -00000000 <__vectors>: - 0: e8 c4 rjmp .+2512 ; 0x9d2 <__ctors_end> - 2: 00 00 nop - 4: 02 c5 rjmp .+2564 ; 0xa0a <__bad_interrupt> - 6: 00 00 nop - 8: 00 c5 rjmp .+2560 ; 0xa0a <__bad_interrupt> - a: 00 00 nop - c: fe c4 rjmp .+2556 ; 0xa0a <__bad_interrupt> - e: 00 00 nop - 10: fc c4 rjmp .+2552 ; 0xa0a <__bad_interrupt> - 12: 00 00 nop - 14: fa c4 rjmp .+2548 ; 0xa0a <__bad_interrupt> - 16: 00 00 nop - 18: f8 c4 rjmp .+2544 ; 0xa0a <__bad_interrupt> - 1a: 00 00 nop - 1c: f6 c4 rjmp .+2540 ; 0xa0a <__bad_interrupt> - 1e: 00 00 nop - 20: f4 c4 rjmp .+2536 ; 0xa0a <__bad_interrupt> - 22: 00 00 nop - 24: f2 c4 rjmp .+2532 ; 0xa0a <__bad_interrupt> - 26: 00 00 nop - 28: 7b c5 rjmp .+2806 ; 0xb20 <__vector_10> - 2a: 00 00 nop - 2c: ee c4 rjmp .+2524 ; 0xa0a <__bad_interrupt> - 2e: 00 00 nop - 30: ec c4 rjmp .+2520 ; 0xa0a <__bad_interrupt> - 32: 00 00 nop - 34: ea c4 rjmp .+2516 ; 0xa0a <__bad_interrupt> - 36: 00 00 nop - 38: e8 c4 rjmp .+2512 ; 0xa0a <__bad_interrupt> - 3a: 00 00 nop - 3c: e6 c4 rjmp .+2508 ; 0xa0a <__bad_interrupt> - 3e: 00 00 nop - 40: e4 c4 rjmp .+2504 ; 0xa0a <__bad_interrupt> - 42: 00 00 nop - 44: e2 c4 rjmp .+2500 ; 0xa0a <__bad_interrupt> - 46: 00 00 nop - 48: e0 c4 rjmp .+2496 ; 0xa0a <__bad_interrupt> - 4a: 00 00 nop - 4c: de c4 rjmp .+2492 ; 0xa0a <__bad_interrupt> - 4e: 00 00 nop - 50: dc c4 rjmp .+2488 ; 0xa0a <__bad_interrupt> - 52: 00 00 nop - 54: da c4 rjmp .+2484 ; 0xa0a <__bad_interrupt> - 56: 00 00 nop - 58: 0c 94 6c 17 jmp 0x2ed8 ; 0x2ed8 <__vector_22> - 5c: d6 c4 rjmp .+2476 ; 0xa0a <__bad_interrupt> - 5e: 00 00 nop - 60: d4 c4 rjmp .+2472 ; 0xa0a <__bad_interrupt> - 62: 00 00 nop - 64: d2 c4 rjmp .+2468 ; 0xa0a <__bad_interrupt> - 66: 00 00 nop - 68: d0 c4 rjmp .+2464 ; 0xa0a <__bad_interrupt> - 6a: 00 00 nop - 6c: ce c4 rjmp .+2460 ; 0xa0a <__bad_interrupt> - 6e: 00 00 nop - 70: cc c4 rjmp .+2456 ; 0xa0a <__bad_interrupt> - 72: 00 00 nop - 74: ca c4 rjmp .+2452 ; 0xa0a <__bad_interrupt> - 76: 00 00 nop - 78: c8 c4 rjmp .+2448 ; 0xa0a <__bad_interrupt> - 7a: 00 00 nop - 7c: c6 c4 rjmp .+2444 ; 0xa0a <__bad_interrupt> - 7e: 00 00 nop - 80: c4 c4 rjmp .+2440 ; 0xa0a <__bad_interrupt> - 82: 00 00 nop - 84: c2 c4 rjmp .+2436 ; 0xa0a <__bad_interrupt> - 86: 00 00 nop - 88: 0c 94 3b 17 jmp 0x2e76 ; 0x2e76 <__vector_34> - 8c: be c4 rjmp .+2428 ; 0xa0a <__bad_interrupt> - 8e: 00 00 nop - 90: bc c4 rjmp .+2424 ; 0xa0a <__bad_interrupt> - 92: 00 00 nop - 94: ba c4 rjmp .+2420 ; 0xa0a <__bad_interrupt> - 96: 00 00 nop - 98: b8 c4 rjmp .+2416 ; 0xa0a <__bad_interrupt> - 9a: 00 00 nop - 9c: b6 c4 rjmp .+2412 ; 0xa0a <__bad_interrupt> - 9e: 00 00 nop - a0: b4 c4 rjmp .+2408 ; 0xa0a <__bad_interrupt> - a2: 00 00 nop - a4: b2 c4 rjmp .+2404 ; 0xa0a <__bad_interrupt> - a6: 00 00 nop - a8: b0 c4 rjmp .+2400 ; 0xa0a <__bad_interrupt> - aa: 00 00 nop - ac: ae c4 rjmp .+2396 ; 0xa0a <__bad_interrupt> - ae: 00 00 nop - b0: ac c4 rjmp .+2392 ; 0xa0a <__bad_interrupt> - b2: 00 00 nop - b4: aa c4 rjmp .+2388 ; 0xa0a <__bad_interrupt> - b6: 00 00 nop - b8: a8 c4 rjmp .+2384 ; 0xa0a <__bad_interrupt> - ba: 00 00 nop - bc: a6 c4 rjmp .+2380 ; 0xa0a <__bad_interrupt> - be: 00 00 nop - c0: a4 c4 rjmp .+2376 ; 0xa0a <__bad_interrupt> - c2: 00 00 nop - c4: a2 c4 rjmp .+2372 ; 0xa0a <__bad_interrupt> - c6: 00 00 nop - c8: a0 c4 rjmp .+2368 ; 0xa0a <__bad_interrupt> - ca: 00 00 nop - cc: 9e c4 rjmp .+2364 ; 0xa0a <__bad_interrupt> - ce: 00 00 nop - d0: 9c c4 rjmp .+2360 ; 0xa0a <__bad_interrupt> - d2: 00 00 nop - d4: 9a c4 rjmp .+2356 ; 0xa0a <__bad_interrupt> - d6: 00 00 nop - d8: 98 c4 rjmp .+2352 ; 0xa0a <__bad_interrupt> - da: 00 00 nop - dc: 96 c4 rjmp .+2348 ; 0xa0a <__bad_interrupt> - de: 00 00 nop - e0: 94 c4 rjmp .+2344 ; 0xa0a <__bad_interrupt> - e2: 00 00 nop - e4: 92 c4 rjmp .+2340 ; 0xa0a <__bad_interrupt> - e6: 00 00 nop - e8: 90 c4 rjmp .+2336 ; 0xa0a <__bad_interrupt> - ea: 00 00 nop - ec: 8e c4 rjmp .+2332 ; 0xa0a <__bad_interrupt> - ee: 00 00 nop - f0: 8c c4 rjmp .+2328 ; 0xa0a <__bad_interrupt> - f2: 00 00 nop - f4: 8a c4 rjmp .+2324 ; 0xa0a <__bad_interrupt> - f6: 00 00 nop - f8: 88 c4 rjmp .+2320 ; 0xa0a <__bad_interrupt> - fa: 00 00 nop - fc: 86 c4 rjmp .+2316 ; 0xa0a <__bad_interrupt> - fe: 00 00 nop - 100: 84 c4 rjmp .+2312 ; 0xa0a <__bad_interrupt> - 102: 00 00 nop - 104: 82 c4 rjmp .+2308 ; 0xa0a <__bad_interrupt> - 106: 00 00 nop - 108: 80 c4 rjmp .+2304 ; 0xa0a <__bad_interrupt> - 10a: 00 00 nop - 10c: 7e c4 rjmp .+2300 ; 0xa0a <__bad_interrupt> - 10e: 00 00 nop - 110: 7c c4 rjmp .+2296 ; 0xa0a <__bad_interrupt> - 112: 00 00 nop - 114: 7a c4 rjmp .+2292 ; 0xa0a <__bad_interrupt> - 116: 00 00 nop - 118: 78 c4 rjmp .+2288 ; 0xa0a <__bad_interrupt> - 11a: 00 00 nop - 11c: 76 c4 rjmp .+2284 ; 0xa0a <__bad_interrupt> - 11e: 00 00 nop - 120: 74 c4 rjmp .+2280 ; 0xa0a <__bad_interrupt> - 122: 00 00 nop - 124: 72 c4 rjmp .+2276 ; 0xa0a <__bad_interrupt> - 126: 00 00 nop - 128: 70 c4 rjmp .+2272 ; 0xa0a <__bad_interrupt> - 12a: 00 00 nop - 12c: 6e c4 rjmp .+2268 ; 0xa0a <__bad_interrupt> - 12e: 00 00 nop - 130: 6c c4 rjmp .+2264 ; 0xa0a <__bad_interrupt> - 132: 00 00 nop - 134: 6a c4 rjmp .+2260 ; 0xa0a <__bad_interrupt> - 136: 00 00 nop - 138: 68 c4 rjmp .+2256 ; 0xa0a <__bad_interrupt> - 13a: 00 00 nop - 13c: 66 c4 rjmp .+2252 ; 0xa0a <__bad_interrupt> - 13e: 00 00 nop - 140: 64 c4 rjmp .+2248 ; 0xa0a <__bad_interrupt> - 142: 00 00 nop - 144: 62 c4 rjmp .+2244 ; 0xa0a <__bad_interrupt> - 146: 00 00 nop - 148: 60 c4 rjmp .+2240 ; 0xa0a <__bad_interrupt> - 14a: 00 00 nop - 14c: 0c 94 26 18 jmp 0x304c ; 0x304c <__vector_83> - 150: 5c c4 rjmp .+2232 ; 0xa0a <__bad_interrupt> - 152: 00 00 nop - 154: 5a c4 rjmp .+2228 ; 0xa0a <__bad_interrupt> - 156: 00 00 nop - 158: 58 c4 rjmp .+2224 ; 0xa0a <__bad_interrupt> - 15a: 00 00 nop - 15c: 56 c4 rjmp .+2220 ; 0xa0a <__bad_interrupt> - 15e: 00 00 nop - 160: 54 c4 rjmp .+2216 ; 0xa0a <__bad_interrupt> - 162: 00 00 nop - 164: 52 c4 rjmp .+2212 ; 0xa0a <__bad_interrupt> - 166: 00 00 nop - 168: 50 c4 rjmp .+2208 ; 0xa0a <__bad_interrupt> - 16a: 00 00 nop - 16c: 4e c4 rjmp .+2204 ; 0xa0a <__bad_interrupt> - 16e: 00 00 nop - 170: 4c c4 rjmp .+2200 ; 0xa0a <__bad_interrupt> - 172: 00 00 nop - 174: 4a c4 rjmp .+2196 ; 0xa0a <__bad_interrupt> - 176: 00 00 nop - 178: 48 c4 rjmp .+2192 ; 0xa0a <__bad_interrupt> - 17a: 00 00 nop - 17c: 46 c4 rjmp .+2188 ; 0xa0a <__bad_interrupt> - 17e: 00 00 nop - 180: 44 c4 rjmp .+2184 ; 0xa0a <__bad_interrupt> - 182: 00 00 nop - 184: 42 c4 rjmp .+2180 ; 0xa0a <__bad_interrupt> - 186: 00 00 nop - 188: 40 c4 rjmp .+2176 ; 0xa0a <__bad_interrupt> - 18a: 00 00 nop - 18c: 3e c4 rjmp .+2172 ; 0xa0a <__bad_interrupt> - 18e: 00 00 nop - 190: 3c c4 rjmp .+2168 ; 0xa0a <__bad_interrupt> - 192: 00 00 nop - 194: 3a c4 rjmp .+2164 ; 0xa0a <__bad_interrupt> - 196: 00 00 nop - 198: 38 c4 rjmp .+2160 ; 0xa0a <__bad_interrupt> - 19a: 00 00 nop - 19c: 36 c4 rjmp .+2156 ; 0xa0a <__bad_interrupt> - 19e: 00 00 nop - 1a0: 34 c4 rjmp .+2152 ; 0xa0a <__bad_interrupt> - 1a2: 00 00 nop - 1a4: 32 c4 rjmp .+2148 ; 0xa0a <__bad_interrupt> - 1a6: 00 00 nop - 1a8: 30 c4 rjmp .+2144 ; 0xa0a <__bad_interrupt> - 1aa: 00 00 nop - 1ac: 2e c4 rjmp .+2140 ; 0xa0a <__bad_interrupt> - 1ae: 00 00 nop - 1b0: 2c c4 rjmp .+2136 ; 0xa0a <__bad_interrupt> - 1b2: 00 00 nop - 1b4: 2a c4 rjmp .+2132 ; 0xa0a <__bad_interrupt> - 1b6: 00 00 nop - 1b8: 28 c4 rjmp .+2128 ; 0xa0a <__bad_interrupt> - 1ba: 00 00 nop - 1bc: 26 c4 rjmp .+2124 ; 0xa0a <__bad_interrupt> - 1be: 00 00 nop - 1c0: 24 c4 rjmp .+2120 ; 0xa0a <__bad_interrupt> - 1c2: 00 00 nop - 1c4: 22 c4 rjmp .+2116 ; 0xa0a <__bad_interrupt> - 1c6: 00 00 nop - 1c8: 20 c4 rjmp .+2112 ; 0xa0a <__bad_interrupt> - 1ca: 00 00 nop - 1cc: 1e c4 rjmp .+2108 ; 0xa0a <__bad_interrupt> - 1ce: 00 00 nop - 1d0: 1c c4 rjmp .+2104 ; 0xa0a <__bad_interrupt> - 1d2: 00 00 nop - 1d4: 1a c4 rjmp .+2100 ; 0xa0a <__bad_interrupt> - 1d6: 00 00 nop - 1d8: 18 c4 rjmp .+2096 ; 0xa0a <__bad_interrupt> - 1da: 00 00 nop - 1dc: 16 c4 rjmp .+2092 ; 0xa0a <__bad_interrupt> - 1de: 00 00 nop - 1e0: 14 c4 rjmp .+2088 ; 0xa0a <__bad_interrupt> - 1e2: 00 00 nop - 1e4: 12 c4 rjmp .+2084 ; 0xa0a <__bad_interrupt> - 1e6: 00 00 nop - 1e8: 10 c4 rjmp .+2080 ; 0xa0a <__bad_interrupt> - 1ea: 00 00 nop - 1ec: 0e c4 rjmp .+2076 ; 0xa0a <__bad_interrupt> - 1ee: 00 00 nop - 1f0: 0c c4 rjmp .+2072 ; 0xa0a <__bad_interrupt> - 1f2: 00 00 nop - 1f4: 0c 94 14 29 jmp 0x5228 ; 0x5228 <__vector_125> - 1f8: 08 c4 rjmp .+2064 ; 0xa0a <__bad_interrupt> - 1fa: 00 00 nop - 1fc: 82 0f add r24, r18 - 1fe: 80 0f add r24, r16 - 200: 80 0f add r24, r16 - 202: 80 0f add r24, r16 - 204: 80 0f add r24, r16 - 206: 80 0f add r24, r16 - 208: 80 0f add r24, r16 - 20a: 80 0f add r24, r16 - 20c: 80 0f add r24, r16 - 20e: 80 0f add r24, r16 - 210: 80 0f add r24, r16 - 212: 80 0f add r24, r16 - 214: 80 0f add r24, r16 - 216: 80 0f add r24, r16 - 218: 80 0f add r24, r16 - 21a: 80 0f add r24, r16 - 21c: 8d 0f add r24, r29 - 21e: a1 0f add r26, r17 - 220: a7 0f add r26, r23 - 222: ad 0f add r26, r29 - 224: 80 0f add r24, r16 - 226: 80 0f add r24, r16 - 228: 80 0f add r24, r16 - 22a: 80 0f add r24, r16 - 22c: 80 0f add r24, r16 - 22e: 80 0f add r24, r16 - 230: 80 0f add r24, r16 - 232: 80 0f add r24, r16 - 234: 80 0f add r24, r16 - 236: 80 0f add r24, r16 - 238: 80 0f add r24, r16 - 23a: 80 0f add r24, r16 - 23c: 99 0f add r25, r25 - 23e: 99 0f add r25, r25 - 240: 99 0f add r25, r25 - 242: 99 0f add r25, r25 - 244: 99 0f add r25, r25 - 246: 99 0f add r25, r25 - 248: 99 0f add r25, r25 - 24a: 99 0f add r25, r25 - 24c: 79 0f add r23, r25 - 24e: 77 0f add r23, r23 - 250: 77 0f add r23, r23 - 252: 77 0f add r23, r23 - 254: 77 0f add r23, r23 - 256: 77 0f add r23, r23 - 258: 77 0f add r23, r23 - 25a: 77 0f add r23, r23 - 25c: 77 0f add r23, r23 - 25e: 77 0f add r23, r23 - 260: 77 0f add r23, r23 - 262: 77 0f add r23, r23 - 264: 77 0f add r23, r23 - 266: 77 0f add r23, r23 - 268: 77 0f add r23, r23 - 26a: 77 0f add r23, r23 - 26c: 93 0f add r25, r19 - 26e: c3 0f add r28, r19 - 270: b5 0f add r27, r21 - 272: bb 0f add r27, r27 - 274: 77 0f add r23, r23 - 276: 77 0f add r23, r23 - 278: 77 0f add r23, r23 - 27a: 77 0f add r23, r23 - 27c: 77 0f add r23, r23 - 27e: 77 0f add r23, r23 - 280: 77 0f add r23, r23 - 282: 77 0f add r23, r23 - 284: 77 0f add r23, r23 - 286: 77 0f add r23, r23 - 288: 77 0f add r23, r23 - 28a: 77 0f add r23, r23 - 28c: c9 0f add r28, r25 - 28e: c9 0f add r28, r25 - 290: c9 0f add r28, r25 - 292: c9 0f add r28, r25 - 294: c9 0f add r28, r25 - 296: c9 0f add r28, r25 - 298: c9 0f add r28, r25 - 29a: c9 0f add r28, r25 - 29c: 88 14 cp r8, r8 - 29e: 88 14 cp r8, r8 - 2a0: 94 14 cp r9, r4 - 2a2: 9d 14 cp r9, r13 - 2a4: ac 14 cp r10, r12 - 2a6: 5b 14 cp r5, r11 - 2a8: 75 14 cp r7, r5 - 2aa: 7b 14 cp r7, r11 - 2ac: 6f 14 cp r6, r15 - 2ae: ea 18 sub r14, r10 - 2b0: 76 18 sub r7, r6 - 2b2: 7f 18 sub r7, r15 - 2b4: 86 18 sub r8, r6 - 2b6: 94 18 sub r9, r4 - 2b8: 9f 18 sub r9, r15 - 2ba: c4 18 sub r12, r4 - 2bc: 3e 18 sub r3, r14 - 2be: d2 18 sub r13, r2 - 2c0: d9 18 sub r13, r9 - 2c2: e0 18 sub r14, r0 - 2c4: 3c 1c adc r3, r12 - 2c6: 3c 1c adc r3, r12 - 2c8: 54 1c adc r5, r4 - 2ca: ab 1c adc r10, r11 - 2cc: 8e 1d adc r24, r14 - 2ce: 6e 1c adc r6, r14 - 2d0: 6a 1d adc r22, r10 - 2d2: ba 1c adc r11, r10 - 2d4: d8 1c adc r13, r8 - 2d6: 00 1c adc r0, r0 - 2d8: 1f 1c adc r1, r15 - 2da: 1f 1c adc r1, r15 - 2dc: 1f 1c adc r1, r15 - 2de: 1f 24 eor r1, r15 - 2e0: ec 23 and r30, r28 - 2e2: 8b 23 and r24, r27 - 2e4: ec 23 and r30, r28 - 2e6: 8b 23 and r24, r27 - 2e8: da 23 and r29, r26 - 2ea: bc 23 and r27, r28 - 2ec: 8b 23 and r24, r27 - 2ee: b3 23 and r27, r19 - 2f0: 9c 23 and r25, r28 - -000002f2 : - 2f2: 1c 03 4c 00 55 00 46 00 41 00 20 00 43 00 44 00 ..L.U.F.A. .C.D. - 302: 43 00 20 00 44 00 65 00 6d 00 6f 00 00 00 C. .D.e.m.o... - -00000310 : - 310: 18 03 44 00 65 00 61 00 6e 00 20 00 43 00 61 00 ..D.e.a.n. .C.a. - 320: 6d 00 65 00 72 00 61 00 00 00 m.e.r.a... - -0000032a : - 32a: 04 03 09 04 .... - -0000032e : - 32e: 09 02 3e 00 02 01 00 c0 32 09 04 00 00 01 02 02 ..>.....2....... - 33e: 01 00 05 24 00 10 01 04 24 02 06 05 24 06 00 01 ...$....$...$... - 34e: 07 05 82 03 08 00 ff 09 04 01 00 02 0a 00 00 00 ................ - 35e: 07 05 04 02 10 00 05 07 05 83 02 10 00 05 .............. - -0000036c : - 36c: 12 01 10 01 02 00 00 08 d0 16 b2 04 01 00 01 02 ................ - 37c: dc 01 .. - -0000037e : - 37e: 00 4e 4f 4e 45 00 00 00 00 00 00 00 00 00 00 00 .NONE........... - 38e: 00 18 06 19 06 1a 06 1b 06 1c 06 1d 06 20 06 21 ............. .! - 39e: 06 00 00 00 01 01 4d 46 5f 55 4c 54 52 41 4c 49 ......MF_ULTRALI - 3ae: 47 48 54 00 00 00 04 19 3b 19 eb 19 ef 19 f3 19 GHT.....;....... - 3be: f4 19 45 1b 58 1b 40 00 07 00 02 4d 46 5f 43 4c ..E.X.@....MF_CL - 3ce: 41 53 53 49 43 5f 31 4b 00 00 00 04 19 3b 19 97 ASSIC_1K.....;.. - 3de: 1b ca 1b ce 1b cf 1b ce 20 ef 20 00 04 04 00 03 ........ . ..... - 3ee: 4d 46 5f 50 4c 55 53 31 4b 5f 37 42 00 00 00 00 MF_PLUS1K_7B.... - 3fe: 04 19 3b 19 a6 1b ca 1b ce 1b cf 1b ce 20 ef 20 ..;.......... . - 40e: 00 04 07 00 04 4d 46 5f 43 4c 41 53 53 49 43 5f .....MF_CLASSIC_ - 41e: 34 4b 00 00 00 04 19 3b 19 bb 1b ca 1b ce 1b cf 4K.....;........ - 42e: 1b ce 20 ef 20 00 10 04 00 05 49 53 4f 31 34 34 .. . .....ISO144 - 43e: 34 33 41 5f 53 4e 49 46 46 00 04 19 3b 19 1a 06 43A_SNIFF...;... - 44e: 1b 06 1c 06 1d 06 20 06 21 06 00 00 00 01 ...... .!..... - -0000045c : - 45c: 4e 4f 4e 45 00 00 00 00 00 00 00 00 00 00 00 00 NONE............ - 46c: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - 47c: 55 49 44 5f 52 41 4e 44 4f 4d 00 00 00 00 00 00 UID_RANDOM...... - 48c: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - 49c: 55 49 44 5f 4c 45 46 54 5f 49 4e 43 52 45 4d 45 UID_LEFT_INCREME - 4ac: 4e 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 NT.............. - 4bc: 55 49 44 5f 52 49 47 48 54 5f 49 4e 43 52 45 4d UID_RIGHT_INCREM - 4cc: 45 4e 54 00 00 00 00 00 00 00 00 00 00 00 00 00 ENT............. - 4dc: 55 49 44 5f 4c 45 46 54 5f 44 45 43 52 45 4d 45 UID_LEFT_DECREME - 4ec: 4e 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 NT.............. - 4fc: 55 49 44 5f 52 49 47 48 54 5f 44 45 43 52 45 4d UID_RIGHT_DECREM - 50c: 45 4e 54 00 00 00 00 00 00 00 00 00 00 00 00 00 ENT............. - 51c: 43 59 43 4c 45 5f 53 45 54 54 49 4e 47 53 00 00 CYCLE_SETTINGS.. - 52c: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - 53c: 53 54 4f 52 45 5f 4d 45 4d 00 00 00 00 00 00 00 STORE_MEM....... - 54c: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - 55c: 52 45 43 41 4c 4c 5f 4d 45 4d 00 00 00 00 00 00 RECALL_MEM...... - 56c: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - -0000057c <__c.6448>: - 57c: 2c 00 ,. - -0000057e : - 57e: 4f 46 46 00 00 00 00 00 00 00 00 00 00 00 00 00 OFF............. - 58e: 4d 45 4d 4f 52 59 00 00 00 00 00 00 00 00 00 00 MEMORY.......... - 59e: 54 45 52 4d 49 4e 41 4c 00 00 00 00 00 00 00 00 TERMINAL........ - -000005ae : - 5ae: 4e 4f 4e 45 00 00 00 00 00 00 00 00 00 00 00 00 NONE............ - 5be: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - 5ce: 54 45 52 4d 49 4e 41 4c 5f 43 4f 4e 4e 00 00 00 TERMINAL_CONN... - 5de: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - 5ee: 54 45 52 4d 49 4e 41 4c 5f 52 58 54 58 00 00 00 TERMINAL_RXTX... - 5fe: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - 60e: 53 45 54 54 49 4e 47 5f 43 48 41 4e 47 45 00 00 SETTING_CHANGE.. - 61e: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - 62e: 4d 45 4d 4f 52 59 5f 53 54 4f 52 45 44 00 00 00 MEMORY_STORED... - 63e: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - 64e: 4d 45 4d 4f 52 59 5f 43 48 41 4e 47 45 44 00 00 MEMORY_CHANGED.. - 65e: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - 66e: 43 4f 44 45 43 5f 52 58 00 00 00 00 00 00 00 00 CODEC_RX........ - 67e: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - 68e: 43 4f 44 45 43 5f 54 58 00 00 00 00 00 00 00 00 CODEC_TX........ - 69e: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - -000006ae <__c.6718>: - 6ae: 25 35 75 20 6d 56 00 %5u mV. - -000006b5 <__c.6688>: - 6b5: 43 4c 45 41 52 00 CLEAR. - -000006bb <__c.6686>: - 6bb: 4c 4f 41 44 42 49 4e 00 LOADBIN. - -000006c3 <__c.6681>: - 6c3: 25 75 00 %u. - -000006c6 <__c.6672>: - 6c6: 25 53 2c 25 53 00 %S,%S. - -000006cc <__c.6674>: - 6cc: 4c 4f 41 44 42 49 4e 00 LOADBIN. - -000006d4 <__c.6676>: - 6d4: 43 4c 45 41 52 00 CLEAR. - -000006da <__c.6622>: - 6da: 25 75 00 %u. - -000006dd <__c.6617>: - 6dd: 25 75 00 %u. - -000006e0 <__c.6590>: - 6e0: 52 41 4e 44 4f 4d 00 RANDOM. - -000006e7 <__c.6572>: - 6e7: 25 73 00 %s. - -000006ea <__c.6561>: - 6ea: 43 68 61 6d 65 6c 65 6f 6e 2d 4d 69 6e 69 20 25 Chameleon-Mini % - 6fa: 53 20 75 73 69 6e 67 20 4c 55 46 41 20 25 53 20 S using LUFA %S - 70a: 63 6f 6d 70 69 6c 65 64 20 77 69 74 68 20 41 56 compiled with AV - 71a: 52 2d 47 43 43 20 25 53 00 R-GCC %S. - -00000723 <__c.6563>: - 723: 31 35 30 33 30 34 00 150304. - -0000072a <__c.6565>: - 72a: 31 33 30 39 30 31 00 130901. - -00000731 <__c.6567>: - 731: 34 2e 38 2e 31 00 4.8.1. - -00000737 <__c.6227>: - 737: 0d 0a 00 ... - -0000073a <__c.6225>: - 73a: 0d 0a 00 ... - -0000073d : - 73d: 64 31 30 30 3a 4f 4b 00 00 00 00 00 00 00 00 00 d100:OK......... - 74d: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - 75d: 00 65 31 30 31 3a 4f 4b 20 57 49 54 48 20 54 45 .e101:OK WITH TE - 76d: 58 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 XT.............. - 77d: 00 00 6e 31 31 30 3a 57 41 49 54 49 4e 47 20 46 ..n110:WAITING F - 78d: 4f 52 20 58 4d 4f 44 45 4d 00 00 00 00 00 00 00 OR XMODEM....... - 79d: 00 00 00 c8 32 30 30 3a 55 4e 4b 4e 4f 57 4e 20 ....200:UNKNOWN - 7ad: 43 4f 4d 4d 41 4e 44 00 00 00 00 00 00 00 00 00 COMMAND......... - 7bd: 00 00 00 00 c9 32 30 31 3a 49 4e 56 41 4c 49 44 .....201:INVALID - 7cd: 20 43 4f 4d 4d 41 4e 44 20 55 53 41 47 45 00 00 COMMAND USAGE.. - 7dd: 00 00 00 00 00 ca 32 30 32 3a 49 4e 56 41 4c 49 ......202:INVALI - 7ed: 44 20 50 41 52 41 4d 45 54 45 52 00 00 00 00 00 D PARAMETER..... - 7fd: 00 00 00 00 00 00 ...... - -00000803 : - 803: 56 45 52 53 49 4f 4e 00 00 00 00 00 00 00 00 00 VERSION......... - 813: 00 00 00 00 99 11 43 4f 4e 46 49 47 00 00 00 00 ......CONFIG.... - 823: 00 00 00 00 00 00 d6 11 cd 11 b7 11 55 49 44 00 ............UID. - 833: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 12 ................ - 843: dc 11 52 45 41 44 4f 4e 4c 59 00 00 00 00 00 00 ..READONLY...... - 853: 00 00 00 00 6a 12 58 12 55 50 4c 4f 41 44 00 00 ....j.X.UPLOAD.. - 863: 00 00 00 00 00 00 00 00 7e 12 00 00 00 00 44 4f ........~.....DO - 873: 57 4e 4c 4f 41 44 00 00 00 00 00 00 00 00 83 12 WNLOAD.......... - 883: 00 00 00 00 52 45 53 45 54 00 00 00 00 00 00 00 ....RESET....... - 893: 00 00 00 00 88 12 00 00 00 00 55 50 47 52 41 44 ..........UPGRAD - 8a3: 45 00 00 00 00 00 00 00 00 00 93 12 00 00 00 00 E............... - 8b3: 4d 45 4d 53 49 5a 45 00 00 00 00 00 00 00 00 00 MEMSIZE......... - 8c3: 00 00 00 00 9e 12 55 49 44 53 49 5a 45 00 00 00 ......UIDSIZE... - 8d3: 00 00 00 00 00 00 00 00 00 00 b6 12 42 55 54 54 ............BUTT - 8e3: 4f 4e 00 00 00 00 00 00 00 00 00 00 cc 12 d8 12 ON.............. - 8f3: d1 12 42 55 54 54 4f 4e 5f 4c 4f 4e 47 00 00 00 ..BUTTON_LONG... - 903: 00 00 e2 12 ee 12 e7 12 4c 45 44 47 52 45 45 4e ........LEDGREEN - 913: 00 00 00 00 00 00 00 00 f8 12 04 13 fd 12 4c 45 ..............LE - 923: 44 52 45 44 00 00 00 00 00 00 00 00 00 00 0e 13 DRED............ - 933: 1a 13 13 13 4c 4f 47 4d 4f 44 45 00 00 00 00 00 ....LOGMODE..... - 943: 00 00 00 00 24 13 2e 13 29 13 4c 4f 47 4d 45 4d ....$...).LOGMEM - 953: 00 00 00 00 00 00 00 00 00 00 36 13 6a 13 50 13 ..........6.j.P. - 963: 53 45 54 54 49 4e 47 00 00 00 00 00 00 00 00 00 SETTING......... - 973: 00 00 8f 13 8a 13 43 4c 45 41 52 00 00 00 00 00 ......CLEAR..... - 983: 00 00 00 00 00 00 97 13 00 00 00 00 48 45 4c 50 ............HELP - 993: 00 00 00 00 00 00 00 00 00 00 00 00 9b 13 00 00 ................ - 9a3: 00 00 52 53 53 49 00 00 00 00 00 00 00 00 00 00 ..RSSI.......... - 9b3: 00 00 00 00 00 00 e5 13 00 00 00 00 00 00 00 00 ................ - 9c3: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............... - -000009d2 <__ctors_end>: - 9d2: 11 24 eor r1, r1 - 9d4: 1f be out 0x3f, r1 ; 63 - 9d6: cf ef ldi r28, 0xFF ; 255 - 9d8: cd bf out 0x3d, r28 ; 61 - 9da: df e2 ldi r29, 0x2F ; 47 - 9dc: de bf out 0x3e, r29 ; 62 - -000009de <__do_copy_data>: - 9de: 10 e2 ldi r17, 0x20 ; 32 - 9e0: a0 e0 ldi r26, 0x00 ; 0 - 9e2: b0 e2 ldi r27, 0x20 ; 32 - 9e4: ea ee ldi r30, 0xEA ; 234 - 9e6: fe e5 ldi r31, 0x5E ; 94 - 9e8: 02 c0 rjmp .+4 ; 0x9ee <__do_copy_data+0x10> - 9ea: 05 90 lpm r0, Z+ - 9ec: 0d 92 st X+, r0 - 9ee: a2 39 cpi r26, 0x92 ; 146 - 9f0: b1 07 cpc r27, r17 - 9f2: d9 f7 brne .-10 ; 0x9ea <__do_copy_data+0xc> - -000009f4 <__do_clear_bss>: - 9f4: 2e e2 ldi r18, 0x2E ; 46 - 9f6: a2 e9 ldi r26, 0x92 ; 146 - 9f8: b0 e2 ldi r27, 0x20 ; 32 - 9fa: 01 c0 rjmp .+2 ; 0x9fe <.do_clear_bss_start> - -000009fc <.do_clear_bss_loop>: - 9fc: 1d 92 st X+, r1 - -000009fe <.do_clear_bss_start>: - 9fe: a9 3c cpi r26, 0xC9 ; 201 - a00: b2 07 cpc r27, r18 - a02: e1 f7 brne .-8 ; 0x9fc <.do_clear_bss_loop> - a04: 03 d0 rcall .+6 ; 0xa0c
- a06: 0c 94 73 2f jmp 0x5ee6 ; 0x5ee6 <_exit> - -00000a0a <__bad_interrupt>: - a0a: 84 c0 rjmp .+264 ; 0xb14 <__vector_default> - -00000a0c
: -#include "Chameleon-Mini.h" - -int main(void) -{ - SystemInit(); - a0c: 8a d0 rcall .+276 ; 0xb22 - a0e: 0e 94 89 0e call 0x1d12 ; 0x1d12 - SettingsLoad(); - a12: 0e 94 f0 0d call 0x1be0 ; 0x1be0 - LogInit(); - a16: 0e 94 6b 0f call 0x1ed6 ; 0x1ed6 - LEDInit(); - a1a: 07 d3 rcall .+1550 ; 0x102a - MemoryInit(); - a1c: 2e d1 rcall .+604 ; 0xc7a - a1e: 0e 94 24 11 call 0x2248 ; 0x2248 - ConfigurationInit(); - a22: a7 d1 rcall .+846 ; 0xd72 - TerminalInit(); - a24: 68 d7 rcall .+3792 ; 0x18f6 - a26: 81 e0 ldi r24, 0x01 ; 1 - RandomInit(); - a28: 80 93 00 02 sts 0x0200, r24 - ButtonInit(); - a2c: 10 92 01 02 sts 0x0201, r1 -#define ANTENNA_LEVEL_DENOMINATOR (ANTENNA_LEVEL_SCALE) - -static inline -void AntennaLevelInit(void) -{ - ADCA.CTRLA = ADC_ENABLE_bm; - a30: 92 e0 ldi r25, 0x02 ; 2 - a32: 90 93 02 02 sts 0x0202, r25 - ADCA.CTRLB = ADC_RESOLUTION_12BIT_gc; - a36: 93 e0 ldi r25, 0x03 ; 3 - a38: 90 93 04 02 sts 0x0204, r25 - ADCA.REFCTRL = ADC_REFSEL_INT1V_gc | ADC_BANDGAP_bm; - a3c: 80 93 20 02 sts 0x0220, r24 - ADCA.PRESCALER = ADC_PRESCALER_DIV32_gc; - a40: 88 e3 ldi r24, 0x38 ; 56 - a42: 80 93 21 02 sts 0x0221, r24 - ADCA.CH0.CTRL = ADC_CH_INPUTMODE_SINGLEENDED_gc; - a46: ee d0 rcall .+476 ; 0xc24 - a48: 80 91 48 00 lds r24, 0x0048 - ADCA.CH0.MUXCTRL = ADC_CH_MUXPOS_PIN7_gc; - a4c: 81 60 ori r24, 0x01 ; 1 - a4e: 80 93 48 00 sts 0x0048, r24 - AntennaLevelInit(); - - SystemInterruptInit(); - a52: c2 e0 ldi r28, 0x02 ; 2 - asm volatile("sleep"); -} - -INLINE void SystemSleepEnable(void) -{ - SLEEP.CTRL |= SLEEP_SEN_bm; - a54: 0e c0 rjmp .+28 ; 0xa72 - a56: 0e 94 29 11 call 0x2252 ; 0x2252 - a5a: e0 91 fb 28 lds r30, 0x28FB -{ - if (RTC.INTFLAGS & RTC_COMPIF_bm) { - while(RTC.STATUS & RTC_SYNCBUSY_bm) - ; - - RTC.INTFLAGS = RTC_COMPIF_bm; - a5e: f0 91 fc 28 lds r31, 0x28FC - ButtonTick(); - LogTick(); - LEDTick(); - } - - TerminalTask(); - a62: 09 95 icall - a64: 0e 94 9d 0d call 0x1b3a ; 0x1b3a -INLINE void ApplicationInit(void) { - ActiveConfiguration.ApplicationInitFunc(); -} - -INLINE void ApplicationTask(void) { - ActiveConfiguration.ApplicationTaskFunc(); - a68: e0 91 f5 28 lds r30, 0x28F5 - a6c: f0 91 f6 28 lds r31, 0x28F6 - ApplicationTask(); - LogTask(); - a70: 09 95 icall - a72: 80 91 03 04 lds r24, 0x0403 -INLINE void CodecInit(void) { - ActiveConfiguration.CodecInitFunc(); -} - -INLINE void CodecTask(void) { - ActiveConfiguration.CodecTaskFunc(); - a76: 81 ff sbrs r24, 1 - a78: ee cf rjmp .-36 ; 0xa56 - a7a: 80 91 01 04 lds r24, 0x0401 -INLINE void SystemSleepDisable(void); -INLINE void SystemSleepSetMode(uint8_t SleepMode); - -INLINE bool SystemTick100ms(void) -{ - if (RTC.INTFLAGS & RTC_COMPIF_bm) { - a7e: 80 fd sbrc r24, 0 - a80: fc cf rjmp .-8 ; 0xa7a - a82: c0 93 03 04 sts 0x0403, r28 - while(RTC.STATUS & RTC_SYNCBUSY_bm) - a86: 89 d1 rcall .+786 ; 0xd9a - a88: 0e 94 4a 11 call 0x2294 ; 0x2294 - a8c: 3b d7 rcall .+3702 ; 0x1904 - ; - - RTC.INTFLAGS = RTC_COMPIF_bm; - a8e: 0e 94 9c 0d call 0x1b38 ; 0x1b38 - SystemInterruptInit(); - SystemSleepEnable(); - - while(1) { - if (SystemTick100ms()) { - RandomTick(); - a92: 0e 94 70 0f call 0x1ee0 ; 0x1ee0 - TerminalTick(); - a96: df cf rjmp .-66 ; 0xa56 - -00000a98 : - */ -uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, - const uint8_t wIndex, - const void** const DescriptorAddress) -{ - const uint8_t DescriptorType = (wValue >> 8); - a98: 29 2f mov r18, r25 - a9a: 33 27 eor r19, r19 - const uint8_t DescriptorNumber = (wValue & 0xFF); - - const void* Address = NULL; - uint16_t Size = NO_DESCRIPTOR; - - switch (DescriptorType) - a9c: 22 30 cpi r18, 0x02 ; 2 - a9e: 31 05 cpc r19, r1 - aa0: 29 f1 breq .+74 ; 0xaec - aa2: 23 30 cpi r18, 0x03 ; 3 - aa4: 31 05 cpc r19, r1 - aa6: 99 f0 breq .+38 ; 0xace - aa8: 21 30 cpi r18, 0x01 ; 1 - aaa: 31 05 cpc r19, r1 - aac: 41 f0 breq .+16 ; 0xabe -{ - const uint8_t DescriptorType = (wValue >> 8); - const uint8_t DescriptorNumber = (wValue & 0xFF); - - const void* Address = NULL; - uint16_t Size = NO_DESCRIPTOR; - aae: 80 e0 ldi r24, 0x00 ; 0 - ab0: 90 e0 ldi r25, 0x00 ; 0 - const void** const DescriptorAddress) -{ - const uint8_t DescriptorType = (wValue >> 8); - const uint8_t DescriptorNumber = (wValue & 0xFF); - - const void* Address = NULL; - ab2: 20 e0 ldi r18, 0x00 ; 0 - ab4: 30 e0 ldi r19, 0x00 ; 0 - } - - break; - } - - *DescriptorAddress = Address; - ab6: fa 01 movw r30, r20 - ab8: 20 83 st Z, r18 - aba: 31 83 std Z+1, r19 ; 0x01 - return Size; -} - abc: 08 95 ret - - switch (DescriptorType) - { - case DTYPE_Device: - Address = &DeviceDescriptor; - Size = sizeof(USB_Descriptor_Device_t); - abe: 82 e1 ldi r24, 0x12 ; 18 - ac0: 90 e0 ldi r25, 0x00 ; 0 - uint16_t Size = NO_DESCRIPTOR; - - switch (DescriptorType) - { - case DTYPE_Device: - Address = &DeviceDescriptor; - ac2: 2c e6 ldi r18, 0x6C ; 108 - ac4: 33 e0 ldi r19, 0x03 ; 3 - } - - break; - } - - *DescriptorAddress = Address; - ac6: fa 01 movw r30, r20 - ac8: 20 83 st Z, r18 - aca: 31 83 std Z+1, r19 ; 0x01 - return Size; -} - acc: 08 95 ret - ace: 99 27 eor r25, r25 - case DTYPE_Configuration: - Address = &ConfigurationDescriptor; - Size = sizeof(USB_Descriptor_Configuration_t); - break; - case DTYPE_String: - switch (DescriptorNumber) - ad0: 81 30 cpi r24, 0x01 ; 1 - ad2: 91 05 cpc r25, r1 - ad4: 99 f0 breq .+38 ; 0xafc - ad6: 82 30 cpi r24, 0x02 ; 2 - ad8: 91 05 cpc r25, r1 - ada: b1 f0 breq .+44 ; 0xb08 - adc: 89 2b or r24, r25 - ade: 39 f7 brne .-50 ; 0xaae - { - case 0x00: - Address = &LanguageString; - Size = pgm_read_byte(&LanguageString.Header.Size); - ae0: ea e2 ldi r30, 0x2A ; 42 - ae2: f3 e0 ldi r31, 0x03 ; 3 - ae4: 84 91 lpm r24, Z - ae6: 90 e0 ldi r25, 0x00 ; 0 - break; - case DTYPE_String: - switch (DescriptorNumber) - { - case 0x00: - Address = &LanguageString; - ae8: 9f 01 movw r18, r30 - Size = pgm_read_byte(&LanguageString.Header.Size); - break; - aea: e5 cf rjmp .-54 ; 0xab6 - Address = &DeviceDescriptor; - Size = sizeof(USB_Descriptor_Device_t); - break; - case DTYPE_Configuration: - Address = &ConfigurationDescriptor; - Size = sizeof(USB_Descriptor_Configuration_t); - aec: 8e e3 ldi r24, 0x3E ; 62 - aee: 90 e0 ldi r25, 0x00 ; 0 - case DTYPE_Device: - Address = &DeviceDescriptor; - Size = sizeof(USB_Descriptor_Device_t); - break; - case DTYPE_Configuration: - Address = &ConfigurationDescriptor; - af0: 2e e2 ldi r18, 0x2E ; 46 - af2: 33 e0 ldi r19, 0x03 ; 3 - } - - break; - } - - *DescriptorAddress = Address; - af4: fa 01 movw r30, r20 - af6: 20 83 st Z, r18 - af8: 31 83 std Z+1, r19 ; 0x01 - return Size; -} - afa: 08 95 ret - Address = &LanguageString; - Size = pgm_read_byte(&LanguageString.Header.Size); - break; - case 0x01: - Address = &ManufacturerString; - Size = pgm_read_byte(&ManufacturerString.Header.Size); - afc: e0 e1 ldi r30, 0x10 ; 16 - afe: f3 e0 ldi r31, 0x03 ; 3 - b00: 84 91 lpm r24, Z - b02: 90 e0 ldi r25, 0x00 ; 0 - case 0x00: - Address = &LanguageString; - Size = pgm_read_byte(&LanguageString.Header.Size); - break; - case 0x01: - Address = &ManufacturerString; - b04: 9f 01 movw r18, r30 - Size = pgm_read_byte(&ManufacturerString.Header.Size); - break; - b06: d7 cf rjmp .-82 ; 0xab6 - case 0x02: - Address = &ProductString; - Size = pgm_read_byte(&ProductString.Header.Size); - b08: e2 ef ldi r30, 0xF2 ; 242 - b0a: f2 e0 ldi r31, 0x02 ; 2 - b0c: 84 91 lpm r24, Z - b0e: 90 e0 ldi r25, 0x00 ; 0 - case 0x01: - Address = &ManufacturerString; - Size = pgm_read_byte(&ManufacturerString.Header.Size); - break; - case 0x02: - Address = &ProductString; - b10: 9f 01 movw r18, r30 - Size = pgm_read_byte(&ProductString.Header.Size); - break; - b12: d1 cf rjmp .-94 ; 0xab6 - -00000b14 <__vector_default>: -#define WDT_PER_500CLK_gc WDT_PER_512CLK_gc -#endif - - -ISR(BADISR_vect) -{ - b14: 1f 92 push r1 - b16: 0f 92 push r0 - b18: 0f b6 in r0, 0x3f ; 63 - b1a: 0f 92 push r0 - b1c: 11 24 eor r1, r1 - b1e: ff cf rjmp .-2 ; 0xb1e <__vector_default+0xa> - -00000b20 <__vector_10>: - while(1); -} - -EMPTY_INTERRUPT(RTC_OVF_vect); - b20: 18 95 reti - -00000b22 : - -void SystemInit(void) -{ - if (RST.STATUS & RST_WDRF_bm) { - b22: 80 91 78 00 lds r24, 0x0078 - b26: 83 ff sbrs r24, 3 - b28: 0a c0 rjmp .+20 ; 0xb3e - /* On Watchdog reset clear WDRF bit, disable watchdog - * and jump into bootloader */ - RST.STATUS = RST_WDRF_bm; - b2a: 88 e0 ldi r24, 0x08 ; 8 - b2c: 80 93 78 00 sts 0x0078, r24 - - CCP = CCP_IOREG_gc; - b30: 88 ed ldi r24, 0xD8 ; 216 - b32: 84 bf out 0x34, r24 ; 52 - WDT.CTRL = WDT_CEN_bm; - b34: 81 e0 ldi r24, 0x01 ; 1 - b36: 80 93 80 00 sts 0x0080, r24 - - asm volatile ("jmp %0"::"i" (BOOT_SECTION_START + 0x1FC)); - b3a: fd 95 fe c0 jmp 0x7f81fc ; 0x7f81fc <__data_load_end+0x7f2280> - } - - /* 32MHz system clock using internal RC and 32K DFLL*/ - OSC.CTRL |= OSC_RC32MEN_bm | OSC_RC32KEN_bm; - b3e: 80 91 50 00 lds r24, 0x0050 - b42: 86 60 ori r24, 0x06 ; 6 - b44: 80 93 50 00 sts 0x0050, r24 - while(!(OSC.STATUS & OSC_RC32MRDY_bm)) - b48: 80 91 51 00 lds r24, 0x0051 - b4c: 81 ff sbrs r24, 1 - b4e: fc cf rjmp .-8 ; 0xb48 - ; - while(!(OSC.STATUS & OSC_RC32KRDY_bm)) - b50: 80 91 51 00 lds r24, 0x0051 - b54: 82 ff sbrs r24, 2 - b56: fc cf rjmp .-8 ; 0xb50 - ; - - OSC.DFLLCTRL = OSC_RC32MCREF_RC32K_gc; - b58: 10 92 56 00 sts 0x0056, r1 - DFLLRC32M.CTRL = DFLL_ENABLE_bm; - b5c: 21 e0 ldi r18, 0x01 ; 1 - b5e: 20 93 60 00 sts 0x0060, r18 - - CCP = CCP_IOREG_gc; - b62: 88 ed ldi r24, 0xD8 ; 216 - b64: 84 bf out 0x34, r24 ; 52 - CLK.CTRL = CLK_SCLKSEL_RC32M_gc; - b66: 20 93 40 00 sts 0x0040, r18 - - /* Use TCE0 as system tick */ - TCE0.PER = F_CPU / 256 / SYSTEM_TICK_FREQ - 1; - b6a: 83 ed ldi r24, 0xD3 ; 211 - b6c: 90 e3 ldi r25, 0x30 ; 48 - b6e: 80 93 26 0a sts 0x0A26, r24 - b72: 90 93 27 0a sts 0x0A27, r25 - TCE0.CTRLA = TC_CLKSEL_DIV256_gc; - b76: 86 e0 ldi r24, 0x06 ; 6 - b78: 80 93 00 0a sts 0x0A00, r24 - - /* Enable RTC with roughly 1kHz clock for system tick - * and to wake up while sleeping. */ - CLK.RTCCTRL = CLK_RTCSRC_ULP_gc | CLK_RTCEN_bm; - b7c: 20 93 43 00 sts 0x0043, r18 - RTC.PER = 1000 / SYSTEM_TICK_FREQ - 1; - b80: 83 e6 ldi r24, 0x63 ; 99 - b82: 90 e0 ldi r25, 0x00 ; 0 - b84: 80 93 0a 04 sts 0x040A, r24 - b88: 90 93 0b 04 sts 0x040B, r25 - RTC.COMP = 1000 / SYSTEM_TICK_FREQ - 1; - b8c: 80 93 0c 04 sts 0x040C, r24 - b90: 90 93 0d 04 sts 0x040D, r25 - RTC.CTRL = RTC_PRESCALER_DIV1_gc; - b94: 20 93 00 04 sts 0x0400, r18 - RTC.INTCTRL = RTC_OVFINTLVL_LO_gc; - b98: 20 93 02 04 sts 0x0402, r18 - - - /* Enable EEPROM data memory mapping */ - NVM.CTRLB |= NVM_EEMAPEN_bm; - b9c: 80 91 cc 01 lds r24, 0x01CC - ba0: 88 60 ori r24, 0x08 ; 8 - ba2: 80 93 cc 01 sts 0x01CC, r24 - ba6: 08 95 ret - -00000ba8 : -} - -void SystemReset(void) -{ - CCP = CCP_IOREG_gc; - ba8: 88 ed ldi r24, 0xD8 ; 216 - baa: 84 bf out 0x34, r24 ; 52 - RST.CTRL = RST_SWRST_bm; - bac: 81 e0 ldi r24, 0x01 ; 1 - bae: e8 e7 ldi r30, 0x78 ; 120 - bb0: f0 e0 ldi r31, 0x00 ; 0 - bb2: 81 83 std Z+1, r24 ; 0x01 - bb4: 08 95 ret - -00000bb6 : -} - -void SystemEnterBootloader(void) -{ - /* Use Watchdog timer to reset into bootloader. */ - CCP = CCP_IOREG_gc; - bb6: 88 ed ldi r24, 0xD8 ; 216 - bb8: 84 bf out 0x34, r24 ; 52 - WDT.CTRL = WDT_PER_500CLK_gc | WDT_ENABLE_bm | WDT_CEN_bm; - bba: 8b e1 ldi r24, 0x1B ; 27 - bbc: 80 93 80 00 sts 0x0080, r24 - bc0: 08 95 ret - -00000bc2 : - SLEEP.CTRL |= SLEEP_SEN_bm; -} - -INLINE void SystemSleepDisable(void) -{ - SLEEP.CTRL &= ~SLEEP_SEN_bm; - bc2: 80 91 48 00 lds r24, 0x0048 - bc6: 8e 7f andi r24, 0xFE ; 254 - bc8: 80 93 48 00 sts 0x0048, r24 -void SystemStartUSBClock(void) -{ - SystemSleepDisable(); - - /* 48MHz USB Clock using 12MHz XTAL */ - OSC.XOSCCTRL = OSC_FRQRANGE_12TO16_gc | OSC_XOSCSEL_XTAL_16KCLK_gc; - bcc: 8b ec ldi r24, 0xCB ; 203 - bce: 80 93 52 00 sts 0x0052, r24 - OSC.CTRL |= OSC_XOSCEN_bm; - bd2: 80 91 50 00 lds r24, 0x0050 - bd6: 88 60 ori r24, 0x08 ; 8 - bd8: 80 93 50 00 sts 0x0050, r24 - while(!(OSC.STATUS & OSC_XOSCRDY_bm)) - bdc: 80 91 51 00 lds r24, 0x0051 - be0: 83 ff sbrs r24, 3 - be2: fc cf rjmp .-8 ; 0xbdc - ; - - OSC.PLLCTRL = OSC_PLLSRC_XOSC_gc | (4 << OSC_PLLFAC_gp); - be4: 84 ec ldi r24, 0xC4 ; 196 - be6: 80 93 55 00 sts 0x0055, r24 - - OSC.CTRL |= OSC_PLLEN_bm; - bea: 80 91 50 00 lds r24, 0x0050 - bee: 80 61 ori r24, 0x10 ; 16 - bf0: 80 93 50 00 sts 0x0050, r24 - while(!(OSC.STATUS & OSC_PLLRDY_bm)) - bf4: 80 91 51 00 lds r24, 0x0051 - bf8: 84 ff sbrs r24, 4 - bfa: fc cf rjmp .-8 ; 0xbf4 - ; -} - bfc: 08 95 ret - -00000bfe : - asm volatile("sleep"); -} - -INLINE void SystemSleepEnable(void) -{ - SLEEP.CTRL |= SLEEP_SEN_bm; - bfe: e8 e4 ldi r30, 0x48 ; 72 - c00: f0 e0 ldi r31, 0x00 ; 0 - c02: 80 81 ld r24, Z - c04: 81 60 ori r24, 0x01 ; 1 - c06: 80 83 st Z, r24 -void SystemStopUSBClock(void) -{ - SystemSleepEnable(); - - /* Disable USB Clock to minimize power consumption */ - CLK.USBCTRL &= ~CLK_USBSEN_bm; - c08: e0 e4 ldi r30, 0x40 ; 64 - c0a: f0 e0 ldi r31, 0x00 ; 0 - c0c: 84 81 ldd r24, Z+4 ; 0x04 - c0e: 8e 7f andi r24, 0xFE ; 254 - c10: 84 83 std Z+4, r24 ; 0x04 - OSC.CTRL &= ~OSC_PLLEN_bm; - c12: e0 e5 ldi r30, 0x50 ; 80 - c14: f0 e0 ldi r31, 0x00 ; 0 - c16: 80 81 ld r24, Z - c18: 8f 7e andi r24, 0xEF ; 239 - c1a: 80 83 st Z, r24 - OSC.CTRL &= ~OSC_XOSCEN_bm; - c1c: 80 81 ld r24, Z - c1e: 87 7f andi r24, 0xF7 ; 247 - c20: 80 83 st Z, r24 - c22: 08 95 ret - -00000c24 : -} - -void SystemInterruptInit(void) -{ - /* Enable all interrupt levels */ - PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; - c24: 87 e0 ldi r24, 0x07 ; 7 - c26: e0 ea ldi r30, 0xA0 ; 160 - c28: f0 e0 ldi r31, 0x00 ; 0 - c2a: 82 83 std Z+2, r24 ; 0x02 - sei(); - c2c: 78 94 sei - c2e: 08 95 ret - -00000c30 : - -/* Include all Codecs and Applications */ -#include "Codec/Codec.h" -#include "Application/Application.h" - -static void CodecInitDummy(void) { } - c30: 08 95 ret - -00000c32 : -static void CodecTaskDummy(void) { } - c32: 08 95 ret - -00000c34 : -static void ApplicationInitDummy(void) {} - c34: 08 95 ret - -00000c36 : -static void ApplicationResetDummy(void) {} - c36: 08 95 ret - -00000c38 : -static void ApplicationTaskDummy(void) {} - c38: 08 95 ret - -00000c3a : -static uint16_t ApplicationProcessDummy(uint8_t* ByteBuffer, uint16_t ByteCount) { return 0; } - c3a: 80 e0 ldi r24, 0x00 ; 0 - c3c: 90 e0 ldi r25, 0x00 ; 0 - c3e: 08 95 ret - -00000c40 : -static void ApplicationGetUidDummy(ConfigurationUidType Uid) { } - c40: 08 95 ret - -00000c42 : -static void ApplicationSetUidDummy(ConfigurationUidType Uid) { } - c42: 08 95 ret - -00000c44 : - ConfigurationSetById(GlobalSettings.ActiveSettingPtr->Configuration); -} - -void ConfigurationSetById( ConfigurationEnum Configuration ) -{ - GlobalSettings.ActiveSettingPtr->Configuration = Configuration; - c44: e0 91 0a 29 lds r30, 0x290A - c48: f0 91 0b 29 lds r31, 0x290B - c4c: 83 83 std Z+3, r24 ; 0x03 - - /* Copy struct from PROGMEM to RAM */ - memcpy_P(&ActiveConfiguration, - &ConfigurationTable[Configuration], sizeof(ConfigurationType)); - c4e: 95 e2 ldi r25, 0x25 ; 37 - c50: 89 9f mul r24, r25 - c52: b0 01 movw r22, r0 - c54: 11 24 eor r1, r1 - c56: 62 58 subi r22, 0x82 ; 130 - c58: 7c 4f sbci r23, 0xFC ; 252 -void ConfigurationSetById( ConfigurationEnum Configuration ) -{ - GlobalSettings.ActiveSettingPtr->Configuration = Configuration; - - /* Copy struct from PROGMEM to RAM */ - memcpy_P(&ActiveConfiguration, - c5a: 45 e2 ldi r20, 0x25 ; 37 - c5c: 50 e0 ldi r21, 0x00 ; 0 - c5e: 82 ee ldi r24, 0xE2 ; 226 - c60: 98 e2 ldi r25, 0x28 ; 40 - c62: 0e 94 f6 2b call 0x57ec ; 0x57ec -#include "MifareClassic.h" - - -/* Function wrappers */ -INLINE void ApplicationInit(void) { - ActiveConfiguration.ApplicationInitFunc(); - c66: e0 91 f7 28 lds r30, 0x28F7 - c6a: f0 91 f8 28 lds r31, 0x28F8 - c6e: 09 95 icall -#define CODEC_CARRIER_FREQ 13560000 - -extern uint8_t CodecBuffer[CODEC_BUFFER_SIZE]; - -INLINE void CodecInit(void) { - ActiveConfiguration.CodecInitFunc(); - c70: e0 91 f3 28 lds r30, 0x28F3 - c74: f0 91 f4 28 lds r31, 0x28F4 - c78: 09 94 ijmp - -00000c7a : - -ConfigurationType ActiveConfiguration; - -void ConfigurationInit(void) -{ - ConfigurationSetById(GlobalSettings.ActiveSettingPtr->Configuration); - c7a: e0 91 0a 29 lds r30, 0x290A - c7e: f0 91 0b 29 lds r31, 0x290B - c82: 83 81 ldd r24, Z+3 ; 0x03 - c84: df cf rjmp .-66 ; 0xc44 - -00000c86 : - ApplicationInit(); - CodecInit(); -} - -bool ConfigurationSetByName(const char* ConfigurationName) -{ - c86: 0f 93 push r16 - c88: 1f 93 push r17 - c8a: cf 93 push r28 - c8c: df 93 push r29 - c8e: 4f e7 ldi r20, 0x7F ; 127 - c90: 53 e0 ldi r21, 0x03 ; 3 - uint8_t i; - - /* Loop through table trying to find the configuration */ - for (i=0; i<(sizeof(ConfigurationTable) / sizeof(*ConfigurationTable)); i++) { - c92: 10 e0 ldi r17, 0x00 ; 0 - c94: bc 01 movw r22, r24 - c96: 6f 5f subi r22, 0xFF ; 255 - c98: 7f 4f sbci r23, 0xFF ; 255 - const char* pTableConfigName = ConfigurationTable[i].ConfigurationName; - c9a: 9a 01 movw r18, r20 - const char* pRequestedConfigName = ConfigurationName; - bool StringMismatch = false; - char c = pgm_read_byte(pTableConfigName); - c9c: fa 01 movw r30, r20 - c9e: c4 91 lpm r28, Z - - /* Try to keep running until both strings end at the same point */ - while ( !(c == '\0' && *pRequestedConfigName == '\0') ) { - ca0: c1 11 cpse r28, r1 - ca2: 0f c0 rjmp .+30 ; 0xcc2 - uint8_t i; - - /* Loop through table trying to find the configuration */ - for (i=0; i<(sizeof(ConfigurationTable) / sizeof(*ConfigurationTable)); i++) { - const char* pTableConfigName = ConfigurationTable[i].ConfigurationName; - const char* pRequestedConfigName = ConfigurationName; - ca4: ec 01 movw r28, r24 - bool StringMismatch = false; - char c = pgm_read_byte(pTableConfigName); - - /* Try to keep running until both strings end at the same point */ - while ( !(c == '\0' && *pRequestedConfigName == '\0') ) { - ca6: 28 81 ld r18, Y - ca8: 22 23 and r18, r18 - caa: 11 f1 breq .+68 ; 0xcf0 -bool ConfigurationSetByName(const char* ConfigurationName) -{ - uint8_t i; - - /* Loop through table trying to find the configuration */ - for (i=0; i<(sizeof(ConfigurationTable) / sizeof(*ConfigurationTable)); i++) { - cac: 1f 5f subi r17, 0xFF ; 255 - cae: 4b 5d subi r20, 0xDB ; 219 - cb0: 5f 4f sbci r21, 0xFF ; 255 - cb2: 16 30 cpi r17, 0x06 ; 6 - cb4: 91 f7 brne .-28 ; 0xc9a - ConfigurationSetById(i); - return true; - } - } - - return false; - cb6: 80 e0 ldi r24, 0x00 ; 0 -} - cb8: df 91 pop r29 - cba: cf 91 pop r28 - cbc: 1f 91 pop r17 - cbe: 0f 91 pop r16 - cc0: 08 95 ret - bool StringMismatch = false; - char c = pgm_read_byte(pTableConfigName); - - /* Try to keep running until both strings end at the same point */ - while ( !(c == '\0' && *pRequestedConfigName == '\0') ) { - if ( (c == '\0') || (*pRequestedConfigName == '\0') ) { - cc2: dc 01 movw r26, r24 - cc4: fc 91 ld r31, X - cc6: ff 23 and r31, r31 - cc8: 89 f3 breq .-30 ; 0xcac - /* One String ended before the other did -> unequal length */ - StringMismatch = true; - break; - } - - if (c != *pRequestedConfigName) { - cca: cf 13 cpse r28, r31 - ccc: ef cf rjmp .-34 ; 0xcac - cce: db 01 movw r26, r22 - cd0: 05 c0 rjmp .+10 ; 0xcdc - bool StringMismatch = false; - char c = pgm_read_byte(pTableConfigName); - - /* Try to keep running until both strings end at the same point */ - while ( !(c == '\0' && *pRequestedConfigName == '\0') ) { - if ( (c == '\0') || (*pRequestedConfigName == '\0') ) { - cd2: fd 91 ld r31, X+ - cd4: ff 23 and r31, r31 - cd6: 51 f3 breq .-44 ; 0xcac - /* One String ended before the other did -> unequal length */ - StringMismatch = true; - break; - } - - if (c != *pRequestedConfigName) { - cd8: f0 13 cpse r31, r16 - cda: e8 cf rjmp .-48 ; 0xcac - StringMismatch = true; - break; - } - - /* Proceed to next character */ - pTableConfigName++; - cdc: 2f 5f subi r18, 0xFF ; 255 - cde: 3f 4f sbci r19, 0xFF ; 255 - pRequestedConfigName++; - ce0: ed 01 movw r28, r26 - - c = pgm_read_byte(pTableConfigName); - ce2: f9 01 movw r30, r18 - ce4: 04 91 lpm r16, Z - const char* pRequestedConfigName = ConfigurationName; - bool StringMismatch = false; - char c = pgm_read_byte(pTableConfigName); - - /* Try to keep running until both strings end at the same point */ - while ( !(c == '\0' && *pRequestedConfigName == '\0') ) { - ce6: 01 11 cpse r16, r1 - ce8: f4 cf rjmp .-24 ; 0xcd2 - cea: 28 81 ld r18, Y - cec: 21 11 cpse r18, r1 - cee: de cf rjmp .-68 ; 0xcac - c = pgm_read_byte(pTableConfigName); - } - - if (!StringMismatch) { - /* Configuration found */ - ConfigurationSetById(i); - cf0: 81 2f mov r24, r17 - cf2: a8 df rcall .-176 ; 0xc44 - return true; - cf4: 81 e0 ldi r24, 0x01 ; 1 - } - } - - return false; -} - cf6: df 91 pop r29 - cf8: cf 91 pop r28 - cfa: 1f 91 pop r17 - cfc: 0f 91 pop r16 - cfe: 08 95 ret - -00000d00 : - -void ConfigurationGetList(char* ConfigListOut, uint16_t ByteCount) -{ - d00: 0f 93 push r16 - d02: 1f 93 push r17 - d04: cf 93 push r28 - d06: df 93 push r29 - uint8_t i; - - /* Account for '\0' */ - ByteCount--; - d08: 61 50 subi r22, 0x01 ; 1 - d0a: 71 09 sbc r23, r1 - d0c: 4f e7 ldi r20, 0x7F ; 127 - d0e: 53 e0 ldi r21, 0x03 ; 3 - ByteCount--; - } - - if ( i < (CONFIG_COUNT - 1) ) { - /* No comma on last configuration */ - *ConfigListOut++ = ','; - d10: 1c e2 ldi r17, 0x2C ; 44 - - /* Account for '\0' */ - ByteCount--; - - for (i=0; i CONFIGURATION_NAME_LENGTH_MAX) { - d14: fa 01 movw r30, r20 - d16: 04 91 lpm r16, Z - d18: 00 23 and r16, r16 - d1a: 49 f1 breq .+82 ; 0xd6e - d1c: 61 31 cpi r22, 0x11 ; 17 - d1e: 71 05 cpc r23, r1 - d20: 20 f4 brcc .+8 ; 0xd2a - d22: 25 c0 rjmp .+74 ; 0xd6e - d24: 60 31 cpi r22, 0x10 ; 16 - d26: 71 05 cpc r23, r1 - d28: 61 f0 breq .+24 ; 0xd42 - d2a: dc 01 movw r26, r24 - d2c: 01 96 adiw r24, 0x01 ; 1 - d2e: ec 01 movw r28, r24 - /* While not end-of-string and enough buffer to - * put a complete configuration name */ - *ConfigListOut++ = c; - d30: 0c 93 st X, r16 - ConfigName++; - d32: 2f 5f subi r18, 0xFF ; 255 - d34: 3f 4f sbci r19, 0xFF ; 255 - ByteCount--; - d36: 61 50 subi r22, 0x01 ; 1 - d38: 71 09 sbc r23, r1 - - for (i=0; i CONFIGURATION_NAME_LENGTH_MAX) { - d3a: f9 01 movw r30, r18 - d3c: 04 91 lpm r16, Z - d3e: 01 11 cpse r16, r1 - d40: f1 cf rjmp .-30 ; 0xd24 - *ConfigListOut++ = c; - ConfigName++; - ByteCount--; - } - - if ( i < (CONFIG_COUNT - 1) ) { - d42: f4 e0 ldi r31, 0x04 ; 4 - d44: 48 33 cpi r20, 0x38 ; 56 - d46: 5f 07 cpc r21, r31 - d48: 61 f0 breq .+24 ; 0xd62 - /* No comma on last configuration */ - *ConfigListOut++ = ','; - d4a: ce 01 movw r24, r28 - d4c: 01 96 adiw r24, 0x01 ; 1 - d4e: 18 83 st Y, r17 - ByteCount--; - d50: 61 50 subi r22, 0x01 ; 1 - d52: 71 09 sbc r23, r1 - d54: 4b 5d subi r20, 0xDB ; 219 - d56: 5f 4f sbci r21, 0xFF ; 255 - uint8_t i; - - /* Account for '\0' */ - ByteCount--; - - for (i=0; i - ByteCount--; - } - - if ( i < (CONFIG_COUNT - 1) ) { - /* No comma on last configuration */ - *ConfigListOut++ = ','; - d60: ec 01 movw r28, r24 - ByteCount--; - } - } - - *ConfigListOut = '\0'; - d62: 18 82 st Y, r1 -} - d64: df 91 pop r29 - d66: cf 91 pop r28 - d68: 1f 91 pop r17 - d6a: 0f 91 pop r16 - d6c: 08 95 ret - - for (i=0; i CONFIGURATION_NAME_LENGTH_MAX) { - d6e: ec 01 movw r28, r24 - d70: e8 cf rjmp .-48 ; 0xd42 - -00000d72 : -#include "Random.h" - -#include - -void RandomInit(void) -{ - d72: 08 95 ret - -00000d74 : - -} - -uint8_t RandomGetByte(void) -{ - return rand() & 0xFF; - d74: 0c 94 e8 2b jmp 0x57d0 ; 0x57d0 -} - d78: 08 95 ret - -00000d7a : - -void RandomGetBuffer(void* Buffer, uint8_t ByteCount) -{ - d7a: 1f 93 push r17 - d7c: cf 93 push r28 - d7e: df 93 push r29 - uint8_t* BufferPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - d80: 66 23 and r22, r22 - d82: 39 f0 breq .+14 ; 0xd92 - d84: ec 01 movw r28, r24 - d86: 16 2f mov r17, r22 - -} - -uint8_t RandomGetByte(void) -{ - return rand() & 0xFF; - d88: 0e 94 e8 2b call 0x57d0 ; 0x57d0 - d8c: 89 93 st Y+, r24 - d8e: 11 50 subi r17, 0x01 ; 1 - -void RandomGetBuffer(void* Buffer, uint8_t ByteCount) -{ - uint8_t* BufferPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - d90: d9 f7 brne .-10 ; 0xd88 - *BufferPtr++ = RandomGetByte(); - } -} - d92: df 91 pop r29 - d94: cf 91 pop r28 - d96: 1f 91 pop r17 - d98: 08 95 ret - -00000d9a : - -void RandomTick(void) -{ - rand(); - d9a: 0e 94 e8 2b call 0x57d0 ; 0x57d0 - rand(); - d9e: 0e 94 e8 2b call 0x57d0 ; 0x57d0 - rand(); - da2: 0e 94 e8 2b call 0x57d0 ; 0x57d0 - rand(); - da6: 0c 94 e8 2b jmp 0x57d0 ; 0x57d0 - -00000daa : -#include "Common.h" - -uint16_t BufferToHexString(char* HexOut, uint16_t MaxChars, const void* Buffer, uint16_t ByteCount) -{ - daa: cf 93 push r28 - dac: df 93 push r29 - dae: dc 01 movw r26, r24 - uint8_t* ByteBuffer = (uint8_t*) Buffer; - uint16_t CharCount = 0; - - /* Account for '\0' at the end */ - MaxChars--; - db0: 61 50 subi r22, 0x01 ; 1 - db2: 71 09 sbc r23, r1 - - while( (ByteCount > 0) && (MaxChars >= 2) ) { - db4: 21 15 cp r18, r1 - db6: 31 05 cpc r19, r1 - db8: a9 f1 breq .+106 ; 0xe24 - dba: 62 30 cpi r22, 0x02 ; 2 - dbc: 71 05 cpc r23, r1 - dbe: 90 f1 brcs .+100 ; 0xe24 - dc0: fa 01 movw r30, r20 - dc2: 21 50 subi r18, 0x01 ; 1 - dc4: 31 09 sbc r19, r1 - dc6: 24 0f add r18, r20 - dc8: 35 1f adc r19, r21 -#include "Common.h" - -uint16_t BufferToHexString(char* HexOut, uint16_t MaxChars, const void* Buffer, uint16_t ByteCount) -{ - uint8_t* ByteBuffer = (uint8_t*) Buffer; - uint16_t CharCount = 0; - dca: 80 e0 ldi r24, 0x00 ; 0 - dcc: 90 e0 ldi r25, 0x00 ; 0 - dce: 17 c0 rjmp .+46 ; 0xdfe - MaxChars--; - - while( (ByteCount > 0) && (MaxChars >= 2) ) { - uint8_t Byte = *ByteBuffer; - - HexOut[0] = NIBBLE_TO_HEXCHAR( (Byte >> 4) & 0x0F ); - dd0: d0 5d subi r29, 0xD0 ; 208 - dd2: dc 93 st X, r29 - HexOut[1] = NIBBLE_TO_HEXCHAR( (Byte >> 0) & 0x0F ); - dd4: cf 70 andi r28, 0x0F ; 15 - dd6: 4c 2f mov r20, r28 - dd8: 50 e0 ldi r21, 0x00 ; 0 - dda: 4a 30 cpi r20, 0x0A ; 10 - ddc: 51 05 cpc r21, r1 - dde: 04 f5 brge .+64 ; 0xe20 - de0: c0 5d subi r28, 0xD0 ; 208 - de2: 11 96 adiw r26, 0x01 ; 1 - de4: cc 93 st X, r28 - de6: 11 97 sbiw r26, 0x01 ; 1 - - HexOut += 2; - de8: 12 96 adiw r26, 0x02 ; 2 - MaxChars -= 2; - dea: 62 50 subi r22, 0x02 ; 2 - dec: 71 09 sbc r23, r1 - CharCount += 2; - dee: 02 96 adiw r24, 0x02 ; 2 - uint16_t CharCount = 0; - - /* Account for '\0' at the end */ - MaxChars--; - - while( (ByteCount > 0) && (MaxChars >= 2) ) { - df0: e2 17 cp r30, r18 - df2: f3 07 cpc r31, r19 - df4: c9 f0 breq .+50 ; 0xe28 - df6: 31 96 adiw r30, 0x01 ; 1 - df8: 62 30 cpi r22, 0x02 ; 2 - dfa: 71 05 cpc r23, r1 - dfc: a8 f0 brcs .+42 ; 0xe28 - uint8_t Byte = *ByteBuffer; - dfe: c0 81 ld r28, Z - - HexOut[0] = NIBBLE_TO_HEXCHAR( (Byte >> 4) & 0x0F ); - e00: dc 2f mov r29, r28 - e02: d2 95 swap r29 - e04: df 70 andi r29, 0x0F ; 15 - e06: 4d 2f mov r20, r29 - e08: 50 e0 ldi r21, 0x00 ; 0 - e0a: 4a 30 cpi r20, 0x0A ; 10 - e0c: 51 05 cpc r21, r1 - e0e: 04 f3 brlt .-64 ; 0xdd0 - e10: d9 5c subi r29, 0xC9 ; 201 - e12: dc 93 st X, r29 - HexOut[1] = NIBBLE_TO_HEXCHAR( (Byte >> 0) & 0x0F ); - e14: cf 70 andi r28, 0x0F ; 15 - e16: 4c 2f mov r20, r28 - e18: 50 e0 ldi r21, 0x00 ; 0 - e1a: 4a 30 cpi r20, 0x0A ; 10 - e1c: 51 05 cpc r21, r1 - e1e: 04 f3 brlt .-64 ; 0xde0 - e20: c9 5c subi r28, 0xC9 ; 201 - e22: df cf rjmp .-66 ; 0xde2 -#include "Common.h" - -uint16_t BufferToHexString(char* HexOut, uint16_t MaxChars, const void* Buffer, uint16_t ByteCount) -{ - uint8_t* ByteBuffer = (uint8_t*) Buffer; - uint16_t CharCount = 0; - e24: 80 e0 ldi r24, 0x00 ; 0 - e26: 90 e0 ldi r25, 0x00 ; 0 - CharCount += 2; - ByteBuffer++; - ByteCount -= 1; - } - - *HexOut = '\0'; - e28: 1c 92 st X, r1 - - return CharCount; -} - e2a: df 91 pop r29 - e2c: cf 91 pop r28 - e2e: 08 95 ret - -00000e30 : - -uint16_t HexStringToBuffer(void* Buffer, uint16_t MaxBytes, const char* HexIn) -{ - e30: dc 01 movw r26, r24 - e32: fa 01 movw r30, r20 - uint8_t* ByteBuffer = (uint8_t*) Buffer; - uint16_t ByteCount = 0; - - while( (HexIn[0] != '\0') && (HexIn[1] != '\0') && (MaxBytes > 0) ) { - e34: 80 81 ld r24, Z - e36: 88 23 and r24, r24 - e38: 09 f4 brne .+2 ; 0xe3c - e3a: 41 c0 rjmp .+130 ; 0xebe - e3c: 91 81 ldd r25, Z+1 ; 0x01 - e3e: 99 23 and r25, r25 - e40: d9 f1 breq .+118 ; 0xeb8 -} - -uint16_t HexStringToBuffer(void* Buffer, uint16_t MaxBytes, const char* HexIn) -{ - uint8_t* ByteBuffer = (uint8_t*) Buffer; - uint16_t ByteCount = 0; - e42: 20 e0 ldi r18, 0x00 ; 0 - e44: 30 e0 ldi r19, 0x00 ; 0 - - while( (HexIn[0] != '\0') && (HexIn[1] != '\0') && (MaxBytes > 0) ) { - e46: 61 15 cp r22, r1 - e48: 71 05 cpc r23, r1 - e4a: a1 f4 brne .+40 ; 0xe74 - e4c: 33 c0 rjmp .+102 ; 0xeb4 - if (VALID_HEXCHAR(HexIn[0]) && VALID_HEXCHAR(HexIn[1])) { - uint8_t Byte = 0; - - Byte |= HEXCHAR_TO_NIBBLE(HexIn[0]) << 4; - e4e: 82 95 swap r24 - e50: 80 7f andi r24, 0xF0 ; 240 - Byte |= HEXCHAR_TO_NIBBLE(HexIn[1]) << 0; - e52: 91 34 cpi r25, 0x41 ; 65 - e54: 30 f5 brcc .+76 ; 0xea2 - e56: 94 2f mov r25, r20 - e58: 89 2b or r24, r25 - - *ByteBuffer = Byte; - e5a: 8d 93 st X+, r24 - - ByteBuffer++; - MaxBytes--; - ByteCount++; - e5c: 2f 5f subi r18, 0xFF ; 255 - e5e: 3f 4f sbci r19, 0xFF ; 255 - HexIn += 2; - e60: 32 96 adiw r30, 0x02 ; 2 -uint16_t HexStringToBuffer(void* Buffer, uint16_t MaxBytes, const char* HexIn) -{ - uint8_t* ByteBuffer = (uint8_t*) Buffer; - uint16_t ByteCount = 0; - - while( (HexIn[0] != '\0') && (HexIn[1] != '\0') && (MaxBytes > 0) ) { - e62: 80 81 ld r24, Z - e64: 88 23 and r24, r24 - e66: 31 f1 breq .+76 ; 0xeb4 - e68: 91 81 ldd r25, Z+1 ; 0x01 - e6a: 99 23 and r25, r25 - e6c: 29 f1 breq .+74 ; 0xeb8 - e6e: 62 17 cp r22, r18 - e70: 73 07 cpc r23, r19 - e72: 01 f1 breq .+64 ; 0xeb4 - if (VALID_HEXCHAR(HexIn[0]) && VALID_HEXCHAR(HexIn[1])) { - e74: 40 ed ldi r20, 0xD0 ; 208 - e76: 48 0f add r20, r24 - e78: 4a 30 cpi r20, 0x0A ; 10 - e7a: 20 f0 brcs .+8 ; 0xe84 - e7c: 4f eb ldi r20, 0xBF ; 191 - e7e: 48 0f add r20, r24 - e80: 46 30 cpi r20, 0x06 ; 6 - e82: d0 f4 brcc .+52 ; 0xeb8 - e84: 40 ed ldi r20, 0xD0 ; 208 - e86: 49 0f add r20, r25 - e88: 4a 30 cpi r20, 0x0A ; 10 - e8a: 20 f0 brcs .+8 ; 0xe94 - e8c: 5f eb ldi r21, 0xBF ; 191 - e8e: 59 0f add r21, r25 - e90: 56 30 cpi r21, 0x06 ; 6 - e92: 90 f4 brcc .+36 ; 0xeb8 - uint8_t Byte = 0; - - Byte |= HEXCHAR_TO_NIBBLE(HexIn[0]) << 4; - e94: 81 34 cpi r24, 0x41 ; 65 - e96: d8 f2 brcs .-74 ; 0xe4e - e98: 82 95 swap r24 - e9a: 80 7f andi r24, 0xF0 ; 240 - e9c: 80 57 subi r24, 0x70 ; 112 - Byte |= HEXCHAR_TO_NIBBLE(HexIn[1]) << 0; - e9e: 91 34 cpi r25, 0x41 ; 65 - ea0: d0 f2 brcs .-76 ; 0xe56 - ea2: 97 53 subi r25, 0x37 ; 55 - ea4: 89 2b or r24, r25 - - *ByteBuffer = Byte; - ea6: 8d 93 st X+, r24 - - ByteBuffer++; - MaxBytes--; - ByteCount++; - ea8: 2f 5f subi r18, 0xFF ; 255 - eaa: 3f 4f sbci r19, 0xFF ; 255 - HexIn += 2; - eac: 32 96 adiw r30, 0x02 ; 2 -uint16_t HexStringToBuffer(void* Buffer, uint16_t MaxBytes, const char* HexIn) -{ - uint8_t* ByteBuffer = (uint8_t*) Buffer; - uint16_t ByteCount = 0; - - while( (HexIn[0] != '\0') && (HexIn[1] != '\0') && (MaxBytes > 0) ) { - eae: 80 81 ld r24, Z - eb0: 81 11 cpse r24, r1 - eb2: da cf rjmp .-76 ; 0xe68 - if ( (HexIn[0] != '\0') && (HexIn[1] == '\0') ) { - /* Odd number of characters */ - return 0; - } - - return ByteCount; - eb4: c9 01 movw r24, r18 - eb6: 08 95 ret - } - } - - if ( (HexIn[0] != '\0') && (HexIn[1] == '\0') ) { - /* Odd number of characters */ - return 0; - eb8: 80 e0 ldi r24, 0x00 ; 0 - eba: 90 e0 ldi r25, 0x00 ; 0 - } - - return ByteCount; -} - ebc: 08 95 ret -} - -uint16_t HexStringToBuffer(void* Buffer, uint16_t MaxBytes, const char* HexIn) -{ - uint8_t* ByteBuffer = (uint8_t*) Buffer; - uint16_t ByteCount = 0; - ebe: 20 e0 ldi r18, 0x00 ; 0 - ec0: 30 e0 ldi r19, 0x00 ; 0 - ec2: f8 cf rjmp .-16 ; 0xeb4 - -00000ec4 : - MemoryRecall(); -} - -void MemoryReadBlock(void* Buffer, uint16_t Address, uint16_t ByteCount) -{ - uint8_t* SrcPtr = &Memory[Address]; - ec4: fb 01 movw r30, r22 - ec6: ee 56 subi r30, 0x6E ; 110 - ec8: ff 4d sbci r31, 0xDF ; 223 - uint8_t* DstPtr = (uint8_t*) Buffer; - - /* Prevent Buf Ovfs */ - ByteCount = MIN(ByteCount, MEMORY_SIZE_PER_SETTING - Address); - eca: 20 e0 ldi r18, 0x00 ; 0 - ecc: 34 e0 ldi r19, 0x04 ; 4 - ece: 26 1b sub r18, r22 - ed0: 37 0b sbc r19, r23 - ed2: 42 17 cp r20, r18 - ed4: 53 07 cpc r21, r19 - ed6: 08 f4 brcc .+2 ; 0xeda - ed8: 9a 01 movw r18, r20 - - while(ByteCount--) { - eda: 21 15 cp r18, r1 - edc: 31 05 cpc r19, r1 - ede: 49 f0 breq .+18 ; 0xef2 - ee0: dc 01 movw r26, r24 - ee2: cf 01 movw r24, r30 - ee4: 82 0f add r24, r18 - ee6: 93 1f adc r25, r19 - *DstPtr++ = *SrcPtr++; - ee8: 21 91 ld r18, Z+ - eea: 2d 93 st X+, r18 - uint8_t* DstPtr = (uint8_t*) Buffer; - - /* Prevent Buf Ovfs */ - ByteCount = MIN(ByteCount, MEMORY_SIZE_PER_SETTING - Address); - - while(ByteCount--) { - eec: e8 17 cp r30, r24 - eee: f9 07 cpc r31, r25 - ef0: d9 f7 brne .-10 ; 0xee8 - ef2: 08 95 ret - -00000ef4 : -} - -void MemoryWriteBlock(const void* Buffer, uint16_t Address, uint16_t ByteCount) -{ - uint8_t* SrcPtr = (uint8_t*) Buffer; - uint8_t* DstPtr = &Memory[Address]; - ef4: db 01 movw r26, r22 - ef6: ae 56 subi r26, 0x6E ; 110 - ef8: bf 4d sbci r27, 0xDF ; 223 - - /* Prevent Buf Ovfs */ - ByteCount = MIN(ByteCount, MEMORY_SIZE_PER_SETTING - Address); - efa: 20 e0 ldi r18, 0x00 ; 0 - efc: 34 e0 ldi r19, 0x04 ; 4 - efe: 26 1b sub r18, r22 - f00: 37 0b sbc r19, r23 - f02: 42 17 cp r20, r18 - f04: 53 07 cpc r21, r19 - f06: 08 f4 brcc .+2 ; 0xf0a - f08: 9a 01 movw r18, r20 - - while(ByteCount--) { - f0a: 21 15 cp r18, r1 - f0c: 31 05 cpc r19, r1 - f0e: 41 f0 breq .+16 ; 0xf20 - f10: fc 01 movw r30, r24 - f12: 82 0f add r24, r18 - f14: 93 1f adc r25, r19 - *DstPtr++ = *SrcPtr++; - f16: 21 91 ld r18, Z+ - f18: 2d 93 st X+, r18 - uint8_t* DstPtr = &Memory[Address]; - - /* Prevent Buf Ovfs */ - ByteCount = MIN(ByteCount, MEMORY_SIZE_PER_SETTING - Address); - - while(ByteCount--) { - f1a: e8 17 cp r30, r24 - f1c: f9 07 cpc r31, r25 - f1e: d9 f7 brne .-10 ; 0xf16 - *DstPtr++ = *SrcPtr++; - } - - LEDTrigger(LED_MEMORY_CHANGED, LED_ON); - f20: 61 e1 ldi r22, 0x11 ; 17 - f22: 85 e0 ldi r24, 0x05 ; 5 - f24: 0c 94 f1 0f jmp 0x1fe2 ; 0x1fe2 - -00000f28 : -} - -void MemoryClear(void) -{ - f28: 80 e0 ldi r24, 0x00 ; 0 - f2a: 94 e0 ldi r25, 0x04 ; 4 - f2c: e2 e9 ldi r30, 0x92 ; 146 - f2e: f0 e2 ldi r31, 0x20 ; 32 - f30: df 01 movw r26, r30 - f32: 9c 01 movw r18, r24 - f34: 1d 92 st X+, r1 - f36: 21 50 subi r18, 0x01 ; 1 - f38: 30 40 sbci r19, 0x00 ; 0 - f3a: e1 f7 brne .-8 ; 0xf34 - f3c: 08 95 ret - -00000f3e : -} - -void MemoryRecall(void) -{ - /* Recall memory from permanent flash */ - FlashRead(Memory, (uint32_t) GlobalSettings.ActiveSettingIdx * MEMORY_SIZE_PER_SETTING, MEMORY_SIZE_PER_SETTING); - f3e: 80 91 09 29 lds r24, 0x2909 - f42: 90 e0 ldi r25, 0x00 ; 0 - f44: a0 e0 ldi r26, 0x00 ; 0 - f46: b0 e0 ldi r27, 0x00 ; 0 - f48: 4a e0 ldi r20, 0x0A ; 10 - f4a: 88 0f add r24, r24 - f4c: 99 1f adc r25, r25 - f4e: aa 1f adc r26, r26 - f50: bb 1f adc r27, r27 - f52: 4a 95 dec r20 - f54: d1 f7 brne .-12 ; 0xf4a - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - f56: 40 e1 ldi r20, 0x10 ; 16 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - f58: 57 ed ldi r21, 0xD7 ; 215 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - f5a: 30 e4 ldi r19, 0x40 ; 64 - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - f5c: 40 93 66 06 sts 0x0666, r20 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - f60: 50 93 a0 09 sts 0x09A0, r21 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - f64: 20 91 a1 09 lds r18, 0x09A1 - f68: 26 ff sbrs r18, 6 - f6a: fc cf rjmp .-8 ; 0xf64 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - f6c: 30 93 a1 09 sts 0x09A1, r19 - - return MEMORY_FLASH_USART.DATA; - f70: 20 91 a0 09 lds r18, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - f74: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - f78: 20 91 a1 09 lds r18, 0x09A1 - f7c: 26 ff sbrs r18, 6 - f7e: fc cf rjmp .-8 ; 0xf78 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - f80: 30 93 a1 09 sts 0x09A1, r19 - - return MEMORY_FLASH_USART.DATA; - f84: 20 91 a0 09 lds r18, 0x09A0 - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(FLASH_CMD_STATUS_REG_READ); - Register = SPITransferByte(0); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - f88: 40 93 65 06 sts 0x0665, r20 - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; -} - -INLINE void FlashRead(void* Buffer, uint32_t Address, uint16_t ByteCount) -{ - while(FlashIsBusy()); - f8c: 27 ff sbrs r18, 7 - f8e: e6 cf rjmp .-52 ; 0xf5c - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - f90: 20 e1 ldi r18, 0x10 ; 16 - f92: 20 93 66 06 sts 0x0666, r18 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - f96: 23 e0 ldi r18, 0x03 ; 3 - f98: 20 93 a0 09 sts 0x09A0, r18 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - f9c: 20 91 a1 09 lds r18, 0x09A1 - fa0: 26 ff sbrs r18, 6 - fa2: fc cf rjmp .-8 ; 0xf9c - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - fa4: 20 e4 ldi r18, 0x40 ; 64 - fa6: 20 93 a1 09 sts 0x09A1, r18 - - return MEMORY_FLASH_USART.DATA; - faa: 20 91 a0 09 lds r18, 0x09A0 -{ - while(FlashIsBusy()); - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(0x03); - SPITransferByte( (Address >> 16) & 0xFF ); - fae: ad 01 movw r20, r26 - fb0: 66 27 eor r22, r22 - fb2: 77 27 eor r23, r23 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - fb4: 40 93 a0 09 sts 0x09A0, r20 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - fb8: 20 91 a1 09 lds r18, 0x09A1 - fbc: 26 ff sbrs r18, 6 - fbe: fc cf rjmp .-8 ; 0xfb8 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - fc0: 20 e4 ldi r18, 0x40 ; 64 - fc2: 20 93 a1 09 sts 0x09A1, r18 - - return MEMORY_FLASH_USART.DATA; - fc6: 20 91 a0 09 lds r18, 0x09A0 - while(FlashIsBusy()); - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(0x03); - SPITransferByte( (Address >> 16) & 0xFF ); - SPITransferByte( (Address >> 8) & 0xFF ); - fca: 89 2f mov r24, r25 - fcc: 9a 2f mov r25, r26 - fce: ab 2f mov r26, r27 - fd0: bb 27 eor r27, r27 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - fd2: 80 93 a0 09 sts 0x09A0, r24 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - fd6: 80 91 a1 09 lds r24, 0x09A1 - fda: 86 ff sbrs r24, 6 - fdc: fc cf rjmp .-8 ; 0xfd6 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - fde: 80 e4 ldi r24, 0x40 ; 64 - fe0: 80 93 a1 09 sts 0x09A1, r24 - - return MEMORY_FLASH_USART.DATA; - fe4: 80 91 a0 09 lds r24, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - fe8: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - fec: 80 91 a1 09 lds r24, 0x09A1 - ff0: 86 ff sbrs r24, 6 - ff2: fc cf rjmp .-8 ; 0xfec - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - ff4: 80 e4 ldi r24, 0x40 ; 64 - ff6: 80 93 a1 09 sts 0x09A1, r24 - - return MEMORY_FLASH_USART.DATA; - ffa: 80 91 a0 09 lds r24, 0x09A0 - ffe: e2 e9 ldi r30, 0x92 ; 146 - 1000: f0 e2 ldi r31, 0x20 ; 32 - uint8_t* ByteBuffer = (uint8_t*) Buffer; - - while(ByteCount-- > 0) { - MEMORY_FLASH_USART.DATA = 0; - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1002: 90 e4 ldi r25, 0x40 ; 64 -INLINE void SPIReadBlock(void* Buffer, uint16_t ByteCount) -{ - uint8_t* ByteBuffer = (uint8_t*) Buffer; - - while(ByteCount-- > 0) { - MEMORY_FLASH_USART.DATA = 0; - 1004: 10 92 a0 09 sts 0x09A0, r1 - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1008: 80 91 a1 09 lds r24, 0x09A1 - 100c: 86 ff sbrs r24, 6 - 100e: fc cf rjmp .-8 ; 0x1008 - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1010: 90 93 a1 09 sts 0x09A1, r25 - *ByteBuffer++ = MEMORY_FLASH_USART.DATA; - 1014: 80 91 a0 09 lds r24, 0x09A0 - 1018: 81 93 st Z+, r24 - -INLINE void SPIReadBlock(void* Buffer, uint16_t ByteCount) -{ - uint8_t* ByteBuffer = (uint8_t*) Buffer; - - while(ByteCount-- > 0) { - 101a: 84 e2 ldi r24, 0x24 ; 36 - 101c: e2 39 cpi r30, 0x92 ; 146 - 101e: f8 07 cpc r31, r24 - 1020: 89 f7 brne .-30 ; 0x1004 - SPITransferByte(0x03); - SPITransferByte( (Address >> 16) & 0xFF ); - SPITransferByte( (Address >> 8) & 0xFF ); - SPITransferByte( (Address >> 0) & 0xFF ); - SPIReadBlock(Buffer, ByteCount); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 1022: 80 e1 ldi r24, 0x10 ; 16 - 1024: 80 93 65 06 sts 0x0665, r24 - 1028: 08 95 ret - -0000102a : - SPITransferByte( 0 ); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; -} - -void MemoryInit(void) -{ - 102a: cf 93 push r28 - 102c: df 93 push r29 - 102e: 00 d0 rcall .+0 ; 0x1030 - 1030: 00 d0 rcall .+0 ; 0x1032 - 1032: cd b7 in r28, 0x3d ; 61 - 1034: de b7 in r29, 0x3e ; 62 - /* Configure MEMORY_FLASH_USART for SPI master mode 0 with maximum clock frequency */ - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 1036: 80 e1 ldi r24, 0x10 ; 16 - 1038: 80 93 65 06 sts 0x0665, r24 - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_SCK; - 103c: 92 e0 ldi r25, 0x02 ; 2 - 103e: 90 93 66 06 sts 0x0666, r25 - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_MOSI; - 1042: 98 e0 ldi r25, 0x08 ; 8 - 1044: 90 93 65 06 sts 0x0665, r25 - - MEMORY_FLASH_PORT.DIRSET = MEMORY_FLASH_SCK | MEMORY_FLASH_MOSI | MEMORY_FLASH_CS; - 1048: 9a e1 ldi r25, 0x1A ; 26 - 104a: 90 93 61 06 sts 0x0661, r25 - - MEMORY_FLASH_USART.BAUDCTRLA = 15;//0; - 104e: 9f e0 ldi r25, 0x0F ; 15 - 1050: 90 93 a6 09 sts 0x09A6, r25 - MEMORY_FLASH_USART.BAUDCTRLB = 0; - 1054: 10 92 a7 09 sts 0x09A7, r1 - MEMORY_FLASH_USART.CTRLC = USART_CMODE_MSPI_gc; // | USART_CHSIZE_8BIT_gc; - 1058: 90 ec ldi r25, 0xC0 ; 192 - 105a: 90 93 a5 09 sts 0x09A5, r25 - MEMORY_FLASH_USART.CTRLB = USART_RXEN_bm | USART_TXEN_bm; - 105e: 98 e1 ldi r25, 0x18 ; 24 - 1060: 90 93 a4 09 sts 0x09A4, r25 - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 1064: 80 93 66 06 sts 0x0666, r24 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1068: 87 ed ldi r24, 0xD7 ; 215 - 106a: 80 93 a0 09 sts 0x09A0, r24 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 106e: 80 91 a1 09 lds r24, 0x09A1 - 1072: 86 ff sbrs r24, 6 - 1074: fc cf rjmp .-8 ; 0x106e - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1076: 80 e4 ldi r24, 0x40 ; 64 - 1078: 80 93 a1 09 sts 0x09A1, r24 - - return MEMORY_FLASH_USART.DATA; - 107c: 80 91 a0 09 lds r24, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1080: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1084: 80 91 a1 09 lds r24, 0x09A1 - 1088: 86 ff sbrs r24, 6 - 108a: fc cf rjmp .-8 ; 0x1084 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 108c: 80 e4 ldi r24, 0x40 ; 64 - 108e: 80 93 a1 09 sts 0x09A1, r24 - - return MEMORY_FLASH_USART.DATA; - 1092: 80 91 a0 09 lds r24, 0x09A0 - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(FLASH_CMD_STATUS_REG_READ); - Register = SPITransferByte(0); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 1096: 90 e1 ldi r25, 0x10 ; 16 - 1098: 90 93 65 06 sts 0x0665, r25 - MEMORY_FLASH_USART.BAUDCTRLB = 0; - MEMORY_FLASH_USART.CTRLC = USART_CMODE_MSPI_gc; // | USART_CHSIZE_8BIT_gc; - MEMORY_FLASH_USART.CTRLB = USART_RXEN_bm | USART_TXEN_bm; - - - if ( !(FlashReadStatusRegister() & FLASH_STATUS_REG_PAGESIZE_BIT) ) { - 109c: 80 fd sbrc r24, 0 - 109e: 3e c0 rjmp .+124 ; 0x111c - return !(FlashReadStatusRegister() & FLASH_STATUS_REG_READY_BIT); -} - -INLINE void FlashConfigurePageSize(void) -{ - uint8_t Sequence[] = {0x3D, 0x2A, 0x80, 0xA6}; - 10a0: 8d e3 ldi r24, 0x3D ; 61 - 10a2: 89 83 std Y+1, r24 ; 0x01 - 10a4: 8a e2 ldi r24, 0x2A ; 42 - 10a6: 8a 83 std Y+2, r24 ; 0x02 - 10a8: 80 e8 ldi r24, 0x80 ; 128 - 10aa: 8b 83 std Y+3, r24 ; 0x03 - 10ac: 86 ea ldi r24, 0xA6 ; 166 - 10ae: 8c 83 std Y+4, r24 ; 0x04 - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 10b0: 20 e1 ldi r18, 0x10 ; 16 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 10b2: 37 ed ldi r19, 0xD7 ; 215 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 10b4: 90 e4 ldi r25, 0x40 ; 64 - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 10b6: 20 93 66 06 sts 0x0666, r18 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 10ba: 30 93 a0 09 sts 0x09A0, r19 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 10be: 80 91 a1 09 lds r24, 0x09A1 - 10c2: 86 ff sbrs r24, 6 - 10c4: fc cf rjmp .-8 ; 0x10be - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 10c6: 90 93 a1 09 sts 0x09A1, r25 - - return MEMORY_FLASH_USART.DATA; - 10ca: 80 91 a0 09 lds r24, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 10ce: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 10d2: 80 91 a1 09 lds r24, 0x09A1 - 10d6: 86 ff sbrs r24, 6 - 10d8: fc cf rjmp .-8 ; 0x10d2 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 10da: 90 93 a1 09 sts 0x09A1, r25 - - return MEMORY_FLASH_USART.DATA; - 10de: 80 91 a0 09 lds r24, 0x09A0 - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(FLASH_CMD_STATUS_REG_READ); - Register = SPITransferByte(0); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 10e2: 20 93 65 06 sts 0x0665, r18 - -INLINE void FlashConfigurePageSize(void) -{ - uint8_t Sequence[] = {0x3D, 0x2A, 0x80, 0xA6}; - - while(FlashIsBusy()); - 10e6: 87 ff sbrs r24, 7 - 10e8: e6 cf rjmp .-52 ; 0x10b6 - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 10ea: 80 e1 ldi r24, 0x10 ; 16 - 10ec: 80 93 66 06 sts 0x0666, r24 - 10f0: fe 01 movw r30, r28 - 10f2: 31 96 adiw r30, 0x01 ; 1 - 10f4: ce 01 movw r24, r28 - 10f6: 05 96 adiw r24, 0x05 ; 5 - uint8_t* ByteBuffer = (uint8_t*) Buffer; - - while(ByteCount-- > 0) { - MEMORY_FLASH_USART.DATA = *ByteBuffer++; - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 10f8: 30 e4 ldi r19, 0x40 ; 64 -INLINE void SPIWriteBlock(const void* Buffer, uint16_t ByteCount) -{ - uint8_t* ByteBuffer = (uint8_t*) Buffer; - - while(ByteCount-- > 0) { - MEMORY_FLASH_USART.DATA = *ByteBuffer++; - 10fa: 21 91 ld r18, Z+ - 10fc: 20 93 a0 09 sts 0x09A0, r18 - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1100: 20 91 a1 09 lds r18, 0x09A1 - 1104: 26 ff sbrs r18, 6 - 1106: fc cf rjmp .-8 ; 0x1100 - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1108: 30 93 a1 09 sts 0x09A1, r19 - MEMORY_FLASH_USART.DATA; /* Flush Buffer */ - 110c: 20 91 a0 09 lds r18, 0x09A0 - -INLINE void SPIWriteBlock(const void* Buffer, uint16_t ByteCount) -{ - uint8_t* ByteBuffer = (uint8_t*) Buffer; - - while(ByteCount-- > 0) { - 1110: e8 17 cp r30, r24 - 1112: f9 07 cpc r31, r25 - 1114: 91 f7 brne .-28 ; 0x10fa - - while(FlashIsBusy()); - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPIWriteBlock(Sequence, sizeof(Sequence)); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 1116: 80 e1 ldi r24, 0x10 ; 16 - 1118: 80 93 65 06 sts 0x0665, r24 - FlashConfigurePageSize(); - } - - /* Load permanent flash contents to memory at startup */ - MemoryRecall(); -} - 111c: 24 96 adiw r28, 0x04 ; 4 - 111e: cd bf out 0x3d, r28 ; 61 - 1120: de bf out 0x3e, r29 ; 62 - 1122: df 91 pop r29 - 1124: cf 91 pop r28 - /* Configure for 256 byte Dataflash if not already done. */ - FlashConfigurePageSize(); - } - - /* Load permanent flash contents to memory at startup */ - MemoryRecall(); - 1126: 0b cf rjmp .-490 ; 0xf3e - -00001128 : - /* Recall memory from permanent flash */ - FlashRead(Memory, (uint32_t) GlobalSettings.ActiveSettingIdx * MEMORY_SIZE_PER_SETTING, MEMORY_SIZE_PER_SETTING); -} - -void MemoryStore(void) -{ - 1128: 5f 92 push r5 - 112a: 6f 92 push r6 - 112c: 7f 92 push r7 - 112e: 8f 92 push r8 - 1130: 9f 92 push r9 - 1132: af 92 push r10 - 1134: bf 92 push r11 - 1136: cf 92 push r12 - 1138: df 92 push r13 - 113a: ef 92 push r14 - 113c: ff 92 push r15 - 113e: 0f 93 push r16 - 1140: 1f 93 push r17 - 1142: cf 93 push r28 - 1144: df 93 push r29 - /* Store current memory into permanent flash */ - FlashWrite(Memory, (uint32_t) GlobalSettings.ActiveSettingIdx * MEMORY_SIZE_PER_SETTING, MEMORY_SIZE_PER_SETTING); - 1146: 80 91 09 29 lds r24, 0x2909 - 114a: 90 e0 ldi r25, 0x00 ; 0 - 114c: a0 e0 ldi r26, 0x00 ; 0 - 114e: b0 e0 ldi r27, 0x00 ; 0 - 1150: 6a e0 ldi r22, 0x0A ; 10 - 1152: 88 0f add r24, r24 - 1154: 99 1f adc r25, r25 - 1156: aa 1f adc r26, r26 - 1158: bb 1f adc r27, r27 - 115a: 6a 95 dec r22 - 115c: d1 f7 brne .-12 ; 0x1152 - 115e: 22 e9 ldi r18, 0x92 ; 146 - 1160: 30 e2 ldi r19, 0x20 ; 32 - 1162: 00 e0 ldi r16, 0x00 ; 0 - 1164: 14 e0 ldi r17, 0x04 ; 4 -INLINE void FlashWrite(const void* Buffer, uint32_t Address, uint16_t ByteCount) -{ - while(ByteCount > 0) { - uint16_t PageAddress = Address / FLASH_PAGE_SIZE; - uint8_t ByteAddress = Address % FLASH_PAGE_SIZE; - uint16_t PageBytes = MIN(FLASH_PAGE_SIZE - ByteAddress, ByteCount); - 1166: e1 2c mov r14, r1 - 1168: ff 24 eor r15, r15 - 116a: f3 94 inc r15 - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 116c: e0 e1 ldi r30, 0x10 ; 16 - 116e: ce 2e mov r12, r30 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1170: f7 ed ldi r31, 0xD7 ; 215 - 1172: bf 2e mov r11, r31 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1174: c0 e4 ldi r28, 0x40 ; 64 - 1176: dc 2e mov r13, r28 - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 1178: d0 e1 ldi r29, 0x10 ; 16 - 117a: ad 2e mov r10, r29 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 117c: 47 ed ldi r20, 0xD7 ; 215 - 117e: 94 2e mov r9, r20 - 1180: 53 e5 ldi r21, 0x53 ; 83 - 1182: 65 2e mov r6, r21 - 1184: 64 e8 ldi r22, 0x84 ; 132 - 1186: 76 2e mov r7, r22 - 1188: 73 e8 ldi r23, 0x83 ; 131 - 118a: 87 2e mov r8, r23 -} - -INLINE void FlashWrite(const void* Buffer, uint32_t Address, uint16_t ByteCount) -{ - while(ByteCount > 0) { - uint16_t PageAddress = Address / FLASH_PAGE_SIZE; - 118c: 49 2f mov r20, r25 - 118e: 5a 2f mov r21, r26 - 1190: 6b 2f mov r22, r27 - 1192: 77 27 eor r23, r23 - uint8_t ByteAddress = Address % FLASH_PAGE_SIZE; - 1194: f8 2f mov r31, r24 - uint16_t PageBytes = MIN(FLASH_PAGE_SIZE - ByteAddress, ByteCount); - 1196: e7 01 movw r28, r14 - 1198: c8 1b sub r28, r24 - 119a: d1 09 sbc r29, r1 - 119c: 0c 17 cp r16, r28 - 119e: 1d 07 cpc r17, r29 - 11a0: 08 f4 brcc .+2 ; 0x11a4 - 11a2: e8 01 movw r28, r16 - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 11a4: a0 92 66 06 sts 0x0666, r10 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 11a8: 90 92 a0 09 sts 0x09A0, r9 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 11ac: e0 91 a1 09 lds r30, 0x09A1 - 11b0: e6 ff sbrs r30, 6 - 11b2: fc cf rjmp .-8 ; 0x11ac - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 11b4: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 11b8: e0 91 a0 09 lds r30, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 11bc: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 11c0: e0 91 a1 09 lds r30, 0x09A1 - 11c4: e6 ff sbrs r30, 6 - 11c6: fc cf rjmp .-8 ; 0x11c0 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 11c8: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 11cc: e0 91 a0 09 lds r30, 0x09A0 - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(FLASH_CMD_STATUS_REG_READ); - Register = SPITransferByte(0); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 11d0: c0 92 65 06 sts 0x0665, r12 - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; -} - -INLINE void FlashMemoryToBuffer(uint16_t PageAddress) -{ - while(FlashIsBusy()); - 11d4: e7 ff sbrs r30, 7 - 11d6: e6 cf rjmp .-52 ; 0x11a4 - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 11d8: a0 92 66 06 sts 0x0666, r10 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 11dc: 60 92 a0 09 sts 0x09A0, r6 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 11e0: e0 91 a1 09 lds r30, 0x09A1 - 11e4: e6 ff sbrs r30, 6 - 11e6: fc cf rjmp .-8 ; 0x11e0 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 11e8: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 11ec: e0 91 a0 09 lds r30, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 11f0: 50 93 a0 09 sts 0x09A0, r21 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 11f4: e0 91 a1 09 lds r30, 0x09A1 - 11f8: e6 ff sbrs r30, 6 - 11fa: fc cf rjmp .-8 ; 0x11f4 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 11fc: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 1200: e0 91 a0 09 lds r30, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1204: 40 93 a0 09 sts 0x09A0, r20 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1208: e0 91 a1 09 lds r30, 0x09A1 - 120c: e6 ff sbrs r30, 6 - 120e: fc cf rjmp .-8 ; 0x1208 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1210: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 1214: e0 91 a0 09 lds r30, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1218: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 121c: e0 91 a1 09 lds r30, 0x09A1 - 1220: e6 ff sbrs r30, 6 - 1222: fc cf rjmp .-8 ; 0x121c - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1224: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 1228: e0 91 a0 09 lds r30, 0x09A0 - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(FLASH_CMD_MEM_TO_BUF1); - SPITransferByte( (PageAddress >> 8) & 0xFF ); - SPITransferByte( (PageAddress >> 0) & 0xFF ); - SPITransferByte( 0 ); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 122c: c0 92 65 06 sts 0x0665, r12 - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 1230: c0 92 66 06 sts 0x0666, r12 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1234: b0 92 a0 09 sts 0x09A0, r11 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1238: e0 91 a1 09 lds r30, 0x09A1 - 123c: e6 ff sbrs r30, 6 - 123e: fc cf rjmp .-8 ; 0x1238 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1240: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 1244: e0 91 a0 09 lds r30, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1248: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 124c: e0 91 a1 09 lds r30, 0x09A1 - 1250: e6 ff sbrs r30, 6 - 1252: fc cf rjmp .-8 ; 0x124c - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1254: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 1258: e0 91 a0 09 lds r30, 0x09A0 - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(FLASH_CMD_STATUS_REG_READ); - Register = SPITransferByte(0); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 125c: c0 92 65 06 sts 0x0665, r12 - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; -} - -INLINE void FlashWriteBuffer(const void* Buffer, uint8_t Address, uint16_t ByteCount) -{ - while(FlashIsBusy()); - 1260: e7 ff sbrs r30, 7 - 1262: e6 cf rjmp .-52 ; 0x1230 - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 1264: a0 92 66 06 sts 0x0666, r10 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1268: 70 92 a0 09 sts 0x09A0, r7 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 126c: e0 91 a1 09 lds r30, 0x09A1 - 1270: e6 ff sbrs r30, 6 - 1272: fc cf rjmp .-8 ; 0x126c - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1274: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 1278: e0 91 a0 09 lds r30, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 127c: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1280: e0 91 a1 09 lds r30, 0x09A1 - 1284: e6 ff sbrs r30, 6 - 1286: fc cf rjmp .-8 ; 0x1280 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1288: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 128c: e0 91 a0 09 lds r30, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1290: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1294: e0 91 a1 09 lds r30, 0x09A1 - 1298: e6 ff sbrs r30, 6 - 129a: fc cf rjmp .-8 ; 0x1294 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 129c: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 12a0: e0 91 a0 09 lds r30, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 12a4: f0 93 a0 09 sts 0x09A0, r31 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 12a8: e0 91 a1 09 lds r30, 0x09A1 - 12ac: e6 ff sbrs r30, 6 - 12ae: fc cf rjmp .-8 ; 0x12a8 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 12b0: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 12b4: e0 91 a0 09 lds r30, 0x09A0 - -INLINE void SPIWriteBlock(const void* Buffer, uint16_t ByteCount) -{ - uint8_t* ByteBuffer = (uint8_t*) Buffer; - - while(ByteCount-- > 0) { - 12b8: 20 97 sbiw r28, 0x00 ; 0 - 12ba: 89 f0 breq .+34 ; 0x12de - 12bc: f9 01 movw r30, r18 - 12be: 2c 0f add r18, r28 - 12c0: 3d 1f adc r19, r29 - MEMORY_FLASH_USART.DATA = *ByteBuffer++; - 12c2: 51 90 ld r5, Z+ - 12c4: 50 92 a0 09 sts 0x09A0, r5 - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 12c8: 50 90 a1 09 lds r5, 0x09A1 - 12cc: 56 fe sbrs r5, 6 - 12ce: fc cf rjmp .-8 ; 0x12c8 - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 12d0: d0 92 a1 09 sts 0x09A1, r13 - MEMORY_FLASH_USART.DATA; /* Flush Buffer */ - 12d4: 50 90 a0 09 lds r5, 0x09A0 - -INLINE void SPIWriteBlock(const void* Buffer, uint16_t ByteCount) -{ - uint8_t* ByteBuffer = (uint8_t*) Buffer; - - while(ByteCount-- > 0) { - 12d8: e2 17 cp r30, r18 - 12da: f3 07 cpc r31, r19 - 12dc: 91 f7 brne .-28 ; 0x12c2 - SPITransferByte(FLASH_CMD_BUF1_WRITE); - SPITransferByte( 0 ); - SPITransferByte( 0 ); - SPITransferByte( Address ); - SPIWriteBlock(Buffer, ByteCount); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 12de: c0 92 65 06 sts 0x0665, r12 - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 12e2: c0 92 66 06 sts 0x0666, r12 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 12e6: b0 92 a0 09 sts 0x09A0, r11 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 12ea: e0 91 a1 09 lds r30, 0x09A1 - 12ee: e6 ff sbrs r30, 6 - 12f0: fc cf rjmp .-8 ; 0x12ea - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 12f2: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 12f6: e0 91 a0 09 lds r30, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 12fa: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 12fe: e0 91 a1 09 lds r30, 0x09A1 - 1302: e6 ff sbrs r30, 6 - 1304: fc cf rjmp .-8 ; 0x12fe - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1306: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 130a: e0 91 a0 09 lds r30, 0x09A0 - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(FLASH_CMD_STATUS_REG_READ); - Register = SPITransferByte(0); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 130e: c0 92 65 06 sts 0x0665, r12 - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; -} - -INLINE void FlashBufferToMemory(uint16_t PageAddress) -{ - while(FlashIsBusy()); - 1312: e7 ff sbrs r30, 7 - 1314: e6 cf rjmp .-52 ; 0x12e2 - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 1316: a0 92 66 06 sts 0x0666, r10 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 131a: 80 92 a0 09 sts 0x09A0, r8 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 131e: e0 91 a1 09 lds r30, 0x09A1 - 1322: e6 ff sbrs r30, 6 - 1324: fc cf rjmp .-8 ; 0x131e - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1326: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 132a: e0 91 a0 09 lds r30, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 132e: 50 93 a0 09 sts 0x09A0, r21 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1332: e0 91 a1 09 lds r30, 0x09A1 - 1336: e6 ff sbrs r30, 6 - 1338: fc cf rjmp .-8 ; 0x1332 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 133a: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 133e: e0 91 a0 09 lds r30, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1342: 40 93 a0 09 sts 0x09A0, r20 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1346: 40 91 a1 09 lds r20, 0x09A1 - 134a: 46 ff sbrs r20, 6 - 134c: fc cf rjmp .-8 ; 0x1346 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 134e: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 1352: 40 91 a0 09 lds r20, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1356: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 135a: 40 91 a1 09 lds r20, 0x09A1 - 135e: 46 ff sbrs r20, 6 - 1360: fc cf rjmp .-8 ; 0x135a - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1362: d0 92 a1 09 sts 0x09A1, r13 - - return MEMORY_FLASH_USART.DATA; - 1366: 40 91 a0 09 lds r20, 0x09A0 - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(FLASH_CMD_BUF1_TO_MEM_ERASE); - SPITransferByte( (PageAddress >> 8) & 0xFF ); - SPITransferByte( (PageAddress >> 0) & 0xFF ); - SPITransferByte( 0 ); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 136a: c0 92 65 06 sts 0x0665, r12 - - FlashMemoryToBuffer(PageAddress); - FlashWriteBuffer(Buffer, ByteAddress, PageBytes); - FlashBufferToMemory(PageAddress); - - ByteCount -= PageBytes; - 136e: 0c 1b sub r16, r28 - 1370: 1d 0b sbc r17, r29 - Address += PageBytes; - 1372: 8c 0f add r24, r28 - 1374: 9d 1f adc r25, r29 - 1376: a1 1d adc r26, r1 - 1378: b1 1d adc r27, r1 - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; -} - -INLINE void FlashWrite(const void* Buffer, uint32_t Address, uint16_t ByteCount) -{ - while(ByteCount > 0) { - 137a: 01 15 cp r16, r1 - 137c: 11 05 cpc r17, r1 - 137e: 09 f0 breq .+2 ; 0x1382 - 1380: 05 cf rjmp .-502 ; 0x118c -void MemoryStore(void) -{ - /* Store current memory into permanent flash */ - FlashWrite(Memory, (uint32_t) GlobalSettings.ActiveSettingIdx * MEMORY_SIZE_PER_SETTING, MEMORY_SIZE_PER_SETTING); - - LEDTrigger(LED_MEMORY_CHANGED, LED_OFF); - 1382: 60 e1 ldi r22, 0x10 ; 16 - 1384: 85 e0 ldi r24, 0x05 ; 5 - 1386: 2d d6 rcall .+3162 ; 0x1fe2 - LEDTrigger(LED_MEMORY_STORED, LED_PULSE); - 1388: 63 e1 ldi r22, 0x13 ; 19 - 138a: 84 e0 ldi r24, 0x04 ; 4 -} - 138c: df 91 pop r29 - 138e: cf 91 pop r28 - 1390: 1f 91 pop r17 - 1392: 0f 91 pop r16 - 1394: ff 90 pop r15 - 1396: ef 90 pop r14 - 1398: df 90 pop r13 - 139a: cf 90 pop r12 - 139c: bf 90 pop r11 - 139e: af 90 pop r10 - 13a0: 9f 90 pop r9 - 13a2: 8f 90 pop r8 - 13a4: 7f 90 pop r7 - 13a6: 6f 90 pop r6 - 13a8: 5f 90 pop r5 -{ - /* Store current memory into permanent flash */ - FlashWrite(Memory, (uint32_t) GlobalSettings.ActiveSettingIdx * MEMORY_SIZE_PER_SETTING, MEMORY_SIZE_PER_SETTING); - - LEDTrigger(LED_MEMORY_CHANGED, LED_OFF); - LEDTrigger(LED_MEMORY_STORED, LED_PULSE); - 13aa: 1b c6 rjmp .+3126 ; 0x1fe2 - -000013ac : -} - -bool MemoryUploadBlock(void* Buffer, uint32_t BlockAddress, uint16_t ByteCount) -{ - 13ac: 2f 92 push r2 - 13ae: 3f 92 push r3 - 13b0: 4f 92 push r4 - 13b2: 5f 92 push r5 - 13b4: 6f 92 push r6 - 13b6: 7f 92 push r7 - 13b8: 8f 92 push r8 - 13ba: 9f 92 push r9 - 13bc: af 92 push r10 - 13be: bf 92 push r11 - 13c0: cf 92 push r12 - 13c2: df 92 push r13 - 13c4: ef 92 push r14 - 13c6: ff 92 push r15 - 13c8: 0f 93 push r16 - 13ca: 1f 93 push r17 - 13cc: cf 93 push r28 - 13ce: df 93 push r29 - 13d0: cd b7 in r28, 0x3d ; 61 - 13d2: de b7 in r29, 0x3e ; 62 - 13d4: 2c 97 sbiw r28, 0x0c ; 12 - 13d6: cd bf out 0x3d, r28 ; 61 - 13d8: de bf out 0x3e, r29 ; 62 - 13da: 4c 01 movw r8, r24 - if (BlockAddress >= MEMORY_SIZE_PER_SETTING) { - 13dc: 41 15 cp r20, r1 - 13de: 04 e0 ldi r16, 0x04 ; 4 - 13e0: 50 07 cpc r21, r16 - 13e2: 61 05 cpc r22, r1 - 13e4: 71 05 cpc r23, r1 - 13e6: 08 f0 brcs .+2 ; 0x13ea - 13e8: 5d c1 rjmp .+698 ; 0x16a4 - /* Prevent writing out of bounds by silently ignoring it */ - return true; - } else { - /* Calculate bytes left in memory and start writing */ - uint32_t BytesLeft = MEMORY_SIZE_PER_SETTING - BlockAddress; - uint32_t FlashAddress = (uint32_t) BlockAddress + (uint32_t) GlobalSettings.ActiveSettingIdx * MEMORY_SIZE_PER_SETTING; - 13ea: 80 91 09 29 lds r24, 0x2909 - 13ee: 90 e0 ldi r25, 0x00 ; 0 - 13f0: a0 e0 ldi r26, 0x00 ; 0 - 13f2: b0 e0 ldi r27, 0x00 ; 0 - 13f4: 1a e0 ldi r17, 0x0A ; 10 - 13f6: 88 0f add r24, r24 - 13f8: 99 1f adc r25, r25 - 13fa: aa 1f adc r26, r26 - 13fc: bb 1f adc r27, r27 - 13fe: 1a 95 dec r17 - 1400: d1 f7 brne .-12 ; 0x13f6 - 1402: 84 0f add r24, r20 - 1404: 95 1f adc r25, r21 - 1406: a6 1f adc r26, r22 - 1408: b7 1f adc r27, r23 - if (BlockAddress >= MEMORY_SIZE_PER_SETTING) { - /* Prevent writing out of bounds by silently ignoring it */ - return true; - } else { - /* Calculate bytes left in memory and start writing */ - uint32_t BytesLeft = MEMORY_SIZE_PER_SETTING - BlockAddress; - 140a: c1 2c mov r12, r1 - 140c: 04 e0 ldi r16, 0x04 ; 4 - 140e: d0 2e mov r13, r16 - 1410: e1 2c mov r14, r1 - 1412: f1 2c mov r15, r1 - uint32_t FlashAddress = (uint32_t) BlockAddress + (uint32_t) GlobalSettings.ActiveSettingIdx * MEMORY_SIZE_PER_SETTING; - ByteCount = MIN(ByteCount, BytesLeft); - 1414: 89 01 movw r16, r18 - 1416: 20 e0 ldi r18, 0x00 ; 0 - 1418: 30 e0 ldi r19, 0x00 ; 0 - 141a: c4 1a sub r12, r20 - 141c: d5 0a sbc r13, r21 - 141e: e6 0a sbc r14, r22 - 1420: f7 0a sbc r15, r23 - 1422: cd 82 std Y+5, r12 ; 0x05 - 1424: de 82 std Y+6, r13 ; 0x06 - 1426: ef 82 std Y+7, r14 ; 0x07 - 1428: f8 86 std Y+8, r15 ; 0x08 - 142a: 0c 15 cp r16, r12 - 142c: 1d 05 cpc r17, r13 - 142e: 2e 05 cpc r18, r14 - 1430: 3f 05 cpc r19, r15 - 1432: 08 f4 brcc .+2 ; 0x1436 - 1434: 51 c1 rjmp .+674 ; 0x16d8 - 1436: ed 80 ldd r14, Y+5 ; 0x05 - 1438: fe 80 ldd r15, Y+6 ; 0x06 - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; -} - -INLINE void FlashWrite(const void* Buffer, uint32_t Address, uint16_t ByteCount) -{ - while(ByteCount > 0) { - 143a: e1 14 cp r14, r1 - 143c: f1 04 cpc r15, r1 - 143e: 09 f4 brne .+2 ; 0x1442 - 1440: 31 c1 rjmp .+610 ; 0x16a4 - 1442: a8 2c mov r10, r8 - 1444: 39 2c mov r3, r9 - uint16_t PageAddress = Address / FLASH_PAGE_SIZE; - uint8_t ByteAddress = Address % FLASH_PAGE_SIZE; - uint16_t PageBytes = MIN(FLASH_PAGE_SIZE - ByteAddress, ByteCount); - 1446: c1 2c mov r12, r1 - 1448: dd 24 eor r13, r13 - 144a: d3 94 inc r13 - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 144c: 10 e1 ldi r17, 0x10 ; 16 - 144e: 71 2e mov r7, r17 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1450: 07 ed ldi r16, 0xD7 ; 215 - 1452: 60 2e mov r6, r16 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1454: 20 e4 ldi r18, 0x40 ; 64 - 1456: b2 2e mov r11, r18 - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 1458: 30 e1 ldi r19, 0x10 ; 16 - 145a: 53 2e mov r5, r19 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 145c: e7 ed ldi r30, 0xD7 ; 215 - 145e: 4e 2e mov r4, r30 - 1460: f3 e5 ldi r31, 0x53 ; 83 - 1462: 2f 2e mov r2, r31 - 1464: 04 e8 ldi r16, 0x84 ; 132 - 1466: 13 e8 ldi r17, 0x83 ; 131 - 1468: 49 87 std Y+9, r20 ; 0x09 - 146a: 5a 87 std Y+10, r21 ; 0x0a - 146c: 6b 87 std Y+11, r22 ; 0x0b - 146e: 7c 87 std Y+12, r23 ; 0x0c -} - -INLINE void FlashWrite(const void* Buffer, uint32_t Address, uint16_t ByteCount) -{ - while(ByteCount > 0) { - uint16_t PageAddress = Address / FLASH_PAGE_SIZE; - 1470: 29 2f mov r18, r25 - 1472: 3a 2f mov r19, r26 - 1474: 4b 2f mov r20, r27 - 1476: 55 27 eor r21, r21 - 1478: 29 83 std Y+1, r18 ; 0x01 - 147a: 3a 83 std Y+2, r19 ; 0x02 - 147c: 4b 83 std Y+3, r20 ; 0x03 - 147e: 5c 83 std Y+4, r21 ; 0x04 - uint8_t ByteAddress = Address % FLASH_PAGE_SIZE; - 1480: 38 2f mov r19, r24 - uint16_t PageBytes = MIN(FLASH_PAGE_SIZE - ByteAddress, ByteCount); - 1482: a6 01 movw r20, r12 - 1484: 48 1b sub r20, r24 - 1486: 51 09 sbc r21, r1 - 1488: e4 16 cp r14, r20 - 148a: f5 06 cpc r15, r21 - 148c: 08 f4 brcc .+2 ; 0x1490 - 148e: a7 01 movw r20, r14 - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 1490: 50 92 66 06 sts 0x0666, r5 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1494: 40 92 a0 09 sts 0x09A0, r4 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1498: 20 91 a1 09 lds r18, 0x09A1 - 149c: 26 ff sbrs r18, 6 - 149e: fc cf rjmp .-8 ; 0x1498 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 14a0: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 14a4: 20 91 a0 09 lds r18, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 14a8: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 14ac: 20 91 a1 09 lds r18, 0x09A1 - 14b0: 26 ff sbrs r18, 6 - 14b2: fc cf rjmp .-8 ; 0x14ac - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 14b4: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 14b8: 20 91 a0 09 lds r18, 0x09A0 - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(FLASH_CMD_STATUS_REG_READ); - Register = SPITransferByte(0); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 14bc: 70 92 65 06 sts 0x0665, r7 - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; -} - -INLINE void FlashMemoryToBuffer(uint16_t PageAddress) -{ - while(FlashIsBusy()); - 14c0: 27 ff sbrs r18, 7 - 14c2: e6 cf rjmp .-52 ; 0x1490 - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 14c4: 50 92 66 06 sts 0x0666, r5 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 14c8: 20 92 a0 09 sts 0x09A0, r2 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 14cc: 20 91 a1 09 lds r18, 0x09A1 - 14d0: 26 ff sbrs r18, 6 - 14d2: fc cf rjmp .-8 ; 0x14cc - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 14d4: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 14d8: 20 91 a0 09 lds r18, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 14dc: 6a 81 ldd r22, Y+2 ; 0x02 - 14de: 60 93 a0 09 sts 0x09A0, r22 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 14e2: 20 91 a1 09 lds r18, 0x09A1 - 14e6: 26 ff sbrs r18, 6 - 14e8: fc cf rjmp .-8 ; 0x14e2 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 14ea: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 14ee: 20 91 a0 09 lds r18, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 14f2: e9 81 ldd r30, Y+1 ; 0x01 - 14f4: e0 93 a0 09 sts 0x09A0, r30 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 14f8: 20 91 a1 09 lds r18, 0x09A1 - 14fc: 26 ff sbrs r18, 6 - 14fe: fc cf rjmp .-8 ; 0x14f8 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1500: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 1504: 20 91 a0 09 lds r18, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1508: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 150c: 20 91 a1 09 lds r18, 0x09A1 - 1510: 26 ff sbrs r18, 6 - 1512: fc cf rjmp .-8 ; 0x150c - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1514: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 1518: 20 91 a0 09 lds r18, 0x09A0 - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(FLASH_CMD_MEM_TO_BUF1); - SPITransferByte( (PageAddress >> 8) & 0xFF ); - SPITransferByte( (PageAddress >> 0) & 0xFF ); - SPITransferByte( 0 ); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 151c: 70 92 65 06 sts 0x0665, r7 - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 1520: 70 92 66 06 sts 0x0666, r7 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1524: 60 92 a0 09 sts 0x09A0, r6 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1528: 20 91 a1 09 lds r18, 0x09A1 - 152c: 26 ff sbrs r18, 6 - 152e: fc cf rjmp .-8 ; 0x1528 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1530: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 1534: 20 91 a0 09 lds r18, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1538: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 153c: 20 91 a1 09 lds r18, 0x09A1 - 1540: 26 ff sbrs r18, 6 - 1542: fc cf rjmp .-8 ; 0x153c - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1544: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 1548: 20 91 a0 09 lds r18, 0x09A0 - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(FLASH_CMD_STATUS_REG_READ); - Register = SPITransferByte(0); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 154c: 70 92 65 06 sts 0x0665, r7 - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; -} - -INLINE void FlashWriteBuffer(const void* Buffer, uint8_t Address, uint16_t ByteCount) -{ - while(FlashIsBusy()); - 1550: 27 ff sbrs r18, 7 - 1552: e6 cf rjmp .-52 ; 0x1520 - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 1554: 50 92 66 06 sts 0x0666, r5 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1558: 00 93 a0 09 sts 0x09A0, r16 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 155c: 20 91 a1 09 lds r18, 0x09A1 - 1560: 26 ff sbrs r18, 6 - 1562: fc cf rjmp .-8 ; 0x155c - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1564: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 1568: 20 91 a0 09 lds r18, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 156c: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1570: 20 91 a1 09 lds r18, 0x09A1 - 1574: 26 ff sbrs r18, 6 - 1576: fc cf rjmp .-8 ; 0x1570 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1578: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 157c: 20 91 a0 09 lds r18, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1580: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1584: 20 91 a1 09 lds r18, 0x09A1 - 1588: 26 ff sbrs r18, 6 - 158a: fc cf rjmp .-8 ; 0x1584 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 158c: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 1590: 20 91 a0 09 lds r18, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1594: 30 93 a0 09 sts 0x09A0, r19 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1598: 20 91 a1 09 lds r18, 0x09A1 - 159c: 26 ff sbrs r18, 6 - 159e: fc cf rjmp .-8 ; 0x1598 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 15a0: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 15a4: 20 91 a0 09 lds r18, 0x09A0 - -INLINE void SPIWriteBlock(const void* Buffer, uint16_t ByteCount) -{ - uint8_t* ByteBuffer = (uint8_t*) Buffer; - - while(ByteCount-- > 0) { - 15a8: 41 15 cp r20, r1 - 15aa: 51 05 cpc r21, r1 - 15ac: 09 f4 brne .+2 ; 0x15b0 - 15ae: 91 c0 rjmp .+290 ; 0x16d2 - 15b0: ea 2d mov r30, r10 - 15b2: f3 2d mov r31, r3 - 15b4: 9f 01 movw r18, r30 - 15b6: 24 0f add r18, r20 - 15b8: 35 1f adc r19, r21 - MEMORY_FLASH_USART.DATA = *ByteBuffer++; - 15ba: 61 91 ld r22, Z+ - 15bc: 60 93 a0 09 sts 0x09A0, r22 - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 15c0: 60 91 a1 09 lds r22, 0x09A1 - 15c4: 66 ff sbrs r22, 6 - 15c6: fc cf rjmp .-8 ; 0x15c0 - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 15c8: b0 92 a1 09 sts 0x09A1, r11 - MEMORY_FLASH_USART.DATA; /* Flush Buffer */ - 15cc: 60 91 a0 09 lds r22, 0x09A0 - -INLINE void SPIWriteBlock(const void* Buffer, uint16_t ByteCount) -{ - uint8_t* ByteBuffer = (uint8_t*) Buffer; - - while(ByteCount-- > 0) { - 15d0: e2 17 cp r30, r18 - 15d2: f3 07 cpc r31, r19 - 15d4: 91 f7 brne .-28 ; 0x15ba - SPITransferByte(FLASH_CMD_BUF1_WRITE); - SPITransferByte( 0 ); - SPITransferByte( 0 ); - SPITransferByte( Address ); - SPIWriteBlock(Buffer, ByteCount); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 15d6: 70 92 65 06 sts 0x0665, r7 - -INLINE uint8_t FlashReadStatusRegister(void) -{ - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 15da: 70 92 66 06 sts 0x0666, r7 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 15de: 60 92 a0 09 sts 0x09A0, r6 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 15e2: 60 91 a1 09 lds r22, 0x09A1 - 15e6: 66 ff sbrs r22, 6 - 15e8: fc cf rjmp .-8 ; 0x15e2 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 15ea: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 15ee: 60 91 a0 09 lds r22, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 15f2: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 15f6: 60 91 a1 09 lds r22, 0x09A1 - 15fa: 66 ff sbrs r22, 6 - 15fc: fc cf rjmp .-8 ; 0x15f6 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 15fe: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 1602: 60 91 a0 09 lds r22, 0x09A0 - uint8_t Register; - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(FLASH_CMD_STATUS_REG_READ); - Register = SPITransferByte(0); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 1606: 70 92 65 06 sts 0x0665, r7 - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; -} - -INLINE void FlashBufferToMemory(uint16_t PageAddress) -{ - while(FlashIsBusy()); - 160a: 67 ff sbrs r22, 7 - 160c: e6 cf rjmp .-52 ; 0x15da - - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - 160e: 50 92 66 06 sts 0x0666, r5 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1612: 10 93 a0 09 sts 0x09A0, r17 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1616: 60 91 a1 09 lds r22, 0x09A1 - 161a: 66 ff sbrs r22, 6 - 161c: fc cf rjmp .-8 ; 0x1616 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 161e: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 1622: 60 91 a0 09 lds r22, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1626: fa 81 ldd r31, Y+2 ; 0x02 - 1628: f0 93 a0 09 sts 0x09A0, r31 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 162c: 60 91 a1 09 lds r22, 0x09A1 - 1630: 66 ff sbrs r22, 6 - 1632: fc cf rjmp .-8 ; 0x162c - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 1634: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 1638: 60 91 a0 09 lds r22, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 163c: 69 81 ldd r22, Y+1 ; 0x01 - 163e: 60 93 a0 09 sts 0x09A0, r22 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1642: 60 91 a1 09 lds r22, 0x09A1 - 1646: 66 ff sbrs r22, 6 - 1648: fc cf rjmp .-8 ; 0x1642 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 164a: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 164e: 60 91 a0 09 lds r22, 0x09A0 - -static uint8_t Memory[MEMORY_SIZE_PER_SETTING]; - -INLINE uint8_t SPITransferByte(uint8_t Data) -{ - MEMORY_FLASH_USART.DATA = Data; - 1652: 10 92 a0 09 sts 0x09A0, r1 - - while (!(MEMORY_FLASH_USART.STATUS & USART_TXCIF_bm)); - 1656: 60 91 a1 09 lds r22, 0x09A1 - 165a: 66 ff sbrs r22, 6 - 165c: fc cf rjmp .-8 ; 0x1656 - - MEMORY_FLASH_USART.STATUS = USART_TXCIF_bm; - 165e: b0 92 a1 09 sts 0x09A1, r11 - - return MEMORY_FLASH_USART.DATA; - 1662: 60 91 a0 09 lds r22, 0x09A0 - MEMORY_FLASH_PORT.OUTCLR = MEMORY_FLASH_CS; - SPITransferByte(FLASH_CMD_BUF1_TO_MEM_ERASE); - SPITransferByte( (PageAddress >> 8) & 0xFF ); - SPITransferByte( (PageAddress >> 0) & 0xFF ); - SPITransferByte( 0 ); - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; - 1666: 70 92 65 06 sts 0x0665, r7 - - FlashMemoryToBuffer(PageAddress); - FlashWriteBuffer(Buffer, ByteAddress, PageBytes); - FlashBufferToMemory(PageAddress); - - ByteCount -= PageBytes; - 166a: e4 1a sub r14, r20 - 166c: f5 0a sbc r15, r21 - Address += PageBytes; - 166e: 84 0f add r24, r20 - 1670: 95 1f adc r25, r21 - 1672: a1 1d adc r26, r1 - 1674: b1 1d adc r27, r1 - Buffer += PageBytes; - 1676: a2 2e mov r10, r18 - 1678: 33 2e mov r3, r19 - MEMORY_FLASH_PORT.OUTSET = MEMORY_FLASH_CS; -} - -INLINE void FlashWrite(const void* Buffer, uint32_t Address, uint16_t ByteCount) -{ - while(ByteCount > 0) { - 167a: e1 14 cp r14, r1 - 167c: f1 04 cpc r15, r1 - 167e: 09 f0 breq .+2 ; 0x1682 - 1680: f7 ce rjmp .-530 ; 0x1470 - 1682: 49 85 ldd r20, Y+9 ; 0x09 - 1684: 5a 85 ldd r21, Y+10 ; 0x0a - 1686: 6b 85 ldd r22, Y+11 ; 0x0b - 1688: 7c 85 ldd r23, Y+12 ; 0x0c - - /* Store into flash */ - FlashWrite(Buffer, FlashAddress, ByteCount); - - /* Store to local memory */ - uint8_t* DstPtr = &Memory[BlockAddress]; - 168a: da 01 movw r26, r20 - 168c: ae 56 subi r26, 0x6E ; 110 - 168e: bf 4d sbci r27, 0xDF ; 223 - 1690: 8d 81 ldd r24, Y+5 ; 0x05 - 1692: 9e 81 ldd r25, Y+6 ; 0x06 - 1694: 8a 0f add r24, r26 - 1696: 9b 1f adc r25, r27 - 1698: f4 01 movw r30, r8 - uint8_t* SrcPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - *DstPtr++ = *SrcPtr++; - 169a: 21 91 ld r18, Z+ - 169c: 2d 93 st X+, r18 - - /* Store to local memory */ - uint8_t* DstPtr = &Memory[BlockAddress]; - uint8_t* SrcPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - 169e: a8 17 cp r26, r24 - 16a0: b9 07 cpc r27, r25 - 16a2: d9 f7 brne .-10 ; 0x169a - } - - return true; - } - -} - 16a4: 81 e0 ldi r24, 0x01 ; 1 - 16a6: 2c 96 adiw r28, 0x0c ; 12 - 16a8: cd bf out 0x3d, r28 ; 61 - 16aa: de bf out 0x3e, r29 ; 62 - 16ac: df 91 pop r29 - 16ae: cf 91 pop r28 - 16b0: 1f 91 pop r17 - 16b2: 0f 91 pop r16 - 16b4: ff 90 pop r15 - 16b6: ef 90 pop r14 - 16b8: df 90 pop r13 - 16ba: cf 90 pop r12 - 16bc: bf 90 pop r11 - 16be: af 90 pop r10 - 16c0: 9f 90 pop r9 - 16c2: 8f 90 pop r8 - 16c4: 7f 90 pop r7 - 16c6: 6f 90 pop r6 - 16c8: 5f 90 pop r5 - 16ca: 4f 90 pop r4 - 16cc: 3f 90 pop r3 - 16ce: 2f 90 pop r2 - 16d0: 08 95 ret - 16d2: 2a 2d mov r18, r10 - 16d4: 33 2d mov r19, r3 - 16d6: 7f cf rjmp .-258 ; 0x15d6 - return true; - } else { - /* Calculate bytes left in memory and start writing */ - uint32_t BytesLeft = MEMORY_SIZE_PER_SETTING - BlockAddress; - uint32_t FlashAddress = (uint32_t) BlockAddress + (uint32_t) GlobalSettings.ActiveSettingIdx * MEMORY_SIZE_PER_SETTING; - ByteCount = MIN(ByteCount, BytesLeft); - 16d8: 0d 83 std Y+5, r16 ; 0x05 - 16da: 1e 83 std Y+6, r17 ; 0x06 - 16dc: 2f 83 std Y+7, r18 ; 0x07 - 16de: 38 87 std Y+8, r19 ; 0x08 - 16e0: aa ce rjmp .-684 ; 0x1436 - -000016e2 : - } - -} - -bool MemoryDownloadBlock(void* Buffer, uint32_t BlockAddress, uint16_t ByteCount) -{ - 16e2: cf 92 push r12 - 16e4: df 92 push r13 - 16e6: ef 92 push r14 - 16e8: ff 92 push r15 - 16ea: 0f 93 push r16 - 16ec: 1f 93 push r17 - 16ee: 69 01 movw r12, r18 - if (BlockAddress >= MEMORY_SIZE_PER_SETTING) { - 16f0: 41 15 cp r20, r1 - 16f2: 24 e0 ldi r18, 0x04 ; 4 - 16f4: 52 07 cpc r21, r18 - 16f6: 61 05 cpc r22, r1 - 16f8: 71 05 cpc r23, r1 - 16fa: 40 f5 brcc .+80 ; 0x174c - /* There are bytes out of bounds to be read. Notify that we are done. */ - return false; - } else { - /* Calculate bytes left in memory and issue reading */ - uint32_t BytesLeft = MEMORY_SIZE_PER_SETTING - BlockAddress; - 16fc: 00 e0 ldi r16, 0x00 ; 0 - 16fe: 14 e0 ldi r17, 0x04 ; 4 - 1700: 20 e0 ldi r18, 0x00 ; 0 - 1702: 30 e0 ldi r19, 0x00 ; 0 - //uint32_t FlashAddress = (uint32_t) BlockAddress + (uint32_t) GlobalSettings.ActiveSetting * MEMORY_SIZE_PER_SETTING; - ByteCount = MIN(ByteCount, BytesLeft); - 1704: e1 2c mov r14, r1 - 1706: f1 2c mov r15, r1 - 1708: 04 1b sub r16, r20 - 170a: 15 0b sbc r17, r21 - 170c: 26 0b sbc r18, r22 - 170e: 37 0b sbc r19, r23 - 1710: c0 16 cp r12, r16 - 1712: d1 06 cpc r13, r17 - 1714: e2 06 cpc r14, r18 - 1716: f3 06 cpc r15, r19 - 1718: b0 f0 brcs .+44 ; 0x1746 - - /* Output local memory contents */ - uint8_t* DstPtr = (uint8_t*) Buffer; - uint8_t* SrcPtr = &Memory[BlockAddress]; - 171a: 4e 56 subi r20, 0x6E ; 110 - 171c: 5f 4d sbci r21, 0xDF ; 223 - - while(ByteCount--) { - 171e: 01 15 cp r16, r1 - 1720: 11 05 cpc r17, r1 - 1722: 49 f0 breq .+18 ; 0x1736 - 1724: da 01 movw r26, r20 - 1726: fc 01 movw r30, r24 - 1728: 08 0f add r16, r24 - 172a: 19 1f adc r17, r25 - *DstPtr++ = *SrcPtr++; - 172c: 8d 91 ld r24, X+ - 172e: 81 93 st Z+, r24 - - /* Output local memory contents */ - uint8_t* DstPtr = (uint8_t*) Buffer; - uint8_t* SrcPtr = &Memory[BlockAddress]; - - while(ByteCount--) { - 1730: e0 17 cp r30, r16 - 1732: f1 07 cpc r31, r17 - 1734: d9 f7 brne .-10 ; 0x172c - *DstPtr++ = *SrcPtr++; - } - - return true; - 1736: 81 e0 ldi r24, 0x01 ; 1 - } -} - 1738: 1f 91 pop r17 - 173a: 0f 91 pop r16 - 173c: ff 90 pop r15 - 173e: ef 90 pop r14 - 1740: df 90 pop r13 - 1742: cf 90 pop r12 - 1744: 08 95 ret - return false; - } else { - /* Calculate bytes left in memory and issue reading */ - uint32_t BytesLeft = MEMORY_SIZE_PER_SETTING - BlockAddress; - //uint32_t FlashAddress = (uint32_t) BlockAddress + (uint32_t) GlobalSettings.ActiveSetting * MEMORY_SIZE_PER_SETTING; - ByteCount = MIN(ByteCount, BytesLeft); - 1746: 97 01 movw r18, r14 - 1748: 86 01 movw r16, r12 - 174a: e7 cf rjmp .-50 ; 0x171a - -bool MemoryDownloadBlock(void* Buffer, uint32_t BlockAddress, uint16_t ByteCount) -{ - if (BlockAddress >= MEMORY_SIZE_PER_SETTING) { - /* There are bytes out of bounds to be read. Notify that we are done. */ - return false; - 174c: 80 e0 ldi r24, 0x00 ; 0 - *DstPtr++ = *SrcPtr++; - } - - return true; - } -} - 174e: 1f 91 pop r17 - 1750: 0f 91 pop r16 - 1752: ff 90 pop r15 - 1754: ef 90 pop r14 - 1756: df 90 pop r13 - 1758: cf 90 pop r12 - 175a: 08 95 ret - -0000175c : - [BUTTON_ACTION_STORE_MEM] = "STORE_MEM", - [BUTTON_ACTION_RECALL_MEM] = "RECALL_MEM", -}; - -static void ExecuteButtonAction(ButtonActionEnum ButtonAction) -{ - 175c: ff 92 push r15 - 175e: 0f 93 push r16 - 1760: 1f 93 push r17 - 1762: cf 93 push r28 - 1764: df 93 push r29 - 1766: cd b7 in r28, 0x3d ; 61 - 1768: de b7 in r29, 0x3e ; 62 - 176a: a0 97 sbiw r28, 0x20 ; 32 - 176c: cd bf out 0x3d, r28 ; 61 - 176e: de bf out 0x3e, r29 ; 62 - uint8_t UidBuffer[32]; - - if (ButtonAction == BUTTON_ACTION_UID_RANDOM) { - 1770: 81 30 cpi r24, 0x01 ; 1 - 1772: e9 f0 breq .+58 ; 0x17ae - for (uint8_t i=0; i - 1778: 51 c0 rjmp .+162 ; 0x181c - UidBuffer[i] = (UidBuffer[i] + 1) & 0xFF; - } - } - - ApplicationSetUid(UidBuffer); - } else if (ButtonAction == BUTTON_ACTION_UID_RIGHT_INCREMENT) { - 177a: 83 30 cpi r24, 0x03 ; 3 - 177c: 09 f4 brne .+2 ; 0x1780 - 177e: 6c c0 rjmp .+216 ; 0x1858 - UidBuffer[i] = (UidBuffer[i] + 1) & 0xFF; - } - } - - ApplicationSetUid(UidBuffer); - } else if (ButtonAction == BUTTON_ACTION_UID_LEFT_DECREMENT) { - 1780: 84 30 cpi r24, 0x04 ; 4 - 1782: 79 f1 breq .+94 ; 0x17e2 - UidBuffer[i] = (UidBuffer[i] - 1) & 0xFF; - } - } - - ApplicationSetUid(UidBuffer); - } else if (ButtonAction == BUTTON_ACTION_UID_RIGHT_DECREMENT) { - 1784: 85 30 cpi r24, 0x05 ; 5 - 1786: 09 f4 brne .+2 ; 0x178a - 1788: 8c c0 rjmp .+280 ; 0x18a2 - UidBuffer[i] = (UidBuffer[i] - 1) & 0xFF; - } - } - - ApplicationSetUid(UidBuffer); - } else if (ButtonAction == BUTTON_ACTION_CYCLE_SETTINGS) { - 178a: 86 30 cpi r24, 0x06 ; 6 - 178c: 09 f4 brne .+2 ; 0x1790 - 178e: ab c0 rjmp .+342 ; 0x18e6 - SettingsCycle(); - } else if (ButtonAction == BUTTON_ACTION_STORE_MEM) { - 1790: 87 30 cpi r24, 0x07 ; 7 - 1792: 09 f4 brne .+2 ; 0x1796 - 1794: aa c0 rjmp .+340 ; 0x18ea - MemoryStore(); - } else if (ButtonAction == BUTTON_ACTION_RECALL_MEM) { - 1796: 88 30 cpi r24, 0x08 ; 8 - 1798: 09 f4 brne .+2 ; 0x179c - 179a: 81 c0 rjmp .+258 ; 0x189e - MemoryRecall(); - } -} - 179c: a0 96 adiw r28, 0x20 ; 32 - 179e: cd bf out 0x3d, r28 ; 61 - 17a0: de bf out 0x3e, r29 ; 62 - 17a2: df 91 pop r29 - 17a4: cf 91 pop r28 - 17a6: 1f 91 pop r17 - 17a8: 0f 91 pop r16 - 17aa: ff 90 pop r15 - 17ac: 08 95 ret -static void ExecuteButtonAction(ButtonActionEnum ButtonAction) -{ - uint8_t UidBuffer[32]; - - if (ButtonAction == BUTTON_ACTION_UID_RANDOM) { - for (uint8_t i=0; i - 17b6: 9b c0 rjmp .+310 ; 0x18ee - 17b8: f1 2c mov r15, r1 - 17ba: 8e 01 movw r16, r28 - 17bc: 0f 5f subi r16, 0xFF ; 255 - 17be: 1f 4f sbci r17, 0xFF ; 255 - UidBuffer[i] = RandomGetByte(); - 17c0: d9 da rcall .-2638 ; 0xd74 - 17c2: f8 01 movw r30, r16 - 17c4: ef 0d add r30, r15 - 17c6: f1 1d adc r31, r1 - 17c8: 80 83 st Z, r24 -static void ExecuteButtonAction(ButtonActionEnum ButtonAction) -{ - uint8_t UidBuffer[32]; - - if (ButtonAction == BUTTON_ACTION_UID_RANDOM) { - for (uint8_t i=0; i -INLINE void ApplicationGetUid(ConfigurationUidType Uid) { - ActiveConfiguration.ApplicationGetUidFunc(Uid); -} - -INLINE void ApplicationSetUid(ConfigurationUidType Uid) { - ActiveConfiguration.ApplicationSetUidFunc(Uid); - 17d4: e0 91 01 29 lds r30, 0x2901 - 17d8: f0 91 02 29 lds r31, 0x2902 - 17dc: c8 01 movw r24, r16 - 17de: 09 95 icall - 17e0: dd cf rjmp .-70 ; 0x179c - ActiveConfiguration.ApplicationResetFunc(); - //LogEntry(LOG_INFO_APP_RESET, NULL, 0); -} - -INLINE void ApplicationGetUid(ConfigurationUidType Uid) { - ActiveConfiguration.ApplicationGetUidFunc(Uid); - 17e2: e0 91 ff 28 lds r30, 0x28FF - 17e6: f0 91 00 29 lds r31, 0x2900 - 17ea: 8e 01 movw r16, r28 - 17ec: 0f 5f subi r16, 0xFF ; 255 - 17ee: 1f 4f sbci r17, 0xFF ; 255 - 17f0: c8 01 movw r24, r16 - 17f2: 09 95 icall - } else if (ButtonAction == BUTTON_ACTION_UID_LEFT_DECREMENT) { - ApplicationGetUid(UidBuffer); - bool Carry = 1; - uint8_t i; - - for (i=0; i - 17fc: f8 01 movw r30, r16 - } - - ApplicationSetUid(UidBuffer); - } else if (ButtonAction == BUTTON_ACTION_UID_LEFT_DECREMENT) { - ApplicationGetUid(UidBuffer); - bool Carry = 1; - 17fe: 91 e0 ldi r25, 0x01 ; 1 - uint8_t i; - - for (i=0; i - if (UidBuffer[i] == 0x00) { - 1804: 80 81 ld r24, Z - 1806: 91 e0 ldi r25, 0x01 ; 1 - 1808: 81 11 cpse r24, r1 - 180a: 90 e0 ldi r25, 0x00 ; 0 - Carry = 1; - } else { - Carry = 0; - } - - UidBuffer[i] = (UidBuffer[i] - 1) & 0xFF; - 180c: 81 50 subi r24, 0x01 ; 1 - 180e: 80 83 st Z, r24 - 1810: 31 96 adiw r30, 0x01 ; 1 - 1812: 8e 2f mov r24, r30 - 1814: 80 1b sub r24, r16 - } else if (ButtonAction == BUTTON_ACTION_UID_LEFT_DECREMENT) { - ApplicationGetUid(UidBuffer); - bool Carry = 1; - uint8_t i; - - for (i=0; i - 181a: dc cf rjmp .-72 ; 0x17d4 - 181c: e0 91 ff 28 lds r30, 0x28FF - 1820: f0 91 00 29 lds r31, 0x2900 - 1824: 8e 01 movw r16, r28 - 1826: 0f 5f subi r16, 0xFF ; 255 - 1828: 1f 4f sbci r17, 0xFF ; 255 - 182a: c8 01 movw r24, r16 - 182c: 09 95 icall - } else if (ButtonAction == BUTTON_ACTION_UID_LEFT_INCREMENT) { - ApplicationGetUid(UidBuffer); - bool Carry = 1; - uint8_t i; - - for (i=0; i - 1836: f8 01 movw r30, r16 - } - - ApplicationSetUid(UidBuffer); - } else if (ButtonAction == BUTTON_ACTION_UID_LEFT_INCREMENT) { - ApplicationGetUid(UidBuffer); - bool Carry = 1; - 1838: 91 e0 ldi r25, 0x01 ; 1 - uint8_t i; - - for (i=0; i - if (UidBuffer[i] == 0xFF) { - 183e: 80 81 ld r24, Z - 1840: 91 e0 ldi r25, 0x01 ; 1 - 1842: 8f 3f cpi r24, 0xFF ; 255 - 1844: 09 f0 breq .+2 ; 0x1848 - 1846: 90 e0 ldi r25, 0x00 ; 0 - Carry = 1; - } else { - Carry = 0; - } - - UidBuffer[i] = (UidBuffer[i] + 1) & 0xFF; - 1848: 8f 5f subi r24, 0xFF ; 255 - 184a: 80 83 st Z, r24 - 184c: 31 96 adiw r30, 0x01 ; 1 - 184e: 8e 2f mov r24, r30 - 1850: 80 1b sub r24, r16 - } else if (ButtonAction == BUTTON_ACTION_UID_LEFT_INCREMENT) { - ApplicationGetUid(UidBuffer); - bool Carry = 1; - uint8_t i; - - for (i=0; i - 1856: be cf rjmp .-132 ; 0x17d4 - 1858: e0 91 ff 28 lds r30, 0x28FF - 185c: f0 91 00 29 lds r31, 0x2900 - 1860: 8e 01 movw r16, r28 - 1862: 0f 5f subi r16, 0xFF ; 255 - 1864: 1f 4f sbci r17, 0xFF ; 255 - 1866: c8 01 movw r24, r16 - 1868: 09 95 icall - - ApplicationSetUid(UidBuffer); - } else if (ButtonAction == BUTTON_ACTION_UID_RIGHT_INCREMENT) { - ApplicationGetUid(UidBuffer); - bool Carry = 1; - uint8_t i = ActiveConfiguration.UidSize; - 186a: 20 91 05 29 lds r18, 0x2905 - } - - ApplicationSetUid(UidBuffer); - } else if (ButtonAction == BUTTON_ACTION_UID_RIGHT_INCREMENT) { - ApplicationGetUid(UidBuffer); - bool Carry = 1; - 186e: 31 e0 ldi r19, 0x01 ; 1 - uint8_t i = ActiveConfiguration.UidSize; - - while(i-- > 0) { - 1870: 21 50 subi r18, 0x01 ; 1 - 1872: 08 f4 brcc .+2 ; 0x1876 - 1874: af cf rjmp .-162 ; 0x17d4 - if (Carry) { - 1876: 33 23 and r19, r19 - 1878: d9 f3 breq .-10 ; 0x1870 - if (UidBuffer[i] == 0xFF) { - 187a: 82 2f mov r24, r18 - 187c: 90 e0 ldi r25, 0x00 ; 0 - 187e: f8 01 movw r30, r16 - 1880: e8 0f add r30, r24 - 1882: f9 1f adc r31, r25 - 1884: 40 81 ld r20, Z - 1886: 31 e0 ldi r19, 0x01 ; 1 - 1888: 4f 3f cpi r20, 0xFF ; 255 - 188a: 09 f0 breq .+2 ; 0x188e - 188c: 30 e0 ldi r19, 0x00 ; 0 - Carry = 1; - } else { - Carry = 0; - } - - UidBuffer[i] = (UidBuffer[i] + 1) & 0xFF; - 188e: f8 01 movw r30, r16 - 1890: e8 0f add r30, r24 - 1892: f9 1f adc r31, r25 - 1894: 4f 5f subi r20, 0xFF ; 255 - 1896: 40 83 st Z, r20 - } else if (ButtonAction == BUTTON_ACTION_UID_RIGHT_INCREMENT) { - ApplicationGetUid(UidBuffer); - bool Carry = 1; - uint8_t i = ActiveConfiguration.UidSize; - - while(i-- > 0) { - 1898: 21 50 subi r18, 0x01 ; 1 - 189a: 68 f7 brcc .-38 ; 0x1876 - 189c: 9b cf rjmp .-202 ; 0x17d4 - } else if (ButtonAction == BUTTON_ACTION_CYCLE_SETTINGS) { - SettingsCycle(); - } else if (ButtonAction == BUTTON_ACTION_STORE_MEM) { - MemoryStore(); - } else if (ButtonAction == BUTTON_ACTION_RECALL_MEM) { - MemoryRecall(); - 189e: 4f db rcall .-2402 ; 0xf3e - 18a0: 7d cf rjmp .-262 ; 0x179c - 18a2: e0 91 ff 28 lds r30, 0x28FF - 18a6: f0 91 00 29 lds r31, 0x2900 - 18aa: 8e 01 movw r16, r28 - 18ac: 0f 5f subi r16, 0xFF ; 255 - 18ae: 1f 4f sbci r17, 0xFF ; 255 - 18b0: c8 01 movw r24, r16 - 18b2: 09 95 icall - - ApplicationSetUid(UidBuffer); - } else if (ButtonAction == BUTTON_ACTION_UID_RIGHT_DECREMENT) { - ApplicationGetUid(UidBuffer); - bool Carry = 1; - uint8_t i = ActiveConfiguration.UidSize; - 18b4: 20 91 05 29 lds r18, 0x2905 - } - - ApplicationSetUid(UidBuffer); - } else if (ButtonAction == BUTTON_ACTION_UID_RIGHT_DECREMENT) { - ApplicationGetUid(UidBuffer); - bool Carry = 1; - 18b8: 31 e0 ldi r19, 0x01 ; 1 - uint8_t i = ActiveConfiguration.UidSize; - - while(i-- > 0) { - 18ba: 21 50 subi r18, 0x01 ; 1 - 18bc: 08 f4 brcc .+2 ; 0x18c0 - 18be: 8a cf rjmp .-236 ; 0x17d4 - if (Carry) { - 18c0: 33 23 and r19, r19 - 18c2: d9 f3 breq .-10 ; 0x18ba - if (UidBuffer[i] == 0x00) { - 18c4: 82 2f mov r24, r18 - 18c6: 90 e0 ldi r25, 0x00 ; 0 - 18c8: f8 01 movw r30, r16 - 18ca: e8 0f add r30, r24 - 18cc: f9 1f adc r31, r25 - 18ce: 40 81 ld r20, Z - 18d0: 31 e0 ldi r19, 0x01 ; 1 - 18d2: 41 11 cpse r20, r1 - 18d4: 30 e0 ldi r19, 0x00 ; 0 - Carry = 1; - } else { - Carry = 0; - } - - UidBuffer[i] = (UidBuffer[i] - 1) & 0xFF; - 18d6: f8 01 movw r30, r16 - 18d8: e8 0f add r30, r24 - 18da: f9 1f adc r31, r25 - 18dc: 41 50 subi r20, 0x01 ; 1 - 18de: 40 83 st Z, r20 - } else if (ButtonAction == BUTTON_ACTION_UID_RIGHT_DECREMENT) { - ApplicationGetUid(UidBuffer); - bool Carry = 1; - uint8_t i = ActiveConfiguration.UidSize; - - while(i-- > 0) { - 18e0: 21 50 subi r18, 0x01 ; 1 - 18e2: 70 f7 brcc .-36 ; 0x18c0 - 18e4: 77 cf rjmp .-274 ; 0x17d4 - } - } - - ApplicationSetUid(UidBuffer); - } else if (ButtonAction == BUTTON_ACTION_CYCLE_SETTINGS) { - SettingsCycle(); - 18e6: 57 d2 rcall .+1198 ; 0x1d96 - 18e8: 59 cf rjmp .-334 ; 0x179c - } else if (ButtonAction == BUTTON_ACTION_STORE_MEM) { - MemoryStore(); - 18ea: 1e dc rcall .-1988 ; 0x1128 - 18ec: 57 cf rjmp .-338 ; 0x179c - 18ee: 8e 01 movw r16, r28 - 18f0: 0f 5f subi r16, 0xFF ; 255 - 18f2: 1f 4f sbci r17, 0xFF ; 255 - 18f4: 6f cf rjmp .-290 ; 0x17d4 - -000018f6 : - } -} - -void ButtonInit(void) -{ - BUTTON_PORT.DIRCLR = BUTTON_MASK; - 18f6: e0 e0 ldi r30, 0x00 ; 0 - 18f8: f6 e0 ldi r31, 0x06 ; 6 - 18fa: 80 e4 ldi r24, 0x40 ; 64 - 18fc: 82 83 std Z+2, r24 ; 0x02 - BUTTON_PORT.BUTTON_PINCTRL = PORT_OPC_PULLUP_gc; - 18fe: 88 e1 ldi r24, 0x18 ; 24 - 1900: 86 8b std Z+22, r24 ; 0x16 - 1902: 08 95 ret - -00001904 : -} - -void ButtonTick(void) -{ - static uint8_t PressTickCounter = 0; - uint8_t ThisButtonState = ~BUTTON_PORT.IN; - 1904: 80 91 08 06 lds r24, 0x0608 - - if (ThisButtonState & BUTTON_MASK) { - 1908: 86 ff sbrs r24, 6 - 190a: 08 c0 rjmp .+16 ; 0x191c - /* Button is still pressed, ignore */ - } - } else if (!(ThisButtonState & BUTTON_MASK)) { - /* Button is currently not being pressed. Check if PressTickCounter contains - * a recent short button press. */ - if ( (PressTickCounter > 0) && (PressTickCounter <= LONG_PRESS_TICK_COUNT) ) { - 190c: 80 91 92 24 lds r24, 0x2492 - 1910: 81 50 subi r24, 0x01 ; 1 - 1912: 8a 30 cpi r24, 0x0A ; 10 - 1914: a8 f0 brcs .+42 ; 0x1940 - /* We have a short button press */ - ExecuteButtonAction(GlobalSettings.ActiveSettingPtr->ButtonAction); - } - - PressTickCounter = 0; - 1916: 10 92 92 24 sts 0x2492, r1 - 191a: 08 95 ret - static uint8_t PressTickCounter = 0; - uint8_t ThisButtonState = ~BUTTON_PORT.IN; - - if (ThisButtonState & BUTTON_MASK) { - /* Button is currently pressed */ - if (PressTickCounter < LONG_PRESS_TICK_COUNT) { - 191c: 80 91 92 24 lds r24, 0x2492 - 1920: 8a 30 cpi r24, 0x0A ; 10 - 1922: 50 f0 brcs .+20 ; 0x1938 - /* Count ticks while button is being pressed */ - PressTickCounter++; - } else if (PressTickCounter == LONG_PRESS_TICK_COUNT) { - 1924: 8a 30 cpi r24, 0x0A ; 10 - 1926: c9 f7 brne .-14 ; 0x191a - /* Long button press detected execute button action and advance PressTickCounter - * to an invalid state. */ - ExecuteButtonAction(GlobalSettings.ActiveSettingPtr->ButtonLongAction); - 1928: e0 91 0a 29 lds r30, 0x290A - 192c: f0 91 0b 29 lds r31, 0x290B - 1930: 81 81 ldd r24, Z+1 ; 0x01 - 1932: 14 df rcall .-472 ; 0x175c - PressTickCounter++; - 1934: 80 91 92 24 lds r24, 0x2492 - 1938: 8f 5f subi r24, 0xFF ; 255 - 193a: 80 93 92 24 sts 0x2492, r24 - 193e: 08 95 ret - } else if (!(ThisButtonState & BUTTON_MASK)) { - /* Button is currently not being pressed. Check if PressTickCounter contains - * a recent short button press. */ - if ( (PressTickCounter > 0) && (PressTickCounter <= LONG_PRESS_TICK_COUNT) ) { - /* We have a short button press */ - ExecuteButtonAction(GlobalSettings.ActiveSettingPtr->ButtonAction); - 1940: e0 91 0a 29 lds r30, 0x290A - 1944: f0 91 0b 29 lds r31, 0x290B - 1948: 80 81 ld r24, Z - 194a: 08 df rcall .-496 ; 0x175c - 194c: e4 cf rjmp .-56 ; 0x1916 - -0000194e : - PressTickCounter = 0; - } -} - -void ButtonGetActionList(char* ListOut, uint16_t BufferSize) -{ - 194e: 0f 93 push r16 - 1950: 1f 93 push r17 - 1952: cf 93 push r28 - 1954: df 93 push r29 - uint8_t i; - - /* Account for '\0' */ - BufferSize--; - 1956: 61 50 subi r22, 0x01 ; 1 - 1958: 71 09 sbc r23, r1 - 195a: 4c e5 ldi r20, 0x5C ; 92 - 195c: 54 e0 ldi r21, 0x04 ; 4 - BufferSize--; - } - - if ( i < (BUTTON_ACTION_COUNT - 1) ) { - /* No comma on last configuration */ - *ListOut++ = ','; - 195e: 1c e2 ldi r17, 0x2C ; 44 - - /* Account for '\0' */ - BufferSize--; - - for (i=0; i sizeof(ButtonActionTable[i]) ) { - 1962: fa 01 movw r30, r20 - 1964: 04 91 lpm r16, Z - 1966: 00 23 and r16, r16 - 1968: 49 f1 breq .+82 ; 0x19bc - 196a: 61 32 cpi r22, 0x21 ; 33 - 196c: 71 05 cpc r23, r1 - 196e: 20 f4 brcc .+8 ; 0x1978 - 1970: 25 c0 rjmp .+74 ; 0x19bc - 1972: 60 32 cpi r22, 0x20 ; 32 - 1974: 71 05 cpc r23, r1 - 1976: 61 f0 breq .+24 ; 0x1990 - 1978: dc 01 movw r26, r24 - 197a: 01 96 adiw r24, 0x01 ; 1 - 197c: ec 01 movw r28, r24 - /* While not end-of-string and enough buffer to - * put a complete configuration name */ - *ListOut++ = c; - 197e: 0c 93 st X, r16 - ActionName++; - 1980: 2f 5f subi r18, 0xFF ; 255 - 1982: 3f 4f sbci r19, 0xFF ; 255 - BufferSize--; - 1984: 61 50 subi r22, 0x01 ; 1 - 1986: 71 09 sbc r23, r1 - - for (i=0; i sizeof(ButtonActionTable[i]) ) { - 1988: f9 01 movw r30, r18 - 198a: 04 91 lpm r16, Z - 198c: 01 11 cpse r16, r1 - 198e: f1 cf rjmp .-30 ; 0x1972 - *ListOut++ = c; - ActionName++; - BufferSize--; - } - - if ( i < (BUTTON_ACTION_COUNT - 1) ) { - 1990: f5 e0 ldi r31, 0x05 ; 5 - 1992: 4c 35 cpi r20, 0x5C ; 92 - 1994: 5f 07 cpc r21, r31 - 1996: 61 f0 breq .+24 ; 0x19b0 - /* No comma on last configuration */ - *ListOut++ = ','; - 1998: ce 01 movw r24, r28 - 199a: 01 96 adiw r24, 0x01 ; 1 - 199c: 18 83 st Y, r17 - BufferSize--; - 199e: 61 50 subi r22, 0x01 ; 1 - 19a0: 71 09 sbc r23, r1 - 19a2: 40 5e subi r20, 0xE0 ; 224 - 19a4: 5f 4f sbci r21, 0xFF ; 255 - uint8_t i; - - /* Account for '\0' */ - BufferSize--; - - for (i=0; i - BufferSize--; - } - - if ( i < (BUTTON_ACTION_COUNT - 1) ) { - /* No comma on last configuration */ - *ListOut++ = ','; - 19ae: ec 01 movw r28, r24 - BufferSize--; - } - } - - *ListOut = '\0'; - 19b0: 18 82 st Y, r1 -} - 19b2: df 91 pop r29 - 19b4: cf 91 pop r28 - 19b6: 1f 91 pop r17 - 19b8: 0f 91 pop r16 - 19ba: 08 95 ret - - for (i=0; i sizeof(ButtonActionTable[i]) ) { - 19bc: ec 01 movw r28, r24 - 19be: e8 cf rjmp .-48 ; 0x1990 - -000019c0 : - - *ListOut = '\0'; -} - -void ButtonSetActionById(ButtonTypeEnum Type, ButtonActionEnum Action) -{ - 19c0: 88 23 and r24, r24 - 19c2: 19 f0 breq .+6 ; 0x19ca - 19c4: 81 30 cpi r24, 0x01 ; 1 - 19c6: 91 f0 breq .+36 ; 0x19ec - 19c8: 08 95 ret - } -#else - /* Write button action to all settings when using global settings */ - for (uint8_t i=0; i: - } -#endif -} - -void ButtonGetActionByName(ButtonTypeEnum Type, char* ActionOut, uint16_t BufferSize) -{ - 1a0e: fb 01 movw r30, r22 - if (Type == BUTTON_PRESS_SHORT) { - 1a10: 88 23 and r24, r24 - 1a12: 21 f0 breq .+8 ; 0x1a1c - strncpy_P(ActionOut, ButtonActionTable[GlobalSettings.ActiveSettingPtr->ButtonAction], BufferSize); - } else if (Type == BUTTON_PRESS_LONG) { - 1a14: 81 30 cpi r24, 0x01 ; 1 - 1a16: 81 f0 breq .+32 ; 0x1a38 - strncpy_P(ActionOut, ButtonActionTable[GlobalSettings.ActiveSettingPtr->ButtonLongAction], BufferSize); - } else { - /* Should not happen (TM) */ - *ActionOut = '\0'; - 1a18: 10 82 st Z, r1 - 1a1a: 08 95 ret -} - -void ButtonGetActionByName(ButtonTypeEnum Type, char* ActionOut, uint16_t BufferSize) -{ - if (Type == BUTTON_PRESS_SHORT) { - strncpy_P(ActionOut, ButtonActionTable[GlobalSettings.ActiveSettingPtr->ButtonAction], BufferSize); - 1a1c: a0 91 0a 29 lds r26, 0x290A - 1a20: b0 91 0b 29 lds r27, 0x290B - 1a24: 6c 91 ld r22, X - } else if (Type == BUTTON_PRESS_LONG) { - strncpy_P(ActionOut, ButtonActionTable[GlobalSettings.ActiveSettingPtr->ButtonLongAction], BufferSize); - 1a26: 80 e2 ldi r24, 0x20 ; 32 - 1a28: 68 9f mul r22, r24 - 1a2a: b0 01 movw r22, r0 - 1a2c: 11 24 eor r1, r1 - 1a2e: 64 5a subi r22, 0xA4 ; 164 - 1a30: 7b 4f sbci r23, 0xFB ; 251 - 1a32: cf 01 movw r24, r30 - 1a34: 0c 94 18 2c jmp 0x5830 ; 0x5830 - 1a38: a0 91 0a 29 lds r26, 0x290A - 1a3c: b0 91 0b 29 lds r27, 0x290B - 1a40: 11 96 adiw r26, 0x01 ; 1 - 1a42: 6c 91 ld r22, X - 1a44: f0 cf rjmp .-32 ; 0x1a26 - -00001a46 : - *ActionOut = '\0'; - } -} - -bool ButtonSetActionByName(ButtonTypeEnum Type, const char* Action) -{ - 1a46: 1f 93 push r17 - 1a48: cf 93 push r28 - 1a4a: df 93 push r29 - 1a4c: 18 2f mov r17, r24 - 1a4e: eb 01 movw r28, r22 - uint8_t i; - - for (i=0; i - 1a5a: 89 2b or r24, r25 - 1a5c: f1 f1 breq .+124 ; 0x1ada - 1a5e: 6c e7 ldi r22, 0x7C ; 124 - 1a60: 74 e0 ldi r23, 0x04 ; 4 - 1a62: ce 01 movw r24, r28 - 1a64: 0e 94 ff 2b call 0x57fe ; 0x57fe - 1a68: 89 2b or r24, r25 - 1a6a: 09 f4 brne .+2 ; 0x1a6e - 1a6c: 3e c0 rjmp .+124 ; 0x1aea - 1a6e: 6c e9 ldi r22, 0x9C ; 156 - 1a70: 74 e0 ldi r23, 0x04 ; 4 - 1a72: ce 01 movw r24, r28 - 1a74: 0e 94 ff 2b call 0x57fe ; 0x57fe - 1a78: 89 2b or r24, r25 - 1a7a: c9 f1 breq .+114 ; 0x1aee - 1a7c: 6c eb ldi r22, 0xBC ; 188 - 1a7e: 74 e0 ldi r23, 0x04 ; 4 - 1a80: ce 01 movw r24, r28 - 1a82: 0e 94 ff 2b call 0x57fe ; 0x57fe - 1a86: 89 2b or r24, r25 - 1a88: a1 f1 breq .+104 ; 0x1af2 - 1a8a: 6c ed ldi r22, 0xDC ; 220 - 1a8c: 74 e0 ldi r23, 0x04 ; 4 - 1a8e: ce 01 movw r24, r28 - 1a90: 0e 94 ff 2b call 0x57fe ; 0x57fe - 1a94: 89 2b or r24, r25 - 1a96: 79 f1 breq .+94 ; 0x1af6 - 1a98: 6c ef ldi r22, 0xFC ; 252 - 1a9a: 74 e0 ldi r23, 0x04 ; 4 - 1a9c: ce 01 movw r24, r28 - 1a9e: 0e 94 ff 2b call 0x57fe ; 0x57fe - 1aa2: 89 2b or r24, r25 - 1aa4: 51 f1 breq .+84 ; 0x1afa - 1aa6: 6c e1 ldi r22, 0x1C ; 28 - 1aa8: 75 e0 ldi r23, 0x05 ; 5 - 1aaa: ce 01 movw r24, r28 - 1aac: 0e 94 ff 2b call 0x57fe ; 0x57fe - 1ab0: 89 2b or r24, r25 - 1ab2: 29 f1 breq .+74 ; 0x1afe - 1ab4: 6c e3 ldi r22, 0x3C ; 60 - 1ab6: 75 e0 ldi r23, 0x05 ; 5 - 1ab8: ce 01 movw r24, r28 - 1aba: 0e 94 ff 2b call 0x57fe ; 0x57fe - 1abe: 89 2b or r24, r25 - 1ac0: 01 f1 breq .+64 ; 0x1b02 - 1ac2: 6c e5 ldi r22, 0x5C ; 92 - 1ac4: 75 e0 ldi r23, 0x05 ; 5 - 1ac6: ce 01 movw r24, r28 - 1ac8: 0e 94 ff 2b call 0x57fe ; 0x57fe - 1acc: 89 2b or r24, r25 - 1ace: d9 f0 breq .+54 ; 0x1b06 - return true; - } - } - - /* Button action not found */ - return false; - 1ad0: 80 e0 ldi r24, 0x00 ; 0 -} - 1ad2: df 91 pop r29 - 1ad4: cf 91 pop r28 - 1ad6: 1f 91 pop r17 - 1ad8: 08 95 ret - -bool ButtonSetActionByName(ButtonTypeEnum Type, const char* Action) -{ - uint8_t i; - - for (i=0; i - return true; - 1ae0: 81 e0 ldi r24, 0x01 ; 1 - } - } - - /* Button action not found */ - return false; -} - 1ae2: df 91 pop r29 - 1ae4: cf 91 pop r28 - 1ae6: 1f 91 pop r17 - 1ae8: 08 95 ret - -bool ButtonSetActionByName(ButtonTypeEnum Type, const char* Action) -{ - uint8_t i; - - for (i=0; i - 1aee: 62 e0 ldi r22, 0x02 ; 2 - 1af0: f5 cf rjmp .-22 ; 0x1adc - 1af2: 63 e0 ldi r22, 0x03 ; 3 - 1af4: f3 cf rjmp .-26 ; 0x1adc - 1af6: 64 e0 ldi r22, 0x04 ; 4 - 1af8: f1 cf rjmp .-30 ; 0x1adc - 1afa: 65 e0 ldi r22, 0x05 ; 5 - 1afc: ef cf rjmp .-34 ; 0x1adc - 1afe: 66 e0 ldi r22, 0x06 ; 6 - 1b00: ed cf rjmp .-38 ; 0x1adc - 1b02: 67 e0 ldi r22, 0x07 ; 7 - 1b04: eb cf rjmp .-42 ; 0x1adc - 1b06: 68 e0 ldi r22, 0x08 ; 8 - 1b08: e9 cf rjmp .-46 ; 0x1adc - -00001b0a : - [LOG_MODE_MEMORY] = "MEMORY", - [LOG_MODE_TERMINAL] = "TERMINAL" -}; - -static void LogFuncOff(LogEntryEnum Entry, void* Data, uint8_t Length) -{ - 1b0a: 08 95 ret - -00001b0c : - LogSetModeById(LOG_MODE_OFF); - } -} - -static void LogFuncTerminal(LogEntryEnum Entry, void* Data, uint8_t Length) -{ - 1b0c: 1f 93 push r17 - 1b0e: cf 93 push r28 - 1b10: df 93 push r29 - 1b12: eb 01 movw r28, r22 - 1b14: 14 2f mov r17, r20 -void EVENT_USB_Device_Disconnect(void); -void EVENT_USB_Device_ConfigurationChanged(void); -void EVENT_USB_Device_ControlRequest(void); - -INLINE void TerminalSendChar(char c) { CDC_Device_SendByte(&TerminalHandle, c); } -INLINE void TerminalSendByte(uint8_t Byte) { CDC_Device_SendByte(&TerminalHandle, Byte); } - 1b16: 68 2f mov r22, r24 - 1b18: 81 e0 ldi r24, 0x01 ; 1 - 1b1a: 90 e2 ldi r25, 0x20 ; 32 - 1b1c: 0e 94 f5 29 call 0x53ea ; 0x53ea - 1b20: 61 2f mov r22, r17 - 1b22: 81 e0 ldi r24, 0x01 ; 1 - 1b24: 90 e2 ldi r25, 0x20 ; 32 - 1b26: 0e 94 f5 29 call 0x53ea ; 0x53ea - TerminalSendByte((uint8_t) Entry); - TerminalSendByte((uint8_t) Length); - TerminalSendBlock(Data, Length); - 1b2a: 61 2f mov r22, r17 - 1b2c: 70 e0 ldi r23, 0x00 ; 0 - 1b2e: ce 01 movw r24, r28 -} - 1b30: df 91 pop r29 - 1b32: cf 91 pop r28 - 1b34: 1f 91 pop r17 - -static void LogFuncTerminal(LogEntryEnum Entry, void* Data, uint8_t Length) -{ - TerminalSendByte((uint8_t) Entry); - TerminalSendByte((uint8_t) Length); - TerminalSendBlock(Data, Length); - 1b36: 82 c3 rjmp .+1796 ; 0x223c - -00001b38 : - LogMemClear(); - LogSetModeById(GlobalSettings.ActiveSettingPtr->LogMode); -} - -void LogTick(void) -{ - 1b38: 08 95 ret - -00001b3a : - -} - -void LogTask(void) -{ - 1b3a: 08 95 ret - -00001b3c : - -} - -bool LogMemLoadBlock(void* Buffer, uint32_t BlockAddress, uint16_t ByteCount) -{ - if (BlockAddress < sizeof(LogMem)) { - 1b3c: 41 15 cp r20, r1 - 1b3e: e4 e0 ldi r30, 0x04 ; 4 - 1b40: 5e 07 cpc r21, r30 - 1b42: 61 05 cpc r22, r1 - 1b44: 71 05 cpc r23, r1 - 1b46: 80 f4 brcc .+32 ; 0x1b68 - uint8_t* DataPtr = (uint8_t*) Buffer; - uint8_t* MemPtr = &LogMem[BlockAddress]; - 1b48: 49 56 subi r20, 0x69 ; 105 - 1b4a: 5b 4d sbci r21, 0xDB ; 219 - - while(ByteCount-- > 0) { - 1b4c: 21 15 cp r18, r1 - 1b4e: 31 05 cpc r19, r1 - 1b50: 49 f0 breq .+18 ; 0x1b64 - 1b52: da 01 movw r26, r20 - 1b54: fc 01 movw r30, r24 - 1b56: 28 0f add r18, r24 - 1b58: 39 1f adc r19, r25 - *DataPtr++ = *MemPtr++; - 1b5a: 8d 91 ld r24, X+ - 1b5c: 81 93 st Z+, r24 -{ - if (BlockAddress < sizeof(LogMem)) { - uint8_t* DataPtr = (uint8_t*) Buffer; - uint8_t* MemPtr = &LogMem[BlockAddress]; - - while(ByteCount-- > 0) { - 1b5e: e2 17 cp r30, r18 - 1b60: f3 07 cpc r31, r19 - 1b62: d9 f7 brne .-10 ; 0x1b5a - *DataPtr++ = *MemPtr++; - } - - return true; - 1b64: 81 e0 ldi r24, 0x01 ; 1 - 1b66: 08 95 ret - } else { - return false; - 1b68: 80 e0 ldi r24, 0x00 ; 0 - } -} - 1b6a: 08 95 ret - -00001b6c : - -void LogMemClear(void) -{ - 1b6c: 40 e0 ldi r20, 0x00 ; 0 - 1b6e: 54 e0 ldi r21, 0x04 ; 4 - 1b70: 6f ef ldi r22, 0xFF ; 255 - 1b72: 7f ef ldi r23, 0xFF ; 255 - 1b74: 87 e9 ldi r24, 0x97 ; 151 - 1b76: 94 e2 ldi r25, 0x24 ; 36 - 1b78: 0e 94 30 2c call 0x5860 ; 0x5860 - - for (i=0; i: -} - -uint16_t LogMemFree(void) -{ - return LogMemLeft; -} - 1b96: 80 91 93 24 lds r24, 0x2493 - 1b9a: 90 91 94 24 lds r25, 0x2494 - 1b9e: 08 95 ret - -00001ba0 : - -void LogSetModeById(LogModeEnum Mode) -{ - GlobalSettings.ActiveSettingPtr->LogMode = Mode; - 1ba0: e0 91 0a 29 lds r30, 0x290A - 1ba4: f0 91 0b 29 lds r31, 0x290B - 1ba8: 82 83 std Z+2, r24 ; 0x02 - - switch(Mode) { - 1baa: 81 30 cpi r24, 0x01 ; 1 - 1bac: 91 f0 breq .+36 ; 0x1bd2 - 1bae: 50 f0 brcs .+20 ; 0x1bc4 - 1bb0: 82 30 cpi r24, 0x02 ; 2 - 1bb2: 39 f4 brne .+14 ; 0x1bc2 - case LOG_MODE_MEMORY: - LogFunc = LogFuncMemory; - break; - - case LOG_MODE_TERMINAL: - LogFunc = LogFuncTerminal; - 1bb4: 86 e8 ldi r24, 0x86 ; 134 - 1bb6: 9d e0 ldi r25, 0x0D ; 13 - 1bb8: 80 93 07 29 sts 0x2907, r24 - 1bbc: 90 93 08 29 sts 0x2908, r25 - 1bc0: 08 95 ret - 1bc2: 08 95 ret -{ - GlobalSettings.ActiveSettingPtr->LogMode = Mode; - - switch(Mode) { - case LOG_MODE_OFF: - LogFunc = LogFuncOff; - 1bc4: 85 e8 ldi r24, 0x85 ; 133 - 1bc6: 9d e0 ldi r25, 0x0D ; 13 - 1bc8: 80 93 07 29 sts 0x2907, r24 - 1bcc: 90 93 08 29 sts 0x2908, r25 - break; - 1bd0: 08 95 ret - - case LOG_MODE_MEMORY: - LogFunc = LogFuncMemory; - 1bd2: 87 ef ldi r24, 0xF7 ; 247 - 1bd4: 9d e0 ldi r25, 0x0D ; 13 - 1bd6: 80 93 07 29 sts 0x2907, r24 - 1bda: 90 93 08 29 sts 0x2908, r25 - break; - 1bde: 08 95 ret - -00001be0 : - TerminalSendBlock(Data, Length); -} - -void LogInit(void) -{ - LogMemClear(); - 1be0: c5 df rcall .-118 ; 0x1b6c - LogSetModeById(GlobalSettings.ActiveSettingPtr->LogMode); - 1be2: e0 91 0a 29 lds r30, 0x290A - 1be6: f0 91 0b 29 lds r31, 0x290B - 1bea: 82 81 ldd r24, Z+2 ; 0x02 - 1bec: d9 cf rjmp .-78 ; 0x1ba0 - -00001bee : - /* Do nothing */ -} - -static void LogFuncMemory(LogEntryEnum Entry, void* Data, uint8_t Length) -{ - if (LogMemLeft >= (Length + 2)) { - 1bee: 20 91 93 24 lds r18, 0x2493 - 1bf2: 30 91 94 24 lds r19, 0x2494 - 1bf6: e4 2f mov r30, r20 - 1bf8: f0 e0 ldi r31, 0x00 ; 0 - 1bfa: df 01 movw r26, r30 - 1bfc: 12 96 adiw r26, 0x02 ; 2 - 1bfe: 2a 17 cp r18, r26 - 1c00: 3b 07 cpc r19, r27 - 1c02: 50 f1 brcs .+84 ; 0x1c58 - LogMemLeft -= Length + 2; - 1c04: 22 50 subi r18, 0x02 ; 2 - 1c06: 31 09 sbc r19, r1 - 1c08: 2e 1b sub r18, r30 - 1c0a: 3f 0b sbc r19, r31 - 1c0c: 20 93 93 24 sts 0x2493, r18 - 1c10: 30 93 94 24 sts 0x2494, r19 - - uint8_t* DataPtr = (uint8_t*) Data; - - *LogMemPtr++ = (uint8_t) Entry; - 1c14: e0 91 95 24 lds r30, 0x2495 - 1c18: f0 91 96 24 lds r31, 0x2496 - 1c1c: 80 83 st Z, r24 - *LogMemPtr++ = (uint8_t) Length; - 1c1e: 9f 01 movw r18, r30 - 1c20: 2e 5f subi r18, 0xFE ; 254 - 1c22: 3f 4f sbci r19, 0xFF ; 255 - 1c24: 20 93 95 24 sts 0x2495, r18 - 1c28: 30 93 96 24 sts 0x2496, r19 - 1c2c: 41 83 std Z+1, r20 ; 0x01 - - while(Length--) { - 1c2e: 8f ef ldi r24, 0xFF ; 255 - 1c30: 84 0f add r24, r20 - 1c32: 44 23 and r20, r20 - 1c34: 81 f0 breq .+32 ; 0x1c56 - 1c36: fb 01 movw r30, r22 - 1c38: d9 01 movw r26, r18 - 1c3a: 98 2f mov r25, r24 - *LogMemPtr++ = *DataPtr++; - 1c3c: 41 91 ld r20, Z+ - 1c3e: 4d 93 st X+, r20 - uint8_t* DataPtr = (uint8_t*) Data; - - *LogMemPtr++ = (uint8_t) Entry; - *LogMemPtr++ = (uint8_t) Length; - - while(Length--) { - 1c40: 91 50 subi r25, 0x01 ; 1 - 1c42: e0 f7 brcc .-8 ; 0x1c3c - 1c44: 90 e0 ldi r25, 0x00 ; 0 - 1c46: 01 96 adiw r24, 0x01 ; 1 - 1c48: 82 0f add r24, r18 - 1c4a: 93 1f adc r25, r19 - 1c4c: 80 93 95 24 sts 0x2495, r24 - 1c50: 90 93 96 24 sts 0x2496, r25 - 1c54: 08 95 ret - 1c56: 08 95 ret - *LogMemPtr++ = *DataPtr++; - } - } else { - /* If memory full. Deactivate logmode */ - LogSetModeById(LOG_MODE_OFF); - 1c58: 80 e0 ldi r24, 0x00 ; 0 - 1c5a: a2 cf rjmp .-188 ; 0x1ba0 - -00001c5c : - } - -} - -bool LogSetModeByName(const char* Name) -{ - 1c5c: cf 93 push r28 - 1c5e: df 93 push r29 - 1c60: ec 01 movw r28, r24 - uint8_t i; - - for (i=0; i<(sizeof(LogModeTable) / sizeof(*LogModeTable)); i++) { - if (strcmp_P(Name, LogModeTable[i]) == 0) { - 1c62: 6e e7 ldi r22, 0x7E ; 126 - 1c64: 75 e0 ldi r23, 0x05 ; 5 - 1c66: 0e 94 ff 2b call 0x57fe ; 0x57fe - 1c6a: 89 2b or r24, r25 - 1c6c: 91 f0 breq .+36 ; 0x1c92 - 1c6e: 6e e8 ldi r22, 0x8E ; 142 - 1c70: 75 e0 ldi r23, 0x05 ; 5 - 1c72: ce 01 movw r24, r28 - 1c74: 0e 94 ff 2b call 0x57fe ; 0x57fe - 1c78: 89 2b or r24, r25 - 1c7a: 89 f0 breq .+34 ; 0x1c9e - 1c7c: 6e e9 ldi r22, 0x9E ; 158 - 1c7e: 75 e0 ldi r23, 0x05 ; 5 - 1c80: ce 01 movw r24, r28 - 1c82: 0e 94 ff 2b call 0x57fe ; 0x57fe - 1c86: 89 2b or r24, r25 - 1c88: 61 f0 breq .+24 ; 0x1ca2 - LogSetModeById(i); - return true; - } - } - - return false; - 1c8a: 80 e0 ldi r24, 0x00 ; 0 -} - 1c8c: df 91 pop r29 - 1c8e: cf 91 pop r28 - 1c90: 08 95 ret - -bool LogSetModeByName(const char* Name) -{ - uint8_t i; - - for (i=0; i<(sizeof(LogModeTable) / sizeof(*LogModeTable)); i++) { - 1c92: 80 e0 ldi r24, 0x00 ; 0 - if (strcmp_P(Name, LogModeTable[i]) == 0) { - LogSetModeById(i); - 1c94: 85 df rcall .-246 ; 0x1ba0 - return true; - 1c96: 81 e0 ldi r24, 0x01 ; 1 - } - } - - return false; -} - 1c98: df 91 pop r29 - 1c9a: cf 91 pop r28 - 1c9c: 08 95 ret - -bool LogSetModeByName(const char* Name) -{ - uint8_t i; - - for (i=0; i<(sizeof(LogModeTable) / sizeof(*LogModeTable)); i++) { - 1c9e: 81 e0 ldi r24, 0x01 ; 1 - 1ca0: f9 cf rjmp .-14 ; 0x1c94 - 1ca2: 82 e0 ldi r24, 0x02 ; 2 - 1ca4: f7 cf rjmp .-18 ; 0x1c94 - -00001ca6 : - - return false; -} - -void LogGetModeByName(char* Name, uint16_t BufferSize) -{ - 1ca6: ab 01 movw r20, r22 - strncpy_P(Name, LogModeTable[GlobalSettings.ActiveSettingPtr->LogMode], BufferSize); - 1ca8: e0 91 0a 29 lds r30, 0x290A - 1cac: f0 91 0b 29 lds r31, 0x290B - 1cb0: 62 81 ldd r22, Z+2 ; 0x02 - 1cb2: 20 e1 ldi r18, 0x10 ; 16 - 1cb4: 62 9f mul r22, r18 - 1cb6: b0 01 movw r22, r0 - 1cb8: 11 24 eor r1, r1 - 1cba: 62 58 subi r22, 0x82 ; 130 - 1cbc: 7a 4f sbci r23, 0xFA ; 250 - 1cbe: 0c 94 18 2c jmp 0x5830 ; 0x5830 - -00001cc2 : -} - -void LogGetModeList(char* List, uint16_t BufferSize) -{ - 1cc2: 0f 93 push r16 - 1cc4: 1f 93 push r17 - 1cc6: cf 93 push r28 - 1cc8: df 93 push r29 - 1cca: ec 01 movw r28, r24 - 1ccc: 8b 01 movw r16, r22 - uint8_t i; - - *List = '\0'; - 1cce: 18 82 st Y, r1 - - for (i=0; i<(sizeof(LogModeTable) / sizeof(*LogModeTable)); i++) { - strncat_P(List, LogModeTable[i], BufferSize); - 1cd0: ab 01 movw r20, r22 - 1cd2: 6e e7 ldi r22, 0x7E ; 126 - 1cd4: 75 e0 ldi r23, 0x05 ; 5 - 1cd6: 0e 94 08 2c call 0x5810 ; 0x5810 - - if (i < (sizeof(LogModeTable) / sizeof(*LogModeTable) - 1)) { - strncat_P(List, PSTR(","), BufferSize); - 1cda: a8 01 movw r20, r16 - 1cdc: 6c e7 ldi r22, 0x7C ; 124 - 1cde: 75 e0 ldi r23, 0x05 ; 5 - 1ce0: ce 01 movw r24, r28 - 1ce2: 0e 94 08 2c call 0x5810 ; 0x5810 - uint8_t i; - - *List = '\0'; - - for (i=0; i<(sizeof(LogModeTable) / sizeof(*LogModeTable)); i++) { - strncat_P(List, LogModeTable[i], BufferSize); - 1ce6: a8 01 movw r20, r16 - 1ce8: 6e e8 ldi r22, 0x8E ; 142 - 1cea: 75 e0 ldi r23, 0x05 ; 5 - 1cec: ce 01 movw r24, r28 - 1cee: 0e 94 08 2c call 0x5810 ; 0x5810 - - if (i < (sizeof(LogModeTable) / sizeof(*LogModeTable) - 1)) { - strncat_P(List, PSTR(","), BufferSize); - 1cf2: a8 01 movw r20, r16 - 1cf4: 6c e7 ldi r22, 0x7C ; 124 - 1cf6: 75 e0 ldi r23, 0x05 ; 5 - 1cf8: ce 01 movw r24, r28 - 1cfa: 0e 94 08 2c call 0x5810 ; 0x5810 - uint8_t i; - - *List = '\0'; - - for (i=0; i<(sizeof(LogModeTable) / sizeof(*LogModeTable)); i++) { - strncat_P(List, LogModeTable[i], BufferSize); - 1cfe: a8 01 movw r20, r16 - 1d00: 6e e9 ldi r22, 0x9E ; 158 - 1d02: 75 e0 ldi r23, 0x05 ; 5 - 1d04: ce 01 movw r24, r28 - - if (i < (sizeof(LogModeTable) / sizeof(*LogModeTable) - 1)) { - strncat_P(List, PSTR(","), BufferSize); - } - } -} - 1d06: df 91 pop r29 - 1d08: cf 91 pop r28 - 1d0a: 1f 91 pop r17 - 1d0c: 0f 91 pop r16 - uint8_t i; - - *List = '\0'; - - for (i=0; i<(sizeof(LogModeTable) / sizeof(*LogModeTable)); i++) { - strncat_P(List, LogModeTable[i], BufferSize); - 1d0e: 0c 94 08 2c jmp 0x5810 ; 0x5810 - -00001d12 : - } -} - -uint8_t SettingsGetActiveById(void) { - return INDEX_TO_SETTING(GlobalSettings.ActiveSettingIdx); -} - 1d12: 43 e3 ldi r20, 0x33 ; 51 - 1d14: 50 e0 ldi r21, 0x00 ; 0 - 1d16: 60 e0 ldi r22, 0x00 ; 0 - 1d18: 70 e0 ldi r23, 0x00 ; 0 - 1d1a: 89 e0 ldi r24, 0x09 ; 9 - 1d1c: 99 e2 ldi r25, 0x29 ; 41 - 1d1e: 0c 94 27 2e jmp 0x5c4e ; 0x5c4e <__eerd_block_x32a4u> - -00001d22 : - 1d22: 43 e3 ldi r20, 0x33 ; 51 - 1d24: 50 e0 ldi r21, 0x00 ; 0 - 1d26: 60 e0 ldi r22, 0x00 ; 0 - 1d28: 70 e0 ldi r23, 0x00 ; 0 - 1d2a: 89 e0 ldi r24, 0x09 ; 9 - 1d2c: 99 e2 ldi r25, 0x29 ; 41 - 1d2e: 0c 94 32 2e jmp 0x5c64 ; 0x5c64 <__eewr_block_x32a4u> - -00001d32 : - 1d32: 1f 93 push r17 - 1d34: cf 93 push r28 - 1d36: df 93 push r29 - 1d38: 1f 92 push r1 - 1d3a: cd b7 in r28, 0x3d ; 61 - 1d3c: de b7 in r29, 0x3e ; 62 - 1d3e: 1f ef ldi r17, 0xFF ; 255 - 1d40: 18 0f add r17, r24 - 1d42: 18 30 cpi r17, 0x08 ; 8 - 1d44: 30 f0 brcs .+12 ; 0x1d52 - 1d46: 80 e0 ldi r24, 0x00 ; 0 - 1d48: 0f 90 pop r0 - 1d4a: df 91 pop r29 - 1d4c: cf 91 pop r28 - 1d4e: 1f 91 pop r17 - 1d50: 08 95 ret - 1d52: 89 83 std Y+1, r24 ; 0x01 - 1d54: e9 d9 rcall .-3118 ; 0x1128 - 1d56: 10 93 09 29 sts 0x2909, r17 - 1d5a: 41 2f mov r20, r17 - 1d5c: 50 e0 ldi r21, 0x00 ; 0 - 1d5e: 9a 01 movw r18, r20 - 1d60: 22 0f add r18, r18 - 1d62: 33 1f adc r19, r19 - 1d64: 24 0f add r18, r20 - 1d66: 35 1f adc r19, r21 - 1d68: 22 0f add r18, r18 - 1d6a: 33 1f adc r19, r19 - 1d6c: 24 5f subi r18, 0xF4 ; 244 - 1d6e: 36 4d sbci r19, 0xD6 ; 214 - 1d70: 20 93 0a 29 sts 0x290A, r18 - 1d74: 30 93 0b 29 sts 0x290B, r19 - 1d78: 0e 94 3d 06 call 0xc7a ; 0xc7a - 1d7c: 31 df rcall .-414 ; 0x1be0 - 1d7e: df d8 rcall .-3650 ; 0xf3e - 1d80: 89 81 ldd r24, Y+1 ; 0x01 - 1d82: 6f e1 ldi r22, 0x1F ; 31 - 1d84: 68 0f add r22, r24 - 1d86: 83 e0 ldi r24, 0x03 ; 3 - 1d88: 2c d1 rcall .+600 ; 0x1fe2 - 1d8a: 81 e0 ldi r24, 0x01 ; 1 - 1d8c: 0f 90 pop r0 - 1d8e: df 91 pop r29 - 1d90: cf 91 pop r28 - 1d92: 1f 91 pop r17 - 1d94: 08 95 ret - -00001d96 : - 1d96: 20 91 09 29 lds r18, 0x2909 - 1d9a: 30 e0 ldi r19, 0x00 ; 0 - 1d9c: 2f 5f subi r18, 0xFF ; 255 - 1d9e: 3f 4f sbci r19, 0xFF ; 255 - 1da0: 27 70 andi r18, 0x07 ; 7 - 1da2: 33 27 eor r19, r19 - 1da4: 82 2f mov r24, r18 - 1da6: 2f 5f subi r18, 0xFF ; 255 - 1da8: 3f 4f sbci r19, 0xFF ; 255 - 1daa: f9 01 movw r30, r18 - 1dac: ee 0f add r30, r30 - 1dae: ff 1f adc r31, r31 - 1db0: e2 0f add r30, r18 - 1db2: f3 1f adc r31, r19 - 1db4: ee 0f add r30, r30 - 1db6: ff 1f adc r31, r31 - 1db8: e7 5f subi r30, 0xF7 ; 247 - 1dba: f6 4d sbci r31, 0xD6 ; 214 - 1dbc: 90 81 ld r25, Z - 1dbe: 91 11 cpse r25, r1 - 1dc0: 78 c0 rjmp .+240 ; 0x1eb2 - 1dc2: 27 70 andi r18, 0x07 ; 7 - 1dc4: 33 27 eor r19, r19 - 1dc6: 82 2f mov r24, r18 - 1dc8: 2f 5f subi r18, 0xFF ; 255 - 1dca: 3f 4f sbci r19, 0xFF ; 255 - 1dcc: f9 01 movw r30, r18 - 1dce: ee 0f add r30, r30 - 1dd0: ff 1f adc r31, r31 - 1dd2: e2 0f add r30, r18 - 1dd4: f3 1f adc r31, r19 - 1dd6: ee 0f add r30, r30 - 1dd8: ff 1f adc r31, r31 - 1dda: e7 5f subi r30, 0xF7 ; 247 - 1ddc: f6 4d sbci r31, 0xD6 ; 214 - 1dde: 90 81 ld r25, Z - 1de0: 91 11 cpse r25, r1 - 1de2: 67 c0 rjmp .+206 ; 0x1eb2 - 1de4: 27 70 andi r18, 0x07 ; 7 - 1de6: 33 27 eor r19, r19 - 1de8: 82 2f mov r24, r18 - 1dea: 2f 5f subi r18, 0xFF ; 255 - 1dec: 3f 4f sbci r19, 0xFF ; 255 - 1dee: f9 01 movw r30, r18 - 1df0: ee 0f add r30, r30 - 1df2: ff 1f adc r31, r31 - 1df4: e2 0f add r30, r18 - 1df6: f3 1f adc r31, r19 - 1df8: ee 0f add r30, r30 - 1dfa: ff 1f adc r31, r31 - 1dfc: e7 5f subi r30, 0xF7 ; 247 - 1dfe: f6 4d sbci r31, 0xD6 ; 214 - 1e00: 90 81 ld r25, Z - 1e02: 91 11 cpse r25, r1 - 1e04: 56 c0 rjmp .+172 ; 0x1eb2 - 1e06: 27 70 andi r18, 0x07 ; 7 - 1e08: 33 27 eor r19, r19 - 1e0a: 82 2f mov r24, r18 - 1e0c: 2f 5f subi r18, 0xFF ; 255 - 1e0e: 3f 4f sbci r19, 0xFF ; 255 - 1e10: f9 01 movw r30, r18 - 1e12: ee 0f add r30, r30 - 1e14: ff 1f adc r31, r31 - 1e16: e2 0f add r30, r18 - 1e18: f3 1f adc r31, r19 - 1e1a: ee 0f add r30, r30 - 1e1c: ff 1f adc r31, r31 - 1e1e: e7 5f subi r30, 0xF7 ; 247 - 1e20: f6 4d sbci r31, 0xD6 ; 214 - 1e22: 90 81 ld r25, Z - 1e24: 91 11 cpse r25, r1 - 1e26: 45 c0 rjmp .+138 ; 0x1eb2 - 1e28: 27 70 andi r18, 0x07 ; 7 - 1e2a: 33 27 eor r19, r19 - 1e2c: 82 2f mov r24, r18 - 1e2e: 2f 5f subi r18, 0xFF ; 255 - 1e30: 3f 4f sbci r19, 0xFF ; 255 - 1e32: f9 01 movw r30, r18 - 1e34: ee 0f add r30, r30 - 1e36: ff 1f adc r31, r31 - 1e38: e2 0f add r30, r18 - 1e3a: f3 1f adc r31, r19 - 1e3c: ee 0f add r30, r30 - 1e3e: ff 1f adc r31, r31 - 1e40: e7 5f subi r30, 0xF7 ; 247 - 1e42: f6 4d sbci r31, 0xD6 ; 214 - 1e44: 90 81 ld r25, Z - 1e46: 91 11 cpse r25, r1 - 1e48: 34 c0 rjmp .+104 ; 0x1eb2 - 1e4a: 27 70 andi r18, 0x07 ; 7 - 1e4c: 33 27 eor r19, r19 - 1e4e: 82 2f mov r24, r18 - 1e50: 2f 5f subi r18, 0xFF ; 255 - 1e52: 3f 4f sbci r19, 0xFF ; 255 - 1e54: f9 01 movw r30, r18 - 1e56: ee 0f add r30, r30 - 1e58: ff 1f adc r31, r31 - 1e5a: e2 0f add r30, r18 - 1e5c: f3 1f adc r31, r19 - 1e5e: ee 0f add r30, r30 - 1e60: ff 1f adc r31, r31 - 1e62: e7 5f subi r30, 0xF7 ; 247 - 1e64: f6 4d sbci r31, 0xD6 ; 214 - 1e66: 90 81 ld r25, Z - 1e68: 91 11 cpse r25, r1 - 1e6a: 23 c0 rjmp .+70 ; 0x1eb2 - 1e6c: 27 70 andi r18, 0x07 ; 7 - 1e6e: 33 27 eor r19, r19 - 1e70: 82 2f mov r24, r18 - 1e72: 2f 5f subi r18, 0xFF ; 255 - 1e74: 3f 4f sbci r19, 0xFF ; 255 - 1e76: f9 01 movw r30, r18 - 1e78: ee 0f add r30, r30 - 1e7a: ff 1f adc r31, r31 - 1e7c: e2 0f add r30, r18 - 1e7e: f3 1f adc r31, r19 - 1e80: ee 0f add r30, r30 - 1e82: ff 1f adc r31, r31 - 1e84: e7 5f subi r30, 0xF7 ; 247 - 1e86: f6 4d sbci r31, 0xD6 ; 214 - 1e88: 90 81 ld r25, Z - 1e8a: 91 11 cpse r25, r1 - 1e8c: 12 c0 rjmp .+36 ; 0x1eb2 - 1e8e: 27 70 andi r18, 0x07 ; 7 - 1e90: 33 27 eor r19, r19 - 1e92: 82 2f mov r24, r18 - 1e94: 2f 5f subi r18, 0xFF ; 255 - 1e96: 3f 4f sbci r19, 0xFF ; 255 - 1e98: f9 01 movw r30, r18 - 1e9a: ee 0f add r30, r30 - 1e9c: ff 1f adc r31, r31 - 1e9e: e2 0f add r30, r18 - 1ea0: f3 1f adc r31, r19 - 1ea2: ee 0f add r30, r30 - 1ea4: ff 1f adc r31, r31 - 1ea6: e7 5f subi r30, 0xF7 ; 247 - 1ea8: f6 4d sbci r31, 0xD6 ; 214 - 1eaa: 90 81 ld r25, Z - 1eac: 91 11 cpse r25, r1 - 1eae: 01 c0 rjmp .+2 ; 0x1eb2 - 1eb0: 08 95 ret - 1eb2: 8f 5f subi r24, 0xFF ; 255 - 1eb4: 3e cf rjmp .-388 ; 0x1d32 - -00001eb6 : - -void SettingsGetActiveByName(char* SettingOut, uint16_t BufferSize) { - SettingOut[0] = SettingsGetActiveById() + '0'; - 1eb6: 20 91 09 29 lds r18, 0x2909 - 1eba: 2f 5c subi r18, 0xCF ; 207 - 1ebc: fc 01 movw r30, r24 - 1ebe: 20 83 st Z, r18 - SettingOut[1] = '\0'; - 1ec0: 11 82 std Z+1, r1 ; 0x01 - 1ec2: 08 95 ret - -00001ec4 : -} - -bool SettingsSetActiveByName(const char* Setting) { - 1ec4: fc 01 movw r30, r24 - uint8_t SettingNr = Setting[0] - '0'; - 1ec6: 80 81 ld r24, Z - - if (Setting[1] == '\0') { - 1ec8: 91 81 ldd r25, Z+1 ; 0x01 - 1eca: 99 23 and r25, r25 - 1ecc: 11 f0 breq .+4 ; 0x1ed2 - return SettingsSetActiveById(SettingNr); - } else { - return false; - } -} - 1ece: 80 e0 ldi r24, 0x00 ; 0 - 1ed0: 08 95 ret - -bool SettingsSetActiveByName(const char* Setting) { - uint8_t SettingNr = Setting[0] - '0'; - - if (Setting[1] == '\0') { - return SettingsSetActiveById(SettingNr); - 1ed2: 80 53 subi r24, 0x30 ; 48 - 1ed4: 2e cf rjmp .-420 ; 0x1d32 - -00001ed6 : - } -} - -void LEDInit(void) -{ - LED_PORT.DIRSET = LED_MASK; - 1ed6: 80 e3 ldi r24, 0x30 ; 48 - 1ed8: e0 e0 ldi r30, 0x00 ; 0 - 1eda: f6 e0 ldi r31, 0x06 ; 6 - 1edc: 81 83 std Z+1, r24 ; 0x01 - 1ede: 08 95 ret - -00001ee0 : - -INLINE void Tick(uint8_t Mask, LEDActionEnum* Action) -{ - static uint8_t BlinkPrescaler = 0; - - switch (*Action) - 1ee0: 20 91 97 28 lds r18, 0x2897 - 1ee4: 82 2f mov r24, r18 - 1ee6: 90 e0 ldi r25, 0x00 ; 0 - 1ee8: 88 32 cpi r24, 0x28 ; 40 - 1eea: 91 05 cpc r25, r1 - 1eec: 88 f0 brcs .+34 ; 0x1f10 - } - break; - - default: - /* Should not happen (TM) */ - *Action = LED_NO_ACTION; - 1eee: 10 92 97 28 sts 0x2897, r1 - -INLINE void Tick(uint8_t Mask, LEDActionEnum* Action) -{ - static uint8_t BlinkPrescaler = 0; - - switch (*Action) - 1ef2: 20 91 98 28 lds r18, 0x2898 - 1ef6: 82 2f mov r24, r18 - 1ef8: 90 e0 ldi r25, 0x00 ; 0 - 1efa: 88 32 cpi r24, 0x28 ; 40 - 1efc: 91 05 cpc r25, r1 - 1efe: 18 f0 brcs .+6 ; 0x1f06 - } - break; - - default: - /* Should not happen (TM) */ - *Action = LED_NO_ACTION; - 1f00: 10 92 98 28 sts 0x2898, r1 - 1f04: 08 95 ret - -INLINE void Tick(uint8_t Mask, LEDActionEnum* Action) -{ - static uint8_t BlinkPrescaler = 0; - - switch (*Action) - 1f06: fc 01 movw r30, r24 - 1f08: e2 50 subi r30, 0x02 ; 2 - 1f0a: ff 4f sbci r31, 0xFF ; 255 - 1f0c: 0c 94 7a 2b jmp 0x56f4 ; 0x56f4 <__tablejump2__> - 1f10: fc 01 movw r30, r24 - 1f12: ea 5d subi r30, 0xDA ; 218 - 1f14: fe 4f sbci r31, 0xFE ; 254 - 1f16: 0c 94 7a 2b jmp 0x56f4 ; 0x56f4 <__tablejump2__> - - case LED_PULSE: - if (!(LED_PORT.OUT & Mask)) { - LED_PORT.OUTSET = Mask; - } else { - LED_PORT.OUTCLR = Mask; - 1f1a: 80 e2 ldi r24, 0x20 ; 32 - 1f1c: 80 93 06 06 sts 0x0606, r24 - *Action = LED_NO_ACTION; - 1f20: 10 92 98 28 sts 0x2898, r1 - 1f24: 08 95 ret - - case LED_PULSE: - if (!(LED_PORT.OUT & Mask)) { - LED_PORT.OUTSET = Mask; - } else { - LED_PORT.OUTCLR = Mask; - 1f26: 80 e1 ldi r24, 0x10 ; 16 - 1f28: 80 93 06 06 sts 0x0606, r24 - *Action = LED_NO_ACTION; - 1f2c: 10 92 97 28 sts 0x2897, r1 - 1f30: e0 cf rjmp .-64 ; 0x1ef2 - } - break; - - case LED_BLINK_1X ... LED_BLINK_8X: - if (++BlinkPrescaler == BLINK_PRESCALER) { - 1f32: 80 91 99 28 lds r24, 0x2899 - 1f36: 8f 5f subi r24, 0xFF ; 255 - 1f38: 81 30 cpi r24, 0x01 ; 1 - 1f3a: 99 f1 breq .+102 ; 0x1fa2 - 1f3c: 80 93 99 28 sts 0x2899, r24 - 1f40: 08 95 ret - LED_PORT.OUTCLR = Mask; - *Action = LED_NO_ACTION; - break; - - case LED_ON: - LED_PORT.OUTSET = Mask; - 1f42: 80 e2 ldi r24, 0x20 ; 32 - 1f44: 80 93 05 06 sts 0x0605, r24 - *Action = LED_NO_ACTION; - 1f48: 10 92 98 28 sts 0x2898, r1 - 1f4c: 08 95 ret - break; - - case LED_TOGGLE: - LED_PORT.OUTTGL = Mask; - 1f4e: 80 e2 ldi r24, 0x20 ; 32 - 1f50: 80 93 07 06 sts 0x0607, r24 - *Action = LED_NO_ACTION; - 1f54: 10 92 98 28 sts 0x2898, r1 - 1f58: 08 95 ret - break; - - case LED_PULSE: - if (!(LED_PORT.OUT & Mask)) { - 1f5a: 80 91 04 06 lds r24, 0x0604 - 1f5e: 85 fd sbrc r24, 5 - 1f60: dc cf rjmp .-72 ; 0x1f1a - BlinkPrescaler = 0; - /* Blink functionality occurs at slower speed than Tick-frequency */ - - if (!(LED_PORT.OUT & Mask)) { - /* LED is off, turn it on */ - LED_PORT.OUTSET = Mask; - 1f62: 80 e2 ldi r24, 0x20 ; 32 - 1f64: 80 93 05 06 sts 0x0605, r24 - 1f68: 08 95 ret - LED_PORT.OUTSET = Mask; - *Action = LED_NO_ACTION; - break; - - case LED_TOGGLE: - LED_PORT.OUTTGL = Mask; - 1f6a: 80 e1 ldi r24, 0x10 ; 16 - 1f6c: 80 93 07 06 sts 0x0607, r24 - *Action = LED_NO_ACTION; - 1f70: 10 92 97 28 sts 0x2897, r1 - 1f74: be cf rjmp .-132 ; 0x1ef2 - break; - - case LED_PULSE: - if (!(LED_PORT.OUT & Mask)) { - 1f76: 80 91 04 06 lds r24, 0x0604 - 1f7a: 84 fd sbrc r24, 4 - 1f7c: d4 cf rjmp .-88 ; 0x1f26 - BlinkPrescaler = 0; - /* Blink functionality occurs at slower speed than Tick-frequency */ - - if (!(LED_PORT.OUT & Mask)) { - /* LED is off, turn it on */ - LED_PORT.OUTSET = Mask; - 1f7e: 80 e1 ldi r24, 0x10 ; 16 - 1f80: 80 93 05 06 sts 0x0605, r24 - 1f84: b6 cf rjmp .-148 ; 0x1ef2 - LED_PORT.OUTCLR = Mask; - *Action = LED_NO_ACTION; - break; - - case LED_ON: - LED_PORT.OUTSET = Mask; - 1f86: 80 e1 ldi r24, 0x10 ; 16 - 1f88: 80 93 05 06 sts 0x0605, r24 - *Action = LED_NO_ACTION; - 1f8c: 10 92 97 28 sts 0x2897, r1 - 1f90: b0 cf rjmp .-160 ; 0x1ef2 - *Action = LED_NO_ACTION; - } - break; - - case LED_BLINK_1X ... LED_BLINK_8X: - if (++BlinkPrescaler == BLINK_PRESCALER) { - 1f92: 80 91 99 28 lds r24, 0x2899 - 1f96: 8f 5f subi r24, 0xFF ; 255 - 1f98: 81 30 cpi r24, 0x01 ; 1 - 1f9a: 99 f0 breq .+38 ; 0x1fc2 - 1f9c: 80 93 99 28 sts 0x2899, r24 - 1fa0: a8 cf rjmp .-176 ; 0x1ef2 - BlinkPrescaler = 0; - 1fa2: 10 92 99 28 sts 0x2899, r1 - /* Blink functionality occurs at slower speed than Tick-frequency */ - - if (!(LED_PORT.OUT & Mask)) { - 1fa6: 80 91 04 06 lds r24, 0x0604 - 1faa: 85 ff sbrs r24, 5 - 1fac: da cf rjmp .-76 ; 0x1f62 - /* LED is off, turn it on */ - LED_PORT.OUTSET = Mask; - } else { - /* LED is on, turn it off and change state */ - LED_PORT.OUTCLR = Mask; - 1fae: 80 e2 ldi r24, 0x20 ; 32 - 1fb0: 80 93 06 06 sts 0x0606, r24 - - if (*Action == LED_BLINK_1X) { - 1fb4: 20 32 cpi r18, 0x20 ; 32 - 1fb6: 09 f4 brne .+2 ; 0x1fba - 1fb8: a3 cf rjmp .-186 ; 0x1f00 - *Action = LED_NO_ACTION; - } else { - /* Still some blinks to do. Use the fact that LED_BLINK_XY are ordered sequentially */ - *Action = *Action - 1; - 1fba: 21 50 subi r18, 0x01 ; 1 - 1fbc: 20 93 98 28 sts 0x2898, r18 - 1fc0: 08 95 ret - } - break; - - case LED_BLINK_1X ... LED_BLINK_8X: - if (++BlinkPrescaler == BLINK_PRESCALER) { - BlinkPrescaler = 0; - 1fc2: 10 92 99 28 sts 0x2899, r1 - /* Blink functionality occurs at slower speed than Tick-frequency */ - - if (!(LED_PORT.OUT & Mask)) { - 1fc6: 80 91 04 06 lds r24, 0x0604 - 1fca: 84 ff sbrs r24, 4 - 1fcc: d8 cf rjmp .-80 ; 0x1f7e - /* LED is off, turn it on */ - LED_PORT.OUTSET = Mask; - } else { - /* LED is on, turn it off and change state */ - LED_PORT.OUTCLR = Mask; - 1fce: 80 e1 ldi r24, 0x10 ; 16 - 1fd0: 80 93 06 06 sts 0x0606, r24 - - if (*Action == LED_BLINK_1X) { - 1fd4: 20 32 cpi r18, 0x20 ; 32 - 1fd6: 09 f4 brne .+2 ; 0x1fda - 1fd8: 8a cf rjmp .-236 ; 0x1eee - *Action = LED_NO_ACTION; - } else { - /* Still some blinks to do. Use the fact that LED_BLINK_XY are ordered sequentially */ - *Action = *Action - 1; - 1fda: 21 50 subi r18, 0x01 ; 1 - 1fdc: 20 93 97 28 sts 0x2897, r18 - 1fe0: 88 cf rjmp .-240 ; 0x1ef2 - -00001fe2 : - Tick(LED_GREEN, &LEDGreenAction); -} - -/* TODO: This would be nicer as INLINE */ -void LEDTrigger(LEDFunctionEnum Func, LEDActionEnum Action) { - if (GlobalSettings.ActiveSettingPtr->LEDGreenFunction == Func) { - 1fe2: e0 91 0a 29 lds r30, 0x290A - 1fe6: f0 91 0b 29 lds r31, 0x290B - 1fea: 95 81 ldd r25, Z+5 ; 0x05 - 1fec: 98 17 cp r25, r24 - 1fee: 31 f0 breq .+12 ; 0x1ffc - LEDGreenAction = Action; - } - - if (GlobalSettings.ActiveSettingPtr->LEDRedFunction == Func) { - 1ff0: 94 81 ldd r25, Z+4 ; 0x04 - 1ff2: 98 13 cpse r25, r24 - 1ff4: 08 95 ret - LEDRedAction = Action; - 1ff6: 60 93 97 28 sts 0x2897, r22 - 1ffa: 08 95 ret -} - -/* TODO: This would be nicer as INLINE */ -void LEDTrigger(LEDFunctionEnum Func, LEDActionEnum Action) { - if (GlobalSettings.ActiveSettingPtr->LEDGreenFunction == Func) { - LEDGreenAction = Action; - 1ffc: 60 93 98 28 sts 0x2898, r22 - 2000: f7 cf rjmp .-18 ; 0x1ff0 - -00002002 : - LEDRedAction = Action; - } -} - -void LEDGetFuncList(char* ListOut, uint16_t BufferSize) -{ - 2002: 0f 93 push r16 - 2004: 1f 93 push r17 - 2006: cf 93 push r28 - 2008: df 93 push r29 - uint8_t i; - - /* Account for '\0' */ - BufferSize--; - 200a: 61 50 subi r22, 0x01 ; 1 - 200c: 71 09 sbc r23, r1 - 200e: 4e ea ldi r20, 0xAE ; 174 - 2010: 55 e0 ldi r21, 0x05 ; 5 - BufferSize--; - } - - if ( i < (LED_FUNC_COUNT - 1) ) { - /* No comma on last configuration */ - *ListOut++ = ','; - 2012: 1c e2 ldi r17, 0x2C ; 44 - - /* Account for '\0' */ - BufferSize--; - - for (i=0; i sizeof(LEDFuncTable[i]) ) { - 2016: fa 01 movw r30, r20 - 2018: 04 91 lpm r16, Z - 201a: 00 23 and r16, r16 - 201c: 49 f1 breq .+82 ; 0x2070 - 201e: 61 32 cpi r22, 0x21 ; 33 - 2020: 71 05 cpc r23, r1 - 2022: 20 f4 brcc .+8 ; 0x202c - 2024: 25 c0 rjmp .+74 ; 0x2070 - 2026: 60 32 cpi r22, 0x20 ; 32 - 2028: 71 05 cpc r23, r1 - 202a: 61 f0 breq .+24 ; 0x2044 - 202c: dc 01 movw r26, r24 - 202e: 01 96 adiw r24, 0x01 ; 1 - 2030: ec 01 movw r28, r24 - /* While not end-of-string and enough buffer to - * put a complete configuration name */ - *ListOut++ = c; - 2032: 0c 93 st X, r16 - FuncName++; - 2034: 2f 5f subi r18, 0xFF ; 255 - 2036: 3f 4f sbci r19, 0xFF ; 255 - BufferSize--; - 2038: 61 50 subi r22, 0x01 ; 1 - 203a: 71 09 sbc r23, r1 - - for (i=0; i sizeof(LEDFuncTable[i]) ) { - 203c: f9 01 movw r30, r18 - 203e: 04 91 lpm r16, Z - 2040: 01 11 cpse r16, r1 - 2042: f1 cf rjmp .-30 ; 0x2026 - *ListOut++ = c; - FuncName++; - BufferSize--; - } - - if ( i < (LED_FUNC_COUNT - 1) ) { - 2044: f6 e0 ldi r31, 0x06 ; 6 - 2046: 4e 38 cpi r20, 0x8E ; 142 - 2048: 5f 07 cpc r21, r31 - 204a: 61 f0 breq .+24 ; 0x2064 - /* No comma on last configuration */ - *ListOut++ = ','; - 204c: ce 01 movw r24, r28 - 204e: 01 96 adiw r24, 0x01 ; 1 - 2050: 18 83 st Y, r17 - BufferSize--; - 2052: 61 50 subi r22, 0x01 ; 1 - 2054: 71 09 sbc r23, r1 - 2056: 40 5e subi r20, 0xE0 ; 224 - 2058: 5f 4f sbci r21, 0xFF ; 255 - uint8_t i; - - /* Account for '\0' */ - BufferSize--; - - for (i=0; i - BufferSize--; - } - - if ( i < (LED_FUNC_COUNT - 1) ) { - /* No comma on last configuration */ - *ListOut++ = ','; - 2062: ec 01 movw r28, r24 - BufferSize--; - } - } - - *ListOut = '\0'; - 2064: 18 82 st Y, r1 -} - 2066: df 91 pop r29 - 2068: cf 91 pop r28 - 206a: 1f 91 pop r17 - 206c: 0f 91 pop r16 - 206e: 08 95 ret - - for (i=0; i sizeof(LEDFuncTable[i]) ) { - 2070: ec 01 movw r28, r24 - 2072: e8 cf rjmp .-48 ; 0x2044 - -00002074 : - - *ListOut = '\0'; -} - -void LEDSetFuncById(uint8_t Mask, LEDFunctionEnum Func) -{ - 2074: 98 2f mov r25, r24 - 2076: 90 71 andi r25, 0x10 ; 16 - 2078: 85 fd sbrc r24, 5 - 207a: 03 c0 rjmp .+6 ; 0x2082 - 207c: 91 11 cpse r25, r1 - 207e: 3f c0 rjmp .+126 ; 0x20fe - 2080: 08 95 ret - } -#else - /* Write LED func to all settings when using global settings */ - for (uint8_t i=0; i - } - - if (Mask & LED_RED) { - GlobalSettings.Settings[i].LEDRedFunction = Func; - 208a: 60 93 10 29 sts 0x2910, r22 - } -#else - /* Write LED func to all settings when using global settings */ - for (uint8_t i=0; i - LED_PORT.OUTCLR = LED_RED; - 20d4: 80 e1 ldi r24, 0x10 ; 16 - 20d6: 80 93 06 06 sts 0x0606, r24 - LEDRedAction = LED_NO_ACTION; - 20da: 10 92 97 28 sts 0x2897, r1 - 20de: 08 95 ret - } -#else - /* Write LED func to all settings when using global settings */ - for (uint8_t i=0; i - } - - if (Mask & LED_RED) { - GlobalSettings.Settings[i].LEDRedFunction = Func; - 20fe: 60 93 10 29 sts 0x2910, r22 - 2102: 60 93 16 29 sts 0x2916, r22 - 2106: 60 93 1c 29 sts 0x291C, r22 - 210a: 60 93 22 29 sts 0x2922, r22 - 210e: 60 93 28 29 sts 0x2928, r22 - 2112: 60 93 2e 29 sts 0x292E, r22 - 2116: 60 93 34 29 sts 0x2934, r22 - 211a: 60 93 3a 29 sts 0x293A, r22 - 211e: d8 cf rjmp .-80 ; 0x20d0 - -00002120 : - } - -} - -void LEDGetFuncByName(uint8_t Mask, char* FuncOut, uint16_t BufferSize) -{ - 2120: fb 01 movw r30, r22 - if (Mask == LED_GREEN) { - 2122: 80 32 cpi r24, 0x20 ; 32 - 2124: 21 f0 breq .+8 ; 0x212e - strncpy_P(FuncOut, LEDFuncTable[GlobalSettings.ActiveSettingPtr->LEDGreenFunction], BufferSize); - } else if (Mask == LED_RED) { - 2126: 80 31 cpi r24, 0x10 ; 16 - 2128: 89 f0 breq .+34 ; 0x214c - strncpy_P(FuncOut, LEDFuncTable[GlobalSettings.ActiveSettingPtr->LEDRedFunction], BufferSize); - } else { - *FuncOut = '\0'; - 212a: 10 82 st Z, r1 - 212c: 08 95 ret -} - -void LEDGetFuncByName(uint8_t Mask, char* FuncOut, uint16_t BufferSize) -{ - if (Mask == LED_GREEN) { - strncpy_P(FuncOut, LEDFuncTable[GlobalSettings.ActiveSettingPtr->LEDGreenFunction], BufferSize); - 212e: a0 91 0a 29 lds r26, 0x290A - 2132: b0 91 0b 29 lds r27, 0x290B - 2136: 15 96 adiw r26, 0x05 ; 5 - 2138: 6c 91 ld r22, X - } else if (Mask == LED_RED) { - strncpy_P(FuncOut, LEDFuncTable[GlobalSettings.ActiveSettingPtr->LEDRedFunction], BufferSize); - 213a: 80 e2 ldi r24, 0x20 ; 32 - 213c: 68 9f mul r22, r24 - 213e: b0 01 movw r22, r0 - 2140: 11 24 eor r1, r1 - 2142: 62 55 subi r22, 0x52 ; 82 - 2144: 7a 4f sbci r23, 0xFA ; 250 - 2146: cf 01 movw r24, r30 - 2148: 0c 94 18 2c jmp 0x5830 ; 0x5830 - 214c: a0 91 0a 29 lds r26, 0x290A - 2150: b0 91 0b 29 lds r27, 0x290B - 2154: 14 96 adiw r26, 0x04 ; 4 - 2156: 6c 91 ld r22, X - 2158: f0 cf rjmp .-32 ; 0x213a - -0000215a : - *FuncOut = '\0'; - } -} - -bool LEDSetFuncByName(uint8_t Mask, const char* FuncName) -{ - 215a: 1f 93 push r17 - 215c: cf 93 push r28 - 215e: df 93 push r29 - 2160: 18 2f mov r17, r24 - 2162: eb 01 movw r28, r22 - uint8_t i; - - for (i=0; i - 216e: 89 2b or r24, r25 - 2170: b1 f1 breq .+108 ; 0x21de - 2172: 6e ec ldi r22, 0xCE ; 206 - 2174: 75 e0 ldi r23, 0x05 ; 5 - 2176: ce 01 movw r24, r28 - 2178: 0e 94 ff 2b call 0x57fe ; 0x57fe - 217c: 89 2b or r24, r25 - 217e: b9 f1 breq .+110 ; 0x21ee - 2180: 6e ee ldi r22, 0xEE ; 238 - 2182: 75 e0 ldi r23, 0x05 ; 5 - 2184: ce 01 movw r24, r28 - 2186: 0e 94 ff 2b call 0x57fe ; 0x57fe - 218a: 89 2b or r24, r25 - 218c: 91 f1 breq .+100 ; 0x21f2 - 218e: 6e e0 ldi r22, 0x0E ; 14 - 2190: 76 e0 ldi r23, 0x06 ; 6 - 2192: ce 01 movw r24, r28 - 2194: 0e 94 ff 2b call 0x57fe ; 0x57fe - 2198: 89 2b or r24, r25 - 219a: 69 f1 breq .+90 ; 0x21f6 - 219c: 6e e2 ldi r22, 0x2E ; 46 - 219e: 76 e0 ldi r23, 0x06 ; 6 - 21a0: ce 01 movw r24, r28 - 21a2: 0e 94 ff 2b call 0x57fe ; 0x57fe - 21a6: 89 2b or r24, r25 - 21a8: 41 f1 breq .+80 ; 0x21fa - 21aa: 6e e4 ldi r22, 0x4E ; 78 - 21ac: 76 e0 ldi r23, 0x06 ; 6 - 21ae: ce 01 movw r24, r28 - 21b0: 0e 94 ff 2b call 0x57fe ; 0x57fe - 21b4: 89 2b or r24, r25 - 21b6: 19 f1 breq .+70 ; 0x21fe - 21b8: 6e e6 ldi r22, 0x6E ; 110 - 21ba: 76 e0 ldi r23, 0x06 ; 6 - 21bc: ce 01 movw r24, r28 - 21be: 0e 94 ff 2b call 0x57fe ; 0x57fe - 21c2: 89 2b or r24, r25 - 21c4: f1 f0 breq .+60 ; 0x2202 - 21c6: 6e e8 ldi r22, 0x8E ; 142 - 21c8: 76 e0 ldi r23, 0x06 ; 6 - 21ca: ce 01 movw r24, r28 - 21cc: 0e 94 ff 2b call 0x57fe ; 0x57fe - 21d0: 89 2b or r24, r25 - 21d2: c9 f0 breq .+50 ; 0x2206 - return true; - } - } - - /* LED Func not found */ - return false; - 21d4: 80 e0 ldi r24, 0x00 ; 0 -} - 21d6: df 91 pop r29 - 21d8: cf 91 pop r28 - 21da: 1f 91 pop r17 - 21dc: 08 95 ret - -bool LEDSetFuncByName(uint8_t Mask, const char* FuncName) -{ - uint8_t i; - - for (i=0; i - return true; - 21e4: 81 e0 ldi r24, 0x01 ; 1 - } - } - - /* LED Func not found */ - return false; -} - 21e6: df 91 pop r29 - 21e8: cf 91 pop r28 - 21ea: 1f 91 pop r17 - 21ec: 08 95 ret - -bool LEDSetFuncByName(uint8_t Mask, const char* FuncName) -{ - uint8_t i; - - for (i=0; i - 21f2: 62 e0 ldi r22, 0x02 ; 2 - 21f4: f5 cf rjmp .-22 ; 0x21e0 - 21f6: 63 e0 ldi r22, 0x03 ; 3 - 21f8: f3 cf rjmp .-26 ; 0x21e0 - 21fa: 64 e0 ldi r22, 0x04 ; 4 - 21fc: f1 cf rjmp .-30 ; 0x21e0 - 21fe: 65 e0 ldi r22, 0x05 ; 5 - 2200: ef cf rjmp .-34 ; 0x21e0 - 2202: 66 e0 ldi r22, 0x06 ; 6 - 2204: ed cf rjmp .-38 ; 0x21e0 - 2206: 67 e0 ldi r22, 0x07 ; 7 - 2208: eb cf rjmp .-42 ; 0x21e0 - -0000220a : -uint8_t TerminalBuffer[TERMINAL_BUFFER_SIZE]; -TerminalStateEnum TerminalState = TERMINAL_UNINITIALIZED; -static uint8_t TerminalInitDelay = INIT_DELAY; - -void TerminalSendString(const char* s) { - CDC_Device_SendString(&TerminalHandle, s); - 220a: bc 01 movw r22, r24 - 220c: 81 e0 ldi r24, 0x01 ; 1 - 220e: 90 e2 ldi r25, 0x20 ; 32 - 2210: 0c 94 a6 29 jmp 0x534c ; 0x534c - -00002214 : -} - -void TerminalSendStringP(const char* s) { - 2214: cf 93 push r28 - 2216: df 93 push r29 - char c; - - while( (c = pgm_read_byte(s++)) != '\0' ) { - 2218: ec 01 movw r28, r24 - 221a: 21 96 adiw r28, 0x01 ; 1 - 221c: fc 01 movw r30, r24 - 221e: 64 91 lpm r22, Z - 2220: 66 23 and r22, r22 - 2222: 49 f0 breq .+18 ; 0x2236 -void EVENT_USB_Device_Connect(void); -void EVENT_USB_Device_Disconnect(void); -void EVENT_USB_Device_ConfigurationChanged(void); -void EVENT_USB_Device_ControlRequest(void); - -INLINE void TerminalSendChar(char c) { CDC_Device_SendByte(&TerminalHandle, c); } - 2224: 81 e0 ldi r24, 0x01 ; 1 - 2226: 90 e2 ldi r25, 0x20 ; 32 - 2228: 0e 94 f5 29 call 0x53ea ; 0x53ea - 222c: fe 01 movw r30, r28 - 222e: 64 91 lpm r22, Z - 2230: 21 96 adiw r28, 0x01 ; 1 - 2232: 61 11 cpse r22, r1 - 2234: f7 cf rjmp .-18 ; 0x2224 - TerminalSendChar(c); - } -} - 2236: df 91 pop r29 - 2238: cf 91 pop r28 - 223a: 08 95 ret - -0000223c : -#endif - - - -void TerminalSendBlock(void* Buffer, uint16_t ByteCount) -{ - 223c: ab 01 movw r20, r22 - CDC_Device_SendData(&TerminalHandle, Buffer, ByteCount); - 223e: bc 01 movw r22, r24 - 2240: 81 e0 ldi r24, 0x01 ; 1 - 2242: 90 e2 ldi r25, 0x20 ; 32 - 2244: 0c 94 cb 29 jmp 0x5396 ; 0x5396 - -00002248 : - } -} - -void TerminalInit(void) -{ - TERMINAL_VBUS_PORT.DIRCLR = TERMINAL_VBUS_MASK; - 2248: 80 e2 ldi r24, 0x20 ; 32 - 224a: e0 e6 ldi r30, 0x60 ; 96 - 224c: f6 e0 ldi r31, 0x06 ; 6 - 224e: 82 83 std Z+2, r24 ; 0x02 - 2250: 08 95 ret - -00002252 : -} - -void TerminalTask(void) -{ - 2252: cf 93 push r28 - 2254: df 93 push r29 - if (TerminalState == TERMINAL_INITIALIZED) { - 2256: 80 91 9a 28 lds r24, 0x289A - 225a: 82 30 cpi r24, 0x02 ; 2 - 225c: 19 f0 breq .+6 ; 0x2264 - CDC_Device_USBTask(&TerminalHandle); - USB_USBTask(); - - ProcessByte(); - } -} - 225e: df 91 pop r29 - 2260: cf 91 pop r28 - 2262: 08 95 ret -} - -void TerminalTask(void) -{ - if (TerminalState == TERMINAL_INITIALIZED) { - CDC_Device_USBTask(&TerminalHandle); - 2264: 81 e0 ldi r24, 0x01 ; 1 - 2266: 90 e2 ldi r25, 0x20 ; 32 - 2268: 0e 94 68 2a call 0x54d0 ; 0x54d0 - USB_USBTask(); - 226c: 0e 94 8b 24 call 0x4916 ; 0x4916 - CDC_Device_SendData(&TerminalHandle, Buffer, ByteCount); -} - - -static void ProcessByte(void) { - int16_t Byte = CDC_Device_ReceiveByte(&TerminalHandle); - 2270: 81 e0 ldi r24, 0x01 ; 1 - 2272: 90 e2 ldi r25, 0x20 ; 32 - 2274: 0e 94 83 2a call 0x5506 ; 0x5506 - 2278: ec 01 movw r28, r24 - - if (Byte >= 0) { - 227a: 97 fd sbrc r25, 7 - 227c: f0 cf rjmp .-32 ; 0x225e - /* Byte received */ - LEDTrigger(LED_TERMINAL_RXTX, LED_PULSE); - 227e: 63 e1 ldi r22, 0x13 ; 19 - 2280: 82 e0 ldi r24, 0x02 ; 2 - 2282: af de rcall .-674 ; 0x1fe2 - - if (XModemProcessByte(Byte)) { - 2284: 8c 2f mov r24, r28 - 2286: 06 d3 rcall .+1548 ; 0x2894 - 2288: 81 11 cpse r24, r1 - 228a: e9 cf rjmp .-46 ; 0x225e - /* XModem handled the byte */ - } else if (CommandLineProcessByte(Byte)) { - 228c: 8c 2f mov r24, r28 - CDC_Device_USBTask(&TerminalHandle); - USB_USBTask(); - - ProcessByte(); - } -} - 228e: df 91 pop r29 - 2290: cf 91 pop r28 - /* Byte received */ - LEDTrigger(LED_TERMINAL_RXTX, LED_PULSE); - - if (XModemProcessByte(Byte)) { - /* XModem handled the byte */ - } else if (CommandLineProcessByte(Byte)) { - 2292: a5 c4 rjmp .+2378 ; 0x2bde - -00002294 : - } -} - -static void SenseVBus(void) -{ - switch(TerminalState) { - 2294: 80 91 9a 28 lds r24, 0x289A - 2298: 81 30 cpi r24, 0x01 ; 1 - 229a: 39 f1 breq .+78 ; 0x22ea - 229c: d8 f0 brcs .+54 ; 0x22d4 - 229e: 82 30 cpi r24, 0x02 ; 2 - 22a0: 51 f0 breq .+20 ; 0x22b6 - 22a2: 83 30 cpi r24, 0x03 ; 3 - 22a4: 99 f4 brne .+38 ; 0x22cc - TerminalState = TERMINAL_UNITIALIZING; - } - break; - - case TERMINAL_UNITIALIZING: - if (--TerminalInitDelay == 0) { - 22a6: 80 91 00 20 lds r24, 0x2000 - 22aa: 81 50 subi r24, 0x01 ; 1 - 22ac: 80 93 00 20 sts 0x2000, r24 - 22b0: 88 23 and r24, r24 - 22b2: 51 f1 breq .+84 ; 0x2308 - 22b4: 08 95 ret - TerminalState = TERMINAL_INITIALIZED; - } - break; - - case TERMINAL_INITIALIZED: - if (!(TERMINAL_VBUS_PORT.IN & TERMINAL_VBUS_MASK)) { - 22b6: 80 91 68 06 lds r24, 0x0668 - 22ba: 85 fd sbrc r24, 5 - 22bc: 09 c0 rjmp .+18 ; 0x22d0 - /* Initialized and VBUS sense low */ - TerminalInitDelay = INIT_DELAY; - 22be: 84 e1 ldi r24, 0x14 ; 20 - 22c0: 80 93 00 20 sts 0x2000, r24 - TerminalState = TERMINAL_UNITIALIZING; - 22c4: 83 e0 ldi r24, 0x03 ; 3 - 22c6: 80 93 9a 28 sts 0x289A, r24 - 22ca: 08 95 ret - -void TerminalTick(void) -{ - SenseVBus(); - - if (TerminalState == TERMINAL_INITIALIZED) { - 22cc: 82 30 cpi r24, 0x02 ; 2 - 22ce: 91 f7 brne .-28 ; 0x22b4 - XModemTick(); - 22d0: 4b d4 rcall .+2198 ; 0x2b68 - CommandLineTick(); - 22d2: 93 c5 rjmp .+2854 ; 0x2dfa - -static void SenseVBus(void) -{ - switch(TerminalState) { - case TERMINAL_UNINITIALIZED: - if (TERMINAL_VBUS_PORT.IN & TERMINAL_VBUS_MASK) { - 22d4: 80 91 68 06 lds r24, 0x0668 - 22d8: 85 ff sbrs r24, 5 - 22da: ec cf rjmp .-40 ; 0x22b4 - /* Not initialized and VBUS sense high */ - TerminalInitDelay = INIT_DELAY; - 22dc: 84 e1 ldi r24, 0x14 ; 20 - 22de: 80 93 00 20 sts 0x2000, r24 - TerminalState = TERMINAL_INITIALIZING; - 22e2: 81 e0 ldi r24, 0x01 ; 1 - 22e4: 80 93 9a 28 sts 0x289A, r24 - 22e8: 08 95 ret - } - break; - - case TERMINAL_INITIALIZING: - if (--TerminalInitDelay == 0) { - 22ea: 80 91 00 20 lds r24, 0x2000 - 22ee: 81 50 subi r24, 0x01 ; 1 - 22f0: 80 93 00 20 sts 0x2000, r24 - 22f4: 81 11 cpse r24, r1 - 22f6: de cf rjmp .-68 ; 0x22b4 - SystemStartUSBClock(); - 22f8: 0e 94 e1 05 call 0xbc2 ; 0xbc2 - USB_Init(); - 22fc: 0e 94 df 28 call 0x51be ; 0x51be - TerminalState = TERMINAL_INITIALIZED; - 2300: 82 e0 ldi r24, 0x02 ; 2 - 2302: 80 93 9a 28 sts 0x289A, r24 - 2306: e4 cf rjmp .-56 ; 0x22d0 - } - break; - - case TERMINAL_UNITIALIZING: - if (--TerminalInitDelay == 0) { - USB_Disable(); - 2308: 0e 94 a4 28 call 0x5148 ; 0x5148 - SystemStopUSBClock(); - 230c: 0e 94 ff 05 call 0xbfe ; 0xbfe - TerminalState = TERMINAL_UNINITIALIZED; - 2310: 10 92 9a 28 sts 0x289A, r1 - 2314: 08 95 ret - -00002316 : -} - -/** Event handler for the library USB Connection event. */ -void EVENT_USB_Device_Connect(void) -{ - LEDTrigger(LED_TERMINAL_CONN, LED_ON); - 2316: 61 e1 ldi r22, 0x11 ; 17 - 2318: 81 e0 ldi r24, 0x01 ; 1 - 231a: 63 ce rjmp .-826 ; 0x1fe2 - -0000231c : -} - -/** Event handler for the library USB Disconnection event. */ -void EVENT_USB_Device_Disconnect(void) -{ - LEDTrigger(LED_TERMINAL_CONN, LED_OFF); - 231c: 60 e1 ldi r22, 0x10 ; 16 - 231e: 81 e0 ldi r24, 0x01 ; 1 - 2320: 60 ce rjmp .-832 ; 0x1fe2 - -00002322 : - - -/** Event handler for the library USB Configuration Changed event. */ -void EVENT_USB_Device_ConfigurationChanged(void) -{ - CDC_Device_ConfigureEndpoints(&TerminalHandle); - 2322: 81 e0 ldi r24, 0x01 ; 1 - 2324: 90 e2 ldi r25, 0x20 ; 32 - 2326: 0c 94 81 29 jmp 0x5302 ; 0x5302 - -0000232a : -} - -/** Event handler for the library USB Control Request reception event. */ -void EVENT_USB_Device_ControlRequest(void) -{ - CDC_Device_ProcessControlRequest(&TerminalHandle); - 232a: 81 e0 ldi r24, 0x01 ; 1 - 232c: 90 e2 ldi r25, 0x20 ; 32 - 232e: 0c 94 e0 2a jmp 0x55c0 ; 0x55c0 - -00002332 : - -extern const PROGMEM CommandEntryType CommandTable[]; - -CommandStatusIdType CommandGetVersion(char* OutParam) -{ - snprintf_P(OutParam, TERMINAL_BUFFER_SIZE, PSTR( - 2332: 21 e3 ldi r18, 0x31 ; 49 - 2334: 37 e0 ldi r19, 0x07 ; 7 - 2336: 3f 93 push r19 - 2338: 2f 93 push r18 - 233a: 2a e2 ldi r18, 0x2A ; 42 - 233c: 37 e0 ldi r19, 0x07 ; 7 - 233e: 3f 93 push r19 - 2340: 2f 93 push r18 - 2342: 23 e2 ldi r18, 0x23 ; 35 - 2344: 37 e0 ldi r19, 0x07 ; 7 - 2346: 3f 93 push r19 - 2348: 2f 93 push r18 - 234a: 2a ee ldi r18, 0xEA ; 234 - 234c: 36 e0 ldi r19, 0x06 ; 6 - 234e: 3f 93 push r19 - 2350: 2f 93 push r18 - 2352: 21 e0 ldi r18, 0x01 ; 1 - 2354: 2f 93 push r18 - 2356: 1f 92 push r1 - 2358: 9f 93 push r25 - 235a: 8f 93 push r24 - 235c: 0e 94 37 2c call 0x586e ; 0x586e - "Chameleon-Mini %S using LUFA %S compiled with AVR-GCC %S" - ), PSTR(CHAMELEON_MINI_VERSION_STRING), PSTR(LUFA_VERSION_STRING), PSTR(__VERSION__) - ); - - return COMMAND_INFO_OK_WITH_TEXT_ID; - 2360: 8d b7 in r24, 0x3d ; 61 - 2362: 9e b7 in r25, 0x3e ; 62 - 2364: 0c 96 adiw r24, 0x0c ; 12 - 2366: 8d bf out 0x3d, r24 ; 61 - 2368: 9e bf out 0x3e, r25 ; 62 -} - 236a: 85 e6 ldi r24, 0x65 ; 101 - 236c: 08 95 ret - -0000236e : - -CommandStatusIdType CommandGetConfig(char* OutParam) -{ - snprintf_P(OutParam, TERMINAL_BUFFER_SIZE, - 236e: 23 ee ldi r18, 0xE3 ; 227 - 2370: 38 e2 ldi r19, 0x28 ; 40 - 2372: 3f 93 push r19 - 2374: 2f 93 push r18 - 2376: 27 ee ldi r18, 0xE7 ; 231 - 2378: 36 e0 ldi r19, 0x06 ; 6 - 237a: 3f 93 push r19 - 237c: 2f 93 push r18 - 237e: 21 e0 ldi r18, 0x01 ; 1 - 2380: 2f 93 push r18 - 2382: 1f 92 push r1 - 2384: 9f 93 push r25 - 2386: 8f 93 push r24 - 2388: 0e 94 37 2c call 0x586e ; 0x586e - PSTR("%s"), ActiveConfiguration.ConfigurationName); - - return COMMAND_INFO_OK_WITH_TEXT_ID; - 238c: 8d b7 in r24, 0x3d ; 61 - 238e: 9e b7 in r25, 0x3e ; 62 - 2390: 08 96 adiw r24, 0x08 ; 8 - 2392: 8d bf out 0x3d, r24 ; 61 - 2394: 9e bf out 0x3e, r25 ; 62 - -} - 2396: 85 e6 ldi r24, 0x65 ; 101 - 2398: 08 95 ret - -0000239a : - -CommandStatusIdType CommandSetConfig(const char* InParam) -{ - if (ConfigurationSetByName(InParam)) { - 239a: 0e 94 43 06 call 0xc86 ; 0xc86 - 239e: 81 11 cpse r24, r1 - 23a0: 02 c0 rjmp .+4 ; 0x23a6 - SettingsSave(); - return COMMAND_INFO_OK_ID; - } else { - return COMMAND_ERR_INVALID_PARAM_ID; - 23a2: 8a ec ldi r24, 0xCA ; 202 - } -} - 23a4: 08 95 ret -} - -CommandStatusIdType CommandSetConfig(const char* InParam) -{ - if (ConfigurationSetByName(InParam)) { - SettingsSave(); - 23a6: bd dc rcall .-1670 ; 0x1d22 - return COMMAND_INFO_OK_ID; - 23a8: 84 e6 ldi r24, 0x64 ; 100 - 23aa: 08 95 ret - -000023ac : - } -} - -CommandStatusIdType CommandExecConfig(char* OutMessage) -{ - ConfigurationGetList(OutMessage, TERMINAL_BUFFER_SIZE); - 23ac: 60 e0 ldi r22, 0x00 ; 0 - 23ae: 71 e0 ldi r23, 0x01 ; 1 - 23b0: 0e 94 80 06 call 0xd00 ; 0xd00 - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 23b4: 85 e6 ldi r24, 0x65 ; 101 - 23b6: 08 95 ret - -000023b8 : - -CommandStatusIdType CommandGetUid(char* OutParam) -{ - 23b8: ef 92 push r14 - 23ba: ff 92 push r15 - 23bc: 0f 93 push r16 - 23be: 1f 93 push r17 - 23c0: cf 93 push r28 - 23c2: df 93 push r29 - 23c4: cd b7 in r28, 0x3d ; 61 - 23c6: de b7 in r29, 0x3e ; 62 - 23c8: a0 97 sbiw r28, 0x20 ; 32 - 23ca: cd bf out 0x3d, r28 ; 61 - 23cc: de bf out 0x3e, r29 ; 62 - 23ce: 8c 01 movw r16, r24 - uint8_t UidBuffer[COMMAND_UID_BUFSIZE]; - uint16_t UidSize = ActiveConfiguration.UidSize; - 23d0: e0 90 05 29 lds r14, 0x2905 - 23d4: f1 2c mov r15, r1 - ActiveConfiguration.ApplicationResetFunc(); - //LogEntry(LOG_INFO_APP_RESET, NULL, 0); -} - -INLINE void ApplicationGetUid(ConfigurationUidType Uid) { - ActiveConfiguration.ApplicationGetUidFunc(Uid); - 23d6: e0 91 ff 28 lds r30, 0x28FF - 23da: f0 91 00 29 lds r31, 0x2900 - 23de: ce 01 movw r24, r28 - 23e0: 01 96 adiw r24, 0x01 ; 1 - 23e2: 09 95 icall - - ApplicationGetUid(UidBuffer); - - BufferToHexString(OutParam, TERMINAL_BUFFER_SIZE, - 23e4: 97 01 movw r18, r14 - 23e6: ae 01 movw r20, r28 - 23e8: 4f 5f subi r20, 0xFF ; 255 - 23ea: 5f 4f sbci r21, 0xFF ; 255 - 23ec: 60 e0 ldi r22, 0x00 ; 0 - 23ee: 71 e0 ldi r23, 0x01 ; 1 - 23f0: c8 01 movw r24, r16 - 23f2: 0e 94 d5 06 call 0xdaa ; 0xdaa - UidBuffer, UidSize); - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 23f6: 85 e6 ldi r24, 0x65 ; 101 - 23f8: a0 96 adiw r28, 0x20 ; 32 - 23fa: cd bf out 0x3d, r28 ; 61 - 23fc: de bf out 0x3e, r29 ; 62 - 23fe: df 91 pop r29 - 2400: cf 91 pop r28 - 2402: 1f 91 pop r17 - 2404: 0f 91 pop r16 - 2406: ff 90 pop r15 - 2408: ef 90 pop r14 - 240a: 08 95 ret - -0000240c : - -CommandStatusIdType CommandSetUid(const char* InParam) -{ - 240c: bf 92 push r11 - 240e: cf 92 push r12 - 2410: df 92 push r13 - 2412: ef 92 push r14 - 2414: ff 92 push r15 - 2416: 0f 93 push r16 - 2418: 1f 93 push r17 - 241a: cf 93 push r28 - 241c: df 93 push r29 - 241e: cd b7 in r28, 0x3d ; 61 - 2420: de b7 in r29, 0x3e ; 62 - 2422: a0 97 sbiw r28, 0x20 ; 32 - 2424: cd bf out 0x3d, r28 ; 61 - 2426: de bf out 0x3e, r29 ; 62 - 2428: 8c 01 movw r16, r24 - uint8_t UidBuffer[COMMAND_UID_BUFSIZE]; - uint16_t UidSize = ActiveConfiguration.UidSize; - 242a: c0 90 05 29 lds r12, 0x2905 - 242e: d1 2c mov r13, r1 - - if (strcmp_P(InParam, PSTR(COMMAND_UID_RANDOM)) == 0) { - 2430: 60 ee ldi r22, 0xE0 ; 224 - 2432: 76 e0 ldi r23, 0x06 ; 6 - 2434: 0e 94 ff 2b call 0x57fe ; 0x57fe - 2438: 89 2b or r24, r25 - 243a: 49 f5 brne .+82 ; 0x248e - /* Load with random bytes */ - for (uint8_t i=0; i - 2442: b1 2c mov r11, r1 - 2444: ce 01 movw r24, r28 - 2446: 01 96 adiw r24, 0x01 ; 1 - 2448: 7c 01 movw r14, r24 - 244a: 00 e0 ldi r16, 0x00 ; 0 - 244c: 10 e0 ldi r17, 0x00 ; 0 - UidBuffer[i] = RandomGetByte(); - 244e: 0e 94 ba 06 call 0xd74 ; 0xd74 - 2452: f7 01 movw r30, r14 - 2454: e0 0f add r30, r16 - 2456: f1 1f adc r31, r17 - 2458: 80 83 st Z, r24 - uint8_t UidBuffer[COMMAND_UID_BUFSIZE]; - uint16_t UidSize = ActiveConfiguration.UidSize; - - if (strcmp_P(InParam, PSTR(COMMAND_UID_RANDOM)) == 0) { - /* Load with random bytes */ - for (uint8_t i=0; i -} - -INLINE void ApplicationSetUid(ConfigurationUidType Uid) { - ActiveConfiguration.ApplicationSetUidFunc(Uid); - 2466: e0 91 01 29 lds r30, 0x2901 - 246a: f0 91 02 29 lds r31, 0x2902 - 246e: c7 01 movw r24, r14 - 2470: 09 95 icall - } - } - - ApplicationSetUid(UidBuffer); - - return COMMAND_INFO_OK_ID; - 2472: 84 e6 ldi r24, 0x64 ; 100 -} - 2474: a0 96 adiw r28, 0x20 ; 32 - 2476: cd bf out 0x3d, r28 ; 61 - 2478: de bf out 0x3e, r29 ; 62 - 247a: df 91 pop r29 - 247c: cf 91 pop r28 - 247e: 1f 91 pop r17 - 2480: 0f 91 pop r16 - 2482: ff 90 pop r15 - 2484: ef 90 pop r14 - 2486: df 90 pop r13 - 2488: cf 90 pop r12 - 248a: bf 90 pop r11 - 248c: 08 95 ret - for (uint8_t i=0; i - 249e: 8c 15 cp r24, r12 - 24a0: 9d 05 cpc r25, r13 - 24a2: 09 f3 breq .-62 ; 0x2466 - /* Malformed input. Abort */ - return COMMAND_ERR_INVALID_PARAM_ID; - 24a4: 8a ec ldi r24, 0xCA ; 202 - 24a6: e6 cf rjmp .-52 ; 0x2474 - 24a8: ce 01 movw r24, r28 - 24aa: 01 96 adiw r24, 0x01 ; 1 - 24ac: 7c 01 movw r14, r24 - 24ae: db cf rjmp .-74 ; 0x2466 - -000024b0 : - return COMMAND_INFO_OK_ID; -} - -CommandStatusIdType CommandGetReadOnly(char* OutParam) -{ - if (ActiveConfiguration.ReadOnly) { - 24b0: 20 91 06 29 lds r18, 0x2906 - 24b4: 21 11 cpse r18, r1 - 24b6: 07 c0 rjmp .+14 ; 0x24c6 - OutParam[0] = COMMAND_CHAR_TRUE; - } else { - OutParam[0] = COMMAND_CHAR_FALSE; - 24b8: 20 e3 ldi r18, 0x30 ; 48 - 24ba: fc 01 movw r30, r24 - 24bc: 20 83 st Z, r18 - } - - OutParam[1] = '\0'; - 24be: fc 01 movw r30, r24 - 24c0: 11 82 std Z+1, r1 ; 0x01 - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 24c2: 85 e6 ldi r24, 0x65 ; 101 - 24c4: 08 95 ret -} - -CommandStatusIdType CommandGetReadOnly(char* OutParam) -{ - if (ActiveConfiguration.ReadOnly) { - OutParam[0] = COMMAND_CHAR_TRUE; - 24c6: 21 e3 ldi r18, 0x31 ; 49 - 24c8: fc 01 movw r30, r24 - 24ca: 20 83 st Z, r18 - } else { - OutParam[0] = COMMAND_CHAR_FALSE; - } - - OutParam[1] = '\0'; - 24cc: fc 01 movw r30, r24 - 24ce: 11 82 std Z+1, r1 ; 0x01 - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 24d0: 85 e6 ldi r24, 0x65 ; 101 - 24d2: 08 95 ret - -000024d4 : - -CommandStatusIdType CommandSetReadOnly(const char* InParam) -{ - if (InParam[1] == '\0') { - 24d4: fc 01 movw r30, r24 - 24d6: 21 81 ldd r18, Z+1 ; 0x01 - 24d8: 21 11 cpse r18, r1 - 24da: 05 c0 rjmp .+10 ; 0x24e6 - if (InParam[0] == COMMAND_CHAR_TRUE) { - 24dc: 80 81 ld r24, Z - 24de: 81 33 cpi r24, 0x31 ; 49 - 24e0: 41 f0 breq .+16 ; 0x24f2 - ActiveConfiguration.ReadOnly = true; - return COMMAND_INFO_OK_ID; - } else if (InParam[0] == COMMAND_CHAR_FALSE) { - 24e2: 80 33 cpi r24, 0x30 ; 48 - 24e4: 11 f0 breq .+4 ; 0x24ea - ActiveConfiguration.ReadOnly = false; - return COMMAND_INFO_OK_ID; - } - } - - return COMMAND_ERR_INVALID_PARAM_ID; - 24e6: 8a ec ldi r24, 0xCA ; 202 -} - 24e8: 08 95 ret - if (InParam[1] == '\0') { - if (InParam[0] == COMMAND_CHAR_TRUE) { - ActiveConfiguration.ReadOnly = true; - return COMMAND_INFO_OK_ID; - } else if (InParam[0] == COMMAND_CHAR_FALSE) { - ActiveConfiguration.ReadOnly = false; - 24ea: 10 92 06 29 sts 0x2906, r1 - return COMMAND_INFO_OK_ID; - 24ee: 84 e6 ldi r24, 0x64 ; 100 - 24f0: 08 95 ret - -CommandStatusIdType CommandSetReadOnly(const char* InParam) -{ - if (InParam[1] == '\0') { - if (InParam[0] == COMMAND_CHAR_TRUE) { - ActiveConfiguration.ReadOnly = true; - 24f2: 81 e0 ldi r24, 0x01 ; 1 - 24f4: 80 93 06 29 sts 0x2906, r24 - return COMMAND_INFO_OK_ID; - 24f8: 84 e6 ldi r24, 0x64 ; 100 - 24fa: 08 95 ret - -000024fc : - return COMMAND_ERR_INVALID_PARAM_ID; -} - -CommandStatusIdType CommandExecUpload(char* OutMessage) -{ - XModemReceive(MemoryUploadBlock); - 24fc: 86 ed ldi r24, 0xD6 ; 214 - 24fe: 99 e0 ldi r25, 0x09 ; 9 - 2500: 98 d1 rcall .+816 ; 0x2832 - return COMMAND_INFO_XMODEM_WAIT_ID; -} - 2502: 8e e6 ldi r24, 0x6E ; 110 - 2504: 08 95 ret - -00002506 : - -CommandStatusIdType CommandExecDownload(char* OutMessage) -{ - XModemSend(MemoryDownloadBlock); - 2506: 81 e7 ldi r24, 0x71 ; 113 - 2508: 9b e0 ldi r25, 0x0B ; 11 - 250a: ae d1 rcall .+860 ; 0x2868 - return COMMAND_INFO_XMODEM_WAIT_ID; -} - 250c: 8e e6 ldi r24, 0x6E ; 110 - 250e: 08 95 ret - -00002510 : - * enumerating the device once attached until \ref USB_Attach() is called. - */ - static inline void USB_Detach(void) ATTR_ALWAYS_INLINE; - static inline void USB_Detach(void) - { - USB.CTRLB &= ~USB_ATTACH_bm; - 2510: e0 ec ldi r30, 0xC0 ; 192 - 2512: f4 e0 ldi r31, 0x04 ; 4 - 2514: 81 81 ldd r24, Z+1 ; 0x01 - 2516: 8e 7f andi r24, 0xFE ; 254 - 2518: 81 83 std Z+1, r24 ; 0x01 - -CommandStatusIdType CommandExecReset(char* OutMessage) -{ - USB_Detach(); - USB_Disable(); - 251a: 0e 94 a4 28 call 0x5148 ; 0x5148 - - SystemReset(); - 251e: 0e 94 d4 05 call 0xba8 ; 0xba8 - - return COMMAND_INFO_OK_ID; -} - 2522: 84 e6 ldi r24, 0x64 ; 100 - 2524: 08 95 ret - -00002526 : - 2526: e0 ec ldi r30, 0xC0 ; 192 - 2528: f4 e0 ldi r31, 0x04 ; 4 - 252a: 81 81 ldd r24, Z+1 ; 0x01 - 252c: 8e 7f andi r24, 0xFE ; 254 - 252e: 81 83 std Z+1, r24 ; 0x01 - -#ifdef SUPPORT_FIRMWARE_UPGRADE -CommandStatusIdType CommandExecUpgrade(char* OutMessage) -{ - USB_Detach(); - USB_Disable(); - 2530: 0e 94 a4 28 call 0x5148 ; 0x5148 - - SystemEnterBootloader(); - 2534: 0e 94 db 05 call 0xbb6 ; 0xbb6 - - return COMMAND_INFO_OK_ID; -} - 2538: 84 e6 ldi r24, 0x64 ; 100 - 253a: 08 95 ret - -0000253c : -#endif - -CommandStatusIdType CommandGetMemSize(char* OutParam) -{ - snprintf_P(OutParam, TERMINAL_BUFFER_SIZE, PSTR("%u"), ActiveConfiguration.MemorySize); - 253c: e3 e0 ldi r30, 0x03 ; 3 - 253e: f9 e2 ldi r31, 0x29 ; 41 - 2540: 21 81 ldd r18, Z+1 ; 0x01 - 2542: 2f 93 push r18 - 2544: 20 81 ld r18, Z - 2546: 2f 93 push r18 - 2548: 2d ed ldi r18, 0xDD ; 221 - 254a: 36 e0 ldi r19, 0x06 ; 6 - 254c: 3f 93 push r19 - 254e: 2f 93 push r18 - 2550: 21 e0 ldi r18, 0x01 ; 1 - 2552: 2f 93 push r18 - 2554: 1f 92 push r1 - 2556: 9f 93 push r25 - 2558: 8f 93 push r24 - 255a: 0e 94 37 2c call 0x586e ; 0x586e - - return COMMAND_INFO_OK_WITH_TEXT_ID; - 255e: 8d b7 in r24, 0x3d ; 61 - 2560: 9e b7 in r25, 0x3e ; 62 - 2562: 08 96 adiw r24, 0x08 ; 8 - 2564: 8d bf out 0x3d, r24 ; 61 - 2566: 9e bf out 0x3e, r25 ; 62 -} - 2568: 85 e6 ldi r24, 0x65 ; 101 - 256a: 08 95 ret - -0000256c : - -CommandStatusIdType CommandGetUidSize(char* OutParam) -{ - snprintf_P(OutParam, TERMINAL_BUFFER_SIZE, PSTR("%u"), ActiveConfiguration.UidSize); - 256c: 20 91 05 29 lds r18, 0x2905 - 2570: 1f 92 push r1 - 2572: 2f 93 push r18 - 2574: 2a ed ldi r18, 0xDA ; 218 - 2576: 36 e0 ldi r19, 0x06 ; 6 - 2578: 3f 93 push r19 - 257a: 2f 93 push r18 - 257c: 21 e0 ldi r18, 0x01 ; 1 - 257e: 2f 93 push r18 - 2580: 1f 92 push r1 - 2582: 9f 93 push r25 - 2584: 8f 93 push r24 - 2586: 0e 94 37 2c call 0x586e ; 0x586e - - return COMMAND_INFO_OK_WITH_TEXT_ID; - 258a: 8d b7 in r24, 0x3d ; 61 - 258c: 9e b7 in r25, 0x3e ; 62 - 258e: 08 96 adiw r24, 0x08 ; 8 - 2590: 8d bf out 0x3d, r24 ; 61 - 2592: 9e bf out 0x3e, r25 ; 62 -} - 2594: 85 e6 ldi r24, 0x65 ; 101 - 2596: 08 95 ret - -00002598 : - -CommandStatusIdType CommandExecButton(char* OutMessage) -{ - ButtonGetActionList(OutMessage, TERMINAL_BUFFER_SIZE); - 2598: 60 e0 ldi r22, 0x00 ; 0 - 259a: 71 e0 ldi r23, 0x01 ; 1 - 259c: d8 d9 rcall .-3152 ; 0x194e - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 259e: 85 e6 ldi r24, 0x65 ; 101 - 25a0: 08 95 ret - -000025a2 : - -CommandStatusIdType CommandGetButton(char* OutParam) -{ - ButtonGetActionByName(BUTTON_PRESS_SHORT, OutParam, TERMINAL_BUFFER_SIZE); - 25a2: 40 e0 ldi r20, 0x00 ; 0 - 25a4: 51 e0 ldi r21, 0x01 ; 1 - 25a6: bc 01 movw r22, r24 - 25a8: 80 e0 ldi r24, 0x00 ; 0 - 25aa: 31 da rcall .-2974 ; 0x1a0e - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 25ac: 85 e6 ldi r24, 0x65 ; 101 - 25ae: 08 95 ret - -000025b0 : - -CommandStatusIdType CommandSetButton(const char* InParam) -{ - if (ButtonSetActionByName(BUTTON_PRESS_SHORT, InParam)) { - 25b0: bc 01 movw r22, r24 - 25b2: 80 e0 ldi r24, 0x00 ; 0 - 25b4: 48 da rcall .-2928 ; 0x1a46 - 25b6: 81 11 cpse r24, r1 - 25b8: 02 c0 rjmp .+4 ; 0x25be - SettingsSave(); - return COMMAND_INFO_OK_ID; - } else { - return COMMAND_ERR_INVALID_PARAM_ID; - 25ba: 8a ec ldi r24, 0xCA ; 202 - } -} - 25bc: 08 95 ret -} - -CommandStatusIdType CommandSetButton(const char* InParam) -{ - if (ButtonSetActionByName(BUTTON_PRESS_SHORT, InParam)) { - SettingsSave(); - 25be: b1 db rcall .-2206 ; 0x1d22 - return COMMAND_INFO_OK_ID; - 25c0: 84 e6 ldi r24, 0x64 ; 100 - 25c2: 08 95 ret - -000025c4 : - } -} - -CommandStatusIdType CommandExecButtonLong(char* OutMessage) -{ - ButtonGetActionList(OutMessage, TERMINAL_BUFFER_SIZE); - 25c4: 60 e0 ldi r22, 0x00 ; 0 - 25c6: 71 e0 ldi r23, 0x01 ; 1 - 25c8: c2 d9 rcall .-3196 ; 0x194e - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 25ca: 85 e6 ldi r24, 0x65 ; 101 - 25cc: 08 95 ret - -000025ce : - -CommandStatusIdType CommandGetButtonLong(char* OutParam) -{ - ButtonGetActionByName(BUTTON_PRESS_LONG, OutParam, TERMINAL_BUFFER_SIZE); - 25ce: 40 e0 ldi r20, 0x00 ; 0 - 25d0: 51 e0 ldi r21, 0x01 ; 1 - 25d2: bc 01 movw r22, r24 - 25d4: 81 e0 ldi r24, 0x01 ; 1 - 25d6: 1b da rcall .-3018 ; 0x1a0e - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 25d8: 85 e6 ldi r24, 0x65 ; 101 - 25da: 08 95 ret - -000025dc : - -CommandStatusIdType CommandSetButtonLong(const char* InParam) -{ - if (ButtonSetActionByName(BUTTON_PRESS_LONG, InParam)) { - 25dc: bc 01 movw r22, r24 - 25de: 81 e0 ldi r24, 0x01 ; 1 - 25e0: 32 da rcall .-2972 ; 0x1a46 - 25e2: 81 11 cpse r24, r1 - 25e4: 02 c0 rjmp .+4 ; 0x25ea - SettingsSave(); - return COMMAND_INFO_OK_ID; - } else { - return COMMAND_ERR_INVALID_PARAM_ID; - 25e6: 8a ec ldi r24, 0xCA ; 202 - } -} - 25e8: 08 95 ret -} - -CommandStatusIdType CommandSetButtonLong(const char* InParam) -{ - if (ButtonSetActionByName(BUTTON_PRESS_LONG, InParam)) { - SettingsSave(); - 25ea: 9b db rcall .-2250 ; 0x1d22 - return COMMAND_INFO_OK_ID; - 25ec: 84 e6 ldi r24, 0x64 ; 100 - 25ee: 08 95 ret - -000025f0 : - } -} - -CommandStatusIdType CommandExecLedGreen(char* OutMessage) -{ - LEDGetFuncList(OutMessage, TERMINAL_BUFFER_SIZE); - 25f0: 60 e0 ldi r22, 0x00 ; 0 - 25f2: 71 e0 ldi r23, 0x01 ; 1 - 25f4: 06 dd rcall .-1524 ; 0x2002 - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 25f6: 85 e6 ldi r24, 0x65 ; 101 - 25f8: 08 95 ret - -000025fa : - -CommandStatusIdType CommandGetLedGreen(char* OutParam) -{ - LEDGetFuncByName(LED_GREEN, OutParam, TERMINAL_BUFFER_SIZE); - 25fa: 40 e0 ldi r20, 0x00 ; 0 - 25fc: 51 e0 ldi r21, 0x01 ; 1 - 25fe: bc 01 movw r22, r24 - 2600: 80 e2 ldi r24, 0x20 ; 32 - 2602: 8e dd rcall .-1252 ; 0x2120 - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 2604: 85 e6 ldi r24, 0x65 ; 101 - 2606: 08 95 ret - -00002608 : - -CommandStatusIdType CommandSetLedGreen(const char* InParam) -{ - if (LEDSetFuncByName(LED_GREEN, InParam)) { - 2608: bc 01 movw r22, r24 - 260a: 80 e2 ldi r24, 0x20 ; 32 - 260c: a6 dd rcall .-1204 ; 0x215a - 260e: 81 11 cpse r24, r1 - 2610: 02 c0 rjmp .+4 ; 0x2616 - SettingsSave(); - return COMMAND_INFO_OK_ID; - } else { - return COMMAND_ERR_INVALID_PARAM_ID; - 2612: 8a ec ldi r24, 0xCA ; 202 - } -} - 2614: 08 95 ret -} - -CommandStatusIdType CommandSetLedGreen(const char* InParam) -{ - if (LEDSetFuncByName(LED_GREEN, InParam)) { - SettingsSave(); - 2616: 85 db rcall .-2294 ; 0x1d22 - return COMMAND_INFO_OK_ID; - 2618: 84 e6 ldi r24, 0x64 ; 100 - 261a: 08 95 ret - -0000261c : - } -} - -CommandStatusIdType CommandExecLedRed(char* OutMessage) -{ - LEDGetFuncList(OutMessage, TERMINAL_BUFFER_SIZE); - 261c: 60 e0 ldi r22, 0x00 ; 0 - 261e: 71 e0 ldi r23, 0x01 ; 1 - 2620: f0 dc rcall .-1568 ; 0x2002 - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 2622: 85 e6 ldi r24, 0x65 ; 101 - 2624: 08 95 ret - -00002626 : - -CommandStatusIdType CommandGetLedRed(char* OutParam) -{ - LEDGetFuncByName(LED_RED, OutParam, TERMINAL_BUFFER_SIZE); - 2626: 40 e0 ldi r20, 0x00 ; 0 - 2628: 51 e0 ldi r21, 0x01 ; 1 - 262a: bc 01 movw r22, r24 - 262c: 80 e1 ldi r24, 0x10 ; 16 - 262e: 78 dd rcall .-1296 ; 0x2120 - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 2630: 85 e6 ldi r24, 0x65 ; 101 - 2632: 08 95 ret - -00002634 : - -CommandStatusIdType CommandSetLedRed(const char* InParam) -{ - if (LEDSetFuncByName(LED_RED, InParam)) { - 2634: bc 01 movw r22, r24 - 2636: 80 e1 ldi r24, 0x10 ; 16 - 2638: 90 dd rcall .-1248 ; 0x215a - 263a: 81 11 cpse r24, r1 - 263c: 02 c0 rjmp .+4 ; 0x2642 - SettingsSave(); - return COMMAND_INFO_OK_ID; - } else { - return COMMAND_ERR_INVALID_PARAM_ID; - 263e: 8a ec ldi r24, 0xCA ; 202 - } -} - 2640: 08 95 ret -} - -CommandStatusIdType CommandSetLedRed(const char* InParam) -{ - if (LEDSetFuncByName(LED_RED, InParam)) { - SettingsSave(); - 2642: 6f db rcall .-2338 ; 0x1d22 - return COMMAND_INFO_OK_ID; - 2644: 84 e6 ldi r24, 0x64 ; 100 - 2646: 08 95 ret - -00002648 : -} - -CommandStatusIdType CommandExecLogMode(char* OutMessage) -{ - /* Get list of log modes */ - LogGetModeList(OutMessage, TERMINAL_BUFFER_SIZE); - 2648: 60 e0 ldi r22, 0x00 ; 0 - 264a: 71 e0 ldi r23, 0x01 ; 1 - 264c: 3a db rcall .-2444 ; 0x1cc2 - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 264e: 85 e6 ldi r24, 0x65 ; 101 - 2650: 08 95 ret - -00002652 : - -CommandStatusIdType CommandGetLogMode(char* OutParam) -{ - /* Get Logmode */ - LogGetModeByName(OutParam, TERMINAL_BUFFER_SIZE); - 2652: 60 e0 ldi r22, 0x00 ; 0 - 2654: 71 e0 ldi r23, 0x01 ; 1 - 2656: 27 db rcall .-2482 ; 0x1ca6 - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 2658: 85 e6 ldi r24, 0x65 ; 101 - 265a: 08 95 ret - -0000265c : - -CommandStatusIdType CommandSetLogMode(const char* InParam) -{ - if (LogSetModeByName(InParam)) { - 265c: ff da rcall .-2562 ; 0x1c5c - 265e: 81 11 cpse r24, r1 - 2660: 02 c0 rjmp .+4 ; 0x2666 - SettingsSave(); - return COMMAND_INFO_OK_ID; - } else { - return COMMAND_ERR_INVALID_PARAM_ID; - 2662: 8a ec ldi r24, 0xCA ; 202 - } -} - 2664: 08 95 ret -} - -CommandStatusIdType CommandSetLogMode(const char* InParam) -{ - if (LogSetModeByName(InParam)) { - SettingsSave(); - 2666: 5d db rcall .-2374 ; 0x1d22 - return COMMAND_INFO_OK_ID; - 2668: 84 e6 ldi r24, 0x64 ; 100 - 266a: 08 95 ret - -0000266c : - } -} - -CommandStatusIdType CommandExecLogMem(char* OutMessage) -{ - snprintf_P(OutMessage, TERMINAL_BUFFER_SIZE, - 266c: 24 ed ldi r18, 0xD4 ; 212 - 266e: 36 e0 ldi r19, 0x06 ; 6 - 2670: 3f 93 push r19 - 2672: 2f 93 push r18 - 2674: 2c ec ldi r18, 0xCC ; 204 - 2676: 36 e0 ldi r19, 0x06 ; 6 - 2678: 3f 93 push r19 - 267a: 2f 93 push r18 - 267c: 26 ec ldi r18, 0xC6 ; 198 - 267e: 36 e0 ldi r19, 0x06 ; 6 - 2680: 3f 93 push r19 - 2682: 2f 93 push r18 - 2684: 21 e0 ldi r18, 0x01 ; 1 - 2686: 2f 93 push r18 - 2688: 1f 92 push r1 - 268a: 9f 93 push r25 - 268c: 8f 93 push r24 - 268e: 0e 94 37 2c call 0x586e ; 0x586e - PSTR("%S,%S"), PSTR(COMMAND_LOGMEM_LOADBIN), PSTR(COMMAND_LOGMEM_CLEAR) ); - - return COMMAND_INFO_OK_WITH_TEXT_ID; - 2692: 8d b7 in r24, 0x3d ; 61 - 2694: 9e b7 in r25, 0x3e ; 62 - 2696: 0a 96 adiw r24, 0x0a ; 10 - 2698: 8d bf out 0x3d, r24 ; 61 - 269a: 9e bf out 0x3e, r25 ; 62 -} - 269c: 85 e6 ldi r24, 0x65 ; 101 - 269e: 08 95 ret - -000026a0 : - -CommandStatusIdType CommandGetLogMem(char* OutParam) -{ - 26a0: cf 93 push r28 - 26a2: df 93 push r29 - 26a4: ec 01 movw r28, r24 - snprintf_P(OutParam, TERMINAL_BUFFER_SIZE, - 26a6: 77 da rcall .-2834 ; 0x1b96 - 26a8: 9f 93 push r25 - 26aa: 8f 93 push r24 - 26ac: 23 ec ldi r18, 0xC3 ; 195 - 26ae: 36 e0 ldi r19, 0x06 ; 6 - 26b0: 3f 93 push r19 - 26b2: 2f 93 push r18 - 26b4: 81 e0 ldi r24, 0x01 ; 1 - 26b6: 8f 93 push r24 - 26b8: 1f 92 push r1 - 26ba: df 93 push r29 - 26bc: cf 93 push r28 - 26be: 0e 94 37 2c call 0x586e ; 0x586e - PSTR("%u"), LogMemFree()); - - - return COMMAND_INFO_OK_WITH_TEXT_ID; - 26c2: 8d b7 in r24, 0x3d ; 61 - 26c4: 9e b7 in r25, 0x3e ; 62 - 26c6: 08 96 adiw r24, 0x08 ; 8 - 26c8: 8d bf out 0x3d, r24 ; 61 - 26ca: 9e bf out 0x3e, r25 ; 62 -} - 26cc: 85 e6 ldi r24, 0x65 ; 101 - 26ce: df 91 pop r29 - 26d0: cf 91 pop r28 - 26d2: 08 95 ret - -000026d4 : - -CommandStatusIdType CommandSetLogMem(const char* InParam) -{ - 26d4: cf 93 push r28 - 26d6: df 93 push r29 - 26d8: ec 01 movw r28, r24 - if (strcmp_P(InParam, PSTR(COMMAND_LOGMEM_LOADBIN)) == 0) { - 26da: 6b eb ldi r22, 0xBB ; 187 - 26dc: 76 e0 ldi r23, 0x06 ; 6 - 26de: 0e 94 ff 2b call 0x57fe ; 0x57fe - 26e2: 89 2b or r24, r25 - 26e4: 81 f0 breq .+32 ; 0x2706 - XModemSend(LogMemLoadBlock); - return COMMAND_INFO_XMODEM_WAIT_ID; - } else if (strcmp_P(InParam, PSTR(COMMAND_LOGMEM_CLEAR)) == 0) { - 26e6: 65 eb ldi r22, 0xB5 ; 181 - 26e8: 76 e0 ldi r23, 0x06 ; 6 - 26ea: ce 01 movw r24, r28 - 26ec: 0e 94 ff 2b call 0x57fe ; 0x57fe - 26f0: 89 2b or r24, r25 - 26f2: 21 f0 breq .+8 ; 0x26fc - LogMemClear(); - return COMMAND_INFO_OK_ID; - } else { - return COMMAND_ERR_INVALID_PARAM_ID; - 26f4: 8a ec ldi r24, 0xCA ; 202 - } -} - 26f6: df 91 pop r29 - 26f8: cf 91 pop r28 - 26fa: 08 95 ret -{ - if (strcmp_P(InParam, PSTR(COMMAND_LOGMEM_LOADBIN)) == 0) { - XModemSend(LogMemLoadBlock); - return COMMAND_INFO_XMODEM_WAIT_ID; - } else if (strcmp_P(InParam, PSTR(COMMAND_LOGMEM_CLEAR)) == 0) { - LogMemClear(); - 26fc: 37 da rcall .-2962 ; 0x1b6c - return COMMAND_INFO_OK_ID; - 26fe: 84 e6 ldi r24, 0x64 ; 100 - } else { - return COMMAND_ERR_INVALID_PARAM_ID; - } -} - 2700: df 91 pop r29 - 2702: cf 91 pop r28 - 2704: 08 95 ret -} - -CommandStatusIdType CommandSetLogMem(const char* InParam) -{ - if (strcmp_P(InParam, PSTR(COMMAND_LOGMEM_LOADBIN)) == 0) { - XModemSend(LogMemLoadBlock); - 2706: 8e e9 ldi r24, 0x9E ; 158 - 2708: 9d e0 ldi r25, 0x0D ; 13 - 270a: ae d0 rcall .+348 ; 0x2868 - return COMMAND_INFO_XMODEM_WAIT_ID; - 270c: 8e e6 ldi r24, 0x6E ; 110 - LogMemClear(); - return COMMAND_INFO_OK_ID; - } else { - return COMMAND_ERR_INVALID_PARAM_ID; - } -} - 270e: df 91 pop r29 - 2710: cf 91 pop r28 - 2712: 08 95 ret - -00002714 : - -CommandStatusIdType CommandGetSetting(char* OutParam) -{ - SettingsGetActiveByName(OutParam, TERMINAL_BUFFER_SIZE); - 2714: 60 e0 ldi r22, 0x00 ; 0 - 2716: 71 e0 ldi r23, 0x01 ; 1 - 2718: ce db rcall .-2148 ; 0x1eb6 - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 271a: 85 e6 ldi r24, 0x65 ; 101 - 271c: 08 95 ret - -0000271e : - -CommandStatusIdType CommandSetSetting(const char* InParam) -{ - if (SettingsSetActiveByName(InParam)) { - 271e: d2 db rcall .-2140 ; 0x1ec4 - 2720: 81 11 cpse r24, r1 - 2722: 02 c0 rjmp .+4 ; 0x2728 - SettingsSave(); - return COMMAND_INFO_OK_ID; - } else { - return COMMAND_ERR_INVALID_PARAM_ID; - 2724: 8a ec ldi r24, 0xCA ; 202 - } -} - 2726: 08 95 ret -} - -CommandStatusIdType CommandSetSetting(const char* InParam) -{ - if (SettingsSetActiveByName(InParam)) { - SettingsSave(); - 2728: fc da rcall .-2568 ; 0x1d22 - return COMMAND_INFO_OK_ID; - 272a: 84 e6 ldi r24, 0x64 ; 100 - 272c: 08 95 ret - -0000272e : - } -} - -CommandStatusIdType CommandExecClear(char* OutParam) -{ - MemoryClear(); - 272e: 0e 94 94 07 call 0xf28 ; 0xf28 - return COMMAND_INFO_OK_ID; -} - 2732: 84 e6 ldi r24, 0x64 ; 100 - 2734: 08 95 ret - -00002736 : - -CommandStatusIdType CommandExecHelp(char* OutMessage) -{ - 2736: df 92 push r13 - 2738: ef 92 push r14 - 273a: ff 92 push r15 - 273c: 0f 93 push r16 - 273e: 1f 93 push r17 - 2740: cf 93 push r28 - 2742: df 93 push r29 - 2744: 7c 01 movw r14, r24 - const CommandEntryType* EntryPtr = CommandTable; - uint16_t ByteCount = TERMINAL_BUFFER_SIZE - 1; /* Account for '\0' */ - 2746: cf ef ldi r28, 0xFF ; 255 - 2748: d0 e0 ldi r29, 0x00 ; 0 - return COMMAND_INFO_OK_ID; -} - -CommandStatusIdType CommandExecHelp(char* OutMessage) -{ - const CommandEntryType* EntryPtr = CommandTable; - 274a: 03 e0 ldi r16, 0x03 ; 3 - 274c: 18 e0 ldi r17, 0x08 ; 8 - *OutMessage++ = c; - CommandName++; - ByteCount--; - } - - *OutMessage++ = ','; - 274e: 8c e2 ldi r24, 0x2C ; 44 - 2750: d8 2e mov r13, r24 -CommandStatusIdType CommandExecHelp(char* OutMessage) -{ - const CommandEntryType* EntryPtr = CommandTable; - uint16_t ByteCount = TERMINAL_BUFFER_SIZE - 1; /* Account for '\0' */ - - while(strcmp_P(COMMAND_LIST_END, EntryPtr->Command) != 0) { - 2752: b8 01 movw r22, r16 - 2754: 80 e9 ldi r24, 0x90 ; 144 - 2756: 90 e2 ldi r25, 0x20 ; 32 - 2758: 0e 94 ff 2b call 0x57fe ; 0x57fe - 275c: 89 2b or r24, r25 - 275e: 39 f1 breq .+78 ; 0x27ae - const char* CommandName = EntryPtr->Command; - char c; - - while( (c = pgm_read_byte(CommandName)) != '\0' && ByteCount > 32) { - 2760: f8 01 movw r30, r16 - 2762: 44 91 lpm r20, Z - 2764: 44 23 and r20, r20 - 2766: 79 f1 breq .+94 ; 0x27c6 - 2768: c1 32 cpi r28, 0x21 ; 33 - 276a: d1 05 cpc r29, r1 - 276c: 60 f1 brcs .+88 ; 0x27c6 - 276e: d7 01 movw r26, r14 - 2770: f8 01 movw r30, r16 - 2772: 04 c0 rjmp .+8 ; 0x277c - 2774: c0 32 cpi r28, 0x20 ; 32 - 2776: d1 05 cpc r29, r1 - 2778: 51 f0 breq .+20 ; 0x278e - 277a: dc 01 movw r26, r24 - 277c: cd 01 movw r24, r26 - 277e: 01 96 adiw r24, 0x01 ; 1 - 2780: 9c 01 movw r18, r24 - *OutMessage++ = c; - 2782: 4c 93 st X, r20 - CommandName++; - 2784: 31 96 adiw r30, 0x01 ; 1 - ByteCount--; - 2786: 21 97 sbiw r28, 0x01 ; 1 - - while(strcmp_P(COMMAND_LIST_END, EntryPtr->Command) != 0) { - const char* CommandName = EntryPtr->Command; - char c; - - while( (c = pgm_read_byte(CommandName)) != '\0' && ByteCount > 32) { - 2788: 44 91 lpm r20, Z - 278a: 41 11 cpse r20, r1 - 278c: f3 cf rjmp .-26 ; 0x2774 - *OutMessage++ = c; - CommandName++; - ByteCount--; - } - - *OutMessage++ = ','; - 278e: 79 01 movw r14, r18 - 2790: 8f ef ldi r24, 0xFF ; 255 - 2792: e8 1a sub r14, r24 - 2794: f8 0a sbc r15, r24 - 2796: f9 01 movw r30, r18 - 2798: d0 82 st Z, r13 - ByteCount--; - 279a: 21 97 sbiw r28, 0x01 ; 1 - - EntryPtr++; - 279c: 0a 5e subi r16, 0xEA ; 234 - 279e: 1f 4f sbci r17, 0xFF ; 255 -CommandStatusIdType CommandExecHelp(char* OutMessage) -{ - const CommandEntryType* EntryPtr = CommandTable; - uint16_t ByteCount = TERMINAL_BUFFER_SIZE - 1; /* Account for '\0' */ - - while(strcmp_P(COMMAND_LIST_END, EntryPtr->Command) != 0) { - 27a0: b8 01 movw r22, r16 - 27a2: 80 e9 ldi r24, 0x90 ; 144 - 27a4: 90 e2 ldi r25, 0x20 ; 32 - 27a6: 0e 94 ff 2b call 0x57fe ; 0x57fe - 27aa: 89 2b or r24, r25 - 27ac: c9 f6 brne .-78 ; 0x2760 - ByteCount--; - - EntryPtr++; - } - - *--OutMessage = '\0'; - 27ae: d7 01 movw r26, r14 - 27b0: 11 97 sbiw r26, 0x01 ; 1 - 27b2: 1c 92 st X, r1 - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - 27b4: 85 e6 ldi r24, 0x65 ; 101 - 27b6: df 91 pop r29 - 27b8: cf 91 pop r28 - 27ba: 1f 91 pop r17 - 27bc: 0f 91 pop r16 - 27be: ff 90 pop r15 - 27c0: ef 90 pop r14 - 27c2: df 90 pop r13 - 27c4: 08 95 ret - - while(strcmp_P(COMMAND_LIST_END, EntryPtr->Command) != 0) { - const char* CommandName = EntryPtr->Command; - char c; - - while( (c = pgm_read_byte(CommandName)) != '\0' && ByteCount > 32) { - 27c6: 97 01 movw r18, r14 - 27c8: e2 cf rjmp .-60 ; 0x278e - -000027ca : - - return COMMAND_INFO_OK_WITH_TEXT_ID; -} - -CommandStatusIdType CommandGetRssi(char* OutParam) -{ - 27ca: fc 01 movw r30, r24 -} - -static inline -uint16_t AntennaLevelGet(void) -{ - ADCA.CH0.CTRL |= ADC_CH_START_bm; - 27cc: 20 91 20 02 lds r18, 0x0220 - 27d0: 20 68 ori r18, 0x80 ; 128 - 27d2: 20 93 20 02 sts 0x0220, r18 - while( !(ADCA.CH0.INTFLAGS & ADC_CH_CHIF_bm) ); - 27d6: 20 91 23 02 lds r18, 0x0223 - 27da: 20 ff sbrs r18, 0 - 27dc: fc cf rjmp .-8 ; 0x27d6 - - ADCA.CH0.INTFLAGS = ADC_CH_CHIF_bm; - 27de: 81 e0 ldi r24, 0x01 ; 1 - 27e0: 80 93 23 02 sts 0x0223, r24 - - int16_t Result = ADCA.CH0RES - ANTENNA_LEVEL_OFFSET; - 27e4: a0 91 10 02 lds r26, 0x0210 - 27e8: b0 91 11 02 lds r27, 0x0211 - 27ec: ae 5b subi r26, 0xBE ; 190 - 27ee: b1 09 sbc r27, r1 - 27f0: b7 fd sbrc r27, 7 - 27f2: 1c c0 rjmp .+56 ; 0x282c - if (Result < 0) Result = 0; - - return (uint16_t) (((uint32_t) Result * ANTENNA_LEVEL_NUMERATOR) / ANTENNA_LEVEL_DENOMINATOR); - 27f4: 29 e6 ldi r18, 0x69 ; 105 - 27f6: 37 e5 ldi r19, 0x57 ; 87 - 27f8: 4b e0 ldi r20, 0x0B ; 11 - 27fa: 50 e0 ldi r21, 0x00 ; 0 - 27fc: 0e 94 80 2b call 0x5700 ; 0x5700 <__mulshisi3> - 2800: aa 27 eor r26, r26 - 2802: bb 27 eor r27, r27 - snprintf_P(OutParam, TERMINAL_BUFFER_SIZE, - 2804: 9f 93 push r25 - 2806: 8f 93 push r24 - 2808: 2e ea ldi r18, 0xAE ; 174 - 280a: 36 e0 ldi r19, 0x06 ; 6 - 280c: 3f 93 push r19 - 280e: 2f 93 push r18 - 2810: 81 e0 ldi r24, 0x01 ; 1 - 2812: 8f 93 push r24 - 2814: 1f 92 push r1 - 2816: ff 93 push r31 - 2818: ef 93 push r30 - 281a: 0e 94 37 2c call 0x586e ; 0x586e - PSTR("%5u mV"), AntennaLevelGet()); - - - return COMMAND_INFO_OK_WITH_TEXT_ID; - 281e: 8d b7 in r24, 0x3d ; 61 - 2820: 9e b7 in r25, 0x3e ; 62 - 2822: 08 96 adiw r24, 0x08 ; 8 - 2824: 8d bf out 0x3d, r24 ; 61 - 2826: 9e bf out 0x3e, r25 ; 62 -} - 2828: 85 e6 ldi r24, 0x65 ; 101 - 282a: 08 95 ret - 282c: a0 e0 ldi r26, 0x00 ; 0 - 282e: b0 e0 ldi r27, 0x00 ; 0 - 2830: e1 cf rjmp .-62 ; 0x27f4 - -00002832 : - return Checksum; -} - -void XModemReceive(XModemCallbackType TheCallbackFunc) -{ - State = STATE_RECEIVE_INIT; - 2832: 21 e0 ldi r18, 0x01 ; 1 - 2834: 20 93 a9 28 sts 0x28A9, r18 - CurrentFrameNumber = FIRST_FRAME_NUMBER; - 2838: 20 93 a8 28 sts 0x28A8, r18 - RetryCount = RECV_INIT_COUNT; - 283c: 2c e3 ldi r18, 0x3C ; 60 - 283e: 20 93 a5 28 sts 0x28A5, r18 - RetryTimeout = RECV_INIT_TIMEOUT; - 2842: 25 e0 ldi r18, 0x05 ; 5 - 2844: 30 e0 ldi r19, 0x00 ; 0 - 2846: 20 93 a3 28 sts 0x28A3, r18 - 284a: 30 93 a4 28 sts 0x28A4, r19 - BlockAddress = 0; - 284e: 10 92 9d 28 sts 0x289D, r1 - 2852: 10 92 9e 28 sts 0x289E, r1 - 2856: 10 92 9f 28 sts 0x289F, r1 - 285a: 10 92 a0 28 sts 0x28A0, r1 - - CallbackFunc = TheCallbackFunc; - 285e: 80 93 9b 28 sts 0x289B, r24 - 2862: 90 93 9c 28 sts 0x289C, r25 - 2866: 08 95 ret - -00002868 : -} - -void XModemSend(XModemCallbackType TheCallbackFunc) -{ - State = STATE_SEND_INIT; - 2868: 27 e0 ldi r18, 0x07 ; 7 - 286a: 20 93 a9 28 sts 0x28A9, r18 - RetryTimeout = SEND_INIT_TIMEOUT; - 286e: 2c e2 ldi r18, 0x2C ; 44 - 2870: 31 e0 ldi r19, 0x01 ; 1 - 2872: 20 93 a3 28 sts 0x28A3, r18 - 2876: 30 93 a4 28 sts 0x28A4, r19 - BlockAddress = 0; - 287a: 10 92 9d 28 sts 0x289D, r1 - 287e: 10 92 9e 28 sts 0x289E, r1 - 2882: 10 92 9f 28 sts 0x289F, r1 - 2886: 10 92 a0 28 sts 0x28A0, r1 - - CallbackFunc = TheCallbackFunc; - 288a: 80 93 9b 28 sts 0x289B, r24 - 288e: 90 93 9c 28 sts 0x289C, r25 - 2892: 08 95 ret - -00002894 : -} - -bool XModemProcessByte(uint8_t Byte) -{ - 2894: cf 93 push r28 - switch(State) { - 2896: 40 91 a9 28 lds r20, 0x28A9 - 289a: 50 e0 ldi r21, 0x00 ; 0 - 289c: fa 01 movw r30, r20 - 289e: 31 97 sbiw r30, 0x01 ; 1 - 28a0: e9 30 cpi r30, 0x09 ; 9 - 28a2: f1 05 cpc r31, r1 - 28a4: 20 f0 brcs .+8 ; 0x28ae - /* Receive Ack */ - State = STATE_OFF; - break; - - default: - return false; - 28a6: c0 e0 ldi r28, 0x00 ; 0 - break; - } - - return true; -} - 28a8: 8c 2f mov r24, r28 - 28aa: cf 91 pop r28 - 28ac: 08 95 ret - CallbackFunc = TheCallbackFunc; -} - -bool XModemProcessByte(uint8_t Byte) -{ - switch(State) { - 28ae: e2 5b subi r30, 0xB2 ; 178 - 28b0: fe 4f sbci r31, 0xFE ; 254 - 28b2: 0c 94 7a 2b jmp 0x56f4 ; 0x56f4 <__tablejump2__> - } - - break; - - case STATE_RECEIVE_PROCESS: - if (ReceivedFrameNumber == CurrentFrameNumber) { - 28b6: 20 91 a7 28 lds r18, 0x28A7 - 28ba: 90 91 a8 28 lds r25, 0x28A8 - 28be: 29 17 cp r18, r25 - 28c0: 09 f4 brne .+2 ; 0x28c4 - 28c2: ea c0 rjmp .+468 ; 0x2a98 - } else { - /* Data seems to be damaged */ - TerminalSendByte(BYTE_NAK); - State = STATE_RECEIVE_WAIT; - } - } else if (ReceivedFrameNumber == (CurrentFrameNumber - 1)) { - 28c4: 30 e0 ldi r19, 0x00 ; 0 - 28c6: 89 2f mov r24, r25 - 28c8: 90 e0 ldi r25, 0x00 ; 0 - 28ca: 01 97 sbiw r24, 0x01 ; 1 - 28cc: 28 17 cp r18, r24 - 28ce: 39 07 cpc r19, r25 - 28d0: 09 f4 brne .+2 ; 0x28d4 - 28d2: 2d c1 rjmp .+602 ; 0x2b2e -INLINE void TerminalSendByte(uint8_t Byte) { CDC_Device_SendByte(&TerminalHandle, Byte); } - 28d4: 68 e1 ldi r22, 0x18 ; 24 - 28d6: 81 e0 ldi r24, 0x01 ; 1 - 28d8: 90 e2 ldi r25, 0x20 ; 32 - 28da: 0e 94 f5 29 call 0x53ea ; 0x53ea - TerminalSendByte(BYTE_ACK); - State = STATE_RECEIVE_WAIT; - } else { - /* This frame is completely out of order. Just cancel */ - TerminalSendByte(BYTE_CAN); - State = STATE_OFF; - 28de: 10 92 a9 28 sts 0x28A9, r1 - default: - return false; - break; - } - - return true; - 28e2: c1 e0 ldi r28, 0x01 ; 1 -} - 28e4: 8c 2f mov r24, r28 - 28e6: cf 91 pop r28 - 28e8: 08 95 ret - - break; - - case STATE_SEND_INIT: - /* Start sending on NAK */ - if (Byte == BYTE_NAK) { - 28ea: 85 31 cpi r24, 0x15 ; 21 - 28ec: 09 f4 brne .+2 ; 0x28f0 - 28ee: 7f c0 rjmp .+254 ; 0x29ee - CurrentFrameNumber = FIRST_FRAME_NUMBER - 1; - Byte = BYTE_ACK; - } else if (Byte == BYTE_ESC) { - 28f0: 8b 31 cpi r24, 0x1B ; 27 - 28f2: 09 f4 brne .+2 ; 0x28f6 - 28f4: 78 c0 rjmp .+240 ; 0x29e6 - } - - /* Fallthrough */ - - case STATE_SEND_WAIT: - if (Byte == BYTE_CAN) { - 28f6: 88 31 cpi r24, 0x18 ; 24 - 28f8: 09 f4 brne .+2 ; 0x28fc - 28fa: 10 c1 rjmp .+544 ; 0x2b1c - /* Cancel */ - TerminalSendByte(BYTE_ACK); - State = STATE_OFF; - } else if (Byte == BYTE_ACK) { - 28fc: 86 30 cpi r24, 0x06 ; 6 - 28fe: 09 f4 brne .+2 ; 0x2902 - 2900: 78 c0 rjmp .+240 ; 0x29f2 - BlockAddress += XMODEM_BLOCK_SIZE; - } else { - TerminalSendByte(BYTE_EOT); - State = STATE_SEND_EOT; - } - } else if (Byte == BYTE_NAK){ - 2902: 85 31 cpi r24, 0x15 ; 21 - 2904: 09 f4 brne .+2 ; 0x2908 - 2906: 49 c0 rjmp .+146 ; 0x299a - default: - return false; - break; - } - - return true; - 2908: c1 e0 ldi r28, 0x01 ; 1 -} - 290a: 8c 2f mov r24, r28 - 290c: cf 91 pop r28 - 290e: 08 95 ret -bool XModemProcessByte(uint8_t Byte) -{ - switch(State) { - case STATE_RECEIVE_INIT: - case STATE_RECEIVE_WAIT: - if (Byte == BYTE_SOH) { - 2910: 81 30 cpi r24, 0x01 ; 1 - 2912: 09 f4 brne .+2 ; 0x2916 - 2914: 0e c1 rjmp .+540 ; 0x2b32 - /* Next frame incoming */ - BufferIdx = 0; - Checksum = CHECKSUM_INIT_VALUE; - State = STATE_RECEIVE_FRAMENUM1; - } else if (Byte == BYTE_EOT) { - 2916: 84 30 cpi r24, 0x04 ; 4 - 2918: 09 f4 brne .+2 ; 0x291c - 291a: 00 c1 rjmp .+512 ; 0x2b1c - /* Transmission finished */ - TerminalSendByte(BYTE_ACK); - State = STATE_OFF; - } else if ( (Byte == BYTE_CAN) || (Byte == BYTE_ESC) ) { - 291c: 88 31 cpi r24, 0x18 ; 24 - 291e: f9 f2 breq .-66 ; 0x28de - 2920: 8b 31 cpi r24, 0x1B ; 27 - 2922: e9 f2 breq .-70 ; 0x28de - default: - return false; - break; - } - - return true; - 2924: c1 e0 ldi r28, 0x01 ; 1 - 2926: f1 cf rjmp .-30 ; 0x290a - - break; - - case STATE_RECEIVE_FRAMENUM1: - /* Store frame number */ - ReceivedFrameNumber = Byte; - 2928: 80 93 a7 28 sts 0x28A7, r24 - State = STATE_RECEIVE_FRAMENUM2; - 292c: 84 e0 ldi r24, 0x04 ; 4 - 292e: 80 93 a9 28 sts 0x28A9, r24 - default: - return false; - break; - } - - return true; - 2932: c1 e0 ldi r28, 0x01 ; 1 -} - 2934: 8c 2f mov r24, r28 - 2936: cf 91 pop r28 - 2938: 08 95 ret - ReceivedFrameNumber = Byte; - State = STATE_RECEIVE_FRAMENUM2; - break; - - case STATE_RECEIVE_FRAMENUM2: - if (Byte == (255 - ReceivedFrameNumber)) { - 293a: 90 e0 ldi r25, 0x00 ; 0 - 293c: 40 91 a7 28 lds r20, 0x28A7 - 2940: 2f ef ldi r18, 0xFF ; 255 - 2942: 30 e0 ldi r19, 0x00 ; 0 - 2944: 24 1b sub r18, r20 - 2946: 31 09 sbc r19, r1 - 2948: 82 17 cp r24, r18 - 294a: 93 07 cpc r25, r19 - 294c: e1 f4 brne .+56 ; 0x2986 - /* frame-number check passed. */ - State = STATE_RECEIVE_DATA; - 294e: 85 e0 ldi r24, 0x05 ; 5 - 2950: 80 93 a9 28 sts 0x28A9, r24 - default: - return false; - break; - } - - return true; - 2954: c1 e0 ldi r28, 0x01 ; 1 - 2956: a8 cf rjmp .-176 ; 0x28a8 - - break; - - case STATE_RECEIVE_DATA: - /* Process byte and update checksum */ - TerminalBuffer[BufferIdx++] = Byte; - 2958: 40 91 a1 28 lds r20, 0x28A1 - 295c: 50 91 a2 28 lds r21, 0x28A2 - 2960: 9a 01 movw r18, r20 - 2962: 2f 5f subi r18, 0xFF ; 255 - 2964: 3f 4f sbci r19, 0xFF ; 255 - 2966: 20 93 a1 28 sts 0x28A1, r18 - 296a: 30 93 a2 28 sts 0x28A2, r19 - 296e: fa 01 movw r30, r20 - 2970: e4 5c subi r30, 0xC4 ; 196 - 2972: f6 4d sbci r31, 0xD6 ; 214 - 2974: 80 83 st Z, r24 - - if (BufferIdx == XMODEM_BLOCK_SIZE) { - 2976: 20 38 cpi r18, 0x80 ; 128 - 2978: 31 05 cpc r19, r1 - 297a: 31 f6 brne .-116 ; 0x2908 - /* Block full */ - State = STATE_RECEIVE_PROCESS; - 297c: 86 e0 ldi r24, 0x06 ; 6 - 297e: 80 93 a9 28 sts 0x28A9, r24 - default: - return false; - break; - } - - return true; - 2982: c1 e0 ldi r28, 0x01 ; 1 - 2984: 91 cf rjmp .-222 ; 0x28a8 - 2986: 65 e1 ldi r22, 0x15 ; 21 - 2988: 81 e0 ldi r24, 0x01 ; 1 - 298a: 90 e2 ldi r25, 0x20 ; 32 - 298c: 0e 94 f5 29 call 0x53ea ; 0x53ea - State = STATE_RECEIVE_WAIT; - } - } else if (ReceivedFrameNumber == (CurrentFrameNumber - 1)) { - /* This is a retransmission */ - TerminalSendByte(BYTE_ACK); - State = STATE_RECEIVE_WAIT; - 2990: 82 e0 ldi r24, 0x02 ; 2 - 2992: 80 93 a9 28 sts 0x28A9, r24 - default: - return false; - break; - } - - return true; - 2996: c1 e0 ldi r28, 0x01 ; 1 - 2998: 87 cf rjmp .-242 ; 0x28a8 - 299a: 61 e0 ldi r22, 0x01 ; 1 - 299c: 81 e0 ldi r24, 0x01 ; 1 - 299e: 90 e2 ldi r25, 0x20 ; 32 - 29a0: 0e 94 f5 29 call 0x53ea ; 0x53ea - 29a4: 60 91 a8 28 lds r22, 0x28A8 - 29a8: 81 e0 ldi r24, 0x01 ; 1 - 29aa: 90 e2 ldi r25, 0x20 ; 32 - 29ac: 0e 94 f5 29 call 0x53ea ; 0x53ea - } - } else if (Byte == BYTE_NAK){ - /* Resend frame */ - TerminalSendByte(BYTE_SOH); - TerminalSendByte(CurrentFrameNumber); - TerminalSendByte(255 - CurrentFrameNumber); - 29b0: 60 91 a8 28 lds r22, 0x28A8 - 29b4: 60 95 com r22 - 29b6: 81 e0 ldi r24, 0x01 ; 1 - 29b8: 90 e2 ldi r25, 0x20 ; 32 - 29ba: 0e 94 f5 29 call 0x53ea ; 0x53ea - TerminalSendBlock(TerminalBuffer, XMODEM_BLOCK_SIZE); - 29be: 60 e8 ldi r22, 0x80 ; 128 - 29c0: 70 e0 ldi r23, 0x00 ; 0 - 29c2: 8c e3 ldi r24, 0x3C ; 60 - 29c4: 99 e2 ldi r25, 0x29 ; 41 - 29c6: 3a dc rcall .-1932 ; 0x223c - 29c8: ec e3 ldi r30, 0x3C ; 60 - 29ca: f9 e2 ldi r31, 0x29 ; 41 -static uint32_t BlockAddress; - -static XModemCallbackType CallbackFunc; - -static uint8_t CalcChecksum(const void* Buffer, uint16_t ByteCount) { - uint8_t Checksum = CHECKSUM_INIT_VALUE; - 29cc: 60 e0 ldi r22, 0x00 ; 0 - uint8_t* DataPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - Checksum += *DataPtr++; - 29ce: 81 91 ld r24, Z+ - 29d0: 68 0f add r22, r24 - -static uint8_t CalcChecksum(const void* Buffer, uint16_t ByteCount) { - uint8_t Checksum = CHECKSUM_INIT_VALUE; - uint8_t* DataPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - 29d2: 29 e2 ldi r18, 0x29 ; 41 - 29d4: ec 3b cpi r30, 0xBC ; 188 - 29d6: f2 07 cpc r31, r18 - 29d8: d1 f7 brne .-12 ; 0x29ce - 29da: 81 e0 ldi r24, 0x01 ; 1 - 29dc: 90 e2 ldi r25, 0x20 ; 32 - 29de: 0e 94 f5 29 call 0x53ea ; 0x53ea - default: - return false; - break; - } - - return true; - 29e2: c1 e0 ldi r28, 0x01 ; 1 - 29e4: 92 cf rjmp .-220 ; 0x290a - /* Start sending on NAK */ - if (Byte == BYTE_NAK) { - CurrentFrameNumber = FIRST_FRAME_NUMBER - 1; - Byte = BYTE_ACK; - } else if (Byte == BYTE_ESC) { - State = STATE_OFF; - 29e6: 10 92 a9 28 sts 0x28A9, r1 - default: - return false; - break; - } - - return true; - 29ea: c1 e0 ldi r28, 0x01 ; 1 - 29ec: 8e cf rjmp .-228 ; 0x290a - break; - - case STATE_SEND_INIT: - /* Start sending on NAK */ - if (Byte == BYTE_NAK) { - CurrentFrameNumber = FIRST_FRAME_NUMBER - 1; - 29ee: 10 92 a8 28 sts 0x28A8, r1 - /* Cancel */ - TerminalSendByte(BYTE_ACK); - State = STATE_OFF; - } else if (Byte == BYTE_ACK) { - /* Acknowledge. Proceed to next frame, get data and calc checksum */ - CurrentFrameNumber++; - 29f2: 80 91 a8 28 lds r24, 0x28A8 - 29f6: 8f 5f subi r24, 0xFF ; 255 - 29f8: 80 93 a8 28 sts 0x28A8, r24 - - if (CallbackFunc(TerminalBuffer, BlockAddress, XMODEM_BLOCK_SIZE)) { - 29fc: 40 91 9d 28 lds r20, 0x289D - 2a00: 50 91 9e 28 lds r21, 0x289E - 2a04: 60 91 9f 28 lds r22, 0x289F - 2a08: 70 91 a0 28 lds r23, 0x28A0 - 2a0c: e0 91 9b 28 lds r30, 0x289B - 2a10: f0 91 9c 28 lds r31, 0x289C - 2a14: 20 e8 ldi r18, 0x80 ; 128 - 2a16: 30 e0 ldi r19, 0x00 ; 0 - 2a18: 8c e3 ldi r24, 0x3C ; 60 - 2a1a: 99 e2 ldi r25, 0x29 ; 41 - 2a1c: 09 95 icall - 2a1e: c8 2f mov r28, r24 - 2a20: 88 23 and r24, r24 - 2a22: 09 f4 brne .+2 ; 0x2a26 - 2a24: 91 c0 rjmp .+290 ; 0x2b48 - 2a26: 61 e0 ldi r22, 0x01 ; 1 - 2a28: 81 e0 ldi r24, 0x01 ; 1 - 2a2a: 90 e2 ldi r25, 0x20 ; 32 - 2a2c: 0e 94 f5 29 call 0x53ea ; 0x53ea - 2a30: 60 91 a8 28 lds r22, 0x28A8 - 2a34: 81 e0 ldi r24, 0x01 ; 1 - 2a36: 90 e2 ldi r25, 0x20 ; 32 - 2a38: 0e 94 f5 29 call 0x53ea ; 0x53ea - TerminalSendByte(BYTE_SOH); - TerminalSendByte(CurrentFrameNumber); - TerminalSendByte(255 - CurrentFrameNumber); - 2a3c: 60 91 a8 28 lds r22, 0x28A8 - 2a40: 60 95 com r22 - 2a42: 81 e0 ldi r24, 0x01 ; 1 - 2a44: 90 e2 ldi r25, 0x20 ; 32 - 2a46: 0e 94 f5 29 call 0x53ea ; 0x53ea - TerminalSendBlock(TerminalBuffer, XMODEM_BLOCK_SIZE); - 2a4a: 60 e8 ldi r22, 0x80 ; 128 - 2a4c: 70 e0 ldi r23, 0x00 ; 0 - 2a4e: 8c e3 ldi r24, 0x3C ; 60 - 2a50: 99 e2 ldi r25, 0x29 ; 41 - 2a52: f4 db rcall .-2072 ; 0x223c - 2a54: ec e3 ldi r30, 0x3C ; 60 - 2a56: f9 e2 ldi r31, 0x29 ; 41 -static uint32_t BlockAddress; - -static XModemCallbackType CallbackFunc; - -static uint8_t CalcChecksum(const void* Buffer, uint16_t ByteCount) { - uint8_t Checksum = CHECKSUM_INIT_VALUE; - 2a58: 60 e0 ldi r22, 0x00 ; 0 - uint8_t* DataPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - Checksum += *DataPtr++; - 2a5a: 81 91 ld r24, Z+ - 2a5c: 68 0f add r22, r24 - -static uint8_t CalcChecksum(const void* Buffer, uint16_t ByteCount) { - uint8_t Checksum = CHECKSUM_INIT_VALUE; - uint8_t* DataPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - 2a5e: 89 e2 ldi r24, 0x29 ; 41 - 2a60: ec 3b cpi r30, 0xBC ; 188 - 2a62: f8 07 cpc r31, r24 - 2a64: d1 f7 brne .-12 ; 0x2a5a - 2a66: 81 e0 ldi r24, 0x01 ; 1 - 2a68: 90 e2 ldi r25, 0x20 ; 32 - 2a6a: 0e 94 f5 29 call 0x53ea ; 0x53ea - TerminalSendByte(CurrentFrameNumber); - TerminalSendByte(255 - CurrentFrameNumber); - TerminalSendBlock(TerminalBuffer, XMODEM_BLOCK_SIZE); - TerminalSendByte(CalcChecksum(TerminalBuffer, XMODEM_BLOCK_SIZE)); - - BlockAddress += XMODEM_BLOCK_SIZE; - 2a6e: 40 91 9d 28 lds r20, 0x289D - 2a72: 50 91 9e 28 lds r21, 0x289E - 2a76: 60 91 9f 28 lds r22, 0x289F - 2a7a: 70 91 a0 28 lds r23, 0x28A0 - 2a7e: 40 58 subi r20, 0x80 ; 128 - 2a80: 5f 4f sbci r21, 0xFF ; 255 - 2a82: 6f 4f sbci r22, 0xFF ; 255 - 2a84: 7f 4f sbci r23, 0xFF ; 255 - 2a86: 40 93 9d 28 sts 0x289D, r20 - 2a8a: 50 93 9e 28 sts 0x289E, r21 - 2a8e: 60 93 9f 28 sts 0x289F, r22 - 2a92: 70 93 a0 28 sts 0x28A0, r23 - 2a96: 08 cf rjmp .-496 ; 0x28a8 - 2a98: ec e3 ldi r30, 0x3C ; 60 - 2a9a: f9 e2 ldi r31, 0x29 ; 41 - } - - break; - - case STATE_RECEIVE_PROCESS: - if (ReceivedFrameNumber == CurrentFrameNumber) { - 2a9c: 90 e0 ldi r25, 0x00 ; 0 -static uint8_t CalcChecksum(const void* Buffer, uint16_t ByteCount) { - uint8_t Checksum = CHECKSUM_INIT_VALUE; - uint8_t* DataPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - Checksum += *DataPtr++; - 2a9e: 21 91 ld r18, Z+ - 2aa0: 92 0f add r25, r18 - -static uint8_t CalcChecksum(const void* Buffer, uint16_t ByteCount) { - uint8_t Checksum = CHECKSUM_INIT_VALUE; - uint8_t* DataPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - 2aa2: 29 e2 ldi r18, 0x29 ; 41 - 2aa4: ec 3b cpi r30, 0xBC ; 188 - 2aa6: f2 07 cpc r31, r18 - 2aa8: d1 f7 brne .-12 ; 0x2a9e - - case STATE_RECEIVE_PROCESS: - if (ReceivedFrameNumber == CurrentFrameNumber) { - /* This is the expected frame. Calculate and verify checksum */ - - if (CalcChecksum(TerminalBuffer, XMODEM_BLOCK_SIZE) == Byte) { - 2aaa: 89 13 cpse r24, r25 - 2aac: 6c cf rjmp .-296 ; 0x2986 - /* Checksum is valid. Pass received data to callback function */ - if (CallbackFunc(TerminalBuffer, BlockAddress, XMODEM_BLOCK_SIZE)) { - 2aae: 40 91 9d 28 lds r20, 0x289D - 2ab2: 50 91 9e 28 lds r21, 0x289E - 2ab6: 60 91 9f 28 lds r22, 0x289F - 2aba: 70 91 a0 28 lds r23, 0x28A0 - 2abe: e0 91 9b 28 lds r30, 0x289B - 2ac2: f0 91 9c 28 lds r31, 0x289C - 2ac6: 20 e8 ldi r18, 0x80 ; 128 - 2ac8: 30 e0 ldi r19, 0x00 ; 0 - 2aca: 8c e3 ldi r24, 0x3C ; 60 - 2acc: 99 e2 ldi r25, 0x29 ; 41 - 2ace: 09 95 icall - 2ad0: c8 2f mov r28, r24 - 2ad2: 88 23 and r24, r24 - 2ad4: 09 f4 brne .+2 ; 0x2ad8 - 2ad6: 42 c0 rjmp .+132 ; 0x2b5c - /* Proceed to next frame and send ACK */ - CurrentFrameNumber++; - 2ad8: 80 91 a8 28 lds r24, 0x28A8 - 2adc: 8f 5f subi r24, 0xFF ; 255 - 2ade: 80 93 a8 28 sts 0x28A8, r24 - BlockAddress += XMODEM_BLOCK_SIZE; - 2ae2: 40 91 9d 28 lds r20, 0x289D - 2ae6: 50 91 9e 28 lds r21, 0x289E - 2aea: 60 91 9f 28 lds r22, 0x289F - 2aee: 70 91 a0 28 lds r23, 0x28A0 - 2af2: 40 58 subi r20, 0x80 ; 128 - 2af4: 5f 4f sbci r21, 0xFF ; 255 - 2af6: 6f 4f sbci r22, 0xFF ; 255 - 2af8: 7f 4f sbci r23, 0xFF ; 255 - 2afa: 40 93 9d 28 sts 0x289D, r20 - 2afe: 50 93 9e 28 sts 0x289E, r21 - 2b02: 60 93 9f 28 sts 0x289F, r22 - 2b06: 70 93 a0 28 sts 0x28A0, r23 -void EVENT_USB_Device_Connect(void); -void EVENT_USB_Device_Disconnect(void); -void EVENT_USB_Device_ConfigurationChanged(void); -void EVENT_USB_Device_ControlRequest(void); - -INLINE void TerminalSendChar(char c) { CDC_Device_SendByte(&TerminalHandle, c); } - 2b0a: 66 e0 ldi r22, 0x06 ; 6 - 2b0c: 81 e0 ldi r24, 0x01 ; 1 - 2b0e: 90 e2 ldi r25, 0x20 ; 32 - 2b10: 0e 94 f5 29 call 0x53ea ; 0x53ea - TerminalSendChar(BYTE_ACK); - State = STATE_RECEIVE_WAIT; - 2b14: 82 e0 ldi r24, 0x02 ; 2 - 2b16: 80 93 a9 28 sts 0x28A9, r24 - 2b1a: c6 ce rjmp .-628 ; 0x28a8 -INLINE void TerminalSendByte(uint8_t Byte) { CDC_Device_SendByte(&TerminalHandle, Byte); } - 2b1c: 66 e0 ldi r22, 0x06 ; 6 - 2b1e: 81 e0 ldi r24, 0x01 ; 1 - 2b20: 90 e2 ldi r25, 0x20 ; 32 - 2b22: 0e 94 f5 29 call 0x53ea ; 0x53ea - Checksum = CHECKSUM_INIT_VALUE; - State = STATE_RECEIVE_FRAMENUM1; - } else if (Byte == BYTE_EOT) { - /* Transmission finished */ - TerminalSendByte(BYTE_ACK); - State = STATE_OFF; - 2b26: 10 92 a9 28 sts 0x28A9, r1 - default: - return false; - break; - } - - return true; - 2b2a: c1 e0 ldi r28, 0x01 ; 1 - 2b2c: bd ce rjmp .-646 ; 0x28a8 - 2b2e: 66 e0 ldi r22, 0x06 ; 6 - 2b30: 2b cf rjmp .-426 ; 0x2988 - switch(State) { - case STATE_RECEIVE_INIT: - case STATE_RECEIVE_WAIT: - if (Byte == BYTE_SOH) { - /* Next frame incoming */ - BufferIdx = 0; - 2b32: 10 92 a1 28 sts 0x28A1, r1 - 2b36: 10 92 a2 28 sts 0x28A2, r1 - Checksum = CHECKSUM_INIT_VALUE; - 2b3a: 10 92 a6 28 sts 0x28A6, r1 - State = STATE_RECEIVE_FRAMENUM1; - 2b3e: 83 e0 ldi r24, 0x03 ; 3 - 2b40: 80 93 a9 28 sts 0x28A9, r24 - default: - return false; - break; - } - - return true; - 2b44: c1 e0 ldi r28, 0x01 ; 1 - 2b46: b0 ce rjmp .-672 ; 0x28a8 - 2b48: 64 e0 ldi r22, 0x04 ; 4 - 2b4a: 81 e0 ldi r24, 0x01 ; 1 - 2b4c: 90 e2 ldi r25, 0x20 ; 32 - 2b4e: 0e 94 f5 29 call 0x53ea ; 0x53ea - TerminalSendByte(CalcChecksum(TerminalBuffer, XMODEM_BLOCK_SIZE)); - - BlockAddress += XMODEM_BLOCK_SIZE; - } else { - TerminalSendByte(BYTE_EOT); - State = STATE_SEND_EOT; - 2b52: 89 e0 ldi r24, 0x09 ; 9 - 2b54: 80 93 a9 28 sts 0x28A9, r24 - default: - return false; - break; - } - - return true; - 2b58: c1 e0 ldi r28, 0x01 ; 1 - 2b5a: a6 ce rjmp .-692 ; 0x28a8 - 2b5c: 68 e1 ldi r22, 0x18 ; 24 - 2b5e: 81 e0 ldi r24, 0x01 ; 1 - 2b60: 90 e2 ldi r25, 0x20 ; 32 - 2b62: 0e 94 f5 29 call 0x53ea ; 0x53ea - 2b66: b6 ce rjmp .-660 ; 0x28d4 - -00002b68 : -} - -void XModemTick(void) -{ - /* Timeouts go here */ - switch(State) { - 2b68: 80 91 a9 28 lds r24, 0x28A9 - 2b6c: 81 30 cpi r24, 0x01 ; 1 - 2b6e: 99 f0 breq .+38 ; 0x2b96 - 2b70: 87 30 cpi r24, 0x07 ; 7 - 2b72: 81 f4 brne .+32 ; 0x2b94 - RetryTimeout = RECV_INIT_TIMEOUT; - } - break; - - case STATE_SEND_INIT: - if (RetryTimeout-- == 0) { - 2b74: 80 91 a3 28 lds r24, 0x28A3 - 2b78: 90 91 a4 28 lds r25, 0x28A4 - 2b7c: 9c 01 movw r18, r24 - 2b7e: 21 50 subi r18, 0x01 ; 1 - 2b80: 31 09 sbc r19, r1 - 2b82: 20 93 a3 28 sts 0x28A3, r18 - 2b86: 30 93 a4 28 sts 0x28A4, r19 - 2b8a: 89 2b or r24, r25 - 2b8c: 11 f4 brne .+4 ; 0x2b92 - /* Abort */ - State = STATE_OFF; - 2b8e: 10 92 a9 28 sts 0x28A9, r1 - 2b92: 08 95 ret - 2b94: 08 95 ret -void XModemTick(void) -{ - /* Timeouts go here */ - switch(State) { - case STATE_RECEIVE_INIT: - if (RetryTimeout-- == 0) { - 2b96: 80 91 a3 28 lds r24, 0x28A3 - 2b9a: 90 91 a4 28 lds r25, 0x28A4 - 2b9e: 9c 01 movw r18, r24 - 2ba0: 21 50 subi r18, 0x01 ; 1 - 2ba2: 31 09 sbc r19, r1 - 2ba4: 20 93 a3 28 sts 0x28A3, r18 - 2ba8: 30 93 a4 28 sts 0x28A4, r19 - 2bac: 89 2b or r24, r25 - 2bae: 89 f7 brne .-30 ; 0x2b92 - if (RetryCount-- > 0) { - 2bb0: 80 91 a5 28 lds r24, 0x28A5 - 2bb4: 9f ef ldi r25, 0xFF ; 255 - 2bb6: 98 0f add r25, r24 - 2bb8: 90 93 a5 28 sts 0x28A5, r25 - 2bbc: 81 11 cpse r24, r1 - 2bbe: 09 c0 rjmp .+18 ; 0x2bd2 - /* Put out communication request */ - TerminalSendChar(BYTE_NAK); - } else { - /* Just shut off after some time. */ - State = STATE_OFF; - 2bc0: 10 92 a9 28 sts 0x28A9, r1 - } - - RetryTimeout = RECV_INIT_TIMEOUT; - 2bc4: 85 e0 ldi r24, 0x05 ; 5 - 2bc6: 90 e0 ldi r25, 0x00 ; 0 - 2bc8: 80 93 a3 28 sts 0x28A3, r24 - 2bcc: 90 93 a4 28 sts 0x28A4, r25 - 2bd0: 08 95 ret -void EVENT_USB_Device_Connect(void); -void EVENT_USB_Device_Disconnect(void); -void EVENT_USB_Device_ConfigurationChanged(void); -void EVENT_USB_Device_ControlRequest(void); - -INLINE void TerminalSendChar(char c) { CDC_Device_SendByte(&TerminalHandle, c); } - 2bd2: 65 e1 ldi r22, 0x15 ; 21 - 2bd4: 81 e0 ldi r24, 0x01 ; 1 - 2bd6: 90 e2 ldi r25, 0x20 ; 32 - 2bd8: 0e 94 f5 29 call 0x53ea ; 0x53ea - 2bdc: f3 cf rjmp .-26 ; 0x2bc4 - -00002bde : -void CommandLineInit(void) -{ - BufferIdx = 0; -} - -bool CommandLineProcessByte(uint8_t Byte) { - 2bde: ef 92 push r14 - 2be0: ff 92 push r15 - 2be2: 0f 93 push r16 - 2be4: 1f 93 push r17 - 2be6: cf 93 push r28 - 2be8: df 93 push r29 - 2bea: 1f 92 push r1 - 2bec: cd b7 in r28, 0x3d ; 61 - 2bee: de b7 in r29, 0x3e ; 62 - if (IS_CHARACTER(Byte)){ - 2bf0: 9f eb ldi r25, 0xBF ; 191 - 2bf2: 98 0f add r25, r24 - 2bf4: 9a 31 cpi r25, 0x1A ; 26 - 2bf6: 28 f0 brcs .+10 ; 0x2c02 - 2bf8: 9f e9 ldi r25, 0x9F ; 159 - 2bfa: 98 0f add r25, r24 - 2bfc: 9a 31 cpi r25, 0x1A ; 26 - 2bfe: e0 f4 brcc .+56 ; 0x2c38 - /* Store uppercase character */ - if (IS_LOWERCASE(Byte)) { - Byte = TO_UPPERCASE(Byte); - 2c00: 80 52 subi r24, 0x20 ; 32 - } - - /* Prevent buffer overflow and account for '\0' */ - if (BufferIdx < (sizeof(TerminalBuffer) / sizeof(*TerminalBuffer) - 1)) { - 2c02: 20 91 aa 28 lds r18, 0x28AA - 2c06: 30 91 ab 28 lds r19, 0x28AB - 2c0a: 2f 3f cpi r18, 0xFF ; 255 - 2c0c: 31 05 cpc r19, r1 - 2c0e: 58 f4 brcc .+22 ; 0x2c26 - TerminalBuffer[BufferIdx++] = Byte; - 2c10: a9 01 movw r20, r18 - 2c12: 4f 5f subi r20, 0xFF ; 255 - 2c14: 5f 4f sbci r21, 0xFF ; 255 - 2c16: 40 93 aa 28 sts 0x28AA, r20 - 2c1a: 50 93 ab 28 sts 0x28AB, r21 - 2c1e: f9 01 movw r30, r18 - 2c20: e4 5c subi r30, 0xC4 ; 196 - 2c22: f6 4d sbci r31, 0xD6 ; 214 - 2c24: 80 83 st Z, r24 - } else { - /* Ignore other chars */ - } - - return true; -} - 2c26: 81 e0 ldi r24, 0x01 ; 1 - 2c28: 0f 90 pop r0 - 2c2a: df 91 pop r29 - 2c2c: cf 91 pop r28 - 2c2e: 1f 91 pop r17 - 2c30: 0f 91 pop r16 - 2c32: ff 90 pop r15 - 2c34: ef 90 pop r14 - 2c36: 08 95 ret -{ - BufferIdx = 0; -} - -bool CommandLineProcessByte(uint8_t Byte) { - if (IS_CHARACTER(Byte)){ - 2c38: 90 ed ldi r25, 0xD0 ; 208 - 2c3a: 98 0f add r25, r24 - 2c3c: 9a 30 cpi r25, 0x0A ; 10 - 2c3e: 08 f3 brcs .-62 ; 0x2c02 - 2c40: 8f 35 cpi r24, 0x5F ; 95 - 2c42: f9 f2 breq .-66 ; 0x2c02 - 2c44: 98 2f mov r25, r24 - 2c46: 9d 7f andi r25, 0xFD ; 253 - 2c48: 9d 33 cpi r25, 0x3D ; 61 - 2c4a: d9 f2 breq .-74 ; 0x2c02 - - /* Prevent buffer overflow and account for '\0' */ - if (BufferIdx < (sizeof(TerminalBuffer) / sizeof(*TerminalBuffer) - 1)) { - TerminalBuffer[BufferIdx++] = Byte; - } - }else if (Byte == '\r') { - 2c4c: 8d 30 cpi r24, 0x0D ; 13 - 2c4e: a9 f0 breq .+42 ; 0x2c7a - /* Process on \r. Terminate string and decode. */ - TerminalBuffer[BufferIdx] = '\0'; - BufferIdx = 0; - - DecodeCommand(); - }else if (Byte == '\b') { - 2c50: 88 30 cpi r24, 0x08 ; 8 - 2c52: 39 f0 breq .+14 ; 0x2c62 - /* Backspace. Delete last character in buffer. */ - if (BufferIdx > 0) { - BufferIdx--; - } - } else if (Byte == 0x1B){ - 2c54: 8b 31 cpi r24, 0x1B ; 27 - 2c56: 39 f7 brne .-50 ; 0x2c26 - /* Drop buffer on escape */ - BufferIdx = 0; - 2c58: 10 92 aa 28 sts 0x28AA, r1 - 2c5c: 10 92 ab 28 sts 0x28AB, r1 - 2c60: e2 cf rjmp .-60 ; 0x2c26 - BufferIdx = 0; - - DecodeCommand(); - }else if (Byte == '\b') { - /* Backspace. Delete last character in buffer. */ - if (BufferIdx > 0) { - 2c62: 80 91 aa 28 lds r24, 0x28AA - 2c66: 90 91 ab 28 lds r25, 0x28AB - 2c6a: 00 97 sbiw r24, 0x00 ; 0 - 2c6c: e1 f2 breq .-72 ; 0x2c26 - BufferIdx--; - 2c6e: 01 97 sbiw r24, 0x01 ; 1 - 2c70: 80 93 aa 28 sts 0x28AA, r24 - 2c74: 90 93 ab 28 sts 0x28AB, r25 - 2c78: d6 cf rjmp .-84 ; 0x2c26 - if (BufferIdx < (sizeof(TerminalBuffer) / sizeof(*TerminalBuffer) - 1)) { - TerminalBuffer[BufferIdx++] = Byte; - } - }else if (Byte == '\r') { - /* Process on \r. Terminate string and decode. */ - TerminalBuffer[BufferIdx] = '\0'; - 2c7a: e0 91 aa 28 lds r30, 0x28AA - 2c7e: f0 91 ab 28 lds r31, 0x28AB - 2c82: e4 5c subi r30, 0xC4 ; 196 - 2c84: f6 4d sbci r31, 0xD6 ; 214 - 2c86: 10 82 st Z, r1 - BufferIdx = 0; - 2c88: 10 92 aa 28 sts 0x28AA, r1 - 2c8c: 10 92 ab 28 sts 0x28AB, r1 - bool CommandFound = false; - CommandStatusIdType StatusId = COMMAND_ERR_UNKNOWN_CMD_ID; - char* pTerminalBuffer = (char*) TerminalBuffer; - - /* Do some sanity check first */ - if (!IS_COMMAND_DELIMITER(pTerminalBuffer[0])) { - 2c90: 80 91 3c 29 lds r24, 0x293C - 2c94: 88 23 and r24, r24 - 2c96: 31 f1 breq .+76 ; 0x2ce4 - 2c98: 8d 7f andi r24, 0xFD ; 253 - 2c9a: 8d 33 cpi r24, 0x3D ; 61 - 2c9c: 19 f1 breq .+70 ; 0x2ce4 - 2c9e: ed e3 ldi r30, 0x3D ; 61 - 2ca0: f9 e2 ldi r31, 0x29 ; 41 - 2ca2: 04 c0 rjmp .+8 ; 0x2cac - char* pCommandDelimiter = pTerminalBuffer; - char CommandDelimiter = '\0'; - - /* Search for command delimiter, store it and replace with '\0' */ - while(!(IS_COMMAND_DELIMITER(*pCommandDelimiter))) - 2ca4: 2f 33 cpi r18, 0x3F ; 63 - 2ca6: 31 f0 breq .+12 ; 0x2cb4 - 2ca8: 2d 33 cpi r18, 0x3D ; 61 - 2caa: 21 f0 breq .+8 ; 0x2cb4 - pCommandDelimiter++; - 2cac: 8f 01 movw r16, r30 - if (!IS_COMMAND_DELIMITER(pTerminalBuffer[0])) { - char* pCommandDelimiter = pTerminalBuffer; - char CommandDelimiter = '\0'; - - /* Search for command delimiter, store it and replace with '\0' */ - while(!(IS_COMMAND_DELIMITER(*pCommandDelimiter))) - 2cae: 21 91 ld r18, Z+ - 2cb0: 21 11 cpse r18, r1 - 2cb2: f8 cf rjmp .-16 ; 0x2ca4 - pCommandDelimiter++; - - CommandDelimiter = *pCommandDelimiter; - *pCommandDelimiter = '\0'; - 2cb4: f8 01 movw r30, r16 - 2cb6: 10 82 st Z, r1 - 2cb8: 83 e0 ldi r24, 0x03 ; 3 - 2cba: e8 2e mov r14, r24 - 2cbc: 88 e0 ldi r24, 0x08 ; 8 - 2cbe: f8 2e mov r15, r24 - - /* Search in command table */ - for (i=0; i<(sizeof(CommandTable) / sizeof(*CommandTable)); i++) { - if (strcmp_P(pTerminalBuffer, CommandTable[i].Command) == 0) { - 2cc0: b7 01 movw r22, r14 - 2cc2: 8c e3 ldi r24, 0x3C ; 60 - 2cc4: 99 e2 ldi r25, 0x29 ; 41 - 2cc6: 29 83 std Y+1, r18 ; 0x01 - 2cc8: 0e 94 ff 2b call 0x57fe ; 0x57fe - 2ccc: 29 81 ldd r18, Y+1 ; 0x01 - 2cce: 89 2b or r24, r25 - 2cd0: 09 f4 brne .+2 ; 0x2cd4 - 2cd2: 43 c0 rjmp .+134 ; 0x2d5a - 2cd4: f6 e1 ldi r31, 0x16 ; 22 - 2cd6: ef 0e add r14, r31 - 2cd8: f1 1c adc r15, r1 - - CommandDelimiter = *pCommandDelimiter; - *pCommandDelimiter = '\0'; - - /* Search in command table */ - for (i=0; i<(sizeof(CommandTable) / sizeof(*CommandTable)); i++) { - 2cda: 81 ed ldi r24, 0xD1 ; 209 - 2cdc: e8 16 cp r14, r24 - 2cde: 89 e0 ldi r24, 0x09 ; 9 - 2ce0: f8 06 cpc r15, r24 - 2ce2: 71 f7 brne .-36 ; 0x2cc0 - -static void DecodeCommand(void) -{ - uint8_t i; - bool CommandFound = false; - CommandStatusIdType StatusId = COMMAND_ERR_UNKNOWN_CMD_ID; - 2ce4: 88 ec ldi r24, 0xC8 ; 200 -} - -static void DecodeCommand(void) -{ - uint8_t i; - bool CommandFound = false; - 2ce6: 10 e0 ldi r17, 0x00 ; 0 -static const char* GetStatusMessageP(CommandStatusIdType StatusId) -{ - uint8_t i; - - for (i=0; i<(sizeof(StatusTable)/sizeof(*StatusTable)); i++) { - if (pgm_read_byte(&StatusTable[i].Id) == StatusId) - 2ce8: ed e3 ldi r30, 0x3D ; 61 - 2cea: f7 e0 ldi r31, 0x07 ; 7 - 2cec: e4 91 lpm r30, Z - 2cee: 8e 17 cp r24, r30 - 2cf0: 09 f4 brne .+2 ; 0x2cf4 - 2cf2: 70 c0 rjmp .+224 ; 0x2dd4 - 2cf4: ee e5 ldi r30, 0x5E ; 94 - 2cf6: f7 e0 ldi r31, 0x07 ; 7 - 2cf8: e4 91 lpm r30, Z - 2cfa: 8e 17 cp r24, r30 - 2cfc: 09 f4 brne .+2 ; 0x2d00 - 2cfe: 67 c0 rjmp .+206 ; 0x2dce - 2d00: ef e7 ldi r30, 0x7F ; 127 - 2d02: f7 e0 ldi r31, 0x07 ; 7 - 2d04: e4 91 lpm r30, Z - 2d06: 8e 17 cp r24, r30 - 2d08: 09 f4 brne .+2 ; 0x2d0c - 2d0a: 5e c0 rjmp .+188 ; 0x2dc8 - 2d0c: e0 ea ldi r30, 0xA0 ; 160 - 2d0e: f7 e0 ldi r31, 0x07 ; 7 - 2d10: e4 91 lpm r30, Z - 2d12: 8e 17 cp r24, r30 - 2d14: 09 f4 brne .+2 ; 0x2d18 - 2d16: 55 c0 rjmp .+170 ; 0x2dc2 - 2d18: e1 ec ldi r30, 0xC1 ; 193 - 2d1a: f7 e0 ldi r31, 0x07 ; 7 - 2d1c: e4 91 lpm r30, Z - 2d1e: 8e 17 cp r24, r30 - 2d20: 09 f4 brne .+2 ; 0x2d24 - 2d22: 4c c0 rjmp .+152 ; 0x2dbc - 2d24: e2 ee ldi r30, 0xE2 ; 226 - 2d26: f7 e0 ldi r31, 0x07 ; 7 - 2d28: e4 91 lpm r30, Z - 2d2a: 8e 17 cp r24, r30 - 2d2c: 09 f4 brne .+2 ; 0x2d30 - 2d2e: 3b c0 rjmp .+118 ; 0x2da6 - return StatusTable[i].Message; - } - - return (void*) 0; - 2d30: 80 e0 ldi r24, 0x00 ; 0 - 2d32: 90 e0 ldi r25, 0x00 ; 0 - } - } - } - - /* Send command status message */ - TerminalSendStringP(GetStatusMessageP(StatusId)); - 2d34: 6f da rcall .-2850 ; 0x2214 - TerminalSendStringP(PSTR(STATUS_MESSAGE_TRAILER)); - 2d36: 8a e3 ldi r24, 0x3A ; 58 - 2d38: 97 e0 ldi r25, 0x07 ; 7 - 2d3a: 6c da rcall .-2856 ; 0x2214 - - if (CommandFound && (pTerminalBuffer[0] != '\0') ) { - 2d3c: 11 23 and r17, r17 - 2d3e: 09 f4 brne .+2 ; 0x2d42 - 2d40: 72 cf rjmp .-284 ; 0x2c26 - 2d42: 80 91 3c 29 lds r24, 0x293C - 2d46: 88 23 and r24, r24 - 2d48: 09 f4 brne .+2 ; 0x2d4c - 2d4a: 6d cf rjmp .-294 ; 0x2c26 - /* Send optional answer */ - TerminalSendString(pTerminalBuffer); - 2d4c: 8c e3 ldi r24, 0x3C ; 60 - 2d4e: 99 e2 ldi r25, 0x29 ; 41 - 2d50: 5c da rcall .-2888 ; 0x220a - TerminalSendStringP(PSTR(OPTIONAL_ANSWER_TRAILER)); - 2d52: 87 e3 ldi r24, 0x37 ; 55 - 2d54: 97 e0 ldi r25, 0x07 ; 7 - 2d56: 5e da rcall .-2884 ; 0x2214 - 2d58: 66 cf rjmp .-308 ; 0x2c26 - for (i=0; i<(sizeof(CommandTable) / sizeof(*CommandTable)); i++) { - if (strcmp_P(pTerminalBuffer, CommandTable[i].Command) == 0) { - /* Command found. Clear buffer, and call appropriate function */ - char* pParam = ++pCommandDelimiter; - - pTerminalBuffer[0] = '\0'; - 2d5a: 10 92 3c 29 sts 0x293C, r1 -static CommandStatusIdType CallCommandFunc( - const CommandEntryType* CommandEntry, char CommandDelimiter, char* pParam) { - char* pTerminalBuffer = (char*) TerminalBuffer; - - /* Call appropriate function depending on CommandDelimiter */ - if (CommandDelimiter == CHAR_GET_MODE) { - 2d5e: 2f 33 cpi r18, 0x3F ; 63 - 2d60: b9 f0 breq .+46 ; 0x2d90 - CommandGetFuncType GetFunc = pgm_read_ptr(&CommandEntry->GetFunc); - if (GetFunc != NO_FUNCTION) { - return GetFunc(pTerminalBuffer); - } - } else if (CommandDelimiter == CHAR_SET_MODE) { - 2d62: 2d 33 cpi r18, 0x3D ; 61 - 2d64: 09 f4 brne .+2 ; 0x2d68 - 2d66: 39 c0 rjmp .+114 ; 0x2dda - CommandSetFuncType SetFunc = pgm_read_ptr(&CommandEntry->SetFunc); - if (SetFunc != NO_FUNCTION) { - return SetFunc(pParam); - } - } else if (CommandDelimiter == CHAR_EXEC_MODE){ - 2d68: 22 23 and r18, r18 - 2d6a: 19 f0 breq .+6 ; 0x2d72 - } else { - /* This should not happen (TM) */ - } - - /* This delimiter has not been registered with this command */ - return COMMAND_ERR_INVALID_USAGE_ID; - 2d6c: 89 ec ldi r24, 0xC9 ; 201 - if (strcmp_P(pTerminalBuffer, CommandTable[i].Command) == 0) { - /* Command found. Clear buffer, and call appropriate function */ - char* pParam = ++pCommandDelimiter; - - pTerminalBuffer[0] = '\0'; - CommandFound = true; - 2d6e: 11 e0 ldi r17, 0x01 ; 1 - 2d70: bb cf rjmp .-138 ; 0x2ce8 - CommandSetFuncType SetFunc = pgm_read_ptr(&CommandEntry->SetFunc); - if (SetFunc != NO_FUNCTION) { - return SetFunc(pParam); - } - } else if (CommandDelimiter == CHAR_EXEC_MODE){ - CommandExecFuncType ExecFunc = pgm_read_ptr(&CommandEntry->ExecFunc); - 2d72: 97 01 movw r18, r14 - 2d74: 20 5f subi r18, 0xF0 ; 240 - 2d76: 3f 4f sbci r19, 0xFF ; 255 - 2d78: f9 01 movw r30, r18 - 2d7a: 45 91 lpm r20, Z+ - 2d7c: 54 91 lpm r21, Z - if (ExecFunc != NO_FUNCTION) { - 2d7e: 41 15 cp r20, r1 - 2d80: 51 05 cpc r21, r1 - 2d82: a1 f3 breq .-24 ; 0x2d6c - return ExecFunc(pTerminalBuffer); - 2d84: 8c e3 ldi r24, 0x3C ; 60 - 2d86: 99 e2 ldi r25, 0x29 ; 41 - 2d88: fa 01 movw r30, r20 - 2d8a: 09 95 icall - if (strcmp_P(pTerminalBuffer, CommandTable[i].Command) == 0) { - /* Command found. Clear buffer, and call appropriate function */ - char* pParam = ++pCommandDelimiter; - - pTerminalBuffer[0] = '\0'; - CommandFound = true; - 2d8c: 11 e0 ldi r17, 0x01 ; 1 - 2d8e: ac cf rjmp .-168 ; 0x2ce8 - const CommandEntryType* CommandEntry, char CommandDelimiter, char* pParam) { - char* pTerminalBuffer = (char*) TerminalBuffer; - - /* Call appropriate function depending on CommandDelimiter */ - if (CommandDelimiter == CHAR_GET_MODE) { - CommandGetFuncType GetFunc = pgm_read_ptr(&CommandEntry->GetFunc); - 2d90: 97 01 movw r18, r14 - 2d92: 2c 5e subi r18, 0xEC ; 236 - 2d94: 3f 4f sbci r19, 0xFF ; 255 - 2d96: f9 01 movw r30, r18 - 2d98: 45 91 lpm r20, Z+ - 2d9a: 54 91 lpm r21, Z - if (GetFunc != NO_FUNCTION) { - 2d9c: 41 15 cp r20, r1 - 2d9e: 51 05 cpc r21, r1 - 2da0: 89 f7 brne .-30 ; 0x2d84 - } else { - /* This should not happen (TM) */ - } - - /* This delimiter has not been registered with this command */ - return COMMAND_ERR_INVALID_USAGE_ID; - 2da2: 89 ec ldi r24, 0xC9 ; 201 - 2da4: e4 cf rjmp .-56 ; 0x2d6e -static const char* GetStatusMessageP(CommandStatusIdType StatusId) -{ - uint8_t i; - - for (i=0; i<(sizeof(StatusTable)/sizeof(*StatusTable)); i++) { - if (pgm_read_byte(&StatusTable[i].Id) == StatusId) - 2da6: 25 e0 ldi r18, 0x05 ; 5 - 2da8: 30 e0 ldi r19, 0x00 ; 0 - return StatusTable[i].Message; - 2daa: 41 e2 ldi r20, 0x21 ; 33 - 2dac: 42 9f mul r20, r18 - 2dae: c0 01 movw r24, r0 - 2db0: 43 9f mul r20, r19 - 2db2: 90 0d add r25, r0 - 2db4: 11 24 eor r1, r1 - 2db6: 82 5c subi r24, 0xC2 ; 194 - 2db8: 98 4f sbci r25, 0xF8 ; 248 - 2dba: bc cf rjmp .-136 ; 0x2d34 -static const char* GetStatusMessageP(CommandStatusIdType StatusId) -{ - uint8_t i; - - for (i=0; i<(sizeof(StatusTable)/sizeof(*StatusTable)); i++) { - if (pgm_read_byte(&StatusTable[i].Id) == StatusId) - 2dbc: 24 e0 ldi r18, 0x04 ; 4 - 2dbe: 30 e0 ldi r19, 0x00 ; 0 - 2dc0: f4 cf rjmp .-24 ; 0x2daa - 2dc2: 23 e0 ldi r18, 0x03 ; 3 - 2dc4: 30 e0 ldi r19, 0x00 ; 0 - 2dc6: f1 cf rjmp .-30 ; 0x2daa - 2dc8: 22 e0 ldi r18, 0x02 ; 2 - 2dca: 30 e0 ldi r19, 0x00 ; 0 - 2dcc: ee cf rjmp .-36 ; 0x2daa - 2dce: 21 e0 ldi r18, 0x01 ; 1 - 2dd0: 30 e0 ldi r19, 0x00 ; 0 - 2dd2: eb cf rjmp .-42 ; 0x2daa - 2dd4: 20 e0 ldi r18, 0x00 ; 0 - 2dd6: 30 e0 ldi r19, 0x00 ; 0 - 2dd8: e8 cf rjmp .-48 ; 0x2daa - CommandGetFuncType GetFunc = pgm_read_ptr(&CommandEntry->GetFunc); - if (GetFunc != NO_FUNCTION) { - return GetFunc(pTerminalBuffer); - } - } else if (CommandDelimiter == CHAR_SET_MODE) { - CommandSetFuncType SetFunc = pgm_read_ptr(&CommandEntry->SetFunc); - 2dda: 97 01 movw r18, r14 - 2ddc: 2e 5e subi r18, 0xEE ; 238 - 2dde: 3f 4f sbci r19, 0xFF ; 255 - 2de0: f9 01 movw r30, r18 - 2de2: 45 91 lpm r20, Z+ - 2de4: 54 91 lpm r21, Z - if (SetFunc != NO_FUNCTION) { - 2de6: 41 15 cp r20, r1 - 2de8: 51 05 cpc r21, r1 - 2dea: 09 f4 brne .+2 ; 0x2dee - 2dec: bf cf rjmp .-130 ; 0x2d6c - return SetFunc(pParam); - 2dee: c8 01 movw r24, r16 - 2df0: 01 96 adiw r24, 0x01 ; 1 - 2df2: fa 01 movw r30, r20 - 2df4: 09 95 icall - if (strcmp_P(pTerminalBuffer, CommandTable[i].Command) == 0) { - /* Command found. Clear buffer, and call appropriate function */ - char* pParam = ++pCommandDelimiter; - - pTerminalBuffer[0] = '\0'; - CommandFound = true; - 2df6: 11 e0 ldi r17, 0x01 ; 1 - 2df8: 77 cf rjmp .-274 ; 0x2ce8 - -00002dfa : - - return true; -} - -void CommandLineTick(void) -{ - 2dfa: 08 95 ret - -00002dfc : -INLINE void CodecTask(void) { - ActiveConfiguration.CodecTaskFunc(); -} - -INLINE void CodecSetDemodPower(bool bOnOff) { - CODEC_DEMOD_POWER_PORT.DIRSET = CODEC_DEMOD_POWER_MASK; - 2dfc: a0 e2 ldi r26, 0x20 ; 32 - 2dfe: b6 e0 ldi r27, 0x06 ; 6 - 2e00: 82 e0 ldi r24, 0x02 ; 2 - 2e02: 11 96 adiw r26, 0x01 ; 1 - 2e04: 8c 93 st X, r24 - 2e06: 11 97 sbiw r26, 0x01 ; 1 - - if (bOnOff) { - CODEC_DEMOD_POWER_PORT.OUTSET = CODEC_DEMOD_POWER_MASK; - 2e08: 15 96 adiw r26, 0x05 ; 5 - 2e0a: 8c 93 st X, r24 - 2e0c: 15 97 sbiw r26, 0x05 ; 5 - -static void StartDemod(void) { - /* Activate Power for demodulator */ - CodecSetDemodPower(true); - - CodecBufferPtr = CodecBuffer; - 2e0e: 8c e3 ldi r24, 0x3C ; 60 - 2e10: 9a e2 ldi r25, 0x2A ; 42 - 2e12: 80 93 b8 28 sts 0x28B8, r24 - 2e16: 90 93 b9 28 sts 0x28B9, r25 - ParityBufferPtr = &CodecBuffer[ISO14443A_BUFFER_PARITY_OFFSET]; - 2e1a: 8c eb ldi r24, 0xBC ; 188 - 2e1c: 9a e2 ldi r25, 0x2A ; 42 - 2e1e: 80 93 b6 28 sts 0x28B6, r24 - 2e22: 90 93 b7 28 sts 0x28B7, r25 - DataRegister = 0; - 2e26: 10 92 b1 28 sts 0x28B1, r1 - SampleRegister = 0; - 2e2a: 10 92 b0 28 sts 0x28B0, r1 - SamplePosition = 0; - 2e2e: 10 92 ac 28 sts 0x28AC, r1 - BitCount = 0; - 2e32: 10 92 b4 28 sts 0x28B4, r1 - 2e36: 10 92 b5 28 sts 0x28B5, r1 - IsParityBit = false; - 2e3a: 10 92 af 28 sts 0x28AF, r1 - - /* Configure sampling-timer free running and sync to first modulation-pause. */ - CODEC_TIMER_SAMPLING.CNT = 0; - 2e3e: e0 e4 ldi r30, 0x40 ; 64 - 2e40: f8 e0 ldi r31, 0x08 ; 8 - 2e42: 10 a2 std Z+32, r1 ; 0x20 - 2e44: 11 a2 std Z+33, r1 ; 0x21 - CODEC_TIMER_SAMPLING.PER = SAMPLE_RATE_SYSTEM_CYCLES - 1; - 2e46: 8d e2 ldi r24, 0x2D ; 45 - 2e48: 91 e0 ldi r25, 0x01 ; 1 - 2e4a: 86 a3 std Z+38, r24 ; 0x26 - 2e4c: 97 a3 std Z+39, r25 ; 0x27 - CODEC_TIMER_SAMPLING.CCA = 0xFFFF; /* CCA Interrupt is not active! */ - 2e4e: 8f ef ldi r24, 0xFF ; 255 - 2e50: 9f ef ldi r25, 0xFF ; 255 - 2e52: 80 a7 std Z+40, r24 ; 0x28 - 2e54: 91 a7 std Z+41, r25 ; 0x29 - CODEC_TIMER_SAMPLING.CTRLA = TC_CLKSEL_DIV1_gc; - 2e56: 81 e0 ldi r24, 0x01 ; 1 - 2e58: 80 83 st Z, r24 - CODEC_TIMER_SAMPLING.CTRLD = TC_EVACT_RESTART_gc | TC_EVSEL_CH0_gc; - 2e5a: 88 e8 ldi r24, 0x88 ; 136 - 2e5c: 83 83 std Z+3, r24 ; 0x03 - CODEC_TIMER_SAMPLING.INTCTRLB = TC_CCAINTLVL_HI_gc; - 2e5e: 83 e0 ldi r24, 0x03 ; 3 - 2e60: 87 83 std Z+7, r24 ; 0x07 - - /* Start looking out for modulation pause via interrupt. */ - CODEC_DEMOD_IN_PORT.INT0MASK = CODEC_DEMOD_IN_MASK0; - 2e62: 84 e0 ldi r24, 0x04 ; 4 - 2e64: 1a 96 adiw r26, 0x0a ; 10 - 2e66: 8c 93 st X, r24 - SLEEP.CTRL &= ~SLEEP_SEN_bm; -} - -INLINE void SystemSleepSetMode(uint8_t SleepMode) -{ - SLEEP.CTRL = (SLEEP.CTRL & ~SLEEP_SMODE_gm) | SleepMode; - 2e68: e8 e4 ldi r30, 0x48 ; 72 - 2e6a: f0 e0 ldi r31, 0x00 ; 0 - 2e6c: 80 81 ld r24, Z - 2e6e: 81 7f andi r24, 0xF1 ; 241 - 2e70: 86 60 ori r24, 0x06 ; 6 - 2e72: 80 83 st Z, r24 - 2e74: 08 95 ret - -00002e76 <__vector_34>: - SystemSleepSetMode(SYSTEM_SMODE_PSAVE); -} - -ISR(CODEC_DEMOD_IN_INT0_VECT) { - 2e76: 1f 92 push r1 - 2e78: 0f 92 push r0 - 2e7a: 0f b6 in r0, 0x3f ; 63 - 2e7c: 0f 92 push r0 - 2e7e: 11 24 eor r1, r1 - 2e80: 8f 93 push r24 - 2e82: 9f 93 push r25 - 2e84: ef 93 push r30 - 2e86: ff 93 push r31 - 2e88: e8 e4 ldi r30, 0x48 ; 72 - 2e8a: f0 e0 ldi r31, 0x00 ; 0 - 2e8c: 80 81 ld r24, Z - 2e8e: 81 7f andi r24, 0xF1 ; 241 - 2e90: 80 83 st Z, r24 - * XYZBUF mechanism of the xmega to automatically double the sampling rate on the - * next overflow. For this we have to temporarily deactivate the automatical alignment - * in order to catch next overflow event for updating the BUF registers. - * We want to sample the demodulated data stream in the first quarter of the half-bit - * where the pulsed miller encoded is located. */ - CODEC_TIMER_SAMPLING.CTRLD = TC_EVACT_OFF_gc; - 2e92: e0 e4 ldi r30, 0x40 ; 64 - 2e94: f8 e0 ldi r31, 0x08 ; 8 - 2e96: 13 82 std Z+3, r1 ; 0x03 - CODEC_TIMER_SAMPLING.PERBUF = SAMPLE_RATE_SYSTEM_CYCLES/2 - 1; /* Half bit width */ - 2e98: 86 e9 ldi r24, 0x96 ; 150 - 2e9a: 90 e0 ldi r25, 0x00 ; 0 - 2e9c: 86 ab std Z+54, r24 ; 0x36 - 2e9e: 97 ab std Z+55, r25 ; 0x37 - CODEC_TIMER_SAMPLING.CCABUF = SAMPLE_RATE_SYSTEM_CYCLES/8 - 10 - 1; /* Compensate for DIGFILT and ISR prolog */ - 2ea0: 8a e1 ldi r24, 0x1A ; 26 - 2ea2: 90 e0 ldi r25, 0x00 ; 0 - 2ea4: 80 af std Z+56, r24 ; 0x38 - 2ea6: 91 af std Z+57, r25 ; 0x39 - /* Setup Frame Delay Timer and wire to EVSYS. Frame delay time is - * measured from last change in RF field, therefore we use - * the event channel 1 (end of modulation pause) as the restart event. - * The preliminary frame delay time chosen here is irrelevant, because - * the correct FDT gets set automatically after demodulation. */ - CODEC_TIMER_LOADMOD.CNT = 0; - 2ea8: e0 e4 ldi r30, 0x40 ; 64 - 2eaa: f9 e0 ldi r31, 0x09 ; 9 - 2eac: 10 a2 std Z+32, r1 ; 0x20 - 2eae: 11 a2 std Z+33, r1 ; 0x21 - CODEC_TIMER_LOADMOD.PER = 0xFFFF; - 2eb0: 8f ef ldi r24, 0xFF ; 255 - 2eb2: 9f ef ldi r25, 0xFF ; 255 - 2eb4: 86 a3 std Z+38, r24 ; 0x26 - 2eb6: 97 a3 std Z+39, r25 ; 0x27 - CODEC_TIMER_LOADMOD.CTRLD = TC_EVACT_RESTART_gc | TC_EVSEL_CH1_gc; - 2eb8: 89 e8 ldi r24, 0x89 ; 137 - 2eba: 83 83 std Z+3, r24 ; 0x03 - CODEC_TIMER_LOADMOD.CTRLA = TC_CLKSEL_EVCH6_gc; - 2ebc: 8e e0 ldi r24, 0x0E ; 14 - 2ebe: 80 83 st Z, r24 - - /* Disable this interrupt */ - CODEC_DEMOD_IN_PORT.INT0MASK = 0; - 2ec0: e0 e2 ldi r30, 0x20 ; 32 - 2ec2: f6 e0 ldi r31, 0x06 ; 6 - 2ec4: 12 86 std Z+10, r1 ; 0x0a -} - 2ec6: ff 91 pop r31 - 2ec8: ef 91 pop r30 - 2eca: 9f 91 pop r25 - 2ecc: 8f 91 pop r24 - 2ece: 0f 90 pop r0 - 2ed0: 0f be out 0x3f, r0 ; 63 - 2ed2: 0f 90 pop r0 - 2ed4: 1f 90 pop r1 - 2ed6: 18 95 reti - -00002ed8 <__vector_22>: - -ISR(CODEC_TIMER_SAMPLING_CCA_VECT) { - 2ed8: 1f 92 push r1 - 2eda: 0f 92 push r0 - 2edc: 0f b6 in r0, 0x3f ; 63 - 2ede: 0f 92 push r0 - 2ee0: 11 24 eor r1, r1 - 2ee2: 2f 93 push r18 - 2ee4: 3f 93 push r19 - 2ee6: 4f 93 push r20 - 2ee8: 8f 93 push r24 - 2eea: 9f 93 push r25 - 2eec: ef 93 push r30 - 2eee: ff 93 push r31 - /* This interrupt gets called twice for every bit to sample it. */ - uint8_t SamplePin = CODEC_DEMOD_IN_PORT.IN & CODEC_DEMOD_IN_MASK; - 2ef0: 90 91 28 06 lds r25, 0x0628 - uint8_t NewSampleRegister; - - /* Shift sampled bit into sampling register and hold a local copy for fast access. */ - NewSampleRegister = SampleRegister << 1; - 2ef4: 80 91 b0 28 lds r24, 0x28B0 - CODEC_DEMOD_IN_PORT.INT0MASK = 0; -} - -ISR(CODEC_TIMER_SAMPLING_CCA_VECT) { - /* This interrupt gets called twice for every bit to sample it. */ - uint8_t SamplePin = CODEC_DEMOD_IN_PORT.IN & CODEC_DEMOD_IN_MASK; - 2ef8: 95 70 andi r25, 0x05 ; 5 - uint8_t NewSampleRegister; - - /* Shift sampled bit into sampling register and hold a local copy for fast access. */ - NewSampleRegister = SampleRegister << 1; - NewSampleRegister |= (!SamplePin ? 0x01 : 0x00); - 2efa: 21 e0 ldi r18, 0x01 ; 1 - 2efc: 09 f0 breq .+2 ; 0x2f00 <__vector_22+0x28> - 2efe: 20 e0 ldi r18, 0x00 ; 0 - /* This interrupt gets called twice for every bit to sample it. */ - uint8_t SamplePin = CODEC_DEMOD_IN_PORT.IN & CODEC_DEMOD_IN_MASK; - uint8_t NewSampleRegister; - - /* Shift sampled bit into sampling register and hold a local copy for fast access. */ - NewSampleRegister = SampleRegister << 1; - 2f00: 88 0f add r24, r24 - NewSampleRegister |= (!SamplePin ? 0x01 : 0x00); - 2f02: 82 2b or r24, r18 - SampleRegister = NewSampleRegister; - 2f04: 80 93 b0 28 sts 0x28B0, r24 - - if (SamplePosition) { - 2f08: 90 91 ac 28 lds r25, 0x28AC - 2f0c: 99 23 and r25, r25 - 2f0e: c1 f1 breq .+112 ; 0x2f80 <__vector_22+0xa8> - /* Analyze the sampling register after 2 samples. */ - if ((NewSampleRegister & 0x07) == 0x07) { - 2f10: 98 2f mov r25, r24 - 2f12: 97 70 andi r25, 0x07 ; 7 - 2f14: 97 30 cpi r25, 0x07 ; 7 - 2f16: 09 f4 brne .+2 ; 0x2f1a <__vector_22+0x42> - 2f18: 48 c0 rjmp .+144 ; 0x2faa <__vector_22+0xd2> - - /* Signal, that we have finished sampling */ - Flags.DemodFinished = 1; - } else { - /* Otherwise, we check the two sample bits from the bit before. */ - uint8_t BitSample = NewSampleRegister & 0xC; - 2f1a: 98 2f mov r25, r24 - 2f1c: 9c 70 andi r25, 0x0C ; 12 - uint8_t Bit = 0; - - if (BitSample != (0x0 << 2)) { - 2f1e: 81 f1 breq .+96 ; 0x2f80 <__vector_22+0xa8> - /* We have a valid bit. decode and process it. */ - if (BitSample & (0x1 << 2)) { - 2f20: 82 fb bst r24, 2 - 2f22: 88 27 eor r24, r24 - 2f24: 80 f9 bld r24, 0 - 2f26: 91 e0 ldi r25, 0x01 ; 1 - 2f28: 89 27 eor r24, r25 - } else { - /* 10 sequence -> This is a one bit */ - Bit = 1; - } - - LastBit = Bit; - 2f2a: 80 93 ae 28 sts 0x28AE, r24 - - if (!IsParityBit) { - 2f2e: 90 91 af 28 lds r25, 0x28AF - 2f32: 91 11 cpse r25, r1 - 2f34: 7f c0 rjmp .+254 ; 0x3034 <__stack+0x35> - /* This is a data bit, so shift it into the data register and - * hold a local copy of it. */ - uint8_t NewDataRegister = DataRegister >> 1; - 2f36: 90 91 b1 28 lds r25, 0x28B1 - 2f3a: 96 95 lsr r25 - NewDataRegister |= (Bit ? 0x80 : 0x00); - 2f3c: 88 23 and r24, r24 - 2f3e: 09 f4 brne .+2 ; 0x2f42 <__vector_22+0x6a> - 2f40: 83 c0 rjmp .+262 ; 0x3048 <__stack+0x49> - 2f42: 20 e8 ldi r18, 0x80 ; 128 - 2f44: 29 2b or r18, r25 - DataRegister = NewDataRegister; - 2f46: 20 93 b1 28 sts 0x28B1, r18 - - /* Update bitcount */ - uint16_t NewBitCount = ++BitCount; - 2f4a: 80 91 b4 28 lds r24, 0x28B4 - 2f4e: 90 91 b5 28 lds r25, 0x28B5 - 2f52: 01 96 adiw r24, 0x01 ; 1 - 2f54: 80 93 b4 28 sts 0x28B4, r24 - 2f58: 90 93 b5 28 sts 0x28B5, r25 - if ((NewBitCount & 0x07) == 0) { - 2f5c: 87 70 andi r24, 0x07 ; 7 - 2f5e: 99 27 eor r25, r25 - 2f60: 89 2b or r24, r25 - 2f62: 71 f4 brne .+28 ; 0x2f80 <__vector_22+0xa8> - /* We have reached a byte boundary! Store the data register. */ - /* TODO: Prevent buffer overflow */ - *CodecBufferPtr++ = NewDataRegister; - 2f64: e0 91 b8 28 lds r30, 0x28B8 - 2f68: f0 91 b9 28 lds r31, 0x28B9 - 2f6c: cf 01 movw r24, r30 - 2f6e: 01 96 adiw r24, 0x01 ; 1 - 2f70: 80 93 b8 28 sts 0x28B8, r24 - 2f74: 90 93 b9 28 sts 0x28B9, r25 - 2f78: 20 83 st Z, r18 - - /* Store bit for determining FDT at EOC and enable parity - * handling on next bit. */ - IsParityBit = true; - 2f7a: 81 e0 ldi r24, 0x01 ; 1 - 2f7c: 80 93 af 28 sts 0x28AF, r24 - } - } else { - /* On odd sample position just sample. */ - } - - SamplePosition = !SamplePosition; - 2f80: 80 91 ac 28 lds r24, 0x28AC - 2f84: 91 e0 ldi r25, 0x01 ; 1 - 2f86: 89 27 eor r24, r25 - 2f88: 80 93 ac 28 sts 0x28AC, r24 - - /* Make sure the sampling timer gets automatically aligned to the - * modulation pauses by using the RESTART event. - * This can be understood as a "poor mans PLL" and makes sure that we are - * never too far out the bit-grid while sampling. */ - CODEC_TIMER_SAMPLING.CTRLD = TC_EVACT_RESTART_gc | TC_EVSEL_CH0_gc; - 2f8c: 88 e8 ldi r24, 0x88 ; 136 - 2f8e: 80 93 43 08 sts 0x0843, r24 -} - 2f92: ff 91 pop r31 - 2f94: ef 91 pop r30 - 2f96: 9f 91 pop r25 - 2f98: 8f 91 pop r24 - 2f9a: 4f 91 pop r20 - 2f9c: 3f 91 pop r19 - 2f9e: 2f 91 pop r18 - 2fa0: 0f 90 pop r0 - 2fa2: 0f be out 0x3f, r0 ; 63 - 2fa4: 0f 90 pop r0 - 2fa6: 1f 90 pop r1 - 2fa8: 18 95 reti - - if (SamplePosition) { - /* Analyze the sampling register after 2 samples. */ - if ((NewSampleRegister & 0x07) == 0x07) { - /* No carrier modulation for 3 sample points. EOC! */ - CODEC_TIMER_SAMPLING.CTRLA = TC_CLKSEL_OFF_gc; - 2faa: 10 92 40 08 sts 0x0840, r1 - CODEC_TIMER_SAMPLING.INTFLAGS = TC0_CCAIF_bm; - 2fae: 80 e1 ldi r24, 0x10 ; 16 - 2fb0: 80 93 4c 08 sts 0x084C, r24 - - /* By this time, the FDT timer is aligned to the last modulation - * edge of the reader. So we disable the auto-synchronization and - * let it count the frame delay time in the background, and generate - * an interrupt once it has reached the FDT. */ - CODEC_TIMER_LOADMOD.CTRLD = TC_EVACT_OFF_gc; - 2fb4: 10 92 43 09 sts 0x0943, r1 - - if (LastBit) { - 2fb8: 80 91 ae 28 lds r24, 0x28AE - 2fbc: 88 23 and r24, r24 - 2fbe: e9 f1 breq .+122 ; 0x303a <__stack+0x3b> - CODEC_TIMER_LOADMOD.PER = ISO14443A_FRAME_DELAY_PREV1; - 2fc0: 8c eb ldi r24, 0xBC ; 188 - 2fc2: 94 e0 ldi r25, 0x04 ; 4 - 2fc4: 80 93 66 09 sts 0x0966, r24 - 2fc8: 90 93 67 09 sts 0x0967, r25 - } else { - CODEC_TIMER_LOADMOD.PER = ISO14443A_FRAME_DELAY_PREV0; - } - - LoadModState = LOADMOD_FDT; - 2fcc: 10 92 ad 28 sts 0x28AD, r1 - - CODEC_TIMER_LOADMOD.INTFLAGS = TC1_OVFIF_bm; - 2fd0: 81 e0 ldi r24, 0x01 ; 1 - 2fd2: 80 93 4c 09 sts 0x094C, r24 - CODEC_TIMER_LOADMOD.INTCTRLA = TC_OVFINTLVL_HI_gc; - 2fd6: 83 e0 ldi r24, 0x03 ; 3 - 2fd8: 80 93 46 09 sts 0x0946, r24 - - /* Determine if we did not receive a multiple of 8 bits. - * If this is the case, right-align the remaining data and - * store it into the buffer. */ - uint8_t RemainingBits = BitCount % 8; - 2fdc: 80 91 b4 28 lds r24, 0x28B4 - 2fe0: 90 91 b5 28 lds r25, 0x28B5 - 2fe4: 87 70 andi r24, 0x07 ; 7 - if (RemainingBits != 0) { - 2fe6: 11 f1 breq .+68 ; 0x302c <__stack+0x2d> - uint8_t NewDataRegister = DataRegister; - 2fe8: 90 91 b1 28 lds r25, 0x28B1 - - while (RemainingBits++ < 8) { - /* Pad with zeroes to right-align. */ - NewDataRegister >>= 1; - 2fec: 96 95 lsr r25 - * store it into the buffer. */ - uint8_t RemainingBits = BitCount % 8; - if (RemainingBits != 0) { - uint8_t NewDataRegister = DataRegister; - - while (RemainingBits++ < 8) { - 2fee: 22 e0 ldi r18, 0x02 ; 2 - 2ff0: 28 0f add r18, r24 - 2ff2: 87 30 cpi r24, 0x07 ; 7 - 2ff4: b1 f0 breq .+44 ; 0x3022 <__stack+0x23> - /* Pad with zeroes to right-align. */ - NewDataRegister >>= 1; - 2ff6: 96 95 lsr r25 - * store it into the buffer. */ - uint8_t RemainingBits = BitCount % 8; - if (RemainingBits != 0) { - uint8_t NewDataRegister = DataRegister; - - while (RemainingBits++ < 8) { - 2ff8: 43 e0 ldi r20, 0x03 ; 3 - 2ffa: 48 0f add r20, r24 - 2ffc: 28 30 cpi r18, 0x08 ; 8 - 2ffe: 88 f4 brcc .+34 ; 0x3022 <__stack+0x23> - /* Pad with zeroes to right-align. */ - NewDataRegister >>= 1; - 3000: 96 95 lsr r25 - * store it into the buffer. */ - uint8_t RemainingBits = BitCount % 8; - if (RemainingBits != 0) { - uint8_t NewDataRegister = DataRegister; - - while (RemainingBits++ < 8) { - 3002: 34 e0 ldi r19, 0x04 ; 4 - 3004: 38 0f add r19, r24 - 3006: 48 30 cpi r20, 0x08 ; 8 - 3008: 60 f4 brcc .+24 ; 0x3022 <__stack+0x23> - /* Pad with zeroes to right-align. */ - NewDataRegister >>= 1; - 300a: 96 95 lsr r25 - * store it into the buffer. */ - uint8_t RemainingBits = BitCount % 8; - if (RemainingBits != 0) { - uint8_t NewDataRegister = DataRegister; - - while (RemainingBits++ < 8) { - 300c: 25 e0 ldi r18, 0x05 ; 5 - 300e: 28 0f add r18, r24 - 3010: 38 30 cpi r19, 0x08 ; 8 - 3012: 38 f4 brcc .+14 ; 0x3022 <__stack+0x23> - /* Pad with zeroes to right-align. */ - NewDataRegister >>= 1; - 3014: 96 95 lsr r25 - * store it into the buffer. */ - uint8_t RemainingBits = BitCount % 8; - if (RemainingBits != 0) { - uint8_t NewDataRegister = DataRegister; - - while (RemainingBits++ < 8) { - 3016: 28 30 cpi r18, 0x08 ; 8 - 3018: 20 f4 brcc .+8 ; 0x3022 <__stack+0x23> - /* Pad with zeroes to right-align. */ - NewDataRegister >>= 1; - 301a: 96 95 lsr r25 - * store it into the buffer. */ - uint8_t RemainingBits = BitCount % 8; - if (RemainingBits != 0) { - uint8_t NewDataRegister = DataRegister; - - while (RemainingBits++ < 8) { - 301c: 81 30 cpi r24, 0x01 ; 1 - 301e: 09 f4 brne .+2 ; 0x3022 <__stack+0x23> - /* Pad with zeroes to right-align. */ - NewDataRegister >>= 1; - 3020: 96 95 lsr r25 - } - - /* TODO: Prevent buffer overflow */ - *CodecBufferPtr = NewDataRegister; - 3022: e0 91 b8 28 lds r30, 0x28B8 - 3026: f0 91 b9 28 lds r31, 0x28B9 - 302a: 90 83 st Z, r25 - } - - /* Signal, that we have finished sampling */ - Flags.DemodFinished = 1; - 302c: 81 e0 ldi r24, 0x01 ; 1 - 302e: 80 93 ba 28 sts 0x28BA, r24 - 3032: a6 cf rjmp .-180 ; 0x2f80 <__vector_22+0xa8> - - } else { - /* This is a parity bit. Store it */ - /* TODO: Store parity and prevent overflow */ - //*ParityBufferPtr++ = Bit; - IsParityBit = false; - 3034: 10 92 af 28 sts 0x28AF, r1 - 3038: a3 cf rjmp .-186 ; 0x2f80 <__vector_22+0xa8> - CODEC_TIMER_LOADMOD.CTRLD = TC_EVACT_OFF_gc; - - if (LastBit) { - CODEC_TIMER_LOADMOD.PER = ISO14443A_FRAME_DELAY_PREV1; - } else { - CODEC_TIMER_LOADMOD.PER = ISO14443A_FRAME_DELAY_PREV0; - 303a: 8c e7 ldi r24, 0x7C ; 124 - 303c: 94 e0 ldi r25, 0x04 ; 4 - 303e: 80 93 66 09 sts 0x0966, r24 - 3042: 90 93 67 09 sts 0x0967, r25 - 3046: c2 cf rjmp .-124 ; 0x2fcc <__vector_22+0xf4> - - if (!IsParityBit) { - /* This is a data bit, so shift it into the data register and - * hold a local copy of it. */ - uint8_t NewDataRegister = DataRegister >> 1; - NewDataRegister |= (Bit ? 0x80 : 0x00); - 3048: 20 e0 ldi r18, 0x00 ; 0 - 304a: 7c cf rjmp .-264 ; 0x2f44 <__vector_22+0x6c> - -0000304c <__vector_83>: - * This can be understood as a "poor mans PLL" and makes sure that we are - * never too far out the bit-grid while sampling. */ - CODEC_TIMER_SAMPLING.CTRLD = TC_EVACT_RESTART_gc | TC_EVSEL_CH0_gc; -} - -ISR(CODEC_TIMER_OVF_VECT) { - 304c: 1f 92 push r1 - 304e: 0f 92 push r0 - 3050: 0f b6 in r0, 0x3f ; 63 - 3052: 0f 92 push r0 - 3054: 11 24 eor r1, r1 - 3056: 2f 93 push r18 - 3058: 3f 93 push r19 - 305a: 8f 93 push r24 - 305c: 9f 93 push r25 - 305e: af 93 push r26 - 3060: bf 93 push r27 - 3062: ef 93 push r30 - 3064: ff 93 push r31 - /* Bit rate timer. Output a half bit on the output. */ - uint8_t Temp8; - uint16_t Temp16; - - switch (LoadModState) { - 3066: 80 91 ad 28 lds r24, 0x28AD - 306a: 90 e0 ldi r25, 0x00 ; 0 - 306c: 8b 30 cpi r24, 0x0B ; 11 - 306e: 91 05 cpc r25, r1 - 3070: 80 f5 brcc .+96 ; 0x30d2 <__vector_83+0x86> - 3072: fc 01 movw r30, r24 - 3074: e9 5a subi r30, 0xA9 ; 169 - 3076: fe 4f sbci r31, 0xFE ; 254 - 3078: 0c 94 7a 2b jmp 0x56f4 ; 0x56f4 <__tablejump2__> - - LoadModState = LOADMOD_PARITY1; - break; - - case LOADMOD_PARITY1: - if (*ParityBufferPtr) { - 307c: e0 91 b6 28 lds r30, 0x28B6 - 3080: f0 91 b7 28 lds r31, 0x28B7 - 3084: 80 81 ld r24, Z - 3086: 81 11 cpse r24, r1 - 3088: ac c0 rjmp .+344 ; 0x31e2 <__vector_83+0x196> - CODEC_LOADMOD_PORT.OUTCLR = CODEC_LOADMOD_MASK; - } else { - CODEC_LOADMOD_PORT.OUTSET = CODEC_LOADMOD_MASK; - 308a: 80 e4 ldi r24, 0x40 ; 64 - 308c: 80 93 45 06 sts 0x0645, r24 - } - - if (BitSent == BitCount) { - 3090: 20 91 b2 28 lds r18, 0x28B2 - 3094: 30 91 b3 28 lds r19, 0x28B3 - 3098: 80 91 b4 28 lds r24, 0x28B4 - 309c: 90 91 b5 28 lds r25, 0x28B5 - 30a0: 28 17 cp r18, r24 - 30a2: 39 07 cpc r19, r25 - 30a4: 09 f4 brne .+2 ; 0x30a8 <__vector_83+0x5c> - 30a6: 6c c0 rjmp .+216 ; 0x3180 <__vector_83+0x134> - /* No data left */ - LoadModState = LOADMOD_STOP_BIT0; - } else { - /* Fetch next data and continue sending bits. */ - ParityBufferPtr++; - 30a8: 31 96 adiw r30, 0x01 ; 1 - 30aa: e0 93 b6 28 sts 0x28B6, r30 - 30ae: f0 93 b7 28 sts 0x28B7, r31 - DataRegister = *++CodecBufferPtr; - 30b2: e0 91 b8 28 lds r30, 0x28B8 - 30b6: f0 91 b9 28 lds r31, 0x28B9 - 30ba: cf 01 movw r24, r30 - 30bc: 01 96 adiw r24, 0x01 ; 1 - 30be: 80 93 b8 28 sts 0x28B8, r24 - 30c2: 90 93 b9 28 sts 0x28B9, r25 - 30c6: 81 81 ldd r24, Z+1 ; 0x01 - 30c8: 80 93 b1 28 sts 0x28B1, r24 - LoadModState = LOADMOD_DATA0; - 30cc: 84 e0 ldi r24, 0x04 ; 4 - 30ce: 80 93 ad 28 sts 0x28AD, r24 - break; - - default: - break; - } -} - 30d2: ff 91 pop r31 - 30d4: ef 91 pop r30 - 30d6: bf 91 pop r27 - 30d8: af 91 pop r26 - 30da: 9f 91 pop r25 - 30dc: 8f 91 pop r24 - 30de: 3f 91 pop r19 - 30e0: 2f 91 pop r18 - 30e2: 0f 90 pop r0 - 30e4: 0f be out 0x3f, r0 ; 63 - 30e6: 0f 90 pop r0 - 30e8: 1f 90 pop r1 - 30ea: 18 95 reti - break; - - case LOADMOD_START: - /* Application produced data. With this interrupt we are aligned to the bit-grid. - * Start subcarrier generation and align to bitrate. */ - CODEC_TIMER_LOADMOD.PER = ISO14443A_BIT_RATE_CYCLES / 2 - 1; - 30ec: 8f e3 ldi r24, 0x3F ; 63 - 30ee: 90 e0 ldi r25, 0x00 ; 0 - 30f0: 80 93 66 09 sts 0x0966, r24 - 30f4: 90 93 67 09 sts 0x0967, r25 - CODEC_SUBCARRIER_TIMER.CTRLA = TC_CLKSEL_EVCH6_gc; - 30f8: 8e e0 ldi r24, 0x0E ; 14 - 30fa: 80 93 00 08 sts 0x0800, r24 - - /* Fallthrough to first bit */ - - case LOADMOD_START_BIT0: - CODEC_LOADMOD_PORT.OUTSET = CODEC_LOADMOD_MASK; - 30fe: 80 e4 ldi r24, 0x40 ; 64 - 3100: 80 93 45 06 sts 0x0645, r24 - LoadModState = LOADMOD_START_BIT1; - 3104: 83 e0 ldi r24, 0x03 ; 3 - 3106: 80 93 ad 28 sts 0x28AD, r24 - break; - 310a: e3 cf rjmp .-58 ; 0x30d2 <__vector_83+0x86> - - case LOADMOD_START_BIT1: - CODEC_LOADMOD_PORT.OUTCLR = CODEC_LOADMOD_MASK; - 310c: 80 e4 ldi r24, 0x40 ; 64 - 310e: 80 93 46 06 sts 0x0646, r24 - LoadModState = LOADMOD_DATA0; - 3112: 84 e0 ldi r24, 0x04 ; 4 - 3114: 80 93 ad 28 sts 0x28AD, r24 - - /* Fetch first byte */ - DataRegister = *CodecBufferPtr; - 3118: e0 91 b8 28 lds r30, 0x28B8 - 311c: f0 91 b9 28 lds r31, 0x28B9 - 3120: 80 81 ld r24, Z - 3122: 80 93 b1 28 sts 0x28B1, r24 - break; - 3126: d5 cf rjmp .-86 ; 0x30d2 <__vector_83+0x86> - - case LOADMOD_DATA0: - if (DataRegister & 1) { - 3128: 80 91 b1 28 lds r24, 0x28B1 - 312c: 80 fd sbrc r24, 0 - 312e: 64 c0 rjmp .+200 ; 0x31f8 <__vector_83+0x1ac> - CODEC_LOADMOD_PORT.OUTSET = CODEC_LOADMOD_MASK; - } else { - CODEC_LOADMOD_PORT.OUTCLR = CODEC_LOADMOD_MASK; - 3130: 80 e4 ldi r24, 0x40 ; 64 - 3132: 80 93 46 06 sts 0x0646, r24 - } - - LoadModState = LOADMOD_DATA1; - 3136: 85 e0 ldi r24, 0x05 ; 5 - 3138: 80 93 ad 28 sts 0x28AD, r24 - break; - 313c: ca cf rjmp .-108 ; 0x30d2 <__vector_83+0x86> - - case LOADMOD_DATA1: - Temp8 = DataRegister; - 313e: 80 91 b1 28 lds r24, 0x28B1 - - if (Temp8 & 1) { - CODEC_LOADMOD_PORT.OUTCLR = CODEC_LOADMOD_MASK; - 3142: 90 e4 ldi r25, 0x40 ; 64 - break; - - case LOADMOD_DATA1: - Temp8 = DataRegister; - - if (Temp8 & 1) { - 3144: 80 fd sbrc r24, 0 - 3146: 55 c0 rjmp .+170 ; 0x31f2 <__vector_83+0x1a6> - CODEC_LOADMOD_PORT.OUTCLR = CODEC_LOADMOD_MASK; - } else { - CODEC_LOADMOD_PORT.OUTSET = CODEC_LOADMOD_MASK; - 3148: 90 93 45 06 sts 0x0645, r25 - } - - DataRegister = Temp8 >> 1; - 314c: 86 95 lsr r24 - 314e: 80 93 b1 28 sts 0x28B1, r24 - - Temp16 = BitSent; - 3152: 80 91 b2 28 lds r24, 0x28B2 - 3156: 90 91 b3 28 lds r25, 0x28B3 - BitSent = ++Temp16; - 315a: 01 96 adiw r24, 0x01 ; 1 - 315c: 80 93 b2 28 sts 0x28B2, r24 - 3160: 90 93 b3 28 sts 0x28B3, r25 - - if ((Temp16 & 0x07) == 0) { - 3164: 9c 01 movw r18, r24 - 3166: 27 70 andi r18, 0x07 ; 7 - 3168: 33 27 eor r19, r19 - 316a: 23 2b or r18, r19 - 316c: 09 f4 brne .+2 ; 0x3170 <__vector_83+0x124> - 316e: 48 c0 rjmp .+144 ; 0x3200 <__vector_83+0x1b4> - /* Byte boundary. Load parity bit and output it later. */ - LoadModState = LOADMOD_PARITY0; - break; - } - - if (Temp16 == BitCount) { - 3170: 20 91 b4 28 lds r18, 0x28B4 - 3174: 30 91 b5 28 lds r19, 0x28B5 - 3178: 82 17 cp r24, r18 - 317a: 93 07 cpc r25, r19 - 317c: 09 f0 breq .+2 ; 0x3180 <__vector_83+0x134> - 317e: a6 cf rjmp .-180 ; 0x30cc <__vector_83+0x80> - CODEC_LOADMOD_PORT.OUTSET = CODEC_LOADMOD_MASK; - } - - if (BitSent == BitCount) { - /* No data left */ - LoadModState = LOADMOD_STOP_BIT0; - 3180: 88 e0 ldi r24, 0x08 ; 8 - 3182: 80 93 ad 28 sts 0x28AD, r24 - 3186: a5 cf rjmp .-182 ; 0x30d2 <__vector_83+0x86> - LoadModState = LOADMOD_DATA0; - - break; - - case LOADMOD_PARITY0: - if (*ParityBufferPtr) { - 3188: e0 91 b6 28 lds r30, 0x28B6 - 318c: f0 91 b7 28 lds r31, 0x28B7 - 3190: 80 81 ld r24, Z - 3192: 81 11 cpse r24, r1 - 3194: 2a c0 rjmp .+84 ; 0x31ea <__vector_83+0x19e> - CODEC_LOADMOD_PORT.OUTSET = CODEC_LOADMOD_MASK; - } else { - CODEC_LOADMOD_PORT.OUTCLR = CODEC_LOADMOD_MASK; - 3196: 80 e4 ldi r24, 0x40 ; 64 - 3198: 80 93 46 06 sts 0x0646, r24 - } - - LoadModState = LOADMOD_PARITY1; - 319c: 87 e0 ldi r24, 0x07 ; 7 - 319e: 80 93 ad 28 sts 0x28AD, r24 - break; - 31a2: 97 cf rjmp .-210 ; 0x30d2 <__vector_83+0x86> - } - - break; - - case LOADMOD_STOP_BIT0: - CODEC_LOADMOD_PORT.OUTCLR = CODEC_LOADMOD_MASK; - 31a4: 80 e4 ldi r24, 0x40 ; 64 - 31a6: 80 93 46 06 sts 0x0646, r24 - LoadModState = LOADMOD_STOP_BIT1; - 31aa: 89 e0 ldi r24, 0x09 ; 9 - 31ac: 80 93 ad 28 sts 0x28AD, r24 - break; - 31b0: 90 cf rjmp .-224 ; 0x30d2 <__vector_83+0x86> - - case LOADMOD_STOP_BIT1: - CODEC_LOADMOD_PORT.OUTCLR = CODEC_LOADMOD_MASK; - 31b2: 80 e4 ldi r24, 0x40 ; 64 - 31b4: 80 93 46 06 sts 0x0646, r24 - LoadModState = LOADMOD_FINISHED; - 31b8: 8a e0 ldi r24, 0x0A ; 10 - 31ba: 80 93 ad 28 sts 0x28AD, r24 - break; - 31be: 89 cf rjmp .-238 ; 0x30d2 <__vector_83+0x86> - - case LOADMOD_FINISHED: - /* We have written all of our bits. Deactivate the loadmod - * timer. Also disable the bit-rate interrupt again. And - * stop the subcarrier divider. */ - CODEC_TIMER_LOADMOD.CTRLA = TC_CLKSEL_OFF_gc; - 31c0: 10 92 40 09 sts 0x0940, r1 - CODEC_TIMER_LOADMOD.INTCTRLA = 0; - 31c4: 10 92 46 09 sts 0x0946, r1 - CODEC_SUBCARRIER_TIMER.CTRLA = TC_CLKSEL_OFF_gc; - 31c8: 10 92 00 08 sts 0x0800, r1 - - /* Signal application that we have finished loadmod */ - Flags.LoadmodFinished = 1; - 31cc: 81 e0 ldi r24, 0x01 ; 1 - 31ce: 80 93 bb 28 sts 0x28BB, r24 - break; - 31d2: 7f cf rjmp .-258 ; 0x30d2 <__vector_83+0x86> - uint16_t Temp16; - - switch (LoadModState) { - case LOADMOD_FDT: - /* No data has been produced, but FDT has ended. Switch over to bit-grid aligning. */ - CODEC_TIMER_LOADMOD.PER = ISO14443A_BIT_GRID_CYCLES - 1; - 31d4: 8f e7 ldi r24, 0x7F ; 127 - 31d6: 90 e0 ldi r25, 0x00 ; 0 - 31d8: 80 93 66 09 sts 0x0966, r24 - 31dc: 90 93 67 09 sts 0x0967, r25 - break; - 31e0: 78 cf rjmp .-272 ; 0x30d2 <__vector_83+0x86> - LoadModState = LOADMOD_PARITY1; - break; - - case LOADMOD_PARITY1: - if (*ParityBufferPtr) { - CODEC_LOADMOD_PORT.OUTCLR = CODEC_LOADMOD_MASK; - 31e2: 80 e4 ldi r24, 0x40 ; 64 - 31e4: 80 93 46 06 sts 0x0646, r24 - 31e8: 53 cf rjmp .-346 ; 0x3090 <__vector_83+0x44> - - break; - - case LOADMOD_PARITY0: - if (*ParityBufferPtr) { - CODEC_LOADMOD_PORT.OUTSET = CODEC_LOADMOD_MASK; - 31ea: 80 e4 ldi r24, 0x40 ; 64 - 31ec: 80 93 45 06 sts 0x0645, r24 - 31f0: d5 cf rjmp .-86 ; 0x319c <__vector_83+0x150> - - case LOADMOD_DATA1: - Temp8 = DataRegister; - - if (Temp8 & 1) { - CODEC_LOADMOD_PORT.OUTCLR = CODEC_LOADMOD_MASK; - 31f2: 90 93 46 06 sts 0x0646, r25 - 31f6: aa cf rjmp .-172 ; 0x314c <__vector_83+0x100> - DataRegister = *CodecBufferPtr; - break; - - case LOADMOD_DATA0: - if (DataRegister & 1) { - CODEC_LOADMOD_PORT.OUTSET = CODEC_LOADMOD_MASK; - 31f8: 80 e4 ldi r24, 0x40 ; 64 - 31fa: 80 93 45 06 sts 0x0645, r24 - 31fe: 9b cf rjmp .-202 ; 0x3136 <__vector_83+0xea> - Temp16 = BitSent; - BitSent = ++Temp16; - - if ((Temp16 & 0x07) == 0) { - /* Byte boundary. Load parity bit and output it later. */ - LoadModState = LOADMOD_PARITY0; - 3200: 86 e0 ldi r24, 0x06 ; 6 - 3202: 80 93 ad 28 sts 0x28AD, r24 - break; - 3206: 65 cf rjmp .-310 ; 0x30d2 <__vector_83+0x86> - -00003208 : - default: - break; - } -} - -void ISO14443ACodecInit(void) { - 3208: cf 93 push r28 - 320a: df 93 push r29 -static volatile LoadModStateType LoadModState; -static volatile bool SamplePosition; - -static void Initialize(void) { - /* Configure CARRIER input pin and route it to EVSYS */ - CODEC_CARRIER_IN_PORT.DIRCLR = CODEC_CARRIER_IN_MASK; - 320c: e0 e4 ldi r30, 0x40 ; 64 - 320e: f6 e0 ldi r31, 0x06 ; 6 - 3210: 84 e0 ldi r24, 0x04 ; 4 - 3212: 82 83 std Z+2, r24 ; 0x02 - CODEC_CARRIER_IN_PORT.CODEC_CARRIER_IN_PINCTRL = PORT_ISC_BOTHEDGES_gc; - 3214: 12 8a std Z+18, r1 ; 0x12 - EVSYS.CH6MUX = CODEC_CARRIER_IN_EVMUX; - 3216: c0 e8 ldi r28, 0x80 ; 128 - 3218: d1 e0 ldi r29, 0x01 ; 1 - 321a: 82 e6 ldi r24, 0x62 ; 98 - 321c: 8e 83 std Y+6, r24 ; 0x06 - - /* Configure two DEMOD pins for input. - * Configure event channel 0 for rising edge (begin of modulation pause) - * Configure event channel 1 for falling edge (end of modulation pause) */ - CODEC_DEMOD_IN_PORT.DIRCLR = CODEC_DEMOD_IN_MASK; - 321e: a0 e2 ldi r26, 0x20 ; 32 - 3220: b6 e0 ldi r27, 0x06 ; 6 - 3222: 85 e0 ldi r24, 0x05 ; 5 - 3224: 12 96 adiw r26, 0x02 ; 2 - 3226: 8c 93 st X, r24 - 3228: 12 97 sbiw r26, 0x02 ; 2 - CODEC_DEMOD_IN_PORT.CODEC_DEMOD_IN_PINCTRL0 = PORT_ISC_RISING_gc; - 322a: 81 e0 ldi r24, 0x01 ; 1 - 322c: 52 96 adiw r26, 0x12 ; 18 - 322e: 8c 93 st X, r24 - 3230: 52 97 sbiw r26, 0x12 ; 18 - CODEC_DEMOD_IN_PORT.CODEC_DEMOD_IN_PINCTRL1 = PORT_ISC_FALLING_gc; - 3232: 82 e0 ldi r24, 0x02 ; 2 - 3234: 50 96 adiw r26, 0x10 ; 16 - 3236: 8c 93 st X, r24 - 3238: 50 97 sbiw r26, 0x10 ; 16 - CODEC_DEMOD_IN_PORT.INT0MASK = 0; - 323a: 1a 96 adiw r26, 0x0a ; 10 - 323c: 1c 92 st X, r1 - 323e: 1a 97 sbiw r26, 0x0a ; 10 - CODEC_DEMOD_IN_PORT.INTCTRL = PORT_INT0LVL_HI_gc; - 3240: 83 e0 ldi r24, 0x03 ; 3 - 3242: 19 96 adiw r26, 0x09 ; 9 - 3244: 8c 93 st X, r24 - EVSYS.CH0MUX = CODEC_DEMOD_IN_EVMUX0; - 3246: 9a e5 ldi r25, 0x5A ; 90 - 3248: 98 83 st Y, r25 - EVSYS.CH1MUX = CODEC_DEMOD_IN_EVMUX1; - 324a: 98 e5 ldi r25, 0x58 ; 88 - 324c: 99 83 std Y+1, r25 ; 0x01 - - /* Configure LOADMOD and SUBCARRIER output pins. - * Disable PSK modulation by setting pin to low. */ - CODEC_LOADMOD_PORT.DIRSET = CODEC_LOADMOD_MASK; - 324e: 90 e4 ldi r25, 0x40 ; 64 - 3250: 91 83 std Z+1, r25 ; 0x01 - CODEC_LOADMOD_PORT.OUTCLR = CODEC_LOADMOD_MASK; - 3252: 96 83 std Z+6, r25 ; 0x06 - CODEC_SUBCARRIER_PORT.DIRSET = CODEC_SUBCARRIER_MASK; - 3254: 81 83 std Z+1, r24 ; 0x01 - CODEC_SUBCARRIER_PORT.OUTCLR = CODEC_SUBCARRIER_MASK; - 3256: 86 83 std Z+6, r24 ; 0x06 - - /* Configure subcarrier generation with 50% DC output using OOK */ - CODEC_SUBCARRIER_TIMER.PER = ISO14443A_SUBCARRIER_DIVIDER - 1; - 3258: e0 e0 ldi r30, 0x00 ; 0 - 325a: f8 e0 ldi r31, 0x08 ; 8 - 325c: 8f e0 ldi r24, 0x0F ; 15 - 325e: 90 e0 ldi r25, 0x00 ; 0 - 3260: 86 a3 std Z+38, r24 ; 0x26 - 3262: 97 a3 std Z+39, r25 ; 0x27 - CODEC_SUBCARRIER_TIMER.CODEC_SUBCARRIER_CC_OOK = ISO14443A_SUBCARRIER_DIVIDER/2; - 3264: 88 e0 ldi r24, 0x08 ; 8 - 3266: 90 e0 ldi r25, 0x00 ; 0 - 3268: 82 a7 std Z+42, r24 ; 0x2a - 326a: 93 a7 std Z+43, r25 ; 0x2b - CODEC_SUBCARRIER_TIMER.CTRLB = CODEC_SUBCARRIER_CCEN_OOK | TC_WGMODE_SINGLESLOPE_gc; - 326c: 83 e2 ldi r24, 0x23 ; 35 - 326e: 81 83 std Z+1, r24 ; 0x01 -void ISO14443ACodecInit(void) { - /* Initialize common peripherals and start listening - * for incoming data. */ - Initialize(); - StartDemod(); -} - 3270: df 91 pop r29 - 3272: cf 91 pop r28 - -void ISO14443ACodecInit(void) { - /* Initialize common peripherals and start listening - * for incoming data. */ - Initialize(); - StartDemod(); - 3274: c3 cd rjmp .-1146 ; 0x2dfc - -00003276 : -} - -void ISO14443ACodecTask(void) { - 3276: 0f 93 push r16 - 3278: 1f 93 push r17 - 327a: cf 93 push r28 - 327c: df 93 push r29 - if (Flags.DemodFinished) { - 327e: 80 91 ba 28 lds r24, 0x28BA - 3282: 88 23 and r24, r24 - 3284: c1 f0 breq .+48 ; 0x32b6 - Flags.DemodFinished = 0; - 3286: 10 92 ba 28 sts 0x28BA, r1 -INLINE void CodecTask(void) { - ActiveConfiguration.CodecTaskFunc(); -} - -INLINE void CodecSetDemodPower(bool bOnOff) { - CODEC_DEMOD_POWER_PORT.DIRSET = CODEC_DEMOD_POWER_MASK; - 328a: 82 e0 ldi r24, 0x02 ; 2 - 328c: 80 93 21 06 sts 0x0621, r24 - - if (bOnOff) { - CODEC_DEMOD_POWER_PORT.OUTSET = CODEC_DEMOD_POWER_MASK; - } else { - CODEC_DEMOD_POWER_PORT.OUTCLR = CODEC_DEMOD_POWER_MASK; - 3290: 80 93 26 06 sts 0x0626, r24 - /* Reception finished. Process the received bytes */ - CodecSetDemodPower(false); - - uint16_t DemodBitCount = BitCount; - 3294: 00 91 b4 28 lds r16, 0x28B4 - 3298: 10 91 b5 28 lds r17, 0x28B5 - uint16_t AnswerBitCount = ISO14443A_APP_NO_RESPONSE; - - if (DemodBitCount > 0) { - 329c: 01 15 cp r16, r1 - 329e: 11 05 cpc r17, r1 - 32a0: 99 f4 brne .+38 ; 0x32c8 -INLINE uint16_t ApplicationProcess(uint8_t* ByteBuffer, uint16_t ByteCount) { - return ActiveConfiguration.ApplicationProcessFunc(ByteBuffer, ByteCount); -} - -INLINE void ApplicationReset(void) { - ActiveConfiguration.ApplicationResetFunc(); - 32a2: e0 91 f9 28 lds r30, 0x28F9 - 32a6: f0 91 fa 28 lds r31, 0x28FA - 32aa: 09 95 icall - CodecBufferPtr = CodecBuffer; - ParityBufferPtr = &CodecBuffer[ISO14443A_BUFFER_PARITY_OFFSET]; - LoadModState = LOADMOD_START; - } else { - /* No data to be processed. Disable loadmodding and start listening again */ - CODEC_TIMER_LOADMOD.CTRLA = TC_CLKSEL_OFF_gc; - 32ac: 10 92 40 09 sts 0x0940, r1 - CODEC_TIMER_LOADMOD.INTCTRLA = 0; - 32b0: 10 92 46 09 sts 0x0946, r1 - - StartDemod(); - 32b4: a3 dd rcall .-1210 ; 0x2dfc - } - } - - if (Flags.LoadmodFinished) { - 32b6: 80 91 bb 28 lds r24, 0x28BB - 32ba: 81 11 cpse r24, r1 - 32bc: 5a c0 rjmp .+180 ; 0x3372 - * for incoming data again. */ - StartDemod(); - } - - //SystemSleep(); -} - 32be: df 91 pop r29 - 32c0: cf 91 pop r28 - 32c2: 1f 91 pop r17 - 32c4: 0f 91 pop r16 - 32c6: 08 95 ret - - uint16_t DemodBitCount = BitCount; - uint16_t AnswerBitCount = ISO14443A_APP_NO_RESPONSE; - - if (DemodBitCount > 0) { - LogEntry(LOG_INFO_RX_DATA, CodecBuffer, (DemodBitCount+7)/8); - 32c8: a8 01 movw r20, r16 - 32ca: 49 5f subi r20, 0xF9 ; 249 - 32cc: 5f 4f sbci r21, 0xFF ; 255 - 32ce: 56 95 lsr r21 - 32d0: 47 95 ror r20 - 32d2: 56 95 lsr r21 - 32d4: 47 95 ror r20 - 32d6: 56 95 lsr r21 - 32d8: 47 95 ror r20 -void LogSetModeById(LogModeEnum Mode); -bool LogSetModeByName(const char* Name); -void LogGetModeByName(char* Name, uint16_t BufferSize); -void LogGetModeList(char* List, uint16_t BufferSize); - -INLINE void LogEntry(LogEntryEnum Entry, void* Data, uint8_t Length) { LogFunc(Entry, Data, Length); } - 32da: e0 91 07 29 lds r30, 0x2907 - 32de: f0 91 08 29 lds r31, 0x2908 - 32e2: 6c e3 ldi r22, 0x3C ; 60 - 32e4: 7a e2 ldi r23, 0x2A ; 42 - 32e6: 80 e2 ldi r24, 0x20 ; 32 - 32e8: 09 95 icall - LEDTrigger(LED_CODEC_RX, LED_PULSE); - 32ea: 63 e1 ldi r22, 0x13 ; 19 - 32ec: 86 e0 ldi r24, 0x06 ; 6 - 32ee: 0e 94 f1 0f call 0x1fe2 ; 0x1fe2 -INLINE void ApplicationTask(void) { - ActiveConfiguration.ApplicationTaskFunc(); -} - -INLINE uint16_t ApplicationProcess(uint8_t* ByteBuffer, uint16_t ByteCount) { - return ActiveConfiguration.ApplicationProcessFunc(ByteBuffer, ByteCount); - 32f2: e0 91 fd 28 lds r30, 0x28FD - 32f6: f0 91 fe 28 lds r31, 0x28FE - 32fa: b8 01 movw r22, r16 - 32fc: 8c e3 ldi r24, 0x3C ; 60 - 32fe: 9a e2 ldi r25, 0x2A ; 42 - 3300: 09 95 icall - 3302: 8c 01 movw r16, r24 - - /* Call application if we received data */ - AnswerBitCount = ApplicationProcess(CodecBuffer, DemodBitCount); - - if (AnswerBitCount & ISO14443A_APP_CUSTOM_PARITY) { - 3304: 94 ff sbrs r25, 4 - 3306: 3c c0 rjmp .+120 ; 0x3380 - /* Application has generated it's own parity bits. - * Clear this option bit. */ - AnswerBitCount &= ~ISO14443A_APP_CUSTOM_PARITY; - 3308: 1f 7e andi r17, 0xEF ; 239 - } - } else { - ApplicationReset(); - } - - if (AnswerBitCount != ISO14443A_APP_NO_RESPONSE) { - 330a: 01 15 cp r16, r1 - 330c: 11 05 cpc r17, r1 - 330e: 71 f2 breq .-100 ; 0x32ac - LogEntry(LOG_INFO_TX_DATA, CodecBuffer, (AnswerBitCount + 7) / 8); - 3310: a8 01 movw r20, r16 - 3312: 49 5f subi r20, 0xF9 ; 249 - 3314: 5f 4f sbci r21, 0xFF ; 255 - 3316: 56 95 lsr r21 - 3318: 47 95 ror r20 - 331a: 56 95 lsr r21 - 331c: 47 95 ror r20 - 331e: 56 95 lsr r21 - 3320: 47 95 ror r20 - 3322: e0 91 07 29 lds r30, 0x2907 - 3326: f0 91 08 29 lds r31, 0x2908 - 332a: 6c e3 ldi r22, 0x3C ; 60 - 332c: 7a e2 ldi r23, 0x2A ; 42 - 332e: 81 e2 ldi r24, 0x21 ; 33 - 3330: 09 95 icall - LEDTrigger(LED_CODEC_TX, LED_PULSE); - 3332: 63 e1 ldi r22, 0x13 ; 19 - 3334: 87 e0 ldi r24, 0x07 ; 7 - 3336: 0e 94 f1 0f call 0x1fe2 ; 0x1fe2 - - BitCount = AnswerBitCount; - 333a: 00 93 b4 28 sts 0x28B4, r16 - 333e: 10 93 b5 28 sts 0x28B5, r17 - BitSent = 0; - 3342: 10 92 b2 28 sts 0x28B2, r1 - 3346: 10 92 b3 28 sts 0x28B3, r1 - CodecBufferPtr = CodecBuffer; - 334a: 8c e3 ldi r24, 0x3C ; 60 - 334c: 9a e2 ldi r25, 0x2A ; 42 - 334e: 80 93 b8 28 sts 0x28B8, r24 - 3352: 90 93 b9 28 sts 0x28B9, r25 - ParityBufferPtr = &CodecBuffer[ISO14443A_BUFFER_PARITY_OFFSET]; - 3356: 8c eb ldi r24, 0xBC ; 188 - 3358: 9a e2 ldi r25, 0x2A ; 42 - 335a: 80 93 b6 28 sts 0x28B6, r24 - 335e: 90 93 b7 28 sts 0x28B7, r25 - LoadModState = LOADMOD_START; - 3362: 81 e0 ldi r24, 0x01 ; 1 - 3364: 80 93 ad 28 sts 0x28AD, r24 - - StartDemod(); - } - } - - if (Flags.LoadmodFinished) { - 3368: 80 91 bb 28 lds r24, 0x28BB - 336c: 88 23 and r24, r24 - 336e: 09 f4 brne .+2 ; 0x3372 - 3370: a6 cf rjmp .-180 ; 0x32be - Flags.LoadmodFinished = 0; - 3372: 10 92 bb 28 sts 0x28BB, r1 - * for incoming data again. */ - StartDemod(); - } - - //SystemSleep(); -} - 3376: df 91 pop r29 - 3378: cf 91 pop r28 - 337a: 1f 91 pop r17 - 337c: 0f 91 pop r16 - - if (Flags.LoadmodFinished) { - Flags.LoadmodFinished = 0; - /* Load modulation has been finished. Stop it and start to listen - * for incoming data again. */ - StartDemod(); - 337e: 3e cd rjmp .-1412 ; 0x2dfc - /* Application has generated it's own parity bits. - * Clear this option bit. */ - AnswerBitCount &= ~ISO14443A_APP_CUSTOM_PARITY; - } else { - /* We have to generate the parity bits ourself */ - for (uint8_t i = 0; i < (AnswerBitCount / 8); i++) { - 3380: ac 01 movw r20, r24 - 3382: 56 95 lsr r21 - 3384: 47 95 ror r20 - 3386: 56 95 lsr r21 - 3388: 47 95 ror r20 - 338a: 56 95 lsr r21 - 338c: 47 95 ror r20 - 338e: 41 15 cp r20, r1 - 3390: 51 05 cpc r21, r1 - 3392: 09 f4 brne .+2 ; 0x3396 - 3394: ba cf rjmp .-140 ; 0x330a - 3396: 90 e0 ldi r25, 0x00 ; 0 - 3398: 20 e0 ldi r18, 0x00 ; 0 - 339a: 30 e0 ldi r19, 0x00 ; 0 - /* For each whole byte, generate a parity bit. */ - CodecBuffer[ISO14443A_BUFFER_PARITY_OFFSET + i] = - ODD_PARITY(CodecBuffer[i]); - 339c: f9 01 movw r30, r18 - 339e: e4 5c subi r30, 0xC4 ; 196 - 33a0: f5 4d sbci r31, 0xD5 ; 213 - 33a2: 80 81 ld r24, Z - 33a4: 08 2e mov r0, r24 - 33a6: 82 95 swap r24 - 33a8: 80 25 eor r24, r0 - 33aa: 08 2e mov r0, r24 - 33ac: 86 95 lsr r24 - 33ae: 86 95 lsr r24 - 33b0: 80 25 eor r24, r0 - AnswerBitCount &= ~ISO14443A_APP_CUSTOM_PARITY; - } else { - /* We have to generate the parity bits ourself */ - for (uint8_t i = 0; i < (AnswerBitCount / 8); i++) { - /* For each whole byte, generate a parity bit. */ - CodecBuffer[ISO14443A_BUFFER_PARITY_OFFSET + i] = - 33b2: e0 58 subi r30, 0x80 ; 128 - 33b4: ff 4f sbci r31, 0xFF ; 255 - ODD_PARITY(CodecBuffer[i]); - 33b6: 8f 5f subi r24, 0xFF ; 255 - 33b8: 86 95 lsr r24 - 33ba: 81 70 andi r24, 0x01 ; 1 - 33bc: c8 2f mov r28, r24 - 33be: 80 e0 ldi r24, 0x00 ; 0 - 33c0: d8 2f mov r29, r24 - 33c2: 81 e0 ldi r24, 0x01 ; 1 - 33c4: c8 27 eor r28, r24 - 33c6: c0 83 st Z, r28 - /* Application has generated it's own parity bits. - * Clear this option bit. */ - AnswerBitCount &= ~ISO14443A_APP_CUSTOM_PARITY; - } else { - /* We have to generate the parity bits ourself */ - for (uint8_t i = 0; i < (AnswerBitCount / 8); i++) { - 33c8: 9f 5f subi r25, 0xFF ; 255 - 33ca: 29 2f mov r18, r25 - 33cc: 30 e0 ldi r19, 0x00 ; 0 - 33ce: 24 17 cp r18, r20 - 33d0: 35 07 cpc r19, r21 - 33d2: 20 f3 brcs .-56 ; 0x339c - 33d4: 9d cf rjmp .-198 ; 0x3310 - -000033d6 : - -static uint8_t CompatWritePageAddress; - -void MifareUltralightAppInit(void) -{ - State = STATE_IDLE; - 33d6: 81 e0 ldi r24, 0x01 ; 1 - 33d8: 80 93 bd 28 sts 0x28BD, r24 - 33dc: 08 95 ret - -000033de : -} - -void MifareUltralightAppReset(void) -{ - State = STATE_IDLE; - 33de: 81 e0 ldi r24, 0x01 ; 1 - 33e0: 80 93 bd 28 sts 0x28BD, r24 - 33e4: 08 95 ret - -000033e6 : -} - -void MifareUltralightAppTask(void) -{ - 33e6: 08 95 ret - -000033e8 : - -} - - -uint16_t MifareUltralightAppProcess(uint8_t* Buffer, uint16_t BitCount) -{ - 33e8: ff 92 push r15 - 33ea: 0f 93 push r16 - 33ec: 1f 93 push r17 - 33ee: cf 93 push r28 - 33f0: df 93 push r29 - 33f2: 00 d0 rcall .+0 ; 0x33f4 - 33f4: 00 d0 rcall .+0 ; 0x33f6 - 33f6: cd b7 in r28, 0x3d ; 61 - 33f8: de b7 in r29, 0x3e ; 62 - 33fa: 8c 01 movw r16, r24 - uint8_t Cmd = Buffer[0]; - 33fc: fc 01 movw r30, r24 - 33fe: 90 81 ld r25, Z - - switch(State) { - 3400: 80 91 bd 28 lds r24, 0x28BD - 3404: 82 30 cpi r24, 0x02 ; 2 - 3406: 09 f4 brne .+2 ; 0x340a - 3408: 5b c0 rjmp .+182 ; 0x34c0 - 340a: d8 f0 brcs .+54 ; 0x3442 - 340c: 84 30 cpi r24, 0x04 ; 4 - 340e: 09 f4 brne .+2 ; 0x3412 - 3410: 3e c0 rjmp .+124 ; 0x348e - 3412: 30 f1 brcs .+76 ; 0x3460 - 3414: 85 30 cpi r24, 0x05 ; 5 - 3416: c9 f4 brne .+50 ; 0x344a - } - break; - - case STATE_COMPAT_WRITE: - /* Compatibility write. Receiving 16 bytes of data of which 4 bytes are valid. */ - if (ISO14443ACheckCRCA(Buffer, BYTES_PER_COMPAT_WRITE)) { - 3418: 60 e1 ldi r22, 0x10 ; 16 - 341a: 70 e0 ldi r23, 0x00 ; 0 - 341c: c8 01 movw r24, r16 - 341e: 3c d7 rcall .+3704 ; 0x4298 - 3420: 88 23 and r24, r24 - 3422: 09 f4 brne .+2 ; 0x3426 - 3424: 86 c0 rjmp .+268 ; 0x3532 - /* We don't perform any checks here. You will be able to program the - * whole memory. Also there is no OTP behaviour. */ - if (!ActiveConfiguration.ReadOnly) { - 3426: 80 91 06 29 lds r24, 0x2906 - 342a: 88 23 and r24, r24 - 342c: 09 f4 brne .+2 ; 0x3430 - 342e: 8a c0 rjmp .+276 ; 0x3544 - } else { - /* If we are told to be read only, we silently ignore the write command - * and pretend to have written data. */ - } - - State = STATE_ACTIVE; - 3430: 84 e0 ldi r24, 0x04 ; 4 - 3432: 80 93 bd 28 sts 0x28BD, r24 - Buffer[0] = ACK_VALUE; - 3436: 8a e0 ldi r24, 0x0A ; 10 - 3438: f8 01 movw r30, r16 - 343a: 80 83 st Z, r24 - return ACK_FRAME_SIZE; - 343c: 84 e0 ldi r24, 0x04 ; 4 - 343e: 90 e0 ldi r25, 0x00 ; 0 - 3440: 06 c0 rjmp .+12 ; 0x344e -INLINE -bool ISO14443AWakeUp(void* Buffer, uint16_t* BitCount, uint16_t ATQAValue) -{ - uint8_t* DataPtr = (uint8_t*) Buffer; - - if ( (DataPtr[0] == ISO14443A_CMD_REQA) || (DataPtr[0] == ISO14443A_CMD_WUPA) ){ - 3442: 96 32 cpi r25, 0x26 ; 38 - 3444: d1 f0 breq .+52 ; 0x347a - 3446: 92 35 cpi r25, 0x52 ; 82 - 3448: c1 f0 breq .+48 ; 0x347a - - *BitCount = ISO14443A_SAK_FRAME_SIZE; - return true; - } else { - /* We have not been selected. Don't send anything. */ - *BitCount = 0; - 344a: 80 e0 ldi r24, 0x00 ; 0 - 344c: 90 e0 ldi r25, 0x00 ; 0 - break; - } - - /* No response has been sent, when we reach here */ - return ISO14443A_APP_NO_RESPONSE; -} - 344e: 24 96 adiw r28, 0x04 ; 4 - 3450: cd bf out 0x3d, r28 ; 61 - 3452: de bf out 0x3e, r29 ; 62 - 3454: df 91 pop r29 - 3456: cf 91 pop r28 - 3458: 1f 91 pop r17 - 345a: 0f 91 pop r16 - 345c: ff 90 pop r15 - 345e: 08 95 ret -INLINE -bool ISO14443AWakeUp(void* Buffer, uint16_t* BitCount, uint16_t ATQAValue) -{ - uint8_t* DataPtr = (uint8_t*) Buffer; - - if ( (DataPtr[0] == ISO14443A_CMD_REQA) || (DataPtr[0] == ISO14443A_CMD_WUPA) ){ - 3460: 96 32 cpi r25, 0x26 ; 38 - 3462: 59 f0 breq .+22 ; 0x347a - 3464: 92 35 cpi r25, 0x52 ; 82 - 3466: 49 f0 breq .+18 ; 0x347a - - case STATE_READY2: - if (ISO14443AWakeUp(Buffer, &BitCount, ATQA_VALUE)) { - State = STATE_READY1; - return BitCount; - } else if (Cmd == ISO14443A_CMD_SELECT_CL2) { - 3468: 95 39 cpi r25, 0x95 ; 149 - 346a: 09 f4 brne .+2 ; 0x346e - 346c: 78 c0 rjmp .+240 ; 0x355e - Buffer[0] = NAK_INVALID_ARG; - return NAK_FRAME_SIZE; - } - } else { - /* Unknown command. Enter halt state */ - State = STATE_IDLE; - 346e: 81 e0 ldi r24, 0x01 ; 1 - 3470: 80 93 bd 28 sts 0x28BD, r24 - /* Unknown state? Should never happen. */ - break; - } - - /* No response has been sent, when we reach here */ - return ISO14443A_APP_NO_RESPONSE; - 3474: 80 e0 ldi r24, 0x00 ; 0 - 3476: 90 e0 ldi r25, 0x00 ; 0 - } - } else { - /* Unknown command. Enter halt state */ - State = STATE_IDLE; - } - break; - 3478: ea cf rjmp .-44 ; 0x344e - DataPtr[0] = (ATQAValue >> 0) & 0x00FF; - 347a: 84 e4 ldi r24, 0x44 ; 68 - 347c: f8 01 movw r30, r16 - 347e: 80 83 st Z, r24 - DataPtr[1] = (ATQAValue >> 8) & 0x00FF; - 3480: 11 82 std Z+1, r1 ; 0x01 - switch(State) { - case STATE_IDLE: - case STATE_HALT: - if (ISO14443AWakeUp(Buffer, &BitCount, ATQA_VALUE)) { - /* We received a REQA or WUPA command, so wake up. */ - State = STATE_READY1; - 3482: 82 e0 ldi r24, 0x02 ; 2 - 3484: 80 93 bd 28 sts 0x28BD, r24 - - *BitCount = ISO14443A_ATQA_FRAME_SIZE; - 3488: 80 e1 ldi r24, 0x10 ; 16 - 348a: 90 e0 ldi r25, 0x00 ; 0 - return BitCount; - 348c: e0 cf rjmp .-64 ; 0x344e -INLINE -bool ISO14443AWakeUp(void* Buffer, uint16_t* BitCount, uint16_t ATQAValue) -{ - uint8_t* DataPtr = (uint8_t*) Buffer; - - if ( (DataPtr[0] == ISO14443A_CMD_REQA) || (DataPtr[0] == ISO14443A_CMD_WUPA) ){ - 348e: 96 32 cpi r25, 0x26 ; 38 - 3490: a1 f3 breq .-24 ; 0x347a - 3492: 92 35 cpi r25, 0x52 ; 82 - 3494: 91 f3 breq .-28 ; 0x347a - - case STATE_ACTIVE: - if (ISO14443AWakeUp(Buffer, &BitCount, ATQA_VALUE)) { - State = STATE_READY1; - return BitCount; - } else if (Cmd == CMD_READ) { - 3496: 90 33 cpi r25, 0x30 ; 48 - 3498: 09 f4 brne .+2 ; 0x349c - 349a: 8d c0 rjmp .+282 ; 0x35b6 - } - } else { - Buffer[0] = NAK_CRC_ERROR; - return NAK_FRAME_SIZE; - } - } else if (Cmd == CMD_WRITE) { - 349c: 92 3a cpi r25, 0xA2 ; 162 - 349e: 09 f4 brne .+2 ; 0x34a2 - 34a0: b9 c0 rjmp .+370 ; 0x3614 - } - } else { - Buffer[0] = NAK_CRC_ERROR; - return NAK_FRAME_SIZE; - } - } else if (Cmd == CMD_COMPAT_WRITE) { - 34a2: 90 3a cpi r25, 0xA0 ; 160 - 34a4: 09 f4 brne .+2 ; 0x34a8 - 34a6: d3 c0 rjmp .+422 ; 0x364e - } - } else { - Buffer[0] = NAK_CRC_ERROR; - return NAK_FRAME_SIZE; - } - } else if (Cmd == CMD_HALT) { - 34a8: 90 35 cpi r25, 0x50 ; 80 - 34aa: 09 f7 brne .-62 ; 0x346e - /* Halts the tag. According to the ISO14443, the second - * byte is supposed to be 0. */ - if (Buffer[1] == 0) { - 34ac: f8 01 movw r30, r16 - 34ae: 81 81 ldd r24, Z+1 ; 0x01 - 34b0: 88 23 and r24, r24 - 34b2: 09 f4 brne .+2 ; 0x34b6 - 34b4: de c0 rjmp .+444 ; 0x3672 - } else { - Buffer[0] = NAK_CRC_ERROR; - return NAK_FRAME_SIZE; - } - } else { - Buffer[0] = NAK_INVALID_ARG; - 34b6: f8 01 movw r30, r16 - 34b8: 10 82 st Z, r1 - return NAK_FRAME_SIZE; - 34ba: 84 e0 ldi r24, 0x04 ; 4 - 34bc: 90 e0 ldi r25, 0x00 ; 0 - 34be: c7 cf rjmp .-114 ; 0x344e - 34c0: 96 32 cpi r25, 0x26 ; 38 - 34c2: d9 f2 breq .-74 ; 0x347a - 34c4: 92 35 cpi r25, 0x52 ; 82 - 34c6: c9 f2 breq .-78 ; 0x347a - - case STATE_READY1: - if (ISO14443AWakeUp(Buffer, &BitCount, ATQA_VALUE)) { - State = STATE_READY1; - return BitCount; - } else if (Cmd == ISO14443A_CMD_SELECT_CL1) { - 34c8: 93 39 cpi r25, 0x93 ; 147 - 34ca: 89 f6 brne .-94 ; 0x346e - /* Load UID CL1 and perform anticollision. Since - * MF Ultralight use a double-sized UID, the first byte - * of CL1 has to be the cascade-tag byte. */ - uint8_t UidCL1[ISO14443A_CL_UID_SIZE] = { [0] = ISO14443A_UID0_CT }; - 34cc: 19 82 std Y+1, r1 ; 0x01 - 34ce: 1a 82 std Y+2, r1 ; 0x02 - 34d0: 1b 82 std Y+3, r1 ; 0x03 - 34d2: 1c 82 std Y+4, r1 ; 0x04 - 34d4: 88 e8 ldi r24, 0x88 ; 136 - 34d6: 89 83 std Y+1, r24 ; 0x01 - - MemoryReadBlock(&UidCL1[1], UID_CL1_ADDRESS, UID_CL1_SIZE); - 34d8: 43 e0 ldi r20, 0x03 ; 3 - 34da: 50 e0 ldi r21, 0x00 ; 0 - 34dc: 60 e0 ldi r22, 0x00 ; 0 - 34de: 70 e0 ldi r23, 0x00 ; 0 - 34e0: ce 01 movw r24, r28 - 34e2: 02 96 adiw r24, 0x02 ; 2 - 34e4: 0e 94 62 07 call 0xec4 ; 0xec4 - uint8_t* DataPtr = (uint8_t*) Buffer; - uint8_t NVB = DataPtr[1]; - //uint8_t CollisionByteCount = (NVB >> 4) & 0x0F; - //uint8_t CollisionBitCount = (NVB >> 0) & 0x0F; - - switch (NVB) { - 34e8: f8 01 movw r30, r16 - 34ea: 81 81 ldd r24, Z+1 ; 0x01 - 34ec: 80 32 cpi r24, 0x20 ; 32 - 34ee: 09 f4 brne .+2 ; 0x34f2 - 34f0: 81 c0 rjmp .+258 ; 0x35f4 - 34f2: 80 37 cpi r24, 0x70 ; 112 - 34f4: 09 f0 breq .+2 ; 0x34f8 - 34f6: a9 cf rjmp .-174 ; 0x344a - return false; - - case ISO14443A_NVB_AC_END: - /* End of anticollision procedure. - * Send SAK CLn if we are selected. */ - if ( (DataPtr[2] == UidCL[0]) && - 34f8: f8 01 movw r30, r16 - 34fa: 92 81 ldd r25, Z+2 ; 0x02 - 34fc: 89 81 ldd r24, Y+1 ; 0x01 - 34fe: 98 13 cpse r25, r24 - 3500: a4 cf rjmp .-184 ; 0x344a - 3502: 93 81 ldd r25, Z+3 ; 0x03 - 3504: 8a 81 ldd r24, Y+2 ; 0x02 - 3506: 98 13 cpse r25, r24 - 3508: a0 cf rjmp .-192 ; 0x344a - (DataPtr[3] == UidCL[1]) && - 350a: 94 81 ldd r25, Z+4 ; 0x04 - 350c: 8b 81 ldd r24, Y+3 ; 0x03 - 350e: 98 13 cpse r25, r24 - 3510: 9c cf rjmp .-200 ; 0x344a - (DataPtr[4] == UidCL[2]) && - 3512: 95 81 ldd r25, Z+5 ; 0x05 - 3514: 8c 81 ldd r24, Y+4 ; 0x04 - 3516: 98 13 cpse r25, r24 - 3518: 98 cf rjmp .-208 ; 0x344a - (DataPtr[5] == UidCL[3]) ) { - - DataPtr[0] = SAKValue; - 351a: 84 e0 ldi r24, 0x04 ; 4 - 351c: 80 83 st Z, r24 - ISO14443AAppendCRCA(Buffer, 1); - 351e: 61 e0 ldi r22, 0x01 ; 1 - 3520: 70 e0 ldi r23, 0x00 ; 0 - 3522: c8 01 movw r24, r16 - 3524: 8b d6 rcall .+3350 ; 0x423c - - if (ISO14443ASelect(Buffer, &BitCount, UidCL1, SAK_CL1_VALUE)) { - /* CL1 stage has ended successfully */ - State = STATE_READY2; - 3526: 83 e0 ldi r24, 0x03 ; 3 - 3528: 80 93 bd 28 sts 0x28BD, r24 - - *BitCount = ISO14443A_SAK_FRAME_SIZE; - 352c: 88 e1 ldi r24, 0x18 ; 24 - 352e: 90 e0 ldi r25, 0x00 ; 0 - 3530: 8e cf rjmp .-228 ; 0x344e - - State = STATE_ACTIVE; - Buffer[0] = ACK_VALUE; - return ACK_FRAME_SIZE; - } else { - State = STATE_ACTIVE; - 3532: 84 e0 ldi r24, 0x04 ; 4 - 3534: 80 93 bd 28 sts 0x28BD, r24 - Buffer[0] = NAK_CRC_ERROR; - 3538: 81 e0 ldi r24, 0x01 ; 1 - 353a: f8 01 movw r30, r16 - 353c: 80 83 st Z, r24 - return NAK_FRAME_SIZE; - 353e: 84 e0 ldi r24, 0x04 ; 4 - 3540: 90 e0 ldi r25, 0x00 ; 0 - 3542: 85 cf rjmp .-246 ; 0x344e - /* Compatibility write. Receiving 16 bytes of data of which 4 bytes are valid. */ - if (ISO14443ACheckCRCA(Buffer, BYTES_PER_COMPAT_WRITE)) { - /* We don't perform any checks here. You will be able to program the - * whole memory. Also there is no OTP behaviour. */ - if (!ActiveConfiguration.ReadOnly) { - MemoryWriteBlock(Buffer, CompatWritePageAddress * BYTES_PER_PAGE, BYTES_PER_WRITE); - 3544: 60 91 bc 28 lds r22, 0x28BC - 3548: 70 e0 ldi r23, 0x00 ; 0 - 354a: 66 0f add r22, r22 - 354c: 77 1f adc r23, r23 - 354e: 66 0f add r22, r22 - 3550: 77 1f adc r23, r23 - 3552: 44 e0 ldi r20, 0x04 ; 4 - 3554: 50 e0 ldi r21, 0x00 ; 0 - 3556: c8 01 movw r24, r16 - 3558: 0e 94 7a 07 call 0xef4 ; 0xef4 - 355c: 69 cf rjmp .-302 ; 0x3430 - return BitCount; - } else if (Cmd == ISO14443A_CMD_SELECT_CL2) { - /* Load UID CL2 and perform anticollision */ - uint8_t UidCL2[ISO14443A_CL_UID_SIZE]; - - MemoryReadBlock(UidCL2, UID_CL2_ADDRESS, UID_CL2_SIZE); - 355e: 44 e0 ldi r20, 0x04 ; 4 - 3560: 50 e0 ldi r21, 0x00 ; 0 - 3562: 64 e0 ldi r22, 0x04 ; 4 - 3564: 70 e0 ldi r23, 0x00 ; 0 - 3566: ce 01 movw r24, r28 - 3568: 01 96 adiw r24, 0x01 ; 1 - 356a: 0e 94 62 07 call 0xec4 ; 0xec4 - uint8_t* DataPtr = (uint8_t*) Buffer; - uint8_t NVB = DataPtr[1]; - //uint8_t CollisionByteCount = (NVB >> 4) & 0x0F; - //uint8_t CollisionBitCount = (NVB >> 0) & 0x0F; - - switch (NVB) { - 356e: f8 01 movw r30, r16 - 3570: 81 81 ldd r24, Z+1 ; 0x01 - 3572: 80 32 cpi r24, 0x20 ; 32 - 3574: 09 f4 brne .+2 ; 0x3578 - 3576: 3e c0 rjmp .+124 ; 0x35f4 - 3578: 80 37 cpi r24, 0x70 ; 112 - 357a: 09 f0 breq .+2 ; 0x357e - 357c: 66 cf rjmp .-308 ; 0x344a - return false; - - case ISO14443A_NVB_AC_END: - /* End of anticollision procedure. - * Send SAK CLn if we are selected. */ - if ( (DataPtr[2] == UidCL[0]) && - 357e: f8 01 movw r30, r16 - 3580: 92 81 ldd r25, Z+2 ; 0x02 - 3582: 89 81 ldd r24, Y+1 ; 0x01 - 3584: 98 13 cpse r25, r24 - 3586: 61 cf rjmp .-318 ; 0x344a - 3588: 93 81 ldd r25, Z+3 ; 0x03 - 358a: 8a 81 ldd r24, Y+2 ; 0x02 - 358c: 98 13 cpse r25, r24 - 358e: 5d cf rjmp .-326 ; 0x344a - (DataPtr[3] == UidCL[1]) && - 3590: 94 81 ldd r25, Z+4 ; 0x04 - 3592: 8b 81 ldd r24, Y+3 ; 0x03 - 3594: 98 13 cpse r25, r24 - 3596: 59 cf rjmp .-334 ; 0x344a - (DataPtr[4] == UidCL[2]) && - 3598: 95 81 ldd r25, Z+5 ; 0x05 - 359a: 8c 81 ldd r24, Y+4 ; 0x04 - 359c: 98 13 cpse r25, r24 - 359e: 55 cf rjmp .-342 ; 0x344a - (DataPtr[5] == UidCL[3]) ) { - - DataPtr[0] = SAKValue; - 35a0: 10 82 st Z, r1 - ISO14443AAppendCRCA(Buffer, 1); - 35a2: 61 e0 ldi r22, 0x01 ; 1 - 35a4: 70 e0 ldi r23, 0x00 ; 0 - 35a6: c8 01 movw r24, r16 - 35a8: 49 d6 rcall .+3218 ; 0x423c - - if (ISO14443ASelect(Buffer, &BitCount, UidCL2, SAK_CL2_VALUE)) { - /* CL2 stage has ended successfully. This means - * our complete UID has been sent to the reader. */ - State = STATE_ACTIVE; - 35aa: 84 e0 ldi r24, 0x04 ; 4 - 35ac: 80 93 bd 28 sts 0x28BD, r24 - - *BitCount = ISO14443A_SAK_FRAME_SIZE; - 35b0: 88 e1 ldi r24, 0x18 ; 24 - 35b2: 90 e0 ldi r25, 0x00 ; 0 - 35b4: 4c cf rjmp .-360 ; 0x344e - case STATE_ACTIVE: - if (ISO14443AWakeUp(Buffer, &BitCount, ATQA_VALUE)) { - State = STATE_READY1; - return BitCount; - } else if (Cmd == CMD_READ) { - uint8_t PageAddress = Buffer[1]; - 35b6: f8 01 movw r30, r16 - 35b8: f1 80 ldd r15, Z+1 ; 0x01 - - if (ISO14443ACheckCRCA(Buffer, CMD_READ_FRAME_SIZE)) { - 35ba: 62 e0 ldi r22, 0x02 ; 2 - 35bc: 70 e0 ldi r23, 0x00 ; 0 - 35be: c8 01 movw r24, r16 - 35c0: 6b d6 rcall .+3286 ; 0x4298 - 35c2: 88 23 and r24, r24 - 35c4: 09 f4 brne .+2 ; 0x35c8 - 35c6: b8 cf rjmp .-144 ; 0x3538 - if ( (PageAddress >= PAGE_READ_MIN) - 35c8: ff e0 ldi r31, 0x0F ; 15 - 35ca: ff 15 cp r31, r15 - 35cc: 08 f4 brcc .+2 ; 0x35d0 - 35ce: 73 cf rjmp .-282 ; 0x34b6 - && (PageAddress <= PAGE_READ_MAX) ) { - /* TODO: Missing address wrap around behaviour. - * Implement using a for-loop copying 4 bytes each iteration - * and mask pageaddress */ - MemoryReadBlock(Buffer, PageAddress * BYTES_PER_PAGE, BYTES_PER_READ); - 35d0: 6f 2d mov r22, r15 - 35d2: 70 e0 ldi r23, 0x00 ; 0 - 35d4: 66 0f add r22, r22 - 35d6: 77 1f adc r23, r23 - 35d8: 66 0f add r22, r22 - 35da: 77 1f adc r23, r23 - 35dc: 40 e1 ldi r20, 0x10 ; 16 - 35de: 50 e0 ldi r21, 0x00 ; 0 - 35e0: c8 01 movw r24, r16 - 35e2: 0e 94 62 07 call 0xec4 ; 0xec4 - ISO14443AAppendCRCA(Buffer, BYTES_PER_READ); - 35e6: 60 e1 ldi r22, 0x10 ; 16 - 35e8: 70 e0 ldi r23, 0x00 ; 0 - 35ea: c8 01 movw r24, r16 - 35ec: 27 d6 rcall .+3150 ; 0x423c - return (BYTES_PER_READ + ISO14443A_CRCA_SIZE) * 8; - 35ee: 80 e9 ldi r24, 0x90 ; 144 - 35f0: 90 e0 ldi r25, 0x00 ; 0 - 35f2: 2d cf rjmp .-422 ; 0x344e - - switch (NVB) { - case ISO14443A_NVB_AC_START: - /* Start of anticollision procedure. - * Send whole UID CLn + BCC */ - DataPtr[0] = UidCL[0]; - 35f4: 89 81 ldd r24, Y+1 ; 0x01 - 35f6: f8 01 movw r30, r16 - 35f8: 80 83 st Z, r24 - DataPtr[1] = UidCL[1]; - 35fa: 3a 81 ldd r19, Y+2 ; 0x02 - 35fc: 31 83 std Z+1, r19 ; 0x01 - DataPtr[2] = UidCL[2]; - 35fe: 2b 81 ldd r18, Y+3 ; 0x03 - 3600: 22 83 std Z+2, r18 ; 0x02 - DataPtr[3] = UidCL[3]; - 3602: 9c 81 ldd r25, Y+4 ; 0x04 - 3604: 93 83 std Z+3, r25 ; 0x03 - DataPtr[4] = ISO14443A_CALC_BCC(DataPtr); - 3606: 83 27 eor r24, r19 - 3608: 82 27 eor r24, r18 - 360a: 89 27 eor r24, r25 - 360c: 84 83 std Z+4, r24 ; 0x04 - - *BitCount = ISO14443A_CL_FRAME_SIZE; - 360e: 88 e2 ldi r24, 0x28 ; 40 - 3610: 90 e0 ldi r25, 0x00 ; 0 - 3612: 1d cf rjmp .-454 ; 0x344e - return NAK_FRAME_SIZE; - } - } else if (Cmd == CMD_WRITE) { - /* This is a write command containing 4 bytes of data that - * should be written to the given page address. */ - uint8_t PageAddress = Buffer[1]; - 3614: f8 01 movw r30, r16 - 3616: f1 80 ldd r15, Z+1 ; 0x01 - if (ISO14443ACheckCRCA(Buffer, CMD_WRITE_FRAME_SIZE)) { - 3618: 66 e0 ldi r22, 0x06 ; 6 - 361a: 70 e0 ldi r23, 0x00 ; 0 - 361c: c8 01 movw r24, r16 - 361e: 3c d6 rcall .+3192 ; 0x4298 - 3620: 88 23 and r24, r24 - 3622: 09 f4 brne .+2 ; 0x3626 - 3624: 89 cf rjmp .-238 ; 0x3538 - /* CRC check passed */ - if ( (PageAddress >= PAGE_WRITE_MIN) - && (PageAddress <= PAGE_WRITE_MAX) ) { - 3626: 8e ef ldi r24, 0xFE ; 254 - 3628: 8f 0d add r24, r15 - /* This is a write command containing 4 bytes of data that - * should be written to the given page address. */ - uint8_t PageAddress = Buffer[1]; - if (ISO14443ACheckCRCA(Buffer, CMD_WRITE_FRAME_SIZE)) { - /* CRC check passed */ - if ( (PageAddress >= PAGE_WRITE_MIN) - 362a: 8e 30 cpi r24, 0x0E ; 14 - 362c: 08 f0 brcs .+2 ; 0x3630 - 362e: 43 cf rjmp .-378 ; 0x34b6 - && (PageAddress <= PAGE_WRITE_MAX) ) { - /* PageAddress is within bounds. */ - - if (!ActiveConfiguration.ReadOnly) { - 3630: 80 91 06 29 lds r24, 0x2906 - 3634: 81 11 cpse r24, r1 - 3636: ff ce rjmp .-514 ; 0x3436 - MemoryWriteBlock(&Buffer[2], PageAddress * BYTES_PER_PAGE, BYTES_PER_WRITE); - 3638: f4 e0 ldi r31, 0x04 ; 4 - 363a: ff 9e mul r15, r31 - 363c: b0 01 movw r22, r0 - 363e: 11 24 eor r1, r1 - 3640: 44 e0 ldi r20, 0x04 ; 4 - 3642: 50 e0 ldi r21, 0x00 ; 0 - 3644: c8 01 movw r24, r16 - 3646: 02 96 adiw r24, 0x02 ; 2 - 3648: 0e 94 7a 07 call 0xef4 ; 0xef4 - 364c: f4 ce rjmp .-536 ; 0x3436 - } - } else if (Cmd == CMD_COMPAT_WRITE) { - /* The Mifare compatbility write command is a 2-frame command. - * The first frame contains the page-address and the second frame - * holds the data. */ - uint8_t PageAddress = Buffer[1]; - 364e: f8 01 movw r30, r16 - 3650: f1 80 ldd r15, Z+1 ; 0x01 - - if (ISO14443ACheckCRCA(Buffer, CMD_COMPAT_WRITE_FRAME_SIZE)) { - 3652: 62 e0 ldi r22, 0x02 ; 2 - 3654: 70 e0 ldi r23, 0x00 ; 0 - 3656: c8 01 movw r24, r16 - 3658: 1f d6 rcall .+3134 ; 0x4298 - 365a: 88 23 and r24, r24 - 365c: 09 f4 brne .+2 ; 0x3660 - 365e: 6c cf rjmp .-296 ; 0x3538 - if ( (PageAddress >= PAGE_WRITE_MIN) - && (PageAddress <= PAGE_WRITE_MAX) ) { - 3660: 8e ef ldi r24, 0xFE ; 254 - 3662: 8f 0d add r24, r15 - * The first frame contains the page-address and the second frame - * holds the data. */ - uint8_t PageAddress = Buffer[1]; - - if (ISO14443ACheckCRCA(Buffer, CMD_COMPAT_WRITE_FRAME_SIZE)) { - if ( (PageAddress >= PAGE_WRITE_MIN) - 3664: 8e 30 cpi r24, 0x0E ; 14 - 3666: 08 f0 brcs .+2 ; 0x366a - 3668: 26 cf rjmp .-436 ; 0x34b6 - && (PageAddress <= PAGE_WRITE_MAX) ) { - /* CRC check passed and page-address is within bounds. - * Store address and proceed to receiving the data. */ - CompatWritePageAddress = PageAddress; - 366a: f0 92 bc 28 sts 0x28BC, r15 - State = STATE_COMPAT_WRITE; - 366e: 85 e0 ldi r24, 0x05 ; 5 - 3670: e0 ce rjmp .-576 ; 0x3432 - } - } else if (Cmd == CMD_HALT) { - /* Halts the tag. According to the ISO14443, the second - * byte is supposed to be 0. */ - if (Buffer[1] == 0) { - if (ISO14443ACheckCRCA(Buffer, 2)) { - 3672: 62 e0 ldi r22, 0x02 ; 2 - 3674: 70 e0 ldi r23, 0x00 ; 0 - 3676: c8 01 movw r24, r16 - 3678: 0f d6 rcall .+3102 ; 0x4298 - 367a: 88 23 and r24, r24 - 367c: 09 f4 brne .+2 ; 0x3680 - 367e: 5c cf rjmp .-328 ; 0x3538 - /* According to ISO14443, we must not send anything - * in order to acknowledge the HALT command. */ - State = STATE_HALT; - 3680: 10 92 bd 28 sts 0x28BD, r1 - return ISO14443A_APP_NO_RESPONSE; - 3684: 80 e0 ldi r24, 0x00 ; 0 - 3686: 90 e0 ldi r25, 0x00 ; 0 - 3688: e2 ce rjmp .-572 ; 0x344e - -0000368a : - /* No response has been sent, when we reach here */ - return ISO14443A_APP_NO_RESPONSE; -} - -void MifareUltralightGetUid(ConfigurationUidType Uid) -{ - 368a: cf 93 push r28 - 368c: df 93 push r29 - 368e: ec 01 movw r28, r24 - /* Read UID from memory */ - MemoryReadBlock(&Uid[0], UID_CL1_ADDRESS, UID_CL1_SIZE); - 3690: 43 e0 ldi r20, 0x03 ; 3 - 3692: 50 e0 ldi r21, 0x00 ; 0 - 3694: 60 e0 ldi r22, 0x00 ; 0 - 3696: 70 e0 ldi r23, 0x00 ; 0 - 3698: 0e 94 62 07 call 0xec4 ; 0xec4 - MemoryReadBlock(&Uid[UID_CL1_SIZE], UID_CL2_ADDRESS, UID_CL2_SIZE); - 369c: 44 e0 ldi r20, 0x04 ; 4 - 369e: 50 e0 ldi r21, 0x00 ; 0 - 36a0: 64 e0 ldi r22, 0x04 ; 4 - 36a2: 70 e0 ldi r23, 0x00 ; 0 - 36a4: ce 01 movw r24, r28 - 36a6: 03 96 adiw r24, 0x03 ; 3 -} - 36a8: df 91 pop r29 - 36aa: cf 91 pop r28 - -void MifareUltralightGetUid(ConfigurationUidType Uid) -{ - /* Read UID from memory */ - MemoryReadBlock(&Uid[0], UID_CL1_ADDRESS, UID_CL1_SIZE); - MemoryReadBlock(&Uid[UID_CL1_SIZE], UID_CL2_ADDRESS, UID_CL2_SIZE); - 36ac: 0c 94 62 07 jmp 0xec4 ; 0xec4 - -000036b0 : -} - -void MifareUltralightSetUid(ConfigurationUidType Uid) -{ - 36b0: 0f 93 push r16 - 36b2: 1f 93 push r17 - 36b4: cf 93 push r28 - 36b6: df 93 push r29 - 36b8: 00 d0 rcall .+0 ; 0x36ba - 36ba: cd b7 in r28, 0x3d ; 61 - 36bc: de b7 in r29, 0x3e ; 62 - 36be: 8c 01 movw r16, r24 - /* Calculate check bytes and write everything into memory */ - uint8_t BCC1 = ISO14443A_UID0_CT ^ Uid[0] ^ Uid[1] ^ Uid[2]; - 36c0: fc 01 movw r30, r24 - 36c2: 80 81 ld r24, Z - 36c4: 91 81 ldd r25, Z+1 ; 0x01 - 36c6: 89 27 eor r24, r25 - 36c8: 98 e8 ldi r25, 0x88 ; 136 - 36ca: 89 27 eor r24, r25 - 36cc: 92 81 ldd r25, Z+2 ; 0x02 - 36ce: 89 27 eor r24, r25 - 36d0: 8a 83 std Y+2, r24 ; 0x02 - uint8_t BCC2 = Uid[3] ^ Uid[4] ^ Uid[5] ^ Uid[6]; - 36d2: 84 81 ldd r24, Z+4 ; 0x04 - 36d4: 93 81 ldd r25, Z+3 ; 0x03 - 36d6: 89 27 eor r24, r25 - 36d8: 95 81 ldd r25, Z+5 ; 0x05 - 36da: 89 27 eor r24, r25 - 36dc: 96 81 ldd r25, Z+6 ; 0x06 - 36de: 89 27 eor r24, r25 - 36e0: 89 83 std Y+1, r24 ; 0x01 - - MemoryWriteBlock(&Uid[0], UID_CL1_ADDRESS, UID_CL1_SIZE); - 36e2: 43 e0 ldi r20, 0x03 ; 3 - 36e4: 50 e0 ldi r21, 0x00 ; 0 - 36e6: 60 e0 ldi r22, 0x00 ; 0 - 36e8: 70 e0 ldi r23, 0x00 ; 0 - 36ea: c8 01 movw r24, r16 - 36ec: 0e 94 7a 07 call 0xef4 ; 0xef4 - MemoryWriteBlock(&BCC1, UID_BCC1_ADDRESS, ISO14443A_CL_BCC_SIZE); - 36f0: 41 e0 ldi r20, 0x01 ; 1 - 36f2: 50 e0 ldi r21, 0x00 ; 0 - 36f4: 63 e0 ldi r22, 0x03 ; 3 - 36f6: 70 e0 ldi r23, 0x00 ; 0 - 36f8: ce 01 movw r24, r28 - 36fa: 02 96 adiw r24, 0x02 ; 2 - 36fc: 0e 94 7a 07 call 0xef4 ; 0xef4 - MemoryWriteBlock(&Uid[UID_CL1_SIZE], UID_CL2_ADDRESS, UID_CL2_SIZE); - 3700: 44 e0 ldi r20, 0x04 ; 4 - 3702: 50 e0 ldi r21, 0x00 ; 0 - 3704: 64 e0 ldi r22, 0x04 ; 4 - 3706: 70 e0 ldi r23, 0x00 ; 0 - 3708: c8 01 movw r24, r16 - 370a: 03 96 adiw r24, 0x03 ; 3 - 370c: 0e 94 7a 07 call 0xef4 ; 0xef4 - MemoryWriteBlock(&BCC2, UID_BCC2_ADDRESS, ISO14443A_CL_BCC_SIZE); - 3710: 41 e0 ldi r20, 0x01 ; 1 - 3712: 50 e0 ldi r21, 0x00 ; 0 - 3714: 68 e0 ldi r22, 0x08 ; 8 - 3716: 70 e0 ldi r23, 0x00 ; 0 - 3718: ce 01 movw r24, r28 - 371a: 01 96 adiw r24, 0x01 ; 1 - 371c: 0e 94 7a 07 call 0xef4 ; 0xef4 -} - 3720: 0f 90 pop r0 - 3722: 0f 90 pop r0 - 3724: df 91 pop r29 - 3726: cf 91 pop r28 - 3728: 1f 91 pop r17 - 372a: 0f 91 pop r16 - 372c: 08 95 ret - -0000372e : - Block[11] = Block[3]; -} - -void MifareClassicAppInit1K(void) -{ - State = STATE_IDLE; - 372e: 81 e0 ldi r24, 0x01 ; 1 - 3730: 80 93 db 28 sts 0x28DB, r24 - CardATQAValue = MFCLASSIC_1K_ATQA_VALUE; - 3734: 84 e0 ldi r24, 0x04 ; 4 - 3736: 90 e0 ldi r25, 0x00 ; 0 - 3738: 80 93 c0 28 sts 0x28C0, r24 - 373c: 90 93 c1 28 sts 0x28C1, r25 - CardSAKValue = MFCLASSIC_1K_SAK_CL1_VALUE; - 3740: 88 e0 ldi r24, 0x08 ; 8 - 3742: 80 93 bf 28 sts 0x28BF, r24 - _7BUID = 0x00; - 3746: 10 92 be 28 sts 0x28BE, r1 - 374a: 08 95 ret - -0000374c : -} - -void MifarePlus1kAppInit_7B(void) -{ - State = STATE_IDLE; - 374c: 81 e0 ldi r24, 0x01 ; 1 - 374e: 80 93 db 28 sts 0x28DB, r24 - CardATQAValue = MFPlus_ATQA_VALUE; - 3752: 84 e4 ldi r24, 0x44 ; 68 - 3754: 90 e0 ldi r25, 0x00 ; 0 - 3756: 80 93 c0 28 sts 0x28C0, r24 - 375a: 90 93 c1 28 sts 0x28C1, r25 - CardSAKValue = MFCLASSIC_1K_SAK_CL1_VALUE; - 375e: 88 e0 ldi r24, 0x08 ; 8 - 3760: 80 93 bf 28 sts 0x28BF, r24 - uint8_t UidSize = ActiveConfiguration.UidSize; - _7BUID = (UidSize == 7); - 3764: 81 e0 ldi r24, 0x01 ; 1 - 3766: 90 91 05 29 lds r25, 0x2905 - 376a: 97 30 cpi r25, 0x07 ; 7 - 376c: 09 f0 breq .+2 ; 0x3770 - 376e: 80 e0 ldi r24, 0x00 ; 0 - 3770: 80 93 be 28 sts 0x28BE, r24 - 3774: 08 95 ret - -00003776 : -} - -void MifareClassicAppInit4K(void) -{ - State = STATE_IDLE; - 3776: 81 e0 ldi r24, 0x01 ; 1 - 3778: 80 93 db 28 sts 0x28DB, r24 - CardATQAValue = MFCLASSIC_4K_ATQA_VALUE; - 377c: 82 e0 ldi r24, 0x02 ; 2 - 377e: 90 e0 ldi r25, 0x00 ; 0 - 3780: 80 93 c0 28 sts 0x28C0, r24 - 3784: 90 93 c1 28 sts 0x28C1, r25 - CardSAKValue = MFCLASSIC_4K_SAK_CL1_VALUE; - 3788: 88 e1 ldi r24, 0x18 ; 24 - 378a: 80 93 bf 28 sts 0x28BF, r24 - _7BUID = 0x00; - 378e: 10 92 be 28 sts 0x28BE, r1 - 3792: 08 95 ret - -00003794 : -} - -void MifareClassicAppReset(void) -{ - State = STATE_IDLE; - 3794: 81 e0 ldi r24, 0x01 ; 1 - 3796: 80 93 db 28 sts 0x28DB, r24 - 379a: 08 95 ret - -0000379c : -} - -void MifareClassicAppTask(void) -{ - 379c: 08 95 ret - -0000379e : - -} - -uint16_t MifareClassicAppProcess(uint8_t* Buffer, uint16_t BitCount) -{ - 379e: 7f 92 push r7 - 37a0: 8f 92 push r8 - 37a2: 9f 92 push r9 - 37a4: af 92 push r10 - 37a6: bf 92 push r11 - 37a8: cf 92 push r12 - 37aa: df 92 push r13 - 37ac: ef 92 push r14 - 37ae: ff 92 push r15 - 37b0: 0f 93 push r16 - 37b2: 1f 93 push r17 - 37b4: cf 93 push r28 - 37b6: df 93 push r29 - 37b8: cd b7 in r28, 0x3d ; 61 - 37ba: de b7 in r29, 0x3e ; 62 - 37bc: 2e 97 sbiw r28, 0x0e ; 14 - 37be: cd bf out 0x3d, r28 ; 61 - 37c0: de bf out 0x3e, r29 ; 62 - 37c2: 8c 01 movw r16, r24 - switch(State) { - 37c4: 40 91 db 28 lds r20, 0x28DB - 37c8: 50 e0 ldi r21, 0x00 ; 0 - 37ca: 4d 30 cpi r20, 0x0D ; 13 - 37cc: 51 05 cpc r21, r1 - 37ce: 98 f0 brcs .+38 ; 0x37f6 - - *BitCount = ISO14443A_SAK_FRAME_SIZE; - return true; - } else { - /* We have not been selected. Don't send anything. */ - *BitCount = 0; - 37d0: 80 e0 ldi r24, 0x00 ; 0 - 37d2: 90 e0 ldi r25, 0x00 ; 0 - break; - } - - /* No response has been sent, when we reach here */ - return ISO14443A_APP_NO_RESPONSE; -} - 37d4: 2e 96 adiw r28, 0x0e ; 14 - 37d6: cd bf out 0x3d, r28 ; 61 - 37d8: de bf out 0x3e, r29 ; 62 - 37da: df 91 pop r29 - 37dc: cf 91 pop r28 - 37de: 1f 91 pop r17 - 37e0: 0f 91 pop r16 - 37e2: ff 90 pop r15 - 37e4: ef 90 pop r14 - 37e6: df 90 pop r13 - 37e8: cf 90 pop r12 - 37ea: bf 90 pop r11 - 37ec: af 90 pop r10 - 37ee: 9f 90 pop r9 - 37f0: 8f 90 pop r8 - 37f2: 7f 90 pop r7 - 37f4: 08 95 ret - -} - -uint16_t MifareClassicAppProcess(uint8_t* Buffer, uint16_t BitCount) -{ - switch(State) { - 37f6: fa 01 movw r30, r20 - 37f8: ee 59 subi r30, 0x9E ; 158 - 37fa: fe 4f sbci r31, 0xFE ; 254 - 37fc: 0c 94 7a 2b jmp 0x56f4 ; 0x56f4 <__tablejump2__> - 3800: 7c 01 movw r14, r24 - 3802: d1 2c mov r13, r1 - * check for CRC. Then write the data when ReadOnly mode is not - * activated. */ - - /* We receive 16 bytes of data to be written and 2 bytes CRCA. Decrypt */ - for (uint8_t i=0; i<(MEM_BYTES_PER_BLOCK + ISO14443A_CRCA_SIZE); i++) - Buffer[i] ^= Crypto1Byte(); - 3804: f7 01 movw r30, r14 - 3806: c0 80 ld r12, Z - 3808: ef d6 rcall .+3550 ; 0x45e8 - 380a: 8c 25 eor r24, r12 - 380c: d7 01 movw r26, r14 - 380e: 8d 93 st X+, r24 - 3810: 7d 01 movw r14, r26 - * sending the data to be written. Decrypt the data first and - * check for CRC. Then write the data when ReadOnly mode is not - * activated. */ - - /* We receive 16 bytes of data to be written and 2 bytes CRCA. Decrypt */ - for (uint8_t i=0; i<(MEM_BYTES_PER_BLOCK + ISO14443A_CRCA_SIZE); i++) - 3812: d3 94 inc r13 - 3814: b2 e1 ldi r27, 0x12 ; 18 - 3816: db 12 cpse r13, r27 - 3818: f5 cf rjmp .-22 ; 0x3804 - Buffer[i] ^= Crypto1Byte(); - - if (ISO14443ACheckCRCA(Buffer, MEM_BYTES_PER_BLOCK)) { - 381a: 60 e1 ldi r22, 0x10 ; 16 - 381c: 70 e0 ldi r23, 0x00 ; 0 - 381e: c8 01 movw r24, r16 - 3820: 3b d5 rcall .+2678 ; 0x4298 - 3822: 88 23 and r24, r24 - 3824: 09 f4 brne .+2 ; 0x3828 - 3826: 33 c2 rjmp .+1126 ; 0x3c8e - if (!ActiveConfiguration.ReadOnly) { - 3828: 80 91 06 29 lds r24, 0x2906 - 382c: 88 23 and r24, r24 - 382e: 09 f4 brne .+2 ; 0x3832 - 3830: a8 c1 rjmp .+848 ; 0x3b82 - MemoryWriteBlock(Buffer, CurrentAddress * MEM_BYTES_PER_BLOCK, MEM_BYTES_PER_BLOCK); - } else { - /* Silently ignore in ReadOnly mode */ - } - - Buffer[0] = ACK_VALUE ^ Crypto1Nibble(); - 3832: ed d6 rcall .+3546 ; 0x460e - 3834: 9a e0 ldi r25, 0x0A ; 10 - 3836: 98 27 eor r25, r24 - 3838: d8 01 movw r26, r16 - 383a: 9c 93 st X, r25 - 383c: 17 c0 rjmp .+46 ; 0x386c - 383e: 7c 01 movw r14, r24 - -} - -uint16_t MifareClassicAppProcess(uint8_t* Buffer, uint16_t BitCount) -{ - switch(State) { - 3840: 56 e0 ldi r21, 0x06 ; 6 - 3842: d5 2e mov r13, r21 - * decrypt the data and check CRC. Read data from the requested block - * address into the global block buffer and check for integrity. Then - * add or subtract according to issued command if necessary and store - * the block back into the global block buffer. */ - for (uint8_t i=0; i<(MEM_VALUE_SIZE + ISO14443A_CRCA_SIZE); i++) - Buffer[i] ^= Crypto1Byte(); - 3844: d7 01 movw r26, r14 - 3846: cc 90 ld r12, X - 3848: cf d6 rcall .+3486 ; 0x45e8 - 384a: 8c 25 eor r24, r12 - 384c: f7 01 movw r30, r14 - 384e: 81 93 st Z+, r24 - 3850: 7f 01 movw r14, r30 - 3852: da 94 dec r13 - * been issued earlier and the reader is now sending the data. First, - * decrypt the data and check CRC. Read data from the requested block - * address into the global block buffer and check for integrity. Then - * add or subtract according to issued command if necessary and store - * the block back into the global block buffer. */ - for (uint8_t i=0; i<(MEM_VALUE_SIZE + ISO14443A_CRCA_SIZE); i++) - 3854: b9 f7 brne .-18 ; 0x3844 - Buffer[i] ^= Crypto1Byte(); - - if (ISO14443ACheckCRCA(Buffer, MEM_VALUE_SIZE )) { - 3856: 64 e0 ldi r22, 0x04 ; 4 - 3858: 70 e0 ldi r23, 0x00 ; 0 - 385a: c8 01 movw r24, r16 - 385c: 1d d5 rcall .+2618 ; 0x4298 - 385e: 81 11 cpse r24, r1 - 3860: fc c1 rjmp .+1016 ; 0x3c5a - /* Not sure if this is the correct error code.. */ - Buffer[0] = NAK_OTHER_ERROR ^ Crypto1Nibble(); - } - } else { - /* CRC Error. */ - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - 3862: d5 d6 rcall .+3498 ; 0x460e - 3864: 91 e0 ldi r25, 0x01 ; 1 - 3866: 98 27 eor r25, r24 - 3868: d8 01 movw r26, r16 - 386a: 9c 93 st X, r25 - } - - State = STATE_AUTHED_IDLE; - 386c: 88 e0 ldi r24, 0x08 ; 8 - 386e: 80 93 db 28 sts 0x28DB, r24 - return ACK_NAK_FRAME_SIZE; - 3872: 84 e0 ldi r24, 0x04 ; 4 - 3874: 90 e0 ldi r25, 0x00 ; 0 - 3876: ae cf rjmp .-164 ; 0x37d4 -uint16_t MifareClassicAppProcess(uint8_t* Buffer, uint16_t BitCount) -{ - switch(State) { - case STATE_IDLE: - case STATE_HALT: - if (ISO14443AWakeUp(Buffer, &BitCount, CardATQAValue)) { - 3878: 20 91 c0 28 lds r18, 0x28C0 - 387c: 90 91 c1 28 lds r25, 0x28C1 -INLINE -bool ISO14443AWakeUp(void* Buffer, uint16_t* BitCount, uint16_t ATQAValue) -{ - uint8_t* DataPtr = (uint8_t*) Buffer; - - if ( (DataPtr[0] == ISO14443A_CMD_REQA) || (DataPtr[0] == ISO14443A_CMD_WUPA) ){ - 3880: d8 01 movw r26, r16 - 3882: 8c 91 ld r24, X - 3884: 86 32 cpi r24, 0x26 ; 38 - 3886: 09 f4 brne .+2 ; 0x388a - 3888: 5b c1 rjmp .+694 ; 0x3b40 - 388a: 82 35 cpi r24, 0x52 ; 82 - 388c: 09 f4 brne .+2 ; 0x3890 - 388e: 58 c1 rjmp .+688 ; 0x3b40 - State = STATE_READY1; - return BitCount; - } -#ifdef SUPPORT_MF_CLASSIC_MAGIC_MODE - else if (Buffer[0] == CMD_CHINESE_UNLOCK) { - 3890: 80 34 cpi r24, 0x40 ; 64 - 3892: 09 f0 breq .+2 ; 0x3896 - 3894: 9d cf rjmp .-198 ; 0x37d0 - State = STATE_CHINESE_IDLE; - 3896: 82 e0 ldi r24, 0x02 ; 2 - 3898: 80 93 db 28 sts 0x28DB, r24 - Buffer[0] = ACK_VALUE; - 389c: 8a e0 ldi r24, 0x0A ; 10 - 389e: d8 01 movw r26, r16 - 38a0: 8c 93 st X, r24 - return ACK_NAK_FRAME_SIZE; - 38a2: 84 e0 ldi r24, 0x04 ; 4 - 38a4: 90 e0 ldi r25, 0x00 ; 0 - 38a6: 96 cf rjmp .-212 ; 0x37d4 - break; - -#ifdef SUPPORT_MF_CLASSIC_MAGIC_MODE - case STATE_CHINESE_IDLE: - /* Support special china commands that dont require authentication. */ - if (Buffer[0] == CMD_CHINESE_UNLOCK_RW) { - 38a8: fc 01 movw r30, r24 - 38aa: 80 81 ld r24, Z - /* Unlock read and write commands */ - Buffer[0] = ACK_VALUE; - return ACK_NAK_FRAME_SIZE; - } else if (Buffer[0] == CMD_CHINESE_WIPE) { - 38ac: 98 2f mov r25, r24 - 38ae: 9d 7f andi r25, 0xFD ; 253 - 38b0: 91 34 cpi r25, 0x41 ; 65 - 38b2: 09 f4 brne .+2 ; 0x38b6 - 38b4: 58 c1 rjmp .+688 ; 0x3b66 - /* Wipe memory */ - Buffer[0] = ACK_VALUE; - return ACK_NAK_FRAME_SIZE; - } else if (Buffer[0] == CMD_READ) { - 38b6: 80 33 cpi r24, 0x30 ; 48 - 38b8: 09 f4 brne .+2 ; 0x38bc - 38ba: 85 c1 rjmp .+778 ; 0x3bc6 - * BITS_PER_BYTE; - } else { - Buffer[0] = NAK_CRC_ERROR; - return ACK_NAK_FRAME_SIZE; - } - } else if (Buffer[0] == CMD_WRITE) { - 38bc: 80 3a cpi r24, 0xA0 ; 160 - 38be: 09 f4 brne .+2 ; 0x38c2 - 38c0: 29 c4 rjmp .+2130 ; 0x4114 - return ACK_NAK_FRAME_SIZE; - } else { - Buffer[0] = NAK_CRC_ERROR; - return ACK_NAK_FRAME_SIZE; - } - } else if (Buffer[0] == CMD_HALT) { - 38c2: 80 35 cpi r24, 0x50 ; 80 - 38c4: 09 f0 breq .+2 ; 0x38c8 - 38c6: 84 cf rjmp .-248 ; 0x37d0 - /* Halts the tag. According to the ISO14443, the second - * byte is supposed to be 0. */ - if (Buffer[1] == 0) { - 38c8: f8 01 movw r30, r16 - 38ca: 81 81 ldd r24, Z+1 ; 0x01 - 38cc: 88 23 and r24, r24 - 38ce: 09 f4 brne .+2 ; 0x38d2 - 38d0: 25 c2 rjmp .+1098 ; 0x3d1c - } else { - Buffer[0] = NAK_CRC_ERROR; - return ACK_NAK_FRAME_SIZE; - } - } else { - Buffer[0] = NAK_INVALID_ARG; - 38d2: d8 01 movw r26, r16 - 38d4: 1c 92 st X, r1 - return ACK_NAK_FRAME_SIZE; - 38d6: 84 e0 ldi r24, 0x04 ; 4 - 38d8: 90 e0 ldi r25, 0x00 ; 0 - 38da: 7c cf rjmp .-264 ; 0x37d4 - State = STATE_HALT; - } - break; - - case STATE_READY2: - if (ISO14443AWakeUp(Buffer, &BitCount, CardATQAValue)) { - 38dc: 20 91 c0 28 lds r18, 0x28C0 - 38e0: 90 91 c1 28 lds r25, 0x28C1 - 38e4: f8 01 movw r30, r16 - 38e6: 80 81 ld r24, Z - 38e8: 86 32 cpi r24, 0x26 ; 38 - 38ea: 09 f4 brne .+2 ; 0x38ee - 38ec: 32 c1 rjmp .+612 ; 0x3b52 - 38ee: 82 35 cpi r24, 0x52 ; 82 - 38f0: 09 f4 brne .+2 ; 0x38f4 - 38f2: 2f c1 rjmp .+606 ; 0x3b52 - State = STATE_READY1; - return BitCount; - } else if (Buffer[0] == ISO14443A_CMD_SELECT_CL2) { - 38f4: 85 39 cpi r24, 0x95 ; 149 - 38f6: 09 f0 breq .+2 ; 0x38fa - 38f8: 1e c1 rjmp .+572 ; 0x3b36 - /* Load UID CL2 and perform anticollision */ - uint8_t UidCL2[ISO14443A_CL_UID_SIZE]; - MemoryReadBlock(UidCL2, MEM_UID_CL2_ADDRESS, MEM_UID_CL2_SIZE); - 38fa: 44 e0 ldi r20, 0x04 ; 4 - 38fc: 50 e0 ldi r21, 0x00 ; 0 - 38fe: 63 e0 ldi r22, 0x03 ; 3 - 3900: 70 e0 ldi r23, 0x00 ; 0 - 3902: ce 01 movw r24, r28 - 3904: 01 96 adiw r24, 0x01 ; 1 - 3906: 0e 94 62 07 call 0xec4 ; 0xec4 - - if (ISO14443ASelect(Buffer, &BitCount, UidCL2, CardSAKValue)) { - 390a: 90 91 bf 28 lds r25, 0x28BF - uint8_t* DataPtr = (uint8_t*) Buffer; - uint8_t NVB = DataPtr[1]; - //uint8_t CollisionByteCount = (NVB >> 4) & 0x0F; - //uint8_t CollisionBitCount = (NVB >> 0) & 0x0F; - - switch (NVB) { - 390e: f8 01 movw r30, r16 - 3910: 81 81 ldd r24, Z+1 ; 0x01 - 3912: 80 32 cpi r24, 0x20 ; 32 - 3914: 09 f4 brne .+2 ; 0x3918 - 3916: d1 c3 rjmp .+1954 ; 0x40ba - 3918: 80 37 cpi r24, 0x70 ; 112 - 391a: 09 f0 breq .+2 ; 0x391e - 391c: 59 cf rjmp .-334 ; 0x37d0 - return false; - - case ISO14443A_NVB_AC_END: - /* End of anticollision procedure. - * Send SAK CLn if we are selected. */ - if ( (DataPtr[2] == UidCL[0]) && - 391e: f8 01 movw r30, r16 - 3920: 22 81 ldd r18, Z+2 ; 0x02 - 3922: 89 81 ldd r24, Y+1 ; 0x01 - 3924: 28 13 cpse r18, r24 - 3926: 54 cf rjmp .-344 ; 0x37d0 - 3928: 23 81 ldd r18, Z+3 ; 0x03 - 392a: 8a 81 ldd r24, Y+2 ; 0x02 - 392c: 28 13 cpse r18, r24 - 392e: 50 cf rjmp .-352 ; 0x37d0 - (DataPtr[3] == UidCL[1]) && - 3930: 24 81 ldd r18, Z+4 ; 0x04 - 3932: 8b 81 ldd r24, Y+3 ; 0x03 - 3934: 28 13 cpse r18, r24 - 3936: 4c cf rjmp .-360 ; 0x37d0 - (DataPtr[4] == UidCL[2]) && - 3938: 25 81 ldd r18, Z+5 ; 0x05 - 393a: 8c 81 ldd r24, Y+4 ; 0x04 - 393c: 28 13 cpse r18, r24 - 393e: 48 cf rjmp .-368 ; 0x37d0 - (DataPtr[5] == UidCL[3]) ) { - - DataPtr[0] = SAKValue; - 3940: 90 83 st Z, r25 - ISO14443AAppendCRCA(Buffer, 1); - 3942: 61 e0 ldi r22, 0x01 ; 1 - 3944: 70 e0 ldi r23, 0x00 ; 0 - 3946: c8 01 movw r24, r16 - 3948: 79 d4 rcall .+2290 ; 0x423c - State = STATE_ACTIVE; - 394a: 86 e0 ldi r24, 0x06 ; 6 - 394c: 80 93 db 28 sts 0x28DB, r24 - - *BitCount = ISO14443A_SAK_FRAME_SIZE; - 3950: 88 e1 ldi r24, 0x18 ; 24 - 3952: 90 e0 ldi r25, 0x00 ; 0 - 3954: 3f cf rjmp .-386 ; 0x37d4 - } - } - break; - - case STATE_CHINESE_WRITE: - if (ISO14443ACheckCRCA(Buffer, MEM_BYTES_PER_BLOCK)) { - 3956: 60 e1 ldi r22, 0x10 ; 16 - 3958: 70 e0 ldi r23, 0x00 ; 0 - 395a: 9e d4 rcall .+2364 ; 0x4298 - 395c: 88 23 and r24, r24 - 395e: 09 f4 brne .+2 ; 0x3962 - 3960: 07 c1 rjmp .+526 ; 0x3b70 - /* CRC check passed. Write data into memory and send ACK. */ - if (!ActiveConfiguration.ReadOnly) { - 3962: 80 91 06 29 lds r24, 0x2906 - 3966: 88 23 and r24, r24 - 3968: 09 f4 brne .+2 ; 0x396c - 396a: e0 c1 rjmp .+960 ; 0x3d2c - MemoryWriteBlock(Buffer, CurrentAddress * MEM_BYTES_PER_BLOCK, MEM_BYTES_PER_BLOCK); - } - - Buffer[0] = ACK_VALUE; - 396c: 8a e0 ldi r24, 0x0A ; 10 - 396e: f8 01 movw r30, r16 - 3970: 80 83 st Z, r24 - 3972: 01 c1 rjmp .+514 ; 0x3b76 - - case STATE_AUTHING: - /* Reader delivers an encrypted nonce. We use it - * to setup the crypto1 LFSR in nonlinear feedback mode. - * Furthermore it delivers an encrypted answer. Decrypt and check it */ - Crypto1Auth(&Buffer[0]); - 3974: 14 d6 rcall .+3112 ; 0x459e - 3976: 78 01 movw r14, r16 - 3978: b4 e0 ldi r27, 0x04 ; 4 - 397a: eb 0e add r14, r27 - 397c: f1 1c adc r15, r1 - - for (uint8_t i=0; i<4; i++) - 397e: b1 2c mov r11, r1 - Buffer[i+4] ^= Crypto1Byte(); - 3980: f7 01 movw r30, r14 - 3982: a0 80 ld r10, Z - 3984: 31 d6 rcall .+3170 ; 0x45e8 - 3986: 8a 25 eor r24, r10 - 3988: d7 01 movw r26, r14 - 398a: 8d 93 st X+, r24 - 398c: 7d 01 movw r14, r26 - /* Reader delivers an encrypted nonce. We use it - * to setup the crypto1 LFSR in nonlinear feedback mode. - * Furthermore it delivers an encrypted answer. Decrypt and check it */ - Crypto1Auth(&Buffer[0]); - - for (uint8_t i=0; i<4; i++) - 398e: b3 94 inc r11 - 3990: b4 e0 ldi r27, 0x04 ; 4 - 3992: bb 12 cpse r11, r27 - 3994: f5 cf rjmp .-22 ; 0x3980 - Buffer[i+4] ^= Crypto1Byte(); - - if ((Buffer[4] == ReaderResponse[0]) && - 3996: f8 01 movw r30, r16 - 3998: 94 81 ldd r25, Z+4 ; 0x04 - 399a: 80 91 d3 28 lds r24, 0x28D3 - 399e: 98 17 cp r25, r24 - 39a0: 09 f4 brne .+2 ; 0x39a4 - 39a2: 1d c1 rjmp .+570 ; 0x3bde - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - return ACK_NAK_FRAME_SIZE; - } - } else { - /* Unknown command. Enter HALT state */ - State = STATE_IDLE; - 39a4: 81 e0 ldi r24, 0x01 ; 1 - 39a6: 80 93 db 28 sts 0x28DB, r24 - /* Unknown state? Should never happen. */ - break; - } - - /* No response has been sent, when we reach here */ - return ISO14443A_APP_NO_RESPONSE; - 39aa: 80 e0 ldi r24, 0x00 ; 0 - 39ac: 90 e0 ldi r25, 0x00 ; 0 - } else { - /* Unknown command. Enter HALT state */ - State = STATE_IDLE; - } - - break; - 39ae: 12 cf rjmp .-476 ; 0x37d4 - -} - -uint16_t MifareClassicAppProcess(uint8_t* Buffer, uint16_t BitCount) -{ - switch(State) { - 39b0: 6c 01 movw r12, r24 - 39b2: e4 e0 ldi r30, 0x04 ; 4 - 39b4: be 2e mov r11, r30 - - case STATE_AUTHED_IDLE: - /* In this state, all communication is encrypted. Thus we first have to encrypt - * the incoming data. */ - for (uint8_t i=0; i<4; i++) - Buffer[i] ^= Crypto1Byte(); - 39b6: d6 01 movw r26, r12 - 39b8: ac 90 ld r10, X - 39ba: 16 d6 rcall .+3116 ; 0x45e8 - 39bc: 8a 25 eor r24, r10 - 39be: f6 01 movw r30, r12 - 39c0: 81 93 st Z+, r24 - 39c2: 6f 01 movw r12, r30 - 39c4: ba 94 dec r11 - break; - - case STATE_AUTHED_IDLE: - /* In this state, all communication is encrypted. Thus we first have to encrypt - * the incoming data. */ - for (uint8_t i=0; i<4; i++) - 39c6: b9 f7 brne .-18 ; 0x39b6 - Buffer[i] ^= Crypto1Byte(); - - if (Buffer[0] == CMD_READ) { - 39c8: d8 01 movw r26, r16 - 39ca: 8c 91 ld r24, X - 39cc: 80 33 cpi r24, 0x30 ; 48 - 39ce: 09 f4 brne .+2 ; 0x39d2 - 39d0: bc c1 rjmp .+888 ; 0x3d4a - * BITS_PER_BYTE) | ISO14443A_APP_CUSTOM_PARITY; - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - return ACK_NAK_FRAME_SIZE; - } - } else if (Buffer[0] == CMD_WRITE) { - 39d2: 80 3a cpi r24, 0xA0 ; 160 - 39d4: 09 f4 brne .+2 ; 0x39d8 - 39d6: f3 c1 rjmp .+998 ; 0x3dbe - Buffer[0] = ACK_VALUE ^ Crypto1Nibble(); - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - } - return ACK_NAK_FRAME_SIZE; - } else if (Buffer[0] == CMD_DECREMENT) { - 39d8: 80 3c cpi r24, 0xC0 ; 192 - 39da: 09 f4 brne .+2 ; 0x39de - 39dc: 30 c2 rjmp .+1120 ; 0x3e3e - Buffer[0] = ACK_VALUE ^ Crypto1Nibble(); - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - } - return ACK_NAK_FRAME_SIZE; - } else if (Buffer[0] == CMD_INCREMENT) { - 39de: 81 3c cpi r24, 0xC1 ; 193 - 39e0: 09 f4 brne .+2 ; 0x39e4 - 39e2: c7 c2 rjmp .+1422 ; 0x3f72 - Buffer[0] = ACK_VALUE ^ Crypto1Nibble(); - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - } - return ACK_NAK_FRAME_SIZE; - } else if (Buffer[0] == CMD_RESTORE) { - 39e4: 82 3c cpi r24, 0xC2 ; 194 - 39e6: 09 f4 brne .+2 ; 0x39ea - 39e8: d8 c0 rjmp .+432 ; 0x3b9a - Buffer[0] = ACK_VALUE ^ Crypto1Nibble(); - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - } - return ACK_NAK_FRAME_SIZE; - }else if (Buffer[0] == CMD_TRANSFER) { - 39ea: 80 3b cpi r24, 0xB0 ; 176 - 39ec: 09 f4 brne .+2 ; 0x39f0 - 39ee: d8 c2 rjmp .+1456 ; 0x3fa0 - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - } - - return ACK_NAK_FRAME_SIZE; - } else if ( (Buffer[0] == CMD_AUTH_A) || (Buffer[0] == CMD_AUTH_B) ) { - 39f0: 80 56 subi r24, 0x60 ; 96 - 39f2: 82 30 cpi r24, 0x02 ; 2 - 39f4: b8 f6 brcc .-82 ; 0x39a4 - if (ISO14443ACheckCRCA(Buffer, CMD_AUTH_FRAME_SIZE)) { - 39f6: 62 e0 ldi r22, 0x02 ; 2 - 39f8: 70 e0 ldi r23, 0x00 ; 0 - 39fa: c8 01 movw r24, r16 - 39fc: 4d d4 rcall .+2202 ; 0x4298 - 39fe: 88 23 and r24, r24 - 3a00: 09 f4 brne .+2 ; 0x3a04 - 3a02: a0 c1 rjmp .+832 ; 0x3d44 - /* Nested authentication. */ - uint8_t SectorAddress = Buffer[1] & MEM_SECTOR_ADDR_MASK; - 3a04: f8 01 movw r30, r16 - 3a06: 81 81 ldd r24, Z+1 ; 0x01 - 3a08: 8c 73 andi r24, 0x3C ; 60 - uint8_t KeyOffset = (Buffer[0] == CMD_AUTH_A ? MEM_KEY_A_OFFSET : MEM_KEY_B_OFFSET); - 3a0a: 90 81 ld r25, Z - 3a0c: 90 36 cpi r25, 0x60 ; 96 - 3a0e: 09 f4 brne .+2 ; 0x3a12 - 3a10: a1 c3 rjmp .+1858 ; 0x4154 - 3a12: 6a e3 ldi r22, 0x3A ; 58 - 3a14: 70 e0 ldi r23, 0x00 ; 0 - uint16_t KeyAddress = (uint16_t) SectorAddress * MEM_BYTES_PER_BLOCK + KeyOffset; - 3a16: 7b 01 movw r14, r22 - 3a18: f0 e1 ldi r31, 0x10 ; 16 - 3a1a: 8f 9f mul r24, r31 - 3a1c: e0 0c add r14, r0 - 3a1e: f1 1c adc r15, r1 - 3a20: 11 24 eor r1, r1 - uint8_t Key[6]; - uint8_t Uid[4]; - uint8_t CardNonce[4]; - - /* Generate a random nonce and read UID and key from memory */ - RandomGetBuffer(CardNonce, sizeof(CardNonce)); - 3a22: 4e 01 movw r8, r28 - 3a24: 37 e0 ldi r19, 0x07 ; 7 - 3a26: 83 0e add r8, r19 - 3a28: 91 1c adc r9, r1 - 3a2a: 64 e0 ldi r22, 0x04 ; 4 - 3a2c: c4 01 movw r24, r8 - 3a2e: 0e 94 bd 06 call 0xd7a ; 0xd7a - if (_7BUID) - 3a32: 80 91 be 28 lds r24, 0x28BE - MemoryReadBlock(Uid, MEM_UID_CL2_ADDRESS, MEM_UID_CL2_SIZE); - 3a36: 5e 01 movw r10, r28 - uint8_t Uid[4]; - uint8_t CardNonce[4]; - - /* Generate a random nonce and read UID and key from memory */ - RandomGetBuffer(CardNonce, sizeof(CardNonce)); - if (_7BUID) - 3a38: 88 23 and r24, r24 - 3a3a: 09 f4 brne .+2 ; 0x3a3e - 3a3c: 80 c3 rjmp .+1792 ; 0x413e - MemoryReadBlock(Uid, MEM_UID_CL2_ADDRESS, MEM_UID_CL2_SIZE); - 3a3e: 8b e0 ldi r24, 0x0B ; 11 - 3a40: a8 0e add r10, r24 - 3a42: b1 1c adc r11, r1 - 3a44: 44 e0 ldi r20, 0x04 ; 4 - 3a46: 50 e0 ldi r21, 0x00 ; 0 - 3a48: 63 e0 ldi r22, 0x03 ; 3 - 3a4a: 70 e0 ldi r23, 0x00 ; 0 - 3a4c: c5 01 movw r24, r10 - 3a4e: 0e 94 62 07 call 0xec4 ; 0xec4 - else - MemoryReadBlock(Uid, MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE); - MemoryReadBlock(Key, KeyAddress, MEM_KEY_SIZE); - 3a52: 46 e0 ldi r20, 0x06 ; 6 - 3a54: 50 e0 ldi r21, 0x00 ; 0 - 3a56: b7 01 movw r22, r14 - 3a58: ce 01 movw r24, r28 - 3a5a: 01 96 adiw r24, 0x01 ; 1 - 3a5c: 0e 94 62 07 call 0xec4 ; 0xec4 - 3a60: 8f 81 ldd r24, Y+7 ; 0x07 - 3a62: 98 85 ldd r25, Y+8 ; 0x08 - 3a64: a9 85 ldd r26, Y+9 ; 0x09 - 3a66: ba 85 ldd r27, Y+10 ; 0x0a - 3a68: 80 93 d3 28 sts 0x28D3, r24 - 3a6c: 90 93 d4 28 sts 0x28D4, r25 - 3a70: a0 93 d5 28 sts 0x28D5, r26 - 3a74: b0 93 d6 28 sts 0x28D6, r27 - - /* Precalculate the reader response from card-nonce */ - for (uint8_t i=0; i - 3a82: c0 90 d3 28 lds r12, 0x28D3 - 3a86: d0 90 d4 28 lds r13, 0x28D4 - 3a8a: e0 90 d5 28 lds r14, 0x28D5 - 3a8e: f0 90 d6 28 lds r15, 0x28D6 - 3a92: c0 92 d7 28 sts 0x28D7, r12 - 3a96: d0 92 d8 28 sts 0x28D8, r13 - 3a9a: e0 92 d9 28 sts 0x28D9, r14 - 3a9e: f0 92 da 28 sts 0x28DA, r15 - - /* Precalculate our response from the reader response */ - for (uint8_t i=0; i - - /* Setup crypto1 cipher. */ - Crypto1Setup(Key, Uid, CardNonce); - 3aac: a4 01 movw r20, r8 - 3aae: b5 01 movw r22, r10 - 3ab0: ce 01 movw r24, r28 - 3ab2: 01 96 adiw r24, 0x01 ; 1 - 3ab4: a7 d4 rcall .+2382 ; 0x4404 - 3ab6: 8f 81 ldd r24, Y+7 ; 0x07 - 3ab8: 98 85 ldd r25, Y+8 ; 0x08 - 3aba: a9 85 ldd r26, Y+9 ; 0x09 - 3abc: ba 85 ldd r27, Y+10 ; 0x0a - 3abe: f8 01 movw r30, r16 - 3ac0: 80 83 st Z, r24 - 3ac2: 91 83 std Z+1, r25 ; 0x01 - 3ac4: a2 83 std Z+2, r26 ; 0x02 - 3ac6: b3 83 std Z+3, r27 ; 0x03 - for (uint8_t i=0; i - State = STATE_HALT; - } - break; - - case STATE_ACTIVE: - if (ISO14443AWakeUp(Buffer, &BitCount, CardATQAValue)) { - 3ad4: 20 91 c0 28 lds r18, 0x28C0 - 3ad8: 90 91 c1 28 lds r25, 0x28C1 -INLINE -bool ISO14443AWakeUp(void* Buffer, uint16_t* BitCount, uint16_t ATQAValue) -{ - uint8_t* DataPtr = (uint8_t*) Buffer; - - if ( (DataPtr[0] == ISO14443A_CMD_REQA) || (DataPtr[0] == ISO14443A_CMD_WUPA) ){ - 3adc: d8 01 movw r26, r16 - 3ade: 8c 91 ld r24, X - 3ae0: 86 32 cpi r24, 0x26 ; 38 - 3ae2: 71 f1 breq .+92 ; 0x3b40 - 3ae4: 82 35 cpi r24, 0x52 ; 82 - 3ae6: 61 f1 breq .+88 ; 0x3b40 - State = STATE_READY1; - return BitCount; - } else if (Buffer[0] == CMD_HALT) { - 3ae8: 80 35 cpi r24, 0x50 ; 80 - 3aea: 09 f4 brne .+2 ; 0x3aee - 3aec: 12 c1 rjmp .+548 ; 0x3d12 - } - } else { - Buffer[0] = NAK_INVALID_ARG; - return ACK_NAK_FRAME_SIZE; - } - } else if ( (Buffer[0] == CMD_AUTH_A) || (Buffer[0] == CMD_AUTH_B)) { - 3aee: 90 ea ldi r25, 0xA0 ; 160 - 3af0: 98 0f add r25, r24 - 3af2: 92 30 cpi r25, 0x02 ; 2 - 3af4: 08 f4 brcc .+2 ; 0x3af8 - 3af6: 6d c2 rjmp .+1242 ; 0x3fd2 - return CMD_AUTH_RB_FRAME_SIZE * BITS_PER_BYTE; - } else { - Buffer[0] = NAK_CRC_ERROR; - return ACK_NAK_FRAME_SIZE; - } - } else if ( (Buffer[0] == CMD_READ) || (Buffer[0] == CMD_WRITE) || (Buffer[0] == CMD_DECREMENT) - 3af8: 98 2f mov r25, r24 - 3afa: 9f 77 andi r25, 0x7F ; 127 - 3afc: 90 33 cpi r25, 0x30 ; 48 - 3afe: 31 f0 breq .+12 ; 0x3b0c - 3b00: 80 3a cpi r24, 0xA0 ; 160 - 3b02: 21 f0 breq .+8 ; 0x3b0c - 3b04: 80 5c subi r24, 0xC0 ; 192 - 3b06: 83 30 cpi r24, 0x03 ; 3 - 3b08: 08 f0 brcs .+2 ; 0x3b0c - 3b0a: 4c cf rjmp .-360 ; 0x39a4 - || (Buffer[0] == CMD_INCREMENT) || (Buffer[0] == CMD_RESTORE) || (Buffer[0] == CMD_TRANSFER) ) { - State = STATE_IDLE; - 3b0c: 81 e0 ldi r24, 0x01 ; 1 - 3b0e: 80 93 db 28 sts 0x28DB, r24 - Buffer[0] = NAK_NOT_AUTHED; - 3b12: 84 e0 ldi r24, 0x04 ; 4 - 3b14: d8 01 movw r26, r16 - 3b16: 8c 93 st X, r24 - return ACK_NAK_FRAME_SIZE; - 3b18: 90 e0 ldi r25, 0x00 ; 0 - 3b1a: 5c ce rjmp .-840 ; 0x37d4 - - return ACK_NAK_FRAME_SIZE; -#endif - - case STATE_READY1: - if (ISO14443AWakeUp(Buffer, &BitCount, CardATQAValue)) { - 3b1c: 20 91 c0 28 lds r18, 0x28C0 - 3b20: 90 91 c1 28 lds r25, 0x28C1 - 3b24: f8 01 movw r30, r16 - 3b26: 80 81 ld r24, Z - 3b28: 86 32 cpi r24, 0x26 ; 38 - 3b2a: 99 f0 breq .+38 ; 0x3b52 - 3b2c: 82 35 cpi r24, 0x52 ; 82 - 3b2e: 89 f0 breq .+34 ; 0x3b52 - State = STATE_READY1; - return BitCount; - } else if (Buffer[0] == ISO14443A_CMD_SELECT_CL1) { - 3b30: 83 39 cpi r24, 0x93 ; 147 - 3b32: 09 f4 brne .+2 ; 0x3b36 - 3b34: b2 c0 rjmp .+356 ; 0x3c9a - } - - return BitCount; - } else { - /* Unknown command. Enter HALT state. */ - State = STATE_HALT; - 3b36: 10 92 db 28 sts 0x28DB, r1 - /* Unknown state? Should never happen. */ - break; - } - - /* No response has been sent, when we reach here */ - return ISO14443A_APP_NO_RESPONSE; - 3b3a: 80 e0 ldi r24, 0x00 ; 0 - 3b3c: 90 e0 ldi r25, 0x00 ; 0 - return BitCount; - } else { - /* Unknown command. Enter HALT state. */ - State = STATE_HALT; - } - break; - 3b3e: 4a ce rjmp .-876 ; 0x37d4 - DataPtr[0] = (ATQAValue >> 0) & 0x00FF; - 3b40: f8 01 movw r30, r16 - 3b42: 20 83 st Z, r18 - DataPtr[1] = (ATQAValue >> 8) & 0x00FF; - 3b44: 91 83 std Z+1, r25 ; 0x01 - } - break; - - case STATE_ACTIVE: - if (ISO14443AWakeUp(Buffer, &BitCount, CardATQAValue)) { - State = STATE_READY1; - 3b46: 84 e0 ldi r24, 0x04 ; 4 - 3b48: 80 93 db 28 sts 0x28DB, r24 - - *BitCount = ISO14443A_ATQA_FRAME_SIZE; - 3b4c: 80 e1 ldi r24, 0x10 ; 16 - 3b4e: 90 e0 ldi r25, 0x00 ; 0 - return BitCount; - 3b50: 41 ce rjmp .-894 ; 0x37d4 -bool ISO14443AWakeUp(void* Buffer, uint16_t* BitCount, uint16_t ATQAValue) -{ - uint8_t* DataPtr = (uint8_t*) Buffer; - - if ( (DataPtr[0] == ISO14443A_CMD_REQA) || (DataPtr[0] == ISO14443A_CMD_WUPA) ){ - DataPtr[0] = (ATQAValue >> 0) & 0x00FF; - 3b52: d8 01 movw r26, r16 - 3b54: 2c 93 st X, r18 - DataPtr[1] = (ATQAValue >> 8) & 0x00FF; - 3b56: 11 96 adiw r26, 0x01 ; 1 - 3b58: 9c 93 st X, r25 - } - break; - - case STATE_READY2: - if (ISO14443AWakeUp(Buffer, &BitCount, CardATQAValue)) { - State = STATE_READY1; - 3b5a: 84 e0 ldi r24, 0x04 ; 4 - 3b5c: 80 93 db 28 sts 0x28DB, r24 - - *BitCount = ISO14443A_ATQA_FRAME_SIZE; - 3b60: 80 e1 ldi r24, 0x10 ; 16 - 3b62: 90 e0 ldi r25, 0x00 ; 0 - return BitCount; - 3b64: 37 ce rjmp .-914 ; 0x37d4 -#ifdef SUPPORT_MF_CLASSIC_MAGIC_MODE - case STATE_CHINESE_IDLE: - /* Support special china commands that dont require authentication. */ - if (Buffer[0] == CMD_CHINESE_UNLOCK_RW) { - /* Unlock read and write commands */ - Buffer[0] = ACK_VALUE; - 3b66: 8a e0 ldi r24, 0x0A ; 10 - 3b68: 80 83 st Z, r24 - return ACK_NAK_FRAME_SIZE; - 3b6a: 84 e0 ldi r24, 0x04 ; 4 - 3b6c: 90 e0 ldi r25, 0x00 ; 0 - 3b6e: 32 ce rjmp .-924 ; 0x37d4 - } - - Buffer[0] = ACK_VALUE; - } else { - /* CRC Error. */ - Buffer[0] = NAK_CRC_ERROR; - 3b70: 81 e0 ldi r24, 0x01 ; 1 - 3b72: d8 01 movw r26, r16 - 3b74: 8c 93 st X, r24 - } - - State = STATE_CHINESE_IDLE; - 3b76: 82 e0 ldi r24, 0x02 ; 2 - 3b78: 80 93 db 28 sts 0x28DB, r24 - - return ACK_NAK_FRAME_SIZE; - 3b7c: 84 e0 ldi r24, 0x04 ; 4 - 3b7e: 90 e0 ldi r25, 0x00 ; 0 - 3b80: 29 ce rjmp .-942 ; 0x37d4 - for (uint8_t i=0; i<(MEM_BYTES_PER_BLOCK + ISO14443A_CRCA_SIZE); i++) - Buffer[i] ^= Crypto1Byte(); - - if (ISO14443ACheckCRCA(Buffer, MEM_BYTES_PER_BLOCK)) { - if (!ActiveConfiguration.ReadOnly) { - MemoryWriteBlock(Buffer, CurrentAddress * MEM_BYTES_PER_BLOCK, MEM_BYTES_PER_BLOCK); - 3b82: 60 91 d2 28 lds r22, 0x28D2 - 3b86: e0 e1 ldi r30, 0x10 ; 16 - 3b88: 6e 9f mul r22, r30 - 3b8a: b0 01 movw r22, r0 - 3b8c: 11 24 eor r1, r1 - 3b8e: 40 e1 ldi r20, 0x10 ; 16 - 3b90: 50 e0 ldi r21, 0x00 ; 0 - 3b92: c8 01 movw r24, r16 - 3b94: 0e 94 7a 07 call 0xef4 ; 0xef4 - 3b98: 4c ce rjmp .-872 ; 0x3832 - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - } - return ACK_NAK_FRAME_SIZE; - } else if (Buffer[0] == CMD_RESTORE) { - if (ISO14443ACheckCRCA(Buffer, CMD_DECREMENT_FRAME_SIZE)) { - 3b9a: 62 e0 ldi r22, 0x02 ; 2 - 3b9c: 70 e0 ldi r23, 0x00 ; 0 - 3b9e: c8 01 movw r24, r16 - 3ba0: 7b d3 rcall .+1782 ; 0x4298 - 3ba2: 88 23 and r24, r24 - 3ba4: 09 f4 brne .+2 ; 0x3ba8 - 3ba6: ad c0 rjmp .+346 ; 0x3d02 - CurrentAddress = Buffer[1]; - 3ba8: f8 01 movw r30, r16 - 3baa: 81 81 ldd r24, Z+1 ; 0x01 - 3bac: 80 93 d2 28 sts 0x28D2, r24 - State = STATE_RESTORE; - 3bb0: 8c e0 ldi r24, 0x0C ; 12 - } - return ACK_NAK_FRAME_SIZE; - } else if (Buffer[0] == CMD_DECREMENT) { - if (ISO14443ACheckCRCA(Buffer, CMD_DECREMENT_FRAME_SIZE)) { - CurrentAddress = Buffer[1]; - State = STATE_DECREMENT; - 3bb2: 80 93 db 28 sts 0x28DB, r24 - Buffer[0] = ACK_VALUE ^ Crypto1Nibble(); - 3bb6: 2b d5 rcall .+2646 ; 0x460e - 3bb8: 9a e0 ldi r25, 0x0A ; 10 - 3bba: 98 27 eor r25, r24 - 3bbc: d8 01 movw r26, r16 - 3bbe: 9c 93 st X, r25 - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - } - return ACK_NAK_FRAME_SIZE; - 3bc0: 84 e0 ldi r24, 0x04 ; 4 - 3bc2: 90 e0 ldi r25, 0x00 ; 0 - 3bc4: 07 ce rjmp .-1010 ; 0x37d4 - } else if (Buffer[0] == CMD_CHINESE_WIPE) { - /* Wipe memory */ - Buffer[0] = ACK_VALUE; - return ACK_NAK_FRAME_SIZE; - } else if (Buffer[0] == CMD_READ) { - if (ISO14443ACheckCRCA(Buffer, CMD_READ_FRAME_SIZE)) { - 3bc6: 62 e0 ldi r22, 0x02 ; 2 - 3bc8: 70 e0 ldi r23, 0x00 ; 0 - 3bca: c8 01 movw r24, r16 - 3bcc: 65 d3 rcall .+1738 ; 0x4298 - 3bce: 81 11 cpse r24, r1 - 3bd0: cf c2 rjmp .+1438 ; 0x4170 - ISO14443AAppendCRCA(Buffer, MEM_BYTES_PER_BLOCK); - - return (CMD_READ_RESPONSE_FRAME_SIZE + ISO14443A_CRCA_SIZE ) - * BITS_PER_BYTE; - } else { - Buffer[0] = NAK_CRC_ERROR; - 3bd2: 81 e0 ldi r24, 0x01 ; 1 - 3bd4: f8 01 movw r30, r16 - 3bd6: 80 83 st Z, r24 - return ACK_NAK_FRAME_SIZE; - 3bd8: 84 e0 ldi r24, 0x04 ; 4 - 3bda: 90 e0 ldi r25, 0x00 ; 0 - 3bdc: fb cd rjmp .-1034 ; 0x37d4 - Crypto1Auth(&Buffer[0]); - - for (uint8_t i=0; i<4; i++) - Buffer[i+4] ^= Crypto1Byte(); - - if ((Buffer[4] == ReaderResponse[0]) && - 3bde: 95 81 ldd r25, Z+5 ; 0x05 - 3be0: 80 91 d4 28 lds r24, 0x28D4 - 3be4: 98 13 cpse r25, r24 - 3be6: de ce rjmp .-580 ; 0x39a4 - (Buffer[5] == ReaderResponse[1]) && - 3be8: 96 81 ldd r25, Z+6 ; 0x06 - 3bea: 80 91 d5 28 lds r24, 0x28D5 - 3bee: 98 13 cpse r25, r24 - 3bf0: d9 ce rjmp .-590 ; 0x39a4 - (Buffer[6] == ReaderResponse[2]) && - 3bf2: 97 81 ldd r25, Z+7 ; 0x07 - 3bf4: 80 91 d6 28 lds r24, 0x28D6 - 3bf8: 98 13 cpse r25, r24 - 3bfa: d4 ce rjmp .-600 ; 0x39a4 - 3bfc: 78 01 movw r14, r16 - 3bfe: 07 ed ldi r16, 0xD7 ; 215 - 3c00: 18 e2 ldi r17, 0x28 ; 40 - 3c02: 5f 01 movw r10, r30 - 3c04: f0 e8 ldi r31, 0x80 ; 128 - 3c06: af 0e add r10, r31 - 3c08: b1 1c adc r11, r1 - 3c0a: 48 01 movw r8, r16 - (Buffer[7] == ReaderResponse[3])) { - /* Reader is authenticated. Encrypt the precalculated card response - * and generate the parity bits. */ - for (uint8_t i=0; i - 3c14: 87 25 eor r24, r7 - 3c16: f7 01 movw r30, r14 - 3c18: 81 93 st Z+, r24 - 3c1a: 7f 01 movw r14, r30 - Buffer[ISO14443A_BUFFER_PARITY_OFFSET + i] = ODD_PARITY(CardResponse[i]) ^ Crypto1FilterOutput(); - 3c1c: d4 01 movw r26, r8 - 3c1e: 9c 90 ld r9, X - 3c20: 09 2c mov r0, r9 - 3c22: 92 94 swap r9 - 3c24: 90 24 eor r9, r0 - 3c26: 09 2c mov r0, r9 - 3c28: 96 94 lsr r9 - 3c2a: 96 94 lsr r9 - 3c2c: 90 24 eor r9, r0 - 3c2e: b8 d3 rcall .+1904 ; 0x43a0 - 3c30: 93 94 inc r9 - 3c32: 91 fa bst r9, 1 - 3c34: cc 24 eor r12, r12 - 3c36: c0 f8 bld r12, 0 - 3c38: d1 2c mov r13, r1 - 3c3a: b1 e0 ldi r27, 0x01 ; 1 - 3c3c: cb 26 eor r12, r27 - 3c3e: 8c 25 eor r24, r12 - 3c40: f5 01 movw r30, r10 - 3c42: 81 93 st Z+, r24 - 3c44: 5f 01 movw r10, r30 - (Buffer[5] == ReaderResponse[1]) && - (Buffer[6] == ReaderResponse[2]) && - (Buffer[7] == ReaderResponse[3])) { - /* Reader is authenticated. Encrypt the precalculated card response - * and generate the parity bits. */ - for (uint8_t i=0; i - Buffer[i] = CardResponse[i] ^ Crypto1Byte(); - Buffer[ISO14443A_BUFFER_PARITY_OFFSET + i] = ODD_PARITY(CardResponse[i]) ^ Crypto1FilterOutput(); - } - - State = STATE_AUTHED_IDLE; - 3c4e: 88 e0 ldi r24, 0x08 ; 8 - 3c50: 80 93 db 28 sts 0x28DB, r24 - - return (CMD_AUTH_BA_FRAME_SIZE * BITS_PER_BYTE) | ISO14443A_APP_CUSTOM_PARITY; - 3c54: 80 e2 ldi r24, 0x20 ; 32 - 3c56: 90 e1 ldi r25, 0x10 ; 16 - 3c58: bd cd rjmp .-1158 ; 0x37d4 - * the block back into the global block buffer. */ - for (uint8_t i=0; i<(MEM_VALUE_SIZE + ISO14443A_CRCA_SIZE); i++) - Buffer[i] ^= Crypto1Byte(); - - if (ISO14443ACheckCRCA(Buffer, MEM_VALUE_SIZE )) { - MemoryReadBlock(BlockBuffer, (uint16_t) CurrentAddress * MEM_BYTES_PER_BLOCK, MEM_BYTES_PER_BLOCK); - 3c5a: 60 91 d2 28 lds r22, 0x28D2 - 3c5e: f0 e1 ldi r31, 0x10 ; 16 - 3c60: 6f 9f mul r22, r31 - 3c62: b0 01 movw r22, r0 - 3c64: 11 24 eor r1, r1 - 3c66: 40 e1 ldi r20, 0x10 ; 16 - 3c68: 50 e0 ldi r21, 0x00 ; 0 - 3c6a: 82 ec ldi r24, 0xC2 ; 194 - 3c6c: 98 e2 ldi r25, 0x28 ; 40 - 3c6e: 0e 94 62 07 call 0xec4 ; 0xec4 - -INLINE bool CheckValueIntegrity(uint8_t* Block) -{ - /* Value Blocks contain a value stored three times, with - * the middle portion inverted. */ - if ( (Block[0] == (uint8_t) ~Block[4]) && (Block[0] == Block[8]) - 3c72: 20 91 c2 28 lds r18, 0x28C2 - 3c76: 80 91 c6 28 lds r24, 0x28C6 - 3c7a: 80 95 com r24 - 3c7c: 28 17 cp r18, r24 - 3c7e: 09 f4 brne .+2 ; 0x3c82 - 3c80: eb c0 rjmp .+470 ; 0x3e58 - State = STATE_AUTHED_IDLE; - /* No ACK response on value commands part 2 */ - return ISO14443A_APP_NO_RESPONSE; - } else { - /* Not sure if this is the correct error code.. */ - Buffer[0] = NAK_OTHER_ERROR ^ Crypto1Nibble(); - 3c82: c5 d4 rcall .+2442 ; 0x460e - 3c84: 96 e0 ldi r25, 0x06 ; 6 - 3c86: 98 27 eor r25, r24 - 3c88: f8 01 movw r30, r16 - 3c8a: 90 83 st Z, r25 - 3c8c: ef cd rjmp .-1058 ; 0x386c - /* Silently ignore in ReadOnly mode */ - } - - Buffer[0] = ACK_VALUE ^ Crypto1Nibble(); - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - 3c8e: bf d4 rcall .+2430 ; 0x460e - 3c90: 91 e0 ldi r25, 0x01 ; 1 - 3c92: 98 27 eor r25, r24 - 3c94: f8 01 movw r30, r16 - 3c96: 90 83 st Z, r25 - 3c98: e9 cd rjmp .-1070 ; 0x386c - return BitCount; - } else if (Buffer[0] == ISO14443A_CMD_SELECT_CL1) { - /* Load UID CL1 and perform anticollision */ - uint8_t UidCL1[ISO14443A_CL_UID_SIZE]; - - if (_7BUID) { - 3c9a: 80 91 be 28 lds r24, 0x28BE - 3c9e: 88 23 and r24, r24 - 3ca0: 09 f4 brne .+2 ; 0x3ca4 - 3ca2: 9f c0 rjmp .+318 ; 0x3de2 - MemoryReadBlock(&UidCL1[1], MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE-1); - 3ca4: 43 e0 ldi r20, 0x03 ; 3 - 3ca6: 50 e0 ldi r21, 0x00 ; 0 - 3ca8: 60 e0 ldi r22, 0x00 ; 0 - 3caa: 70 e0 ldi r23, 0x00 ; 0 - 3cac: ce 01 movw r24, r28 - 3cae: 02 96 adiw r24, 0x02 ; 2 - 3cb0: 0e 94 62 07 call 0xec4 ; 0xec4 - UidCL1[0] = ISO14443A_UID0_CT; - 3cb4: 88 e8 ldi r24, 0x88 ; 136 - 3cb6: 89 83 std Y+1, r24 ; 0x01 - uint8_t* DataPtr = (uint8_t*) Buffer; - uint8_t NVB = DataPtr[1]; - //uint8_t CollisionByteCount = (NVB >> 4) & 0x0F; - //uint8_t CollisionBitCount = (NVB >> 0) & 0x0F; - - switch (NVB) { - 3cb8: f8 01 movw r30, r16 - 3cba: 91 81 ldd r25, Z+1 ; 0x01 - 3cbc: 90 32 cpi r25, 0x20 ; 32 - 3cbe: 09 f4 brne .+2 ; 0x3cc2 - 3cc0: 1b c2 rjmp .+1078 ; 0x40f8 - 3cc2: 90 37 cpi r25, 0x70 ; 112 - 3cc4: 09 f0 breq .+2 ; 0x3cc8 - 3cc6: 84 cd rjmp .-1272 ; 0x37d0 - return false; - - case ISO14443A_NVB_AC_END: - /* End of anticollision procedure. - * Send SAK CLn if we are selected. */ - if ( (DataPtr[2] == UidCL[0]) && - 3cc8: f8 01 movw r30, r16 - 3cca: 82 81 ldd r24, Z+2 ; 0x02 - 3ccc: 88 38 cpi r24, 0x88 ; 136 - 3cce: 09 f0 breq .+2 ; 0x3cd2 - 3cd0: 7f cd rjmp .-1282 ; 0x37d0 - 3cd2: 93 81 ldd r25, Z+3 ; 0x03 - 3cd4: 8a 81 ldd r24, Y+2 ; 0x02 - 3cd6: 98 13 cpse r25, r24 - 3cd8: 7b cd rjmp .-1290 ; 0x37d0 - (DataPtr[3] == UidCL[1]) && - 3cda: 94 81 ldd r25, Z+4 ; 0x04 - 3cdc: 8b 81 ldd r24, Y+3 ; 0x03 - 3cde: 98 13 cpse r25, r24 - 3ce0: 77 cd rjmp .-1298 ; 0x37d0 - (DataPtr[4] == UidCL[2]) && - 3ce2: 95 81 ldd r25, Z+5 ; 0x05 - 3ce4: 8c 81 ldd r24, Y+4 ; 0x04 - 3ce6: 98 13 cpse r25, r24 - 3ce8: 73 cd rjmp .-1306 ; 0x37d0 - (DataPtr[5] == UidCL[3]) ) { - - DataPtr[0] = SAKValue; - 3cea: 84 e0 ldi r24, 0x04 ; 4 - 3cec: 80 83 st Z, r24 - ISO14443AAppendCRCA(Buffer, 1); - 3cee: 61 e0 ldi r22, 0x01 ; 1 - 3cf0: 70 e0 ldi r23, 0x00 ; 0 - 3cf2: c8 01 movw r24, r16 - 3cf4: a3 d2 rcall .+1350 ; 0x423c - if (ISO14443ASelect(Buffer, &BitCount, UidCL1, SAK_CL1_VALUE)) - State = STATE_READY2; - 3cf6: 85 e0 ldi r24, 0x05 ; 5 - 3cf8: 80 93 db 28 sts 0x28DB, r24 - - *BitCount = ISO14443A_SAK_FRAME_SIZE; - 3cfc: 88 e1 ldi r24, 0x18 ; 24 - 3cfe: 90 e0 ldi r25, 0x00 ; 0 - 3d00: 69 cd rjmp .-1326 ; 0x37d4 - if (ISO14443ACheckCRCA(Buffer, CMD_DECREMENT_FRAME_SIZE)) { - CurrentAddress = Buffer[1]; - State = STATE_RESTORE; - Buffer[0] = ACK_VALUE ^ Crypto1Nibble(); - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - 3d02: 85 d4 rcall .+2314 ; 0x460e - 3d04: 91 e0 ldi r25, 0x01 ; 1 - if (ISO14443ACheckCRCA(Buffer, CMD_WRITE_FRAME_SIZE)) { - /* Write command. Store the address and prepare for the upcoming data. - * Respond with ACK. */ - CurrentAddress = Buffer[1]; - State = STATE_WRITE; - Buffer[0] = ACK_VALUE ^ Crypto1Nibble(); - 3d06: 98 27 eor r25, r24 - 3d08: f8 01 movw r30, r16 - 3d0a: 90 83 st Z, r25 - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - } - return ACK_NAK_FRAME_SIZE; - 3d0c: 84 e0 ldi r24, 0x04 ; 4 - 3d0e: 90 e0 ldi r25, 0x00 ; 0 - 3d10: 61 cd rjmp .-1342 ; 0x37d4 - State = STATE_READY1; - return BitCount; - } else if (Buffer[0] == CMD_HALT) { - /* Halts the tag. According to the ISO14443, the second - * byte is supposed to be 0. */ - if (Buffer[1] == 0) { - 3d12: d8 01 movw r26, r16 - 3d14: 11 96 adiw r26, 0x01 ; 1 - 3d16: 8c 91 ld r24, X - 3d18: 81 11 cpse r24, r1 - 3d1a: db cd rjmp .-1098 ; 0x38d2 - } - } else if (Buffer[0] == CMD_HALT) { - /* Halts the tag. According to the ISO14443, the second - * byte is supposed to be 0. */ - if (Buffer[1] == 0) { - if (ISO14443ACheckCRCA(Buffer, CMD_HALT_FRAME_SIZE)) { - 3d1c: 62 e0 ldi r22, 0x02 ; 2 - 3d1e: 70 e0 ldi r23, 0x00 ; 0 - 3d20: c8 01 movw r24, r16 - 3d22: ba d2 rcall .+1396 ; 0x4298 - 3d24: 88 23 and r24, r24 - 3d26: 09 f4 brne .+2 ; 0x3d2a - 3d28: 54 cf rjmp .-344 ; 0x3bd2 - 3d2a: 05 cf rjmp .-502 ; 0x3b36 - - case STATE_CHINESE_WRITE: - if (ISO14443ACheckCRCA(Buffer, MEM_BYTES_PER_BLOCK)) { - /* CRC check passed. Write data into memory and send ACK. */ - if (!ActiveConfiguration.ReadOnly) { - MemoryWriteBlock(Buffer, CurrentAddress * MEM_BYTES_PER_BLOCK, MEM_BYTES_PER_BLOCK); - 3d2c: 60 91 d2 28 lds r22, 0x28D2 - 3d30: b0 e1 ldi r27, 0x10 ; 16 - 3d32: 6b 9f mul r22, r27 - 3d34: b0 01 movw r22, r0 - 3d36: 11 24 eor r1, r1 - 3d38: 40 e1 ldi r20, 0x10 ; 16 - 3d3a: 50 e0 ldi r21, 0x00 ; 0 - 3d3c: c8 01 movw r24, r16 - 3d3e: 0e 94 7a 07 call 0xef4 ; 0xef4 - 3d42: 14 ce rjmp .-984 ; 0x396c - * form the reader in the next frame. */ - State = STATE_AUTHING; - - return CMD_AUTH_RB_FRAME_SIZE * BITS_PER_BYTE; - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - 3d44: 64 d4 rcall .+2248 ; 0x460e - 3d46: 91 e0 ldi r25, 0x01 ; 1 - 3d48: 38 cf rjmp .-400 ; 0x3bba - * the incoming data. */ - for (uint8_t i=0; i<4; i++) - Buffer[i] ^= Crypto1Byte(); - - if (Buffer[0] == CMD_READ) { - if (ISO14443ACheckCRCA(Buffer, CMD_READ_FRAME_SIZE)) { - 3d4a: 62 e0 ldi r22, 0x02 ; 2 - 3d4c: 70 e0 ldi r23, 0x00 ; 0 - 3d4e: c8 01 movw r24, r16 - 3d50: a3 d2 rcall .+1350 ; 0x4298 - 3d52: 88 23 and r24, r24 - 3d54: b1 f2 breq .-84 ; 0x3d02 - /* Read command. Read data from memory and append CRCA. */ - MemoryReadBlock(Buffer, (uint16_t) Buffer[1] * MEM_BYTES_PER_BLOCK, MEM_BYTES_PER_BLOCK); - 3d56: f8 01 movw r30, r16 - 3d58: 61 81 ldd r22, Z+1 ; 0x01 - 3d5a: f0 e1 ldi r31, 0x10 ; 16 - 3d5c: 6f 9f mul r22, r31 - 3d5e: b0 01 movw r22, r0 - 3d60: 11 24 eor r1, r1 - 3d62: 40 e1 ldi r20, 0x10 ; 16 - 3d64: 50 e0 ldi r21, 0x00 ; 0 - 3d66: c8 01 movw r24, r16 - 3d68: 0e 94 62 07 call 0xec4 ; 0xec4 - ISO14443AAppendCRCA(Buffer, MEM_BYTES_PER_BLOCK); - 3d6c: 60 e1 ldi r22, 0x10 ; 16 - 3d6e: 70 e0 ldi r23, 0x00 ; 0 - 3d70: c8 01 movw r24, r16 - 3d72: 64 d2 rcall .+1224 ; 0x423c - 3d74: 68 01 movw r12, r16 - 3d76: 30 e8 ldi r19, 0x80 ; 128 - 3d78: c3 0e add r12, r19 - 3d7a: d1 1c adc r13, r1 - 3d7c: 72 e1 ldi r23, 0x12 ; 18 - 3d7e: a7 2e mov r10, r23 - - /* Encrypt and calculate parity bits. */ - for (uint8_t i=0; i<(ISO14443A_CRCA_SIZE + MEM_BYTES_PER_BLOCK); i++) { - uint8_t Plain = Buffer[i]; - 3d80: d8 01 movw r26, r16 - 3d82: bc 90 ld r11, X - Buffer[i] = Plain ^ Crypto1Byte(); - 3d84: 31 d4 rcall .+2146 ; 0x45e8 - 3d86: 8b 25 eor r24, r11 - 3d88: f8 01 movw r30, r16 - 3d8a: 81 93 st Z+, r24 - 3d8c: 8f 01 movw r16, r30 - Buffer[ISO14443A_BUFFER_PARITY_OFFSET + i] = ODD_PARITY(Plain) ^ Crypto1FilterOutput(); - 3d8e: 0b 2c mov r0, r11 - 3d90: b2 94 swap r11 - 3d92: b0 24 eor r11, r0 - 3d94: 0b 2c mov r0, r11 - 3d96: b6 94 lsr r11 - 3d98: b6 94 lsr r11 - 3d9a: b0 24 eor r11, r0 - 3d9c: 01 d3 rcall .+1538 ; 0x43a0 - 3d9e: b3 94 inc r11 - 3da0: b1 fa bst r11, 1 - 3da2: ee 24 eor r14, r14 - 3da4: e0 f8 bld r14, 0 - 3da6: f1 2c mov r15, r1 - 3da8: f1 e0 ldi r31, 0x01 ; 1 - 3daa: ef 26 eor r14, r31 - 3dac: 8e 25 eor r24, r14 - 3dae: d6 01 movw r26, r12 - 3db0: 8d 93 st X+, r24 - 3db2: 6d 01 movw r12, r26 - 3db4: aa 94 dec r10 - /* Read command. Read data from memory and append CRCA. */ - MemoryReadBlock(Buffer, (uint16_t) Buffer[1] * MEM_BYTES_PER_BLOCK, MEM_BYTES_PER_BLOCK); - ISO14443AAppendCRCA(Buffer, MEM_BYTES_PER_BLOCK); - - /* Encrypt and calculate parity bits. */ - for (uint8_t i=0; i<(ISO14443A_CRCA_SIZE + MEM_BYTES_PER_BLOCK); i++) { - 3db6: 21 f7 brne .-56 ; 0x3d80 - uint8_t Plain = Buffer[i]; - Buffer[i] = Plain ^ Crypto1Byte(); - Buffer[ISO14443A_BUFFER_PARITY_OFFSET + i] = ODD_PARITY(Plain) ^ Crypto1FilterOutput(); - } - - return ( (CMD_READ_RESPONSE_FRAME_SIZE + ISO14443A_CRCA_SIZE ) - 3db8: 80 e9 ldi r24, 0x90 ; 144 - 3dba: 90 e1 ldi r25, 0x10 ; 16 - 3dbc: 0b cd rjmp .-1514 ; 0x37d4 - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - return ACK_NAK_FRAME_SIZE; - } - } else if (Buffer[0] == CMD_WRITE) { - if (ISO14443ACheckCRCA(Buffer, CMD_WRITE_FRAME_SIZE)) { - 3dbe: 62 e0 ldi r22, 0x02 ; 2 - 3dc0: 70 e0 ldi r23, 0x00 ; 0 - 3dc2: c8 01 movw r24, r16 - 3dc4: 69 d2 rcall .+1234 ; 0x4298 - 3dc6: 88 23 and r24, r24 - 3dc8: 09 f4 brne .+2 ; 0x3dcc - 3dca: bc cf rjmp .-136 ; 0x3d44 - /* Write command. Store the address and prepare for the upcoming data. - * Respond with ACK. */ - CurrentAddress = Buffer[1]; - 3dcc: d8 01 movw r26, r16 - 3dce: 11 96 adiw r26, 0x01 ; 1 - 3dd0: 8c 91 ld r24, X - 3dd2: 80 93 d2 28 sts 0x28D2, r24 - State = STATE_WRITE; - 3dd6: 89 e0 ldi r24, 0x09 ; 9 - 3dd8: 80 93 db 28 sts 0x28DB, r24 - Buffer[0] = ACK_VALUE ^ Crypto1Nibble(); - 3ddc: 18 d4 rcall .+2096 ; 0x460e - 3dde: 9a e0 ldi r25, 0x0A ; 10 - 3de0: 92 cf rjmp .-220 ; 0x3d06 - MemoryReadBlock(&UidCL1[1], MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE-1); - UidCL1[0] = ISO14443A_UID0_CT; - if (ISO14443ASelect(Buffer, &BitCount, UidCL1, SAK_CL1_VALUE)) - State = STATE_READY2; - } else { - MemoryReadBlock(UidCL1, MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE); - 3de2: 44 e0 ldi r20, 0x04 ; 4 - 3de4: 50 e0 ldi r21, 0x00 ; 0 - 3de6: 60 e0 ldi r22, 0x00 ; 0 - 3de8: 70 e0 ldi r23, 0x00 ; 0 - 3dea: ce 01 movw r24, r28 - 3dec: 01 96 adiw r24, 0x01 ; 1 - 3dee: 0e 94 62 07 call 0xec4 ; 0xec4 - if (ISO14443ASelect(Buffer, &BitCount, UidCL1, CardSAKValue)) - 3df2: 90 91 bf 28 lds r25, 0x28BF - uint8_t* DataPtr = (uint8_t*) Buffer; - uint8_t NVB = DataPtr[1]; - //uint8_t CollisionByteCount = (NVB >> 4) & 0x0F; - //uint8_t CollisionBitCount = (NVB >> 0) & 0x0F; - - switch (NVB) { - 3df6: d8 01 movw r26, r16 - 3df8: 11 96 adiw r26, 0x01 ; 1 - 3dfa: 8c 91 ld r24, X - 3dfc: 80 32 cpi r24, 0x20 ; 32 - 3dfe: 09 f4 brne .+2 ; 0x3e02 - 3e00: 6b c1 rjmp .+726 ; 0x40d8 - 3e02: 80 37 cpi r24, 0x70 ; 112 - 3e04: 09 f0 breq .+2 ; 0x3e08 - 3e06: e4 cc rjmp .-1592 ; 0x37d0 - return false; - - case ISO14443A_NVB_AC_END: - /* End of anticollision procedure. - * Send SAK CLn if we are selected. */ - if ( (DataPtr[2] == UidCL[0]) && - 3e08: d8 01 movw r26, r16 - 3e0a: 12 96 adiw r26, 0x02 ; 2 - 3e0c: 2c 91 ld r18, X - 3e0e: 12 97 sbiw r26, 0x02 ; 2 - 3e10: 89 81 ldd r24, Y+1 ; 0x01 - 3e12: 28 13 cpse r18, r24 - 3e14: dd cc rjmp .-1606 ; 0x37d0 - 3e16: 13 96 adiw r26, 0x03 ; 3 - 3e18: 2c 91 ld r18, X - 3e1a: 13 97 sbiw r26, 0x03 ; 3 - 3e1c: 8a 81 ldd r24, Y+2 ; 0x02 - 3e1e: 28 13 cpse r18, r24 - 3e20: d7 cc rjmp .-1618 ; 0x37d0 - (DataPtr[3] == UidCL[1]) && - 3e22: 14 96 adiw r26, 0x04 ; 4 - 3e24: 2c 91 ld r18, X - 3e26: 14 97 sbiw r26, 0x04 ; 4 - 3e28: 8b 81 ldd r24, Y+3 ; 0x03 - 3e2a: 28 13 cpse r18, r24 - 3e2c: d1 cc rjmp .-1630 ; 0x37d0 - (DataPtr[4] == UidCL[2]) && - 3e2e: 15 96 adiw r26, 0x05 ; 5 - 3e30: 2c 91 ld r18, X - 3e32: 15 97 sbiw r26, 0x05 ; 5 - 3e34: 8c 81 ldd r24, Y+4 ; 0x04 - 3e36: 28 13 cpse r18, r24 - 3e38: cb cc rjmp .-1642 ; 0x37d0 - (DataPtr[5] == UidCL[3]) ) { - - DataPtr[0] = SAKValue; - 3e3a: 9c 93 st X, r25 - 3e3c: 82 cd rjmp .-1276 ; 0x3942 - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - } - return ACK_NAK_FRAME_SIZE; - } else if (Buffer[0] == CMD_DECREMENT) { - if (ISO14443ACheckCRCA(Buffer, CMD_DECREMENT_FRAME_SIZE)) { - 3e3e: 62 e0 ldi r22, 0x02 ; 2 - 3e40: 70 e0 ldi r23, 0x00 ; 0 - 3e42: c8 01 movw r24, r16 - 3e44: 29 d2 rcall .+1106 ; 0x4298 - 3e46: 88 23 and r24, r24 - 3e48: 09 f4 brne .+2 ; 0x3e4c - 3e4a: 5b cf rjmp .-330 ; 0x3d02 - CurrentAddress = Buffer[1]; - 3e4c: f8 01 movw r30, r16 - 3e4e: 81 81 ldd r24, Z+1 ; 0x01 - 3e50: 80 93 d2 28 sts 0x28D2, r24 - State = STATE_DECREMENT; - 3e54: 8b e0 ldi r24, 0x0B ; 11 - 3e56: ad ce rjmp .-678 ; 0x3bb2 - -INLINE bool CheckValueIntegrity(uint8_t* Block) -{ - /* Value Blocks contain a value stored three times, with - * the middle portion inverted. */ - if ( (Block[0] == (uint8_t) ~Block[4]) && (Block[0] == Block[8]) - 3e58: 80 91 ca 28 lds r24, 0x28CA - 3e5c: 28 13 cpse r18, r24 - 3e5e: 11 cf rjmp .-478 ; 0x3c82 - && (Block[1] == (uint8_t) ~Block[5]) && (Block[1] == Block[9]) - 3e60: e0 91 c3 28 lds r30, 0x28C3 - 3e64: 80 91 c7 28 lds r24, 0x28C7 - 3e68: 80 95 com r24 - 3e6a: e8 13 cpse r30, r24 - 3e6c: 0a cf rjmp .-492 ; 0x3c82 - 3e6e: 80 91 cb 28 lds r24, 0x28CB - 3e72: e8 13 cpse r30, r24 - 3e74: 06 cf rjmp .-500 ; 0x3c82 - && (Block[2] == (uint8_t) ~Block[6]) && (Block[2] == Block[10]) - 3e76: 80 91 c4 28 lds r24, 0x28C4 - 3e7a: 90 91 c8 28 lds r25, 0x28C8 - 3e7e: 90 95 com r25 - 3e80: 89 13 cpse r24, r25 - 3e82: ff ce rjmp .-514 ; 0x3c82 - 3e84: 90 91 cc 28 lds r25, 0x28CC - 3e88: 89 13 cpse r24, r25 - 3e8a: fb ce rjmp .-522 ; 0x3c82 - && (Block[3] == (uint8_t) ~Block[7]) && (Block[3] == Block[11]) - 3e8c: 30 91 c5 28 lds r19, 0x28C5 - 3e90: 90 91 c9 28 lds r25, 0x28C9 - 3e94: 90 95 com r25 - 3e96: 39 13 cpse r19, r25 - 3e98: f4 ce rjmp .-536 ; 0x3c82 - 3e9a: 90 91 cd 28 lds r25, 0x28CD - 3e9e: 39 13 cpse r19, r25 - 3ea0: f0 ce rjmp .-544 ; 0x3c82 - && (Block[12] == (uint8_t) ~Block[13]) - 3ea2: 40 91 ce 28 lds r20, 0x28CE - 3ea6: 90 91 cf 28 lds r25, 0x28CF - 3eaa: 90 95 com r25 - 3eac: 49 13 cpse r20, r25 - 3eae: e9 ce rjmp .-558 ; 0x3c82 - && (Block[12] == Block[14]) - 3eb0: 90 91 d0 28 lds r25, 0x28D0 - 3eb4: 49 13 cpse r20, r25 - 3eb6: e5 ce rjmp .-566 ; 0x3c82 - && (Block[14] == (uint8_t) ~Block[15])) { - 3eb8: 90 91 d1 28 lds r25, 0x28D1 - 3ebc: 90 95 com r25 - 3ebe: 49 13 cpse r20, r25 - 3ec0: e0 ce rjmp .-576 ; 0x3c82 -} - -INLINE void ValueFromBlock(uint32_t* Value, uint8_t* Block) -{ - *Value = 0; - *Value |= ((uint32_t) Block[0] << 0); - 3ec2: d8 01 movw r26, r16 - 3ec4: 9c 91 ld r25, X - *Value |= ((uint32_t) Block[1] << 8); - 3ec6: 11 96 adiw r26, 0x01 ; 1 - 3ec8: fc 91 ld r31, X - 3eca: 11 97 sbiw r26, 0x01 ; 1 - *Value |= ((uint32_t) Block[2] << 16); - 3ecc: 12 96 adiw r26, 0x02 ; 2 - 3ece: 4c 91 ld r20, X - 3ed0: 12 97 sbiw r26, 0x02 ; 2 - 3ed2: 50 e0 ldi r21, 0x00 ; 0 - 3ed4: 60 e0 ldi r22, 0x00 ; 0 - 3ed6: 70 e0 ldi r23, 0x00 ; 0 - 3ed8: ba 01 movw r22, r20 - 3eda: 55 27 eor r21, r21 - 3edc: 44 27 eor r20, r20 - -INLINE void ValueFromBlock(uint32_t* Value, uint8_t* Block) -{ - *Value = 0; - *Value |= ((uint32_t) Block[0] << 0); - *Value |= ((uint32_t) Block[1] << 8); - 3ede: 5f 2b or r21, r31 - *Value |= ((uint32_t) Block[2] << 16); - 3ee0: 49 2b or r20, r25 - *Value |= ((uint32_t) Block[3] << 24); - 3ee2: 13 96 adiw r26, 0x03 ; 3 - 3ee4: 9c 91 ld r25, X - 3ee6: 79 2b or r23, r25 -INLINE void ValueFromBlock(uint32_t* Value, uint8_t* Block) -{ - *Value = 0; - *Value |= ((uint32_t) Block[0] << 0); - *Value |= ((uint32_t) Block[1] << 8); - *Value |= ((uint32_t) Block[2] << 16); - 3ee8: 90 e0 ldi r25, 0x00 ; 0 - 3eea: a0 e0 ldi r26, 0x00 ; 0 - 3eec: b0 e0 ldi r27, 0x00 ; 0 - 3eee: dc 01 movw r26, r24 - 3ef0: 99 27 eor r25, r25 - 3ef2: 88 27 eor r24, r24 - -INLINE void ValueFromBlock(uint32_t* Value, uint8_t* Block) -{ - *Value = 0; - *Value |= ((uint32_t) Block[0] << 0); - *Value |= ((uint32_t) Block[1] << 8); - 3ef4: 9e 2b or r25, r30 - *Value |= ((uint32_t) Block[2] << 16); - 3ef6: 82 2b or r24, r18 - *Value |= ((uint32_t) Block[3] << 24); - 3ef8: b3 2b or r27, r19 - uint32_t BlockValue; - - ValueFromBlock(&ParamValue, Buffer); - ValueFromBlock(&BlockValue, BlockBuffer); - - if (State == STATE_DECREMENT) { - 3efa: 20 91 db 28 lds r18, 0x28DB - 3efe: 2b 30 cpi r18, 0x0B ; 11 - 3f00: 09 f4 brne .+2 ; 0x3f04 - 3f02: d6 c0 rjmp .+428 ; 0x40b0 - BlockValue -= ParamValue; - } else if (State == STATE_INCREMENT) { - 3f04: 2a 30 cpi r18, 0x0A ; 10 - 3f06: 21 f4 brne .+8 ; 0x3f10 - BlockValue += ParamValue; - 3f08: 84 0f add r24, r20 - 3f0a: 95 1f adc r25, r21 - 3f0c: a6 1f adc r26, r22 - 3f0e: b7 1f adc r27, r23 - *Value |= ((uint32_t) Block[3] << 24); -} - -INLINE void ValueToBlock(uint8_t* Block, uint32_t Value) -{ - Block[0] = (uint8_t) (Value >> 0); - 3f10: 80 93 c2 28 sts 0x28C2, r24 - Block[1] = (uint8_t) (Value >> 8); - 3f14: c9 2e mov r12, r25 - 3f16: da 2e mov r13, r26 - 3f18: eb 2e mov r14, r27 - 3f1a: ff 24 eor r15, r15 - 3f1c: c0 92 c3 28 sts 0x28C3, r12 - Block[2] = (uint8_t) (Value >> 16); - 3f20: 8d 01 movw r16, r26 - 3f22: 22 27 eor r18, r18 - 3f24: 33 27 eor r19, r19 - 3f26: 00 93 c4 28 sts 0x28C4, r16 - Block[3] = (uint8_t) (Value >> 24); - 3f2a: 4b 2f mov r20, r27 - 3f2c: 55 27 eor r21, r21 - 3f2e: 66 27 eor r22, r22 - 3f30: 77 27 eor r23, r23 - 3f32: 40 93 c5 28 sts 0x28C5, r20 - Block[4] = ~Block[0]; - 3f36: e8 2f mov r30, r24 - 3f38: e0 95 com r30 - 3f3a: e0 93 c6 28 sts 0x28C6, r30 - Block[5] = ~Block[1]; - 3f3e: ec 2d mov r30, r12 - 3f40: e0 95 com r30 - 3f42: e0 93 c7 28 sts 0x28C7, r30 - Block[6] = ~Block[2]; - 3f46: e0 2f mov r30, r16 - 3f48: e0 95 com r30 - 3f4a: e0 93 c8 28 sts 0x28C8, r30 - Block[7] = ~Block[3]; - 3f4e: e4 2f mov r30, r20 - 3f50: e0 95 com r30 - 3f52: e0 93 c9 28 sts 0x28C9, r30 - Block[8] = Block[0]; - 3f56: 80 93 ca 28 sts 0x28CA, r24 - Block[9] = Block[1]; - 3f5a: c0 92 cb 28 sts 0x28CB, r12 - Block[10] = Block[2]; - 3f5e: 00 93 cc 28 sts 0x28CC, r16 - Block[11] = Block[3]; - 3f62: 40 93 cd 28 sts 0x28CD, r20 - /* Do nothing */ - } - - ValueToBlock(BlockBuffer, BlockValue); - - State = STATE_AUTHED_IDLE; - 3f66: 88 e0 ldi r24, 0x08 ; 8 - 3f68: 80 93 db 28 sts 0x28DB, r24 - /* No ACK response on value commands part 2 */ - return ISO14443A_APP_NO_RESPONSE; - 3f6c: 80 e0 ldi r24, 0x00 ; 0 - 3f6e: 90 e0 ldi r25, 0x00 ; 0 - 3f70: 31 cc rjmp .-1950 ; 0x37d4 - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - } - return ACK_NAK_FRAME_SIZE; - } else if (Buffer[0] == CMD_INCREMENT) { - if (ISO14443ACheckCRCA(Buffer, CMD_DECREMENT_FRAME_SIZE)) { - 3f72: 62 e0 ldi r22, 0x02 ; 2 - 3f74: 70 e0 ldi r23, 0x00 ; 0 - 3f76: c8 01 movw r24, r16 - 3f78: 8f d1 rcall .+798 ; 0x4298 - 3f7a: 88 23 and r24, r24 - 3f7c: 09 f4 brne .+2 ; 0x3f80 - 3f7e: e2 ce rjmp .-572 ; 0x3d44 - CurrentAddress = Buffer[1]; - 3f80: d8 01 movw r26, r16 - 3f82: 11 96 adiw r26, 0x01 ; 1 - 3f84: 8c 91 ld r24, X - 3f86: 80 93 d2 28 sts 0x28D2, r24 - State = STATE_INCREMENT; - 3f8a: 6a e0 ldi r22, 0x0A ; 10 - 3f8c: f6 2e mov r15, r22 - 3f8e: f0 92 db 28 sts 0x28DB, r15 - Buffer[0] = ACK_VALUE ^ Crypto1Nibble(); - 3f92: 3d d3 rcall .+1658 ; 0x460e - 3f94: 8f 25 eor r24, r15 - 3f96: f8 01 movw r30, r16 - 3f98: 80 83 st Z, r24 - } else { - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - } - return ACK_NAK_FRAME_SIZE; - 3f9a: 84 e0 ldi r24, 0x04 ; 4 - 3f9c: 90 e0 ldi r25, 0x00 ; 0 - 3f9e: 1a cc rjmp .-1996 ; 0x37d4 - Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble(); - } - return ACK_NAK_FRAME_SIZE; - }else if (Buffer[0] == CMD_TRANSFER) { - /* Write back the global block buffer to the desired block address */ - if (ISO14443ACheckCRCA(Buffer, CMD_TRANSFER_FRAME_SIZE)) { - 3fa0: 62 e0 ldi r22, 0x02 ; 2 - 3fa2: 70 e0 ldi r23, 0x00 ; 0 - 3fa4: c8 01 movw r24, r16 - 3fa6: 78 d1 rcall .+752 ; 0x4298 - 3fa8: 88 23 and r24, r24 - 3faa: 09 f4 brne .+2 ; 0x3fae - 3fac: cb ce rjmp .-618 ; 0x3d44 - if (!ActiveConfiguration.ReadOnly) { - 3fae: 80 91 06 29 lds r24, 0x2906 - 3fb2: 81 11 cpse r24, r1 - 3fb4: 13 cf rjmp .-474 ; 0x3ddc - MemoryWriteBlock(BlockBuffer, (uint16_t) Buffer[1] * MEM_BYTES_PER_BLOCK, MEM_BYTES_PER_BLOCK ); - 3fb6: d8 01 movw r26, r16 - 3fb8: 11 96 adiw r26, 0x01 ; 1 - 3fba: 6c 91 ld r22, X - 3fbc: b0 e1 ldi r27, 0x10 ; 16 - 3fbe: 6b 9f mul r22, r27 - 3fc0: b0 01 movw r22, r0 - 3fc2: 11 24 eor r1, r1 - 3fc4: 40 e1 ldi r20, 0x10 ; 16 - 3fc6: 50 e0 ldi r21, 0x00 ; 0 - 3fc8: 82 ec ldi r24, 0xC2 ; 194 - 3fca: 98 e2 ldi r25, 0x28 ; 40 - 3fcc: 0e 94 7a 07 call 0xef4 ; 0xef4 - 3fd0: 05 cf rjmp .-502 ; 0x3ddc - } else { - Buffer[0] = NAK_INVALID_ARG; - return ACK_NAK_FRAME_SIZE; - } - } else if ( (Buffer[0] == CMD_AUTH_A) || (Buffer[0] == CMD_AUTH_B)) { - if (ISO14443ACheckCRCA(Buffer, CMD_AUTH_FRAME_SIZE)) { - 3fd2: 62 e0 ldi r22, 0x02 ; 2 - 3fd4: 70 e0 ldi r23, 0x00 ; 0 - 3fd6: c8 01 movw r24, r16 - 3fd8: 5f d1 rcall .+702 ; 0x4298 - 3fda: 88 23 and r24, r24 - 3fdc: 09 f4 brne .+2 ; 0x3fe0 - 3fde: f9 cd rjmp .-1038 ; 0x3bd2 - uint8_t SectorAddress = Buffer[1] & MEM_SECTOR_ADDR_MASK; - 3fe0: f8 01 movw r30, r16 - 3fe2: 21 81 ldd r18, Z+1 ; 0x01 - 3fe4: 2c 73 andi r18, 0x3C ; 60 - uint8_t KeyOffset = (Buffer[0] == CMD_AUTH_A ? MEM_KEY_A_OFFSET : MEM_KEY_B_OFFSET); - 3fe6: 80 81 ld r24, Z - 3fe8: 80 36 cpi r24, 0x60 ; 96 - 3fea: 09 f4 brne .+2 ; 0x3fee - 3fec: d4 c0 rjmp .+424 ; 0x4196 - 3fee: 8a e3 ldi r24, 0x3A ; 58 - 3ff0: 90 e0 ldi r25, 0x00 ; 0 - uint16_t KeyAddress = (uint16_t) SectorAddress * MEM_BYTES_PER_BLOCK + KeyOffset; - 3ff2: 7c 01 movw r14, r24 - 3ff4: f0 e1 ldi r31, 0x10 ; 16 - 3ff6: 2f 9f mul r18, r31 - 3ff8: e0 0c add r14, r0 - 3ffa: f1 1c adc r15, r1 - 3ffc: 11 24 eor r1, r1 - uint8_t Key[6]; - uint8_t Uid[4]; - uint8_t CardNonce[4]; - - /* Generate a random nonce and read UID and key from memory */ - RandomGetBuffer(CardNonce, sizeof(CardNonce)); - 3ffe: 4e 01 movw r8, r28 - 4000: 37 e0 ldi r19, 0x07 ; 7 - 4002: 83 0e add r8, r19 - 4004: 91 1c adc r9, r1 - 4006: 64 e0 ldi r22, 0x04 ; 4 - 4008: c4 01 movw r24, r8 - 400a: 0e 94 bd 06 call 0xd7a ; 0xd7a - if (_7BUID) - 400e: 80 91 be 28 lds r24, 0x28BE - MemoryReadBlock(Uid, MEM_UID_CL2_ADDRESS, MEM_UID_CL2_SIZE); - 4012: 5e 01 movw r10, r28 - uint8_t Uid[4]; - uint8_t CardNonce[4]; - - /* Generate a random nonce and read UID and key from memory */ - RandomGetBuffer(CardNonce, sizeof(CardNonce)); - if (_7BUID) - 4014: 88 23 and r24, r24 - 4016: 09 f4 brne .+2 ; 0x401a - 4018: a0 c0 rjmp .+320 ; 0x415a - MemoryReadBlock(Uid, MEM_UID_CL2_ADDRESS, MEM_UID_CL2_SIZE); - 401a: 8b e0 ldi r24, 0x0B ; 11 - 401c: a8 0e add r10, r24 - 401e: b1 1c adc r11, r1 - 4020: 44 e0 ldi r20, 0x04 ; 4 - 4022: 50 e0 ldi r21, 0x00 ; 0 - 4024: 63 e0 ldi r22, 0x03 ; 3 - 4026: 70 e0 ldi r23, 0x00 ; 0 - 4028: c5 01 movw r24, r10 - 402a: 0e 94 62 07 call 0xec4 ; 0xec4 - else - MemoryReadBlock(Uid, MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE); - MemoryReadBlock(Key, KeyAddress, MEM_KEY_SIZE); - 402e: 46 e0 ldi r20, 0x06 ; 6 - 4030: 50 e0 ldi r21, 0x00 ; 0 - 4032: b7 01 movw r22, r14 - 4034: ce 01 movw r24, r28 - 4036: 01 96 adiw r24, 0x01 ; 1 - 4038: 0e 94 62 07 call 0xec4 ; 0xec4 - 403c: 8f 81 ldd r24, Y+7 ; 0x07 - 403e: 98 85 ldd r25, Y+8 ; 0x08 - 4040: a9 85 ldd r26, Y+9 ; 0x09 - 4042: ba 85 ldd r27, Y+10 ; 0x0a - 4044: 80 93 d3 28 sts 0x28D3, r24 - 4048: 90 93 d4 28 sts 0x28D4, r25 - 404c: a0 93 d5 28 sts 0x28D5, r26 - 4050: b0 93 d6 28 sts 0x28D6, r27 - - /* Precalculate the reader response from card-nonce */ - for (uint8_t i=0; i - 405e: 80 91 d3 28 lds r24, 0x28D3 - 4062: 90 91 d4 28 lds r25, 0x28D4 - 4066: a0 91 d5 28 lds r26, 0x28D5 - 406a: b0 91 d6 28 lds r27, 0x28D6 - 406e: 80 93 d7 28 sts 0x28D7, r24 - 4072: 90 93 d8 28 sts 0x28D8, r25 - 4076: a0 93 d9 28 sts 0x28D9, r26 - 407a: b0 93 da 28 sts 0x28DA, r27 - - /* Precalculate our response from the reader response */ - for (uint8_t i=0; i - - /* Respond with the random card nonce and expect further authentication - * form the reader in the next frame. */ - State = STATE_AUTHING; - 4088: 87 e0 ldi r24, 0x07 ; 7 - 408a: 80 93 db 28 sts 0x28DB, r24 - 408e: 8f 81 ldd r24, Y+7 ; 0x07 - 4090: 98 85 ldd r25, Y+8 ; 0x08 - 4092: a9 85 ldd r26, Y+9 ; 0x09 - 4094: ba 85 ldd r27, Y+10 ; 0x0a - 4096: f8 01 movw r30, r16 - 4098: 80 83 st Z, r24 - 409a: 91 83 std Z+1, r25 ; 0x01 - 409c: a2 83 std Z+2, r26 ; 0x02 - 409e: b3 83 std Z+3, r27 ; 0x03 - - for (uint8_t i=0; i - - return CMD_AUTH_RB_FRAME_SIZE * BITS_PER_BYTE; - 40aa: 80 e2 ldi r24, 0x20 ; 32 - 40ac: 90 e0 ldi r25, 0x00 ; 0 - 40ae: 92 cb rjmp .-2268 ; 0x37d4 - - ValueFromBlock(&ParamValue, Buffer); - ValueFromBlock(&BlockValue, BlockBuffer); - - if (State == STATE_DECREMENT) { - BlockValue -= ParamValue; - 40b0: 84 1b sub r24, r20 - 40b2: 95 0b sbc r25, r21 - 40b4: a6 0b sbc r26, r22 - 40b6: b7 0b sbc r27, r23 - 40b8: 2b cf rjmp .-426 ; 0x3f10 - - switch (NVB) { - case ISO14443A_NVB_AC_START: - /* Start of anticollision procedure. - * Send whole UID CLn + BCC */ - DataPtr[0] = UidCL[0]; - 40ba: 89 81 ldd r24, Y+1 ; 0x01 - 40bc: 80 83 st Z, r24 - DataPtr[1] = UidCL[1]; - 40be: 3a 81 ldd r19, Y+2 ; 0x02 - 40c0: 31 83 std Z+1, r19 ; 0x01 - DataPtr[2] = UidCL[2]; - 40c2: 2b 81 ldd r18, Y+3 ; 0x03 - 40c4: 22 83 std Z+2, r18 ; 0x02 - DataPtr[3] = UidCL[3]; - 40c6: 9c 81 ldd r25, Y+4 ; 0x04 - 40c8: 93 83 std Z+3, r25 ; 0x03 - DataPtr[4] = ISO14443A_CALC_BCC(DataPtr); - 40ca: 83 27 eor r24, r19 - 40cc: 82 27 eor r24, r18 - 40ce: 89 27 eor r24, r25 - 40d0: 84 83 std Z+4, r24 ; 0x04 - - *BitCount = ISO14443A_CL_FRAME_SIZE; - 40d2: 88 e2 ldi r24, 0x28 ; 40 - 40d4: 90 e0 ldi r25, 0x00 ; 0 - 40d6: 7e cb rjmp .-2308 ; 0x37d4 - - switch (NVB) { - case ISO14443A_NVB_AC_START: - /* Start of anticollision procedure. - * Send whole UID CLn + BCC */ - DataPtr[0] = UidCL[0]; - 40d8: 89 81 ldd r24, Y+1 ; 0x01 - 40da: f8 01 movw r30, r16 - 40dc: 80 83 st Z, r24 - DataPtr[1] = UidCL[1]; - 40de: 3a 81 ldd r19, Y+2 ; 0x02 - 40e0: 31 83 std Z+1, r19 ; 0x01 - DataPtr[2] = UidCL[2]; - 40e2: 2b 81 ldd r18, Y+3 ; 0x03 - 40e4: 22 83 std Z+2, r18 ; 0x02 - DataPtr[3] = UidCL[3]; - 40e6: 9c 81 ldd r25, Y+4 ; 0x04 - 40e8: 93 83 std Z+3, r25 ; 0x03 - DataPtr[4] = ISO14443A_CALC_BCC(DataPtr); - 40ea: 83 27 eor r24, r19 - 40ec: 82 27 eor r24, r18 - 40ee: 89 27 eor r24, r25 - 40f0: 84 83 std Z+4, r24 ; 0x04 - - *BitCount = ISO14443A_CL_FRAME_SIZE; - 40f2: 88 e2 ldi r24, 0x28 ; 40 - 40f4: 90 e0 ldi r25, 0x00 ; 0 - 40f6: 6e cb rjmp .-2340 ; 0x37d4 - - switch (NVB) { - case ISO14443A_NVB_AC_START: - /* Start of anticollision procedure. - * Send whole UID CLn + BCC */ - DataPtr[0] = UidCL[0]; - 40f8: 80 83 st Z, r24 - DataPtr[1] = UidCL[1]; - 40fa: 3a 81 ldd r19, Y+2 ; 0x02 - 40fc: 31 83 std Z+1, r19 ; 0x01 - DataPtr[2] = UidCL[2]; - 40fe: 9b 81 ldd r25, Y+3 ; 0x03 - 4100: 92 83 std Z+2, r25 ; 0x02 - DataPtr[3] = UidCL[3]; - 4102: 2c 81 ldd r18, Y+4 ; 0x04 - 4104: 23 83 std Z+3, r18 ; 0x03 - DataPtr[4] = ISO14443A_CALC_BCC(DataPtr); - 4106: 93 27 eor r25, r19 - 4108: 98 27 eor r25, r24 - 410a: 92 27 eor r25, r18 - 410c: 94 83 std Z+4, r25 ; 0x04 - - *BitCount = ISO14443A_CL_FRAME_SIZE; - 410e: 88 e2 ldi r24, 0x28 ; 40 - 4110: 90 e0 ldi r25, 0x00 ; 0 - 4112: 60 cb rjmp .-2368 ; 0x37d4 - } else { - Buffer[0] = NAK_CRC_ERROR; - return ACK_NAK_FRAME_SIZE; - } - } else if (Buffer[0] == CMD_WRITE) { - if (ISO14443ACheckCRCA(Buffer, CMD_WRITE_FRAME_SIZE)) { - 4114: 62 e0 ldi r22, 0x02 ; 2 - 4116: 70 e0 ldi r23, 0x00 ; 0 - 4118: c8 01 movw r24, r16 - 411a: be d0 rcall .+380 ; 0x4298 - 411c: 88 23 and r24, r24 - 411e: 09 f4 brne .+2 ; 0x4122 - 4120: 58 cd rjmp .-1360 ; 0x3bd2 - /* Write command. Store the address and prepare for the upcoming data. - * Respond with ACK. */ - CurrentAddress = Buffer[1]; - 4122: d8 01 movw r26, r16 - 4124: 11 96 adiw r26, 0x01 ; 1 - 4126: 8c 91 ld r24, X - 4128: 11 97 sbiw r26, 0x01 ; 1 - 412a: 80 93 d2 28 sts 0x28D2, r24 - State = STATE_CHINESE_WRITE; - 412e: 83 e0 ldi r24, 0x03 ; 3 - 4130: 80 93 db 28 sts 0x28DB, r24 - - Buffer[0] = ACK_VALUE; - 4134: 8a e0 ldi r24, 0x0A ; 10 - 4136: 8c 93 st X, r24 - return ACK_NAK_FRAME_SIZE; - 4138: 84 e0 ldi r24, 0x04 ; 4 - 413a: 90 e0 ldi r25, 0x00 ; 0 - 413c: 4b cb rjmp .-2410 ; 0x37d4 - /* Generate a random nonce and read UID and key from memory */ - RandomGetBuffer(CardNonce, sizeof(CardNonce)); - if (_7BUID) - MemoryReadBlock(Uid, MEM_UID_CL2_ADDRESS, MEM_UID_CL2_SIZE); - else - MemoryReadBlock(Uid, MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE); - 413e: 9b e0 ldi r25, 0x0B ; 11 - 4140: a9 0e add r10, r25 - 4142: b1 1c adc r11, r1 - 4144: 44 e0 ldi r20, 0x04 ; 4 - 4146: 50 e0 ldi r21, 0x00 ; 0 - 4148: 60 e0 ldi r22, 0x00 ; 0 - 414a: 70 e0 ldi r23, 0x00 ; 0 - 414c: c5 01 movw r24, r10 - 414e: 0e 94 62 07 call 0xec4 ; 0xec4 - 4152: 7f cc rjmp .-1794 ; 0x3a52 - return ACK_NAK_FRAME_SIZE; - } else if ( (Buffer[0] == CMD_AUTH_A) || (Buffer[0] == CMD_AUTH_B) ) { - if (ISO14443ACheckCRCA(Buffer, CMD_AUTH_FRAME_SIZE)) { - /* Nested authentication. */ - uint8_t SectorAddress = Buffer[1] & MEM_SECTOR_ADDR_MASK; - uint8_t KeyOffset = (Buffer[0] == CMD_AUTH_A ? MEM_KEY_A_OFFSET : MEM_KEY_B_OFFSET); - 4154: 60 e3 ldi r22, 0x30 ; 48 - 4156: 70 e0 ldi r23, 0x00 ; 0 - 4158: 5e cc rjmp .-1860 ; 0x3a16 - /* Generate a random nonce and read UID and key from memory */ - RandomGetBuffer(CardNonce, sizeof(CardNonce)); - if (_7BUID) - MemoryReadBlock(Uid, MEM_UID_CL2_ADDRESS, MEM_UID_CL2_SIZE); - else - MemoryReadBlock(Uid, MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE); - 415a: 9b e0 ldi r25, 0x0B ; 11 - 415c: a9 0e add r10, r25 - 415e: b1 1c adc r11, r1 - 4160: 44 e0 ldi r20, 0x04 ; 4 - 4162: 50 e0 ldi r21, 0x00 ; 0 - 4164: 60 e0 ldi r22, 0x00 ; 0 - 4166: 70 e0 ldi r23, 0x00 ; 0 - 4168: c5 01 movw r24, r10 - 416a: 0e 94 62 07 call 0xec4 ; 0xec4 - 416e: 5f cf rjmp .-322 ; 0x402e - Buffer[0] = ACK_VALUE; - return ACK_NAK_FRAME_SIZE; - } else if (Buffer[0] == CMD_READ) { - if (ISO14443ACheckCRCA(Buffer, CMD_READ_FRAME_SIZE)) { - /* Read command. Read data from memory and append CRCA. */ - MemoryReadBlock(Buffer, (uint16_t) Buffer[1] * MEM_BYTES_PER_BLOCK, MEM_BYTES_PER_BLOCK); - 4170: d8 01 movw r26, r16 - 4172: 11 96 adiw r26, 0x01 ; 1 - 4174: 6c 91 ld r22, X - 4176: b0 e1 ldi r27, 0x10 ; 16 - 4178: 6b 9f mul r22, r27 - 417a: b0 01 movw r22, r0 - 417c: 11 24 eor r1, r1 - 417e: 40 e1 ldi r20, 0x10 ; 16 - 4180: 50 e0 ldi r21, 0x00 ; 0 - 4182: c8 01 movw r24, r16 - 4184: 0e 94 62 07 call 0xec4 ; 0xec4 - ISO14443AAppendCRCA(Buffer, MEM_BYTES_PER_BLOCK); - 4188: 60 e1 ldi r22, 0x10 ; 16 - 418a: 70 e0 ldi r23, 0x00 ; 0 - 418c: c8 01 movw r24, r16 - 418e: 56 d0 rcall .+172 ; 0x423c - - return (CMD_READ_RESPONSE_FRAME_SIZE + ISO14443A_CRCA_SIZE ) - 4190: 80 e9 ldi r24, 0x90 ; 144 - 4192: 90 e0 ldi r25, 0x00 ; 0 - 4194: 1f cb rjmp .-2498 ; 0x37d4 - return ACK_NAK_FRAME_SIZE; - } - } else if ( (Buffer[0] == CMD_AUTH_A) || (Buffer[0] == CMD_AUTH_B)) { - if (ISO14443ACheckCRCA(Buffer, CMD_AUTH_FRAME_SIZE)) { - uint8_t SectorAddress = Buffer[1] & MEM_SECTOR_ADDR_MASK; - uint8_t KeyOffset = (Buffer[0] == CMD_AUTH_A ? MEM_KEY_A_OFFSET : MEM_KEY_B_OFFSET); - 4196: 80 e3 ldi r24, 0x30 ; 48 - 4198: 90 e0 ldi r25, 0x00 ; 0 - 419a: 2b cf rjmp .-426 ; 0x3ff2 - -0000419c : - /* No response has been sent, when we reach here */ - return ISO14443A_APP_NO_RESPONSE; -} - -void MifareClassicGetUid(ConfigurationUidType Uid) -{ - 419c: cf 93 push r28 - 419e: df 93 push r29 - 41a0: ec 01 movw r28, r24 - if (_7BUID) { - 41a2: 80 91 be 28 lds r24, 0x28BE - 41a6: 81 11 cpse r24, r1 - 41a8: 09 c0 rjmp .+18 ; 0x41bc - //Uid[0]=0x88; - MemoryReadBlock(&Uid[0], MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE-1); - MemoryReadBlock(&Uid[3], MEM_UID_CL2_ADDRESS, MEM_UID_CL2_SIZE); - } - else - MemoryReadBlock(Uid, MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE); - 41aa: 44 e0 ldi r20, 0x04 ; 4 - 41ac: 50 e0 ldi r21, 0x00 ; 0 - 41ae: 60 e0 ldi r22, 0x00 ; 0 - 41b0: 70 e0 ldi r23, 0x00 ; 0 - 41b2: ce 01 movw r24, r28 -} - 41b4: df 91 pop r29 - 41b6: cf 91 pop r28 - //Uid[0]=0x88; - MemoryReadBlock(&Uid[0], MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE-1); - MemoryReadBlock(&Uid[3], MEM_UID_CL2_ADDRESS, MEM_UID_CL2_SIZE); - } - else - MemoryReadBlock(Uid, MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE); - 41b8: 0c 94 62 07 jmp 0xec4 ; 0xec4 - -void MifareClassicGetUid(ConfigurationUidType Uid) -{ - if (_7BUID) { - //Uid[0]=0x88; - MemoryReadBlock(&Uid[0], MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE-1); - 41bc: 43 e0 ldi r20, 0x03 ; 3 - 41be: 50 e0 ldi r21, 0x00 ; 0 - 41c0: 60 e0 ldi r22, 0x00 ; 0 - 41c2: 70 e0 ldi r23, 0x00 ; 0 - 41c4: ce 01 movw r24, r28 - 41c6: 0e 94 62 07 call 0xec4 ; 0xec4 - MemoryReadBlock(&Uid[3], MEM_UID_CL2_ADDRESS, MEM_UID_CL2_SIZE); - 41ca: 44 e0 ldi r20, 0x04 ; 4 - 41cc: 50 e0 ldi r21, 0x00 ; 0 - 41ce: 63 e0 ldi r22, 0x03 ; 3 - 41d0: 70 e0 ldi r23, 0x00 ; 0 - 41d2: ce 01 movw r24, r28 - 41d4: 03 96 adiw r24, 0x03 ; 3 - } - else - MemoryReadBlock(Uid, MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE); -} - 41d6: df 91 pop r29 - 41d8: cf 91 pop r28 -void MifareClassicGetUid(ConfigurationUidType Uid) -{ - if (_7BUID) { - //Uid[0]=0x88; - MemoryReadBlock(&Uid[0], MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE-1); - MemoryReadBlock(&Uid[3], MEM_UID_CL2_ADDRESS, MEM_UID_CL2_SIZE); - 41da: 0c 94 62 07 jmp 0xec4 ; 0xec4 - -000041de : - else - MemoryReadBlock(Uid, MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE); -} - -void MifareClassicSetUid(ConfigurationUidType Uid) -{ - 41de: cf 93 push r28 - 41e0: df 93 push r29 - 41e2: 1f 92 push r1 - 41e4: cd b7 in r28, 0x3d ; 61 - 41e6: de b7 in r29, 0x3e ; 62 - if (_7BUID) { - 41e8: 20 91 be 28 lds r18, 0x28BE - 41ec: 21 11 cpse r18, r1 - 41ee: 1b c0 rjmp .+54 ; 0x4226 - //Uid[0]=0x88; - MemoryWriteBlock(Uid, MEM_UID_CL1_ADDRESS, ActiveConfiguration.UidSize); - } - else { - uint8_t BCC = Uid[0] ^ Uid[1] ^ Uid[2] ^ Uid[3]; - 41f0: fc 01 movw r30, r24 - 41f2: 21 81 ldd r18, Z+1 ; 0x01 - 41f4: 30 81 ld r19, Z - 41f6: 23 27 eor r18, r19 - 41f8: 32 81 ldd r19, Z+2 ; 0x02 - 41fa: 23 27 eor r18, r19 - 41fc: 33 81 ldd r19, Z+3 ; 0x03 - 41fe: 23 27 eor r18, r19 - 4200: 29 83 std Y+1, r18 ; 0x01 - - MemoryWriteBlock(Uid, MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE); - 4202: 44 e0 ldi r20, 0x04 ; 4 - 4204: 50 e0 ldi r21, 0x00 ; 0 - 4206: 60 e0 ldi r22, 0x00 ; 0 - 4208: 70 e0 ldi r23, 0x00 ; 0 - 420a: 0e 94 7a 07 call 0xef4 ; 0xef4 - MemoryWriteBlock(&BCC, MEM_UID_BCC1_ADDRESS, ISO14443A_CL_BCC_SIZE); - 420e: 41 e0 ldi r20, 0x01 ; 1 - 4210: 50 e0 ldi r21, 0x00 ; 0 - 4212: 64 e0 ldi r22, 0x04 ; 4 - 4214: 70 e0 ldi r23, 0x00 ; 0 - 4216: ce 01 movw r24, r28 - 4218: 01 96 adiw r24, 0x01 ; 1 - 421a: 0e 94 7a 07 call 0xef4 ; 0xef4 - } -} - 421e: 0f 90 pop r0 - 4220: df 91 pop r29 - 4222: cf 91 pop r28 - 4224: 08 95 ret - -void MifareClassicSetUid(ConfigurationUidType Uid) -{ - if (_7BUID) { - //Uid[0]=0x88; - MemoryWriteBlock(Uid, MEM_UID_CL1_ADDRESS, ActiveConfiguration.UidSize); - 4226: 40 91 05 29 lds r20, 0x2905 - 422a: 50 e0 ldi r21, 0x00 ; 0 - 422c: 60 e0 ldi r22, 0x00 ; 0 - 422e: 70 e0 ldi r23, 0x00 ; 0 - 4230: 0e 94 7a 07 call 0xef4 ; 0xef4 - uint8_t BCC = Uid[0] ^ Uid[1] ^ Uid[2] ^ Uid[3]; - - MemoryWriteBlock(Uid, MEM_UID_CL1_ADDRESS, MEM_UID_CL1_SIZE); - MemoryWriteBlock(&BCC, MEM_UID_BCC1_ADDRESS, ISO14443A_CL_BCC_SIZE); - } -} - 4234: 0f 90 pop r0 - 4236: df 91 pop r29 - 4238: cf 91 pop r28 - 423a: 08 95 ret - -0000423c : - * Author: skuser - */ - -#include "ISO14443-3A.h" - -void ISO14443AAppendCRCA(void* Buffer, uint16_t ByteCount) { - 423c: fc 01 movw r30, r24 - uint16_t Checksum = 0x6363; - uint8_t* DataPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - 423e: 61 15 cp r22, r1 - 4240: 71 05 cpc r23, r1 - 4242: 39 f1 breq .+78 ; 0x4292 - 4244: 68 0f add r22, r24 - 4246: 79 1f adc r23, r25 - */ - -#include "ISO14443-3A.h" - -void ISO14443AAppendCRCA(void* Buffer, uint16_t ByteCount) { - uint16_t Checksum = 0x6363; - 4248: 23 e6 ldi r18, 0x63 ; 99 - 424a: 33 e6 ldi r19, 0x63 ; 99 - uint8_t* DataPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - uint8_t Byte = *DataPtr++; - 424c: 41 91 ld r20, Z+ - - Byte ^= (uint8_t) (Checksum & 0x00FF); - 424e: 42 27 eor r20, r18 - Byte ^= Byte << 4; - 4250: 50 e1 ldi r21, 0x10 ; 16 - 4252: 45 9f mul r20, r21 - 4254: c0 01 movw r24, r0 - 4256: 11 24 eor r1, r1 - 4258: a4 2f mov r26, r20 - 425a: a8 27 eor r26, r24 - - Checksum = (Checksum >> 8) ^ ( (uint16_t) Byte << 8 ) ^ - 425c: 8a 2f mov r24, r26 - 425e: 90 e0 ldi r25, 0x00 ; 0 - 4260: 58 2f mov r21, r24 - 4262: 44 27 eor r20, r20 - ( (uint16_t) Byte << 3 ) ^ ( (uint16_t) Byte >> 4 ); - 4264: 88 0f add r24, r24 - 4266: 99 1f adc r25, r25 - 4268: 88 0f add r24, r24 - 426a: 99 1f adc r25, r25 - 426c: 88 0f add r24, r24 - 426e: 99 1f adc r25, r25 - uint8_t Byte = *DataPtr++; - - Byte ^= (uint8_t) (Checksum & 0x00FF); - Byte ^= Byte << 4; - - Checksum = (Checksum >> 8) ^ ( (uint16_t) Byte << 8 ) ^ - 4270: 48 27 eor r20, r24 - 4272: 59 27 eor r21, r25 - 4274: 23 2f mov r18, r19 - 4276: 33 27 eor r19, r19 - 4278: 24 27 eor r18, r20 - 427a: 35 27 eor r19, r21 - ( (uint16_t) Byte << 3 ) ^ ( (uint16_t) Byte >> 4 ); - 427c: a2 95 swap r26 - 427e: af 70 andi r26, 0x0F ; 15 - uint8_t Byte = *DataPtr++; - - Byte ^= (uint8_t) (Checksum & 0x00FF); - Byte ^= Byte << 4; - - Checksum = (Checksum >> 8) ^ ( (uint16_t) Byte << 8 ) ^ - 4280: 2a 27 eor r18, r26 - -void ISO14443AAppendCRCA(void* Buffer, uint16_t ByteCount) { - uint16_t Checksum = 0x6363; - uint8_t* DataPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - 4282: e6 17 cp r30, r22 - 4284: f7 07 cpc r31, r23 - 4286: 11 f7 brne .-60 ; 0x424c - 4288: 92 2f mov r25, r18 - 428a: 83 2f mov r24, r19 - - Checksum = (Checksum >> 8) ^ ( (uint16_t) Byte << 8 ) ^ - ( (uint16_t) Byte << 3 ) ^ ( (uint16_t) Byte >> 4 ); - } - - *DataPtr++ = (Checksum >> 0) & 0x00FF; - 428c: 90 83 st Z, r25 - *DataPtr = (Checksum >> 8) & 0x00FF; - 428e: 81 83 std Z+1, r24 ; 0x01 - 4290: 08 95 ret - -void ISO14443AAppendCRCA(void* Buffer, uint16_t ByteCount) { - uint16_t Checksum = 0x6363; - uint8_t* DataPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - 4292: 83 e6 ldi r24, 0x63 ; 99 - 4294: 93 e6 ldi r25, 0x63 ; 99 - 4296: fa cf rjmp .-12 ; 0x428c - -00004298 : - *DataPtr++ = (Checksum >> 0) & 0x00FF; - *DataPtr = (Checksum >> 8) & 0x00FF; -} - -bool ISO14443ACheckCRCA(void* Buffer, uint16_t ByteCount) -{ - 4298: fc 01 movw r30, r24 - uint16_t Checksum = 0x6363; - uint8_t* DataPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - 429a: 61 15 cp r22, r1 - 429c: 71 05 cpc r23, r1 - 429e: a9 f1 breq .+106 ; 0x430a - 42a0: 68 0f add r22, r24 - 42a2: 79 1f adc r23, r25 - *DataPtr = (Checksum >> 8) & 0x00FF; -} - -bool ISO14443ACheckCRCA(void* Buffer, uint16_t ByteCount) -{ - uint16_t Checksum = 0x6363; - 42a4: 23 e6 ldi r18, 0x63 ; 99 - 42a6: 33 e6 ldi r19, 0x63 ; 99 - uint8_t* DataPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - uint8_t Byte = *DataPtr++; - 42a8: 41 91 ld r20, Z+ - - Byte ^= (uint8_t) (Checksum & 0x00FF); - 42aa: 42 27 eor r20, r18 - Byte ^= Byte << 4; - 42ac: 50 e1 ldi r21, 0x10 ; 16 - 42ae: 45 9f mul r20, r21 - 42b0: c0 01 movw r24, r0 - 42b2: 11 24 eor r1, r1 - 42b4: a4 2f mov r26, r20 - 42b6: a8 27 eor r26, r24 - - Checksum = (Checksum >> 8) ^ ( (uint16_t) Byte << 8 ) ^ - 42b8: 8a 2f mov r24, r26 - 42ba: 90 e0 ldi r25, 0x00 ; 0 - 42bc: 58 2f mov r21, r24 - 42be: 44 27 eor r20, r20 - ( (uint16_t) Byte << 3 ) ^ ( (uint16_t) Byte >> 4 ); - 42c0: 88 0f add r24, r24 - 42c2: 99 1f adc r25, r25 - 42c4: 88 0f add r24, r24 - 42c6: 99 1f adc r25, r25 - 42c8: 88 0f add r24, r24 - 42ca: 99 1f adc r25, r25 - uint8_t Byte = *DataPtr++; - - Byte ^= (uint8_t) (Checksum & 0x00FF); - Byte ^= Byte << 4; - - Checksum = (Checksum >> 8) ^ ( (uint16_t) Byte << 8 ) ^ - 42cc: 48 27 eor r20, r24 - 42ce: 59 27 eor r21, r25 - 42d0: 23 2f mov r18, r19 - 42d2: 33 27 eor r19, r19 - 42d4: 24 27 eor r18, r20 - 42d6: 35 27 eor r19, r21 - ( (uint16_t) Byte << 3 ) ^ ( (uint16_t) Byte >> 4 ); - 42d8: a2 95 swap r26 - 42da: af 70 andi r26, 0x0F ; 15 - uint8_t Byte = *DataPtr++; - - Byte ^= (uint8_t) (Checksum & 0x00FF); - Byte ^= Byte << 4; - - Checksum = (Checksum >> 8) ^ ( (uint16_t) Byte << 8 ) ^ - 42dc: 2a 27 eor r18, r26 -bool ISO14443ACheckCRCA(void* Buffer, uint16_t ByteCount) -{ - uint16_t Checksum = 0x6363; - uint8_t* DataPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - 42de: e6 17 cp r30, r22 - 42e0: f7 07 cpc r31, r23 - 42e2: 11 f7 brne .-60 ; 0x42a8 - 42e4: a9 01 movw r20, r18 - 42e6: 55 27 eor r21, r21 - - Checksum = (Checksum >> 8) ^ ( (uint16_t) Byte << 8 ) ^ - ( (uint16_t) Byte << 3 ) ^ ( (uint16_t) Byte >> 4 ); - } - - return (DataPtr[0] == ((Checksum >> 0) & 0xFF)) && (DataPtr[1] == ((Checksum >> 8) & 0xFF)); - 42e8: 80 81 ld r24, Z - 42ea: 90 e0 ldi r25, 0x00 ; 0 - 42ec: 84 17 cp r24, r20 - 42ee: 95 07 cpc r25, r21 - 42f0: 11 f0 breq .+4 ; 0x42f6 - 42f2: 80 e0 ldi r24, 0x00 ; 0 -} - 42f4: 08 95 ret - - Checksum = (Checksum >> 8) ^ ( (uint16_t) Byte << 8 ) ^ - ( (uint16_t) Byte << 3 ) ^ ( (uint16_t) Byte >> 4 ); - } - - return (DataPtr[0] == ((Checksum >> 0) & 0xFF)) && (DataPtr[1] == ((Checksum >> 8) & 0xFF)); - 42f6: 41 81 ldd r20, Z+1 ; 0x01 - 42f8: 50 e0 ldi r21, 0x00 ; 0 - 42fa: 23 2f mov r18, r19 - 42fc: 33 27 eor r19, r19 - 42fe: 81 e0 ldi r24, 0x01 ; 1 - 4300: 42 17 cp r20, r18 - 4302: 53 07 cpc r21, r19 - 4304: b9 f3 breq .-18 ; 0x42f4 - 4306: 80 e0 ldi r24, 0x00 ; 0 - 4308: f5 cf rjmp .-22 ; 0x42f4 -bool ISO14443ACheckCRCA(void* Buffer, uint16_t ByteCount) -{ - uint16_t Checksum = 0x6363; - uint8_t* DataPtr = (uint8_t*) Buffer; - - while(ByteCount--) { - 430a: 43 e6 ldi r20, 0x63 ; 99 - 430c: 50 e0 ldi r21, 0x00 ; 0 - *DataPtr = (Checksum >> 8) & 0x00FF; -} - -bool ISO14443ACheckCRCA(void* Buffer, uint16_t ByteCount) -{ - uint16_t Checksum = 0x6363; - 430e: 23 e6 ldi r18, 0x63 ; 99 - 4310: 33 e6 ldi r19, 0x63 ; 99 - 4312: ea cf rjmp .-44 ; 0x42e8 - -00004314 : -/* Split Crypto1 state into even and odd bits to speed up the output filter network */ -static uint8_t StateEven[LFSR_SIZE/2] = {0}; -static uint8_t StateOdd[LFSR_SIZE/2] = {0}; - -/* Proceed LFSR by one clock cycle */ -static void Crypto1LFSR(uint8_t In) { - 4314: cf 93 push r28 - uint8_t Feedback = 0; - - /* Calculate feedback according to LFSR taps. XOR all 6 state bytes - * into a single bit. */ - Feedback ^= StateEven[0] & (uint8_t) (LFSR_MASK_EVEN >> 0); - 4316: b0 91 df 28 lds r27, 0x28DF - Feedback ^= StateEven[1] & (uint8_t) (LFSR_MASK_EVEN >> 8); - 431a: c0 91 e0 28 lds r28, 0x28E0 - Feedback ^= StateEven[2] & (uint8_t) (LFSR_MASK_EVEN >> 16); - 431e: 40 91 e1 28 lds r20, 0x28E1 - - Feedback ^= StateOdd[0] & (uint8_t) (LFSR_MASK_ODD >> 0); - 4322: a0 91 dc 28 lds r26, 0x28DC - Feedback ^= StateOdd[1] & (uint8_t) (LFSR_MASK_ODD >> 8); - 4326: f0 91 dd 28 lds r31, 0x28DD - Feedback ^= StateOdd[2] & (uint8_t) (LFSR_MASK_ODD >> 16); - 432a: e0 91 de 28 lds r30, 0x28DE - uint8_t Feedback = 0; - - /* Calculate feedback according to LFSR taps. XOR all 6 state bytes - * into a single bit. */ - Feedback ^= StateEven[0] & (uint8_t) (LFSR_MASK_EVEN >> 0); - Feedback ^= StateEven[1] & (uint8_t) (LFSR_MASK_EVEN >> 8); - 432e: 9c 2f mov r25, r28 - 4330: 90 71 andi r25, 0x10 ; 16 -static void Crypto1LFSR(uint8_t In) { - uint8_t Feedback = 0; - - /* Calculate feedback according to LFSR taps. XOR all 6 state bytes - * into a single bit. */ - Feedback ^= StateEven[0] & (uint8_t) (LFSR_MASK_EVEN >> 0); - 4332: 2b 2f mov r18, r27 - 4334: 21 7e andi r18, 0xE1 ; 225 - Feedback ^= StateEven[1] & (uint8_t) (LFSR_MASK_EVEN >> 8); - 4336: 92 27 eor r25, r18 - Feedback ^= StateEven[2] & (uint8_t) (LFSR_MASK_EVEN >> 16); - 4338: 24 2f mov r18, r20 - 433a: 20 72 andi r18, 0x20 ; 32 - 433c: 92 27 eor r25, r18 - - Feedback ^= StateOdd[0] & (uint8_t) (LFSR_MASK_ODD >> 0); - 433e: 2a 2f mov r18, r26 - 4340: 24 79 andi r18, 0x94 ; 148 - 4342: 92 27 eor r25, r18 - Feedback ^= StateOdd[1] & (uint8_t) (LFSR_MASK_ODD >> 8); - 4344: 2f 2f mov r18, r31 - 4346: 23 77 andi r18, 0x73 ; 115 - 4348: 92 27 eor r25, r18 - Feedback ^= StateOdd[2] & (uint8_t) (LFSR_MASK_ODD >> 16); - 434a: 2e 2f mov r18, r30 - 434c: 2a 73 andi r18, 0x3A ; 58 - 434e: 92 27 eor r25, r18 - - Feedback ^= Feedback >> 4; - 4350: 39 2f mov r19, r25 - 4352: 32 95 swap r19 - 4354: 3f 70 andi r19, 0x0F ; 15 - 4356: 39 27 eor r19, r25 - Feedback ^= Feedback >> 2; - 4358: 23 2f mov r18, r19 - 435a: 26 95 lsr r18 - 435c: 26 95 lsr r18 - 435e: 23 27 eor r18, r19 - Feedback ^= Feedback >> 1; - 4360: 92 2f mov r25, r18 - 4362: 96 95 lsr r25 - * - the new odd state becomes the old even state right-shifted by 1. - * For shifting the even state, we convert it into a 32 bit int first */ - uint32_t Temp = 0; - Temp |= ((uint32_t) StateEven[0] << 0); - Temp |= ((uint32_t) StateEven[1] << 8); - Temp |= ((uint32_t) StateEven[2] << 16); - 4364: 50 e0 ldi r21, 0x00 ; 0 - 4366: 60 e0 ldi r22, 0x00 ; 0 - 4368: 70 e0 ldi r23, 0x00 ; 0 - 436a: ba 01 movw r22, r20 - 436c: 55 27 eor r21, r21 - 436e: 44 27 eor r20, r20 - * - the new even state becomes the old odd state - * - the new odd state becomes the old even state right-shifted by 1. - * For shifting the even state, we convert it into a 32 bit int first */ - uint32_t Temp = 0; - Temp |= ((uint32_t) StateEven[0] << 0); - Temp |= ((uint32_t) StateEven[1] << 8); - 4370: 5c 2b or r21, r28 - Temp |= ((uint32_t) StateEven[2] << 16); - 4372: 4b 2b or r20, r27 - - /* Proceed LFSR. Try to force compiler not to shift the unneded upper bits. */ - Temp = (Temp >> 1) & 0x00FFFFFF; - 4374: 76 95 lsr r23 - 4376: 67 95 ror r22 - 4378: 57 95 ror r21 - 437a: 47 95 ror r20 - Feedback ^= StateOdd[1] & (uint8_t) (LFSR_MASK_ODD >> 8); - Feedback ^= StateOdd[2] & (uint8_t) (LFSR_MASK_ODD >> 16); - - Feedback ^= Feedback >> 4; - Feedback ^= Feedback >> 2; - Feedback ^= Feedback >> 1; - 437c: 92 27 eor r25, r18 - - /* Proceed LFSR. Try to force compiler not to shift the unneded upper bits. */ - Temp = (Temp >> 1) & 0x00FFFFFF; - - /* Calculate MSBit of even state as input bit to LFSR */ - if ( (Feedback & 0x01) ^ In ) { - 437e: 91 70 andi r25, 0x01 ; 1 - 4380: 98 13 cpse r25, r24 - Temp |= (uint32_t) 1 << (8 * LFSR_SIZE/2 - 1); - 4382: 60 68 ori r22, 0x80 ; 128 - } - - /* Convert even state back into byte array and swap odd/even state - * as explained above. */ - StateEven[0] = StateOdd[0]; - 4384: a0 93 df 28 sts 0x28DF, r26 - StateEven[1] = StateOdd[1]; - 4388: f0 93 e0 28 sts 0x28E0, r31 - StateEven[2] = StateOdd[2]; - 438c: e0 93 e1 28 sts 0x28E1, r30 - - StateOdd[0] = (uint8_t) (Temp >> 0); - 4390: 40 93 dc 28 sts 0x28DC, r20 - StateOdd[1] = (uint8_t) (Temp >> 8); - 4394: 50 93 dd 28 sts 0x28DD, r21 - StateOdd[2] = (uint8_t) (Temp >> 16); - 4398: 60 93 de 28 sts 0x28DE, r22 -} - 439c: cf 91 pop r28 - 439e: 08 95 ret - -000043a0 : - -uint8_t Crypto1FilterOutput(void) { - 43a0: cf 93 push r28 - 43a2: df 93 push r29 - * 5 bits that are used to lookup the output bit. - */ - uint8_t Sum = 0; - - Sum |= TableAB[0][(StateOdd[0] >> 4) & 0x0F]; - Sum |= TableAB[1][(StateOdd[1] >> 0) & 0x0F]; - 43a4: a0 91 dd 28 lds r26, 0x28DD - 43a8: ea 2f mov r30, r26 - 43aa: ef 70 andi r30, 0x0F ; 15 - 43ac: f0 e0 ldi r31, 0x00 ; 0 - 43ae: e0 5c subi r30, 0xC0 ; 192 - 43b0: ff 4d sbci r31, 0xDF ; 223 - * can simply be ORed together to produce the resulting - * 5 bits that are used to lookup the output bit. - */ - uint8_t Sum = 0; - - Sum |= TableAB[0][(StateOdd[0] >> 4) & 0x0F]; - 43b2: c0 91 dc 28 lds r28, 0x28DC - 43b6: c2 95 swap r28 - 43b8: cf 70 andi r28, 0x0F ; 15 - 43ba: d0 e0 ldi r29, 0x00 ; 0 - 43bc: c0 5c subi r28, 0xC0 ; 192 - 43be: df 4d sbci r29, 0xDF ; 223 - Sum |= TableAB[1][(StateOdd[1] >> 0) & 0x0F]; - 43c0: e0 89 ldd r30, Z+16 ; 0x10 - 43c2: 88 81 ld r24, Y - 43c4: e8 2b or r30, r24 - Sum |= TableAB[2][(StateOdd[1] >> 4) & 0x0F]; - 43c6: a2 95 swap r26 - 43c8: af 70 andi r26, 0x0F ; 15 - 43ca: b0 e0 ldi r27, 0x00 ; 0 - 43cc: a0 5c subi r26, 0xC0 ; 192 - 43ce: bf 4d sbci r27, 0xDF ; 223 - 43d0: 90 96 adiw r26, 0x20 ; 32 - 43d2: 8c 91 ld r24, X - 43d4: e8 2b or r30, r24 - Sum |= TableAB[3][(StateOdd[2] >> 0) & 0x0F]; - 43d6: a0 91 de 28 lds r26, 0x28DE - 43da: ca 2f mov r28, r26 - 43dc: cf 70 andi r28, 0x0F ; 15 - 43de: d0 e0 ldi r29, 0x00 ; 0 - 43e0: c0 5c subi r28, 0xC0 ; 192 - 43e2: df 4d sbci r29, 0xDF ; 223 - 43e4: 88 a9 ldd r24, Y+48 ; 0x30 - 43e6: e8 2b or r30, r24 - Sum |= TableAB[4][(StateOdd[2] >> 4) & 0x0F]; - 43e8: a2 95 swap r26 - 43ea: af 70 andi r26, 0x0F ; 15 - 43ec: b0 e0 ldi r27, 0x00 ; 0 - 43ee: a0 58 subi r26, 0x80 ; 128 - 43f0: bf 4d sbci r27, 0xDF ; 223 - 43f2: 8c 91 ld r24, X - 43f4: e8 2b or r30, r24 - - return TableC[Sum]; - 43f6: f0 e0 ldi r31, 0x00 ; 0 - 43f8: e0 5e subi r30, 0xE0 ; 224 - 43fa: ff 4d sbci r31, 0xDF ; 223 -} - 43fc: 80 81 ld r24, Z - 43fe: df 91 pop r29 - 4400: cf 91 pop r28 - 4402: 08 95 ret - -00004404 : - -void Crypto1Setup(uint8_t Key[6], uint8_t Uid[4], uint8_t CardNonce[4]) -{ - 4404: af 92 push r10 - 4406: bf 92 push r11 - 4408: cf 92 push r12 - 440a: df 92 push r13 - 440c: ef 92 push r14 - 440e: ff 92 push r15 - 4410: 0f 93 push r16 - 4412: 1f 93 push r17 - 4414: cf 93 push r28 - 4416: df 93 push r29 - 4418: 5b 01 movw r10, r22 - 441a: ea 01 movw r28, r20 - 441c: dc 01 movw r26, r24 - 441e: 11 96 adiw r26, 0x01 ; 1 - 4420: 4f ed ldi r20, 0xDF ; 223 - 4422: 58 e2 ldi r21, 0x28 ; 40 - 4424: 6c ed ldi r22, 0xDC ; 220 - 4426: 78 e2 ldi r23, 0x28 ; 40 - 4428: cd 01 movw r24, r26 - 442a: 01 97 sbiw r24, 0x01 ; 1 - * The inner loop generates 8 even and 8 odd bits from 16 key bits and - * the outer loop stores them. */ - for (i=0; i<(LFSR_SIZE/2); i++) { - uint8_t EvenByte = 0; - uint8_t OddByte = 0; - uint16_t KeyWord = ((uint16_t) Key[2*i+1] << 8) | Key[2*i+0]; - 442c: fc 01 movw r30, r24 - 442e: 20 81 ld r18, Z - 4430: 8c 91 ld r24, X - 4432: 30 e0 ldi r19, 0x00 ; 0 - 4434: 38 2b or r19, r24 - 4436: 20 ff sbrs r18, 0 - 4438: b0 c0 rjmp .+352 ; 0x459a - 443a: 00 e4 ldi r16, 0x40 ; 64 - 443c: 21 ff sbrs r18, 1 - 443e: ab c0 rjmp .+342 ; 0x4596 - 4440: 10 e4 ldi r17, 0x40 ; 64 - - if (KeyWord & (1<<1)) { - OddByte |= 0x80; - } - - KeyWord >>= 2; - 4442: c9 01 movw r24, r18 - 4444: 96 95 lsr r25 - 4446: 87 95 ror r24 - 4448: 96 95 lsr r25 - 444a: 87 95 ror r24 - for (j=0; j<8; j++) { - EvenByte >>= 1; - OddByte >>= 1; - - if (KeyWord & (1<<0)) { - EvenByte |= 0x80; - 444c: 30 2f mov r19, r16 - 444e: 30 68 ori r19, 0x80 ; 128 - 4450: 80 ff sbrs r24, 0 - 4452: 30 2f mov r19, r16 - } - - if (KeyWord & (1<<1)) { - OddByte |= 0x80; - 4454: 21 2f mov r18, r17 - 4456: 20 68 ori r18, 0x80 ; 128 - 4458: 81 ff sbrs r24, 1 - 445a: 21 2f mov r18, r17 - } - - KeyWord >>= 2; - 445c: 96 95 lsr r25 - 445e: 87 95 ror r24 - 4460: 96 95 lsr r25 - 4462: 87 95 ror r24 - uint8_t OddByte = 0; - uint16_t KeyWord = ((uint16_t) Key[2*i+1] << 8) | Key[2*i+0]; - uint8_t j; - - for (j=0; j<8; j++) { - EvenByte >>= 1; - 4464: 36 95 lsr r19 - OddByte >>= 1; - 4466: 26 95 lsr r18 - - if (KeyWord & (1<<0)) { - EvenByte |= 0x80; - 4468: 13 2f mov r17, r19 - 446a: 10 68 ori r17, 0x80 ; 128 - 446c: 80 fd sbrc r24, 0 - 446e: 31 2f mov r19, r17 - } - - if (KeyWord & (1<<1)) { - OddByte |= 0x80; - 4470: 12 2f mov r17, r18 - 4472: 10 68 ori r17, 0x80 ; 128 - 4474: 81 fd sbrc r24, 1 - 4476: 21 2f mov r18, r17 - } - - KeyWord >>= 2; - 4478: 96 95 lsr r25 - 447a: 87 95 ror r24 - 447c: 96 95 lsr r25 - 447e: 87 95 ror r24 - uint8_t OddByte = 0; - uint16_t KeyWord = ((uint16_t) Key[2*i+1] << 8) | Key[2*i+0]; - uint8_t j; - - for (j=0; j<8; j++) { - EvenByte >>= 1; - 4480: 36 95 lsr r19 - OddByte >>= 1; - 4482: 26 95 lsr r18 - - if (KeyWord & (1<<0)) { - EvenByte |= 0x80; - 4484: 13 2f mov r17, r19 - 4486: 10 68 ori r17, 0x80 ; 128 - 4488: 80 fd sbrc r24, 0 - 448a: 31 2f mov r19, r17 - } - - if (KeyWord & (1<<1)) { - OddByte |= 0x80; - 448c: 12 2f mov r17, r18 - 448e: 10 68 ori r17, 0x80 ; 128 - 4490: 81 fd sbrc r24, 1 - 4492: 21 2f mov r18, r17 - } - - KeyWord >>= 2; - 4494: 96 95 lsr r25 - 4496: 87 95 ror r24 - 4498: 96 95 lsr r25 - 449a: 87 95 ror r24 - uint8_t OddByte = 0; - uint16_t KeyWord = ((uint16_t) Key[2*i+1] << 8) | Key[2*i+0]; - uint8_t j; - - for (j=0; j<8; j++) { - EvenByte >>= 1; - 449c: 36 95 lsr r19 - OddByte >>= 1; - 449e: 26 95 lsr r18 - - if (KeyWord & (1<<0)) { - EvenByte |= 0x80; - 44a0: 13 2f mov r17, r19 - 44a2: 10 68 ori r17, 0x80 ; 128 - 44a4: 80 fd sbrc r24, 0 - 44a6: 31 2f mov r19, r17 - } - - if (KeyWord & (1<<1)) { - OddByte |= 0x80; - 44a8: 12 2f mov r17, r18 - 44aa: 10 68 ori r17, 0x80 ; 128 - 44ac: 81 fd sbrc r24, 1 - 44ae: 21 2f mov r18, r17 - } - - KeyWord >>= 2; - 44b0: 96 95 lsr r25 - 44b2: 87 95 ror r24 - 44b4: 96 95 lsr r25 - 44b6: 87 95 ror r24 - uint8_t OddByte = 0; - uint16_t KeyWord = ((uint16_t) Key[2*i+1] << 8) | Key[2*i+0]; - uint8_t j; - - for (j=0; j<8; j++) { - EvenByte >>= 1; - 44b8: 36 95 lsr r19 - OddByte >>= 1; - 44ba: 26 95 lsr r18 - - if (KeyWord & (1<<0)) { - EvenByte |= 0x80; - 44bc: 13 2f mov r17, r19 - 44be: 10 68 ori r17, 0x80 ; 128 - 44c0: 80 fd sbrc r24, 0 - 44c2: 31 2f mov r19, r17 - } - - if (KeyWord & (1<<1)) { - OddByte |= 0x80; - 44c4: 12 2f mov r17, r18 - 44c6: 10 68 ori r17, 0x80 ; 128 - 44c8: 81 fd sbrc r24, 1 - 44ca: 21 2f mov r18, r17 - } - - KeyWord >>= 2; - 44cc: 96 95 lsr r25 - 44ce: 87 95 ror r24 - 44d0: 96 95 lsr r25 - 44d2: 87 95 ror r24 - uint8_t OddByte = 0; - uint16_t KeyWord = ((uint16_t) Key[2*i+1] << 8) | Key[2*i+0]; - uint8_t j; - - for (j=0; j<8; j++) { - EvenByte >>= 1; - 44d4: 36 95 lsr r19 - OddByte >>= 1; - 44d6: 26 95 lsr r18 - - if (KeyWord & (1<<0)) { - EvenByte |= 0x80; - 44d8: 13 2f mov r17, r19 - 44da: 10 68 ori r17, 0x80 ; 128 - 44dc: 80 fd sbrc r24, 0 - 44de: 31 2f mov r19, r17 - } - - if (KeyWord & (1<<1)) { - OddByte |= 0x80; - 44e0: 12 2f mov r17, r18 - 44e2: 10 68 ori r17, 0x80 ; 128 - 44e4: 81 fd sbrc r24, 1 - 44e6: 21 2f mov r18, r17 - } - - KeyWord >>= 2; - 44e8: 96 95 lsr r25 - 44ea: 87 95 ror r24 - 44ec: 96 95 lsr r25 - 44ee: 87 95 ror r24 - uint8_t OddByte = 0; - uint16_t KeyWord = ((uint16_t) Key[2*i+1] << 8) | Key[2*i+0]; - uint8_t j; - - for (j=0; j<8; j++) { - EvenByte >>= 1; - 44f0: 36 95 lsr r19 - OddByte >>= 1; - 44f2: 26 95 lsr r18 - - if (KeyWord & (1<<0)) { - EvenByte |= 0x80; - 44f4: 03 2f mov r16, r19 - 44f6: 00 68 ori r16, 0x80 ; 128 - } - - if (KeyWord & (1<<1)) { - OddByte |= 0x80; - 44f8: 12 2f mov r17, r18 - 44fa: 10 68 ori r17, 0x80 ; 128 - 44fc: 80 fd sbrc r24, 0 - 44fe: 30 2f mov r19, r16 - } - - KeyWord >>= 2; - } - - StateEven[i] = EvenByte; - 4500: fa 01 movw r30, r20 - 4502: 31 93 st Z+, r19 - 4504: af 01 movw r20, r30 - 4506: 81 fd sbrc r24, 1 - 4508: 21 2f mov r18, r17 - StateOdd[i] = OddByte; - 450a: fb 01 movw r30, r22 - 450c: 21 93 st Z+, r18 - 450e: bf 01 movw r22, r30 - 4510: 12 96 adiw r26, 0x02 ; 2 - - /* Again, one trade off when splitting up the state into even/odd parts - * is that loading the key into the state becomes a little more difficult. - * The inner loop generates 8 even and 8 odd bits from 16 key bits and - * the outer loop stores them. */ - for (i=0; i<(LFSR_SIZE/2); i++) { - 4512: f8 e2 ldi r31, 0x28 ; 40 - 4514: 42 3e cpi r20, 0xE2 ; 226 - 4516: 5f 07 cpc r21, r31 - 4518: 09 f0 breq .+2 ; 0x451c - 451a: 86 cf rjmp .-244 ; 0x4428 - /* Use Uid XOR CardNonce as feed-in and do 32 clocks on the - * Crypto1 LFSR.*/ - uint32_t Temp = 0; - - Temp |= (uint32_t) (Uid[0] ^ CardNonce[0]) << 0; - Temp |= (uint32_t) (Uid[1] ^ CardNonce[1]) << 8; - 451c: f5 01 movw r30, r10 - 451e: 81 81 ldd r24, Z+1 ; 0x01 - 4520: 99 81 ldd r25, Y+1 ; 0x01 - 4522: 89 27 eor r24, r25 - Temp |= (uint32_t) (Uid[2] ^ CardNonce[2]) << 16; - 4524: c2 80 ldd r12, Z+2 ; 0x02 - 4526: 9a 81 ldd r25, Y+2 ; 0x02 - 4528: c9 26 eor r12, r25 - 452a: d1 2c mov r13, r1 - 452c: e1 2c mov r14, r1 - 452e: f1 2c mov r15, r1 - 4530: 76 01 movw r14, r12 - 4532: dd 24 eor r13, r13 - 4534: cc 24 eor r12, r12 - /* Use Uid XOR CardNonce as feed-in and do 32 clocks on the - * Crypto1 LFSR.*/ - uint32_t Temp = 0; - - Temp |= (uint32_t) (Uid[0] ^ CardNonce[0]) << 0; - Temp |= (uint32_t) (Uid[1] ^ CardNonce[1]) << 8; - 4536: d8 2a or r13, r24 - - /* Use Uid XOR CardNonce as feed-in and do 32 clocks on the - * Crypto1 LFSR.*/ - uint32_t Temp = 0; - - Temp |= (uint32_t) (Uid[0] ^ CardNonce[0]) << 0; - 4538: 80 81 ld r24, Z - 453a: 98 81 ld r25, Y - 453c: 89 27 eor r24, r25 - Temp |= (uint32_t) (Uid[1] ^ CardNonce[1]) << 8; - Temp |= (uint32_t) (Uid[2] ^ CardNonce[2]) << 16; - 453e: c8 2a or r12, r24 - Temp |= (uint32_t) (Uid[3] ^ CardNonce[3]) << 24; - 4540: 83 81 ldd r24, Z+3 ; 0x03 - 4542: 9b 81 ldd r25, Y+3 ; 0x03 - 4544: 89 27 eor r24, r25 - 4546: f8 2a or r15, r24 - 4548: 10 e2 ldi r17, 0x20 ; 32 - - for (i=0; i<32; i++) { - uint8_t Out = Crypto1FilterOutput(); - 454a: 2a df rcall .-428 ; 0x43a0 - 454c: 08 2f mov r16, r24 - - Crypto1LFSR(Temp & 0x01); - 454e: 8c 2d mov r24, r12 - 4550: 81 70 andi r24, 0x01 ; 1 - 4552: e0 de rcall .-576 ; 0x4314 - Temp >>= 1; - 4554: f6 94 lsr r15 - 4556: e7 94 ror r14 - 4558: d7 94 ror r13 - 455a: c7 94 ror r12 - - /* Store the keystream for later use */ - if (Out) { - 455c: 00 23 and r16, r16 - 455e: 11 f0 breq .+4 ; 0x4564 - Temp |= (uint32_t) 1 << 31; - 4560: 68 94 set - 4562: f7 f8 bld r15, 7 - 4564: 11 50 subi r17, 0x01 ; 1 - Temp |= (uint32_t) (Uid[0] ^ CardNonce[0]) << 0; - Temp |= (uint32_t) (Uid[1] ^ CardNonce[1]) << 8; - Temp |= (uint32_t) (Uid[2] ^ CardNonce[2]) << 16; - Temp |= (uint32_t) (Uid[3] ^ CardNonce[3]) << 24; - - for (i=0; i<32; i++) { - 4566: 89 f7 brne .-30 ; 0x454a - } - - /* Crypto1 state register is now set up to be used for authentication. - * In case of nested authentication, we need to use the produced keystream - * to encrypt the CardNonce. For this case we do the encryption in-place. */ - CardNonce[0] ^= (uint8_t) (Temp >> 0); - 4568: 88 81 ld r24, Y - 456a: 8c 25 eor r24, r12 - 456c: 88 83 st Y, r24 - CardNonce[1] ^= (uint8_t) (Temp >> 8); - 456e: 89 81 ldd r24, Y+1 ; 0x01 - 4570: 8d 25 eor r24, r13 - 4572: 89 83 std Y+1, r24 ; 0x01 - CardNonce[2] ^= (uint8_t) (Temp >> 16); - 4574: 8a 81 ldd r24, Y+2 ; 0x02 - 4576: 8e 25 eor r24, r14 - 4578: 8a 83 std Y+2, r24 ; 0x02 - CardNonce[3] ^= (uint8_t) (Temp >> 24); - 457a: 8b 81 ldd r24, Y+3 ; 0x03 - 457c: 8f 25 eor r24, r15 - 457e: 8b 83 std Y+3, r24 ; 0x03 -} - 4580: df 91 pop r29 - 4582: cf 91 pop r28 - 4584: 1f 91 pop r17 - 4586: 0f 91 pop r16 - 4588: ff 90 pop r15 - 458a: ef 90 pop r14 - 458c: df 90 pop r13 - 458e: cf 90 pop r12 - 4590: bf 90 pop r11 - 4592: af 90 pop r10 - 4594: 08 95 ret - 4596: 10 e0 ldi r17, 0x00 ; 0 - 4598: 54 cf rjmp .-344 ; 0x4442 - 459a: 00 e0 ldi r16, 0x00 ; 0 - 459c: 4f cf rjmp .-354 ; 0x443c - -0000459e : - -void Crypto1Auth(uint8_t EncryptedReaderNonce[4]) -{ - 459e: cf 92 push r12 - 45a0: df 92 push r13 - 45a2: ef 92 push r14 - 45a4: ff 92 push r15 - 45a6: cf 93 push r28 - 45a8: fc 01 movw r30, r24 - uint32_t Temp = 0; - - /* For ease of processing, we convert the encrypted reader nonce - * into a 32 bit integer */ - Temp |= (uint32_t) EncryptedReaderNonce[0] << 0; - Temp |= (uint32_t) EncryptedReaderNonce[1] << 8; - 45aa: 81 81 ldd r24, Z+1 ; 0x01 - Temp |= (uint32_t) EncryptedReaderNonce[2] << 16; - 45ac: c2 80 ldd r12, Z+2 ; 0x02 - 45ae: d1 2c mov r13, r1 - 45b0: e1 2c mov r14, r1 - 45b2: f1 2c mov r15, r1 - 45b4: 76 01 movw r14, r12 - 45b6: dd 24 eor r13, r13 - 45b8: cc 24 eor r12, r12 - uint32_t Temp = 0; - - /* For ease of processing, we convert the encrypted reader nonce - * into a 32 bit integer */ - Temp |= (uint32_t) EncryptedReaderNonce[0] << 0; - Temp |= (uint32_t) EncryptedReaderNonce[1] << 8; - 45ba: d8 2a or r13, r24 -{ - uint32_t Temp = 0; - - /* For ease of processing, we convert the encrypted reader nonce - * into a 32 bit integer */ - Temp |= (uint32_t) EncryptedReaderNonce[0] << 0; - 45bc: 80 81 ld r24, Z - Temp |= (uint32_t) EncryptedReaderNonce[1] << 8; - Temp |= (uint32_t) EncryptedReaderNonce[2] << 16; - 45be: c8 2a or r12, r24 - Temp |= (uint32_t) EncryptedReaderNonce[3] << 24; - 45c0: 83 81 ldd r24, Z+3 ; 0x03 - 45c2: f8 2a or r15, r24 - 45c4: c0 e2 ldi r28, 0x20 ; 32 - uint8_t i; - - for (i=0; i<32; i++) { - /* Decrypt one output bit of the given encrypted nonce using the - * filter output as keystream. */ - uint8_t Out = Crypto1FilterOutput(); - 45c6: ec de rcall .-552 ; 0x43a0 - uint8_t Bit = Out ^ (Temp & 0x01); - 45c8: 9c 2d mov r25, r12 - 45ca: 91 70 andi r25, 0x01 ; 1 - - /* Feed back the bit to load the LFSR with the (decrypted) nonce */ - Crypto1LFSR(Bit); - 45cc: 89 27 eor r24, r25 - 45ce: a2 de rcall .-700 ; 0x4314 - Temp >>= 1; - 45d0: f6 94 lsr r15 - 45d2: e7 94 ror r14 - 45d4: d7 94 ror r13 - 45d6: c7 94 ror r12 - 45d8: c1 50 subi r28, 0x01 ; 1 - Temp |= (uint32_t) EncryptedReaderNonce[2] << 16; - Temp |= (uint32_t) EncryptedReaderNonce[3] << 24; - - uint8_t i; - - for (i=0; i<32; i++) { - 45da: a9 f7 brne .-22 ; 0x45c6 - - /* Feed back the bit to load the LFSR with the (decrypted) nonce */ - Crypto1LFSR(Bit); - Temp >>= 1; - } -} - 45dc: cf 91 pop r28 - 45de: ff 90 pop r15 - 45e0: ef 90 pop r14 - 45e2: df 90 pop r13 - 45e4: cf 90 pop r12 - 45e6: 08 95 ret - -000045e8 : - -uint8_t Crypto1Byte(void) -{ - 45e8: 1f 93 push r17 - 45ea: cf 93 push r28 - 45ec: df 93 push r29 - 45ee: d8 e0 ldi r29, 0x08 ; 8 - uint8_t KeyStream = 0; - 45f0: c0 e0 ldi r28, 0x00 ; 0 - /* Generate 8 keystream-bits */ - for (i=0; i<8; i++) { - - /* Calculate output of function-network and cycle LFSR with no - * additional input, thus linearly! */ - uint8_t Out = Crypto1FilterOutput(); - 45f2: d6 de rcall .-596 ; 0x43a0 - 45f4: 18 2f mov r17, r24 - Crypto1LFSR(0); - 45f6: 80 e0 ldi r24, 0x00 ; 0 - 45f8: 8d de rcall .-742 ; 0x4314 - - /* Store keystream bit */ - KeyStream >>= 1; - 45fa: c6 95 lsr r28 - - if (Out) { - 45fc: 11 11 cpse r17, r1 - KeyStream |= (1<<7); - 45fe: c0 68 ori r28, 0x80 ; 128 - 4600: d1 50 subi r29, 0x01 ; 1 -{ - uint8_t KeyStream = 0; - uint8_t i; - - /* Generate 8 keystream-bits */ - for (i=0; i<8; i++) { - 4602: b9 f7 brne .-18 ; 0x45f2 - KeyStream |= (1<<7); - } - } - - return KeyStream; -} - 4604: 8c 2f mov r24, r28 - 4606: df 91 pop r29 - 4608: cf 91 pop r28 - 460a: 1f 91 pop r17 - 460c: 08 95 ret - -0000460e : - -uint8_t Crypto1Nibble(void) -{ - 460e: 1f 93 push r17 - 4610: cf 93 push r28 - 4612: df 93 push r29 - 4614: d4 e0 ldi r29, 0x04 ; 4 - uint8_t KeyStream = 0; - 4616: c0 e0 ldi r28, 0x00 ; 0 - /* Generate 4 keystream-bits */ - for (i=0; i<4; i++) { - - /* Calculate output of function-network and cycle LFSR with no - * additional input, thus linearly! */ - uint8_t Out = Crypto1FilterOutput(); - 4618: c3 de rcall .-634 ; 0x43a0 - 461a: 18 2f mov r17, r24 - Crypto1LFSR(0); - 461c: 80 e0 ldi r24, 0x00 ; 0 - 461e: 7a de rcall .-780 ; 0x4314 - - /* Store keystream bit */ - KeyStream >>= 1; - 4620: c6 95 lsr r28 - - if (Out) { - 4622: 11 11 cpse r17, r1 - KeyStream |= (1<<3); - 4624: c8 60 ori r28, 0x08 ; 8 - 4626: d1 50 subi r29, 0x01 ; 1 -{ - uint8_t KeyStream = 0; - uint8_t i; - - /* Generate 4 keystream-bits */ - for (i=0; i<4; i++) { - 4628: b9 f7 brne .-18 ; 0x4618 - KeyStream |= (1<<3); - } - } - - return KeyStream; -} - 462a: 8c 2f mov r24, r28 - 462c: df 91 pop r29 - 462e: cf 91 pop r28 - 4630: 1f 91 pop r17 - 4632: 08 95 ret - -00004634 : - -void Crypto1PRNG(uint8_t State[4], uint16_t ClockCount) -{ - 4634: 8f 92 push r8 - 4636: 9f 92 push r9 - 4638: af 92 push r10 - 463a: bf 92 push r11 - 463c: cf 92 push r12 - 463e: df 92 push r13 - 4640: ef 92 push r14 - 4642: ff 92 push r15 - 4644: 0f 93 push r16 - 4646: 1f 93 push r17 - 4648: fc 01 movw r30, r24 - while(ClockCount--) { - 464a: cb 01 movw r24, r22 - 464c: 01 97 sbiw r24, 0x01 ; 1 - 464e: 67 2b or r22, r23 - 4650: b1 f1 breq .+108 ; 0x46be - 4652: b2 81 ldd r27, Z+2 ; 0x02 - 4654: a0 81 ld r26, Z - 4656: 81 80 ldd r8, Z+1 ; 0x01 - 4658: 03 81 ldd r16, Z+3 ; 0x03 - 465a: 02 c0 rjmp .+4 ; 0x4660 - 465c: a4 2f mov r26, r20 - 465e: bc 2d mov r27, r12 - * XOR all tapped bits to a single feedback bit. */ - uint8_t Feedback = 0; - - Feedback ^= State[0] & (uint8_t) (PRNG_MASK >> 0); - Feedback ^= State[1] & (uint8_t) (PRNG_MASK >> 8); - Feedback ^= State[2] & (uint8_t) (PRNG_MASK >> 16); - 4660: 2b 2f mov r18, r27 - 4662: 2d 72 andi r18, 0x2D ; 45 - Feedback ^= State[3] & (uint8_t) (PRNG_MASK >> 24); - - Feedback ^= Feedback >> 4; - 4664: 32 2f mov r19, r18 - 4666: 32 95 swap r19 - 4668: 3f 70 andi r19, 0x0F ; 15 - 466a: 32 27 eor r19, r18 - Feedback ^= Feedback >> 2; - 466c: 23 2f mov r18, r19 - 466e: 26 95 lsr r18 - 4670: 26 95 lsr r18 - 4672: 23 27 eor r18, r19 - Feedback ^= Feedback >> 1; - 4674: 32 2f mov r19, r18 - 4676: 36 95 lsr r19 - uint32_t Temp = 0; - - Temp |= (uint32_t) State[0] << 0; - Temp |= (uint32_t) State[1] << 8; - Temp |= (uint32_t) State[2] << 16; - Temp |= (uint32_t) State[3] << 24; - 4678: 40 2f mov r20, r16 - 467a: 50 e0 ldi r21, 0x00 ; 0 - 467c: 60 e0 ldi r22, 0x00 ; 0 - 467e: 70 e0 ldi r23, 0x00 ; 0 - 4680: 74 2f mov r23, r20 - 4682: 66 27 eor r22, r22 - 4684: 55 27 eor r21, r21 - 4686: 44 27 eor r20, r20 - - /* For ease of processing convert the state into a 32 bit integer first */ - uint32_t Temp = 0; - - Temp |= (uint32_t) State[0] << 0; - Temp |= (uint32_t) State[1] << 8; - 4688: 58 29 or r21, r8 - Temp |= (uint32_t) State[2] << 16; - 468a: 4a 2b or r20, r26 - Temp |= (uint32_t) State[3] << 24; - 468c: 6b 2b or r22, r27 - - /* Cycle LFSR and feed back. */ - Temp >>= 1; - 468e: 76 95 lsr r23 - 4690: 67 95 ror r22 - 4692: 57 95 ror r21 - 4694: 47 95 ror r20 - Feedback ^= State[2] & (uint8_t) (PRNG_MASK >> 16); - Feedback ^= State[3] & (uint8_t) (PRNG_MASK >> 24); - - Feedback ^= Feedback >> 4; - Feedback ^= Feedback >> 2; - Feedback ^= Feedback >> 1; - 4696: 32 27 eor r19, r18 - Temp |= (uint32_t) State[3] << 24; - - /* Cycle LFSR and feed back. */ - Temp >>= 1; - - if (Feedback & 0x01) { - 4698: 30 fd sbrc r19, 0 - Temp |= (uint32_t) 1 << (8 * PRNG_SIZE - 1); - 469a: 70 68 ori r23, 0x80 ; 128 - } - - /* Store back state */ - State[0] = (uint8_t) (Temp >> 0); - State[1] = (uint8_t) (Temp >> 8); - 469c: 85 2e mov r8, r21 - 469e: 96 2e mov r9, r22 - 46a0: a7 2e mov r10, r23 - 46a2: bb 24 eor r11, r11 - State[2] = (uint8_t) (Temp >> 16); - 46a4: 6b 01 movw r12, r22 - 46a6: ee 24 eor r14, r14 - 46a8: ff 24 eor r15, r15 - State[3] = (uint8_t) (Temp >> 24); - 46aa: 07 2f mov r16, r23 - 46ac: 11 27 eor r17, r17 - 46ae: 22 27 eor r18, r18 - 46b0: 33 27 eor r19, r19 - return KeyStream; -} - -void Crypto1PRNG(uint8_t State[4], uint16_t ClockCount) -{ - while(ClockCount--) { - 46b2: 01 97 sbiw r24, 0x01 ; 1 - 46b4: 98 f6 brcc .-90 ; 0x465c - 46b6: 40 83 st Z, r20 - 46b8: 81 82 std Z+1, r8 ; 0x01 - 46ba: c2 82 std Z+2, r12 ; 0x02 - 46bc: 03 83 std Z+3, r16 ; 0x03 - State[2] = (uint8_t) (Temp >> 16); - State[3] = (uint8_t) (Temp >> 24); - } - - -} - 46be: 1f 91 pop r17 - 46c0: 0f 91 pop r16 - 46c2: ff 90 pop r15 - 46c4: ef 90 pop r14 - 46c6: df 90 pop r13 - 46c8: cf 90 pop r12 - 46ca: bf 90 pop r11 - 46cc: af 90 pop r10 - 46ce: 9f 90 pop r9 - 46d0: 8f 90 pop r8 - 46d2: 08 95 ret - -000046d4 : -#if !defined(NO_DEVICE_REMOTE_WAKEUP) -bool USB_Device_RemoteWakeupEnabled; -#endif - -void USB_Device_ProcessControlRequest(void) -{ - 46d4: 0f 93 push r16 - 46d6: 1f 93 push r17 - 46d8: cf 93 push r28 - 46da: df 93 push r29 - 46dc: cd b7 in r28, 0x3d ; 61 - 46de: de b7 in r29, 0x3e ; 62 - 46e0: ea 97 sbiw r28, 0x3a ; 58 - 46e2: cd bf out 0x3d, r28 ; 61 - 46e4: de bf out 0x3e, r29 ; 62 - 46e6: 01 e4 ldi r16, 0x41 ; 65 - 46e8: 1b e2 ldi r17, 0x2B ; 43 - USB_ControlRequest.wLength = Endpoint_Read_16_LE(); - #else - uint8_t* RequestHeader = (uint8_t*)&USB_ControlRequest; - - for (uint8_t RequestHeaderByte = 0; RequestHeaderByte < sizeof(USB_Request_Header_t); RequestHeaderByte++) - *(RequestHeader++) = Endpoint_Read_8(); - 46ea: f7 d2 rcall .+1518 ; 0x4cda - 46ec: f8 01 movw r30, r16 - 46ee: 81 93 st Z+, r24 - 46f0: 8f 01 movw r16, r30 - USB_ControlRequest.wIndex = Endpoint_Read_16_LE(); - USB_ControlRequest.wLength = Endpoint_Read_16_LE(); - #else - uint8_t* RequestHeader = (uint8_t*)&USB_ControlRequest; - - for (uint8_t RequestHeaderByte = 0; RequestHeaderByte < sizeof(USB_Request_Header_t); RequestHeaderByte++) - 46f2: fb e2 ldi r31, 0x2B ; 43 - 46f4: 09 34 cpi r16, 0x49 ; 73 - 46f6: 1f 07 cpc r17, r31 - 46f8: c1 f7 brne .-16 ; 0x46ea - *(RequestHeader++) = Endpoint_Read_8(); - #endif - - EVENT_USB_Device_ControlRequest(); - 46fa: 0e 94 95 11 call 0x232a ; 0x232a - - if (Endpoint_IsSETUPReceived()) - 46fe: 6b d3 rcall .+1750 ; 0x4dd6 - 4700: 88 23 and r24, r24 - 4702: 49 f0 breq .+18 ; 0x4716 - { - uint8_t bmRequestType = USB_ControlRequest.bmRequestType; - 4704: 30 91 41 2b lds r19, 0x2B41 - - switch (USB_ControlRequest.bRequest) - 4708: 20 91 42 2b lds r18, 0x2B42 - 470c: 82 2f mov r24, r18 - 470e: 90 e0 ldi r25, 0x00 ; 0 - 4710: 8a 30 cpi r24, 0x0A ; 10 - 4712: 91 05 cpc r25, r1 - 4714: 68 f0 brcs .+26 ; 0x4730 - default: - break; - } - } - - if (Endpoint_IsSETUPReceived()) - 4716: 5f d3 rcall .+1726 ; 0x4dd6 - 4718: 88 23 and r24, r24 - 471a: 11 f0 breq .+4 ; 0x4720 - { - Endpoint_ClearSETUP(); - 471c: 75 d3 rcall .+1770 ; 0x4e08 - Endpoint_StallTransaction(); - 471e: a0 d3 rcall .+1856 ; 0x4e60 - } -} - 4720: ea 96 adiw r28, 0x3a ; 58 - 4722: cd bf out 0x3d, r28 ; 61 - 4724: de bf out 0x3e, r29 ; 62 - 4726: df 91 pop r29 - 4728: cf 91 pop r28 - 472a: 1f 91 pop r17 - 472c: 0f 91 pop r16 - 472e: 08 95 ret - - if (Endpoint_IsSETUPReceived()) - { - uint8_t bmRequestType = USB_ControlRequest.bmRequestType; - - switch (USB_ControlRequest.bRequest) - 4730: fc 01 movw r30, r24 - 4732: e1 59 subi r30, 0x91 ; 145 - 4734: fe 4f sbci r31, 0xFE ; 254 - 4736: de c7 rjmp .+4028 ; 0x56f4 <__tablejump2__> - if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) - USB_Device_GetConfiguration(); - - break; - case REQ_SetConfiguration: - if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) - 4738: 31 11 cpse r19, r1 - 473a: ed cf rjmp .-38 ; 0x4716 -} - -static void USB_Device_SetConfiguration(void) -{ - #if defined(FIXED_NUM_CONFIGURATIONS) - if ((uint8_t)USB_ControlRequest.wValue > FIXED_NUM_CONFIGURATIONS) - 473c: 80 91 43 2b lds r24, 0x2B43 - 4740: 82 30 cpi r24, 0x02 ; 2 - 4742: 48 f7 brcc .-46 ; 0x4716 - if ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations) - return; - #endif - #endif - - Endpoint_ClearSETUP(); - 4744: 61 d3 rcall .+1730 ; 0x4e08 - - USB_Device_ConfigurationNumber = (uint8_t)USB_ControlRequest.wValue; - 4746: 80 91 43 2b lds r24, 0x2B43 - 474a: 80 93 3c 2b sts 0x2B3C, r24 - - Endpoint_ClearStatusStage(); - 474e: 93 d4 rcall .+2342 ; 0x5076 - - if (USB_Device_ConfigurationNumber) - 4750: 80 91 3c 2b lds r24, 0x2B3C - 4754: 88 23 and r24, r24 - 4756: 09 f4 brne .+2 ; 0x475a - 4758: d1 c0 rjmp .+418 ; 0x48fc - USB_DeviceState = DEVICE_STATE_Configured; - 475a: 84 e0 ldi r24, 0x04 ; 4 - 475c: 80 93 40 2b sts 0x2B40, r24 - else - USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered; - - EVENT_USB_Device_ConfigurationChanged(); - 4760: 0e 94 91 11 call 0x2322 ; 0x2322 - 4764: d8 cf rjmp .-80 ; 0x4716 - USB_Device_GetDescriptor(); - } - - break; - case REQ_GetConfiguration: - if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) - 4766: 30 38 cpi r19, 0x80 ; 128 - 4768: b1 f6 brne .-84 ; 0x4716 - EVENT_USB_Device_ConfigurationChanged(); -} - -static void USB_Device_GetConfiguration(void) -{ - Endpoint_ClearSETUP(); - 476a: 4e d3 rcall .+1692 ; 0x4e08 - - Endpoint_Write_8(USB_Device_ConfigurationNumber); - 476c: 80 91 3c 2b lds r24, 0x2B3C - 4770: c4 d2 rcall .+1416 ; 0x4cfa - Endpoint_ClearIN(); - 4772: 8b d2 rcall .+1302 ; 0x4c8a - - Endpoint_ClearStatusStage(); - 4774: 80 d4 rcall .+2304 ; 0x5076 - 4776: cf cf rjmp .-98 ; 0x4716 - if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) - USB_Device_SetAddress(); - - break; - case REQ_GetDescriptor: - if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) || - 4778: 30 58 subi r19, 0x80 ; 128 - 477a: 32 30 cpi r19, 0x02 ; 2 - 477c: 60 f6 brcc .-104 ; 0x4716 - !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) - uint8_t DescriptorAddressSpace; - #endif - - #if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR) - if (USB_ControlRequest.wValue == ((DTYPE_String << 8) | USE_INTERNAL_SERIAL)) - 477e: 80 91 43 2b lds r24, 0x2B43 - 4782: 90 91 44 2b lds r25, 0x2B44 - 4786: 8c 3d cpi r24, 0xDC ; 220 - 4788: e3 e0 ldi r30, 0x03 ; 3 - 478a: 9e 07 cpc r25, r30 - 478c: 09 f4 brne .+2 ; 0x4790 - 478e: 88 c0 rjmp .+272 ; 0x48a0 - USB_Device_GetInternalSerialDescriptor(); - return; - } - #endif - - if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex, - 4790: ae 01 movw r20, r28 - 4792: 4f 5f subi r20, 0xFF ; 255 - 4794: 5f 4f sbci r21, 0xFF ; 255 - 4796: 60 91 45 2b lds r22, 0x2B45 - 479a: 0e 94 4c 05 call 0xa98 ; 0xa98 - 479e: 8c 01 movw r16, r24 - 47a0: 00 97 sbiw r24, 0x00 ; 0 - 47a2: 09 f4 brne .+2 ; 0x47a6 - 47a4: b8 cf rjmp .-144 ; 0x4716 - )) == NO_DESCRIPTOR) - { - return; - } - - Endpoint_ClearSETUP(); - 47a6: 30 d3 rcall .+1632 ; 0x4e08 - #if defined(USE_RAM_DESCRIPTORS) || !defined(ARCH_HAS_MULTI_ADDRESS_SPACE) - Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize); - #elif defined(USE_EEPROM_DESCRIPTORS) - Endpoint_Write_Control_EStream_LE(DescriptorPointer, DescriptorSize); - #elif defined(USE_FLASH_DESCRIPTORS) - Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize); - 47a8: b8 01 movw r22, r16 - 47aa: 89 81 ldd r24, Y+1 ; 0x01 - 47ac: 9a 81 ldd r25, Y+2 ; 0x02 - 47ae: c1 d1 rcall .+898 ; 0x4b32 - Endpoint_Write_Control_EStream_LE(DescriptorPointer, DescriptorSize); - else - Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize); - #endif - - Endpoint_ClearOUT(); - 47b0: 85 d2 rcall .+1290 ; 0x4cbc - 47b2: b1 cf rjmp .-158 ; 0x4716 - USB_Device_ClearSetFeature(); - } - - break; - case REQ_SetAddress: - if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) - 47b4: 31 11 cpse r19, r1 - 47b6: af cf rjmp .-162 ; 0x4716 - } -} - -static void USB_Device_SetAddress(void) -{ - uint8_t DeviceAddress = (USB_ControlRequest.wValue & 0x7F); - 47b8: 10 91 43 2b lds r17, 0x2B43 - 47bc: 1f 77 andi r17, 0x7F ; 127 - - USB_Device_SetDeviceAddress(DeviceAddress); - - Endpoint_ClearSETUP(); - 47be: 24 d3 rcall .+1608 ; 0x4e08 - - Endpoint_ClearStatusStage(); - 47c0: 5a d4 rcall .+2228 ; 0x5076 - - while (!(Endpoint_IsINReady())); - 47c2: e4 d2 rcall .+1480 ; 0x4d8c - 47c4: 88 23 and r24, r24 - 47c6: e9 f3 breq .-6 ; 0x47c2 - } - - static inline void USB_Device_EnableDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; - static inline void USB_Device_EnableDeviceAddress(const uint8_t Address) - { - USB.ADDR = Address; - 47c8: 10 93 c3 04 sts 0x04C3, r17 - - USB_Device_EnableDeviceAddress(DeviceAddress); - - USB_DeviceState = (DeviceAddress) ? DEVICE_STATE_Addressed : DEVICE_STATE_Default; - 47cc: 11 11 cpse r17, r1 - 47ce: 66 c0 rjmp .+204 ; 0x489c - 47d0: 82 e0 ldi r24, 0x02 ; 2 - 47d2: 80 93 40 2b sts 0x2B40, r24 - 47d6: 9f cf rjmp .-194 ; 0x4716 - } - - break; - case REQ_ClearFeature: - case REQ_SetFeature: - if ((bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) || - 47d8: 33 23 and r19, r19 - 47da: 09 f4 brne .+2 ; 0x47de - 47dc: 4b c0 rjmp .+150 ; 0x4874 - 47de: 32 30 cpi r19, 0x02 ; 2 - 47e0: 09 f0 breq .+2 ; 0x47e4 - 47e2: 99 cf rjmp .-206 ; 0x4716 - - break; - #endif - #if !defined(CONTROL_ONLY_DEVICE) - case REQREC_ENDPOINT: - if ((uint8_t)USB_ControlRequest.wValue == FEATURE_SEL_EndpointHalt) - 47e4: 80 91 43 2b lds r24, 0x2B43 - 47e8: 81 11 cpse r24, r1 - 47ea: 24 c0 rjmp .+72 ; 0x4834 - { - uint8_t EndpointIndex = ((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK); - 47ec: 10 91 45 2b lds r17, 0x2B45 - 47f0: 1f 70 andi r17, 0x0F ; 15 - - if (EndpointIndex == ENDPOINT_CONTROLEP) - 47f2: 09 f4 brne .+2 ; 0x47f6 - 47f4: 90 cf rjmp .-224 ; 0x4716 - return; - - Endpoint_SelectEndpoint(EndpointIndex); - 47f6: 81 2f mov r24, r17 - 47f8: 90 d2 rcall .+1312 ; 0x4d1a - - if (Endpoint_IsEnabled()) - { - if (USB_ControlRequest.bRequest == REQ_SetFeature) - 47fa: 80 91 42 2b lds r24, 0x2B42 - 47fe: 83 30 cpi r24, 0x03 ; 3 - 4800: 09 f4 brne .+2 ; 0x4804 - 4802: 86 c0 rjmp .+268 ; 0x4910 - * \ingroup Group_EndpointPacketManagement_XMEGA - */ - static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE; - static inline void Endpoint_ClearStall(void) - { - USB_Endpoint_SelectedHandle->CTRL &= ~USB_EP_STALL_bm; - 4804: a0 91 4b 2b lds r26, 0x2B4B - 4808: b0 91 4c 2b lds r27, 0x2B4C - 480c: 11 96 adiw r26, 0x01 ; 1 - 480e: 8c 91 ld r24, X - 4810: 11 97 sbiw r26, 0x01 ; 1 - 4812: 8b 7f andi r24, 0xFB ; 251 - 4814: 11 96 adiw r26, 0x01 ; 1 - 4816: 8c 93 st X, r24 - static inline void Endpoint_ResetEndpoint(const uint8_t Address) - { - if (Address & ENDPOINT_DIR_IN) - USB_Endpoint_FIFOs[Address & ENDPOINT_EPNUM_MASK].IN.Position = 0; - else - USB_Endpoint_FIFOs[Address & ENDPOINT_EPNUM_MASK].OUT.Position = 0; - 4818: 24 e8 ldi r18, 0x84 ; 132 - 481a: 12 9f mul r17, r18 - 481c: f0 01 movw r30, r0 - 481e: 11 24 eor r1, r1 - 4820: e1 57 subi r30, 0x71 ; 113 - 4822: f4 4d sbci r31, 0xD4 ; 212 - 4824: 10 82 st Z, r1 - - /** Resets the data toggle of the currently selected endpoint. */ - static inline void Endpoint_ResetDataToggle(void) ATTR_ALWAYS_INLINE; - static inline void Endpoint_ResetDataToggle(void) - { - USB_Endpoint_SelectedHandle->STATUS &= ~USB_EP_TOGGLE_bm; - 4826: e0 91 4b 2b lds r30, 0x2B4B - 482a: f0 91 4c 2b lds r31, 0x2B4C - 482e: 80 81 ld r24, Z - 4830: 8e 7f andi r24, 0xFE ; 254 - 4832: 80 83 st Z, r24 - #endif - default: - return; - } - - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - 4834: 80 e0 ldi r24, 0x00 ; 0 - 4836: 71 d2 rcall .+1250 ; 0x4d1a - - Endpoint_ClearSETUP(); - 4838: e7 d2 rcall .+1486 ; 0x4e08 - - Endpoint_ClearStatusStage(); - 483a: 1d d4 rcall .+2106 ; 0x5076 - 483c: 6c cf rjmp .-296 ; 0x4716 - uint8_t bmRequestType = USB_ControlRequest.bmRequestType; - - switch (USB_ControlRequest.bRequest) - { - case REQ_GetStatus: - if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) || - 483e: 30 38 cpi r19, 0x80 ; 128 - 4840: 29 f1 breq .+74 ; 0x488c - 4842: 32 38 cpi r19, 0x82 ; 130 - 4844: 09 f0 breq .+2 ; 0x4848 - 4846: 67 cf rjmp .-306 ; 0x4716 - CurrentStatus |= FEATURE_REMOTE_WAKEUP_ENABLED; - #endif - break; - case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT): - #if !defined(CONTROL_ONLY_DEVICE) - Endpoint_SelectEndpoint((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK); - 4848: 80 91 45 2b lds r24, 0x2B45 - 484c: 8f 70 andi r24, 0x0F ; 15 - 484e: 65 d2 rcall .+1226 ; 0x4d1a - * \return Boolean \c true if the currently selected endpoint is stalled, \c false otherwise. - */ - static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Endpoint_IsStalled(void) - { - return ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_STALL_bm) ? true : false); - 4850: e0 91 4b 2b lds r30, 0x2B4B - 4854: f0 91 4c 2b lds r31, 0x2B4C - 4858: 11 81 ldd r17, Z+1 ; 0x01 - 485a: 12 fb bst r17, 2 - 485c: 11 27 eor r17, r17 - 485e: 10 f9 bld r17, 0 - - CurrentStatus = Endpoint_IsStalled(); - - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - 4860: 80 e0 ldi r24, 0x00 ; 0 - 4862: 5b d2 rcall .+1206 ; 0x4d1a - break; - default: - return; - } - - Endpoint_ClearSETUP(); - 4864: d1 d2 rcall .+1442 ; 0x4e08 - * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. - */ - static inline void Endpoint_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE; - static inline void Endpoint_Write_16_LE(const uint16_t Data) - { - Endpoint_Write_8(Data & 0xFF); - 4866: 81 2f mov r24, r17 - 4868: 48 d2 rcall .+1168 ; 0x4cfa - Endpoint_Write_8(Data >> 8); - 486a: 80 e0 ldi r24, 0x00 ; 0 - 486c: 46 d2 rcall .+1164 ; 0x4cfa - - Endpoint_Write_16_LE(CurrentStatus); - Endpoint_ClearIN(); - 486e: 0d d2 rcall .+1050 ; 0x4c8a - - Endpoint_ClearStatusStage(); - 4870: 02 d4 rcall .+2052 ; 0x5076 - 4872: 51 cf rjmp .-350 ; 0x4716 -{ - switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) - { - #if !defined(NO_DEVICE_REMOTE_WAKEUP) - case REQREC_DEVICE: - if ((uint8_t)USB_ControlRequest.wValue == FEATURE_SEL_DeviceRemoteWakeup) - 4874: 80 91 43 2b lds r24, 0x2B43 - 4878: 81 30 cpi r24, 0x01 ; 1 - 487a: 09 f0 breq .+2 ; 0x487e - 487c: 4c cf rjmp .-360 ; 0x4716 - USB_Device_RemoteWakeupEnabled = (USB_ControlRequest.bRequest == REQ_SetFeature); - 487e: 81 e0 ldi r24, 0x01 ; 1 - 4880: 23 30 cpi r18, 0x03 ; 3 - 4882: 09 f0 breq .+2 ; 0x4886 - 4884: 80 e0 ldi r24, 0x00 ; 0 - 4886: 80 93 3e 2b sts 0x2B3E, r24 - 488a: d4 cf rjmp .-88 ; 0x4834 - Endpoint_ClearOUT(); -} - -static void USB_Device_GetStatus(void) -{ - uint8_t CurrentStatus = 0; - 488c: 10 91 3d 2b lds r17, 0x2B3D - if (USB_Device_CurrentlySelfPowered) - CurrentStatus |= FEATURE_SELFPOWERED_ENABLED; - #endif - - #if !defined(NO_DEVICE_REMOTE_WAKEUP) - if (USB_Device_RemoteWakeupEnabled) - 4890: 80 91 3e 2b lds r24, 0x2B3E - 4894: 88 23 and r24, r24 - 4896: 31 f3 breq .-52 ; 0x4864 - CurrentStatus |= FEATURE_REMOTE_WAKEUP_ENABLED; - 4898: 12 60 ori r17, 0x02 ; 2 - 489a: e4 cf rjmp .-56 ; 0x4864 - - while (!(Endpoint_IsINReady())); - - USB_Device_EnableDeviceAddress(DeviceAddress); - - USB_DeviceState = (DeviceAddress) ? DEVICE_STATE_Addressed : DEVICE_STATE_Default; - 489c: 83 e0 ldi r24, 0x03 ; 3 - 489e: 99 cf rjmp .-206 ; 0x47d2 - { - USB_Descriptor_Header_t Header; - uint16_t UnicodeString[INTERNAL_SERIAL_LENGTH_BITS / 4]; - } SignatureDescriptor; - - SignatureDescriptor.Header.Type = DTYPE_String; - 48a0: 83 e0 ldi r24, 0x03 ; 3 - 48a2: 8a 83 std Y+2, r24 ; 0x02 - SignatureDescriptor.Header.Size = USB_STRING_LEN(INTERNAL_SERIAL_LENGTH_BITS / 4); - 48a4: 8a e3 ldi r24, 0x3A ; 58 - 48a6: 89 83 std Y+1, r24 ; 0x01 - #if (ARCH == ARCH_AVR8) - return SREG; - #elif (ARCH == ARCH_UC3) - return __builtin_mfsr(AVR32_SR); - #elif (ARCH == ARCH_XMEGA) - return SREG; - 48a8: 5f b7 in r21, 0x3f ; 63 - #if (ARCH == ARCH_AVR8) - cli(); - #elif (ARCH == ARCH_UC3) - __builtin_ssrf(AVR32_SR_GM_OFFSET); - #elif (ARCH == ARCH_XMEGA) - cli(); - 48aa: f8 94 cli - #endif - - GCC_MEMORY_BARRIER(); - 48ac: de 01 movw r26, r28 - 48ae: 13 96 adiw r26, 0x03 ; 3 - uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); - GlobalInterruptDisable(); - - uint8_t SigReadAddress = INTERNAL_SERIAL_START_ADDRESS; - - for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++) - 48b0: 20 e0 ldi r18, 0x00 ; 0 - static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) - { - uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); - GlobalInterruptDisable(); - - uint8_t SigReadAddress = INTERNAL_SERIAL_START_ADDRESS; - 48b2: 38 e0 ldi r19, 0x08 ; 8 - - for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++) - { - uint8_t SerialByte; - - NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc; - 48b4: 42 e0 ldi r20, 0x02 ; 2 - 48b6: 07 c0 rjmp .+14 ; 0x48c6 - SigReadAddress++; - } - - SerialByte &= 0x0F; - - UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ? - 48b8: 90 e0 ldi r25, 0x00 ; 0 - 48ba: c7 96 adiw r24, 0x37 ; 55 - 48bc: 8d 93 st X+, r24 - 48be: 9d 93 st X+, r25 - uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); - GlobalInterruptDisable(); - - uint8_t SigReadAddress = INTERNAL_SERIAL_START_ADDRESS; - - for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++) - 48c0: 2f 5f subi r18, 0xFF ; 255 - 48c2: 2c 31 cpi r18, 0x1C ; 28 - 48c4: 91 f0 breq .+36 ; 0x48ea - { - uint8_t SerialByte; - - NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc; - 48c6: 40 93 ca 01 sts 0x01CA, r20 - SerialByte = pgm_read_byte(SigReadAddress); - 48ca: e3 2f mov r30, r19 - 48cc: f0 e0 ldi r31, 0x00 ; 0 - 48ce: 84 91 lpm r24, Z - NVM.CMD = 0; - 48d0: 10 92 ca 01 sts 0x01CA, r1 - - if (SerialCharNum & 0x01) - 48d4: 20 ff sbrs r18, 0 - 48d6: 03 c0 rjmp .+6 ; 0x48de - { - SerialByte >>= 4; - 48d8: 82 95 swap r24 - 48da: 8f 70 andi r24, 0x0F ; 15 - SigReadAddress++; - 48dc: 3f 5f subi r19, 0xFF ; 255 - } - - SerialByte &= 0x0F; - 48de: 8f 70 andi r24, 0x0F ; 15 - - UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ? - 48e0: 8a 30 cpi r24, 0x0A ; 10 - 48e2: 50 f7 brcc .-44 ; 0x48b8 - 48e4: 90 e0 ldi r25, 0x00 ; 0 - 48e6: c0 96 adiw r24, 0x30 ; 48 - 48e8: e9 cf rjmp .-46 ; 0x48bc - if (GlobalIntState & AVR32_SR_GM) - __builtin_ssrf(AVR32_SR_GM_OFFSET); - else - __builtin_csrf(AVR32_SR_GM_OFFSET); - #elif (ARCH == ARCH_XMEGA) - SREG = GlobalIntState; - 48ea: 5f bf out 0x3f, r21 ; 63 - - USB_Device_GetSerialString(SignatureDescriptor.UnicodeString); - - Endpoint_ClearSETUP(); - 48ec: 8d d2 rcall .+1306 ; 0x4e08 - - Endpoint_Write_Control_Stream_LE(&SignatureDescriptor, sizeof(SignatureDescriptor)); - 48ee: 6a e3 ldi r22, 0x3A ; 58 - 48f0: 70 e0 ldi r23, 0x00 ; 0 - 48f2: ce 01 movw r24, r28 - 48f4: 01 96 adiw r24, 0x01 ; 1 - 48f6: 88 d0 rcall .+272 ; 0x4a08 - Endpoint_ClearOUT(); - 48f8: e1 d1 rcall .+962 ; 0x4cbc - 48fa: 0d cf rjmp .-486 ; 0x4716 - } - - static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; - static inline bool USB_Device_IsAddressSet(void) - { - return ((USB.ADDR != 0) ? true : false); - 48fc: 80 91 c3 04 lds r24, 0x04C3 - Endpoint_ClearStatusStage(); - - if (USB_Device_ConfigurationNumber) - USB_DeviceState = DEVICE_STATE_Configured; - else - USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered; - 4900: 88 23 and r24, r24 - 4902: 21 f0 breq .+8 ; 0x490c - 4904: 84 e0 ldi r24, 0x04 ; 4 - 4906: 80 93 40 2b sts 0x2B40, r24 - 490a: 2a cf rjmp .-428 ; 0x4760 - 490c: 81 e0 ldi r24, 0x01 ; 1 - 490e: fb cf rjmp .-10 ; 0x4906 - - if (Endpoint_IsEnabled()) - { - if (USB_ControlRequest.bRequest == REQ_SetFeature) - { - Endpoint_StallTransaction(); - 4910: a7 d2 rcall .+1358 ; 0x4e60 - 4912: 90 cf rjmp .-224 ; 0x4834 - -00004914 : -#define __INCLUDE_FROM_EVENTS_C -#define __INCLUDE_FROM_USB_DRIVER -#include "Events.h" - -void USB_Event_Stub(void) -{ - 4914: 08 95 ret - -00004916 : -#if defined(USB_CAN_BE_DEVICE) && !defined(DEVICE_STATE_AS_GPIOR) -volatile uint8_t USB_DeviceState; -#endif - -void USB_USBTask(void) -{ - 4916: cf 93 push r28 -} - -#if defined(USB_CAN_BE_DEVICE) -static void USB_DeviceTask(void) -{ - if (USB_DeviceState == DEVICE_STATE_Unattached) - 4918: 80 91 40 2b lds r24, 0x2B40 - 491c: 81 11 cpse r24, r1 - 491e: 02 c0 rjmp .+4 ; 0x4924 - #elif defined(USB_CAN_BE_HOST) - USB_HostTask(); - #elif defined(USB_CAN_BE_DEVICE) - USB_DeviceTask(); - #endif -} - 4920: cf 91 pop r28 - 4922: 08 95 ret - * \return Index of the currently selected endpoint. - */ - static inline uint8_t Endpoint_GetCurrentEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t Endpoint_GetCurrentEndpoint(void) - { - return USB_Endpoint_SelectedEndpoint; - 4924: c0 91 4d 2b lds r28, 0x2B4D - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - - uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint(); - - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - 4928: 80 e0 ldi r24, 0x00 ; 0 - 492a: f7 d1 rcall .+1006 ; 0x4d1a - - if (Endpoint_IsSETUPReceived()) - 492c: 54 d2 rcall .+1192 ; 0x4dd6 - 492e: 81 11 cpse r24, r1 - 4930: 03 c0 rjmp .+6 ; 0x4938 - USB_Device_ProcessControlRequest(); - - Endpoint_SelectEndpoint(PrevEndpoint); - 4932: 8c 2f mov r24, r28 - #elif defined(USB_CAN_BE_HOST) - USB_HostTask(); - #elif defined(USB_CAN_BE_DEVICE) - USB_DeviceTask(); - #endif -} - 4934: cf 91 pop r28 - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - - if (Endpoint_IsSETUPReceived()) - USB_Device_ProcessControlRequest(); - - Endpoint_SelectEndpoint(PrevEndpoint); - 4936: f1 c1 rjmp .+994 ; 0x4d1a - uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint(); - - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - - if (Endpoint_IsSETUPReceived()) - USB_Device_ProcessControlRequest(); - 4938: cd de rcall .-614 ; 0x46d4 - - Endpoint_SelectEndpoint(PrevEndpoint); - 493a: 8c 2f mov r24, r28 - #elif defined(USB_CAN_BE_HOST) - USB_HostTask(); - #elif defined(USB_CAN_BE_DEVICE) - USB_DeviceTask(); - #endif -} - 493c: cf 91 pop r28 - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - - if (Endpoint_IsSETUPReceived()) - USB_Device_ProcessControlRequest(); - - Endpoint_SelectEndpoint(PrevEndpoint); - 493e: ed c1 rjmp .+986 ; 0x4d1a - -00004940 : - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - return ENDPOINT_RWCSTREAM_BusSuspended; - } - - return ENDPOINT_RWCSTREAM_NoError; -} - 4940: cf 92 push r12 - 4942: df 92 push r13 - 4944: ef 92 push r14 - 4946: ff 92 push r15 - 4948: 0f 93 push r16 - 494a: 1f 93 push r17 - 494c: cf 93 push r28 - 494e: df 93 push r29 - 4950: 8c 01 movw r16, r24 - 4952: eb 01 movw r28, r22 - 4954: 7a 01 movw r14, r20 - 4956: a5 d3 rcall .+1866 ; 0x50a2 - 4958: 81 11 cpse r24, r1 - 495a: 25 c0 rjmp .+74 ; 0x49a6 - 495c: e1 14 cp r14, r1 - 495e: f1 04 cpc r15, r1 - 4960: 81 f1 breq .+96 ; 0x49c2 - 4962: f7 01 movw r30, r14 - 4964: 80 81 ld r24, Z - 4966: 91 81 ldd r25, Z+1 ; 0x01 - 4968: c8 1b sub r28, r24 - 496a: d9 0b sbc r29, r25 - 496c: 08 0f add r16, r24 - 496e: 19 1f adc r17, r25 - 4970: 20 97 sbiw r28, 0x00 ; 0 - 4972: 09 f4 brne .+2 ; 0x4976 - 4974: 3b c0 rjmp .+118 ; 0x49ec - 4976: c1 2c mov r12, r1 - 4978: d1 2c mov r13, r1 - 497a: 20 91 49 2b lds r18, 0x2B49 - 497e: 30 91 4a 2b lds r19, 0x2B4A - 4982: f9 01 movw r30, r18 - 4984: ef 5b subi r30, 0xBF ; 191 - 4986: ff 4f sbci r31, 0xFF ; 255 - 4988: 90 81 ld r25, Z - 498a: 31 97 sbiw r30, 0x01 ; 1 - 498c: 80 81 ld r24, Z - 498e: 98 17 cp r25, r24 - 4990: 78 f1 brcs .+94 ; 0x49f0 - 4992: 7b d1 rcall .+758 ; 0x4c8a - 4994: c0 df rcall .-128 ; 0x4916 - 4996: f7 01 movw r30, r14 - 4998: 80 81 ld r24, Z - 499a: 91 81 ldd r25, Z+1 ; 0x01 - 499c: 8c 0d add r24, r12 - 499e: 9d 1d adc r25, r13 - 49a0: 80 83 st Z, r24 - 49a2: 91 83 std Z+1, r25 ; 0x01 - 49a4: 85 e0 ldi r24, 0x05 ; 5 - 49a6: df 91 pop r29 - 49a8: cf 91 pop r28 - 49aa: 1f 91 pop r17 - 49ac: 0f 91 pop r16 - 49ae: ff 90 pop r15 - 49b0: ef 90 pop r14 - 49b2: df 90 pop r13 - 49b4: cf 90 pop r12 - 49b6: 08 95 ret - 49b8: 68 d1 rcall .+720 ; 0x4c8a - 49ba: ad df rcall .-166 ; 0x4916 - 49bc: 72 d3 rcall .+1764 ; 0x50a2 - 49be: 81 11 cpse r24, r1 - 49c0: f2 cf rjmp .-28 ; 0x49a6 - 49c2: 20 97 sbiw r28, 0x00 ; 0 - 49c4: 99 f0 breq .+38 ; 0x49ec - 49c6: 20 91 49 2b lds r18, 0x2B49 - 49ca: 30 91 4a 2b lds r19, 0x2B4A - 49ce: f9 01 movw r30, r18 - 49d0: ef 5b subi r30, 0xBF ; 191 - 49d2: ff 4f sbci r31, 0xFF ; 255 - 49d4: 90 81 ld r25, Z - 49d6: 31 97 sbiw r30, 0x01 ; 1 - 49d8: 80 81 ld r24, Z - 49da: 98 17 cp r25, r24 - 49dc: 68 f7 brcc .-38 ; 0x49b8 - 49de: f8 01 movw r30, r16 - 49e0: 81 91 ld r24, Z+ - 49e2: 8f 01 movw r16, r30 - 49e4: 8a d1 rcall .+788 ; 0x4cfa - 49e6: 21 97 sbiw r28, 0x01 ; 1 - 49e8: 20 97 sbiw r28, 0x00 ; 0 - 49ea: 69 f7 brne .-38 ; 0x49c6 - 49ec: 80 e0 ldi r24, 0x00 ; 0 - 49ee: db cf rjmp .-74 ; 0x49a6 - 49f0: f8 01 movw r30, r16 - 49f2: 81 91 ld r24, Z+ - 49f4: 8f 01 movw r16, r30 - 49f6: 81 d1 rcall .+770 ; 0x4cfa - 49f8: ff ef ldi r31, 0xFF ; 255 - 49fa: cf 1a sub r12, r31 - 49fc: df 0a sbc r13, r31 - 49fe: cc 15 cp r28, r12 - 4a00: dd 05 cpc r29, r13 - 4a02: 09 f0 breq .+2 ; 0x4a06 - 4a04: ba cf rjmp .-140 ; 0x497a - 4a06: f2 cf rjmp .-28 ; 0x49ec - -00004a08 : - 4a08: cf 92 push r12 - 4a0a: df 92 push r13 - 4a0c: ef 92 push r14 - 4a0e: ff 92 push r15 - 4a10: 0f 93 push r16 - 4a12: 1f 93 push r17 - 4a14: cf 93 push r28 - 4a16: df 93 push r29 - 4a18: 6c 01 movw r12, r24 - 4a1a: 8b 01 movw r16, r22 - 4a1c: 80 91 4d 2b lds r24, 0x2B4D - 4a20: 80 68 ori r24, 0x80 ; 128 - 4a22: 7b d1 rcall .+758 ; 0x4d1a - 4a24: c0 91 47 2b lds r28, 0x2B47 - 4a28: d0 91 48 2b lds r29, 0x2B48 - 4a2c: c0 17 cp r28, r16 - 4a2e: d1 07 cpc r29, r17 - 4a30: 28 f0 brcs .+10 ; 0x4a3c - 4a32: 01 15 cp r16, r1 - 4a34: 11 05 cpc r17, r1 - 4a36: 09 f4 brne .+2 ; 0x4a3a - 4a38: 6f c0 rjmp .+222 ; 0x4b18 - 4a3a: e8 01 movw r28, r16 - 4a3c: 10 e0 ldi r17, 0x00 ; 0 - 4a3e: 20 97 sbiw r28, 0x00 ; 0 - 4a40: 39 f5 brne .+78 ; 0x4a90 - 4a42: 11 11 cpse r17, r1 - 4a44: 0c c0 rjmp .+24 ; 0x4a5e - 4a46: 2f c0 rjmp .+94 ; 0x4aa6 - 4a48: 85 30 cpi r24, 0x05 ; 5 - 4a4a: 91 f1 breq .+100 ; 0x4ab0 - 4a4c: c4 d1 rcall .+904 ; 0x4dd6 - 4a4e: 81 11 cpse r24, r1 - 4a50: 31 c0 rjmp .+98 ; 0x4ab4 - 4a52: a8 d1 rcall .+848 ; 0x4da4 - 4a54: 81 11 cpse r24, r1 - 4a56: 27 c0 rjmp .+78 ; 0x4aa6 - 4a58: 99 d1 rcall .+818 ; 0x4d8c - 4a5a: 81 11 cpse r24, r1 - 4a5c: 2d c0 rjmp .+90 ; 0x4ab8 - 4a5e: 80 91 40 2b lds r24, 0x2B40 - 4a62: 81 11 cpse r24, r1 - 4a64: f1 cf rjmp .-30 ; 0x4a48 - 4a66: 82 e0 ldi r24, 0x02 ; 2 - 4a68: df 91 pop r29 - 4a6a: cf 91 pop r28 - 4a6c: 1f 91 pop r17 - 4a6e: 0f 91 pop r16 - 4a70: ff 90 pop r15 - 4a72: ef 90 pop r14 - 4a74: df 90 pop r13 - 4a76: cf 90 pop r12 - 4a78: 08 95 ret - 4a7a: 85 30 cpi r24, 0x05 ; 5 - 4a7c: c9 f0 breq .+50 ; 0x4ab0 - 4a7e: ab d1 rcall .+854 ; 0x4dd6 - 4a80: 81 11 cpse r24, r1 - 4a82: 18 c0 rjmp .+48 ; 0x4ab4 - 4a84: 8f d1 rcall .+798 ; 0x4da4 - 4a86: 81 11 cpse r24, r1 - 4a88: 0e c0 rjmp .+28 ; 0x4aa6 - 4a8a: 80 d1 rcall .+768 ; 0x4d8c - 4a8c: 81 11 cpse r24, r1 - 4a8e: 14 c0 rjmp .+40 ; 0x4ab8 - 4a90: 80 91 40 2b lds r24, 0x2B40 - 4a94: 81 11 cpse r24, r1 - 4a96: f1 cf rjmp .-30 ; 0x4a7a - 4a98: e6 cf rjmp .-52 ; 0x4a66 - 4a9a: 80 91 40 2b lds r24, 0x2B40 - 4a9e: 88 23 and r24, r24 - 4aa0: 11 f3 breq .-60 ; 0x4a66 - 4aa2: 85 30 cpi r24, 0x05 ; 5 - 4aa4: 29 f0 breq .+10 ; 0x4ab0 - 4aa6: 7e d1 rcall .+764 ; 0x4da4 - 4aa8: 88 23 and r24, r24 - 4aaa: b9 f3 breq .-18 ; 0x4a9a - 4aac: 80 e0 ldi r24, 0x00 ; 0 - 4aae: dc cf rjmp .-72 ; 0x4a68 - 4ab0: 83 e0 ldi r24, 0x03 ; 3 - 4ab2: da cf rjmp .-76 ; 0x4a68 - 4ab4: 81 e0 ldi r24, 0x01 ; 1 - 4ab6: d8 cf rjmp .-80 ; 0x4a68 - 4ab8: 80 91 4d 2b lds r24, 0x2B4D - 4abc: 87 fd sbrc r24, 7 - 4abe: 30 c0 rjmp .+96 ; 0x4b20 - 4ac0: 20 91 49 2b lds r18, 0x2B49 - 4ac4: 30 91 4a 2b lds r19, 0x2B4A - 4ac8: f9 01 movw r30, r18 - 4aca: e0 5c subi r30, 0xC0 ; 192 - 4acc: ff 4f sbci r31, 0xFF ; 255 - 4ace: e0 80 ld r14, Z - 4ad0: 31 96 adiw r30, 0x01 ; 1 - 4ad2: 80 81 ld r24, Z - 4ad4: f1 2c mov r15, r1 - 4ad6: e8 1a sub r14, r24 - 4ad8: f1 08 sbc r15, r1 - 4ada: 20 97 sbiw r28, 0x00 ; 0 - 4adc: a9 f0 breq .+42 ; 0x4b08 - 4ade: 88 e0 ldi r24, 0x08 ; 8 - 4ae0: e8 16 cp r14, r24 - 4ae2: f1 04 cpc r15, r1 - 4ae4: 88 f4 brcc .+34 ; 0x4b08 - 4ae6: 86 01 movw r16, r12 - 4ae8: 04 c0 rjmp .+8 ; 0x4af2 - 4aea: 88 e0 ldi r24, 0x08 ; 8 - 4aec: e8 16 cp r14, r24 - 4aee: f1 04 cpc r15, r1 - 4af0: 59 f0 breq .+22 ; 0x4b08 - 4af2: f8 01 movw r30, r16 - 4af4: 81 91 ld r24, Z+ - 4af6: 8f 01 movw r16, r30 - 4af8: 00 d1 rcall .+512 ; 0x4cfa - 4afa: 68 01 movw r12, r16 - 4afc: 21 97 sbiw r28, 0x01 ; 1 - 4afe: ff ef ldi r31, 0xFF ; 255 - 4b00: ef 1a sub r14, r31 - 4b02: ff 0a sbc r15, r31 - 4b04: 20 97 sbiw r28, 0x00 ; 0 - 4b06: 89 f7 brne .-30 ; 0x4aea - 4b08: 11 e0 ldi r17, 0x01 ; 1 - 4b0a: e8 e0 ldi r30, 0x08 ; 8 - 4b0c: ee 16 cp r14, r30 - 4b0e: f1 04 cpc r15, r1 - 4b10: 09 f0 breq .+2 ; 0x4b14 - 4b12: 10 e0 ldi r17, 0x00 ; 0 - 4b14: ba d0 rcall .+372 ; 0x4c8a - 4b16: 93 cf rjmp .-218 ; 0x4a3e - 4b18: b8 d0 rcall .+368 ; 0x4c8a - 4b1a: c0 e0 ldi r28, 0x00 ; 0 - 4b1c: d0 e0 ldi r29, 0x00 ; 0 - 4b1e: 8e cf rjmp .-228 ; 0x4a3c - 4b20: e0 91 49 2b lds r30, 0x2B49 - 4b24: f0 91 4a 2b lds r31, 0x2B4A - 4b28: ef 5b subi r30, 0xBF ; 191 - 4b2a: ff 4f sbci r31, 0xFF ; 255 - 4b2c: e0 80 ld r14, Z - 4b2e: f1 2c mov r15, r1 - 4b30: d4 cf rjmp .-88 ; 0x4ada - -00004b32 : - -#if defined(TEMPLATE_FUNC_NAME) - -uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer, - uint16_t Length) -{ - 4b32: df 92 push r13 - 4b34: ef 92 push r14 - 4b36: ff 92 push r15 - 4b38: 0f 93 push r16 - 4b3a: 1f 93 push r17 - 4b3c: cf 93 push r28 - 4b3e: df 93 push r29 - 4b40: f8 2e mov r15, r24 - 4b42: e9 2e mov r14, r25 - 4b44: 8b 01 movw r16, r22 - uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); - bool LastPacketFull = false; - - Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN); - 4b46: 80 91 4d 2b lds r24, 0x2B4D - 4b4a: 80 68 ori r24, 0x80 ; 128 - 4b4c: e6 d0 rcall .+460 ; 0x4d1a - - if (Length > USB_ControlRequest.wLength) - 4b4e: c0 91 47 2b lds r28, 0x2B47 - 4b52: d0 91 48 2b lds r29, 0x2B48 - 4b56: c0 17 cp r28, r16 - 4b58: d1 07 cpc r29, r17 - 4b5a: 28 f0 brcs .+10 ; 0x4b66 - Length = USB_ControlRequest.wLength; - else if (!(Length)) - 4b5c: 01 15 cp r16, r1 - 4b5e: 11 05 cpc r17, r1 - 4b60: 09 f4 brne .+2 ; 0x4b64 - 4b62: 86 c0 rjmp .+268 ; 0x4c70 - 4b64: e8 01 movw r28, r16 - 4b66: 0f 2d mov r16, r15 - 4b68: 1e 2d mov r17, r14 - 4b6a: d1 2c mov r13, r1 - 4b6c: 20 97 sbiw r28, 0x00 ; 0 - 4b6e: 39 f5 brne .+78 ; 0x4bbe - 4b70: d1 10 cpse r13, r1 - 4b72: 0d c0 rjmp .+26 ; 0x4b8e - 4b74: 2f c0 rjmp .+94 ; 0x4bd4 - { - uint8_t USB_DeviceState_LCL = USB_DeviceState; - - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - return ENDPOINT_RWCSTREAM_DeviceDisconnected; - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - 4b76: 85 30 cpi r24, 0x05 ; 5 - 4b78: 09 f4 brne .+2 ; 0x4b7c - 4b7a: 38 c0 rjmp .+112 ; 0x4bec - return ENDPOINT_RWCSTREAM_BusSuspended; - else if (Endpoint_IsSETUPReceived()) - 4b7c: 2c d1 rcall .+600 ; 0x4dd6 - 4b7e: 81 11 cpse r24, r1 - 4b80: 3e c0 rjmp .+124 ; 0x4bfe - return ENDPOINT_RWCSTREAM_HostAborted; - else if (Endpoint_IsOUTReceived()) - 4b82: 10 d1 rcall .+544 ; 0x4da4 - 4b84: 81 11 cpse r24, r1 - 4b86: 26 c0 rjmp .+76 ; 0x4bd4 - break; - - if (Endpoint_IsINReady()) - 4b88: 01 d1 rcall .+514 ; 0x4d8c - 4b8a: 81 11 cpse r24, r1 - 4b8c: 41 c0 rjmp .+130 ; 0x4c10 - else if (!(Length)) - Endpoint_ClearIN(); - - while (Length || LastPacketFull) - { - uint8_t USB_DeviceState_LCL = USB_DeviceState; - 4b8e: 80 91 40 2b lds r24, 0x2B40 - - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - 4b92: 81 11 cpse r24, r1 - 4b94: f0 cf rjmp .-32 ; 0x4b76 - return ENDPOINT_RWCSTREAM_DeviceDisconnected; - 4b96: 82 e0 ldi r24, 0x02 ; 2 - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - return ENDPOINT_RWCSTREAM_BusSuspended; - } - - return ENDPOINT_RWCSTREAM_NoError; -} - 4b98: df 91 pop r29 - 4b9a: cf 91 pop r28 - 4b9c: 1f 91 pop r17 - 4b9e: 0f 91 pop r16 - 4ba0: ff 90 pop r15 - 4ba2: ef 90 pop r14 - 4ba4: df 90 pop r13 - 4ba6: 08 95 ret - { - uint8_t USB_DeviceState_LCL = USB_DeviceState; - - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - return ENDPOINT_RWCSTREAM_DeviceDisconnected; - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - 4ba8: 85 30 cpi r24, 0x05 ; 5 - 4baa: 01 f1 breq .+64 ; 0x4bec - return ENDPOINT_RWCSTREAM_BusSuspended; - else if (Endpoint_IsSETUPReceived()) - 4bac: 14 d1 rcall .+552 ; 0x4dd6 - 4bae: 81 11 cpse r24, r1 - 4bb0: 26 c0 rjmp .+76 ; 0x4bfe - return ENDPOINT_RWCSTREAM_HostAborted; - else if (Endpoint_IsOUTReceived()) - 4bb2: f8 d0 rcall .+496 ; 0x4da4 - 4bb4: 81 11 cpse r24, r1 - 4bb6: 0e c0 rjmp .+28 ; 0x4bd4 - break; - - if (Endpoint_IsINReady()) - 4bb8: e9 d0 rcall .+466 ; 0x4d8c - 4bba: 81 11 cpse r24, r1 - 4bbc: 29 c0 rjmp .+82 ; 0x4c10 - else if (!(Length)) - Endpoint_ClearIN(); - - while (Length || LastPacketFull) - { - uint8_t USB_DeviceState_LCL = USB_DeviceState; - 4bbe: 80 91 40 2b lds r24, 0x2B40 - - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - 4bc2: 81 11 cpse r24, r1 - 4bc4: f1 cf rjmp .-30 ; 0x4ba8 - 4bc6: e7 cf rjmp .-50 ; 0x4b96 - } - } - - while (!(Endpoint_IsOUTReceived())) - { - uint8_t USB_DeviceState_LCL = USB_DeviceState; - 4bc8: 80 91 40 2b lds r24, 0x2B40 - - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - 4bcc: 88 23 and r24, r24 - 4bce: 19 f3 breq .-58 ; 0x4b96 - return ENDPOINT_RWCSTREAM_DeviceDisconnected; - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - 4bd0: 85 30 cpi r24, 0x05 ; 5 - 4bd2: 61 f0 breq .+24 ; 0x4bec - LastPacketFull = (BytesInEndpoint == USB_Device_ControlEndpointSize); - Endpoint_ClearIN(); - } - } - - while (!(Endpoint_IsOUTReceived())) - 4bd4: e7 d0 rcall .+462 ; 0x4da4 - 4bd6: 88 23 and r24, r24 - 4bd8: b9 f3 breq .-18 ; 0x4bc8 - return ENDPOINT_RWCSTREAM_DeviceDisconnected; - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - return ENDPOINT_RWCSTREAM_BusSuspended; - } - - return ENDPOINT_RWCSTREAM_NoError; - 4bda: 80 e0 ldi r24, 0x00 ; 0 -} - 4bdc: df 91 pop r29 - 4bde: cf 91 pop r28 - 4be0: 1f 91 pop r17 - 4be2: 0f 91 pop r16 - 4be4: ff 90 pop r15 - 4be6: ef 90 pop r14 - 4be8: df 90 pop r13 - 4bea: 08 95 ret - uint8_t USB_DeviceState_LCL = USB_DeviceState; - - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - return ENDPOINT_RWCSTREAM_DeviceDisconnected; - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - return ENDPOINT_RWCSTREAM_BusSuspended; - 4bec: 83 e0 ldi r24, 0x03 ; 3 - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - return ENDPOINT_RWCSTREAM_BusSuspended; - } - - return ENDPOINT_RWCSTREAM_NoError; -} - 4bee: df 91 pop r29 - 4bf0: cf 91 pop r28 - 4bf2: 1f 91 pop r17 - 4bf4: 0f 91 pop r16 - 4bf6: ff 90 pop r15 - 4bf8: ef 90 pop r14 - 4bfa: df 90 pop r13 - 4bfc: 08 95 ret - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - return ENDPOINT_RWCSTREAM_DeviceDisconnected; - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - return ENDPOINT_RWCSTREAM_BusSuspended; - else if (Endpoint_IsSETUPReceived()) - return ENDPOINT_RWCSTREAM_HostAborted; - 4bfe: 81 e0 ldi r24, 0x01 ; 1 - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - return ENDPOINT_RWCSTREAM_BusSuspended; - } - - return ENDPOINT_RWCSTREAM_NoError; -} - 4c00: df 91 pop r29 - 4c02: cf 91 pop r28 - 4c04: 1f 91 pop r17 - 4c06: 0f 91 pop r16 - 4c08: ff 90 pop r15 - 4c0a: ef 90 pop r14 - 4c0c: df 90 pop r13 - 4c0e: 08 95 ret - * \return Total number of bytes in the currently selected Endpoint's FIFO buffer. - */ - static inline uint16_t Endpoint_BytesInEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint16_t Endpoint_BytesInEndpoint(void) - { - if (USB_Endpoint_SelectedEndpoint & ENDPOINT_DIR_IN) - 4c10: 80 91 4d 2b lds r24, 0x2B4D - 4c14: 87 fd sbrc r24, 7 - 4c16: 30 c0 rjmp .+96 ; 0x4c78 - return USB_Endpoint_SelectedFIFO->Position; - else - return (USB_Endpoint_SelectedFIFO->Length - USB_Endpoint_SelectedFIFO->Position); - 4c18: 80 91 49 2b lds r24, 0x2B49 - 4c1c: 90 91 4a 2b lds r25, 0x2B4A - 4c20: fc 01 movw r30, r24 - 4c22: e0 5c subi r30, 0xC0 ; 192 - 4c24: ff 4f sbci r31, 0xFF ; 255 - 4c26: e0 80 ld r14, Z - 4c28: 31 96 adiw r30, 0x01 ; 1 - 4c2a: 80 81 ld r24, Z - 4c2c: f1 2c mov r15, r1 - 4c2e: e8 1a sub r14, r24 - 4c30: f1 08 sbc r15, r1 - - if (Endpoint_IsINReady()) - { - uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint(); - - while (Length && (BytesInEndpoint < USB_Device_ControlEndpointSize)) - 4c32: 20 97 sbiw r28, 0x00 ; 0 - 4c34: a1 f0 breq .+40 ; 0x4c5e - 4c36: 88 e0 ldi r24, 0x08 ; 8 - 4c38: e8 16 cp r14, r24 - 4c3a: f1 04 cpc r15, r1 - 4c3c: 28 f0 brcs .+10 ; 0x4c48 - 4c3e: 0f c0 rjmp .+30 ; 0x4c5e - 4c40: 88 e0 ldi r24, 0x08 ; 8 - 4c42: e8 16 cp r14, r24 - 4c44: f1 04 cpc r15, r1 - 4c46: 59 f0 breq .+22 ; 0x4c5e - { - TEMPLATE_TRANSFER_BYTE(DataStream); - 4c48: f8 01 movw r30, r16 - 4c4a: 84 91 lpm r24, Z - 4c4c: 56 d0 rcall .+172 ; 0x4cfa - TEMPLATE_BUFFER_MOVE(DataStream, 1); - 4c4e: 0f 5f subi r16, 0xFF ; 255 - 4c50: 1f 4f sbci r17, 0xFF ; 255 - Length--; - 4c52: 21 97 sbiw r28, 0x01 ; 1 - BytesInEndpoint++; - 4c54: ff ef ldi r31, 0xFF ; 255 - 4c56: ef 1a sub r14, r31 - 4c58: ff 0a sbc r15, r31 - - if (Endpoint_IsINReady()) - { - uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint(); - - while (Length && (BytesInEndpoint < USB_Device_ControlEndpointSize)) - 4c5a: 20 97 sbiw r28, 0x00 ; 0 - 4c5c: 89 f7 brne .-30 ; 0x4c40 - TEMPLATE_BUFFER_MOVE(DataStream, 1); - Length--; - BytesInEndpoint++; - } - - LastPacketFull = (BytesInEndpoint == USB_Device_ControlEndpointSize); - 4c5e: dd 24 eor r13, r13 - 4c60: d3 94 inc r13 - 4c62: e8 e0 ldi r30, 0x08 ; 8 - 4c64: ee 16 cp r14, r30 - 4c66: f1 04 cpc r15, r1 - 4c68: 09 f0 breq .+2 ; 0x4c6c - 4c6a: d1 2c mov r13, r1 - Endpoint_ClearIN(); - 4c6c: 0e d0 rcall .+28 ; 0x4c8a - 4c6e: 7e cf rjmp .-260 ; 0x4b6c - Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN); - - if (Length > USB_ControlRequest.wLength) - Length = USB_ControlRequest.wLength; - else if (!(Length)) - Endpoint_ClearIN(); - 4c70: 0c d0 rcall .+24 ; 0x4c8a - 4c72: c0 e0 ldi r28, 0x00 ; 0 - 4c74: d0 e0 ldi r29, 0x00 ; 0 - 4c76: 77 cf rjmp .-274 ; 0x4b66 - */ - static inline uint16_t Endpoint_BytesInEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint16_t Endpoint_BytesInEndpoint(void) - { - if (USB_Endpoint_SelectedEndpoint & ENDPOINT_DIR_IN) - return USB_Endpoint_SelectedFIFO->Position; - 4c78: e0 91 49 2b lds r30, 0x2B49 - 4c7c: f0 91 4a 2b lds r31, 0x2B4A - 4c80: ef 5b subi r30, 0xBF ; 191 - 4c82: ff 4f sbci r31, 0xFF ; 255 - 4c84: e0 80 ld r14, Z - 4c86: f1 2c mov r15, r1 - 4c88: d4 cf rjmp .-88 ; 0x4c32 - -00004c8a : - USB_Endpoint_SelectedFIFO->Position = 0; -} - -void Endpoint_ClearIN(void) -{ - USB_Endpoint_SelectedHandle->CNT = USB_Endpoint_SelectedFIFO->Position; - 4c8a: e0 91 4b 2b lds r30, 0x2B4B - 4c8e: f0 91 4c 2b lds r31, 0x2B4C - 4c92: a0 91 49 2b lds r26, 0x2B49 - 4c96: b0 91 4a 2b lds r27, 0x2B4A - 4c9a: af 5b subi r26, 0xBF ; 191 - 4c9c: bf 4f sbci r27, 0xFF ; 255 - 4c9e: 8c 91 ld r24, X - 4ca0: 90 e0 ldi r25, 0x00 ; 0 - 4ca2: 82 83 std Z+2, r24 ; 0x02 - 4ca4: 93 83 std Z+3, r25 ; 0x03 - USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm); - 4ca6: 80 81 ld r24, Z - 4ca8: 8d 79 andi r24, 0x9D ; 157 - 4caa: 80 83 st Z, r24 - USB_Endpoint_SelectedFIFO->Position = 0; - 4cac: e0 91 49 2b lds r30, 0x2B49 - 4cb0: f0 91 4a 2b lds r31, 0x2B4A - 4cb4: ef 5b subi r30, 0xBF ; 191 - 4cb6: ff 4f sbci r31, 0xFF ; 255 - 4cb8: 10 82 st Z, r1 - 4cba: 08 95 ret - -00004cbc : -} - -void Endpoint_ClearOUT(void) -{ - USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm); - 4cbc: e0 91 4b 2b lds r30, 0x2B4B - 4cc0: f0 91 4c 2b lds r31, 0x2B4C - 4cc4: 80 81 ld r24, Z - 4cc6: 8d 79 andi r24, 0x9D ; 157 - 4cc8: 80 83 st Z, r24 - USB_Endpoint_SelectedFIFO->Position = 0; - 4cca: e0 91 49 2b lds r30, 0x2B49 - 4cce: f0 91 4a 2b lds r31, 0x2B4A - 4cd2: ef 5b subi r30, 0xBF ; 191 - 4cd4: ff 4f sbci r31, 0xFF ; 255 - 4cd6: 10 82 st Z, r1 - 4cd8: 08 95 ret - -00004cda : - } -} - -uint8_t Endpoint_Read_8(void) -{ - return USB_Endpoint_SelectedFIFO->Data[USB_Endpoint_SelectedFIFO->Position++]; - 4cda: 80 91 49 2b lds r24, 0x2B49 - 4cde: 90 91 4a 2b lds r25, 0x2B4A - 4ce2: fc 01 movw r30, r24 - 4ce4: ef 5b subi r30, 0xBF ; 191 - 4ce6: ff 4f sbci r31, 0xFF ; 255 - 4ce8: 20 81 ld r18, Z - 4cea: 31 e0 ldi r19, 0x01 ; 1 - 4cec: 32 0f add r19, r18 - 4cee: 30 83 st Z, r19 - 4cf0: fc 01 movw r30, r24 - 4cf2: e2 0f add r30, r18 - 4cf4: f1 1d adc r31, r1 - 4cf6: 80 81 ld r24, Z -} - 4cf8: 08 95 ret - -00004cfa : - -void Endpoint_Write_8(const uint8_t Data) -{ - USB_Endpoint_SelectedFIFO->Data[USB_Endpoint_SelectedFIFO->Position++] = Data; - 4cfa: 20 91 49 2b lds r18, 0x2B49 - 4cfe: 30 91 4a 2b lds r19, 0x2B4A - 4d02: f9 01 movw r30, r18 - 4d04: ef 5b subi r30, 0xBF ; 191 - 4d06: ff 4f sbci r31, 0xFF ; 255 - 4d08: 90 81 ld r25, Z - 4d0a: 41 e0 ldi r20, 0x01 ; 1 - 4d0c: 49 0f add r20, r25 - 4d0e: 40 83 st Z, r20 - 4d10: f9 01 movw r30, r18 - 4d12: e9 0f add r30, r25 - 4d14: f1 1d adc r31, r1 - 4d16: 80 83 st Z, r24 - 4d18: 08 95 ret - -00004d1a : - -void Endpoint_SelectEndpoint(const uint8_t Address) -{ - uint8_t EndpointNumber = (Address & ENDPOINT_EPNUM_MASK); - - USB_Endpoint_SelectedEndpoint = Address; - 4d1a: 80 93 4d 2b sts 0x2B4D, r24 - USB_Endpoint_SelectedFIFO->Data[USB_Endpoint_SelectedFIFO->Position++] = Data; -} - -void Endpoint_SelectEndpoint(const uint8_t Address) -{ - uint8_t EndpointNumber = (Address & ENDPOINT_EPNUM_MASK); - 4d1e: 28 2f mov r18, r24 - 4d20: 2f 70 andi r18, 0x0F ; 15 - - USB_Endpoint_SelectedEndpoint = Address; - - Endpoint_FIFOPair_t* EndpointFIFOPair = &USB_Endpoint_FIFOs[EndpointNumber]; - 4d22: 62 2f mov r22, r18 - 4d24: 70 e0 ldi r23, 0x00 ; 0 - 4d26: 94 e8 ldi r25, 0x84 ; 132 - 4d28: 29 9f mul r18, r25 - 4d2a: 90 01 movw r18, r0 - 4d2c: 11 24 eor r1, r1 - 4d2e: 22 5b subi r18, 0xB2 ; 178 - 4d30: 34 4d sbci r19, 0xD4 ; 212 - USB_EndpointTable_t* EndpointTable = (USB_EndpointTable_t*)USB.EPPTR; - 4d32: 40 91 c6 04 lds r20, 0x04C6 - 4d36: 50 91 c7 04 lds r21, 0x04C7 - - if (Address & ENDPOINT_DIR_IN) - 4d3a: 87 fd sbrc r24, 7 - 4d3c: 12 c0 rjmp .+36 ; 0x4d62 - USB_Endpoint_SelectedFIFO = &EndpointFIFOPair->IN; - USB_Endpoint_SelectedHandle = &EndpointTable->Endpoints[EndpointNumber].IN; - } - else - { - USB_Endpoint_SelectedFIFO = &EndpointFIFOPair->OUT; - 4d3e: 20 93 49 2b sts 0x2B49, r18 - 4d42: 30 93 4a 2b sts 0x2B4A, r19 - USB_Endpoint_SelectedHandle = &EndpointTable->Endpoints[EndpointNumber].OUT; - 4d46: cb 01 movw r24, r22 - 4d48: 82 95 swap r24 - 4d4a: 92 95 swap r25 - 4d4c: 90 7f andi r25, 0xF0 ; 240 - 4d4e: 98 27 eor r25, r24 - 4d50: 80 7f andi r24, 0xF0 ; 240 - 4d52: 98 27 eor r25, r24 - 4d54: 84 0f add r24, r20 - 4d56: 95 1f adc r25, r21 - 4d58: 80 93 4b 2b sts 0x2B4B, r24 - 4d5c: 90 93 4c 2b sts 0x2B4C, r25 - 4d60: 08 95 ret - Endpoint_FIFOPair_t* EndpointFIFOPair = &USB_Endpoint_FIFOs[EndpointNumber]; - USB_EndpointTable_t* EndpointTable = (USB_EndpointTable_t*)USB.EPPTR; - - if (Address & ENDPOINT_DIR_IN) - { - USB_Endpoint_SelectedFIFO = &EndpointFIFOPair->IN; - 4d62: 2e 5b subi r18, 0xBE ; 190 - 4d64: 3f 4f sbci r19, 0xFF ; 255 - 4d66: 20 93 49 2b sts 0x2B49, r18 - 4d6a: 30 93 4a 2b sts 0x2B4A, r19 - USB_Endpoint_SelectedHandle = &EndpointTable->Endpoints[EndpointNumber].IN; - 4d6e: 62 95 swap r22 - 4d70: 72 95 swap r23 - 4d72: 70 7f andi r23, 0xF0 ; 240 - 4d74: 76 27 eor r23, r22 - 4d76: 60 7f andi r22, 0xF0 ; 240 - 4d78: 76 27 eor r23, r22 - 4d7a: 68 5f subi r22, 0xF8 ; 248 - 4d7c: 7f 4f sbci r23, 0xFF ; 255 - 4d7e: 64 0f add r22, r20 - 4d80: 75 1f adc r23, r21 - 4d82: 60 93 4b 2b sts 0x2B4B, r22 - 4d86: 70 93 4c 2b sts 0x2B4C, r23 - 4d8a: 08 95 ret - -00004d8c : -volatile USB_EP_t* USB_Endpoint_SelectedHandle; -volatile Endpoint_FIFO_t* USB_Endpoint_SelectedFIFO; - -bool Endpoint_IsINReady(void) -{ - Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN); - 4d8c: 80 91 4d 2b lds r24, 0x2B4D - 4d90: 80 68 ori r24, 0x80 ; 128 - 4d92: c3 df rcall .-122 ; 0x4d1a - - return ((USB_Endpoint_SelectedHandle->STATUS & USB_EP_BUSNACK0_bm) ? true : false); - 4d94: e0 91 4b 2b lds r30, 0x2B4B - 4d98: f0 91 4c 2b lds r31, 0x2B4C - 4d9c: 80 81 ld r24, Z -} - 4d9e: 86 95 lsr r24 - 4da0: 81 70 andi r24, 0x01 ; 1 - 4da2: 08 95 ret - -00004da4 : - -bool Endpoint_IsOUTReceived(void) -{ - Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN); - 4da4: 80 91 4d 2b lds r24, 0x2B4D - 4da8: 8f 77 andi r24, 0x7F ; 127 - 4daa: b7 df rcall .-146 ; 0x4d1a - - if (USB_Endpoint_SelectedHandle->STATUS & USB_EP_TRNCOMPL0_bm) - 4dac: e0 91 4b 2b lds r30, 0x2B4B - 4db0: f0 91 4c 2b lds r31, 0x2B4C - 4db4: 80 81 ld r24, Z - 4db6: 85 ff sbrs r24, 5 - 4db8: 0c c0 rjmp .+24 ; 0x4dd2 - { - USB_Endpoint_SelectedFIFO->Length = USB_Endpoint_SelectedHandle->CNT; - 4dba: 20 91 49 2b lds r18, 0x2B49 - 4dbe: 30 91 4a 2b lds r19, 0x2B4A - 4dc2: 82 81 ldd r24, Z+2 ; 0x02 - 4dc4: 93 81 ldd r25, Z+3 ; 0x03 - 4dc6: f9 01 movw r30, r18 - 4dc8: e0 5c subi r30, 0xC0 ; 192 - 4dca: ff 4f sbci r31, 0xFF ; 255 - 4dcc: 80 83 st Z, r24 - return true; - 4dce: 81 e0 ldi r24, 0x01 ; 1 - 4dd0: 08 95 ret - } - - return false; - 4dd2: 80 e0 ldi r24, 0x00 ; 0 -} - 4dd4: 08 95 ret - -00004dd6 : - -bool Endpoint_IsSETUPReceived(void) -{ - Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN); - 4dd6: 80 91 4d 2b lds r24, 0x2B4D - 4dda: 8f 77 andi r24, 0x7F ; 127 - 4ddc: 9e df rcall .-196 ; 0x4d1a - - if (USB_Endpoint_SelectedHandle->STATUS & USB_EP_SETUP_bm) - 4dde: e0 91 4b 2b lds r30, 0x2B4B - 4de2: f0 91 4c 2b lds r31, 0x2B4C - 4de6: 80 81 ld r24, Z - 4de8: 84 ff sbrs r24, 4 - 4dea: 0c c0 rjmp .+24 ; 0x4e04 - { - USB_Endpoint_SelectedFIFO->Length = USB_Endpoint_SelectedHandle->CNT; - 4dec: 20 91 49 2b lds r18, 0x2B49 - 4df0: 30 91 4a 2b lds r19, 0x2B4A - 4df4: 82 81 ldd r24, Z+2 ; 0x02 - 4df6: 93 81 ldd r25, Z+3 ; 0x03 - 4df8: f9 01 movw r30, r18 - 4dfa: e0 5c subi r30, 0xC0 ; 192 - 4dfc: ff 4f sbci r31, 0xFF ; 255 - 4dfe: 80 83 st Z, r24 - return true; - 4e00: 81 e0 ldi r24, 0x01 ; 1 - 4e02: 08 95 ret - } - - return false; - 4e04: 80 e0 ldi r24, 0x00 ; 0 -} - 4e06: 08 95 ret - -00004e08 : - -void Endpoint_ClearSETUP(void) -{ - Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN); - 4e08: 80 91 4d 2b lds r24, 0x2B4D - 4e0c: 8f 77 andi r24, 0x7F ; 127 - 4e0e: 85 df rcall .-246 ; 0x4d1a - USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_SETUP_bm | USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm); - 4e10: e0 91 4b 2b lds r30, 0x2B4B - 4e14: f0 91 4c 2b lds r31, 0x2B4C - 4e18: 80 81 ld r24, Z - 4e1a: 8d 78 andi r24, 0x8D ; 141 - 4e1c: 80 83 st Z, r24 - USB_Endpoint_SelectedHandle->STATUS |= USB_EP_TOGGLE_bm; - 4e1e: e0 91 4b 2b lds r30, 0x2B4B - 4e22: f0 91 4c 2b lds r31, 0x2B4C - 4e26: 80 81 ld r24, Z - 4e28: 81 60 ori r24, 0x01 ; 1 - 4e2a: 80 83 st Z, r24 - USB_Endpoint_SelectedFIFO->Position = 0; - 4e2c: e0 91 49 2b lds r30, 0x2B49 - 4e30: f0 91 4a 2b lds r31, 0x2B4A - 4e34: ef 5b subi r30, 0xBF ; 191 - 4e36: ff 4f sbci r31, 0xFF ; 255 - 4e38: 10 82 st Z, r1 - - Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN); - 4e3a: 80 91 4d 2b lds r24, 0x2B4D - 4e3e: 80 68 ori r24, 0x80 ; 128 - 4e40: 6c df rcall .-296 ; 0x4d1a - USB_Endpoint_SelectedHandle->STATUS |= USB_EP_TOGGLE_bm; - 4e42: e0 91 4b 2b lds r30, 0x2B4B - 4e46: f0 91 4c 2b lds r31, 0x2B4C - 4e4a: 80 81 ld r24, Z - 4e4c: 81 60 ori r24, 0x01 ; 1 - 4e4e: 80 83 st Z, r24 - USB_Endpoint_SelectedFIFO->Position = 0; - 4e50: e0 91 49 2b lds r30, 0x2B49 - 4e54: f0 91 4a 2b lds r31, 0x2B4A - 4e58: ef 5b subi r30, 0xBF ; 191 - 4e5a: ff 4f sbci r31, 0xFF ; 255 - 4e5c: 10 82 st Z, r1 - 4e5e: 08 95 ret - -00004e60 : - USB_Endpoint_SelectedFIFO->Position = 0; -} - -void Endpoint_StallTransaction(void) -{ - USB_Endpoint_SelectedHandle->CTRL |= USB_EP_STALL_bm; - 4e60: e0 91 4b 2b lds r30, 0x2B4B - 4e64: f0 91 4c 2b lds r31, 0x2B4C - 4e68: 81 81 ldd r24, Z+1 ; 0x01 - 4e6a: 84 60 ori r24, 0x04 ; 4 - 4e6c: 81 83 std Z+1, r24 ; 0x01 - - if ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_TYPE_gm) == USB_EP_TYPE_CONTROL_gc) - 4e6e: e0 91 4b 2b lds r30, 0x2B4B - 4e72: f0 91 4c 2b lds r31, 0x2B4C - 4e76: 81 81 ldd r24, Z+1 ; 0x01 - 4e78: 80 7c andi r24, 0xC0 ; 192 - 4e7a: 80 34 cpi r24, 0x40 ; 64 - 4e7c: 09 f0 breq .+2 ; 0x4e80 - 4e7e: 08 95 ret - { - Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint ^ ENDPOINT_DIR_IN); - 4e80: 80 91 4d 2b lds r24, 0x2B4D - 4e84: 80 58 subi r24, 0x80 ; 128 - 4e86: 49 df rcall .-366 ; 0x4d1a - USB_Endpoint_SelectedHandle->CTRL |= USB_EP_STALL_bm; - 4e88: e0 91 4b 2b lds r30, 0x2B4B - 4e8c: f0 91 4c 2b lds r31, 0x2B4C - 4e90: 81 81 ldd r24, Z+1 ; 0x01 - 4e92: 84 60 ori r24, 0x04 ; 4 - 4e94: 81 83 std Z+1, r24 ; 0x01 - 4e96: 08 95 ret - -00004e98 : -} - -bool Endpoint_ConfigureEndpoint_PRV(const uint8_t Address, - const uint8_t Config, - const uint8_t Size) -{ - 4e98: 1f 93 push r17 - 4e9a: cf 93 push r28 - 4e9c: df 93 push r29 - 4e9e: 00 d0 rcall .+0 ; 0x4ea0 - 4ea0: cd b7 in r28, 0x3d ; 61 - 4ea2: de b7 in r29, 0x3e ; 62 - 4ea4: 18 2f mov r17, r24 - Endpoint_SelectEndpoint(Address); - 4ea6: 4a 83 std Y+2, r20 ; 0x02 - 4ea8: 69 83 std Y+1, r22 ; 0x01 - 4eaa: 37 df rcall .-402 ; 0x4d1a - - USB_Endpoint_SelectedHandle->CTRL = 0; - 4eac: e0 91 4b 2b lds r30, 0x2B4B - 4eb0: f0 91 4c 2b lds r31, 0x2B4C - 4eb4: 11 82 std Z+1, r1 ; 0x01 - USB_Endpoint_SelectedHandle->STATUS = (Address & ENDPOINT_DIR_IN) ? USB_EP_BUSNACK0_bm : 0; - 4eb6: e0 91 4b 2b lds r30, 0x2B4B - 4eba: f0 91 4c 2b lds r31, 0x2B4C - 4ebe: 4a 81 ldd r20, Y+2 ; 0x02 - 4ec0: 69 81 ldd r22, Y+1 ; 0x01 - 4ec2: 17 fd sbrc r17, 7 - 4ec4: 20 c0 rjmp .+64 ; 0x4f06 - 4ec6: 10 82 st Z, r1 - USB_Endpoint_SelectedHandle->CTRL = Config; - 4ec8: e0 91 4b 2b lds r30, 0x2B4B - 4ecc: f0 91 4c 2b lds r31, 0x2B4C - 4ed0: 61 83 std Z+1, r22 ; 0x01 - USB_Endpoint_SelectedHandle->CNT = 0; - 4ed2: e0 91 4b 2b lds r30, 0x2B4B - 4ed6: f0 91 4c 2b lds r31, 0x2B4C - 4eda: 12 82 std Z+2, r1 ; 0x02 - 4edc: 13 82 std Z+3, r1 ; 0x03 - USB_Endpoint_SelectedHandle->DATAPTR = (intptr_t)USB_Endpoint_SelectedFIFO->Data; - 4ede: 80 91 49 2b lds r24, 0x2B49 - 4ee2: 90 91 4a 2b lds r25, 0x2B4A - 4ee6: 84 83 std Z+4, r24 ; 0x04 - 4ee8: 95 83 std Z+5, r25 ; 0x05 - - USB_Endpoint_SelectedFIFO->Length = (Address & ENDPOINT_DIR_IN) ? Size : 0; - 4eea: 40 e0 ldi r20, 0x00 ; 0 - 4eec: fc 01 movw r30, r24 - 4eee: e0 5c subi r30, 0xC0 ; 192 - 4ef0: ff 4f sbci r31, 0xFF ; 255 - 4ef2: 40 83 st Z, r20 - USB_Endpoint_SelectedFIFO->Position = 0; - 4ef4: 31 96 adiw r30, 0x01 ; 1 - 4ef6: 10 82 st Z, r1 - - return true; -} - 4ef8: 81 e0 ldi r24, 0x01 ; 1 - 4efa: 0f 90 pop r0 - 4efc: 0f 90 pop r0 - 4efe: df 91 pop r29 - 4f00: cf 91 pop r28 - 4f02: 1f 91 pop r17 - 4f04: 08 95 ret - const uint8_t Size) -{ - Endpoint_SelectEndpoint(Address); - - USB_Endpoint_SelectedHandle->CTRL = 0; - USB_Endpoint_SelectedHandle->STATUS = (Address & ENDPOINT_DIR_IN) ? USB_EP_BUSNACK0_bm : 0; - 4f06: 82 e0 ldi r24, 0x02 ; 2 - 4f08: 80 83 st Z, r24 - USB_Endpoint_SelectedHandle->CTRL = Config; - 4f0a: e0 91 4b 2b lds r30, 0x2B4B - 4f0e: f0 91 4c 2b lds r31, 0x2B4C - 4f12: 61 83 std Z+1, r22 ; 0x01 - USB_Endpoint_SelectedHandle->CNT = 0; - 4f14: e0 91 4b 2b lds r30, 0x2B4B - 4f18: f0 91 4c 2b lds r31, 0x2B4C - 4f1c: 12 82 std Z+2, r1 ; 0x02 - 4f1e: 13 82 std Z+3, r1 ; 0x03 - USB_Endpoint_SelectedHandle->DATAPTR = (intptr_t)USB_Endpoint_SelectedFIFO->Data; - 4f20: 80 91 49 2b lds r24, 0x2B49 - 4f24: 90 91 4a 2b lds r25, 0x2B4A - 4f28: 84 83 std Z+4, r24 ; 0x04 - 4f2a: 95 83 std Z+5, r25 ; 0x05 - 4f2c: df cf rjmp .-66 ; 0x4eec - -00004f2e : - } -} - -bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table, - const uint8_t Entries) -{ - 4f2e: cf 92 push r12 - 4f30: df 92 push r13 - 4f32: ef 92 push r14 - 4f34: ff 92 push r15 - 4f36: 0f 93 push r16 - 4f38: 1f 93 push r17 - 4f3a: cf 93 push r28 - 4f3c: df 93 push r29 - 4f3e: 1f 92 push r1 - 4f40: cd b7 in r28, 0x3d ; 61 - 4f42: de b7 in r29, 0x3e ; 62 - 4f44: f6 2e mov r15, r22 - for (uint8_t i = 0; i < Entries; i++) - 4f46: 66 23 and r22, r22 - 4f48: 09 f4 brne .+2 ; 0x4f4c - 4f4a: 3e c0 rjmp .+124 ; 0x4fc8 - 4f4c: 6c 01 movw r12, r24 - 4f4e: 00 e0 ldi r16, 0x00 ; 0 - { - if (!(Table[i].Address)) - 4f50: d6 01 movw r26, r12 - 4f52: 1c 91 ld r17, X - 4f54: 11 23 and r17, r17 - 4f56: 91 f1 breq .+100 ; 0x4fbc - continue; - - if (!(Endpoint_ConfigureEndpoint(Table[i].Address, Table[i].Type, Table[i].Size, Table[i].Banks))) - 4f58: d6 01 movw r26, r12 - 4f5a: 11 96 adiw r26, 0x01 ; 1 - 4f5c: ed 91 ld r30, X+ - 4f5e: fc 91 ld r31, X - 4f60: 12 97 sbiw r26, 0x02 ; 2 - 4f62: 13 96 adiw r26, 0x03 ; 3 - 4f64: 8c 91 ld r24, X - 4f66: 13 97 sbiw r26, 0x03 ; 3 - static inline bool Endpoint_ConfigureEndpoint(const uint8_t Address, - const uint8_t Type, - const uint16_t Size, - const uint8_t Banks) - { - uint8_t EPConfigMask = (USB_EP_INTDSBL_bm | ((Banks > 1) ? USB_EP_PINGPONG_bm : 0) | Endpoint_BytesToEPSizeMask(Size)); - 4f68: 14 96 adiw r26, 0x04 ; 4 - 4f6a: 9c 91 ld r25, X - 4f6c: 92 30 cpi r25, 0x02 ; 2 - 4f6e: 08 f4 brcc .+2 ; 0x4f72 - 4f70: 45 c0 rjmp .+138 ; 0x4ffc - 4f72: 98 e1 ldi r25, 0x18 ; 24 - 4f74: 48 e1 ldi r20, 0x18 ; 24 - static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) - { - uint8_t MaskVal = 0; - uint16_t CheckBytes = 8; - - while (CheckBytes < Bytes) - 4f76: e9 30 cpi r30, 0x09 ; 9 - 4f78: f1 05 cpc r31, r1 - 4f7a: 50 f0 brcs .+20 ; 0x4f90 - static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST - ATTR_ALWAYS_INLINE; - static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) - { - uint8_t MaskVal = 0; - uint16_t CheckBytes = 8; - 4f7c: 28 e0 ldi r18, 0x08 ; 8 - 4f7e: 30 e0 ldi r19, 0x00 ; 0 - /* Inline Functions: */ - static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST - ATTR_ALWAYS_INLINE; - static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) - { - uint8_t MaskVal = 0; - 4f80: 90 e0 ldi r25, 0x00 ; 0 - uint16_t CheckBytes = 8; - - while (CheckBytes < Bytes) - { - MaskVal++; - 4f82: 9f 5f subi r25, 0xFF ; 255 - CheckBytes <<= 1; - 4f84: 22 0f add r18, r18 - 4f86: 33 1f adc r19, r19 - static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) - { - uint8_t MaskVal = 0; - uint16_t CheckBytes = 8; - - while (CheckBytes < Bytes) - 4f88: 2e 17 cp r18, r30 - 4f8a: 3f 07 cpc r19, r31 - 4f8c: d0 f3 brcs .-12 ; 0x4f82 - 4f8e: 94 2b or r25, r20 - const uint16_t Size, - const uint8_t Banks) - { - uint8_t EPConfigMask = (USB_EP_INTDSBL_bm | ((Banks > 1) ? USB_EP_PINGPONG_bm : 0) | Endpoint_BytesToEPSizeMask(Size)); - - if ((Address & ENDPOINT_EPNUM_MASK) >= ENDPOINT_TOTAL_ENDPOINTS) - 4f90: 21 2f mov r18, r17 - 4f92: 2f 70 andi r18, 0x0F ; 15 - 4f94: 30 e0 ldi r19, 0x00 ; 0 - 4f96: 26 30 cpi r18, 0x06 ; 6 - 4f98: 31 05 cpc r19, r1 - 4f9a: 9c f5 brge .+102 ; 0x5002 - return false; - - // TODO - Fix once limitations are lifted - EPConfigMask &= ~USB_EP_PINGPONG_bm; - 4f9c: 9f 7e andi r25, 0xEF ; 239 - if (Size > 64) - 4f9e: e1 34 cpi r30, 0x41 ; 65 - 4fa0: f1 05 cpc r31, r1 - 4fa2: 78 f5 brcc .+94 ; 0x5002 - return false; - - switch (Type) - 4fa4: 88 23 and r24, r24 - 4fa6: 01 f1 breq .+64 ; 0x4fe8 - 4fa8: 81 30 cpi r24, 0x01 ; 1 - 4faa: c9 f4 brne .+50 ; 0x4fde - { - case EP_TYPE_CONTROL: - EPConfigMask |= USB_EP_TYPE_CONTROL_gc; - break; - case EP_TYPE_ISOCHRONOUS: - EPConfigMask |= USB_EP_TYPE_ISOCHRONOUS_gc; - 4fac: 90 6c ori r25, 0xC0 ; 192 - 4fae: ee 2e mov r14, r30 - } - - if (Type == EP_TYPE_CONTROL) - Endpoint_ConfigureEndpoint_PRV(Address ^ ENDPOINT_DIR_IN, EPConfigMask, Size); - - return Endpoint_ConfigureEndpoint_PRV(Address, EPConfigMask, Size); - 4fb0: 4e 2d mov r20, r14 - 4fb2: 69 2f mov r22, r25 - 4fb4: 81 2f mov r24, r17 - 4fb6: 70 df rcall .-288 ; 0x4e98 - 4fb8: 88 23 and r24, r24 - 4fba: 19 f1 breq .+70 ; 0x5002 -} - -bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table, - const uint8_t Entries) -{ - for (uint8_t i = 0; i < Entries; i++) - 4fbc: 0f 5f subi r16, 0xFF ; 255 - 4fbe: b5 e0 ldi r27, 0x05 ; 5 - 4fc0: cb 0e add r12, r27 - 4fc2: d1 1c adc r13, r1 - 4fc4: 0f 11 cpse r16, r15 - 4fc6: c4 cf rjmp .-120 ; 0x4f50 - { - return false; - } - } - - return true; - 4fc8: 81 e0 ldi r24, 0x01 ; 1 -} - 4fca: 0f 90 pop r0 - 4fcc: df 91 pop r29 - 4fce: cf 91 pop r28 - 4fd0: 1f 91 pop r17 - 4fd2: 0f 91 pop r16 - 4fd4: ff 90 pop r15 - 4fd6: ef 90 pop r14 - 4fd8: df 90 pop r13 - 4fda: cf 90 pop r12 - 4fdc: 08 95 ret - break; - case EP_TYPE_ISOCHRONOUS: - EPConfigMask |= USB_EP_TYPE_ISOCHRONOUS_gc; - break; - default: - EPConfigMask |= USB_EP_TYPE_BULK_gc; - 4fde: 90 68 ori r25, 0x80 ; 128 - break; - } - - if (Type == EP_TYPE_CONTROL) - 4fe0: 88 23 and r24, r24 - 4fe2: 19 f0 breq .+6 ; 0x4fea - 4fe4: ee 2e mov r14, r30 - 4fe6: e4 cf rjmp .-56 ; 0x4fb0 - return false; - - switch (Type) - { - case EP_TYPE_CONTROL: - EPConfigMask |= USB_EP_TYPE_CONTROL_gc; - 4fe8: 90 64 ori r25, 0x40 ; 64 - EPConfigMask |= USB_EP_TYPE_BULK_gc; - break; - } - - if (Type == EP_TYPE_CONTROL) - Endpoint_ConfigureEndpoint_PRV(Address ^ ENDPOINT_DIR_IN, EPConfigMask, Size); - 4fea: ee 2e mov r14, r30 - 4fec: 4e 2f mov r20, r30 - 4fee: 69 2f mov r22, r25 - 4ff0: 80 e8 ldi r24, 0x80 ; 128 - 4ff2: 81 0f add r24, r17 - 4ff4: 99 83 std Y+1, r25 ; 0x01 - 4ff6: 50 df rcall .-352 ; 0x4e98 - 4ff8: 99 81 ldd r25, Y+1 ; 0x01 - 4ffa: da cf rjmp .-76 ; 0x4fb0 - static inline bool Endpoint_ConfigureEndpoint(const uint8_t Address, - const uint8_t Type, - const uint16_t Size, - const uint8_t Banks) - { - uint8_t EPConfigMask = (USB_EP_INTDSBL_bm | ((Banks > 1) ? USB_EP_PINGPONG_bm : 0) | Endpoint_BytesToEPSizeMask(Size)); - 4ffc: 98 e0 ldi r25, 0x08 ; 8 - 4ffe: 48 e0 ldi r20, 0x08 ; 8 - 5000: ba cf rjmp .-140 ; 0x4f76 - if (!(Table[i].Address)) - continue; - - if (!(Endpoint_ConfigureEndpoint(Table[i].Address, Table[i].Type, Table[i].Size, Table[i].Banks))) - { - return false; - 5002: 80 e0 ldi r24, 0x00 ; 0 - 5004: e2 cf rjmp .-60 ; 0x4fca - -00005006 : - -void Endpoint_ClearEndpoints(void) -{ - for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) - { - ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].IN.CTRL = 0; - 5006: e0 ec ldi r30, 0xC0 ; 192 - 5008: f4 e0 ldi r31, 0x04 ; 4 - 500a: a6 81 ldd r26, Z+6 ; 0x06 - 500c: b7 81 ldd r27, Z+7 ; 0x07 - 500e: 19 96 adiw r26, 0x09 ; 9 - 5010: 1c 92 st X, r1 - ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].OUT.CTRL = 0; - 5012: a6 81 ldd r26, Z+6 ; 0x06 - 5014: b7 81 ldd r27, Z+7 ; 0x07 - 5016: 11 96 adiw r26, 0x01 ; 1 - 5018: 1c 92 st X, r1 - -void Endpoint_ClearEndpoints(void) -{ - for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) - { - ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].IN.CTRL = 0; - 501a: a6 81 ldd r26, Z+6 ; 0x06 - 501c: b7 81 ldd r27, Z+7 ; 0x07 - 501e: 59 96 adiw r26, 0x19 ; 25 - 5020: 1c 92 st X, r1 - ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].OUT.CTRL = 0; - 5022: a6 81 ldd r26, Z+6 ; 0x06 - 5024: b7 81 ldd r27, Z+7 ; 0x07 - 5026: 51 96 adiw r26, 0x11 ; 17 - 5028: 1c 92 st X, r1 - -void Endpoint_ClearEndpoints(void) -{ - for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) - { - ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].IN.CTRL = 0; - 502a: a6 81 ldd r26, Z+6 ; 0x06 - 502c: b7 81 ldd r27, Z+7 ; 0x07 - 502e: 99 96 adiw r26, 0x29 ; 41 - 5030: 1c 92 st X, r1 - ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].OUT.CTRL = 0; - 5032: a6 81 ldd r26, Z+6 ; 0x06 - 5034: b7 81 ldd r27, Z+7 ; 0x07 - 5036: 91 96 adiw r26, 0x21 ; 33 - 5038: 1c 92 st X, r1 - -void Endpoint_ClearEndpoints(void) -{ - for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) - { - ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].IN.CTRL = 0; - 503a: a6 81 ldd r26, Z+6 ; 0x06 - 503c: b7 81 ldd r27, Z+7 ; 0x07 - 503e: d9 96 adiw r26, 0x39 ; 57 - 5040: 1c 92 st X, r1 - ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].OUT.CTRL = 0; - 5042: a6 81 ldd r26, Z+6 ; 0x06 - 5044: b7 81 ldd r27, Z+7 ; 0x07 - 5046: d1 96 adiw r26, 0x31 ; 49 - 5048: 1c 92 st X, r1 - -void Endpoint_ClearEndpoints(void) -{ - for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) - { - ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].IN.CTRL = 0; - 504a: a6 81 ldd r26, Z+6 ; 0x06 - 504c: b7 81 ldd r27, Z+7 ; 0x07 - 504e: a7 5b subi r26, 0xB7 ; 183 - 5050: bf 4f sbci r27, 0xFF ; 255 - 5052: 1c 92 st X, r1 - ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].OUT.CTRL = 0; - 5054: a6 81 ldd r26, Z+6 ; 0x06 - 5056: b7 81 ldd r27, Z+7 ; 0x07 - 5058: af 5b subi r26, 0xBF ; 191 - 505a: bf 4f sbci r27, 0xFF ; 255 - 505c: 1c 92 st X, r1 - -void Endpoint_ClearEndpoints(void) -{ - for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) - { - ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].IN.CTRL = 0; - 505e: a6 81 ldd r26, Z+6 ; 0x06 - 5060: b7 81 ldd r27, Z+7 ; 0x07 - 5062: a7 5a subi r26, 0xA7 ; 167 - 5064: bf 4f sbci r27, 0xFF ; 255 - 5066: 1c 92 st X, r1 - ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].OUT.CTRL = 0; - 5068: 06 80 ldd r0, Z+6 ; 0x06 - 506a: f7 81 ldd r31, Z+7 ; 0x07 - 506c: e0 2d mov r30, r0 - 506e: ef 5a subi r30, 0xAF ; 175 - 5070: ff 4f sbci r31, 0xFF ; 255 - 5072: 10 82 st Z, r1 - 5074: 08 95 ret - -00005076 : - } -} - -void Endpoint_ClearStatusStage(void) -{ - if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST) - 5076: 80 91 41 2b lds r24, 0x2B41 - 507a: 87 ff sbrs r24, 7 - 507c: 05 c0 rjmp .+10 ; 0x5088 - 507e: 0c c0 rjmp .+24 ; 0x5098 - } - else - { - while (!(Endpoint_IsINReady())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - 5080: 80 91 40 2b lds r24, 0x2B40 - 5084: 88 23 and r24, r24 - 5086: 61 f0 breq .+24 ; 0x50a0 - - Endpoint_ClearOUT(); - } - else - { - while (!(Endpoint_IsINReady())) - 5088: 81 de rcall .-766 ; 0x4d8c - 508a: 88 23 and r24, r24 - 508c: c9 f3 breq .-14 ; 0x5080 - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - - Endpoint_ClearIN(); - 508e: fd cd rjmp .-1030 ; 0x4c8a -{ - if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST) - { - while (!(Endpoint_IsOUTReceived())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - 5090: 80 91 40 2b lds r24, 0x2B40 - 5094: 88 23 and r24, r24 - 5096: 21 f0 breq .+8 ; 0x50a0 - -void Endpoint_ClearStatusStage(void) -{ - if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST) - { - while (!(Endpoint_IsOUTReceived())) - 5098: 85 de rcall .-758 ; 0x4da4 - 509a: 88 23 and r24, r24 - 509c: c9 f3 breq .-14 ; 0x5090 - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - - Endpoint_ClearOUT(); - 509e: 0e ce rjmp .-996 ; 0x4cbc - 50a0: 08 95 ret - -000050a2 : - } -} - -#if !defined(CONTROL_ONLY_DEVICE) -uint8_t Endpoint_WaitUntilReady(void) -{ - 50a2: 1f 93 push r17 - 50a4: cf 93 push r28 - 50a6: df 93 push r29 - * \return Current USB frame number from the USB controller. - */ - static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; - static inline uint16_t USB_Device_GetFrameNumber(void) - { - return ((USB_EndpointTable_t*)USB.EPPTR)->FrameNum; - 50a8: e0 91 c6 04 lds r30, 0x04C6 - 50ac: f0 91 c7 04 lds r31, 0x04C7 - 50b0: e0 5a subi r30, 0xA0 ; 160 - 50b2: ff 4f sbci r31, 0xFF ; 255 - 50b4: c0 81 ld r28, Z - 50b6: d1 81 ldd r29, Z+1 ; 0x01 - #if (USB_STREAM_TIMEOUT_MS < 0xFF) - uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; - 50b8: 14 e6 ldi r17, 0x64 ; 100 - * \return The currently selected endpoint's direction, as a \c ENDPOINT_DIR_* mask. - */ - static inline uint8_t Endpoint_GetEndpointDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t Endpoint_GetEndpointDirection(void) - { - return (USB_Endpoint_SelectedEndpoint & ENDPOINT_DIR_IN); - 50ba: 80 91 4d 2b lds r24, 0x2B4D - 50be: 80 78 andi r24, 0x80 ; 128 - - uint16_t PreviousFrameNumber = USB_Device_GetFrameNumber(); - - for (;;) - { - if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN) - 50c0: 80 38 cpi r24, 0x80 ; 128 - 50c2: 31 f1 breq .+76 ; 0x5110 - if (Endpoint_IsINReady()) - return ENDPOINT_READYWAIT_NoError; - } - else - { - if (Endpoint_IsOUTReceived()) - 50c4: 6f de rcall .-802 ; 0x4da4 - 50c6: 81 11 cpse r24, r1 - 50c8: 26 c0 rjmp .+76 ; 0x5116 - return ENDPOINT_READYWAIT_NoError; - } - - uint8_t USB_DeviceState_LCL = USB_DeviceState; - 50ca: 80 91 40 2b lds r24, 0x2B40 - - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - 50ce: 88 23 and r24, r24 - 50d0: 39 f1 breq .+78 ; 0x5120 - return ENDPOINT_READYWAIT_DeviceDisconnected; - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - 50d2: 85 30 cpi r24, 0x05 ; 5 - 50d4: 51 f1 breq .+84 ; 0x512a - * \return Boolean \c true if the currently selected endpoint is stalled, \c false otherwise. - */ - static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Endpoint_IsStalled(void) - { - return ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_STALL_bm) ? true : false); - 50d6: e0 91 4b 2b lds r30, 0x2B4B - 50da: f0 91 4c 2b lds r31, 0x2B4C - 50de: 81 81 ldd r24, Z+1 ; 0x01 - return ENDPOINT_READYWAIT_BusSuspended; - else if (Endpoint_IsStalled()) - 50e0: 82 fd sbrc r24, 2 - 50e2: 28 c0 rjmp .+80 ; 0x5134 - 50e4: e0 91 c6 04 lds r30, 0x04C6 - 50e8: f0 91 c7 04 lds r31, 0x04C7 - 50ec: e0 5a subi r30, 0xA0 ; 160 - 50ee: ff 4f sbci r31, 0xFF ; 255 - 50f0: 80 81 ld r24, Z - 50f2: 91 81 ldd r25, Z+1 ; 0x01 - return ENDPOINT_READYWAIT_EndpointStalled; - - uint16_t CurrentFrameNumber = USB_Device_GetFrameNumber(); - - if (CurrentFrameNumber != PreviousFrameNumber) - 50f4: c8 17 cp r28, r24 - 50f6: d9 07 cpc r29, r25 - 50f8: 01 f3 breq .-64 ; 0x50ba - { - PreviousFrameNumber = CurrentFrameNumber; - - if (!(TimeoutMSRem--)) - 50fa: 2f ef ldi r18, 0xFF ; 255 - 50fc: 21 0f add r18, r17 - 50fe: 11 23 and r17, r17 - 5100: f1 f0 breq .+60 ; 0x513e - 5102: ec 01 movw r28, r24 - 5104: 12 2f mov r17, r18 - * \return The currently selected endpoint's direction, as a \c ENDPOINT_DIR_* mask. - */ - static inline uint8_t Endpoint_GetEndpointDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t Endpoint_GetEndpointDirection(void) - { - return (USB_Endpoint_SelectedEndpoint & ENDPOINT_DIR_IN); - 5106: 80 91 4d 2b lds r24, 0x2B4D - 510a: 80 78 andi r24, 0x80 ; 128 - - uint16_t PreviousFrameNumber = USB_Device_GetFrameNumber(); - - for (;;) - { - if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN) - 510c: 80 38 cpi r24, 0x80 ; 128 - 510e: d1 f6 brne .-76 ; 0x50c4 - { - if (Endpoint_IsINReady()) - 5110: 3d de rcall .-902 ; 0x4d8c - 5112: 88 23 and r24, r24 - 5114: d1 f2 breq .-76 ; 0x50ca - return ENDPOINT_READYWAIT_NoError; - 5116: 80 e0 ldi r24, 0x00 ; 0 - - if (!(TimeoutMSRem--)) - return ENDPOINT_READYWAIT_Timeout; - } - } -} - 5118: df 91 pop r29 - 511a: cf 91 pop r28 - 511c: 1f 91 pop r17 - 511e: 08 95 ret - } - - uint8_t USB_DeviceState_LCL = USB_DeviceState; - - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - return ENDPOINT_READYWAIT_DeviceDisconnected; - 5120: 82 e0 ldi r24, 0x02 ; 2 - - if (!(TimeoutMSRem--)) - return ENDPOINT_READYWAIT_Timeout; - } - } -} - 5122: df 91 pop r29 - 5124: cf 91 pop r28 - 5126: 1f 91 pop r17 - 5128: 08 95 ret - uint8_t USB_DeviceState_LCL = USB_DeviceState; - - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - return ENDPOINT_READYWAIT_DeviceDisconnected; - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - return ENDPOINT_READYWAIT_BusSuspended; - 512a: 83 e0 ldi r24, 0x03 ; 3 - - if (!(TimeoutMSRem--)) - return ENDPOINT_READYWAIT_Timeout; - } - } -} - 512c: df 91 pop r29 - 512e: cf 91 pop r28 - 5130: 1f 91 pop r17 - 5132: 08 95 ret - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - return ENDPOINT_READYWAIT_DeviceDisconnected; - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - return ENDPOINT_READYWAIT_BusSuspended; - else if (Endpoint_IsStalled()) - return ENDPOINT_READYWAIT_EndpointStalled; - 5134: 81 e0 ldi r24, 0x01 ; 1 - - if (!(TimeoutMSRem--)) - return ENDPOINT_READYWAIT_Timeout; - } - } -} - 5136: df 91 pop r29 - 5138: cf 91 pop r28 - 513a: 1f 91 pop r17 - 513c: 08 95 ret - if (CurrentFrameNumber != PreviousFrameNumber) - { - PreviousFrameNumber = CurrentFrameNumber; - - if (!(TimeoutMSRem--)) - return ENDPOINT_READYWAIT_Timeout; - 513e: 84 e0 ldi r24, 0x04 ; 4 - } - } -} - 5140: df 91 pop r29 - 5142: cf 91 pop r28 - 5144: 1f 91 pop r17 - 5146: 08 95 ret - -00005148 : - USB_ResetInterface(); -} - -void USB_Disable(void) -{ - USB_INT_DisableAllInterrupts(); - 5148: 62 d0 rcall .+196 ; 0x520e - USB_INT_ClearAllInterrupts(); - 514a: 68 d0 rcall .+208 ; 0x521c - * enumerating the device once attached until \ref USB_Attach() is called. - */ - static inline void USB_Detach(void) ATTR_ALWAYS_INLINE; - static inline void USB_Detach(void) - { - USB.CTRLB &= ~USB_ATTACH_bm; - 514c: e0 ec ldi r30, 0xC0 ; 192 - 514e: f4 e0 ldi r31, 0x04 ; 4 - 5150: 81 81 ldd r24, Z+1 ; 0x01 - 5152: 8e 7f andi r24, 0xFE ; 254 - 5154: 81 83 std Z+1, r24 ; 0x01 - } - - static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE; - static inline void USB_Controller_Disable(void) - { - USB.CTRLA &= ~USB_ENABLE_bm; - 5156: 80 81 ld r24, Z - 5158: 8f 77 andi r24, 0x7F ; 127 - 515a: 80 83 st Z, r24 - - USB_Detach(); - USB_Controller_Disable(); - - USB_IsInitialized = false; - 515c: 10 92 3f 2b sts 0x2B3F, r1 - 5160: 08 95 ret - -00005162 : -} - -void USB_ResetInterface(void) -{ - 5162: cf 93 push r28 - 5164: df 93 push r29 - #if defined(USB_DEVICE_OPT_FULLSPEED) - if (USB_Options & USB_DEVICE_OPT_LOWSPEED) - CLK.USBCTRL = (((F_USB / 6000000) - 1) << CLK_USBPSDIV_gp); - else - CLK.USBCTRL = (((F_USB / 48000000) - 1) << CLK_USBPSDIV_gp); - 5166: e0 e4 ldi r30, 0x40 ; 64 - 5168: f0 e0 ldi r31, 0x00 ; 0 - 516a: 14 82 std Z+4, r1 ; 0x04 - #else - CLK.USBCTRL = (((F_USB / 6000000) - 1) << CLK_USBPSDIV_gp); - #endif - - if (USB_Options & USB_OPT_PLLCLKSRC) - CLK.USBCTRL |= (CLK_USBSRC_PLL_gc | CLK_USBSEN_bm); - 516c: 84 81 ldd r24, Z+4 ; 0x04 - 516e: 81 60 ori r24, 0x01 ; 1 - 5170: 84 83 std Z+4, r24 ; 0x04 - else - CLK.USBCTRL |= (CLK_USBSRC_RC32M_gc | CLK_USBSEN_bm); - - USB_Device_SetDeviceAddress(0); - - USB_INT_DisableAllInterrupts(); - 5172: 4d d0 rcall .+154 ; 0x520e - USB_INT_ClearAllInterrupts(); - 5174: 53 d0 rcall .+166 ; 0x521c - } - - static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE; - static inline void USB_Controller_Reset(void) - { - USB.CTRLA &= ~USB_ENABLE_bm; - 5176: c0 ec ldi r28, 0xC0 ; 192 - 5178: d4 e0 ldi r29, 0x04 ; 4 - 517a: 88 81 ld r24, Y - 517c: 8f 77 andi r24, 0x7F ; 127 - 517e: 88 83 st Y, r24 - USB.CTRLA |= USB_ENABLE_bm; - 5180: 88 81 ld r24, Y - 5182: 80 68 ori r24, 0x80 ; 128 - 5184: 88 83 st Y, r24 -} - -#if defined(USB_CAN_BE_DEVICE) -static void USB_Init_Device(void) -{ - USB_DeviceState = DEVICE_STATE_Unattached; - 5186: 10 92 40 2b sts 0x2B40, r1 - USB_Device_ConfigurationNumber = 0; - 518a: 10 92 3c 2b sts 0x2B3C, r1 - - #if !defined(NO_DEVICE_REMOTE_WAKEUP) - USB_Device_RemoteWakeupEnabled = false; - 518e: 10 92 3e 2b sts 0x2B3E, r1 - #endif - - #if !defined(NO_DEVICE_SELF_POWER) - USB_Device_CurrentlySelfPowered = false; - 5192: 10 92 3d 2b sts 0x2B3D, r1 - } - - static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE; - static inline void USB_Device_SetFullSpeed(void) - { - USB.CTRLA |= USB_SPEED_bm; - 5196: 88 81 ld r24, Y - 5198: 80 64 ori r24, 0x40 ; 64 - 519a: 88 83 st Y, r24 - EPConfigMask |= USB_EP_TYPE_BULK_gc; - break; - } - - if (Type == EP_TYPE_CONTROL) - Endpoint_ConfigureEndpoint_PRV(Address ^ ENDPOINT_DIR_IN, EPConfigMask, Size); - 519c: 48 e0 ldi r20, 0x08 ; 8 - 519e: 68 e4 ldi r22, 0x48 ; 72 - 51a0: 80 e8 ldi r24, 0x80 ; 128 - 51a2: 7a de rcall .-780 ; 0x4e98 - - return Endpoint_ConfigureEndpoint_PRV(Address, EPConfigMask, Size); - 51a4: 48 e0 ldi r20, 0x08 ; 8 - 51a6: 68 e4 ldi r22, 0x48 ; 72 - 51a8: 80 e0 ldi r24, 0x00 ; 0 - 51aa: 76 de rcall .-788 ; 0x4e98 - static inline void USB_INT_Enable(const uint8_t Interrupt) - { - switch (Interrupt) - { - case USB_INT_BUSEVENTI: - USB.INTCTRLA |= USB_BUSEVIE_bm; - 51ac: 88 85 ldd r24, Y+8 ; 0x08 - 51ae: 80 64 ori r24, 0x40 ; 64 - 51b0: 88 87 std Y+8, r24 ; 0x08 - * register and despite the datasheet making no mention of its requirement in host mode. - */ - static inline void USB_Attach(void) ATTR_ALWAYS_INLINE; - static inline void USB_Attach(void) - { - USB.CTRLB |= USB_ATTACH_bm; - 51b2: 89 81 ldd r24, Y+1 ; 0x01 - 51b4: 81 60 ori r24, 0x01 ; 1 - 51b6: 89 83 std Y+1, r24 ; 0x01 - USB_INT_DisableAllInterrupts(); - USB_INT_ClearAllInterrupts(); - - USB_Controller_Reset(); - USB_Init_Device(); -} - 51b8: df 91 pop r29 - 51ba: cf 91 pop r28 - 51bc: 08 95 ret - -000051be : - #if (ARCH == ARCH_AVR8) - return SREG; - #elif (ARCH == ARCH_UC3) - return __builtin_mfsr(AVR32_SR); - #elif (ARCH == ARCH_XMEGA) - return SREG; - 51be: 2f b7 in r18, 0x3f ; 63 - #if (ARCH == ARCH_AVR8) - cli(); - #elif (ARCH == ARCH_UC3) - __builtin_ssrf(AVR32_SR_GM_OFFSET); - #elif (ARCH == ARCH_XMEGA) - cli(); - 51c0: f8 94 cli - #endif - - uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); - GlobalInterruptDisable(); - - NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc; - 51c2: 82 e0 ldi r24, 0x02 ; 2 - 51c4: e0 ec ldi r30, 0xC0 ; 192 - 51c6: f1 e0 ldi r31, 0x01 ; 1 - 51c8: 82 87 std Z+10, r24 ; 0x0a - USB.CAL0 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL0)); - 51ca: ea e1 ldi r30, 0x1A ; 26 - 51cc: f0 e0 ldi r31, 0x00 ; 0 - 51ce: e4 91 lpm r30, Z - 51d0: a0 ec ldi r26, 0xC0 ; 192 - 51d2: b4 e0 ldi r27, 0x04 ; 4 - 51d4: da 96 adiw r26, 0x3a ; 58 - 51d6: ec 93 st X, r30 - 51d8: da 97 sbiw r26, 0x3a ; 58 - USB.CAL1 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL1)); - 51da: eb e1 ldi r30, 0x1B ; 27 - 51dc: f0 e0 ldi r31, 0x00 ; 0 - 51de: e4 91 lpm r30, Z - 51e0: db 96 adiw r26, 0x3b ; 59 - 51e2: ec 93 st X, r30 - 51e4: db 97 sbiw r26, 0x3b ; 59 - NVM.CMD = NVM_CMD_NO_OPERATION_gc; - 51e6: e0 ec ldi r30, 0xC0 ; 192 - 51e8: f1 e0 ldi r31, 0x01 ; 1 - 51ea: 12 86 std Z+10, r1 ; 0x0a - - /* Ugly workaround to ensure an aligned table, since __BIGGEST_ALIGNMENT__ == 1 for the 8-bit AVR-GCC toolchain */ - USB.EPPTR = ((intptr_t)&USB_EndpointTable[1] & ~(1 << 0)); - 51ec: 87 e6 ldi r24, 0x67 ; 103 - 51ee: 9e e2 ldi r25, 0x2E ; 46 - 51f0: 8e 7f andi r24, 0xFE ; 254 - 51f2: 16 96 adiw r26, 0x06 ; 6 - 51f4: 8d 93 st X+, r24 - 51f6: 9c 93 st X, r25 - 51f8: 17 97 sbiw r26, 0x07 ; 7 - USB.CTRLA = (USB_STFRNUM_bm | ((ENDPOINT_TOTAL_ENDPOINTS - 1) << USB_MAXEP_gp)); - 51fa: 85 e1 ldi r24, 0x15 ; 21 - 51fc: 8c 93 st X, r24 - - if ((USB_Options & USB_OPT_BUSEVENT_PRIHIGH) == USB_OPT_BUSEVENT_PRIHIGH) - USB.INTCTRLA = (3 << USB_INTLVL_gp); - else if ((USB_Options & USB_OPT_BUSEVENT_PRIMED) == USB_OPT_BUSEVENT_PRIMED) - USB.INTCTRLA = (2 << USB_INTLVL_gp); - 51fe: 82 e0 ldi r24, 0x02 ; 2 - 5200: 18 96 adiw r26, 0x08 ; 8 - 5202: 8c 93 st X, r24 - if (GlobalIntState & AVR32_SR_GM) - __builtin_ssrf(AVR32_SR_GM_OFFSET); - else - __builtin_csrf(AVR32_SR_GM_OFFSET); - #elif (ARCH == ARCH_XMEGA) - SREG = GlobalIntState; - 5204: 2f bf out 0x3f, r18 ; 63 - - #if defined(USB_CAN_BE_BOTH) - USB_CurrentMode = Mode; - #endif - - USB_IsInitialized = true; - 5206: 81 e0 ldi r24, 0x01 ; 1 - 5208: 80 93 3f 2b sts 0x2B3F, r24 - - USB_ResetInterface(); - 520c: aa cf rjmp .-172 ; 0x5162 - -0000520e : -#define __INCLUDE_FROM_USB_DRIVER -#include "../USBInterrupt.h" - -void USB_INT_DisableAllInterrupts(void) -{ - USB.INTCTRLA &= USB_INTLVL_gm; - 520e: e0 ec ldi r30, 0xC0 ; 192 - 5210: f4 e0 ldi r31, 0x04 ; 4 - 5212: 80 85 ldd r24, Z+8 ; 0x08 - 5214: 83 70 andi r24, 0x03 ; 3 - 5216: 80 87 std Z+8, r24 ; 0x08 - USB.INTCTRLB = 0; - 5218: 11 86 std Z+9, r1 ; 0x09 - 521a: 08 95 ret - -0000521c : -} - -void USB_INT_ClearAllInterrupts(void) -{ - USB.INTFLAGSACLR = 0xFF; - 521c: e0 ec ldi r30, 0xC0 ; 192 - 521e: f4 e0 ldi r31, 0x04 ; 4 - 5220: 8f ef ldi r24, 0xFF ; 255 - 5222: 82 87 std Z+10, r24 ; 0x0a - USB.INTFLAGSBCLR = 0xFF; - 5224: 84 87 std Z+12, r24 ; 0x0c - 5226: 08 95 ret - -00005228 <__vector_125>: -} - -ISR(USB_BUSEVENT_vect) -{ - 5228: 1f 92 push r1 - 522a: 0f 92 push r0 - 522c: 0f b6 in r0, 0x3f ; 63 - 522e: 0f 92 push r0 - 5230: 11 24 eor r1, r1 - 5232: 2f 93 push r18 - 5234: 3f 93 push r19 - 5236: 4f 93 push r20 - 5238: 5f 93 push r21 - 523a: 6f 93 push r22 - 523c: 7f 93 push r23 - 523e: 8f 93 push r24 - 5240: 9f 93 push r25 - 5242: af 93 push r26 - 5244: bf 93 push r27 - 5246: ef 93 push r30 - 5248: ff 93 push r31 - case USB_INT_BUSEVENTI_Resume: - return ((USB.INTFLAGSACLR & USB_RESUMEIF_bm) ? true : false); - case USB_INT_BUSEVENTI_Reset: - return ((USB.INTFLAGSACLR & USB_RSTIF_bm) ? true : false); - case USB_INT_SOFI: - return ((USB.INTFLAGSACLR & USB_SOFIF_bm) ? true : false); - 524a: 80 91 ca 04 lds r24, 0x04CA - #if !defined(NO_SOF_EVENTS) - if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI)) - 524e: 87 fd sbrc r24, 7 - 5250: 4d c0 rjmp .+154 ; 0x52ec <__vector_125+0xc4> - static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) - { - switch (Interrupt) - { - case USB_INT_BUSEVENTI_Suspend: - return ((USB.INTFLAGSACLR & USB_SUSPENDIF_bm) ? true : false); - 5252: 80 91 ca 04 lds r24, 0x04CA - - EVENT_USB_Device_StartOfFrame(); - } - #endif - - if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Suspend)) - 5256: 86 fd sbrc r24, 6 - 5258: 41 c0 rjmp .+130 ; 0x52dc <__vector_125+0xb4> - case USB_INT_BUSEVENTI_Resume: - return ((USB.INTFLAGSACLR & USB_RESUMEIF_bm) ? true : false); - 525a: 80 91 ca 04 lds r24, 0x04CA - USB_DeviceState = DEVICE_STATE_Suspended; - EVENT_USB_Device_Suspend(); - #endif - } - - if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Resume)) - 525e: 85 ff sbrs r24, 5 - 5260: 0c c0 rjmp .+24 ; 0x527a <__vector_125+0x52> - { - case USB_INT_BUSEVENTI_Suspend: - USB.INTFLAGSACLR = USB_SUSPENDIF_bm; - break; - case USB_INT_BUSEVENTI_Resume: - USB.INTFLAGSACLR = USB_RESUMEIF_bm; - 5262: 80 e2 ldi r24, 0x20 ; 32 - 5264: 80 93 ca 04 sts 0x04CA, r24 - { - USB_INT_Clear(USB_INT_BUSEVENTI_Resume); - - if (USB_Device_ConfigurationNumber) - 5268: 80 91 3c 2b lds r24, 0x2B3C - 526c: 88 23 and r24, r24 - 526e: 71 f1 breq .+92 ; 0x52cc <__vector_125+0xa4> - USB_DeviceState = DEVICE_STATE_Configured; - 5270: 84 e0 ldi r24, 0x04 ; 4 - 5272: 80 93 40 2b sts 0x2B40, r24 - else - USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Addressed : DEVICE_STATE_Powered; - - #if !defined(NO_LIMITED_CONTROLLER_CONNECT) - EVENT_USB_Device_Connect(); - 5276: 0e 94 8b 11 call 0x2316 ; 0x2316 - case USB_INT_BUSEVENTI_Suspend: - return ((USB.INTFLAGSACLR & USB_SUSPENDIF_bm) ? true : false); - case USB_INT_BUSEVENTI_Resume: - return ((USB.INTFLAGSACLR & USB_RESUMEIF_bm) ? true : false); - case USB_INT_BUSEVENTI_Reset: - return ((USB.INTFLAGSACLR & USB_RSTIF_bm) ? true : false); - 527a: 80 91 ca 04 lds r24, 0x04CA - #else - EVENT_USB_Device_WakeUp(); - #endif - } - - if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Reset)) - 527e: 84 ff sbrs r24, 4 - 5280: 14 c0 rjmp .+40 ; 0x52aa <__vector_125+0x82> - break; - case USB_INT_BUSEVENTI_Resume: - USB.INTFLAGSACLR = USB_RESUMEIF_bm; - break; - case USB_INT_BUSEVENTI_Reset: - USB.INTFLAGSACLR = USB_RSTIF_bm; - 5282: 80 e1 ldi r24, 0x10 ; 16 - 5284: 80 93 ca 04 sts 0x04CA, r24 - { - USB_INT_Clear(USB_INT_BUSEVENTI_Reset); - - USB_DeviceState = DEVICE_STATE_Default; - 5288: 82 e0 ldi r24, 0x02 ; 2 - 528a: 80 93 40 2b sts 0x2B40, r24 - USB_Device_ConfigurationNumber = 0; - 528e: 10 92 3c 2b sts 0x2B3C, r1 - } - - static inline void USB_Device_EnableDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; - static inline void USB_Device_EnableDeviceAddress(const uint8_t Address) - { - USB.ADDR = Address; - 5292: 10 92 c3 04 sts 0x04C3, r1 - - USB_Device_EnableDeviceAddress(0); - - Endpoint_ClearEndpoints(); - 5296: b7 de rcall .-658 ; 0x5006 - EPConfigMask |= USB_EP_TYPE_BULK_gc; - break; - } - - if (Type == EP_TYPE_CONTROL) - Endpoint_ConfigureEndpoint_PRV(Address ^ ENDPOINT_DIR_IN, EPConfigMask, Size); - 5298: 48 e0 ldi r20, 0x08 ; 8 - 529a: 68 e4 ldi r22, 0x48 ; 72 - 529c: 80 e8 ldi r24, 0x80 ; 128 - 529e: fc dd rcall .-1032 ; 0x4e98 - - return Endpoint_ConfigureEndpoint_PRV(Address, EPConfigMask, Size); - 52a0: 48 e0 ldi r20, 0x08 ; 8 - 52a2: 68 e4 ldi r22, 0x48 ; 72 - 52a4: 80 e0 ldi r24, 0x00 ; 0 - 52a6: f8 dd rcall .-1040 ; 0x4e98 - Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, - USB_Device_ControlEndpointSize, 1); - - EVENT_USB_Device_Reset(); - 52a8: 35 db rcall .-2454 ; 0x4914 - } -} - 52aa: ff 91 pop r31 - 52ac: ef 91 pop r30 - 52ae: bf 91 pop r27 - 52b0: af 91 pop r26 - 52b2: 9f 91 pop r25 - 52b4: 8f 91 pop r24 - 52b6: 7f 91 pop r23 - 52b8: 6f 91 pop r22 - 52ba: 5f 91 pop r21 - 52bc: 4f 91 pop r20 - 52be: 3f 91 pop r19 - 52c0: 2f 91 pop r18 - 52c2: 0f 90 pop r0 - 52c4: 0f be out 0x3f, r0 ; 63 - 52c6: 0f 90 pop r0 - 52c8: 1f 90 pop r1 - 52ca: 18 95 reti - } - - static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; - static inline bool USB_Device_IsAddressSet(void) - { - return ((USB.ADDR != 0) ? true : false); - 52cc: 80 91 c3 04 lds r24, 0x04C3 - USB_INT_Clear(USB_INT_BUSEVENTI_Resume); - - if (USB_Device_ConfigurationNumber) - USB_DeviceState = DEVICE_STATE_Configured; - else - USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Addressed : DEVICE_STATE_Powered; - 52d0: 81 11 cpse r24, r1 - 52d2: 15 c0 rjmp .+42 ; 0x52fe <__vector_125+0xd6> - 52d4: 81 e0 ldi r24, 0x01 ; 1 - 52d6: 80 93 40 2b sts 0x2B40, r24 - 52da: cd cf rjmp .-102 ; 0x5276 <__vector_125+0x4e> - static inline void USB_INT_Clear(const uint8_t Interrupt) - { - switch (Interrupt) - { - case USB_INT_BUSEVENTI_Suspend: - USB.INTFLAGSACLR = USB_SUSPENDIF_bm; - 52dc: 80 e4 ldi r24, 0x40 ; 64 - 52de: 80 93 ca 04 sts 0x04CA, r24 - if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Suspend)) - { - USB_INT_Clear(USB_INT_BUSEVENTI_Suspend); - - #if !defined(NO_LIMITED_CONTROLLER_CONNECT) - USB_DeviceState = DEVICE_STATE_Unattached; - 52e2: 10 92 40 2b sts 0x2B40, r1 - EVENT_USB_Device_Disconnect(); - 52e6: 0e 94 8e 11 call 0x231c ; 0x231c - 52ea: b7 cf rjmp .-146 ; 0x525a <__vector_125+0x32> - switch (Interrupt) - { - case USB_INT_BUSEVENTI: - return ((USB.INTCTRLA & USB_BUSEVIE_bm) ? true : false); - case USB_INT_SOFI: - return ((USB.INTCTRLA & USB_SOFIE_bm) ? true : false); - 52ec: 80 91 c8 04 lds r24, 0x04C8 -} - -ISR(USB_BUSEVENT_vect) -{ - #if !defined(NO_SOF_EVENTS) - if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI)) - 52f0: 87 ff sbrs r24, 7 - 52f2: af cf rjmp .-162 ; 0x5252 <__vector_125+0x2a> - break; - case USB_INT_BUSEVENTI_Reset: - USB.INTFLAGSACLR = USB_RSTIF_bm; - break; - case USB_INT_SOFI: - USB.INTFLAGSACLR = USB_SOFIF_bm; - 52f4: 80 e8 ldi r24, 0x80 ; 128 - 52f6: 80 93 ca 04 sts 0x04CA, r24 - { - USB_INT_Clear(USB_INT_SOFI); - - EVENT_USB_Device_StartOfFrame(); - 52fa: 0c db rcall .-2536 ; 0x4914 - 52fc: aa cf rjmp .-172 ; 0x5252 <__vector_125+0x2a> - USB_INT_Clear(USB_INT_BUSEVENTI_Resume); - - if (USB_Device_ConfigurationNumber) - USB_DeviceState = DEVICE_STATE_Configured; - else - USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Addressed : DEVICE_STATE_Powered; - 52fe: 83 e0 ldi r24, 0x03 ; 3 - 5300: ea cf rjmp .-44 ; 0x52d6 <__vector_125+0xae> - -00005302 : - -void CDC_Device_CreateBlockingStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, - FILE* const Stream) -{ - *Stream = (FILE)FDEV_SETUP_STREAM(CDC_Device_putchar, CDC_Device_getchar_Blocking, _FDEV_SETUP_RW); - fdev_set_udata(Stream, CDCInterfaceInfo); - 5302: cf 93 push r28 - 5304: df 93 push r29 - 5306: ec 01 movw r28, r24 - 5308: fc 01 movw r30, r24 - 530a: 70 96 adiw r30, 0x10 ; 16 - 530c: 8b e0 ldi r24, 0x0B ; 11 - 530e: df 01 movw r26, r30 - 5310: 1d 92 st X+, r1 - 5312: 8a 95 dec r24 - 5314: e9 f7 brne .-6 ; 0x5310 - 5316: 82 e0 ldi r24, 0x02 ; 2 - 5318: 8c 83 std Y+4, r24 ; 0x04 - 531a: 89 87 std Y+9, r24 ; 0x09 - 531c: 83 e0 ldi r24, 0x03 ; 3 - 531e: 8e 87 std Y+14, r24 ; 0x0e - 5320: 61 e0 ldi r22, 0x01 ; 1 - 5322: ce 01 movw r24, r28 - 5324: 01 96 adiw r24, 0x01 ; 1 - 5326: 03 de rcall .-1018 ; 0x4f2e - 5328: 81 11 cpse r24, r1 - 532a: 04 c0 rjmp .+8 ; 0x5334 - 532c: 80 e0 ldi r24, 0x00 ; 0 - 532e: df 91 pop r29 - 5330: cf 91 pop r28 - 5332: 08 95 ret - 5334: 61 e0 ldi r22, 0x01 ; 1 - 5336: ce 01 movw r24, r28 - 5338: 06 96 adiw r24, 0x06 ; 6 - 533a: f9 dd rcall .-1038 ; 0x4f2e - 533c: 88 23 and r24, r24 - 533e: b1 f3 breq .-20 ; 0x532c - 5340: 61 e0 ldi r22, 0x01 ; 1 - 5342: ce 01 movw r24, r28 - 5344: 0b 96 adiw r24, 0x0b ; 11 - 5346: df 91 pop r29 - 5348: cf 91 pop r28 - 534a: f1 cd rjmp .-1054 ; 0x4f2e - -0000534c : - 534c: cf 93 push r28 - 534e: df 93 push r29 - 5350: eb 01 movw r28, r22 - 5352: 20 91 40 2b lds r18, 0x2B40 - 5356: 24 30 cpi r18, 0x04 ; 4 - 5358: 21 f0 breq .+8 ; 0x5362 - 535a: 82 e0 ldi r24, 0x02 ; 2 - 535c: df 91 pop r29 - 535e: cf 91 pop r28 - 5360: 08 95 ret - 5362: fc 01 movw r30, r24 - 5364: 44 89 ldd r20, Z+20 ; 0x14 - 5366: 55 89 ldd r21, Z+21 ; 0x15 - 5368: 66 89 ldd r22, Z+22 ; 0x16 - 536a: 77 89 ldd r23, Z+23 ; 0x17 - 536c: 45 2b or r20, r21 - 536e: 46 2b or r20, r22 - 5370: 47 2b or r20, r23 - 5372: 99 f3 breq .-26 ; 0x535a - 5374: 81 81 ldd r24, Z+1 ; 0x01 - 5376: d1 dc rcall .-1630 ; 0x4d1a - 5378: fe 01 movw r30, r28 - 537a: 01 90 ld r0, Z+ - 537c: 00 20 and r0, r0 - 537e: e9 f7 brne .-6 ; 0x537a - 5380: bf 01 movw r22, r30 - 5382: 61 50 subi r22, 0x01 ; 1 - 5384: 71 09 sbc r23, r1 - 5386: 6c 1b sub r22, r28 - 5388: 7d 0b sbc r23, r29 - 538a: 40 e0 ldi r20, 0x00 ; 0 - 538c: 50 e0 ldi r21, 0x00 ; 0 - 538e: ce 01 movw r24, r28 - 5390: df 91 pop r29 - 5392: cf 91 pop r28 - 5394: d5 ca rjmp .-2646 ; 0x4940 - -00005396 : - 5396: ef 92 push r14 - 5398: ff 92 push r15 - 539a: 0f 93 push r16 - 539c: 1f 93 push r17 - 539e: cf 93 push r28 - 53a0: df 93 push r29 - 53a2: eb 01 movw r28, r22 - 53a4: 7a 01 movw r14, r20 - 53a6: 20 91 40 2b lds r18, 0x2B40 - 53aa: 24 30 cpi r18, 0x04 ; 4 - 53ac: 41 f0 breq .+16 ; 0x53be - 53ae: 82 e0 ldi r24, 0x02 ; 2 - 53b0: df 91 pop r29 - 53b2: cf 91 pop r28 - 53b4: 1f 91 pop r17 - 53b6: 0f 91 pop r16 - 53b8: ff 90 pop r15 - 53ba: ef 90 pop r14 - 53bc: 08 95 ret - 53be: fc 01 movw r30, r24 - 53c0: 04 89 ldd r16, Z+20 ; 0x14 - 53c2: 15 89 ldd r17, Z+21 ; 0x15 - 53c4: 26 89 ldd r18, Z+22 ; 0x16 - 53c6: 37 89 ldd r19, Z+23 ; 0x17 - 53c8: 01 2b or r16, r17 - 53ca: 02 2b or r16, r18 - 53cc: 03 2b or r16, r19 - 53ce: 79 f3 breq .-34 ; 0x53ae - 53d0: 81 81 ldd r24, Z+1 ; 0x01 - 53d2: a3 dc rcall .-1722 ; 0x4d1a - 53d4: 40 e0 ldi r20, 0x00 ; 0 - 53d6: 50 e0 ldi r21, 0x00 ; 0 - 53d8: b7 01 movw r22, r14 - 53da: ce 01 movw r24, r28 - 53dc: df 91 pop r29 - 53de: cf 91 pop r28 - 53e0: 1f 91 pop r17 - 53e2: 0f 91 pop r16 - 53e4: ff 90 pop r15 - 53e6: ef 90 pop r14 - 53e8: ab ca rjmp .-2730 ; 0x4940 - -000053ea : - 53ea: 0f 93 push r16 - 53ec: 1f 93 push r17 - 53ee: cf 93 push r28 - 53f0: df 93 push r29 - 53f2: 1f 92 push r1 - 53f4: cd b7 in r28, 0x3d ; 61 - 53f6: de b7 in r29, 0x3e ; 62 - 53f8: 20 91 40 2b lds r18, 0x2B40 - 53fc: 24 30 cpi r18, 0x04 ; 4 - 53fe: 39 f0 breq .+14 ; 0x540e - 5400: 82 e0 ldi r24, 0x02 ; 2 - 5402: 0f 90 pop r0 - 5404: df 91 pop r29 - 5406: cf 91 pop r28 - 5408: 1f 91 pop r17 - 540a: 0f 91 pop r16 - 540c: 08 95 ret - 540e: fc 01 movw r30, r24 - 5410: 04 89 ldd r16, Z+20 ; 0x14 - 5412: 15 89 ldd r17, Z+21 ; 0x15 - 5414: 26 89 ldd r18, Z+22 ; 0x16 - 5416: 37 89 ldd r19, Z+23 ; 0x17 - 5418: 01 2b or r16, r17 - 541a: 02 2b or r16, r18 - 541c: 03 2b or r16, r19 - 541e: 81 f3 breq .-32 ; 0x5400 - 5420: 81 81 ldd r24, Z+1 ; 0x01 - 5422: 69 83 std Y+1, r22 ; 0x01 - 5424: 7a dc rcall .-1804 ; 0x4d1a - 5426: 20 91 49 2b lds r18, 0x2B49 - 542a: 30 91 4a 2b lds r19, 0x2B4A - 542e: f9 01 movw r30, r18 - 5430: ef 5b subi r30, 0xBF ; 191 - 5432: ff 4f sbci r31, 0xFF ; 255 - 5434: 90 81 ld r25, Z - 5436: 31 97 sbiw r30, 0x01 ; 1 - 5438: 80 81 ld r24, Z - 543a: 69 81 ldd r22, Y+1 ; 0x01 - 543c: 98 17 cp r25, r24 - 543e: 30 f0 brcs .+12 ; 0x544c - 5440: 69 83 std Y+1, r22 ; 0x01 - 5442: 23 dc rcall .-1978 ; 0x4c8a - 5444: 2e de rcall .-932 ; 0x50a2 - 5446: 69 81 ldd r22, Y+1 ; 0x01 - 5448: 81 11 cpse r24, r1 - 544a: db cf rjmp .-74 ; 0x5402 - 544c: 86 2f mov r24, r22 - 544e: 55 dc rcall .-1878 ; 0x4cfa - 5450: 80 e0 ldi r24, 0x00 ; 0 - 5452: d7 cf rjmp .-82 ; 0x5402 - -00005454 : - 5454: cf 93 push r28 - 5456: df 93 push r29 - 5458: 20 91 40 2b lds r18, 0x2B40 - 545c: 24 30 cpi r18, 0x04 ; 4 - 545e: 21 f0 breq .+8 ; 0x5468 - 5460: 82 e0 ldi r24, 0x02 ; 2 - 5462: df 91 pop r29 - 5464: cf 91 pop r28 - 5466: 08 95 ret - 5468: fc 01 movw r30, r24 - 546a: 44 89 ldd r20, Z+20 ; 0x14 - 546c: 55 89 ldd r21, Z+21 ; 0x15 - 546e: 66 89 ldd r22, Z+22 ; 0x16 - 5470: 77 89 ldd r23, Z+23 ; 0x17 - 5472: 45 2b or r20, r21 - 5474: 46 2b or r20, r22 - 5476: 47 2b or r20, r23 - 5478: 99 f3 breq .-26 ; 0x5460 - 547a: 81 81 ldd r24, Z+1 ; 0x01 - 547c: 4e dc rcall .-1892 ; 0x4d1a - 547e: 80 91 4d 2b lds r24, 0x2B4D - 5482: 20 91 49 2b lds r18, 0x2B49 - 5486: 30 91 4a 2b lds r19, 0x2B4A - 548a: f9 01 movw r30, r18 - 548c: 87 fd sbrc r24, 7 - 548e: 1b c0 rjmp .+54 ; 0x54c6 - 5490: e0 5c subi r30, 0xC0 ; 192 - 5492: ff 4f sbci r31, 0xFF ; 255 - 5494: 80 81 ld r24, Z - 5496: 31 96 adiw r30, 0x01 ; 1 - 5498: 40 81 ld r20, Z - 549a: 90 e0 ldi r25, 0x00 ; 0 - 549c: 84 1b sub r24, r20 - 549e: 91 09 sbc r25, r1 - 54a0: 89 2b or r24, r25 - 54a2: 11 f4 brne .+4 ; 0x54a8 - 54a4: 80 e0 ldi r24, 0x00 ; 0 - 54a6: dd cf rjmp .-70 ; 0x5462 - 54a8: f9 01 movw r30, r18 - 54aa: ef 5b subi r30, 0xBF ; 191 - 54ac: ff 4f sbci r31, 0xFF ; 255 - 54ae: d0 81 ld r29, Z - 54b0: 31 97 sbiw r30, 0x01 ; 1 - 54b2: c0 81 ld r28, Z - 54b4: ea db rcall .-2092 ; 0x4c8a - 54b6: dc 17 cp r29, r28 - 54b8: a8 f3 brcs .-22 ; 0x54a4 - 54ba: f3 dd rcall .-1050 ; 0x50a2 - 54bc: 81 11 cpse r24, r1 - 54be: d1 cf rjmp .-94 ; 0x5462 - 54c0: e4 db rcall .-2104 ; 0x4c8a - 54c2: 80 e0 ldi r24, 0x00 ; 0 - 54c4: ce cf rjmp .-100 ; 0x5462 - 54c6: ef 5b subi r30, 0xBF ; 191 - 54c8: ff 4f sbci r31, 0xFF ; 255 - 54ca: 80 81 ld r24, Z - 54cc: 90 e0 ldi r25, 0x00 ; 0 - 54ce: e8 cf rjmp .-48 ; 0x54a0 - -000054d0 : - 54d0: cf 93 push r28 - 54d2: df 93 push r29 - 54d4: ec 01 movw r28, r24 - 54d6: 80 91 40 2b lds r24, 0x2B40 - 54da: 84 30 cpi r24, 0x04 ; 4 - 54dc: 19 f0 breq .+6 ; 0x54e4 - 54de: df 91 pop r29 - 54e0: cf 91 pop r28 - 54e2: 08 95 ret - 54e4: 4c 89 ldd r20, Y+20 ; 0x14 - 54e6: 5d 89 ldd r21, Y+21 ; 0x15 - 54e8: 6e 89 ldd r22, Y+22 ; 0x16 - 54ea: 7f 89 ldd r23, Y+23 ; 0x17 - 54ec: 45 2b or r20, r21 - 54ee: 46 2b or r20, r22 - 54f0: 47 2b or r20, r23 - 54f2: a9 f3 breq .-22 ; 0x54de - 54f4: 89 81 ldd r24, Y+1 ; 0x01 - 54f6: 11 dc rcall .-2014 ; 0x4d1a - 54f8: 49 dc rcall .-1902 ; 0x4d8c - 54fa: 88 23 and r24, r24 - 54fc: 81 f3 breq .-32 ; 0x54de - 54fe: ce 01 movw r24, r28 - 5500: df 91 pop r29 - 5502: cf 91 pop r28 - 5504: a7 cf rjmp .-178 ; 0x5454 - -00005506 : - 5506: cf 93 push r28 - 5508: df 93 push r29 - 550a: 20 91 40 2b lds r18, 0x2B40 - 550e: 24 30 cpi r18, 0x04 ; 4 - 5510: a9 f5 brne .+106 ; 0x557c - 5512: fc 01 movw r30, r24 - 5514: 44 89 ldd r20, Z+20 ; 0x14 - 5516: 55 89 ldd r21, Z+21 ; 0x15 - 5518: 66 89 ldd r22, Z+22 ; 0x16 - 551a: 77 89 ldd r23, Z+23 ; 0x17 - 551c: 45 2b or r20, r21 - 551e: 46 2b or r20, r22 - 5520: 47 2b or r20, r23 - 5522: 61 f1 breq .+88 ; 0x557c - 5524: 86 81 ldd r24, Z+6 ; 0x06 - 5526: f9 db rcall .-2062 ; 0x4d1a - 5528: 3d dc rcall .-1926 ; 0x4da4 - 552a: 88 23 and r24, r24 - 552c: 39 f1 breq .+78 ; 0x557c - 552e: 80 91 4d 2b lds r24, 0x2B4D - 5532: 40 91 49 2b lds r20, 0x2B49 - 5536: 50 91 4a 2b lds r21, 0x2B4A - 553a: fa 01 movw r30, r20 - 553c: 87 fd sbrc r24, 7 - 553e: 3a c0 rjmp .+116 ; 0x55b4 - 5540: e0 5c subi r30, 0xC0 ; 192 - 5542: ff 4f sbci r31, 0xFF ; 255 - 5544: 80 81 ld r24, Z - 5546: 31 96 adiw r30, 0x01 ; 1 - 5548: 20 81 ld r18, Z - 554a: 90 e0 ldi r25, 0x00 ; 0 - 554c: 82 1b sub r24, r18 - 554e: 91 09 sbc r25, r1 - 5550: 89 2b or r24, r25 - 5552: c9 f4 brne .+50 ; 0x5586 - 5554: cf ef ldi r28, 0xFF ; 255 - 5556: df ef ldi r29, 0xFF ; 255 - 5558: 80 91 4d 2b lds r24, 0x2B4D - 555c: fa 01 movw r30, r20 - 555e: 87 fd sbrc r24, 7 - 5560: 1e c0 rjmp .+60 ; 0x559e - 5562: e0 5c subi r30, 0xC0 ; 192 - 5564: ff 4f sbci r31, 0xFF ; 255 - 5566: 20 81 ld r18, Z - 5568: 31 96 adiw r30, 0x01 ; 1 - 556a: 80 81 ld r24, Z - 556c: 30 e0 ldi r19, 0x00 ; 0 - 556e: 28 1b sub r18, r24 - 5570: 31 09 sbc r19, r1 - 5572: d9 f0 breq .+54 ; 0x55aa - 5574: ce 01 movw r24, r28 - 5576: df 91 pop r29 - 5578: cf 91 pop r28 - 557a: 08 95 ret - 557c: 8f ef ldi r24, 0xFF ; 255 - 557e: 9f ef ldi r25, 0xFF ; 255 - 5580: df 91 pop r29 - 5582: cf 91 pop r28 - 5584: 08 95 ret - 5586: a9 db rcall .-2222 ; 0x4cda - 5588: c8 2f mov r28, r24 - 558a: d0 e0 ldi r29, 0x00 ; 0 - 558c: 40 91 49 2b lds r20, 0x2B49 - 5590: 50 91 4a 2b lds r21, 0x2B4A - 5594: 80 91 4d 2b lds r24, 0x2B4D - 5598: fa 01 movw r30, r20 - 559a: 87 ff sbrs r24, 7 - 559c: e2 cf rjmp .-60 ; 0x5562 - 559e: ef 5b subi r30, 0xBF ; 191 - 55a0: ff 4f sbci r31, 0xFF ; 255 - 55a2: 20 81 ld r18, Z - 55a4: 30 e0 ldi r19, 0x00 ; 0 - 55a6: 23 2b or r18, r19 - 55a8: 29 f7 brne .-54 ; 0x5574 - 55aa: 88 db rcall .-2288 ; 0x4cbc - 55ac: ce 01 movw r24, r28 - 55ae: df 91 pop r29 - 55b0: cf 91 pop r28 - 55b2: 08 95 ret - 55b4: ef 5b subi r30, 0xBF ; 191 - 55b6: ff 4f sbci r31, 0xFF ; 255 - 55b8: 80 81 ld r24, Z - 55ba: 90 e0 ldi r25, 0x00 ; 0 - 55bc: c9 cf rjmp .-110 ; 0x5550 - -000055be : - return ReceivedByte; -} -#endif - -void CDC_Device_Event_Stub(void) -{ - 55be: 08 95 ret - -000055c0 : -#define __INCLUDE_FROM_CDC_DRIVER -#define __INCLUDE_FROM_CDC_DEVICE_C -#include "CDCClassDevice.h" - -void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) -{ - 55c0: ff 92 push r15 - 55c2: 0f 93 push r16 - 55c4: 1f 93 push r17 - 55c6: cf 93 push r28 - 55c8: df 93 push r29 - 55ca: ec 01 movw r28, r24 - if (!(Endpoint_IsSETUPReceived())) - 55cc: 04 dc rcall .-2040 ; 0x4dd6 - 55ce: 88 23 and r24, r24 - 55d0: 49 f0 breq .+18 ; 0x55e4 - return; - - if (USB_ControlRequest.wIndex != CDCInterfaceInfo->Config.ControlInterfaceNumber) - 55d2: 88 81 ld r24, Y - 55d4: 90 e0 ldi r25, 0x00 ; 0 - 55d6: 20 91 45 2b lds r18, 0x2B45 - 55da: 30 91 46 2b lds r19, 0x2B46 - 55de: 28 17 cp r18, r24 - 55e0: 39 07 cpc r19, r25 - 55e2: 31 f0 breq .+12 ; 0x55f0 - EVENT_CDC_Device_BreakSent(CDCInterfaceInfo, (uint8_t)USB_ControlRequest.wValue); - } - - break; - } -} - 55e4: df 91 pop r29 - 55e6: cf 91 pop r28 - 55e8: 1f 91 pop r17 - 55ea: 0f 91 pop r16 - 55ec: ff 90 pop r15 - 55ee: 08 95 ret - return; - - if (USB_ControlRequest.wIndex != CDCInterfaceInfo->Config.ControlInterfaceNumber) - return; - - switch (USB_ControlRequest.bRequest) - 55f0: 80 91 42 2b lds r24, 0x2B42 - 55f4: 81 32 cpi r24, 0x21 ; 33 - 55f6: 09 f4 brne .+2 ; 0x55fa - 55f8: 48 c0 rjmp .+144 ; 0x568a - 55fa: a0 f0 brcs .+40 ; 0x5624 - 55fc: 82 32 cpi r24, 0x22 ; 34 - 55fe: 09 f4 brne .+2 ; 0x5602 - 5600: 65 c0 rjmp .+202 ; 0x56cc - 5602: 83 32 cpi r24, 0x23 ; 35 - 5604: 79 f7 brne .-34 ; 0x55e4 - EVENT_CDC_Device_ControLineStateChanged(CDCInterfaceInfo); - } - - break; - case CDC_REQ_SendBreak: - if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) - 5606: 80 91 41 2b lds r24, 0x2B41 - 560a: 81 32 cpi r24, 0x21 ; 33 - 560c: 59 f7 brne .-42 ; 0x55e4 - { - Endpoint_ClearSETUP(); - 560e: fc db rcall .-2056 ; 0x4e08 - Endpoint_ClearStatusStage(); - 5610: 32 dd rcall .-1436 ; 0x5076 - - EVENT_CDC_Device_BreakSent(CDCInterfaceInfo, (uint8_t)USB_ControlRequest.wValue); - 5612: 60 91 43 2b lds r22, 0x2B43 - 5616: ce 01 movw r24, r28 - } - - break; - } -} - 5618: df 91 pop r29 - 561a: cf 91 pop r28 - 561c: 1f 91 pop r17 - 561e: 0f 91 pop r16 - 5620: ff 90 pop r15 - if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) - { - Endpoint_ClearSETUP(); - Endpoint_ClearStatusStage(); - - EVENT_CDC_Device_BreakSent(CDCInterfaceInfo, (uint8_t)USB_ControlRequest.wValue); - 5622: cd cf rjmp .-102 ; 0x55be - return; - - if (USB_ControlRequest.wIndex != CDCInterfaceInfo->Config.ControlInterfaceNumber) - return; - - switch (USB_ControlRequest.bRequest) - 5624: 80 32 cpi r24, 0x20 ; 32 - 5626: f1 f6 brne .-68 ; 0x55e4 - Endpoint_ClearStatusStage(); - } - - break; - case CDC_REQ_SetLineEncoding: - if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) - 5628: 80 91 41 2b lds r24, 0x2B41 - 562c: 81 32 cpi r24, 0x21 ; 33 - 562e: d1 f6 brne .-76 ; 0x55e4 - { - Endpoint_ClearSETUP(); - 5630: eb db rcall .-2090 ; 0x4e08 - - while (!(Endpoint_IsOUTReceived())) - 5632: 04 c0 rjmp .+8 ; 0x563c - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - 5634: 80 91 40 2b lds r24, 0x2B40 - 5638: 88 23 and r24, r24 - 563a: a1 f2 breq .-88 ; 0x55e4 - case CDC_REQ_SetLineEncoding: - if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) - { - Endpoint_ClearSETUP(); - - while (!(Endpoint_IsOUTReceived())) - 563c: b3 db rcall .-2202 ; 0x4da4 - 563e: 88 23 and r24, r24 - 5640: c9 f3 breq .-14 ; 0x5634 - * \return Next four bytes in the currently selected endpoint's FIFO buffer. - */ - static inline uint32_t Endpoint_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint32_t Endpoint_Read_32_LE(void) - { - uint32_t Byte0 = Endpoint_Read_8(); - 5642: 4b db rcall .-2410 ; 0x4cda - 5644: 08 2f mov r16, r24 - uint32_t Byte1 = Endpoint_Read_8(); - 5646: 49 db rcall .-2414 ; 0x4cda - 5648: 18 2f mov r17, r24 - uint32_t Byte2 = Endpoint_Read_8(); - 564a: 47 db rcall .-2418 ; 0x4cda - 564c: f8 2e mov r15, r24 - uint32_t Byte3 = Endpoint_Read_8(); - 564e: 45 db rcall .-2422 ; 0x4cda - static inline uint32_t Endpoint_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint32_t Endpoint_Read_32_LE(void) - { - uint32_t Byte0 = Endpoint_Read_8(); - uint32_t Byte1 = Endpoint_Read_8(); - uint32_t Byte2 = Endpoint_Read_8(); - 5650: 4f 2d mov r20, r15 - 5652: 50 e0 ldi r21, 0x00 ; 0 - 5654: 60 e0 ldi r22, 0x00 ; 0 - 5656: 70 e0 ldi r23, 0x00 ; 0 - uint32_t Byte3 = Endpoint_Read_8(); - - return ((Byte3 << 24) | (Byte2 << 16) | (Byte1 << 8) | Byte0); - 5658: ba 01 movw r22, r20 - 565a: 55 27 eor r21, r21 - 565c: 44 27 eor r20, r20 - 565e: 78 2b or r23, r24 - 5660: 40 2b or r20, r16 - 5662: 51 2b or r21, r17 - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - - CDCInterfaceInfo->State.LineEncoding.BaudRateBPS = Endpoint_Read_32_LE(); - 5664: 4c 8b std Y+20, r20 ; 0x14 - 5666: 5d 8b std Y+21, r21 ; 0x15 - 5668: 6e 8b std Y+22, r22 ; 0x16 - 566a: 7f 8b std Y+23, r23 ; 0x17 - CDCInterfaceInfo->State.LineEncoding.CharFormat = Endpoint_Read_8(); - 566c: 36 db rcall .-2452 ; 0x4cda - 566e: 88 8f std Y+24, r24 ; 0x18 - CDCInterfaceInfo->State.LineEncoding.ParityType = Endpoint_Read_8(); - 5670: 34 db rcall .-2456 ; 0x4cda - 5672: 89 8f std Y+25, r24 ; 0x19 - CDCInterfaceInfo->State.LineEncoding.DataBits = Endpoint_Read_8(); - 5674: 32 db rcall .-2460 ; 0x4cda - 5676: 8a 8f std Y+26, r24 ; 0x1a - - Endpoint_ClearOUT(); - 5678: 21 db rcall .-2494 ; 0x4cbc - Endpoint_ClearStatusStage(); - 567a: fd dc rcall .-1542 ; 0x5076 - - EVENT_CDC_Device_LineEncodingChanged(CDCInterfaceInfo); - 567c: ce 01 movw r24, r28 - EVENT_CDC_Device_BreakSent(CDCInterfaceInfo, (uint8_t)USB_ControlRequest.wValue); - } - - break; - } -} - 567e: df 91 pop r29 - 5680: cf 91 pop r28 - 5682: 1f 91 pop r17 - 5684: 0f 91 pop r16 - 5686: ff 90 pop r15 - CDCInterfaceInfo->State.LineEncoding.DataBits = Endpoint_Read_8(); - - Endpoint_ClearOUT(); - Endpoint_ClearStatusStage(); - - EVENT_CDC_Device_LineEncodingChanged(CDCInterfaceInfo); - 5688: 9a cf rjmp .-204 ; 0x55be - return; - - switch (USB_ControlRequest.bRequest) - { - case CDC_REQ_GetLineEncoding: - if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) - 568a: 80 91 41 2b lds r24, 0x2B41 - 568e: 81 3a cpi r24, 0xA1 ; 161 - 5690: 09 f0 breq .+2 ; 0x5694 - 5692: a8 cf rjmp .-176 ; 0x55e4 - { - Endpoint_ClearSETUP(); - 5694: b9 db rcall .-2190 ; 0x4e08 - - while (!(Endpoint_IsINReady())); - 5696: 7a db rcall .-2316 ; 0x4d8c - 5698: 88 23 and r24, r24 - 569a: e9 f3 breq .-6 ; 0x5696 - - Endpoint_Write_32_LE(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS); - 569c: 8c 89 ldd r24, Y+20 ; 0x14 - 569e: fd 88 ldd r15, Y+21 ; 0x15 - 56a0: 0e 89 ldd r16, Y+22 ; 0x16 - 56a2: 1f 89 ldd r17, Y+23 ; 0x17 - * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. - */ - static inline void Endpoint_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE; - static inline void Endpoint_Write_32_LE(const uint32_t Data) - { - Endpoint_Write_8(Data & 0xFF); - 56a4: 2a db rcall .-2476 ; 0x4cfa - Endpoint_Write_8(Data >> 8); - 56a6: 8f 2d mov r24, r15 - 56a8: 28 db rcall .-2480 ; 0x4cfa - Endpoint_Write_8(Data >> 16); - 56aa: 80 2f mov r24, r16 - 56ac: 26 db rcall .-2484 ; 0x4cfa - Endpoint_Write_8(Data >> 24); - 56ae: 81 2f mov r24, r17 - 56b0: 24 db rcall .-2488 ; 0x4cfa - Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.CharFormat); - 56b2: 88 8d ldd r24, Y+24 ; 0x18 - 56b4: 22 db rcall .-2492 ; 0x4cfa - Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.ParityType); - 56b6: 89 8d ldd r24, Y+25 ; 0x19 - 56b8: 20 db rcall .-2496 ; 0x4cfa - Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.DataBits); - 56ba: 8a 8d ldd r24, Y+26 ; 0x1a - 56bc: 1e db rcall .-2500 ; 0x4cfa - - Endpoint_ClearIN(); - 56be: e5 da rcall .-2614 ; 0x4c8a - EVENT_CDC_Device_BreakSent(CDCInterfaceInfo, (uint8_t)USB_ControlRequest.wValue); - } - - break; - } -} - 56c0: df 91 pop r29 - 56c2: cf 91 pop r28 - 56c4: 1f 91 pop r17 - 56c6: 0f 91 pop r16 - 56c8: ff 90 pop r15 - Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.CharFormat); - Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.ParityType); - Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.DataBits); - - Endpoint_ClearIN(); - Endpoint_ClearStatusStage(); - 56ca: d5 cc rjmp .-1622 ; 0x5076 - EVENT_CDC_Device_LineEncodingChanged(CDCInterfaceInfo); - } - - break; - case CDC_REQ_SetControlLineState: - if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) - 56cc: 80 91 41 2b lds r24, 0x2B41 - 56d0: 81 32 cpi r24, 0x21 ; 33 - 56d2: 09 f0 breq .+2 ; 0x56d6 - 56d4: 87 cf rjmp .-242 ; 0x55e4 - { - Endpoint_ClearSETUP(); - 56d6: 98 db rcall .-2256 ; 0x4e08 - Endpoint_ClearStatusStage(); - 56d8: ce dc rcall .-1636 ; 0x5076 - - CDCInterfaceInfo->State.ControlLineStates.HostToDevice = USB_ControlRequest.wValue; - 56da: 80 91 43 2b lds r24, 0x2B43 - 56de: 90 91 44 2b lds r25, 0x2B44 - 56e2: 88 8b std Y+16, r24 ; 0x10 - 56e4: 99 8b std Y+17, r25 ; 0x11 - - EVENT_CDC_Device_ControLineStateChanged(CDCInterfaceInfo); - 56e6: ce 01 movw r24, r28 - EVENT_CDC_Device_BreakSent(CDCInterfaceInfo, (uint8_t)USB_ControlRequest.wValue); - } - - break; - } -} - 56e8: df 91 pop r29 - 56ea: cf 91 pop r28 - 56ec: 1f 91 pop r17 - 56ee: 0f 91 pop r16 - 56f0: ff 90 pop r15 - Endpoint_ClearSETUP(); - Endpoint_ClearStatusStage(); - - CDCInterfaceInfo->State.ControlLineStates.HostToDevice = USB_ControlRequest.wValue; - - EVENT_CDC_Device_ControLineStateChanged(CDCInterfaceInfo); - 56f2: 65 cf rjmp .-310 ; 0x55be - -000056f4 <__tablejump2__>: - 56f4: ee 0f add r30, r30 - 56f6: ff 1f adc r31, r31 - -000056f8 <__tablejump__>: - 56f8: 05 90 lpm r0, Z+ - 56fa: f4 91 lpm r31, Z - 56fc: e0 2d mov r30, r0 - 56fe: 09 94 ijmp - -00005700 <__mulshisi3>: - 5700: b7 ff sbrs r27, 7 - 5702: 04 c0 rjmp .+8 ; 0x570c <__muluhisi3> - -00005704 <__mulohisi3>: - 5704: 03 d0 rcall .+6 ; 0x570c <__muluhisi3> - 5706: 82 1b sub r24, r18 - 5708: 93 0b sbc r25, r19 - 570a: 08 95 ret - -0000570c <__muluhisi3>: - 570c: 09 d0 rcall .+18 ; 0x5720 <__umulhisi3> - 570e: a5 9f mul r26, r21 - 5710: 90 0d add r25, r0 - 5712: b4 9f mul r27, r20 - 5714: 90 0d add r25, r0 - 5716: a4 9f mul r26, r20 - 5718: 80 0d add r24, r0 - 571a: 91 1d adc r25, r1 - 571c: 11 24 eor r1, r1 - 571e: 08 95 ret - -00005720 <__umulhisi3>: - 5720: a2 9f mul r26, r18 - 5722: b0 01 movw r22, r0 - 5724: b3 9f mul r27, r19 - 5726: c0 01 movw r24, r0 - 5728: a3 9f mul r26, r19 - 572a: 70 0d add r23, r0 - 572c: 81 1d adc r24, r1 - 572e: 11 24 eor r1, r1 - 5730: 91 1d adc r25, r1 - 5732: b2 9f mul r27, r18 - 5734: 70 0d add r23, r0 - 5736: 81 1d adc r24, r1 - 5738: 11 24 eor r1, r1 - 573a: 91 1d adc r25, r1 - 573c: 08 95 ret - -0000573e : - 573e: 8f 92 push r8 - 5740: 9f 92 push r9 - 5742: af 92 push r10 - 5744: bf 92 push r11 - 5746: cf 92 push r12 - 5748: df 92 push r13 - 574a: ef 92 push r14 - 574c: ff 92 push r15 - 574e: cf 93 push r28 - 5750: df 93 push r29 - 5752: ec 01 movw r28, r24 - 5754: 68 81 ld r22, Y - 5756: 79 81 ldd r23, Y+1 ; 0x01 - 5758: 8a 81 ldd r24, Y+2 ; 0x02 - 575a: 9b 81 ldd r25, Y+3 ; 0x03 - 575c: 61 15 cp r22, r1 - 575e: 71 05 cpc r23, r1 - 5760: 81 05 cpc r24, r1 - 5762: 91 05 cpc r25, r1 - 5764: 21 f4 brne .+8 ; 0x576e - 5766: 64 e2 ldi r22, 0x24 ; 36 - 5768: 79 ed ldi r23, 0xD9 ; 217 - 576a: 8b e5 ldi r24, 0x5B ; 91 - 576c: 97 e0 ldi r25, 0x07 ; 7 - 576e: 2d e1 ldi r18, 0x1D ; 29 - 5770: 33 ef ldi r19, 0xF3 ; 243 - 5772: 41 e0 ldi r20, 0x01 ; 1 - 5774: 50 e0 ldi r21, 0x00 ; 0 - 5776: 48 d3 rcall .+1680 ; 0x5e08 <__divmodsi4> - 5778: 49 01 movw r8, r18 - 577a: 5a 01 movw r10, r20 - 577c: 9b 01 movw r18, r22 - 577e: ac 01 movw r20, r24 - 5780: a7 ea ldi r26, 0xA7 ; 167 - 5782: b1 e4 ldi r27, 0x41 ; 65 - 5784: c3 df rcall .-122 ; 0x570c <__muluhisi3> - 5786: 6b 01 movw r12, r22 - 5788: 7c 01 movw r14, r24 - 578a: ac ee ldi r26, 0xEC ; 236 - 578c: b4 ef ldi r27, 0xF4 ; 244 - 578e: a5 01 movw r20, r10 - 5790: 94 01 movw r18, r8 - 5792: b8 df rcall .-144 ; 0x5704 <__mulohisi3> - 5794: c6 0e add r12, r22 - 5796: d7 1e adc r13, r23 - 5798: e8 1e adc r14, r24 - 579a: f9 1e adc r15, r25 - 579c: f7 fe sbrs r15, 7 - 579e: 06 c0 rjmp .+12 ; 0x57ac - 57a0: 81 e0 ldi r24, 0x01 ; 1 - 57a2: c8 1a sub r12, r24 - 57a4: d1 08 sbc r13, r1 - 57a6: e1 08 sbc r14, r1 - 57a8: 80 e8 ldi r24, 0x80 ; 128 - 57aa: f8 0a sbc r15, r24 - 57ac: c8 82 st Y, r12 - 57ae: d9 82 std Y+1, r13 ; 0x01 - 57b0: ea 82 std Y+2, r14 ; 0x02 - 57b2: fb 82 std Y+3, r15 ; 0x03 - 57b4: c6 01 movw r24, r12 - 57b6: 9f 77 andi r25, 0x7F ; 127 - 57b8: df 91 pop r29 - 57ba: cf 91 pop r28 - 57bc: ff 90 pop r15 - 57be: ef 90 pop r14 - 57c0: df 90 pop r13 - 57c2: cf 90 pop r12 - 57c4: bf 90 pop r11 - 57c6: af 90 pop r10 - 57c8: 9f 90 pop r9 - 57ca: 8f 90 pop r8 - 57cc: 08 95 ret - -000057ce : - 57ce: b7 cf rjmp .-146 ; 0x573e - -000057d0 : - 57d0: 8c e1 ldi r24, 0x1C ; 28 - 57d2: 90 e2 ldi r25, 0x20 ; 32 - 57d4: b4 cf rjmp .-152 ; 0x573e - -000057d6 : - 57d6: a0 e0 ldi r26, 0x00 ; 0 - 57d8: b0 e0 ldi r27, 0x00 ; 0 - 57da: 80 93 1c 20 sts 0x201C, r24 - 57de: 90 93 1d 20 sts 0x201D, r25 - 57e2: a0 93 1e 20 sts 0x201E, r26 - 57e6: b0 93 1f 20 sts 0x201F, r27 - 57ea: 08 95 ret - -000057ec : - 57ec: fb 01 movw r30, r22 - 57ee: dc 01 movw r26, r24 - 57f0: 02 c0 rjmp .+4 ; 0x57f6 - 57f2: 05 90 lpm r0, Z+ - 57f4: 0d 92 st X+, r0 - 57f6: 41 50 subi r20, 0x01 ; 1 - 57f8: 50 40 sbci r21, 0x00 ; 0 - 57fa: d8 f7 brcc .-10 ; 0x57f2 - 57fc: 08 95 ret - -000057fe : - 57fe: fb 01 movw r30, r22 - 5800: dc 01 movw r26, r24 - 5802: 8d 91 ld r24, X+ - 5804: 05 90 lpm r0, Z+ - 5806: 80 19 sub r24, r0 - 5808: 01 10 cpse r0, r1 - 580a: d9 f3 breq .-10 ; 0x5802 - 580c: 99 0b sbc r25, r25 - 580e: 08 95 ret - -00005810 : - 5810: fb 01 movw r30, r22 - 5812: dc 01 movw r26, r24 - 5814: 0d 90 ld r0, X+ - 5816: 00 20 and r0, r0 - 5818: e9 f7 brne .-6 ; 0x5814 - 581a: 11 97 sbiw r26, 0x01 ; 1 - 581c: 41 50 subi r20, 0x01 ; 1 - 581e: 50 40 sbci r21, 0x00 ; 0 - 5820: 28 f0 brcs .+10 ; 0x582c - 5822: 05 90 lpm r0, Z+ - 5824: 00 20 and r0, r0 - 5826: 0d 92 st X+, r0 - 5828: c9 f7 brne .-14 ; 0x581c - 582a: 08 95 ret - 582c: 1c 92 st X, r1 - 582e: 08 95 ret - -00005830 : - 5830: fb 01 movw r30, r22 - 5832: dc 01 movw r26, r24 - 5834: 41 50 subi r20, 0x01 ; 1 - 5836: 50 40 sbci r21, 0x00 ; 0 - 5838: 48 f0 brcs .+18 ; 0x584c - 583a: 05 90 lpm r0, Z+ - 583c: 0d 92 st X+, r0 - 583e: 00 20 and r0, r0 - 5840: c9 f7 brne .-14 ; 0x5834 - 5842: 01 c0 rjmp .+2 ; 0x5846 - 5844: 1d 92 st X+, r1 - 5846: 41 50 subi r20, 0x01 ; 1 - 5848: 50 40 sbci r21, 0x00 ; 0 - 584a: e0 f7 brcc .-8 ; 0x5844 - 584c: 08 95 ret - -0000584e : - 584e: fb 01 movw r30, r22 - 5850: dc 01 movw r26, r24 - 5852: 02 c0 rjmp .+4 ; 0x5858 - 5854: 01 90 ld r0, Z+ - 5856: 0d 92 st X+, r0 - 5858: 41 50 subi r20, 0x01 ; 1 - 585a: 50 40 sbci r21, 0x00 ; 0 - 585c: d8 f7 brcc .-10 ; 0x5854 - 585e: 08 95 ret - -00005860 : - 5860: dc 01 movw r26, r24 - 5862: 01 c0 rjmp .+2 ; 0x5866 - 5864: 6d 93 st X+, r22 - 5866: 41 50 subi r20, 0x01 ; 1 - 5868: 50 40 sbci r21, 0x00 ; 0 - 586a: e0 f7 brcc .-8 ; 0x5864 - 586c: 08 95 ret - -0000586e : - 586e: ae e0 ldi r26, 0x0E ; 14 - 5870: b0 e0 ldi r27, 0x00 ; 0 - 5872: ec e3 ldi r30, 0x3C ; 60 - 5874: fc e2 ldi r31, 0x2C ; 44 - 5876: f2 c2 rjmp .+1508 ; 0x5e5c <__prologue_saves__+0x1c> - 5878: 0d 89 ldd r16, Y+21 ; 0x15 - 587a: 1e 89 ldd r17, Y+22 ; 0x16 - 587c: 8f 89 ldd r24, Y+23 ; 0x17 - 587e: 98 8d ldd r25, Y+24 ; 0x18 - 5880: 2e e0 ldi r18, 0x0E ; 14 - 5882: 2c 83 std Y+4, r18 ; 0x04 - 5884: 09 83 std Y+1, r16 ; 0x01 - 5886: 1a 83 std Y+2, r17 ; 0x02 - 5888: 97 ff sbrs r25, 7 - 588a: 02 c0 rjmp .+4 ; 0x5890 - 588c: 80 e0 ldi r24, 0x00 ; 0 - 588e: 90 e8 ldi r25, 0x80 ; 128 - 5890: 01 97 sbiw r24, 0x01 ; 1 - 5892: 8d 83 std Y+5, r24 ; 0x05 - 5894: 9e 83 std Y+6, r25 ; 0x06 - 5896: ae 01 movw r20, r28 - 5898: 45 5e subi r20, 0xE5 ; 229 - 589a: 5f 4f sbci r21, 0xFF ; 255 - 589c: 69 8d ldd r22, Y+25 ; 0x19 - 589e: 7a 8d ldd r23, Y+26 ; 0x1a - 58a0: ce 01 movw r24, r28 - 58a2: 01 96 adiw r24, 0x01 ; 1 - 58a4: 11 d0 rcall .+34 ; 0x58c8 - 58a6: 4d 81 ldd r20, Y+5 ; 0x05 - 58a8: 5e 81 ldd r21, Y+6 ; 0x06 - 58aa: 57 fd sbrc r21, 7 - 58ac: 0a c0 rjmp .+20 ; 0x58c2 - 58ae: 2f 81 ldd r18, Y+7 ; 0x07 - 58b0: 38 85 ldd r19, Y+8 ; 0x08 - 58b2: 42 17 cp r20, r18 - 58b4: 53 07 cpc r21, r19 - 58b6: 0c f4 brge .+2 ; 0x58ba - 58b8: 9a 01 movw r18, r20 - 58ba: f8 01 movw r30, r16 - 58bc: e2 0f add r30, r18 - 58be: f3 1f adc r31, r19 - 58c0: 10 82 st Z, r1 - 58c2: 2e 96 adiw r28, 0x0e ; 14 - 58c4: e4 e0 ldi r30, 0x04 ; 4 - 58c6: e3 c2 rjmp .+1478 ; 0x5e8e <__epilogue_restores__+0x1c> - -000058c8 : - 58c8: ac e0 ldi r26, 0x0C ; 12 - 58ca: b0 e0 ldi r27, 0x00 ; 0 - 58cc: e9 e6 ldi r30, 0x69 ; 105 - 58ce: fc e2 ldi r31, 0x2C ; 44 - 58d0: b7 c2 rjmp .+1390 ; 0x5e40 <__prologue_saves__> - 58d2: 7c 01 movw r14, r24 - 58d4: 6b 01 movw r12, r22 - 58d6: 8a 01 movw r16, r20 - 58d8: fc 01 movw r30, r24 - 58da: 16 82 std Z+6, r1 ; 0x06 - 58dc: 17 82 std Z+7, r1 ; 0x07 - 58de: 83 81 ldd r24, Z+3 ; 0x03 - 58e0: 81 ff sbrs r24, 1 - 58e2: b0 c1 rjmp .+864 ; 0x5c44 - 58e4: ce 01 movw r24, r28 - 58e6: 01 96 adiw r24, 0x01 ; 1 - 58e8: 4c 01 movw r8, r24 - 58ea: f7 01 movw r30, r14 - 58ec: 93 81 ldd r25, Z+3 ; 0x03 - 58ee: f6 01 movw r30, r12 - 58f0: 93 fd sbrc r25, 3 - 58f2: 85 91 lpm r24, Z+ - 58f4: 93 ff sbrs r25, 3 - 58f6: 81 91 ld r24, Z+ - 58f8: 6f 01 movw r12, r30 - 58fa: 88 23 and r24, r24 - 58fc: 09 f4 brne .+2 ; 0x5900 - 58fe: 9e c1 rjmp .+828 ; 0x5c3c - 5900: 85 32 cpi r24, 0x25 ; 37 - 5902: 39 f4 brne .+14 ; 0x5912 - 5904: 93 fd sbrc r25, 3 - 5906: 85 91 lpm r24, Z+ - 5908: 93 ff sbrs r25, 3 - 590a: 81 91 ld r24, Z+ - 590c: 6f 01 movw r12, r30 - 590e: 85 32 cpi r24, 0x25 ; 37 - 5910: 21 f4 brne .+8 ; 0x591a - 5912: b7 01 movw r22, r14 - 5914: 90 e0 ldi r25, 0x00 ; 0 - 5916: e8 d1 rcall .+976 ; 0x5ce8 - 5918: e8 cf rjmp .-48 ; 0x58ea - 591a: 51 2c mov r5, r1 - 591c: 31 2c mov r3, r1 - 591e: 20 e0 ldi r18, 0x00 ; 0 - 5920: 20 32 cpi r18, 0x20 ; 32 - 5922: a0 f4 brcc .+40 ; 0x594c - 5924: 8b 32 cpi r24, 0x2B ; 43 - 5926: 69 f0 breq .+26 ; 0x5942 - 5928: 30 f4 brcc .+12 ; 0x5936 - 592a: 80 32 cpi r24, 0x20 ; 32 - 592c: 59 f0 breq .+22 ; 0x5944 - 592e: 83 32 cpi r24, 0x23 ; 35 - 5930: 69 f4 brne .+26 ; 0x594c - 5932: 20 61 ori r18, 0x10 ; 16 - 5934: 2c c0 rjmp .+88 ; 0x598e - 5936: 8d 32 cpi r24, 0x2D ; 45 - 5938: 39 f0 breq .+14 ; 0x5948 - 593a: 80 33 cpi r24, 0x30 ; 48 - 593c: 39 f4 brne .+14 ; 0x594c - 593e: 21 60 ori r18, 0x01 ; 1 - 5940: 26 c0 rjmp .+76 ; 0x598e - 5942: 22 60 ori r18, 0x02 ; 2 - 5944: 24 60 ori r18, 0x04 ; 4 - 5946: 23 c0 rjmp .+70 ; 0x598e - 5948: 28 60 ori r18, 0x08 ; 8 - 594a: 21 c0 rjmp .+66 ; 0x598e - 594c: 27 fd sbrc r18, 7 - 594e: 27 c0 rjmp .+78 ; 0x599e - 5950: 30 ed ldi r19, 0xD0 ; 208 - 5952: 38 0f add r19, r24 - 5954: 3a 30 cpi r19, 0x0A ; 10 - 5956: 78 f4 brcc .+30 ; 0x5976 - 5958: 26 ff sbrs r18, 6 - 595a: 06 c0 rjmp .+12 ; 0x5968 - 595c: fa e0 ldi r31, 0x0A ; 10 - 595e: 5f 9e mul r5, r31 - 5960: 30 0d add r19, r0 - 5962: 11 24 eor r1, r1 - 5964: 53 2e mov r5, r19 - 5966: 13 c0 rjmp .+38 ; 0x598e - 5968: 8a e0 ldi r24, 0x0A ; 10 - 596a: 38 9e mul r3, r24 - 596c: 30 0d add r19, r0 - 596e: 11 24 eor r1, r1 - 5970: 33 2e mov r3, r19 - 5972: 20 62 ori r18, 0x20 ; 32 - 5974: 0c c0 rjmp .+24 ; 0x598e - 5976: 8e 32 cpi r24, 0x2E ; 46 - 5978: 21 f4 brne .+8 ; 0x5982 - 597a: 26 fd sbrc r18, 6 - 597c: 5f c1 rjmp .+702 ; 0x5c3c - 597e: 20 64 ori r18, 0x40 ; 64 - 5980: 06 c0 rjmp .+12 ; 0x598e - 5982: 8c 36 cpi r24, 0x6C ; 108 - 5984: 11 f4 brne .+4 ; 0x598a - 5986: 20 68 ori r18, 0x80 ; 128 - 5988: 02 c0 rjmp .+4 ; 0x598e - 598a: 88 36 cpi r24, 0x68 ; 104 - 598c: 41 f4 brne .+16 ; 0x599e - 598e: f6 01 movw r30, r12 - 5990: 93 fd sbrc r25, 3 - 5992: 85 91 lpm r24, Z+ - 5994: 93 ff sbrs r25, 3 - 5996: 81 91 ld r24, Z+ - 5998: 6f 01 movw r12, r30 - 599a: 81 11 cpse r24, r1 - 599c: c1 cf rjmp .-126 ; 0x5920 - 599e: 98 2f mov r25, r24 - 59a0: 9f 7d andi r25, 0xDF ; 223 - 59a2: 95 54 subi r25, 0x45 ; 69 - 59a4: 93 30 cpi r25, 0x03 ; 3 - 59a6: 28 f4 brcc .+10 ; 0x59b2 - 59a8: 0c 5f subi r16, 0xFC ; 252 - 59aa: 1f 4f sbci r17, 0xFF ; 255 - 59ac: ff e3 ldi r31, 0x3F ; 63 - 59ae: f9 83 std Y+1, r31 ; 0x01 - 59b0: 0d c0 rjmp .+26 ; 0x59cc - 59b2: 83 36 cpi r24, 0x63 ; 99 - 59b4: 31 f0 breq .+12 ; 0x59c2 - 59b6: 83 37 cpi r24, 0x73 ; 115 - 59b8: 71 f0 breq .+28 ; 0x59d6 - 59ba: 83 35 cpi r24, 0x53 ; 83 - 59bc: 09 f0 breq .+2 ; 0x59c0 - 59be: 57 c0 rjmp .+174 ; 0x5a6e - 59c0: 21 c0 rjmp .+66 ; 0x5a04 - 59c2: f8 01 movw r30, r16 - 59c4: 80 81 ld r24, Z - 59c6: 89 83 std Y+1, r24 ; 0x01 - 59c8: 0e 5f subi r16, 0xFE ; 254 - 59ca: 1f 4f sbci r17, 0xFF ; 255 - 59cc: 44 24 eor r4, r4 - 59ce: 43 94 inc r4 - 59d0: 51 2c mov r5, r1 - 59d2: 54 01 movw r10, r8 - 59d4: 14 c0 rjmp .+40 ; 0x59fe - 59d6: 38 01 movw r6, r16 - 59d8: f2 e0 ldi r31, 0x02 ; 2 - 59da: 6f 0e add r6, r31 - 59dc: 71 1c adc r7, r1 - 59de: f8 01 movw r30, r16 - 59e0: a0 80 ld r10, Z - 59e2: b1 80 ldd r11, Z+1 ; 0x01 - 59e4: 26 ff sbrs r18, 6 - 59e6: 03 c0 rjmp .+6 ; 0x59ee - 59e8: 65 2d mov r22, r5 - 59ea: 70 e0 ldi r23, 0x00 ; 0 - 59ec: 02 c0 rjmp .+4 ; 0x59f2 - 59ee: 6f ef ldi r22, 0xFF ; 255 - 59f0: 7f ef ldi r23, 0xFF ; 255 - 59f2: c5 01 movw r24, r10 - 59f4: 2c 87 std Y+12, r18 ; 0x0c - 59f6: 6d d1 rcall .+730 ; 0x5cd2 - 59f8: 2c 01 movw r4, r24 - 59fa: 83 01 movw r16, r6 - 59fc: 2c 85 ldd r18, Y+12 ; 0x0c - 59fe: 2f 77 andi r18, 0x7F ; 127 - 5a00: 22 2e mov r2, r18 - 5a02: 16 c0 rjmp .+44 ; 0x5a30 - 5a04: 38 01 movw r6, r16 - 5a06: f2 e0 ldi r31, 0x02 ; 2 - 5a08: 6f 0e add r6, r31 - 5a0a: 71 1c adc r7, r1 - 5a0c: f8 01 movw r30, r16 - 5a0e: a0 80 ld r10, Z - 5a10: b1 80 ldd r11, Z+1 ; 0x01 - 5a12: 26 ff sbrs r18, 6 - 5a14: 03 c0 rjmp .+6 ; 0x5a1c - 5a16: 65 2d mov r22, r5 - 5a18: 70 e0 ldi r23, 0x00 ; 0 - 5a1a: 02 c0 rjmp .+4 ; 0x5a20 - 5a1c: 6f ef ldi r22, 0xFF ; 255 - 5a1e: 7f ef ldi r23, 0xFF ; 255 - 5a20: c5 01 movw r24, r10 - 5a22: 2c 87 std Y+12, r18 ; 0x0c - 5a24: 4b d1 rcall .+662 ; 0x5cbc - 5a26: 2c 01 movw r4, r24 - 5a28: 2c 85 ldd r18, Y+12 ; 0x0c - 5a2a: 20 68 ori r18, 0x80 ; 128 - 5a2c: 22 2e mov r2, r18 - 5a2e: 83 01 movw r16, r6 - 5a30: 23 fc sbrc r2, 3 - 5a32: 19 c0 rjmp .+50 ; 0x5a66 - 5a34: 83 2d mov r24, r3 - 5a36: 90 e0 ldi r25, 0x00 ; 0 - 5a38: 48 16 cp r4, r24 - 5a3a: 59 06 cpc r5, r25 - 5a3c: a0 f4 brcc .+40 ; 0x5a66 - 5a3e: b7 01 movw r22, r14 - 5a40: 80 e2 ldi r24, 0x20 ; 32 - 5a42: 90 e0 ldi r25, 0x00 ; 0 - 5a44: 51 d1 rcall .+674 ; 0x5ce8 - 5a46: 3a 94 dec r3 - 5a48: f5 cf rjmp .-22 ; 0x5a34 - 5a4a: f5 01 movw r30, r10 - 5a4c: 27 fc sbrc r2, 7 - 5a4e: 85 91 lpm r24, Z+ - 5a50: 27 fe sbrs r2, 7 - 5a52: 81 91 ld r24, Z+ - 5a54: 5f 01 movw r10, r30 - 5a56: b7 01 movw r22, r14 - 5a58: 90 e0 ldi r25, 0x00 ; 0 - 5a5a: 46 d1 rcall .+652 ; 0x5ce8 - 5a5c: 31 10 cpse r3, r1 - 5a5e: 3a 94 dec r3 - 5a60: f1 e0 ldi r31, 0x01 ; 1 - 5a62: 4f 1a sub r4, r31 - 5a64: 51 08 sbc r5, r1 - 5a66: 41 14 cp r4, r1 - 5a68: 51 04 cpc r5, r1 - 5a6a: 79 f7 brne .-34 ; 0x5a4a - 5a6c: de c0 rjmp .+444 ; 0x5c2a - 5a6e: 84 36 cpi r24, 0x64 ; 100 - 5a70: 11 f0 breq .+4 ; 0x5a76 - 5a72: 89 36 cpi r24, 0x69 ; 105 - 5a74: 31 f5 brne .+76 ; 0x5ac2 - 5a76: f8 01 movw r30, r16 - 5a78: 27 ff sbrs r18, 7 - 5a7a: 07 c0 rjmp .+14 ; 0x5a8a - 5a7c: 60 81 ld r22, Z - 5a7e: 71 81 ldd r23, Z+1 ; 0x01 - 5a80: 82 81 ldd r24, Z+2 ; 0x02 - 5a82: 93 81 ldd r25, Z+3 ; 0x03 - 5a84: 0c 5f subi r16, 0xFC ; 252 - 5a86: 1f 4f sbci r17, 0xFF ; 255 - 5a88: 08 c0 rjmp .+16 ; 0x5a9a - 5a8a: 60 81 ld r22, Z - 5a8c: 71 81 ldd r23, Z+1 ; 0x01 - 5a8e: 88 27 eor r24, r24 - 5a90: 77 fd sbrc r23, 7 - 5a92: 80 95 com r24 - 5a94: 98 2f mov r25, r24 - 5a96: 0e 5f subi r16, 0xFE ; 254 - 5a98: 1f 4f sbci r17, 0xFF ; 255 - 5a9a: 2f 76 andi r18, 0x6F ; 111 - 5a9c: b2 2e mov r11, r18 - 5a9e: 97 ff sbrs r25, 7 - 5aa0: 09 c0 rjmp .+18 ; 0x5ab4 - 5aa2: 90 95 com r25 - 5aa4: 80 95 com r24 - 5aa6: 70 95 com r23 - 5aa8: 61 95 neg r22 - 5aaa: 7f 4f sbci r23, 0xFF ; 255 - 5aac: 8f 4f sbci r24, 0xFF ; 255 - 5aae: 9f 4f sbci r25, 0xFF ; 255 - 5ab0: 20 68 ori r18, 0x80 ; 128 - 5ab2: b2 2e mov r11, r18 - 5ab4: 2a e0 ldi r18, 0x0A ; 10 - 5ab6: 30 e0 ldi r19, 0x00 ; 0 - 5ab8: a4 01 movw r20, r8 - 5aba: 48 d1 rcall .+656 ; 0x5d4c <__ultoa_invert> - 5abc: a8 2e mov r10, r24 - 5abe: a8 18 sub r10, r8 - 5ac0: 43 c0 rjmp .+134 ; 0x5b48 - 5ac2: 85 37 cpi r24, 0x75 ; 117 - 5ac4: 29 f4 brne .+10 ; 0x5ad0 - 5ac6: 2f 7e andi r18, 0xEF ; 239 - 5ac8: b2 2e mov r11, r18 - 5aca: 2a e0 ldi r18, 0x0A ; 10 - 5acc: 30 e0 ldi r19, 0x00 ; 0 - 5ace: 25 c0 rjmp .+74 ; 0x5b1a - 5ad0: f2 2f mov r31, r18 - 5ad2: f9 7f andi r31, 0xF9 ; 249 - 5ad4: bf 2e mov r11, r31 - 5ad6: 8f 36 cpi r24, 0x6F ; 111 - 5ad8: c1 f0 breq .+48 ; 0x5b0a - 5ada: 18 f4 brcc .+6 ; 0x5ae2 - 5adc: 88 35 cpi r24, 0x58 ; 88 - 5ade: 79 f0 breq .+30 ; 0x5afe - 5ae0: ad c0 rjmp .+346 ; 0x5c3c - 5ae2: 80 37 cpi r24, 0x70 ; 112 - 5ae4: 19 f0 breq .+6 ; 0x5aec - 5ae6: 88 37 cpi r24, 0x78 ; 120 - 5ae8: 21 f0 breq .+8 ; 0x5af2 - 5aea: a8 c0 rjmp .+336 ; 0x5c3c - 5aec: 2f 2f mov r18, r31 - 5aee: 20 61 ori r18, 0x10 ; 16 - 5af0: b2 2e mov r11, r18 - 5af2: b4 fe sbrs r11, 4 - 5af4: 0d c0 rjmp .+26 ; 0x5b10 - 5af6: 8b 2d mov r24, r11 - 5af8: 84 60 ori r24, 0x04 ; 4 - 5afa: b8 2e mov r11, r24 - 5afc: 09 c0 rjmp .+18 ; 0x5b10 - 5afe: 24 ff sbrs r18, 4 - 5b00: 0a c0 rjmp .+20 ; 0x5b16 - 5b02: 9f 2f mov r25, r31 - 5b04: 96 60 ori r25, 0x06 ; 6 - 5b06: b9 2e mov r11, r25 - 5b08: 06 c0 rjmp .+12 ; 0x5b16 - 5b0a: 28 e0 ldi r18, 0x08 ; 8 - 5b0c: 30 e0 ldi r19, 0x00 ; 0 - 5b0e: 05 c0 rjmp .+10 ; 0x5b1a - 5b10: 20 e1 ldi r18, 0x10 ; 16 - 5b12: 30 e0 ldi r19, 0x00 ; 0 - 5b14: 02 c0 rjmp .+4 ; 0x5b1a - 5b16: 20 e1 ldi r18, 0x10 ; 16 - 5b18: 32 e0 ldi r19, 0x02 ; 2 - 5b1a: f8 01 movw r30, r16 - 5b1c: b7 fe sbrs r11, 7 - 5b1e: 07 c0 rjmp .+14 ; 0x5b2e - 5b20: 60 81 ld r22, Z - 5b22: 71 81 ldd r23, Z+1 ; 0x01 - 5b24: 82 81 ldd r24, Z+2 ; 0x02 - 5b26: 93 81 ldd r25, Z+3 ; 0x03 - 5b28: 0c 5f subi r16, 0xFC ; 252 - 5b2a: 1f 4f sbci r17, 0xFF ; 255 - 5b2c: 06 c0 rjmp .+12 ; 0x5b3a - 5b2e: 60 81 ld r22, Z - 5b30: 71 81 ldd r23, Z+1 ; 0x01 - 5b32: 80 e0 ldi r24, 0x00 ; 0 - 5b34: 90 e0 ldi r25, 0x00 ; 0 - 5b36: 0e 5f subi r16, 0xFE ; 254 - 5b38: 1f 4f sbci r17, 0xFF ; 255 - 5b3a: a4 01 movw r20, r8 - 5b3c: 07 d1 rcall .+526 ; 0x5d4c <__ultoa_invert> - 5b3e: a8 2e mov r10, r24 - 5b40: a8 18 sub r10, r8 - 5b42: fb 2d mov r31, r11 - 5b44: ff 77 andi r31, 0x7F ; 127 - 5b46: bf 2e mov r11, r31 - 5b48: b6 fe sbrs r11, 6 - 5b4a: 0b c0 rjmp .+22 ; 0x5b62 - 5b4c: 2b 2d mov r18, r11 - 5b4e: 2e 7f andi r18, 0xFE ; 254 - 5b50: a5 14 cp r10, r5 - 5b52: 50 f4 brcc .+20 ; 0x5b68 - 5b54: b4 fe sbrs r11, 4 - 5b56: 0a c0 rjmp .+20 ; 0x5b6c - 5b58: b2 fc sbrc r11, 2 - 5b5a: 08 c0 rjmp .+16 ; 0x5b6c - 5b5c: 2b 2d mov r18, r11 - 5b5e: 2e 7e andi r18, 0xEE ; 238 - 5b60: 05 c0 rjmp .+10 ; 0x5b6c - 5b62: 7a 2c mov r7, r10 - 5b64: 2b 2d mov r18, r11 - 5b66: 03 c0 rjmp .+6 ; 0x5b6e - 5b68: 7a 2c mov r7, r10 - 5b6a: 01 c0 rjmp .+2 ; 0x5b6e - 5b6c: 75 2c mov r7, r5 - 5b6e: 24 ff sbrs r18, 4 - 5b70: 0d c0 rjmp .+26 ; 0x5b8c - 5b72: fe 01 movw r30, r28 - 5b74: ea 0d add r30, r10 - 5b76: f1 1d adc r31, r1 - 5b78: 80 81 ld r24, Z - 5b7a: 80 33 cpi r24, 0x30 ; 48 - 5b7c: 11 f4 brne .+4 ; 0x5b82 - 5b7e: 29 7e andi r18, 0xE9 ; 233 - 5b80: 09 c0 rjmp .+18 ; 0x5b94 - 5b82: 22 ff sbrs r18, 2 - 5b84: 06 c0 rjmp .+12 ; 0x5b92 - 5b86: 73 94 inc r7 - 5b88: 73 94 inc r7 - 5b8a: 04 c0 rjmp .+8 ; 0x5b94 - 5b8c: 82 2f mov r24, r18 - 5b8e: 86 78 andi r24, 0x86 ; 134 - 5b90: 09 f0 breq .+2 ; 0x5b94 - 5b92: 73 94 inc r7 - 5b94: 23 fd sbrc r18, 3 - 5b96: 12 c0 rjmp .+36 ; 0x5bbc - 5b98: 20 ff sbrs r18, 0 - 5b9a: 06 c0 rjmp .+12 ; 0x5ba8 - 5b9c: 5a 2c mov r5, r10 - 5b9e: 73 14 cp r7, r3 - 5ba0: 18 f4 brcc .+6 ; 0x5ba8 - 5ba2: 53 0c add r5, r3 - 5ba4: 57 18 sub r5, r7 - 5ba6: 73 2c mov r7, r3 - 5ba8: 73 14 cp r7, r3 - 5baa: 60 f4 brcc .+24 ; 0x5bc4 - 5bac: b7 01 movw r22, r14 - 5bae: 80 e2 ldi r24, 0x20 ; 32 - 5bb0: 90 e0 ldi r25, 0x00 ; 0 - 5bb2: 2c 87 std Y+12, r18 ; 0x0c - 5bb4: 99 d0 rcall .+306 ; 0x5ce8 - 5bb6: 73 94 inc r7 - 5bb8: 2c 85 ldd r18, Y+12 ; 0x0c - 5bba: f6 cf rjmp .-20 ; 0x5ba8 - 5bbc: 73 14 cp r7, r3 - 5bbe: 10 f4 brcc .+4 ; 0x5bc4 - 5bc0: 37 18 sub r3, r7 - 5bc2: 01 c0 rjmp .+2 ; 0x5bc6 - 5bc4: 31 2c mov r3, r1 - 5bc6: 24 ff sbrs r18, 4 - 5bc8: 11 c0 rjmp .+34 ; 0x5bec - 5bca: b7 01 movw r22, r14 - 5bcc: 80 e3 ldi r24, 0x30 ; 48 - 5bce: 90 e0 ldi r25, 0x00 ; 0 - 5bd0: 2c 87 std Y+12, r18 ; 0x0c - 5bd2: 8a d0 rcall .+276 ; 0x5ce8 - 5bd4: 2c 85 ldd r18, Y+12 ; 0x0c - 5bd6: 22 ff sbrs r18, 2 - 5bd8: 16 c0 rjmp .+44 ; 0x5c06 - 5bda: 21 ff sbrs r18, 1 - 5bdc: 03 c0 rjmp .+6 ; 0x5be4 - 5bde: 88 e5 ldi r24, 0x58 ; 88 - 5be0: 90 e0 ldi r25, 0x00 ; 0 - 5be2: 02 c0 rjmp .+4 ; 0x5be8 - 5be4: 88 e7 ldi r24, 0x78 ; 120 - 5be6: 90 e0 ldi r25, 0x00 ; 0 - 5be8: b7 01 movw r22, r14 - 5bea: 0c c0 rjmp .+24 ; 0x5c04 - 5bec: 82 2f mov r24, r18 - 5bee: 86 78 andi r24, 0x86 ; 134 - 5bf0: 51 f0 breq .+20 ; 0x5c06 - 5bf2: 21 fd sbrc r18, 1 - 5bf4: 02 c0 rjmp .+4 ; 0x5bfa - 5bf6: 80 e2 ldi r24, 0x20 ; 32 - 5bf8: 01 c0 rjmp .+2 ; 0x5bfc - 5bfa: 8b e2 ldi r24, 0x2B ; 43 - 5bfc: 27 fd sbrc r18, 7 - 5bfe: 8d e2 ldi r24, 0x2D ; 45 - 5c00: b7 01 movw r22, r14 - 5c02: 90 e0 ldi r25, 0x00 ; 0 - 5c04: 71 d0 rcall .+226 ; 0x5ce8 - 5c06: a5 14 cp r10, r5 - 5c08: 30 f4 brcc .+12 ; 0x5c16 - 5c0a: b7 01 movw r22, r14 - 5c0c: 80 e3 ldi r24, 0x30 ; 48 - 5c0e: 90 e0 ldi r25, 0x00 ; 0 - 5c10: 6b d0 rcall .+214 ; 0x5ce8 - 5c12: 5a 94 dec r5 - 5c14: f8 cf rjmp .-16 ; 0x5c06 - 5c16: aa 94 dec r10 - 5c18: f4 01 movw r30, r8 - 5c1a: ea 0d add r30, r10 - 5c1c: f1 1d adc r31, r1 - 5c1e: 80 81 ld r24, Z - 5c20: b7 01 movw r22, r14 - 5c22: 90 e0 ldi r25, 0x00 ; 0 - 5c24: 61 d0 rcall .+194 ; 0x5ce8 - 5c26: a1 10 cpse r10, r1 - 5c28: f6 cf rjmp .-20 ; 0x5c16 - 5c2a: 33 20 and r3, r3 - 5c2c: 09 f4 brne .+2 ; 0x5c30 - 5c2e: 5d ce rjmp .-838 ; 0x58ea - 5c30: b7 01 movw r22, r14 - 5c32: 80 e2 ldi r24, 0x20 ; 32 - 5c34: 90 e0 ldi r25, 0x00 ; 0 - 5c36: 58 d0 rcall .+176 ; 0x5ce8 - 5c38: 3a 94 dec r3 - 5c3a: f7 cf rjmp .-18 ; 0x5c2a - 5c3c: f7 01 movw r30, r14 - 5c3e: 86 81 ldd r24, Z+6 ; 0x06 - 5c40: 97 81 ldd r25, Z+7 ; 0x07 - 5c42: 02 c0 rjmp .+4 ; 0x5c48 - 5c44: 8f ef ldi r24, 0xFF ; 255 - 5c46: 9f ef ldi r25, 0xFF ; 255 - 5c48: 2c 96 adiw r28, 0x0c ; 12 - 5c4a: e2 e1 ldi r30, 0x12 ; 18 - 5c4c: 12 c1 rjmp .+548 ; 0x5e72 <__epilogue_restores__> - -00005c4e <__eerd_block_x32a4u>: - 5c4e: e0 ec ldi r30, 0xC0 ; 192 - 5c50: f1 e0 ldi r31, 0x01 ; 1 - 5c52: a7 85 ldd r26, Z+15 ; 0x0f - 5c54: a7 fd sbrc r26, 7 - 5c56: fd cf rjmp .-6 ; 0x5c52 <__eerd_block_x32a4u+0x4> - 5c58: a4 85 ldd r26, Z+12 ; 0x0c - 5c5a: a8 60 ori r26, 0x08 ; 8 - 5c5c: a4 87 std Z+12, r26 ; 0x0c - 5c5e: 60 50 subi r22, 0x00 ; 0 - 5c60: 70 4f sbci r23, 0xF0 ; 240 - 5c62: f5 cd rjmp .-1046 ; 0x584e - -00005c64 <__eewr_block_x32a4u>: - 5c64: dc 01 movw r26, r24 - 5c66: cb 01 movw r24, r22 - 5c68: 02 c0 rjmp .+4 ; 0x5c6e <__eewr_block_x32a4u+0xa> - 5c6a: 2d 91 ld r18, X+ - 5c6c: 05 d0 rcall .+10 ; 0x5c78 <__eewr_r18_x32a4u> - 5c6e: 41 50 subi r20, 0x01 ; 1 - 5c70: 50 40 sbci r21, 0x00 ; 0 - 5c72: d8 f7 brcc .-10 ; 0x5c6a <__eewr_block_x32a4u+0x6> - 5c74: 08 95 ret - -00005c76 <__eewr_byte_x32a4u>: - 5c76: 26 2f mov r18, r22 - -00005c78 <__eewr_r18_x32a4u>: - 5c78: e0 ec ldi r30, 0xC0 ; 192 - 5c7a: f1 e0 ldi r31, 0x01 ; 1 - 5c7c: 37 85 ldd r19, Z+15 ; 0x0f - 5c7e: 37 fd sbrc r19, 7 - 5c80: fd cf rjmp .-6 ; 0x5c7c <__eewr_r18_x32a4u+0x4> - 5c82: 34 85 ldd r19, Z+12 ; 0x0c - 5c84: 37 7f andi r19, 0xF7 ; 247 - 5c86: 34 87 std Z+12, r19 ; 0x0c - 5c88: 37 85 ldd r19, Z+15 ; 0x0f - 5c8a: 31 ff sbrs r19, 1 - 5c8c: 09 c0 rjmp .+18 ; 0x5ca0 <__eewr_r18_x32a4u+0x28> - 5c8e: 36 e3 ldi r19, 0x36 ; 54 - 5c90: 32 87 std Z+10, r19 ; 0x0a - 5c92: 38 ed ldi r19, 0xD8 ; 216 - 5c94: 34 bf out 0x34, r19 ; 52 - 5c96: 31 e0 ldi r19, 0x01 ; 1 - 5c98: 33 87 std Z+11, r19 ; 0x0b - 5c9a: 37 85 ldd r19, Z+15 ; 0x0f - 5c9c: 37 fd sbrc r19, 7 - 5c9e: fd cf rjmp .-6 ; 0x5c9a <__eewr_r18_x32a4u+0x22> - 5ca0: 33 e3 ldi r19, 0x33 ; 51 - 5ca2: 32 87 std Z+10, r19 ; 0x0a - 5ca4: 80 83 st Z, r24 - 5ca6: 91 83 std Z+1, r25 ; 0x01 - 5ca8: 12 82 std Z+2, r1 ; 0x02 - 5caa: 24 83 std Z+4, r18 ; 0x04 - 5cac: 25 e3 ldi r18, 0x35 ; 53 - 5cae: 22 87 std Z+10, r18 ; 0x0a - 5cb0: 28 ed ldi r18, 0xD8 ; 216 - 5cb2: 31 e0 ldi r19, 0x01 ; 1 - 5cb4: 24 bf out 0x34, r18 ; 52 - 5cb6: 33 87 std Z+11, r19 ; 0x0b - 5cb8: 01 96 adiw r24, 0x01 ; 1 - 5cba: 08 95 ret - -00005cbc : - 5cbc: fc 01 movw r30, r24 - 5cbe: 05 90 lpm r0, Z+ - 5cc0: 61 50 subi r22, 0x01 ; 1 - 5cc2: 70 40 sbci r23, 0x00 ; 0 - 5cc4: 01 10 cpse r0, r1 - 5cc6: d8 f7 brcc .-10 ; 0x5cbe - 5cc8: 80 95 com r24 - 5cca: 90 95 com r25 - 5ccc: 8e 0f add r24, r30 - 5cce: 9f 1f adc r25, r31 - 5cd0: 08 95 ret - -00005cd2 : - 5cd2: fc 01 movw r30, r24 - 5cd4: 61 50 subi r22, 0x01 ; 1 - 5cd6: 70 40 sbci r23, 0x00 ; 0 - 5cd8: 01 90 ld r0, Z+ - 5cda: 01 10 cpse r0, r1 - 5cdc: d8 f7 brcc .-10 ; 0x5cd4 - 5cde: 80 95 com r24 - 5ce0: 90 95 com r25 - 5ce2: 8e 0f add r24, r30 - 5ce4: 9f 1f adc r25, r31 - 5ce6: 08 95 ret - -00005ce8 : - 5ce8: 0f 93 push r16 - 5cea: 1f 93 push r17 - 5cec: cf 93 push r28 - 5cee: df 93 push r29 - 5cf0: 18 2f mov r17, r24 - 5cf2: 09 2f mov r16, r25 - 5cf4: eb 01 movw r28, r22 - 5cf6: 8b 81 ldd r24, Y+3 ; 0x03 - 5cf8: 81 fd sbrc r24, 1 - 5cfa: 03 c0 rjmp .+6 ; 0x5d02 - 5cfc: 8f ef ldi r24, 0xFF ; 255 - 5cfe: 9f ef ldi r25, 0xFF ; 255 - 5d00: 20 c0 rjmp .+64 ; 0x5d42 - 5d02: 82 ff sbrs r24, 2 - 5d04: 10 c0 rjmp .+32 ; 0x5d26 - 5d06: 4e 81 ldd r20, Y+6 ; 0x06 - 5d08: 5f 81 ldd r21, Y+7 ; 0x07 - 5d0a: 2c 81 ldd r18, Y+4 ; 0x04 - 5d0c: 3d 81 ldd r19, Y+5 ; 0x05 - 5d0e: 42 17 cp r20, r18 - 5d10: 53 07 cpc r21, r19 - 5d12: 7c f4 brge .+30 ; 0x5d32 - 5d14: e8 81 ld r30, Y - 5d16: f9 81 ldd r31, Y+1 ; 0x01 - 5d18: 9f 01 movw r18, r30 - 5d1a: 2f 5f subi r18, 0xFF ; 255 - 5d1c: 3f 4f sbci r19, 0xFF ; 255 - 5d1e: 28 83 st Y, r18 - 5d20: 39 83 std Y+1, r19 ; 0x01 - 5d22: 10 83 st Z, r17 - 5d24: 06 c0 rjmp .+12 ; 0x5d32 - 5d26: e8 85 ldd r30, Y+8 ; 0x08 - 5d28: f9 85 ldd r31, Y+9 ; 0x09 - 5d2a: 81 2f mov r24, r17 - 5d2c: 09 95 icall - 5d2e: 89 2b or r24, r25 - 5d30: 29 f7 brne .-54 ; 0x5cfc - 5d32: 2e 81 ldd r18, Y+6 ; 0x06 - 5d34: 3f 81 ldd r19, Y+7 ; 0x07 - 5d36: 2f 5f subi r18, 0xFF ; 255 - 5d38: 3f 4f sbci r19, 0xFF ; 255 - 5d3a: 2e 83 std Y+6, r18 ; 0x06 - 5d3c: 3f 83 std Y+7, r19 ; 0x07 - 5d3e: 81 2f mov r24, r17 - 5d40: 90 2f mov r25, r16 - 5d42: df 91 pop r29 - 5d44: cf 91 pop r28 - 5d46: 1f 91 pop r17 - 5d48: 0f 91 pop r16 - 5d4a: 08 95 ret - -00005d4c <__ultoa_invert>: - 5d4c: fa 01 movw r30, r20 - 5d4e: aa 27 eor r26, r26 - 5d50: 28 30 cpi r18, 0x08 ; 8 - 5d52: 51 f1 breq .+84 ; 0x5da8 <__ultoa_invert+0x5c> - 5d54: 20 31 cpi r18, 0x10 ; 16 - 5d56: 81 f1 breq .+96 ; 0x5db8 <__ultoa_invert+0x6c> - 5d58: e8 94 clt - 5d5a: 6f 93 push r22 - 5d5c: 6e 7f andi r22, 0xFE ; 254 - 5d5e: 6e 5f subi r22, 0xFE ; 254 - 5d60: 7f 4f sbci r23, 0xFF ; 255 - 5d62: 8f 4f sbci r24, 0xFF ; 255 - 5d64: 9f 4f sbci r25, 0xFF ; 255 - 5d66: af 4f sbci r26, 0xFF ; 255 - 5d68: b1 e0 ldi r27, 0x01 ; 1 - 5d6a: 3e d0 rcall .+124 ; 0x5de8 <__ultoa_invert+0x9c> - 5d6c: b4 e0 ldi r27, 0x04 ; 4 - 5d6e: 3c d0 rcall .+120 ; 0x5de8 <__ultoa_invert+0x9c> - 5d70: 67 0f add r22, r23 - 5d72: 78 1f adc r23, r24 - 5d74: 89 1f adc r24, r25 - 5d76: 9a 1f adc r25, r26 - 5d78: a1 1d adc r26, r1 - 5d7a: 68 0f add r22, r24 - 5d7c: 79 1f adc r23, r25 - 5d7e: 8a 1f adc r24, r26 - 5d80: 91 1d adc r25, r1 - 5d82: a1 1d adc r26, r1 - 5d84: 6a 0f add r22, r26 - 5d86: 71 1d adc r23, r1 - 5d88: 81 1d adc r24, r1 - 5d8a: 91 1d adc r25, r1 - 5d8c: a1 1d adc r26, r1 - 5d8e: 20 d0 rcall .+64 ; 0x5dd0 <__ultoa_invert+0x84> - 5d90: 09 f4 brne .+2 ; 0x5d94 <__ultoa_invert+0x48> - 5d92: 68 94 set - 5d94: 3f 91 pop r19 - 5d96: 2a e0 ldi r18, 0x0A ; 10 - 5d98: 26 9f mul r18, r22 - 5d9a: 11 24 eor r1, r1 - 5d9c: 30 19 sub r19, r0 - 5d9e: 30 5d subi r19, 0xD0 ; 208 - 5da0: 31 93 st Z+, r19 - 5da2: de f6 brtc .-74 ; 0x5d5a <__ultoa_invert+0xe> - 5da4: cf 01 movw r24, r30 - 5da6: 08 95 ret - 5da8: 46 2f mov r20, r22 - 5daa: 47 70 andi r20, 0x07 ; 7 - 5dac: 40 5d subi r20, 0xD0 ; 208 - 5dae: 41 93 st Z+, r20 - 5db0: b3 e0 ldi r27, 0x03 ; 3 - 5db2: 0f d0 rcall .+30 ; 0x5dd2 <__ultoa_invert+0x86> - 5db4: c9 f7 brne .-14 ; 0x5da8 <__ultoa_invert+0x5c> - 5db6: f6 cf rjmp .-20 ; 0x5da4 <__ultoa_invert+0x58> - 5db8: 46 2f mov r20, r22 - 5dba: 4f 70 andi r20, 0x0F ; 15 - 5dbc: 40 5d subi r20, 0xD0 ; 208 - 5dbe: 4a 33 cpi r20, 0x3A ; 58 - 5dc0: 18 f0 brcs .+6 ; 0x5dc8 <__ultoa_invert+0x7c> - 5dc2: 49 5d subi r20, 0xD9 ; 217 - 5dc4: 31 fd sbrc r19, 1 - 5dc6: 40 52 subi r20, 0x20 ; 32 - 5dc8: 41 93 st Z+, r20 - 5dca: 02 d0 rcall .+4 ; 0x5dd0 <__ultoa_invert+0x84> - 5dcc: a9 f7 brne .-22 ; 0x5db8 <__ultoa_invert+0x6c> - 5dce: ea cf rjmp .-44 ; 0x5da4 <__ultoa_invert+0x58> - 5dd0: b4 e0 ldi r27, 0x04 ; 4 - 5dd2: a6 95 lsr r26 - 5dd4: 97 95 ror r25 - 5dd6: 87 95 ror r24 - 5dd8: 77 95 ror r23 - 5dda: 67 95 ror r22 - 5ddc: ba 95 dec r27 - 5dde: c9 f7 brne .-14 ; 0x5dd2 <__ultoa_invert+0x86> - 5de0: 00 97 sbiw r24, 0x00 ; 0 - 5de2: 61 05 cpc r22, r1 - 5de4: 71 05 cpc r23, r1 - 5de6: 08 95 ret - 5de8: 9b 01 movw r18, r22 - 5dea: ac 01 movw r20, r24 - 5dec: 0a 2e mov r0, r26 - 5dee: 06 94 lsr r0 - 5df0: 57 95 ror r21 - 5df2: 47 95 ror r20 - 5df4: 37 95 ror r19 - 5df6: 27 95 ror r18 - 5df8: ba 95 dec r27 - 5dfa: c9 f7 brne .-14 ; 0x5dee <__ultoa_invert+0xa2> - 5dfc: 62 0f add r22, r18 - 5dfe: 73 1f adc r23, r19 - 5e00: 84 1f adc r24, r20 - 5e02: 95 1f adc r25, r21 - 5e04: a0 1d adc r26, r0 - 5e06: 08 95 ret - -00005e08 <__divmodsi4>: - 5e08: 05 2e mov r0, r21 - 5e0a: 97 fb bst r25, 7 - 5e0c: 16 f4 brtc .+4 ; 0x5e12 <__divmodsi4+0xa> - 5e0e: 00 94 com r0 - 5e10: 0f d0 rcall .+30 ; 0x5e30 <__negsi2> - 5e12: 57 fd sbrc r21, 7 - 5e14: 05 d0 rcall .+10 ; 0x5e20 <__divmodsi4_neg2> - 5e16: 45 d0 rcall .+138 ; 0x5ea2 <__udivmodsi4> - 5e18: 07 fc sbrc r0, 7 - 5e1a: 02 d0 rcall .+4 ; 0x5e20 <__divmodsi4_neg2> - 5e1c: 46 f4 brtc .+16 ; 0x5e2e <__divmodsi4_exit> - 5e1e: 08 c0 rjmp .+16 ; 0x5e30 <__negsi2> - -00005e20 <__divmodsi4_neg2>: - 5e20: 50 95 com r21 - 5e22: 40 95 com r20 - 5e24: 30 95 com r19 - 5e26: 21 95 neg r18 - 5e28: 3f 4f sbci r19, 0xFF ; 255 - 5e2a: 4f 4f sbci r20, 0xFF ; 255 - 5e2c: 5f 4f sbci r21, 0xFF ; 255 - -00005e2e <__divmodsi4_exit>: - 5e2e: 08 95 ret - -00005e30 <__negsi2>: - 5e30: 90 95 com r25 - 5e32: 80 95 com r24 - 5e34: 70 95 com r23 - 5e36: 61 95 neg r22 - 5e38: 7f 4f sbci r23, 0xFF ; 255 - 5e3a: 8f 4f sbci r24, 0xFF ; 255 - 5e3c: 9f 4f sbci r25, 0xFF ; 255 - 5e3e: 08 95 ret - -00005e40 <__prologue_saves__>: - 5e40: 2f 92 push r2 - 5e42: 3f 92 push r3 - 5e44: 4f 92 push r4 - 5e46: 5f 92 push r5 - 5e48: 6f 92 push r6 - 5e4a: 7f 92 push r7 - 5e4c: 8f 92 push r8 - 5e4e: 9f 92 push r9 - 5e50: af 92 push r10 - 5e52: bf 92 push r11 - 5e54: cf 92 push r12 - 5e56: df 92 push r13 - 5e58: ef 92 push r14 - 5e5a: ff 92 push r15 - 5e5c: 0f 93 push r16 - 5e5e: 1f 93 push r17 - 5e60: cf 93 push r28 - 5e62: df 93 push r29 - 5e64: cd b7 in r28, 0x3d ; 61 - 5e66: de b7 in r29, 0x3e ; 62 - 5e68: ca 1b sub r28, r26 - 5e6a: db 0b sbc r29, r27 - 5e6c: cd bf out 0x3d, r28 ; 61 - 5e6e: de bf out 0x3e, r29 ; 62 - 5e70: 09 94 ijmp - -00005e72 <__epilogue_restores__>: - 5e72: 2a 88 ldd r2, Y+18 ; 0x12 - 5e74: 39 88 ldd r3, Y+17 ; 0x11 - 5e76: 48 88 ldd r4, Y+16 ; 0x10 - 5e78: 5f 84 ldd r5, Y+15 ; 0x0f - 5e7a: 6e 84 ldd r6, Y+14 ; 0x0e - 5e7c: 7d 84 ldd r7, Y+13 ; 0x0d - 5e7e: 8c 84 ldd r8, Y+12 ; 0x0c - 5e80: 9b 84 ldd r9, Y+11 ; 0x0b - 5e82: aa 84 ldd r10, Y+10 ; 0x0a - 5e84: b9 84 ldd r11, Y+9 ; 0x09 - 5e86: c8 84 ldd r12, Y+8 ; 0x08 - 5e88: df 80 ldd r13, Y+7 ; 0x07 - 5e8a: ee 80 ldd r14, Y+6 ; 0x06 - 5e8c: fd 80 ldd r15, Y+5 ; 0x05 - 5e8e: 0c 81 ldd r16, Y+4 ; 0x04 - 5e90: 1b 81 ldd r17, Y+3 ; 0x03 - 5e92: aa 81 ldd r26, Y+2 ; 0x02 - 5e94: b9 81 ldd r27, Y+1 ; 0x01 - 5e96: ce 0f add r28, r30 - 5e98: d1 1d adc r29, r1 - 5e9a: cd bf out 0x3d, r28 ; 61 - 5e9c: de bf out 0x3e, r29 ; 62 - 5e9e: ed 01 movw r28, r26 - 5ea0: 08 95 ret - -00005ea2 <__udivmodsi4>: - 5ea2: a1 e2 ldi r26, 0x21 ; 33 - 5ea4: 1a 2e mov r1, r26 - 5ea6: aa 1b sub r26, r26 - 5ea8: bb 1b sub r27, r27 - 5eaa: fd 01 movw r30, r26 - 5eac: 0d c0 rjmp .+26 ; 0x5ec8 <__udivmodsi4_ep> - -00005eae <__udivmodsi4_loop>: - 5eae: aa 1f adc r26, r26 - 5eb0: bb 1f adc r27, r27 - 5eb2: ee 1f adc r30, r30 - 5eb4: ff 1f adc r31, r31 - 5eb6: a2 17 cp r26, r18 - 5eb8: b3 07 cpc r27, r19 - 5eba: e4 07 cpc r30, r20 - 5ebc: f5 07 cpc r31, r21 - 5ebe: 20 f0 brcs .+8 ; 0x5ec8 <__udivmodsi4_ep> - 5ec0: a2 1b sub r26, r18 - 5ec2: b3 0b sbc r27, r19 - 5ec4: e4 0b sbc r30, r20 - 5ec6: f5 0b sbc r31, r21 - -00005ec8 <__udivmodsi4_ep>: - 5ec8: 66 1f adc r22, r22 - 5eca: 77 1f adc r23, r23 - 5ecc: 88 1f adc r24, r24 - 5ece: 99 1f adc r25, r25 - 5ed0: 1a 94 dec r1 - 5ed2: 69 f7 brne .-38 ; 0x5eae <__udivmodsi4_loop> - 5ed4: 60 95 com r22 - 5ed6: 70 95 com r23 - 5ed8: 80 95 com r24 - 5eda: 90 95 com r25 - 5edc: 9b 01 movw r18, r22 - 5ede: ac 01 movw r20, r24 - 5ee0: bd 01 movw r22, r26 - 5ee2: cf 01 movw r24, r30 - 5ee4: 08 95 ret - -00005ee6 <_exit>: - 5ee6: f8 94 cli - -00005ee8 <__stop_program>: - 5ee8: ff cf rjmp .-2 ; 0x5ee8 <__stop_program>