1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
|
;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 2.7.4 #4943 (Oct 27 2007) (UNIX)
; This file was generated Fri Jun 13 14:34:00 2008
;--------------------------------------------------------
; PIC port for the 14-bit core
;--------------------------------------------------------
; .module serial1
list p=16f648a
radix dec
include "p16f648a.inc"
;--------------------------------------------------------
; external declarations
;--------------------------------------------------------
extern _delay_10us
extern _clearwdt
extern _CCP1CON_bits
extern _CMCON_bits
extern _EECON1_bits
extern _INTCON_bits
extern _OPTION_REG_bits
extern _PCON_bits
extern _PIE1_bits
extern _PIR1_bits
extern _PORTA_bits
extern _PORTB_bits
extern _RCSTA_bits
extern _STATUS_bits
extern _T1CON_bits
extern _T2CON_bits
extern _TRISA_bits
extern _TRISB_bits
extern _TXSTA_bits
extern _VRCON_bits
extern _buffer
extern _transmitBuffer
extern _sendPacket
extern _deviceAddress
extern _INDF
extern _TMR0
extern _PCL
extern _STATUS
extern _FSR
extern _PORTA
extern _PORTB
extern _PCLATH
extern _INTCON
extern _PIR1
extern _TMR1L
extern _TMR1H
extern _T1CON
extern _TMR2
extern _T2CON
extern _CCPR1L
extern _CCPR1H
extern _CCP1CON
extern _RCSTA
extern _TXREG
extern _RCREG
extern _CMCON
extern _OPTION_REG
extern _TRISA
extern _TRISB
extern _PIE1
extern _PCON
extern _PR2
extern _TXSTA
extern _SPBRG
extern _EEDATA
extern _EEADR
extern _EECON1
extern _EECON2
extern _VRCON
extern PSAVE
extern SSAVE
extern WSAVE
extern STK12
extern STK11
extern STK10
extern STK09
extern STK08
extern STK07
extern STK06
extern STK05
extern STK04
extern STK03
extern STK02
extern STK01
extern STK00
;--------------------------------------------------------
; global declarations
;--------------------------------------------------------
global _serialInterruptHandler
global _endMessage
global _endMessageISR
global _packetReady
global _sendReply
global _sendMessage
global _sendMessageISR
global _releaseLock
global _sendDataByteISR
global _sendDataByte
global _uartTransmit
global _uartNotifyReceive
global _serial_init
global _setFlash
global _LEDon
global _flashLED
global _computeCRC
global _uartReceiveError
global _serialStatus
;--------------------------------------------------------
; global definitions
;--------------------------------------------------------
UD_serial1_0 udata
_serialStatus res 1
;--------------------------------------------------------
; absolute symbol definitions
;--------------------------------------------------------
;--------------------------------------------------------
; compiler-defined variables
;--------------------------------------------------------
UDL_serial1_0 udata
r0x1017 res 1
r0x1018 res 1
r0x1014 res 1
r0x1015 res 1
r0x1016 res 1
r0x1019 res 1
r0x101A res 1
r0x101B res 1
r0x1025 res 1
r0x1026 res 1
r0x1027 res 1
r0x1028 res 1
r0x1022 res 1
r0x1023 res 1
r0x1021 res 1
r0x1020 res 1
r0x101C res 1
r0x101D res 1
r0x101E res 1
r0x1012 res 1
r0x1013 res 1
_flash_count res 1
_flash res 1
_flashOFF res 1
_flashON res 1
_transmitBufferHead res 1
_transmitBufferTail res 1
_crc res 1
_in_hdb2 res 1
_in_hdb1 res 1
_packetLength res 1
_sourceAddress res 1
_bufferIndex res 1
_receivedSourceAddress res 1
_sendPacketLength res 1
_sendPacketDestination res 1
;--------------------------------------------------------
; initialized data
;--------------------------------------------------------
ID_serial1_0 idata
_uartState
db 0x30
;--------------------------------------------------------
; overlayable items in internal ram
;--------------------------------------------------------
; udata_ovr
;--------------------------------------------------------
; code
;--------------------------------------------------------
code_serial1 code
;***
; pBlock Stats: dbName = C
;***
;entry: _serialInterruptHandler ;Function start
; 2 exit points
;has an exit
;functions called:
; _uartNotifyReceive
; _uartNotifyReceive
;2 compiler assigned registers:
; r0x1012
; r0x1013
;; Starting pCode block
_serialInterruptHandler ;Function start
; 2 exit points
; .line 905; "serial1.c" if (TXIF && TXIE) {
BANKSEL _PIR1_bits
BTFSS _PIR1_bits,4
GOTO _00339_DS_
BANKSEL _PIE1_bits
BTFSS _PIE1_bits,4
GOTO _00339_DS_
; .line 906; "serial1.c" if (transmitBufferHead == transmitBufferTail) {
BANKSEL _transmitBufferTail
MOVF _transmitBufferTail,W
BANKSEL _transmitBufferHead
XORWF _transmitBufferHead,W
BTFSS STATUS,2
GOTO _00336_DS_
; .line 908; "serial1.c" if (TRMT)
BANKSEL _TXSTA_bits
BTFSS _TXSTA_bits,1
GOTO _00339_DS_
; .line 909; "serial1.c" TXIE = 0;
BCF _PIE1_bits,4
GOTO _00339_DS_
_00336_DS_
; .line 911; "serial1.c" TXREG = transmitBuffer[transmitBufferHead];
BANKSEL _transmitBufferHead
MOVF _transmitBufferHead,W
ADDLW (_transmitBuffer + 0)
BANKSEL r0x1012
MOVWF r0x1012
MOVLW high (_transmitBuffer + 0)
BTFSC STATUS,0
ADDLW 0x01
MOVWF r0x1013
MOVF r0x1012,W
MOVWF FSR
BCF STATUS,7
BTFSC r0x1013,0
BSF STATUS,7
MOVF INDF,W
BANKSEL _TXREG
MOVWF _TXREG
; .line 912; "serial1.c" transmitBufferHead++;
BANKSEL _transmitBufferHead
INCF _transmitBufferHead,F
;unsigned compare: left < lit(0x10=16), size=1
; .line 913; "serial1.c" if (transmitBufferHead >= MAX_TRANSMIT_BUFFER)
MOVLW 0x10
; .line 914; "serial1.c" transmitBufferHead = 0;
SUBWF _transmitBufferHead,W
; .line 928; "serial1.c" if (RCIF) {
BTFSC STATUS,0
CLRF _transmitBufferHead
_00339_DS_
BANKSEL _PIR1_bits
BTFSS _PIR1_bits,5
GOTO _00342_DS_
; .line 929; "serial1.c" uartNotifyReceive();
CALL _uartNotifyReceive
_00342_DS_
BANKSEL _uartState;
RETURN
; exit point of _serialInterruptHandler
;***
; pBlock Stats: dbName = C
;***
;entry: _endMessage ;Function start
; 2 exit points
;has an exit
;functions called:
; _delay_10us
; _delay_10us
; _delay_10us
; _delay_10us
; _delay_10us
; _endMessageIntern
; _delay_10us
; _delay_10us
; _delay_10us
; _delay_10us
; _delay_10us
; _endMessageIntern
;; Starting pCode block
_endMessage ;Function start
; 2 exit points
; .line 881; "serial1.c" GIE=0;
BANKSEL _INTCON_bits
BCF _INTCON_bits,7
_00324_DS_
; .line 883; "serial1.c" while (serialStatus & inTransmitMsgBit) {
BANKSEL _serialStatus
BTFSS _serialStatus,1
GOTO _00326_DS_
; .line 884; "serial1.c" GIE=1;
BANKSEL _INTCON_bits
BSF _INTCON_bits,7
; .line 885; "serial1.c" delay_10us();
PAGESEL _delay_10us
CALL _delay_10us
PAGESEL $
; .line 886; "serial1.c" delay_10us();
PAGESEL _delay_10us
CALL _delay_10us
PAGESEL $
; .line 887; "serial1.c" delay_10us();
PAGESEL _delay_10us
CALL _delay_10us
PAGESEL $
; .line 888; "serial1.c" delay_10us();
PAGESEL _delay_10us
CALL _delay_10us
PAGESEL $
; .line 889; "serial1.c" delay_10us();
PAGESEL _delay_10us
CALL _delay_10us
PAGESEL $
; .line 890; "serial1.c" GIE=0;
BANKSEL _INTCON_bits
BCF _INTCON_bits,7
GOTO _00324_DS_
_00326_DS_
; .line 892; "serial1.c" endMessageIntern();
CALL _endMessageIntern
; .line 893; "serial1.c" GIE=1;
BANKSEL _INTCON_bits
BSF _INTCON_bits,7
RETURN
; exit point of _endMessage
;***
; pBlock Stats: dbName = C
;***
;entry: _endMessageISR ;Function start
; 2 exit points
;has an exit
;functions called:
; _endMessageIntern
; _endMessageIntern
;; Starting pCode block
_endMessageISR ;Function start
; 2 exit points
; .line 867; "serial1.c" endMessageIntern();
CALL _endMessageIntern
RETURN
; exit point of _endMessageISR
;***
; pBlock Stats: dbName = C
;***
;entry: _endMessageIntern ;Function start
; 2 exit points
;has an exit
;functions called:
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _uartTransmit
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _uartTransmit
;4 compiler assigned registers:
; r0x101C
; r0x101D
; r0x101E
; r0x101F
;; Starting pCode block
_endMessageIntern ;Function start
; 2 exit points
; .line 840; "serial1.c" if (serialStatus & inSendQueueMsgBit) {
BANKSEL _serialStatus
BTFSS _serialStatus,2
GOTO _00315_DS_
; .line 844; "serial1.c" uartTransmit(SNAP_SYNC);
MOVLW 0x54
CALL _uartTransmit
; .line 845; "serial1.c" crc = 0;
BANKSEL _crc
CLRF _crc
; .line 846; "serial1.c" uartTransmit(computeCRC(BIN(01010001))); // Request ACK
MOVLW 0x51
CALL _computeCRC
BANKSEL r0x101C
MOVWF r0x101C
CALL _uartTransmit
; .line 847; "serial1.c" uartTransmit(computeCRC(BIN(00110000) | sendPacketLength));
MOVLW 0x30
BANKSEL _sendPacketLength
IORWF _sendPacketLength,W
BANKSEL r0x101C
MOVWF r0x101C
CALL _computeCRC
BANKSEL r0x101C
MOVWF r0x101C
CALL _uartTransmit
; .line 848; "serial1.c" uartTransmit(computeCRC(sendPacketDestination));
BANKSEL _sendPacketDestination
MOVF _sendPacketDestination,W
CALL _computeCRC
BANKSEL r0x101C
MOVWF r0x101C
CALL _uartTransmit
; .line 849; "serial1.c" uartTransmit(computeCRC(deviceAddress));
BANKSEL _deviceAddress
MOVF _deviceAddress,W
CALL _computeCRC
BANKSEL r0x101C
MOVWF r0x101C
CALL _uartTransmit
; .line 850; "serial1.c" for(i = 0; i < sendPacketLength; i++)
BANKSEL r0x101C
CLRF r0x101C
_00311_DS_
BANKSEL _sendPacketLength
MOVF _sendPacketLength,W
BANKSEL r0x101C
SUBWF r0x101C,W
BTFSC STATUS,0
GOTO _00314_DS_
;genSkipc:3694: created from rifx:0xbffdc340
; .line 851; "serial1.c" uartTransmit(computeCRC(sendPacket[i]));
MOVF r0x101C,W
ADDLW (_sendPacket + 0)
MOVWF r0x101D
MOVLW high (_sendPacket + 0)
BTFSC STATUS,0
ADDLW 0x01
MOVWF r0x101E
MOVF r0x101D,W
MOVWF FSR
BCF STATUS,7
BTFSC r0x101E,0
BSF STATUS,7
MOVF INDF,W
;;1 MOVWF r0x101F
CALL _computeCRC
BANKSEL r0x101D
MOVWF r0x101D
CALL _uartTransmit
; .line 850; "serial1.c" for(i = 0; i < sendPacketLength; i++)
BANKSEL r0x101C
INCF r0x101C,F
GOTO _00311_DS_
_00314_DS_
; .line 852; "serial1.c" uartTransmit(crc); /// @todo crc here
BANKSEL _crc
MOVF _crc,W
CALL _uartTransmit
; .line 854; "serial1.c" serialStatus &= ~inSendQueueMsgBit; //clear
BANKSEL _serialStatus
BCF _serialStatus,2
_00315_DS_
RETURN
; exit point of _endMessageIntern
;***
; pBlock Stats: dbName = C
;***
;entry: _packetReady ;Function start
; 2 exit points
;has an exit
;1 compiler assigned register :
; r0x1020
;; Starting pCode block
_packetReady ;Function start
; 2 exit points
; .line 821; "serial1.c" GIE=0;
BANKSEL _INTCON_bits
BCF _INTCON_bits,7
; .line 822; "serial1.c" ready = (serialStatus & processingLockBit);
MOVLW 0x80
BANKSEL _serialStatus
ANDWF _serialStatus,W
BANKSEL r0x1020
MOVWF r0x1020
; .line 823; "serial1.c" if (transmitBufferHead != transmitBufferTail)
BANKSEL _transmitBufferTail
MOVF _transmitBufferTail,W
; .line 824; "serial1.c" ready = 0;
BANKSEL _transmitBufferHead
XORWF _transmitBufferHead,W
; .line 825; "serial1.c" GIE=1;
BTFSC STATUS,2
GOTO _00001_DS_
BANKSEL r0x1020
CLRF r0x1020
_00001_DS_
BANKSEL _INTCON_bits
BSF _INTCON_bits,7
; .line 826; "serial1.c" return ready;
BANKSEL r0x1020
MOVF r0x1020,W
RETURN
; exit point of _packetReady
;***
; pBlock Stats: dbName = C
;***
;entry: _sendReply ;Function start
; 2 exit points
;has an exit
;functions called:
; _sendMessage
; _sendMessage
;; Starting pCode block
_sendReply ;Function start
; 2 exit points
; .line 809; "serial1.c" sendMessage(receivedSourceAddress);
BANKSEL _receivedSourceAddress
MOVF _receivedSourceAddress,W
CALL _sendMessage
RETURN
; exit point of _sendReply
;***
; pBlock Stats: dbName = C
;***
;entry: _sendMessage ;Function start
; 2 exit points
;has an exit
;functions called:
; _delay_10us
; _delay_10us
; _delay_10us
; _delay_10us
; _delay_10us
; _sendMessageIntern
; _delay_10us
; _delay_10us
; _delay_10us
; _delay_10us
; _delay_10us
; _sendMessageIntern
;1 compiler assigned register :
; r0x1021
;; Starting pCode block
_sendMessage ;Function start
; 2 exit points
; .line 786; "serial1.c" void sendMessage(byte dest)
BANKSEL r0x1021
MOVWF r0x1021
; .line 788; "serial1.c" GIE=0;
BANKSEL _INTCON_bits
BCF _INTCON_bits,7
_00288_DS_
; .line 789; "serial1.c" while (serialStatus & inSendQueueMsgBit) {
BANKSEL _serialStatus
BTFSS _serialStatus,2
GOTO _00290_DS_
; .line 791; "serial1.c" GIE=1;
BANKSEL _INTCON_bits
BSF _INTCON_bits,7
; .line 792; "serial1.c" delay_10us();
PAGESEL _delay_10us
CALL _delay_10us
PAGESEL $
; .line 793; "serial1.c" delay_10us();
PAGESEL _delay_10us
CALL _delay_10us
PAGESEL $
; .line 794; "serial1.c" delay_10us();
PAGESEL _delay_10us
CALL _delay_10us
PAGESEL $
; .line 795; "serial1.c" delay_10us();
PAGESEL _delay_10us
CALL _delay_10us
PAGESEL $
; .line 796; "serial1.c" delay_10us();
PAGESEL _delay_10us
CALL _delay_10us
PAGESEL $
; .line 797; "serial1.c" GIE=0;
BANKSEL _INTCON_bits
BCF _INTCON_bits,7
GOTO _00288_DS_
_00290_DS_
; .line 800; "serial1.c" sendMessageIntern(dest);
BANKSEL r0x1021
MOVF r0x1021,W
CALL _sendMessageIntern
; .line 801; "serial1.c" GIE=1;
BANKSEL _INTCON_bits
BSF _INTCON_bits,7
RETURN
; exit point of _sendMessage
;***
; pBlock Stats: dbName = C
;***
;entry: _sendMessageISR ;Function start
; 2 exit points
;has an exit
;functions called:
; _sendMessageIntern
; _sendMessageIntern
;1 compiler assigned register :
; r0x1023
;; Starting pCode block
_sendMessageISR ;Function start
; 2 exit points
; .line 759; "serial1.c" byte sendMessageISR(byte dest)
BANKSEL r0x1023
MOVWF r0x1023
; .line 766; "serial1.c" if ((serialStatus & inSendQueueMsgBit) || (serialStatus & inTransmitMsgBit) ||
BANKSEL _serialStatus
BTFSC _serialStatus,2
GOTO _00274_DS_
BTFSC _serialStatus,1
GOTO _00274_DS_
; .line 767; "serial1.c" (transmitBufferHead != transmitBufferTail)) {
BANKSEL _transmitBufferTail
MOVF _transmitBufferTail,W
; .line 768; "serial1.c" return 0;
BANKSEL _transmitBufferHead
XORWF _transmitBufferHead,W
BTFSC STATUS,2
GOTO _00275_DS_
_00274_DS_
MOVLW 0x00
GOTO _00279_DS_
_00275_DS_
; .line 770; "serial1.c" sendMessageIntern(dest);
BANKSEL r0x1023
MOVF r0x1023,W
CALL _sendMessageIntern
; .line 772; "serial1.c" return 1;
MOVLW 0x01
_00279_DS_
RETURN
; exit point of _sendMessageISR
;***
; pBlock Stats: dbName = C
;***
;entry: _sendMessageIntern ;Function start
; 2 exit points
;has an exit
;1 compiler assigned register :
; r0x1022
;; Starting pCode block
_sendMessageIntern ;Function start
; 2 exit points
; .line 745; "serial1.c" static void sendMessageIntern(byte dest)
BANKSEL r0x1022
MOVWF r0x1022
; .line 747; "serial1.c" serialStatus |= inSendQueueMsgBit; //set bit
BANKSEL _serialStatus
BSF _serialStatus,2
; .line 748; "serial1.c" sendPacketDestination = dest;
BANKSEL r0x1022
MOVF r0x1022,W
BANKSEL _sendPacketDestination
MOVWF _sendPacketDestination
; .line 749; "serial1.c" sendPacketLength = 0;
BANKSEL _sendPacketLength
CLRF _sendPacketLength
RETURN
; exit point of _sendMessageIntern
;***
; pBlock Stats: dbName = C
;***
;entry: _releaseLock ;Function start
; 2 exit points
;has an exit
;; Starting pCode block
_releaseLock ;Function start
; 2 exit points
; .line 735; "serial1.c" GIE=0;
BANKSEL _INTCON_bits
BCF _INTCON_bits,7
; .line 736; "serial1.c" serialStatus &= ~processingLockBit; //clear
BANKSEL _serialStatus
BCF _serialStatus,7
; .line 737; "serial1.c" GIE=1;
BANKSEL _INTCON_bits
BSF _INTCON_bits,7
RETURN
; exit point of _releaseLock
;***
; pBlock Stats: dbName = C
;***
;entry: _sendDataByteISR ;Function start
; 2 exit points
;has an exit
;functions called:
; _sendDataByteIntern
; _sendDataByteIntern
;1 compiler assigned register :
; r0x1024
;; Starting pCode block
_sendDataByteISR ;Function start
; 2 exit points
;;1 MOVWF r0x1024
; .line 726; "serial1.c" sendDataByteIntern(c);
CALL _sendDataByteIntern
RETURN
; exit point of _sendDataByteISR
;***
; pBlock Stats: dbName = C
;***
;entry: _sendDataByte ;Function start
; 2 exit points
;has an exit
;functions called:
; _sendDataByteIntern
; _sendDataByteIntern
;1 compiler assigned register :
; r0x1028
;; Starting pCode block
_sendDataByte ;Function start
; 2 exit points
; .line 713; "serial1.c" void sendDataByte(byte c)
BANKSEL r0x1028
MOVWF r0x1028
; .line 715; "serial1.c" GIE=0;
BANKSEL _INTCON_bits
BCF _INTCON_bits,7
; .line 716; "serial1.c" sendDataByteIntern(c);
BANKSEL r0x1028
MOVF r0x1028,W
CALL _sendDataByteIntern
; .line 717; "serial1.c" GIE=1;
BANKSEL _INTCON_bits
BSF _INTCON_bits,7
RETURN
; exit point of _sendDataByte
;***
; pBlock Stats: dbName = C
;***
;entry: _sendDataByteIntern ;Function start
; 2 exit points
;has an exit
;3 compiler assigned registers:
; r0x1025
; r0x1026
; r0x1027
;; Starting pCode block
_sendDataByteIntern ;Function start
; 2 exit points
; .line 694; "serial1.c" static void sendDataByteIntern(byte c)
BANKSEL r0x1025
MOVWF r0x1025
; .line 696; "serial1.c" if (serialStatus & inSendQueueMsgBit) {
BANKSEL _serialStatus
BTFSS _serialStatus,2
GOTO _00253_DS_
;unsigned compare: left < lit(0x10=16), size=1
; .line 700; "serial1.c" if (sendPacketLength < MAX_PAYLOAD)
MOVLW 0x10
BANKSEL _sendPacketLength
SUBWF _sendPacketLength,W
BTFSC STATUS,0
GOTO _00253_DS_
;genSkipc:3694: created from rifx:0xbffdc340
; .line 701; "serial1.c" sendPacket[sendPacketLength++] = c;
MOVF _sendPacketLength,W
BANKSEL r0x1026
MOVWF r0x1026
BANKSEL _sendPacketLength
INCF _sendPacketLength,F
BANKSEL r0x1026
MOVF r0x1026,W
ADDLW (_sendPacket + 0)
MOVWF r0x1026
MOVLW high (_sendPacket + 0)
BTFSC STATUS,0
ADDLW 0x01
MOVWF r0x1027
MOVF r0x1026,W
MOVWF FSR
BCF STATUS,7
BTFSC r0x1027,0
BSF STATUS,7
MOVF r0x1025,W
MOVWF INDF
_00253_DS_
BANKSEL _uartState;
RETURN
; exit point of _sendDataByteIntern
;***
; pBlock Stats: dbName = C
;***
;entry: _uartTransmit ;Function start
; 2 exit points
;has an exit
;4 compiler assigned registers:
; r0x1018
; r0x1019
; r0x101A
; r0x101B
;; Starting pCode block
_uartTransmit ;Function start
; 2 exit points
; .line 663; "serial1.c" void uartTransmit(byte c)
BANKSEL r0x1018
MOVWF r0x1018
; .line 668; "serial1.c" newTail = transmitBufferTail + 1;
BANKSEL _transmitBufferTail
INCF _transmitBufferTail,W
BANKSEL r0x1019
MOVWF r0x1019
;unsigned compare: left < lit(0x10=16), size=1
; .line 669; "serial1.c" if (newTail >= MAX_TRANSMIT_BUFFER)
MOVLW 0x10
; .line 670; "serial1.c" newTail = 0;
SUBWF r0x1019,W
; .line 674; "serial1.c" if (newTail != transmitBufferHead) {
BTFSC STATUS,0
CLRF r0x1019
BANKSEL _transmitBufferHead
MOVF _transmitBufferHead,W
; .line 675; "serial1.c" transmitBuffer[transmitBufferTail] = c;
BANKSEL r0x1019
XORWF r0x1019,W
BTFSC STATUS,2
GOTO _00238_DS_
BANKSEL _transmitBufferTail
MOVF _transmitBufferTail,W
ADDLW (_transmitBuffer + 0)
BANKSEL r0x101A
MOVWF r0x101A
MOVLW high (_transmitBuffer + 0)
BTFSC STATUS,0
ADDLW 0x01
MOVWF r0x101B
MOVF r0x101A,W
MOVWF FSR
BCF STATUS,7
BTFSC r0x101B,0
BSF STATUS,7
MOVF r0x1018,W
MOVWF INDF
; .line 676; "serial1.c" transmitBufferTail = newTail;
MOVF r0x1019,W
BANKSEL _transmitBufferTail
MOVWF _transmitBufferTail
; .line 678; "serial1.c" if (TXIE == 0) {
BANKSEL _PIE1_bits
BTFSC _PIE1_bits,4
GOTO _00238_DS_
; .line 679; "serial1.c" TXIE=1; //enabling TXIE sets also TXIF
BSF _PIE1_bits,4
_00238_DS_
BANKSEL _uartState;
RETURN
; exit point of _uartTransmit
;***
; pBlock Stats: dbName = C
;***
;entry: _uartNotifyReceive ;Function start
; 2 exit points
;has an exit
;functions called:
; _uartReceiveError
; _uartReceiveError
; _computeCRC
; _uartReceiveError
; _computeCRC
; _uartTransmit
; _uartTransmit
; _uartTransmit
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _uartTransmit
; _computeCRC
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _uartTransmit
; _uartTransmit
; _uartTransmit
; _uartTransmit
; _uartTransmit
; _uartReceiveError
; _uartReceiveError
; _uartReceiveError
; _computeCRC
; _uartReceiveError
; _computeCRC
; _uartTransmit
; _uartTransmit
; _uartTransmit
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _uartTransmit
; _computeCRC
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _computeCRC
; _uartTransmit
; _uartTransmit
; _uartTransmit
; _uartTransmit
; _uartTransmit
; _uartTransmit
; _uartReceiveError
;3 compiler assigned registers:
; r0x1014
; r0x1015
; r0x1016
;; Starting pCode block
_uartNotifyReceive ;Function start
; 2 exit points
; .line 434; "serial1.c" c = RCREG;
BANKSEL _RCREG
MOVF _RCREG,W
; .line 439; "serial1.c" if (OERR) {
BANKSEL r0x1014
MOVWF r0x1014
; .line 440; "serial1.c" CREN = 0;
BANKSEL _RCSTA_bits
BTFSC _RCSTA_bits,1
; .line 445; "serial1.c" CREN = 1;
BCF _RCSTA_bits,4
BSF _RCSTA_bits,4
; .line 447; "serial1.c" if (serialStatus & serialErrorBit) {
BANKSEL _serialStatus
BTFSS _serialStatus,0
GOTO _00159_DS_
; .line 448; "serial1.c" uartReceiveError();
CALL _uartReceiveError
; .line 449; "serial1.c" return;
GOTO _00204_DS_
_00159_DS_
; .line 453; "serial1.c" switch(uartState) {
BANKSEL _uartState
MOVF _uartState,W
BANKSEL r0x1015
MOVWF r0x1015
;unsigned compare: left < lit(0x30=48), size=1
MOVLW 0x30
SUBWF r0x1015,W
BTFSS STATUS,0
GOTO _00202_DS_
;genSkipc:3694: created from rifx:0xbffdc340
;swapping arguments (AOP_TYPEs 1/2)
;unsigned compare: left >= lit(0x3B=59), size=1
MOVLW 0x3b
SUBWF r0x1015,W
BTFSC STATUS,0
GOTO _00202_DS_
;genSkipc:3694: created from rifx:0xbffdc340
MOVLW 0xd0
ADDWF r0x1015,F
MOVLW HIGH(_00224_DS_)
MOVWF PCLATH
MOVLW _00224_DS_
ADDWF r0x1015,W
BTFSC STATUS,0
INCF PCLATH,F
BANKSEL PCL
MOVWF PCL
_00224_DS_
GOTO _00160_DS_
GOTO _00163_DS_
GOTO _00170_DS_
GOTO _00176_DS_
GOTO _00180_DS_
GOTO _00184_DS_
GOTO _00187_DS_
GOTO _00193_DS_
GOTO _00196_DS_
GOTO _00197_DS_
GOTO _00198_DS_
_00160_DS_
; .line 459; "serial1.c" if (c == SNAP_SYNC) {
BANKSEL r0x1014
MOVF r0x1014,W
XORLW 0x54
BTFSS STATUS,2
GOTO _00204_DS_
; .line 460; "serial1.c" uartState = SNAP_haveSync;
MOVLW 0x31
BANKSEL _uartState
MOVWF _uartState
; .line 461; "serial1.c" serialStatus &= ~msgAbortedBit; //clear
BANKSEL _serialStatus
BCF _serialStatus,3
; .line 463; "serial1.c" break;
GOTO _00204_DS_
_00163_DS_
; .line 472; "serial1.c" in_hdb2 = c;
BANKSEL r0x1014
MOVF r0x1014,W
BANKSEL _in_hdb2
MOVWF _in_hdb2
; .line 473; "serial1.c" if ((c & BIN(11111100)) != BIN(01010000)) {
MOVLW 0xfc
BANKSEL r0x1014
ANDWF r0x1014,W
MOVWF r0x1015
; .line 475; "serial1.c" serialStatus |= serialErrorBit; //set serialError
XORLW 0x50
BTFSC STATUS,2
GOTO _00168_DS_
BANKSEL _serialStatus
BSF _serialStatus,0
; .line 476; "serial1.c" serialStatus |= wrongByteErrorBit;
BSF _serialStatus,5
; .line 477; "serial1.c" uartReceiveError();
CALL _uartReceiveError
GOTO _00204_DS_
_00168_DS_
; .line 480; "serial1.c" if ((c & BIN(00000011)) == BIN(00000001))
MOVLW 0x03
BANKSEL r0x1014
ANDWF r0x1014,W
MOVWF r0x1015
XORLW 0x01
BTFSS STATUS,2
GOTO _00165_DS_
; .line 481; "serial1.c" serialStatus |= ackRequestedBit; //set ackRequested-Bit
BANKSEL _serialStatus
BSF _serialStatus,6
GOTO _00166_DS_
_00165_DS_
; .line 483; "serial1.c" serialStatus &= ~ackRequestedBit; //clear
BANKSEL _serialStatus
BCF _serialStatus,6
_00166_DS_
; .line 484; "serial1.c" crc = 0;
BANKSEL _crc
CLRF _crc
; .line 485; "serial1.c" computeCRC(c);
BANKSEL r0x1014
MOVF r0x1014,W
CALL _computeCRC
; .line 486; "serial1.c" uartState = SNAP_haveHDB2;
MOVLW 0x32
BANKSEL _uartState
MOVWF _uartState
; .line 488; "serial1.c" break;
GOTO _00204_DS_
_00170_DS_
; .line 494; "serial1.c" in_hdb1 = c;
BANKSEL r0x1014
MOVF r0x1014,W
BANKSEL _in_hdb1
MOVWF _in_hdb1
; .line 495; "serial1.c" if ((c & BIN(11110000)) != BIN(00110000)) {
MOVLW 0xf0
BANKSEL r0x1014
ANDWF r0x1014,W
MOVWF r0x1015
; .line 496; "serial1.c" serialStatus |= serialErrorBit; //set serialError
XORLW 0x30
BTFSC STATUS,2
GOTO _00174_DS_
BANKSEL _serialStatus
BSF _serialStatus,0
; .line 497; "serial1.c" serialStatus |= wrongByteErrorBit;
BSF _serialStatus,5
; .line 498; "serial1.c" uartReceiveError();
CALL _uartReceiveError
GOTO _00204_DS_
_00174_DS_
; .line 500; "serial1.c" packetLength = c & 0x0f;
MOVLW 0x0f
BANKSEL r0x1014
ANDWF r0x1014,W
BANKSEL _packetLength
MOVWF _packetLength
;swapping arguments (AOP_TYPEs 1/3)
;unsigned compare: left >= lit(0x11=17), size=1
; .line 501; "serial1.c" if (packetLength > MAX_PAYLOAD)
MOVLW 0x11
SUBWF _packetLength,W
BTFSS STATUS,0
GOTO _00172_DS_
;genSkipc:3694: created from rifx:0xbffdc340
; .line 502; "serial1.c" packetLength = MAX_PAYLOAD;
MOVLW 0x10
MOVWF _packetLength
_00172_DS_
; .line 503; "serial1.c" computeCRC(c);
BANKSEL r0x1014
MOVF r0x1014,W
CALL _computeCRC
; .line 504; "serial1.c" uartState = SNAP_haveHDB1;
MOVLW 0x33
BANKSEL _uartState
MOVWF _uartState
; .line 506; "serial1.c" break;
GOTO _00204_DS_
_00176_DS_
; .line 511; "serial1.c" if (c != deviceAddress) {
BANKSEL _deviceAddress
MOVF _deviceAddress,W
; .line 512; "serial1.c" uartTransmit(SNAP_SYNC);
BANKSEL r0x1014
XORWF r0x1014,W
BTFSC STATUS,2
GOTO _00178_DS_
MOVLW 0x54
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 513; "serial1.c" uartTransmit(in_hdb2);
BANKSEL _in_hdb2
MOVF _in_hdb2,W
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 514; "serial1.c" uartTransmit(in_hdb1);
BANKSEL _in_hdb1
MOVF _in_hdb1,W
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 515; "serial1.c" uartTransmit(c);
BANKSEL r0x1014
MOVF r0x1014,W
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 516; "serial1.c" uartState = SNAP_haveDABPass;
MOVLW 0x39
BANKSEL _uartState
MOVWF _uartState
; .line 517; "serial1.c" serialStatus &= ~ackRequestedBit; //clear
BANKSEL _serialStatus
BCF _serialStatus,6
; .line 518; "serial1.c" serialStatus |= inTransmitMsgBit;
BSF _serialStatus,1
GOTO _00204_DS_
_00178_DS_
; .line 520; "serial1.c" computeCRC(c);
BANKSEL r0x1014
MOVF r0x1014,W
CALL _computeCRC
; .line 521; "serial1.c" uartState = SNAP_haveDAB;
MOVLW 0x34
BANKSEL _uartState
MOVWF _uartState
; .line 523; "serial1.c" break;
GOTO _00204_DS_
_00180_DS_
; .line 535; "serial1.c" if (serialStatus & processingLockBit) {
BANKSEL _serialStatus
BTFSS _serialStatus,7
GOTO _00182_DS_
; .line 537; "serial1.c" uartTransmit(SNAP_SYNC);
MOVLW 0x54
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 538; "serial1.c" crc = 0;
BANKSEL _crc
CLRF _crc
; .line 539; "serial1.c" uartTransmit(computeCRC(BIN(01010011))); //HDB2
MOVLW 0x53
CALL _computeCRC
BANKSEL r0x1015
MOVWF r0x1015
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 541; "serial1.c" uartTransmit(computeCRC(BIN(00110000))); //HDB1
MOVLW 0x30
CALL _computeCRC
BANKSEL r0x1015
MOVWF r0x1015
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 542; "serial1.c" uartTransmit(computeCRC(sourceAddress)); // Return to sender
BANKSEL _sourceAddress
MOVF _sourceAddress,W
CALL _computeCRC
BANKSEL r0x1015
MOVWF r0x1015
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 543; "serial1.c" uartTransmit(computeCRC(deviceAddress)); // From us
BANKSEL _deviceAddress
MOVF _deviceAddress,W
CALL _computeCRC
BANKSEL r0x1015
MOVWF r0x1015
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 551; "serial1.c" uartTransmit(crc); // CRC
BANKSEL _crc
MOVF _crc,W
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 552; "serial1.c" serialStatus &= ~ackRequestedBit; //clear
BANKSEL _serialStatus
BCF _serialStatus,6
; .line 553; "serial1.c" serialStatus |= msgAbortedBit; //set
BSF _serialStatus,3
; .line 554; "serial1.c" uartState = SNAP_idle;
MOVLW 0x30
BANKSEL _uartState
MOVWF _uartState
GOTO _00204_DS_
_00182_DS_
; .line 556; "serial1.c" sourceAddress = c;
BANKSEL r0x1014
MOVF r0x1014,W
BANKSEL _sourceAddress
MOVWF _sourceAddress
; .line 557; "serial1.c" bufferIndex = 0;
BANKSEL _bufferIndex
CLRF _bufferIndex
; .line 558; "serial1.c" computeCRC(c);
BANKSEL r0x1014
MOVF r0x1014,W
CALL _computeCRC
; .line 559; "serial1.c" uartState = SNAP_readingData;
MOVLW 0x35
BANKSEL _uartState
MOVWF _uartState
; .line 561; "serial1.c" break;
GOTO _00204_DS_
_00184_DS_
; .line 565; "serial1.c" buffer[bufferIndex] = c;
BANKSEL _bufferIndex
MOVF _bufferIndex,W
ADDLW (_buffer + 0)
BANKSEL r0x1015
MOVWF r0x1015
MOVLW high (_buffer + 0)
BTFSC STATUS,0
ADDLW 0x01
MOVWF r0x1016
MOVF r0x1015,W
MOVWF FSR
BCF STATUS,7
BTFSC r0x1016,0
BSF STATUS,7
MOVF r0x1014,W
MOVWF INDF
; .line 566; "serial1.c" bufferIndex++;
BANKSEL _bufferIndex
INCF _bufferIndex,F
; .line 567; "serial1.c" computeCRC(c);
BANKSEL r0x1014
MOVF r0x1014,W
CALL _computeCRC
; .line 569; "serial1.c" if (bufferIndex == packetLength)
BANKSEL _packetLength
MOVF _packetLength,W
BANKSEL _bufferIndex
XORWF _bufferIndex,W
BTFSS STATUS,2
GOTO _00204_DS_
; .line 570; "serial1.c" uartState = SNAP_dataComplete;
MOVLW 0x36
BANKSEL _uartState
MOVWF _uartState
; .line 571; "serial1.c" break;
GOTO _00204_DS_
_00187_DS_
; .line 580; "serial1.c" if (c == crc) {
BANKSEL _crc
MOVF _crc,W
BANKSEL r0x1014
XORWF r0x1014,W
BTFSS STATUS,2
GOTO _00189_DS_
; .line 588; "serial1.c" hdb2 |= BIN(10);
MOVLW 0x52
MOVWF r0x1015
; .line 589; "serial1.c" serialStatus |= processingLockBit; //set processingLockBit
BANKSEL _serialStatus
BSF _serialStatus,7
; .line 590; "serial1.c" receivedSourceAddress = sourceAddress;
BANKSEL _sourceAddress
MOVF _sourceAddress,W
BANKSEL _receivedSourceAddress
MOVWF _receivedSourceAddress
GOTO _00190_DS_
_00189_DS_
; .line 593; "serial1.c" hdb2 |= BIN(11);
MOVLW 0x53
BANKSEL r0x1015
MOVWF r0x1015
_00190_DS_
; .line 595; "serial1.c" if (serialStatus & ackRequestedBit) {
BANKSEL _serialStatus
BTFSS _serialStatus,6
GOTO _00192_DS_
; .line 597; "serial1.c" uartTransmit(SNAP_SYNC);
MOVLW 0x54
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 598; "serial1.c" crc = 0;
BANKSEL _crc
CLRF _crc
; .line 599; "serial1.c" uartTransmit(computeCRC(hdb2));
BANKSEL r0x1015
MOVF r0x1015,W
CALL _computeCRC
BANKSEL r0x1015
MOVWF r0x1015
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 601; "serial1.c" uartTransmit(computeCRC(BIN(00110000)));
MOVLW 0x30
CALL _computeCRC
BANKSEL r0x1015
MOVWF r0x1015
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 602; "serial1.c" uartTransmit(computeCRC(sourceAddress)); // Return to sender
BANKSEL _sourceAddress
MOVF _sourceAddress,W
CALL _computeCRC
BANKSEL r0x1015
MOVWF r0x1015
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 603; "serial1.c" uartTransmit(computeCRC(deviceAddress)); // From us
BANKSEL _deviceAddress
MOVF _deviceAddress,W
CALL _computeCRC
BANKSEL r0x1015
MOVWF r0x1015
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 604; "serial1.c" uartTransmit(crc); // CRC
BANKSEL _crc
MOVF _crc,W
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 605; "serial1.c" serialStatus &= ~ackRequestedBit; //clear
BANKSEL _serialStatus
BCF _serialStatus,6
_00192_DS_
; .line 608; "serial1.c" uartState = SNAP_idle;
MOVLW 0x30
BANKSEL _uartState
MOVWF _uartState
; .line 609; "serial1.c" break;
GOTO _00204_DS_
_00193_DS_
; .line 613; "serial1.c" uartTransmit(c); // We will be reading HDB1; pass it on
BANKSEL r0x1014
MOVF r0x1014,W
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 614; "serial1.c" packetLength = c & 0x0f;
MOVLW 0x0f
BANKSEL r0x1014
ANDWF r0x1014,W
BANKSEL _packetLength
MOVWF _packetLength
;swapping arguments (AOP_TYPEs 1/3)
;unsigned compare: left >= lit(0x11=17), size=1
; .line 615; "serial1.c" if (packetLength > MAX_PAYLOAD)
MOVLW 0x11
SUBWF _packetLength,W
BTFSS STATUS,0
GOTO _00195_DS_
;genSkipc:3694: created from rifx:0xbffdc340
; .line 616; "serial1.c" packetLength = MAX_PAYLOAD;
MOVLW 0x10
MOVWF _packetLength
_00195_DS_
; .line 617; "serial1.c" uartState = SNAP_haveHDB1Pass;
MOVLW 0x38
BANKSEL _uartState
MOVWF _uartState
; .line 618; "serial1.c" break;
GOTO _00204_DS_
_00196_DS_
; .line 622; "serial1.c" uartTransmit(c); // We will be reading dest addr; pass it on
BANKSEL r0x1014
MOVF r0x1014,W
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 623; "serial1.c" uartState = SNAP_haveDABPass;
MOVLW 0x39
BANKSEL _uartState
MOVWF _uartState
; .line 624; "serial1.c" break;
GOTO _00204_DS_
_00197_DS_
; .line 628; "serial1.c" uartTransmit(c); // We will be reading source addr; pass it on
BANKSEL r0x1014
MOVF r0x1014,W
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
; .line 632; "serial1.c" packetLength++;
BANKSEL _packetLength
INCF _packetLength,F
; .line 634; "serial1.c" uartState = SNAP_readingDataPass;
MOVLW 0x3a
BANKSEL _uartState
MOVWF _uartState
; .line 635; "serial1.c" break;
GOTO _00204_DS_
_00198_DS_
; .line 639; "serial1.c" uartTransmit(c); // This is a data byte; pass it on
BANKSEL r0x1014
MOVF r0x1014,W
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
;swapping arguments (AOP_TYPEs 1/3)
;unsigned compare: left >= lit(0x2=2), size=1
; .line 640; "serial1.c" if (packetLength > 1)
MOVLW 0x02
BANKSEL _packetLength
SUBWF _packetLength,W
BTFSS STATUS,0
GOTO _00200_DS_
;genSkipc:3694: created from rifx:0xbffdc340
; .line 641; "serial1.c" packetLength--;
DECF _packetLength,F
GOTO _00204_DS_
_00200_DS_
; .line 643; "serial1.c" uartState = SNAP_idle;
MOVLW 0x30
BANKSEL _uartState
MOVWF _uartState
; .line 644; "serial1.c" serialStatus &= ~inTransmitMsgBit; //clear
BANKSEL _serialStatus
BCF _serialStatus,1
; .line 646; "serial1.c" break;
GOTO _00204_DS_
_00202_DS_
; .line 649; "serial1.c" serialStatus |= serialErrorBit; //set serialError
BANKSEL _serialStatus
BSF _serialStatus,0
; .line 650; "serial1.c" serialStatus |= wrongStateErrorBit;
BSF _serialStatus,4
; .line 651; "serial1.c" uartReceiveError();
CALL _uartReceiveError
_00204_DS_
; .line 652; "serial1.c" }
RETURN
; exit point of _uartNotifyReceive
;***
; pBlock Stats: dbName = C
;***
;entry: _uartReceiveError ;Function start
; 2 exit points
;has an exit
;functions called:
; _uartTransmit
; _uartTransmit
;1 compiler assigned register :
; r0x1017
;; Starting pCode block
_uartReceiveError ;Function start
; 2 exit points
; .line 404; "serial1.c" if ((serialStatus & msgAbortedBit) == 0) {
BANKSEL _serialStatus
BTFSC _serialStatus,3
GOTO _00148_DS_
; .line 406; "serial1.c" for (i=0; i<8; i++) { //if we are sending too much for the transmit-buffer, it is discarded
MOVLW 0x08
BANKSEL r0x1017
MOVWF r0x1017
_00151_DS_
; .line 407; "serial1.c" uartTransmit(0);
MOVLW 0x00
PAGESEL _uartTransmit
CALL _uartTransmit
PAGESEL $
BANKSEL r0x1017
DECFSZ r0x1017,F
GOTO _00151_DS_
_00148_DS_
; .line 420; "serial1.c" serialStatus = (serialStatus & msgAbortedBit); //clear all bits except msgAbortedBit;
MOVLW 0x08
BANKSEL _serialStatus
ANDWF _serialStatus,F
; .line 422; "serial1.c" uartState = SNAP_idle;
MOVLW 0x30
BANKSEL _uartState
MOVWF _uartState
RETURN
; exit point of _uartReceiveError
;***
; pBlock Stats: dbName = C
;***
;entry: _computeCRC ;Function start
; 2 exit points
;has an exit
;2 compiler assigned registers:
; r0x1017
; r0x1018
;; Starting pCode block
_computeCRC ;Function start
; 2 exit points
; .line 338; "serial1.c" byte computeCRC(byte dataval)
BANKSEL r0x1017
MOVWF r0x1017
; .line 369; "serial1.c" byte i = dataval ^ crc;
BANKSEL _crc
XORWF _crc,W
BANKSEL r0x1018
MOVWF r0x1018
; .line 371; "serial1.c" crc = 0;
BANKSEL _crc
CLRF _crc
; .line 373; "serial1.c" if(i & 1)
BANKSEL r0x1018
BTFSS r0x1018,0
GOTO _00128_DS_
; .line 374; "serial1.c" crc ^= 0x5e;
MOVLW 0x5e
BANKSEL _crc
XORWF _crc,F
_00128_DS_
; .line 375; "serial1.c" if(i & 2)
BANKSEL r0x1018
BTFSS r0x1018,1
GOTO _00130_DS_
; .line 376; "serial1.c" crc ^= 0xbc;
MOVLW 0xbc
BANKSEL _crc
XORWF _crc,F
_00130_DS_
; .line 377; "serial1.c" if(i & 4)
BANKSEL r0x1018
BTFSS r0x1018,2
GOTO _00132_DS_
; .line 378; "serial1.c" crc ^= 0x61;
MOVLW 0x61
BANKSEL _crc
XORWF _crc,F
_00132_DS_
; .line 379; "serial1.c" if(i & 8)
BANKSEL r0x1018
BTFSS r0x1018,3
GOTO _00134_DS_
; .line 380; "serial1.c" crc ^= 0xc2;
MOVLW 0xc2
BANKSEL _crc
XORWF _crc,F
_00134_DS_
; .line 381; "serial1.c" if(i & 0x10)
BANKSEL r0x1018
BTFSS r0x1018,4
GOTO _00136_DS_
; .line 382; "serial1.c" crc ^= 0x9d;
MOVLW 0x9d
BANKSEL _crc
XORWF _crc,F
_00136_DS_
; .line 383; "serial1.c" if(i & 0x20)
BANKSEL r0x1018
BTFSS r0x1018,5
GOTO _00138_DS_
; .line 384; "serial1.c" crc ^= 0x23;
MOVLW 0x23
BANKSEL _crc
XORWF _crc,F
_00138_DS_
; .line 385; "serial1.c" if(i & 0x40)
BANKSEL r0x1018
BTFSS r0x1018,6
GOTO _00140_DS_
; .line 386; "serial1.c" crc ^= 0x46;
MOVLW 0x46
BANKSEL _crc
XORWF _crc,F
_00140_DS_
; .line 387; "serial1.c" if(i & 0x80)
BANKSEL r0x1018
BTFSS r0x1018,7
GOTO _00142_DS_
; .line 388; "serial1.c" crc ^= 0x8c;
MOVLW 0x8c
BANKSEL _crc
XORWF _crc,F
_00142_DS_
; .line 389; "serial1.c" return dataval;
BANKSEL r0x1017
MOVF r0x1017,W
RETURN
; exit point of _computeCRC
;***
; pBlock Stats: dbName = C
;***
;entry: _serial_init ;Function start
; 2 exit points
;has an exit
;; Starting pCode block
_serial_init ;Function start
; 2 exit points
; .line 324; "serial1.c" uartState = SNAP_idle;
MOVLW 0x30
BANKSEL _uartState
MOVWF _uartState
; .line 325; "serial1.c" transmitBufferHead = 0;
BANKSEL _transmitBufferHead
CLRF _transmitBufferHead
; .line 326; "serial1.c" transmitBufferTail = 0;
BANKSEL _transmitBufferTail
CLRF _transmitBufferTail
; .line 327; "serial1.c" serialStatus = 0;
BANKSEL _serialStatus
CLRF _serialStatus
; .line 328; "serial1.c" crc = 0;
BANKSEL _crc
CLRF _crc
; .line 329; "serial1.c" flash = 0;
BANKSEL _flash
CLRF _flash
; .line 330; "serial1.c" flashON = FLASHRATE;
MOVLW 0x32
; .line 331; "serial1.c" flashOFF = FLASHRATE;
BANKSEL _flashON
MOVWF _flashON
BANKSEL _flashOFF
MOVWF _flashOFF
RETURN
; exit point of _serial_init
;***
; pBlock Stats: dbName = C
;***
;entry: _setFlash ;Function start
; 2 exit points
;has an exit
;1 compiler assigned register :
; STK00
;; Starting pCode block
_setFlash ;Function start
; 2 exit points
; .line 313; "serial1.c" void setFlash(byte on, byte off)
BANKSEL _flashON
MOVWF _flashON
MOVF STK00,W
BANKSEL _flashOFF
MOVWF _flashOFF
; .line 316; "serial1.c" flashOFF = off;
RETURN
; exit point of _setFlash
;***
; pBlock Stats: dbName = C
;***
;entry: _LEDon ;Function start
; 2 exit points
;has an exit
;; Starting pCode block
_LEDon ;Function start
; 2 exit points
; .line 310; "serial1.c" LED = 0;
BANKSEL _PORTA_bits
BCF _PORTA_bits,4
RETURN
; exit point of _LEDon
;***
; pBlock Stats: dbName = C
;***
;entry: _flashLED ;Function start
; 2 exit points
;has an exit
;; Starting pCode block
_flashLED ;Function start
; 2 exit points
; .line 292; "serial1.c" flash_count--;
BANKSEL _flash_count
DECF _flash_count,F
; .line 293; "serial1.c" if(flash_count <= 0)
MOVF _flash_count,W
BTFSS STATUS,2
GOTO _00110_DS_
; .line 295; "serial1.c" flash = 1 - flash;
BANKSEL _flash
MOVF _flash,W
SUBLW 0x01
MOVWF _flash
; .line 296; "serial1.c" if(flash)
MOVF _flash,W
BTFSC STATUS,2
GOTO _00106_DS_
; .line 298; "serial1.c" LED = 0;
BANKSEL _PORTA_bits
BCF _PORTA_bits,4
; .line 299; "serial1.c" flash_count = flashOFF;
BANKSEL _flashOFF
MOVF _flashOFF,W
BANKSEL _flash_count
MOVWF _flash_count
GOTO _00110_DS_
_00106_DS_
; .line 302; "serial1.c" LED = 1;
BANKSEL _PORTA_bits
BSF _PORTA_bits,4
; .line 303; "serial1.c" flash_count = flashON;
BANKSEL _flashON
MOVF _flashON,W
BANKSEL _flash_count
MOVWF _flash_count
_00110_DS_
RETURN
; exit point of _flashLED
; code size estimation:
; 569+ 279 = 848 instructions ( 2254 byte)
end
|