-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDumped.asm
8458 lines (8177 loc) · 320 KB
/
Dumped.asm
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
.\.pioenvs\teensy31\firmware.elf: file format elf32-littlearm
Disassembly of section .text:
00000000 <_VectorsFlash>:
0: 00 80 00 20 bd 01 00 00 11 0a 00 00 c9 09 00 00 ... ............
10: c9 09 00 00 c9 09 00 00 c9 09 00 00 c9 09 00 00 ................
20: c9 09 00 00 c9 09 00 00 c9 09 00 00 11 0a 00 00 ................
30: 11 0a 00 00 c9 09 00 00 5d 21 00 00 99 23 00 00 ........]!...#..
40: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
50: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
60: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
70: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
80: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
90: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
a0: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
b0: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
c0: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
d0: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
e0: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
f0: 11 0a 00 00 b5 24 00 00 11 0a 00 00 e1 25 00 00 .....$.......%..
100: 11 0a 00 00 0d 27 00 00 11 0a 00 00 11 0a 00 00 .....'..........
110: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
120: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
130: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
140: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
150: 11 0a 00 00 0d 05 00 00 49 05 00 00 11 0a 00 00 ........I.......
160: 11 0a 00 00 79 10 00 00 11 0a 00 00 11 0a 00 00 ....y...........
170: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
180: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
190: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
1a0: 11 0a 00 00 11 0a 00 00 11 0a 00 00 11 0a 00 00 ................
1b0: 11 0a 00 00 11 0a 00 00 11 0a 00 00 ............
000001bc <ResetHandler>:
volatile int n;
#endif
//volatile int count;
#ifdef KINETISK
WDOG_UNLOCK = WDOG_UNLOCK_SEQ1;
1bc: 4b56 ldr r3, [pc, #344] ; (318 <ResetHandler+0x15c>)
1be: f24c 5220 movw r2, #50464 ; 0xc520
{
1c2: b510 push {r4, lr}
WDOG_UNLOCK = WDOG_UNLOCK_SEQ1;
1c4: 801a strh r2, [r3, #0]
WDOG_UNLOCK = WDOG_UNLOCK_SEQ2;
1c6: f64d 1228 movw r2, #55592 ; 0xd928
1ca: 801a strh r2, [r3, #0]
__asm__ volatile ("nop");
1cc: bf00 nop
__asm__ volatile ("nop");
1ce: bf00 nop
#endif
// programs using the watchdog timer or needing to initialize hardware as
// early as possible can implement startup_early_hook()
startup_early_hook();
1d0: f000 fc22 bl a18 <startup_early_hook>
// enable clocks to always-used peripherals
#if defined(__MK20DX128__)
SIM_SCGC5 = 0x00043F82; // clocks active to all GPIO
SIM_SCGC6 = SIM_SCGC6_RTC | SIM_SCGC6_FTM0 | SIM_SCGC6_FTM1 | SIM_SCGC6_ADC0 | SIM_SCGC6_FTFL;
#elif defined(__MK20DX256__)
SIM_SCGC3 = SIM_SCGC3_ADC1 | SIM_SCGC3_FTM2;
1d4: 4b51 ldr r3, [pc, #324] ; (31c <ResetHandler+0x160>)
1d6: f04f 6210 mov.w r2, #150994944 ; 0x9000000
1da: 601a str r2, [r3, #0]
SIM_SCGC5 = 0x00043F82; // clocks active to all GPIO
1dc: 4a50 ldr r2, [pc, #320] ; (320 <ResetHandler+0x164>)
1de: 609a str r2, [r3, #8]
SIM_SCGC6 = SIM_SCGC6_RTC | SIM_SCGC6_FTM0 | SIM_SCGC6_FTM1 | SIM_SCGC6_ADC0 | SIM_SCGC6_FTFL;
1e0: 4a50 ldr r2, [pc, #320] ; (324 <ResetHandler+0x168>)
1e2: 60da str r2, [r3, #12]
UART0_C2 = UART_C2_TE;
PORTB_PCR17 = PORT_PCR_MUX(3);
#endif
#ifdef KINETISK
// if the RTC oscillator isn't enabled, get it started early
if (!(RTC_CR & RTC_CR_OSCE)) {
1e4: 4a50 ldr r2, [pc, #320] ; (328 <ResetHandler+0x16c>)
1e6: 6813 ldr r3, [r2, #0]
1e8: f413 7380 ands.w r3, r3, #256 ; 0x100
1ec: d104 bne.n 1f8 <ResetHandler+0x3c>
RTC_SR = 0;
1ee: 494f ldr r1, [pc, #316] ; (32c <ResetHandler+0x170>)
1f0: 600b str r3, [r1, #0]
RTC_CR = RTC_CR_SC16P | RTC_CR_SC4P | RTC_CR_OSCE;
1f2: f44f 53a8 mov.w r3, #5376 ; 0x1500
1f6: 6013 str r3, [r2, #0]
}
#endif
// release I/O pins hold, if we woke up from VLLS mode
if (PMC_REGSC & PMC_REGSC_ACKISO) PMC_REGSC |= PMC_REGSC_ACKISO;
1f8: 4b4d ldr r3, [pc, #308] ; (330 <ResetHandler+0x174>)
1fa: 781a ldrb r2, [r3, #0]
1fc: 0711 lsls r1, r2, #28
1fe: d503 bpl.n 208 <ResetHandler+0x4c>
200: 781a ldrb r2, [r3, #0]
202: f042 0208 orr.w r2, r2, #8
206: 701a strb r2, [r3, #0]
// since this is a write once register, make it visible to all F_CPU's
// so we can into other sleep modes in the future at any speed
#if defined(__MK66FX1M0__)
SMC_PMPROT = SMC_PMPROT_AHSRUN | SMC_PMPROT_AVLP | SMC_PMPROT_ALLS | SMC_PMPROT_AVLLS;
#else
SMC_PMPROT = SMC_PMPROT_AVLP | SMC_PMPROT_ALLS | SMC_PMPROT_AVLLS;
208: 4b4a ldr r3, [pc, #296] ; (334 <ResetHandler+0x178>)
#endif
// TODO: do this while the PLL is waiting to lock....
while (dest < &_edata) *dest++ = *src++;
20a: 494b ldr r1, [pc, #300] ; (338 <ResetHandler+0x17c>)
SMC_PMPROT = SMC_PMPROT_AVLP | SMC_PMPROT_ALLS | SMC_PMPROT_AVLLS;
20c: 222a movs r2, #42 ; 0x2a
20e: 701a strb r2, [r3, #0]
210: 4a4a ldr r2, [pc, #296] ; (33c <ResetHandler+0x180>)
212: 4b4b ldr r3, [pc, #300] ; (340 <ResetHandler+0x184>)
while (dest < &_edata) *dest++ = *src++;
214: 428b cmp r3, r1
216: d204 bcs.n 222 <ResetHandler+0x66>
218: f852 0f04 ldr.w r0, [r2, #4]!
21c: f843 0b04 str.w r0, [r3], #4
220: e7f8 b.n 214 <ResetHandler+0x58>
222: 4b48 ldr r3, [pc, #288] ; (344 <ResetHandler+0x188>)
dest = &_sbss;
while (dest < &_ebss) *dest++ = 0;
224: 4948 ldr r1, [pc, #288] ; (348 <ResetHandler+0x18c>)
226: 2200 movs r2, #0
228: 428b cmp r3, r1
22a: d202 bcs.n 232 <ResetHandler+0x76>
22c: f843 2b04 str.w r2, [r3], #4
230: e7fa b.n 228 <ResetHandler+0x6c>
// default all interrupts to medium priority level
for (i=0; i < NVIC_NUM_INTERRUPTS + 16; i++) _VectorsRam[i] = _VectorsFlash[i];
232: 4946 ldr r1, [pc, #280] ; (34c <ResetHandler+0x190>)
234: 4a46 ldr r2, [pc, #280] ; (350 <ResetHandler+0x194>)
236: 2300 movs r3, #0
238: f852 0023 ldr.w r0, [r2, r3, lsl #2]
23c: f841 0023 str.w r0, [r1, r3, lsl #2]
240: 3301 adds r3, #1
242: 2b6f cmp r3, #111 ; 0x6f
244: d1f8 bne.n 238 <ResetHandler+0x7c>
246: 4b43 ldr r3, [pc, #268] ; (354 <ResetHandler+0x198>)
for (i=0; i < NVIC_NUM_INTERRUPTS; i++) NVIC_SET_PRIORITY(i, 128);
248: 4a43 ldr r2, [pc, #268] ; (358 <ResetHandler+0x19c>)
24a: 2180 movs r1, #128 ; 0x80
24c: f803 1b01 strb.w r1, [r3], #1
250: 4293 cmp r3, r2
252: d1fb bne.n 24c <ResetHandler+0x90>
SCB_VTOR = (uint32_t)_VectorsRam; // use vector table in RAM
254: 4b41 ldr r3, [pc, #260] ; (35c <ResetHandler+0x1a0>)
256: 4a3d ldr r2, [pc, #244] ; (34c <ResetHandler+0x190>)
258: 601a str r2, [r3, #0]
// C6[PLLS] bit is written to 0
// C2[LP] bit is written to 1
#else
#if defined(KINETISK)
// enable capacitors for crystal
OSC0_CR = OSC_SC8P | OSC_SC2P | OSC_ERCLKEN;
25a: 4b41 ldr r3, [pc, #260] ; (360 <ResetHandler+0x1a4>)
25c: 228a movs r2, #138 ; 0x8a
25e: 701a strb r2, [r3, #0]
#elif defined(KINETISL)
// enable capacitors for crystal
OSC0_CR = OSC_SC8P | OSC_SC2P | OSC_ERCLKEN;
#endif
// enable osc, 8-32 MHz range, low power mode
MCG_C2 = MCG_C2_RANGE0(2) | MCG_C2_EREFS;
260: f5a3 5380 sub.w r3, r3, #4096 ; 0x1000
264: 2224 movs r2, #36 ; 0x24
266: 705a strb r2, [r3, #1]
// switch to crystal as clock source, FLL input = 16 MHz / 512
MCG_C1 = MCG_C1_CLKS(2) | MCG_C1_FRDIV(4);
268: 22a0 movs r2, #160 ; 0xa0
26a: 701a strb r2, [r3, #0]
// wait for crystal oscillator to begin
while ((MCG_S & MCG_S_OSCINIT0) == 0) ;
26c: 799a ldrb r2, [r3, #6]
26e: 0792 lsls r2, r2, #30
270: d5fc bpl.n 26c <ResetHandler+0xb0>
// wait for FLL to use oscillator
while ((MCG_S & MCG_S_IREFST) != 0) ;
272: 799a ldrb r2, [r3, #6]
274: 06d4 lsls r4, r2, #27
276: d4fc bmi.n 272 <ResetHandler+0xb6>
// wait for MCGOUT to use oscillator
while ((MCG_S & MCG_S_CLKST_MASK) != MCG_S_CLKST(2)) ;
278: 4a3a ldr r2, [pc, #232] ; (364 <ResetHandler+0x1a8>)
27a: 7993 ldrb r3, [r2, #6]
27c: f003 030c and.w r3, r3, #12
280: 2b08 cmp r3, #8
282: 4b38 ldr r3, [pc, #224] ; (364 <ResetHandler+0x1a8>)
284: d1f9 bne.n 27a <ResetHandler+0xbe>
#endif
#else
#if F_CPU == 72000000
MCG_C5 = MCG_C5_PRDIV0(5); // config PLL input for 16 MHz Crystal / 6 = 2.667 Hz
#else
MCG_C5 = MCG_C5_PRDIV0(3); // config PLL input for 16 MHz Crystal / 4 = 4 MHz
286: 2203 movs r2, #3
288: 711a strb r2, [r3, #4]
#if F_CPU == 168000000
MCG_C6 = MCG_C6_PLLS | MCG_C6_VDIV0(18); // config PLL for 168 MHz output
#elif F_CPU == 144000000
MCG_C6 = MCG_C6_PLLS | MCG_C6_VDIV0(12); // config PLL for 144 MHz output
#elif F_CPU == 120000000
MCG_C6 = MCG_C6_PLLS | MCG_C6_VDIV0(6); // config PLL for 120 MHz output
28a: 2246 movs r2, #70 ; 0x46
28c: 715a strb r2, [r3, #5]
#error "This clock speed isn't supported..."
#endif
#endif
// wait for PLL to start using xtal as its input
while (!(MCG_S & MCG_S_PLLST)) ;
28e: 799a ldrb r2, [r3, #6]
290: 0690 lsls r0, r2, #26
292: d5fc bpl.n 28e <ResetHandler+0xd2>
// wait for PLL to lock
while (!(MCG_S & MCG_S_LOCK0)) ;
294: 4a33 ldr r2, [pc, #204] ; (364 <ResetHandler+0x1a8>)
296: 7991 ldrb r1, [r2, #6]
298: 4b32 ldr r3, [pc, #200] ; (364 <ResetHandler+0x1a8>)
29a: 0649 lsls r1, r1, #25
29c: d5fb bpl.n 296 <ResetHandler+0xda>
#endif
SIM_CLKDIV2 = SIM_CLKDIV2_USBDIV(2);
#elif F_CPU == 120000000
// config divisors: 120 MHz core, 60 MHz bus, 24 MHz flash, USB = 128 * 2 / 5
#if F_BUS == 60000000
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(1) | SIM_CLKDIV1_OUTDIV4(4);
29e: 4a32 ldr r2, [pc, #200] ; (368 <ResetHandler+0x1ac>)
2a0: f04f 7182 mov.w r1, #17039360 ; 0x1040000
2a4: 6011 str r1, [r2, #0]
#elif F_BUS == 120000000
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(0) | SIM_CLKDIV1_OUTDIV4(4);
#else
#error "This F_CPU & F_BUS combination is not supported"
#endif
SIM_CLKDIV2 = SIM_CLKDIV2_USBDIV(4) | SIM_CLKDIV2_USBFRAC;
2a6: 2109 movs r1, #9
2a8: 6051 str r1, [r2, #4]
#error "Error, F_CPU must be 192, 180, 168, 144, 120, 96, 72, 48, 24, 16, 8, 4, or 2 MHz"
#endif
#if F_CPU > 16000000
// switch to PLL as clock source, FLL input = 16 MHz / 512
MCG_C1 = MCG_C1_CLKS(0) | MCG_C1_FRDIV(4);
2aa: 2220 movs r2, #32
2ac: 701a strb r2, [r3, #0]
// wait for PLL clock to be used
while ((MCG_S & MCG_S_CLKST_MASK) != MCG_S_CLKST(3)) ;
2ae: 799a ldrb r2, [r3, #6]
2b0: f002 020c and.w r2, r2, #12
2b4: 2a0c cmp r2, #12
2b6: d1fa bne.n 2ae <ResetHandler+0xf2>
// USB uses PLL clock, trace is CPU clock, CLKOUT=OSCERCLK0
#if defined(KINETISK)
#if F_CPU == 216000000 || F_CPU == 180000000
SIM_SOPT2 = SIM_SOPT2_USBSRC | SIM_SOPT2_IRC48SEL | SIM_SOPT2_TRACECLKSEL | SIM_SOPT2_CLKOUTSEL(6);
#else
SIM_SOPT2 = SIM_SOPT2_USBSRC | SIM_SOPT2_PLLFLLSEL | SIM_SOPT2_TRACECLKSEL | SIM_SOPT2_CLKOUTSEL(6);
2b8: 4b2c ldr r3, [pc, #176] ; (36c <ResetHandler+0x1b0>)
2ba: 4a2d ldr r2, [pc, #180] ; (370 <ResetHandler+0x1b4>)
2bc: 601a str r2, [r3, #0]
// since we are not going into "stop mode" i removed it
SMC_PMCTRL = SMC_PMCTRL_RUNM(2); // VLPR mode :-)
#endif
// initialize the SysTick counter
SYST_RVR = (F_CPU / 1000) - 1;
2be: 4b2d ldr r3, [pc, #180] ; (374 <ResetHandler+0x1b8>)
2c0: 4a2d ldr r2, [pc, #180] ; (378 <ResetHandler+0x1bc>)
2c2: 601a str r2, [r3, #0]
SYST_CVR = 0;
2c4: 2200 movs r2, #0
2c6: 605a str r2, [r3, #4]
SYST_CSR = SYST_CSR_CLKSOURCE | SYST_CSR_TICKINT | SYST_CSR_ENABLE;
2c8: 2207 movs r2, #7
2ca: f843 2c04 str.w r2, [r3, #-4]
SCB_SHPR3 = 0x20200000; // Systick = priority 32
2ce: 4a2b ldr r2, [pc, #172] ; (37c <ResetHandler+0x1c0>)
2d0: f8c3 2d0c str.w r2, [r3, #3340] ; 0xd0c
//init_pins();
__enable_irq();
2d4: b662 cpsie i
_init_Teensyduino_internal_();
2d6: f000 fc77 bl bc8 <_init_Teensyduino_internal_>
#if defined(KINETISK)
// RTC initialization
if (RTC_SR & RTC_SR_TIF) {
2da: 4b14 ldr r3, [pc, #80] ; (32c <ResetHandler+0x170>)
2dc: 681b ldr r3, [r3, #0]
2de: 07da lsls r2, r3, #31
2e0: d505 bpl.n 2ee <ResetHandler+0x132>
// compiled-in time will be stale. Write a special
// flag into the VBAT register file indicating the
// RTC is set with known-stale time and should be
// updated when fresh time is known.
#if ARDUINO >= 10600
rtc_set((uint32_t)&__rtc_localtime);
2e2: 4827 ldr r0, [pc, #156] ; (380 <ResetHandler+0x1c4>)
2e4: f000 fc5e bl ba4 <rtc_set>
#else
rtc_set(TIME_T);
#endif
*(uint32_t *)0x4003E01C = 0x5A94C3A5;
2e8: 4b26 ldr r3, [pc, #152] ; (384 <ResetHandler+0x1c8>)
2ea: 4a27 ldr r2, [pc, #156] ; (388 <ResetHandler+0x1cc>)
2ec: 601a str r2, [r3, #0]
}
if ((RCM_SRS0 & RCM_SRS0_PIN) && (*(uint32_t *)0x4003E01C == 0x5A94C3A5)) {
2ee: 4b27 ldr r3, [pc, #156] ; (38c <ResetHandler+0x1d0>)
2f0: 781b ldrb r3, [r3, #0]
2f2: 065b lsls r3, r3, #25
2f4: d509 bpl.n 30a <ResetHandler+0x14e>
2f6: 4c23 ldr r4, [pc, #140] ; (384 <ResetHandler+0x1c8>)
2f8: 4b23 ldr r3, [pc, #140] ; (388 <ResetHandler+0x1cc>)
2fa: 6822 ldr r2, [r4, #0]
2fc: 429a cmp r2, r3
2fe: d104 bne.n 30a <ResetHandler+0x14e>
// Our compiled-in time will be very fresh, so set
// the RTC with this, and clear the VBAT resister file
// data so we don't mess with the time after it's been
// set well.
#if ARDUINO >= 10600
rtc_set((uint32_t)&__rtc_localtime);
300: 481f ldr r0, [pc, #124] ; (380 <ResetHandler+0x1c4>)
302: f000 fc4f bl ba4 <rtc_set>
#else
rtc_set(TIME_T);
#endif
*(uint32_t *)0x4003E01C = 0;
306: 2300 movs r3, #0
308: 6023 str r3, [r4, #0]
}
#endif
__libc_init_array();
30a: f002 fd6b bl 2de4 <__libc_init_array>
startup_late_hook();
30e: f000 fb89 bl a24 <startup_late_hook>
main();
312: f000 fa25 bl 760 <main>
316: e7fe b.n 316 <ResetHandler+0x15a>
318: 4005200e .word 0x4005200e
31c: 40048030 .word 0x40048030
320: 00043f82 .word 0x00043f82
324: 2b000001 .word 0x2b000001
328: 4003d010 .word 0x4003d010
32c: 4003d014 .word 0x4003d014
330: 4007d002 .word 0x4007d002
334: 4007e000 .word 0x4007e000
338: 1fff91f4 .word 0x1fff91f4
33c: 0000392c .word 0x0000392c
340: 1fff8720 .word 0x1fff8720
344: 1fff91f4 .word 0x1fff91f4
348: 1fff9620 .word 0x1fff9620
34c: 1fff8200 .word 0x1fff8200
350: 00000000 .word 0x00000000
354: e000e400 .word 0xe000e400
358: e000e45f .word 0xe000e45f
35c: e000ed08 .word 0xe000ed08
360: 40065000 .word 0x40065000
364: 40064000 .word 0x40064000
368: 40048044 .word 0x40048044
36c: 40048004 .word 0x40048004
370: 000510c0 .word 0x000510c0
374: e000e014 .word 0xe000e014
378: 0001d4bf .word 0x0001d4bf
37c: 20200000 .word 0x20200000
380: 5ab7eb85 .word 0x5ab7eb85
384: 4003e01c .word 0x4003e01c
388: 5a94c3a5 .word 0x5a94c3a5
38c: 4007f000 .word 0x4007f000
390: ffffffff .word 0xffffffff
394: ffffffff .word 0xffffffff
398: ffffffff .word 0xffffffff
39c: ffffffff .word 0xffffffff
3a0: ffffffff .word 0xffffffff
3a4: ffffffff .word 0xffffffff
3a8: ffffffff .word 0xffffffff
3ac: ffffffff .word 0xffffffff
3b0: ffffffff .word 0xffffffff
3b4: ffffffff .word 0xffffffff
3b8: ffffffff .word 0xffffffff
3bc: ffffffff .word 0xffffffff
3c0: ffffffff .word 0xffffffff
3c4: ffffffff .word 0xffffffff
3c8: ffffffff .word 0xffffffff
3cc: ffffffff .word 0xffffffff
3d0: ffffffff .word 0xffffffff
3d4: ffffffff .word 0xffffffff
3d8: ffffffff .word 0xffffffff
3dc: ffffffff .word 0xffffffff
3e0: ffffffff .word 0xffffffff
3e4: ffffffff .word 0xffffffff
3e8: ffffffff .word 0xffffffff
3ec: ffffffff .word 0xffffffff
3f0: ffffffff .word 0xffffffff
3f4: ffffffff .word 0xffffffff
3f8: ffffffff .word 0xffffffff
3fc: ffffffff .word 0xffffffff
00000400 <flashconfigbytes>:
400: ffffffff ffffffff ffffffff fffff9de ................
00000410 <__do_global_dtors_aux>:
410: b510 push {r4, lr}
412: 4c05 ldr r4, [pc, #20] ; (428 <__do_global_dtors_aux+0x18>)
414: 7823 ldrb r3, [r4, #0]
416: b933 cbnz r3, 426 <__do_global_dtors_aux+0x16>
418: 4b04 ldr r3, [pc, #16] ; (42c <__do_global_dtors_aux+0x1c>)
41a: b113 cbz r3, 422 <__do_global_dtors_aux+0x12>
41c: 4804 ldr r0, [pc, #16] ; (430 <__do_global_dtors_aux+0x20>)
41e: f3af 8000 nop.w
422: 2301 movs r3, #1
424: 7023 strb r3, [r4, #0]
426: bd10 pop {r4, pc}
428: 1fff91f4 .word 0x1fff91f4
42c: 00000000 .word 0x00000000
430: 00003928 .word 0x00003928
00000434 <frame_dummy>:
434: 4b08 ldr r3, [pc, #32] ; (458 <frame_dummy+0x24>)
436: b510 push {r4, lr}
438: b11b cbz r3, 442 <frame_dummy+0xe>
43a: 4908 ldr r1, [pc, #32] ; (45c <frame_dummy+0x28>)
43c: 4808 ldr r0, [pc, #32] ; (460 <frame_dummy+0x2c>)
43e: f3af 8000 nop.w
442: 4808 ldr r0, [pc, #32] ; (464 <frame_dummy+0x30>)
444: 6803 ldr r3, [r0, #0]
446: b903 cbnz r3, 44a <frame_dummy+0x16>
448: bd10 pop {r4, pc}
44a: 4b07 ldr r3, [pc, #28] ; (468 <frame_dummy+0x34>)
44c: 2b00 cmp r3, #0
44e: d0fb beq.n 448 <frame_dummy+0x14>
450: e8bd 4010 ldmia.w sp!, {r4, lr}
454: 4718 bx r3
456: bf00 nop
458: 00000000 .word 0x00000000
45c: 1fff91f8 .word 0x1fff91f8
460: 00003928 .word 0x00003928
464: 1fff91f4 .word 0x1fff91f4
468: 00000000 .word 0x00000000
0000046c <SensorNode::SensorNode(SensorPinData_t)>:
}
CurrentLEDState = LEDState;
}
}
SensorNode::SensorNode(SensorPinData_t PinData) {
46c: b430 push {r4, r5}
46e: b084 sub sp, #16
470: ac01 add r4, sp, #4
472: e884 000e stmia.w r4, {r1, r2, r3}
476: 4605 mov r5, r0
_PinData = PinData;
478: e894 0007 ldmia.w r4, {r0, r1, r2}
47c: f105 02cc add.w r2, r5, #204 ; 0xcc
480: e882 000b stmia.w r2, {r0, r1, r3}
}
484: 4628 mov r0, r5
486: b004 add sp, #16
488: bc30 pop {r4, r5}
48a: 4770 bx lr
0000048c <SensorNode::Init()>:
void SensorNode::Init() {
48c: b538 push {r3, r4, r5, lr}
48e: 4604 mov r4, r0
size_t print(char c) { return write((uint8_t)c); }
size_t print(const char s[]) { return write(s); }
size_t print(const __FlashStringHelper *f) { return write((const char *)f); }
size_t print(uint8_t b) { return printNumber(b, 10, 0); }
size_t print(int n) { return print((long)n); }
490: 4d18 ldr r5, [pc, #96] ; (4f4 <SensorNode::Init()+0x68>)
virtual int read() { return usb_serial_getchar(); }
virtual int peek() { return usb_serial_peekchar(); }
virtual void flush() { usb_serial_flush_output(); } // TODO: actually wait for data to leave USB...
virtual void clear(void) { usb_serial_flush_input(); }
virtual size_t write(uint8_t c) { return usb_serial_putchar(c); }
virtual size_t write(const uint8_t *buffer, size_t size) { return usb_serial_write(buffer, size); }
492: 4819 ldr r0, [pc, #100] ; (4f8 <SensorNode::Init()+0x6c>)
494: 210e movs r1, #14
496: f001 fc77 bl 1d88 <usb_serial_write>
49a: f8d4 10cc ldr.w r1, [r4, #204] ; 0xcc
49e: 4628 mov r0, r5
4a0: f000 f9f6 bl 890 <Print::print(long)>
Serial.print("Sensor On Pin ");
Serial.print(_PinData.PulsePin);
pinMode(_PinData.PulsePin, INPUT);
4a4: f894 00cc ldrb.w r0, [r4, #204] ; 0xcc
4a8: 2100 movs r1, #0
4aa: f000 fc81 bl db0 <pinMode>
pinMode(_PinData.LED1Pin, INPUT); //For tristate.
4ae: f894 00d0 ldrb.w r0, [r4, #208] ; 0xd0
4b2: 2100 movs r1, #0
4b4: f000 fc7c bl db0 <pinMode>
pinMode(_PinData.LED2Pin, INPUT);
4b8: f894 00d4 ldrb.w r0, [r4, #212] ; 0xd4
4bc: 2100 movs r1, #0
4be: f000 fc77 bl db0 <pinMode>
Angles[STATION_A][HORZ] = 0;
4c2: 2300 movs r3, #0
4c4: f8c4 30b0 str.w r3, [r4, #176] ; 0xb0
Angles[STATION_A][VERT] = 0;
4c8: f8c4 30b4 str.w r3, [r4, #180] ; 0xb4
Angles[STATION_B][HORZ] = 0;
4cc: f8c4 30b8 str.w r3, [r4, #184] ; 0xb8
Angles[STATION_B][VERT] = 0;
4d0: f8c4 30bc str.w r3, [r4, #188] ; 0xbc
Location[X_AXIS] = 0;
4d4: f8c4 30c0 str.w r3, [r4, #192] ; 0xc0
Location[Y_AXIS] = 0;
4d8: f8c4 30c4 str.w r3, [r4, #196] ; 0xc4
Location[Z_AXIS] = 0;
4dc: f8c4 30c8 str.w r3, [r4, #200] ; 0xc8
4e0: 2109 movs r1, #9
4e2: 4806 ldr r0, [pc, #24] ; (4fc <SensorNode::Init()+0x70>)
4e4: f001 fc50 bl 1d88 <usb_serial_write>
size_t print(double n, int digits = 2) { return printFloat(n, digits); }
size_t print(const Printable &obj) { return obj.printTo(*this); }
size_t println(void);
size_t println(const String &s) { return print(s) + println(); }
size_t println(char c) { return print(c) + println(); }
size_t println(const char s[]) { return print(s) + println(); }
4e8: 4628 mov r0, r5
Serial.println(" Complete");
}
4ea: e8bd 4038 ldmia.w sp!, {r3, r4, r5, lr}
4ee: f000 ba49 b.w 984 <Print::println()>
4f2: bf00 nop
4f4: 1fff88f8 .word 0x1fff88f8
4f8: 00003738 .word 0x00003738
4fc: 00003748 .word 0x00003748
00000500 <SensorNode::~SensorNode()>:
SensorNode::~SensorNode() {
}
500: 4770 bx lr
502: bf00 nop
00000504 <SensorNode::GetPulsePin()>:
u_int8_t SensorNode::GetPulsePin() {
return _PinData.PulsePin;
}
504: f890 00cc ldrb.w r0, [r0, #204] ; 0xcc
508: 4770 bx lr
50a: bf00 nop
0000050c <pit1_isr>:
void PLLSyncB() {
LastPLLTriggers[STATION_B] = CURRENT_TIME;
}
void pit1_isr() { // Pit1 on sync A
50c: b470 push {r4, r5, r6}
PIT_TFLG1 = PIT_TFLG_TIF; // Clear interrupt flag
PIT_TCTRL2 = 0; // Disable PIT2
50e: 4b09 ldr r3, [pc, #36] ; (534 <pit1_isr+0x28>)
PIT_TFLG1 = PIT_TFLG_TIF; // Clear interrupt flag
510: 4e09 ldr r6, [pc, #36] ; (538 <pit1_isr+0x2c>)
PIT_TFLG2 = PIT_TFLG_TIF; // Clear PIT2 Interrupt (so as not to immediately interrupt)
512: 4c0a ldr r4, [pc, #40] ; (53c <pit1_isr+0x30>)
LastPLLTriggers[STATION_A] = CURRENT_TIME;
514: 480a ldr r0, [pc, #40] ; (540 <pit1_isr+0x34>)
516: 490b ldr r1, [pc, #44] ; (544 <pit1_isr+0x38>)
PIT_TFLG1 = PIT_TFLG_TIF; // Clear interrupt flag
518: 2201 movs r2, #1
PIT_TCTRL2 = 0; // Disable PIT2
51a: 2500 movs r5, #0
PIT_TFLG1 = PIT_TFLG_TIF; // Clear interrupt flag
51c: 6032 str r2, [r6, #0]
PIT_TCTRL2 = 0; // Disable PIT2
51e: 601d str r5, [r3, #0]
PIT_TFLG2 = PIT_TFLG_TIF; // Clear PIT2 Interrupt (so as not to immediately interrupt)
520: 6022 str r2, [r4, #0]
PIT_TCTRL2 |= PIT_TCTRL_TIE | PIT_TCTRL_TEN; // Enable for the PIT2 interrupt, and start a new cycle.
522: 681a ldr r2, [r3, #0]
524: f042 0203 orr.w r2, r2, #3
528: 601a str r2, [r3, #0]
LastPLLTriggers[STATION_A] = CURRENT_TIME;
52a: 6803 ldr r3, [r0, #0]
52c: 43db mvns r3, r3
52e: 600b str r3, [r1, #0]
PLLSyncA();
}
530: bc70 pop {r4, r5, r6}
532: 4770 bx lr
534: 40037128 .word 0x40037128
538: 4003711c .word 0x4003711c
53c: 4003712c .word 0x4003712c
540: 40037104 .word 0x40037104
544: 1fff9214 .word 0x1fff9214
00000548 <pit2_isr>:
void pit2_isr() { // Pit2 on sync B
548: b430 push {r4, r5}
PIT_TFLG2 = PIT_TFLG_TIF; //Clear interrupt flag
PIT_TCTRL2 = 0; // Disable another interrupt by disabling timer
54a: 4906 ldr r1, [pc, #24] ; (564 <pit2_isr+0x1c>)
PIT_TFLG2 = PIT_TFLG_TIF; //Clear interrupt flag
54c: 4c06 ldr r4, [pc, #24] ; (568 <pit2_isr+0x20>)
LastPLLTriggers[STATION_B] = CURRENT_TIME;
54e: 4b07 ldr r3, [pc, #28] ; (56c <pit2_isr+0x24>)
550: 4a07 ldr r2, [pc, #28] ; (570 <pit2_isr+0x28>)
PIT_TFLG2 = PIT_TFLG_TIF; //Clear interrupt flag
552: 2501 movs r5, #1
PIT_TCTRL2 = 0; // Disable another interrupt by disabling timer
554: 2000 movs r0, #0
PIT_TFLG2 = PIT_TFLG_TIF; //Clear interrupt flag
556: 6025 str r5, [r4, #0]
PIT_TCTRL2 = 0; // Disable another interrupt by disabling timer
558: 6008 str r0, [r1, #0]
LastPLLTriggers[STATION_B] = CURRENT_TIME;
55a: 681b ldr r3, [r3, #0]
55c: 43db mvns r3, r3
55e: 6053 str r3, [r2, #4]
PLLSyncB();
}
560: bc30 pop {r4, r5}
562: 4770 bx lr
564: 40037128 .word 0x40037128
568: 4003712c .word 0x4003712c
56c: 40037104 .word 0x40037104
570: 1fff9214 .word 0x1fff9214
00000574 <PhaseLockTimeLock(unsigned long, unsigned long)>:
// LastCallTime = Now;
// LastStationEmu = CurrentStationEmu;
//}
void PhaseLockTimeLock(u_int32_t LastHardwareRiseA, u_int32_t LastHardwareRiseB) {
574: e92d 4ff0 stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp, lr}
static u_int32_t LastLastHardwareRiseA = 0;
static u_int32_t LastLastHardwareRiseB = 0;
static u_int32_t LastLastDelta = 0;
u_int32_t LastToThisA = LastHardwareRiseA - LastLastHardwareRiseA;
578: f8df 80b4 ldr.w r8, [pc, #180] ; 630 <PhaseLockTimeLock(unsigned long, unsigned long)+0xbc>
u_int32_t LastToThisB = LastHardwareRiseB - LastLastHardwareRiseB;
57c: 4e25 ldr r6, [pc, #148] ; (614 <PhaseLockTimeLock(unsigned long, unsigned long)+0xa0>)
u_int32_t LastDelta = LastHardwareRiseB - LastHardwareRiseA;
InterPulseTime = (0.9 * InterPulseTime) + (0.1 * ((LastToThisA + LastToThisB) / 2));
57e: f8d8 2000 ldr.w r2, [r8]
582: 6833 ldr r3, [r6, #0]
584: 4f24 ldr r7, [pc, #144] ; (618 <PhaseLockTimeLock(unsigned long, unsigned long)+0xa4>)
InterSyncTime = (0.9 * InterSyncTime) + (0.1 * ((LastDelta + LastLastDelta) / 2));
586: f8df 90ac ldr.w r9, [pc, #172] ; 634 <PhaseLockTimeLock(unsigned long, unsigned long)+0xc0>
58a: 4d24 ldr r5, [pc, #144] ; (61c <PhaseLockTimeLock(unsigned long, unsigned long)+0xa8>)
InterPulseTime = (0.9 * InterPulseTime) + (0.1 * ((LastToThisA + LastToThisB) / 2));
58c: 4413 add r3, r2
58e: 1acb subs r3, r1, r3
void PhaseLockTimeLock(u_int32_t LastHardwareRiseA, u_int32_t LastHardwareRiseB) {
590: 4682 mov sl, r0
InterPulseTime = (0.9 * InterPulseTime) + (0.1 * ((LastToThisA + LastToThisB) / 2));
592: 1818 adds r0, r3, r0
void PhaseLockTimeLock(u_int32_t LastHardwareRiseA, u_int32_t LastHardwareRiseB) {
594: b083 sub sp, #12
InterPulseTime = (0.9 * InterPulseTime) + (0.1 * ((LastToThisA + LastToThisB) / 2));
596: 0840 lsrs r0, r0, #1
void PhaseLockTimeLock(u_int32_t LastHardwareRiseA, u_int32_t LastHardwareRiseB) {
598: 460c mov r4, r1
InterPulseTime = (0.9 * InterPulseTime) + (0.1 * ((LastToThisA + LastToThisB) / 2));
59a: f002 fa4f bl 2a3c <__aeabi_ui2f>
59e: 4920 ldr r1, [pc, #128] ; (620 <PhaseLockTimeLock(unsigned long, unsigned long)+0xac>)
5a0: f002 faa4 bl 2aec <__aeabi_fmul>
5a4: 4683 mov fp, r0
5a6: 6838 ldr r0, [r7, #0]
5a8: f002 fa48 bl 2a3c <__aeabi_ui2f>
5ac: 491d ldr r1, [pc, #116] ; (624 <PhaseLockTimeLock(unsigned long, unsigned long)+0xb0>)
5ae: f002 fa9d bl 2aec <__aeabi_fmul>
5b2: 4601 mov r1, r0
5b4: 4658 mov r0, fp
5b6: f002 f991 bl 28dc <__addsf3>
5ba: f002 fbe7 bl 2d8c <__aeabi_f2uiz>
5be: 4683 mov fp, r0
InterSyncTime = (0.9 * InterSyncTime) + (0.1 * ((LastDelta + LastLastDelta) / 2));
5c0: f8d9 0000 ldr.w r0, [r9]
InterPulseTime = (0.9 * InterPulseTime) + (0.1 * ((LastToThisA + LastToThisB) / 2));
5c4: f8c7 b000 str.w fp, [r7]
u_int32_t LastDelta = LastHardwareRiseB - LastHardwareRiseA;
5c8: ebca 0704 rsb r7, sl, r4
InterSyncTime = (0.9 * InterSyncTime) + (0.1 * ((LastDelta + LastLastDelta) / 2));
5cc: 4438 add r0, r7
5ce: 0840 lsrs r0, r0, #1
5d0: f002 fa34 bl 2a3c <__aeabi_ui2f>
5d4: 4912 ldr r1, [pc, #72] ; (620 <PhaseLockTimeLock(unsigned long, unsigned long)+0xac>)
5d6: f002 fa89 bl 2aec <__aeabi_fmul>
5da: 9001 str r0, [sp, #4]
5dc: 6828 ldr r0, [r5, #0]
5de: f002 fa2d bl 2a3c <__aeabi_ui2f>
5e2: 4910 ldr r1, [pc, #64] ; (624 <PhaseLockTimeLock(unsigned long, unsigned long)+0xb0>)
5e4: f002 fa82 bl 2aec <__aeabi_fmul>
5e8: 9b01 ldr r3, [sp, #4]
5ea: 4601 mov r1, r0
5ec: 4618 mov r0, r3
5ee: f002 f975 bl 28dc <__addsf3>
5f2: f002 fbcb bl 2d8c <__aeabi_f2uiz>
PIT_LDVAL1 = Delta;
5f6: 4a0c ldr r2, [pc, #48] ; (628 <PhaseLockTimeLock(unsigned long, unsigned long)+0xb4>)
InterSyncTime = (0.9 * InterSyncTime) + (0.1 * ((LastDelta + LastLastDelta) / 2));
5f8: 6028 str r0, [r5, #0]
PIT_LDVAL1 = Delta;
5fa: f8c2 b000 str.w fp, [r2]
PIT_LDVAL2 = Delta;
5fe: 4b0b ldr r3, [pc, #44] ; (62c <PhaseLockTimeLock(unsigned long, unsigned long)+0xb8>)
SetPIT1Interrupt(InterPulseTime);
SetPIT2Interrupt(InterSyncTime);
600: 682a ldr r2, [r5, #0]
PIT_LDVAL2 = Delta;
602: 601a str r2, [r3, #0]
LastLastDelta = LastDelta;
604: f8c9 7000 str.w r7, [r9]
LastLastHardwareRiseA = LastHardwareRiseA;
608: f8c8 a000 str.w sl, [r8]
LastLastHardwareRiseB = LastHardwareRiseB;
60c: 6034 str r4, [r6, #0]
}
60e: b003 add sp, #12
610: e8bd 8ff0 ldmia.w sp!, {r4, r5, r6, r7, r8, r9, sl, fp, pc}
614: 1fff9220 .word 0x1fff9220
618: 1fff8800 .word 0x1fff8800
61c: 1fff8804 .word 0x1fff8804
620: 3dcccccd .word 0x3dcccccd
624: 3f666666 .word 0x3f666666
628: 40037110 .word 0x40037110
62c: 40037120 .word 0x40037120
630: 1fff921c .word 0x1fff921c
634: 1fff9210 .word 0x1fff9210
00000638 <InitTimer()>:
// return F_BUS / 1000000;
//}
// PIT 0 - Current Time, loaded with uint32max and counts down.
// PIT 1 - Phaselock Timer on SyncA
// PIT 2 - Phaselock Timer on SyncB
void InitTimer() {
638: b5f0 push {r4, r5, r6, r7, lr}
noInterrupts();
63a: b672 cpsid i
SIM_SCGC6 |= SIM_SCGC6_PIT;
63c: 4a0b ldr r2, [pc, #44] ; (66c <InitTimer()+0x34>)
PIT_MCR = 0;
63e: 4f0c ldr r7, [pc, #48] ; (670 <InitTimer()+0x38>)
SIM_SCGC6 |= SIM_SCGC6_PIT;
640: 6813 ldr r3, [r2, #0]
PIT_LDVAL0 = UINT32_MAX; // Setup current time PIT. Free Running. Never stops
642: 4e0c ldr r6, [pc, #48] ; (674 <InitTimer()+0x3c>)
PIT_TCTRL0 = PIT_TCTRL_TEN;
644: 4c0c ldr r4, [pc, #48] ; (678 <InitTimer()+0x40>)
PIT_LDVAL1 = UINT32_MAX; // Start up the timer, will interrupt soon. This will be changed by phaselock loop
646: 480d ldr r0, [pc, #52] ; (67c <InitTimer()+0x44>)
PIT_TCTRL1 = PIT_TCTRL_TEN | PIT_TCTRL_TIE;
648: 490d ldr r1, [pc, #52] ; (680 <InitTimer()+0x48>)
SIM_SCGC6 |= SIM_SCGC6_PIT;
64a: f443 0300 orr.w r3, r3, #8388608 ; 0x800000
64e: 6013 str r3, [r2, #0]
PIT_MCR = 0;
650: f04f 0e00 mov.w lr, #0
PIT_LDVAL0 = UINT32_MAX; // Setup current time PIT. Free Running. Never stops
654: f04f 33ff mov.w r3, #4294967295
PIT_TCTRL0 = PIT_TCTRL_TEN;
658: 2501 movs r5, #1
PIT_TCTRL1 = PIT_TCTRL_TEN | PIT_TCTRL_TIE;
65a: 2203 movs r2, #3
PIT_MCR = 0;
65c: f8c7 e000 str.w lr, [r7]
PIT_LDVAL0 = UINT32_MAX; // Setup current time PIT. Free Running. Never stops
660: 6033 str r3, [r6, #0]
PIT_TCTRL0 = PIT_TCTRL_TEN;
662: 6025 str r5, [r4, #0]
PIT_LDVAL1 = UINT32_MAX; // Start up the timer, will interrupt soon. This will be changed by phaselock loop
664: 6003 str r3, [r0, #0]
PIT_TCTRL1 = PIT_TCTRL_TEN | PIT_TCTRL_TIE;
666: 600a str r2, [r1, #0]
//PIT_LDVAL2 = UINT32_MAX; // Start up the timer, will interrupt soon. This will be changed by phaselock loop
//PIT_TCTRL2 = PIT_TCTRL_TEN | PIT_TCTRL_TIE;
interrupts();
668: b662 cpsie i
66a: bdf0 pop {r4, r5, r6, r7, pc}
66c: 4004803c .word 0x4004803c
670: 40037000 .word 0x40037000
674: 40037100 .word 0x40037100
678: 40037108 .word 0x40037108
67c: 40037110 .word 0x40037110
680: 40037118 .word 0x40037118
00000684 <Interrupt0Change()>:
Nodes[ID].NewSweepPinInterrupt(LastCallToNow,Now);\
}\
}\
}
void Interrupt0Change() INTERRUPT_CHANGE_FUNCTION(0);
684: 4b15 ldr r3, [pc, #84] ; (6dc <Interrupt0Change()+0x58>)
686: 681b ldr r3, [r3, #0]
688: 43db mvns r3, r3
68a: b662 cpsie i
68c: 4914 ldr r1, [pc, #80] ; (6e0 <Interrupt0Change()+0x5c>)
68e: 680a ldr r2, [r1, #0]
690: 1a9a subs r2, r3, r2
692: f5b2 6fe1 cmp.w r2, #1800 ; 0x708
696: d908 bls.n 6aa <Interrupt0Change()+0x26>
698: b430 push {r4, r5}
69a: f241 2048 movw r0, #4680 ; 0x1248
69e: f6a2 6488 subw r4, r2, #3720 ; 0xe88
6a2: 4284 cmp r4, r0
6a4: 600b str r3, [r1, #0]
6a6: d901 bls.n 6ac <Interrupt0Change()+0x28>
6a8: bc30 pop {r4, r5}
6aa: 4770 bx lr
Pulse LatestHardwareBaseSync[2];
//
void NewSyncPinInterrupt(u_int8_t SourceNode, u_int32_t PulseLength, u_int32_t PulseStartTime) {
static Pulse LastDetectedSync = {0, 0};
if (!IN_RANGE(0, PulseStartTime - LastDetectedSync.StartTime,
6ac: 480d ldr r0, [pc, #52] ; (6e4 <Interrupt0Change()+0x60>)
6ae: 6841 ldr r1, [r0, #4]
6b0: 1a59 subs r1, r3, r1
6b2: f5b1 6fe1 cmp.w r1, #1800 ; 0x708
6b6: d9f7 bls.n 6a8 <Interrupt0Change()+0x24>
PULSETRAIN_SYNC_DISCREPANCY)) { // New Sync Pulse? (multiple nodes feed same function)
u_int8_t SourceStation = IN_RANGE(0, PulseStartTime - LastDetectedSync.StartTime, US_TO_TICKS(1000));
LastDetectedSync.StartTime = LatestHardwareBaseSync[SourceStation].StartTime = PulseStartTime;
6b8: f64e 2460 movw r4, #60000 ; 0xea60
6bc: 4d0a ldr r5, [pc, #40] ; (6e8 <Interrupt0Change()+0x64>)
LastDetectedSync.Length = LatestHardwareBaseSync[SourceStation].Length = PulseLength;
6be: 6002 str r2, [r0, #0]
LastDetectedSync.StartTime = LatestHardwareBaseSync[SourceStation].StartTime = PulseStartTime;
6c0: 42a1 cmp r1, r4
6c2: bf94 ite ls
6c4: 210c movls r1, #12
6c6: 2100 movhi r1, #0
6c8: 186c adds r4, r5, r1
LastDetectedSync.Length = LatestHardwareBaseSync[SourceStation].Length = PulseLength;
6ca: 506a str r2, [r5, r1]
LatestHardwareBaseSync[SourceStation].New = true;
6cc: 7a21 ldrb r1, [r4, #8]
LastDetectedSync.StartTime = LatestHardwareBaseSync[SourceStation].StartTime = PulseStartTime;
6ce: 6043 str r3, [r0, #4]
LatestHardwareBaseSync[SourceStation].New = true;
6d0: f041 0201 orr.w r2, r1, #1
LastDetectedSync.StartTime = LatestHardwareBaseSync[SourceStation].StartTime = PulseStartTime;
6d4: 6063 str r3, [r4, #4]
LatestHardwareBaseSync[SourceStation].New = true;
6d6: 7222 strb r2, [r4, #8]
void Interrupt0Change() INTERRUPT_CHANGE_FUNCTION(0);
6d8: e7e6 b.n 6a8 <Interrupt0Change()+0x24>
6da: bf00 nop
6dc: 40037104 .word 0x40037104
6e0: 1fff9230 .word 0x1fff9230
6e4: 1fff9224 .word 0x1fff9224
6e8: 1fff9234 .word 0x1fff9234
000006ec <__tcf_0>:
SensorNode Nodes[] = {SENSOR_1_PINS};
6ec: 4801 ldr r0, [pc, #4] ; (6f4 <__tcf_0+0x8>)
6ee: f7ff bf07 b.w 500 <SensorNode::~SensorNode()>
6f2: bf00 nop
6f4: 1fff9250 .word 0x1fff9250
000006f8 <MainSetup()>:
void MainSetup() {
6f8: b510 push {r4, lr}
pinMode(LED_BUILTIN, OUTPUT);
6fa: 2101 movs r1, #1
6fc: 200d movs r0, #13
Nodes[i].Init();
6fe: 4c12 ldr r4, [pc, #72] ; (748 <MainSetup()+0x50>)
pinMode(LED_BUILTIN, OUTPUT);
700: f000 fb56 bl db0 <pinMode>
delay(2000);
704: f44f 60fa mov.w r0, #2000 ; 0x7d0
708: f000 fb8e bl e28 <delay>
Nodes[i].Init();
70c: 4620 mov r0, r4
70e: f7ff febd bl 48c <SensorNode::Init()>
delay(100);
712: 2064 movs r0, #100 ; 0x64
714: f000 fb88 bl e28 <delay>
InitTimer(); //Start up better timer (If using)
718: f7ff ff8e bl 638 <InitTimer()>
71c: 2112 movs r1, #18
71e: 480b ldr r0, [pc, #44] ; (74c <MainSetup()+0x54>)
720: f001 fb32 bl 1d88 <usb_serial_write>
attachInterrupt(Nodes[0].GetPulsePin(), Interrupt0Change, CHANGE);
724: 4620 mov r0, r4
726: f7ff feed bl 504 <SensorNode::GetPulsePin()>
72a: 2204 movs r2, #4
72c: 4908 ldr r1, [pc, #32] ; (750 <MainSetup()+0x58>)
72e: f000 f9b9 bl aa4 <attachInterrupt>
732: 2108 movs r1, #8
734: 4807 ldr r0, [pc, #28] ; (754 <MainSetup()+0x5c>)
736: f001 fb27 bl 1d88 <usb_serial_write>
73a: 4807 ldr r0, [pc, #28] ; (758 <MainSetup()+0x60>)
73c: f000 f922 bl 984 <Print::println()>
} else if (pin == 11) {
CORE_PIN11_PORTSET = CORE_PIN11_BITMASK;
} else if (pin == 12) {
CORE_PIN12_PORTSET = CORE_PIN12_BITMASK;
} else if (pin == 13) {
CORE_PIN13_PORTSET = CORE_PIN13_BITMASK;
740: 4b06 ldr r3, [pc, #24] ; (75c <MainSetup()+0x64>)
742: 2220 movs r2, #32
744: 601a str r2, [r3, #0]
746: bd10 pop {r4, pc}
748: 1fff9250 .word 0x1fff9250
74c: 00003754 .word 0x00003754
750: 00000685 .word 0x00000685
754: 00003768 .word 0x00003768
758: 1fff88f8 .word 0x1fff88f8
75c: 400ff084 .word 0x400ff084
00000760 <main>:
//
// }
}
int main() {
760: b580 push {r7, lr}
762: 4f30 ldr r7, [pc, #192] ; (824 <main+0xc4>)
764: 4c30 ldr r4, [pc, #192] ; (828 <main+0xc8>)
u_int32_t RunStartTime = CURRENT_TIME;
766: 4e31 ldr r6, [pc, #196] ; (82c <main+0xcc>)
NextSweepSource = SKIP(SyncPulseMeaning) ? NextSweepSource : STATION_A;
768: 4d31 ldr r5, [pc, #196] ; (830 <main+0xd0>)
MainSetup();
76a: f7ff ffc5 bl 6f8 <MainSetup()>
delay(200);
76e: 20c8 movs r0, #200 ; 0xc8
770: f000 fb5a bl e28 <delay>
if (LatestHardwareBaseSync[STATION_A].New) {
774: 46b8 mov r8, r7
776: e001 b.n 77c <main+0x1c>
while (true) {
MainLoop();
yield(); // Critical for interrupts. For some reason. TODO Investigate.
778: f001 fc5a bl 2030 <yield>
if (LatestHardwareBaseSync[STATION_A].New) {
77c: 7a3b ldrb r3, [r7, #8]
u_int32_t RunStartTime = CURRENT_TIME;
77e: 6832 ldr r2, [r6, #0]
if (LatestHardwareBaseSync[STATION_A].New) {
780: 07d8 lsls r0, r3, #31
u_int32_t RunStartTime = CURRENT_TIME;
782: ea6f 0202 mvn.w r2, r2
if (LatestHardwareBaseSync[STATION_A].New) {
786: d51b bpl.n 7c0 <main+0x60>
noInterrupts();
788: b672 cpsid i
LatestHardwareBaseSync[STATION_A].New = false;
78a: f898 1008 ldrb.w r1, [r8, #8]
Pulse SafeCopy = LatestHardwareBaseSync[STATION_A];
78e: f8d8 3000 ldr.w r3, [r8]
LatestHardwareBaseSync[STATION_A].New = false;
792: f36f 0100 bfc r1, #0, #1
796: f888 1008 strb.w r1, [r8, #8]
interrupts();
79a: b662 cpsie i
NextSweepSource = SKIP(SyncPulseMeaning) ? NextSweepSource : STATION_A;
79c: 4925 ldr r1, [pc, #148] ; (834 <main+0xd4>)
79e: eb03 0343 add.w r3, r3, r3, lsl #1
7a2: 011b lsls r3, r3, #4
7a4: fba1 1303 umull r1, r3, r1, r3
7a8: 095b lsrs r3, r3, #5
7aa: f6a3 13c5 subw r3, r3, #2501 ; 0x9c5
7ae: fba5 1303 umull r1, r3, r5, r3
7b2: f3c3 1347 ubfx r3, r3, #5, #8
7b6: f013 0304 ands.w r3, r3, #4