tao_z
2022-05-25 1044ba0d2286698d0da28112bffc0f114bef2134
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
/**
  ******************************************************************************
  * @file     xl_ftm.h
  * @author   software group
  * @brief    This file contains all the functions prototypes for the FTM 
  *           firmware library.
  ******************************************************************************
  * @attention
    *
  * 2019 by Chipways Communications,Inc. All Rights Reserved.
  * This software is supplied under the terms of a license
  * agreement or non-disclosure agreement with Chipways.
  * Passing on and copying of this document,and communication
  * of its contents is not permitted without prior written
  * authorization.
  *
  * <h2><center>&copy; COPYRIGHT 2019 Chipways</center></h2>
  ******************************************************************************
  */
    
/* Define to prevent recursive inclusion -------------------------------------*/      
#ifndef XL_FTM_H__
#define XL_FTM_H__
 
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ---------------------------------------------------------------*/
#include <XL6600.h>
/* Register define ------------------------------------------------------------*/
/* SC Bit Fields */
#define FTM_SC_PS_MASK                           0x7u
#define FTM_SC_PS_SHIFT                          0
#define FTM_SC_CLKS_MASK                         0x18u
#define FTM_SC_CLKS_SHIFT                        3
#define FTM_SC_CPWMS_MASK                        0x20u
#define FTM_SC_CPWMS_SHIFT                       5
#define FTM_SC_TOIE_MASK                         0x40u
#define FTM_SC_TOIE_SHIFT                        6
#define FTM_SC_TOF_MASK                          0x80u
#define FTM_SC_TOF_SHIFT                         7
    
/* CNT Bit Fields */
#define FTM_CNT_COUNT_MASK                       0xFFFFu
#define FTM_CNT_COUNT_SHIFT                      0
    
/* MOD Bit Fields */
#define FTM_MOD_MOD_MASK                         0xFFFFu
#define FTM_MOD_MOD_SHIFT                        0
 
/* CnSC Bit Fields */
#define FTM_CnSC_ELSA_MASK                       0x4u
#define FTM_CnSC_ELSA_SHIFT                      2
#define FTM_CnSC_ELSB_MASK                       0x8u
#define FTM_CnSC_ELSB_SHIFT                      3
#define FTM_CnSC_MSA_MASK                        0x10u
#define FTM_CnSC_MSA_SHIFT                       4
#define FTM_CnSC_MSB_MASK                        0x20u
#define FTM_CnSC_MSB_SHIFT                       5
#define FTM_CnSC_CHIE_MASK                       0x40u
#define FTM_CnSC_CHIE_SHIFT                      6
#define FTM_CnSC_CHF_MASK                        0x80u
#define FTM_CnSC_CHF_SHIFT                       7
 
/* CnV Bit Fields */
#define FTM_CnV_VAL_MASK                         0xFFFFu
#define FTM_CnV_VAL_SHIFT                        0
 
/* CNTIN Bit Fields */
#define FTM_CNTIN_INIT_MASK                      0xFFFFu
#define FTM_CNTIN_INIT_SHIFT                     0
 
/* STATUS Bit Fields */
#define FTM_STATUS_CH0F_MASK                     0x1u
#define FTM_STATUS_CH0F_SHIFT                    0
#define FTM_STATUS_CH1F_MASK                     0x2u
#define FTM_STATUS_CH1F_SHIFT                    1
#define FTM_STATUS_CH2F_MASK                     0x4u
#define FTM_STATUS_CH2F_SHIFT                    2
#define FTM_STATUS_CH3F_MASK                     0x8u
#define FTM_STATUS_CH3F_SHIFT                    3
#define FTM_STATUS_CH4F_MASK                     0x10u
#define FTM_STATUS_CH4F_SHIFT                    4
#define FTM_STATUS_CH5F_MASK                     0x20u
#define FTM_STATUS_CH5F_SHIFT                    5
#define FTM_STATUS_CH6F_MASK                     0x40u
#define FTM_STATUS_CH6F_SHIFT                    6
#define FTM_STATUS_CH7F_MASK                     0x80u
#define FTM_STATUS_CH7F_SHIFT                    7
 
/* MODE Bit Fields */
#define FTM_MODE_SYNCLOADEN_MASK                 0x1u
#define FTM_MODE_SYNCLOADEN_SHIFT                0
#define FTM_MODE_INIT_MASK                       0x2u
#define FTM_MODE_INIT_SHIFT                      1
#define FTM_MODE_WPDIS_MASK                      0x4u
#define FTM_MODE_WPDIS_SHIFT                     2
#define FTM_MODE_PWMSYNC_MASK                    0x8u
#define FTM_MODE_PWMSYNC_SHIFT                   3
#define FTM_MODE_CAPTEST_MASK                    0x10u
#define FTM_MODE_CAPTEST_SHIFT                   4
#define FTM_MODE_FAULTM_MASK                     0x60u
#define FTM_MODE_FAULTM_SHIFT                    5
#define FTM_MODE_FAULTIE_MASK                    0x80u
#define FTM_MODE_FAULTIE_SHIFT                   7
 
/* SYNC Bit Fields */
#define FTM_SYNC_CNTMIN_MASK                     0x1u
#define FTM_SYNC_CNTMIN_SHIFT                    0
#define FTM_SYNC_CNTMAX_MASK                     0x2u
#define FTM_SYNC_CNTMAX_SHIFT                    1
#define FTM_SYNC_REINIT_MASK                     0x4u
#define FTM_SYNC_REINIT_SHIFT                    2
#define FTM_SYNC_SYNCHOM_MASK                    0x8u
#define FTM_SYNC_SYNCHOM_SHIFT                   3
#define FTM_SYNC_TRIG0_MASK                      0x10u
#define FTM_SYNC_TRIG0_SHIFT                     4
#define FTM_SYNC_TRIG1_MASK                      0x20u
#define FTM_SYNC_TRIG1_SHIFT                     5
#define FTM_SYNC_TRIG2_MASK                      0x40u
#define FTM_SYNC_TRIG2_SHIFT                     6
#define FTM_SYNC_SWSYNC_MASK                     0x80u
#define FTM_SYNC_SWSYNC_SHIFT                    7
 
/* OUTINIT Bit Fields */
#define FTM_OUTINIT_CH0OI_MASK                   0x1u
#define FTM_OUTINIT_CH0OI_SHIFT                  0
#define FTM_OUTINIT_CH1OI_MASK                   0x2u
#define FTM_OUTINIT_CH1OI_SHIFT                  1
#define FTM_OUTINIT_CH2OI_MASK                   0x4u
#define FTM_OUTINIT_CH2OI_SHIFT                  2
#define FTM_OUTINIT_CH3OI_MASK                   0x8u
#define FTM_OUTINIT_CH3OI_SHIFT                  3
#define FTM_OUTINIT_CH4OI_MASK                   0x10u
#define FTM_OUTINIT_CH4OI_SHIFT                  4
#define FTM_OUTINIT_CH5OI_MASK                   0x20u
#define FTM_OUTINIT_CH5OI_SHIFT                  5
#define FTM_OUTINIT_CH6OI_MASK                   0x40u
#define FTM_OUTINIT_CH6OI_SHIFT                  6
#define FTM_OUTINIT_CH7OI_MASK                   0x80u
#define FTM_OUTINIT_CH7OI_SHIFT                  7
 
/* OUTMASK Bit Fields */
#define FTM_OUTMASK_CH0OM_MASK                   0x1u
#define FTM_OUTMASK_CH0OM_SHIFT                  0
#define FTM_OUTMASK_CH1OM_MASK                   0x2u
#define FTM_OUTMASK_CH1OM_SHIFT                  1
#define FTM_OUTMASK_CH2OM_MASK                   0x4u
#define FTM_OUTMASK_CH2OM_SHIFT                  2
#define FTM_OUTMASK_CH3OM_MASK                   0x8u
#define FTM_OUTMASK_CH3OM_SHIFT                  3
#define FTM_OUTMASK_CH4OM_MASK                   0x10u
#define FTM_OUTMASK_CH4OM_SHIFT                  4
#define FTM_OUTMASK_CH5OM_MASK                   0x20u
#define FTM_OUTMASK_CH5OM_SHIFT                  5
#define FTM_OUTMASK_CH6OM_MASK                   0x40u
#define FTM_OUTMASK_CH6OM_SHIFT                  6
#define FTM_OUTMASK_CH7OM_MASK                   0x80u
#define FTM_OUTMASK_CH7OM_SHIFT                  7
 
/* COMBINE Bit Fields */
#define FTM_COMBINE_COMBINE0_MASK                0x1u
#define FTM_COMBINE_COMBINE0_SHIFT               0
#define FTM_COMBINE_COMP0_MASK                   0x2u
#define FTM_COMBINE_COMP0_SHIFT                  1
#define FTM_COMBINE_DECAPEN0_MASK                0x4u
#define FTM_COMBINE_DECAPEN0_SHIFT               2
#define FTM_COMBINE_DECAP0_MASK                  0x8u
#define FTM_COMBINE_DECAP0_SHIFT                 3
#define FTM_COMBINE_DTEN0_MASK                   0x10u
#define FTM_COMBINE_DTEN0_SHIFT                  4
#define FTM_COMBINE_SYNCEN0_MASK                 0x20u
#define FTM_COMBINE_SYNCEN0_SHIFT                5
#define FTM_COMBINE_FAULTEN0_MASK                0x40u
#define FTM_COMBINE_FAULTEN0_SHIFT               6
#define FTM_COMBINE_COMBINE1_MASK                0x100u
#define FTM_COMBINE_COMBINE1_SHIFT               8
#define FTM_COMBINE_COMP1_MASK                   0x200u
#define FTM_COMBINE_COMP1_SHIFT                  9
#define FTM_COMBINE_DECAPEN1_MASK                0x400u
#define FTM_COMBINE_DECAPEN1_SHIFT               10
#define FTM_COMBINE_DECAP1_MASK                  0x800u
#define FTM_COMBINE_DECAP1_SHIFT                 11
#define FTM_COMBINE_DTEN1_MASK                   0x1000u
#define FTM_COMBINE_DTEN1_SHIFT                  12
#define FTM_COMBINE_SYNCEN1_MASK                 0x2000u
#define FTM_COMBINE_SYNCEN1_SHIFT                13
#define FTM_COMBINE_FAULTEN1_MASK                0x4000u
#define FTM_COMBINE_FAULTEN1_SHIFT               14
#define FTM_COMBINE_COMBINE2_MASK                0x10000u
#define FTM_COMBINE_COMBINE2_SHIFT               16
#define FTM_COMBINE_COMP2_MASK                   0x20000u
#define FTM_COMBINE_COMP2_SHIFT                  17
#define FTM_COMBINE_DECAPEN2_MASK                0x40000u
#define FTM_COMBINE_DECAPEN2_SHIFT               18
#define FTM_COMBINE_DECAP2_MASK                  0x80000u
#define FTM_COMBINE_DECAP2_SHIFT                 19
#define FTM_COMBINE_DTEN2_MASK                   0x100000u
#define FTM_COMBINE_DTEN2_SHIFT                  20
#define FTM_COMBINE_SYNCEN2_MASK                 0x200000u
#define FTM_COMBINE_SYNCEN2_SHIFT                21
#define FTM_COMBINE_FAULTEN2_MASK                0x400000u
#define FTM_COMBINE_FAULTEN2_SHIFT               22
#define FTM_COMBINE_COMBINE3_MASK                0x1000000u
#define FTM_COMBINE_COMBINE3_SHIFT               24
#define FTM_COMBINE_COMP3_MASK                   0x2000000u
#define FTM_COMBINE_COMP3_SHIFT                  25
#define FTM_COMBINE_DECAPEN3_MASK                0x4000000u
#define FTM_COMBINE_DECAPEN3_SHIFT               26
#define FTM_COMBINE_DECAP3_MASK                  0x8000000u
#define FTM_COMBINE_DECAP3_SHIFT                 27
#define FTM_COMBINE_DTEN3_MASK                   0x10000000u
#define FTM_COMBINE_DTEN3_SHIFT                  28
#define FTM_COMBINE_SYNCEN3_MASK                 0x20000000u
#define FTM_COMBINE_SYNCEN3_SHIFT                29
#define FTM_COMBINE_FAULTEN3_MASK                0x40000000u
#define FTM_COMBINE_FAULTEN3_SHIFT               30
 
/* DEADTIME Bit Fields */
#define FTM_DEADTIME_DTVAL_MASK                  0x3Fu
#define FTM_DEADTIME_DTVAL_SHIFT                 0
#define FTM_DEADTIME_DTPS_MASK                   0xC0u
#define FTM_DEADTIME_DTPS_SHIFT                  6
 
/* EXTTRIG Bit Fields */
#define FTM_EXTTRIG_CH2TRIG_MASK                 0x1u
#define FTM_EXTTRIG_CH2TRIG_SHIFT                0
#define FTM_EXTTRIG_CH3TRIG_MASK                 0x2u
#define FTM_EXTTRIG_CH3TRIG_SHIFT                1
#define FTM_EXTTRIG_CH4TRIG_MASK                 0x4u
#define FTM_EXTTRIG_CH4TRIG_SHIFT                2
#define FTM_EXTTRIG_CH5TRIG_MASK                 0x8u
#define FTM_EXTTRIG_CH5TRIG_SHIFT                3
#define FTM_EXTTRIG_CH0TRIG_MASK                 0x10u
#define FTM_EXTTRIG_CH0TRIG_SHIFT                4
#define FTM_EXTTRIG_CH1TRIG_MASK                 0x20u
#define FTM_EXTTRIG_CH1TRIG_SHIFT                5
#define FTM_EXTTRIG_INITTRIGEN_MASK              0x40u
#define FTM_EXTTRIG_INITTRIGEN_SHIFT             6
#define FTM_EXTTRIG_TRIGF_MASK                   0x80u
#define FTM_EXTTRIG_TRIGF_SHIFT                  7
 
/* POL Bit Fields */
#define FTM_POL_POL0_MASK                        0x1u
#define FTM_POL_POL0_SHIFT                       0
#define FTM_POL_POL1_MASK                        0x2u
#define FTM_POL_POL1_SHIFT                       1
#define FTM_POL_POL2_MASK                        0x4u
#define FTM_POL_POL2_SHIFT                       2
#define FTM_POL_POL3_MASK                        0x8u
#define FTM_POL_POL3_SHIFT                       3
#define FTM_POL_POL4_MASK                        0x10u
#define FTM_POL_POL4_SHIFT                       4
#define FTM_POL_POL5_MASK                        0x20u
#define FTM_POL_POL5_SHIFT                       5
#define FTM_POL_POL6_MASK                        0x40u
#define FTM_POL_POL6_SHIFT                       6
#define FTM_POL_POL7_MASK                        0x80u
#define FTM_POL_POL7_SHIFT                       7
 
/* FMS Bit Fields */
#define FTM_FMS_FAULTF0_MASK                     0x1u
#define FTM_FMS_FAULTF0_SHIFT                    0
#define FTM_FMS_FAULTF1_MASK                     0x2u
#define FTM_FMS_FAULTF1_SHIFT                    1
#define FTM_FMS_FAULTF2_MASK                     0x4u
#define FTM_FMS_FAULTF2_SHIFT                    2
#define FTM_FMS_FAULTF3_MASK                     0x8u
#define FTM_FMS_FAULTF3_SHIFT                    3
#define FTM_FMS_FAULTIN_MASK                     0x20u
#define FTM_FMS_FAULTIN_SHIFT                    5
#define FTM_FMS_WPEN_MASK                        0x40u
#define FTM_FMS_WPEN_SHIFT                       6
#define FTM_FMS_FAULTF_MASK                      0x80u
#define FTM_FMS_FAULTF_SHIFT                     7
 
/* FILTER Bit Fields */
#define FTM_FILTER_CH0FVAL_MASK                  0xFu
#define FTM_FILTER_CH0FVAL_SHIFT                 0
#define FTM_FILTER_CH1FVAL_MASK                  0xF0u
#define FTM_FILTER_CH1FVAL_SHIFT                 4
#define FTM_FILTER_CH2FVAL_MASK                  0xF00u
#define FTM_FILTER_CH2FVAL_SHIFT                 8
#define FTM_FILTER_CH3FVAL_MASK                  0xF000u
#define FTM_FILTER_CH3FVAL_SHIFT                 12
 
/* FLTCTRL Bit Fields */
#define FTM_FLTCTRL_FAULT0EN_MASK                0x1u
#define FTM_FLTCTRL_FAULT0EN_SHIFT               0
#define FTM_FLTCTRL_FAULT1EN_MASK                0x2u
#define FTM_FLTCTRL_FAULT1EN_SHIFT               1
#define FTM_FLTCTRL_FAULT2EN_MASK                0x4u
#define FTM_FLTCTRL_FAULT2EN_SHIFT               2
#define FTM_FLTCTRL_FAULT3EN_MASK                0x8u
#define FTM_FLTCTRL_FAULT3EN_SHIFT               3
#define FTM_FLTCTRL_FFLTR0EN_MASK                0x10u
#define FTM_FLTCTRL_FFLTR0EN_SHIFT               4
#define FTM_FLTCTRL_FFLTR1EN_MASK                0x20u
#define FTM_FLTCTRL_FFLTR1EN_SHIFT               5
#define FTM_FLTCTRL_FFLTR2EN_MASK                0x40u
#define FTM_FLTCTRL_FFLTR2EN_SHIFT               6
#define FTM_FLTCTRL_FFLTR3EN_MASK                0x80u
#define FTM_FLTCTRL_FFLTR3EN_SHIFT               7
#define FTM_FLTCTRL_FFVAL_MASK                   0xF00u
#define FTM_FLTCTRL_FFVAL_SHIFT                  8
 
/* CONF Bit Fields */
#define FTM_CONF_NUMTOF_MASK                     0x1Fu
#define FTM_CONF_NUMTOF_SHIFT                    0
#define FTM_CONF_BDMMODE_MASK                    0xC0u
#define FTM_CONF_BDMMODE_SHIFT                   6
#define FTM_CONF_GTBEEN_MASK                     0x200u
#define FTM_CONF_GTBEEN_SHIFT                    9
#define FTM_CONF_GTBEOUT_MASK                    0x400u
#define FTM_CONF_GTBEOUT_SHIFT                   10
 
/* FLTPOL Bit Fields */
#define FTM_FLTPOL_FLT0POL_MASK                  0x1u
#define FTM_FLTPOL_FLT0POL_SHIFT                 0
#define FTM_FLTPOL_FLT1POL_MASK                  0x2u
#define FTM_FLTPOL_FLT1POL_SHIFT                 1
#define FTM_FLTPOL_FLT2POL_MASK                  0x4u
#define FTM_FLTPOL_FLT2POL_SHIFT                 2
#define FTM_FLTPOL_FLT3POL_MASK                  0x8u
#define FTM_FLTPOL_FLT3POL_SHIFT                 3
 
/* SYNCONF Bit Fields */
#define FTM_SYNCONF_HWTRIGMODE_MASK              0x1u
#define FTM_SYNCONF_HWTRIGMODE_SHIFT             0
#define FTM_SYNCONF_CNTINC_MASK                  0x4u
#define FTM_SYNCONF_CNTINC_SHIFT                 2
#define FTM_SYNCONF_INVC_MASK                    0x10u
#define FTM_SYNCONF_INVC_SHIFT                   4
#define FTM_SYNCONF_SWOC_MASK                    0x20u
#define FTM_SYNCONF_SWOC_SHIFT                   5
#define FTM_SYNCONF_SYNCMODE_MASK                0x80u
#define FTM_SYNCONF_SYNCMODE_SHIFT               7
#define FTM_SYNCONF_SWRSTCNT_MASK                0x100u
#define FTM_SYNCONF_SWRSTCNT_SHIFT               8
#define FTM_SYNCONF_SWWRBUF_MASK                 0x200u
#define FTM_SYNCONF_SWWRBUF_SHIFT                9
#define FTM_SYNCONF_SWOM_MASK                    0x400u
#define FTM_SYNCONF_SWOM_SHIFT                   10
#define FTM_SYNCONF_SWINVC_MASK                  0x800u
#define FTM_SYNCONF_SWINVC_SHIFT                 11
#define FTM_SYNCONF_SWSOC_MASK                   0x1000u
#define FTM_SYNCONF_SWSOC_SHIFT                  12
#define FTM_SYNCONF_HWRSTCNT_MASK                0x10000u
#define FTM_SYNCONF_HWRSTCNT_SHIFT               16
#define FTM_SYNCONF_HWWRBUF_MASK                 0x20000u
#define FTM_SYNCONF_HWWRBUF_SHIFT                17
#define FTM_SYNCONF_HWOM_MASK                    0x40000u
#define FTM_SYNCONF_HWOM_SHIFT                   18
#define FTM_SYNCONF_HWINVC_MASK                  0x80000u
#define FTM_SYNCONF_HWINVC_SHIFT                 19
#define FTM_SYNCONF_HWSOC_MASK                   0x100000u
#define FTM_SYNCONF_HWSOC_SHIFT                  20
 
/* INVCTRL Bit Fields */
#define FTM_INVCTRL_INV0EN_MASK                  0x1u
#define FTM_INVCTRL_INV0EN_SHIFT                 0
#define FTM_INVCTRL_INV1EN_MASK                  0x2u
#define FTM_INVCTRL_INV1EN_SHIFT                 1
#define FTM_INVCTRL_INV2EN_MASK                  0x4u
#define FTM_INVCTRL_INV2EN_SHIFT                 2
#define FTM_INVCTRL_INV3EN_MASK                  0x8u
#define FTM_INVCTRL_INV3EN_SHIFT                 3
 
/* SWOCTRL Bit Fields */
#define FTM_SWOCTRL_CH0OC_MASK                   0x1u
#define FTM_SWOCTRL_CH0OC_SHIFT                  0
#define FTM_SWOCTRL_CH1OC_MASK                   0x2u
#define FTM_SWOCTRL_CH1OC_SHIFT                  1
#define FTM_SWOCTRL_CH2OC_MASK                   0x4u
#define FTM_SWOCTRL_CH2OC_SHIFT                  2
#define FTM_SWOCTRL_CH3OC_MASK                   0x8u
#define FTM_SWOCTRL_CH3OC_SHIFT                  3
#define FTM_SWOCTRL_CH4OC_MASK                   0x10u
#define FTM_SWOCTRL_CH4OC_SHIFT                  4
#define FTM_SWOCTRL_CH5OC_MASK                   0x20u
#define FTM_SWOCTRL_CH5OC_SHIFT                  5
#define FTM_SWOCTRL_CH6OC_MASK                   0x40u
#define FTM_SWOCTRL_CH6OC_SHIFT                  6
#define FTM_SWOCTRL_CH7OC_MASK                   0x80u
#define FTM_SWOCTRL_CH7OC_SHIFT                  7
#define FTM_SWOCTRL_CH0OCV_MASK                  0x100u
#define FTM_SWOCTRL_CH0OCV_SHIFT                 8
#define FTM_SWOCTRL_CH1OCV_MASK                  0x200u
#define FTM_SWOCTRL_CH1OCV_SHIFT                 9
#define FTM_SWOCTRL_CH2OCV_MASK                  0x400u
#define FTM_SWOCTRL_CH2OCV_SHIFT                 10
#define FTM_SWOCTRL_CH3OCV_MASK                  0x800u
#define FTM_SWOCTRL_CH3OCV_SHIFT                 11
#define FTM_SWOCTRL_CH4OCV_MASK                  0x1000u
#define FTM_SWOCTRL_CH4OCV_SHIFT                 12
#define FTM_SWOCTRL_CH5OCV_MASK                  0x2000u
#define FTM_SWOCTRL_CH5OCV_SHIFT                 13
#define FTM_SWOCTRL_CH6OCV_MASK                  0x4000u
#define FTM_SWOCTRL_CH6OCV_SHIFT                 14
#define FTM_SWOCTRL_CH7OCV_MASK                  0x8000u
#define FTM_SWOCTRL_CH7OCV_SHIFT                 15
 
/* PWMLOAD Bit Fields */
#define FTM_PWMLOAD_CH0SEL_MASK                  0x1u
#define FTM_PWMLOAD_CH0SEL_SHIFT                 0
#define FTM_PWMLOAD_CH1SEL_MASK                  0x2u
#define FTM_PWMLOAD_CH1SEL_SHIFT                 1
#define FTM_PWMLOAD_CH2SEL_MASK                  0x4u
#define FTM_PWMLOAD_CH2SEL_SHIFT                 2
#define FTM_PWMLOAD_CH3SEL_MASK                  0x8u
#define FTM_PWMLOAD_CH3SEL_SHIFT                 3
#define FTM_PWMLOAD_CH4SEL_MASK                  0x10u
#define FTM_PWMLOAD_CH4SEL_SHIFT                 4
#define FTM_PWMLOAD_CH5SEL_MASK                  0x20u
#define FTM_PWMLOAD_CH5SEL_SHIFT                 5
#define FTM_PWMLOAD_CH6SEL_MASK                  0x40u
#define FTM_PWMLOAD_CH6SEL_SHIFT                 6
#define FTM_PWMLOAD_CH7SEL_MASK                  0x80u
#define FTM_PWMLOAD_CH7SEL_SHIFT                 7
#define FTM_PWMLOAD_LDOK_MASK                    0x200u
#define FTM_PWMLOAD_LDOK_SHIFT                   9
 
/** FTM - Register Layout Typedef */
typedef struct {
  __IO uint32_t SC;                                /*!< ×´Ì¬ºÍ¿ØÖƼĴæÆ÷, offset: 0x0 */
  __IO uint32_t CNT;                               /*!< ¼ÆÊý¼Ä´æÆ÷, offset: 0x4 */
  __IO uint32_t MOD;                               /*!< Ä£Êý¼Ä´æÆ÷, offset: 0x8 */
  struct {                                       
    __IO uint32_t CnSC;                            /*!< Í¨µÀ״̬ºÍ¿ØÖƼĴæÆ÷, array offset: 0xC, array step: 0x8 */
    __IO uint32_t CnV;                             /*!< Í¨µÀÖµ¼Ä´æÆ÷, array offset: 0x10, array step: 0x8 */
  } CONTROLS[8];
  __IO uint32_t CNTIN;                             /*!< ¼ÆÊýÆ÷³õʼֵ¼Ä´æÆ÷, offset: 0x4C */
  __IO uint32_t STATUS;                            /*!< ²¶×½ºÍ±È½Ï״̬¼Ä´æÆ÷, offset: 0x50 */
  __IO uint32_t MODE;                              /*!< ÌØÐÔģʽѡÔñ¼Ä´æÆ÷, offset: 0x54 */
  __IO uint32_t SYNC;                              /*!< Í¬²½¼Ä´æÆ÷, offset: 0x58 */
  __IO uint32_t OUTINIT;                           /*!< Í¨µÀÊä³öµÄ³õʼ״̬¼Ä´æÆ÷, offset: 0x5C */
  __IO uint32_t OUTMASK;                           /*!< Êä³öÆÁ±Î¼Ä´æÆ÷, offset: 0x60 */
  __IO uint32_t COMBINE;                           /*!< ÒÑÁ¬½ÓÐŵÀ¹¦ÄܼĴæÆ÷, offset: 0x64 */
  __IO uint32_t DEADTIME;                          /*!< ËÀÇøÊ±¼ä²åÈë¿ØÖÆ, offset: 0x68 */
  __IO uint32_t EXTTRIG;                           /*!< FTMÍⲿ´¥·¢¼Ä´æÆ÷, offset: 0x6C */
  __IO uint32_t POL;                               /*!< Í¨µÀ¼«ÐԼĴæÆ÷, offset: 0x70 */
  __IO uint32_t FMS;                               /*!< ¹ÊÕÏģʽ״̬¼Ä´æÆ÷, offset: 0x74 */
  __IO uint32_t FILTER;                            /*!< ÊäÈë²¶×½Â˲¨Æ÷¿ØÖƼĴæÆ÷, offset: 0x78 */
  __IO uint32_t FLTCTRL;                           /*!< ¹ÊÕÏ¿ØÖƼĴæÆ÷, offset: 0x7C */
       uint8_t RESERVED_1[4];
  __IO uint32_t CONF;                              /*!< ÅäÖüĴæÆ÷, offset: 0x84 */
  __IO uint32_t FLTPOL;                            /*!< FTM ¹ÊÕÏÊäÈ뼫ÐԼĴæÆ÷, offset: 0x88 */
  __IO uint32_t SYNCONF;                           /*!< FTM Èí¼þÊä³ö¿ØÖƼĴæÆ÷, offset: 0x8C */
  __IO uint32_t INVCTRL;                           /*!< FTM Èí¼þÊä³ö¿ØÖƼĴæÆ÷, offset: 0x90 */
  __IO uint32_t SWOCTRL;                           /*!< FTM Èí¼þÊä³ö¿ØÖƼĴæÆ÷, offset: 0x94 */
  __IO uint32_t PWMLOAD;                           /*!< FTM PWM ¼ÓÔØ¼Ä´æÆ÷, offset: 0x98 */
} FTM_Type, *FTM_MemMapPtr;    
extern FTM_Type*        FTM0;
extern FTM_Type*        FTM1;
extern FTM_Type*        FTM2;
 
 
/** @addtogroup XL6600_StdPeriph_Driver
  * @{
  */
 
/** @addtogroup FTM
  * @{
  */
 
/* Exported types ------------------------------------------------------------*/ 
 
/**
  * @brief FTM Ê±ÖÓ³õʼ»¯½á¹¹Ìå
  */
typedef struct
{
  uint32_t   FTM_ClkSource;        /*!< Ê±ÖÓÔ´ */
  uint32_t   FTM_Prescaler;        /*!< Ê±ÖÓÔ¤·ÖƵϵÊý */
    
}FTM_InitTypeDef, *FTM_InitConfigPtr;
 
/**
  * @brief FTM ×éºÏģʽ³õʼ»¯½á¹¹Ì嶨Òå
  */
typedef struct
{
    uint32_t        FTM_ChannelPair;                /*!< Í¨µÀ¶Ô */
    uint32_t        PWMEdgeSelect;                  /*!< PWM±ßÑØÑ¡Ôñ */                            
    uint32_t        FTM_CombineEn;                  /*!< ×éºÏͨµÀʹÄÜ */    
    uint32_t        FTM_CompEn;                     /*!< Í¨µÀ»¥²¹Ê¹ÄÜ */    
    uint32_t        FTM_DeadtimeEn;                 /*!< ËÀÇøÊ±¼äʹÄÜ */
    uint32_t        FTM_SynchronizationEn;          /*!< Ê¹ÄܼĴæÆ÷C(n)V ºÍC(n+1)VµÄPWMͬ²½ */
    uint32_t        FTM_FaultControlEn;             /*!< ¹ÊÕÏ¿ØÖÆÊ¹ÄÜ */
    
}FTM_CombinePWMTypeDef, *FTM_CombinePWMConfigPtr;
  
/**
  * @brief FTM ±È½Ï¹¦Äܳõʼ»¯½á¹¹Ìå
  */
typedef struct
{
    uint32_t FTM_ChannelPair;                /*!< Í¨µÀ¶Ô */                                               
    uint32_t FTM_CaptureMode;                /*!< ²¶»ñģʽ: µ¥´Î²¶»ñºÍÁ¬Ðø */    
    uint32_t FTM_Channel_N_Edge;             /*!< Í¨µÀN±ßÑØ¼ì²â */    
    uint32_t FTM_Channel_Np1_Edge;           /*!< Í¨µÀN+1±ßÑØ¼ì²â */
    
}FTM_DualEdgeCaptureTypeDef, *FTM_DualEdgeCaptureConfigPtr;
 
 
 
/* Exported constants --------------------------------------------------------*/
/** @defgroup FTM_Exported_Constants FTMÄ£¿éʹÓòÎÊý¶¨Òå
  * @{
  */    
 
/** @defgroup FTM_Deinit_Value FTM¼Ä´æÆ÷ĬÈÏÖµ
  * @{
  */
#define FTM_MOD_INIT                    ((uint32_t)20000-(uint32_t)1)              /*!< MOD inite value */
#define FTM_C0V_INIT                    (uint32_t)1000                  /*!< C0V inite value */
#define FTM_C1V_INIT                    (uint32_t)1000                  /*!< C1V inite value */
#define FTM_C2V_INIT                    (uint32_t)1000                  /*!< C2V inite value */    
#define FTM_C3V_INIT                    (uint32_t)1000                  /*!< C3V inite value */
#define FTM_C4V_INIT                    (uint32_t)1000                  /*!< C4V inite value */
#define FTM_C5V_INIT                    (uint32_t)1000                  /*!< C5V inite value */
#define FTM_C6V_INIT                    (uint32_t)1000                  /*!< C6V inite value */
#define FTM_C7V_INIT                    (uint32_t)1000                  /*!< C7V inite value */
/**
  * @}
  */    
    
/** @defgroup FTM_Clocksource_Seclect FTMʱÖÓÔ´Ñ¡Ôñ¶¨Òå
  * @{
  */    
#define FTM_CLOCK_NOCLOCK                        0              /*!< Î´Ñ¡¶¨Ê±ÖÓ£¬¸ÃÉèÖÃÉúЧºó¿É½ûÓÃFTM¼ÆÊýÆ÷ */
#define FTM_CLOCK_SYSTEMCLOCK                    1              /*!< System clock */
#define FTM_CLOCK_FIXEDFREQCLOCK                2              /*!< Fixed Freq Clock */
#define FTM_CLOCK_EXTERNALCLOCK                  3              /*!< External Clock */
/**
  * @}
  */
    
/** @defgroup FTM_Clockprescale_Seclect FTMʱÖÓ·ÖÆµÑ¡Ôñ¶¨Òå
  * @{
  */    
#define FTM_CLOCK_PS_DIV1                        0              /*!< 1·ÖƵ */
#define FTM_CLOCK_PS_DIV2                        1              /*!< 2·ÖƵ */
#define FTM_CLOCK_PS_DIV4                        2              /*!< 4·ÖƵ */
#define FTM_CLOCK_PS_DIV8                        3              /*!< 8·ÖƵ */
#define FTM_CLOCK_PS_DIV16                       4              /*!< 16·ÖƵ */
#define FTM_CLOCK_PS_DIV32                       5              /*!< 32·ÖƵ */
#define FTM_CLOCK_PS_DIV64                       6              /*!< 64·ÖƵ */
#define FTM_CLOCK_PS_DIV128                      7              /*!< 128·ÖƵ */
/**
  * @}
  */
   
/** @defgroup FTM_Deadtime_Clockprescale_Seclect FTMËÀÇøÊ±¼äʱÖÓ·ÖÆµÑ¡Ôñ¶¨Òå
  * @{
  */    
#define FTM_DEADTIME_DTPS_DIV1                   0               /*!< 1·ÖƵ */
#define FTM_DEADTIME_DTPS_DIV4                   2               /*!< 4·ÖƵ */
#define FTM_DEADTIME_DTPS_DIV16                  3               /*!< 16·ÖƵ */
/**
  * @}
  */
    
/** @defgroup FTM_Channels_Modes_Definition FTMͨµÀģʽ¶¨Òå
  * @{
  */
#define FTM_PWMMODE_EDGEALLIGNED                        (uint8_t)1            /*!< ±ßÑØ¶ÔÆëPWM */
#define FTM_PWMMODE_CENTERALLIGNED                        (uint8_t)2          /*!< ÖÐÐÄ¶ÔÆëPWM */
#define FTM_PWMMODE_COMBINE                                (uint8_t)3                  /*!< ×éºÏPWM */
/**
  * @}
  */
    
/** @defgroup FTM_PWM_High/Low_TruePulse FTM_PWM¸ß/µÍÕæÊµÂö³å
 
  * @{
  */    
#define FTM_PWM_HIGHTRUEPULSE                    2u           /*!< ¸ßÕæÂö³å£¨Í¨µÀ(n)Æ¥ÅäʱÖÃλ£¬Í¨µÀ(n+1)Æ¥ÅäʱÇåÁ㣩 */
#define FTM_PWM_LOWTRUEPULSE                     1u           /*!< µÍÕæÂö³å£¨Í¨µÀ(n)Æ¥ÅäʱÇåÁ㣬ͨµÀ(n+1)Æ¥ÅäʱÖÃλ */
/**
  * @}
  */
 
/** @defgroup FTM_InputcaptureEdge_Seclect FTMÊäÈë²¶»ñ±ßÑØÀàÐÍÑ¡Ôñ
  * @{
  */
#define FTM_INPUTCAPTURE_RISINGEDGE          1u     /*!< ÉÏÉýÑØ */
#define FTM_INPUTCAPTURE_FALLINGEDGE         2u     /*!< Ï½µÑØ */
#define FTM_INPUTCAPTURE_BOTHEDGE            3u     /*!< Ë«±ßÑØ */
/**
  * @}
  */
 
/** @defgroup FTM_InputcaptureDualEdge_Seclect  FTMÊäÈë²¶»ñË«±ßÑØÀàÐÍÑ¡Ôñ
  * @{
  */                                                                
#define FTM_INPUTCAPTURE_DUALEDGE_NOEDGE      0u     /*!< ÎÞ±ßÑØ */
#define FTM_INPUTCAPTURE_DUALEDGE_RISING      1u     /*!< ÉÏÉýÑØ */
#define FTM_INPUTCAPTURE_DUALEDGE_FALLING     2u     /*!< Ï½µÑØ */
#define FTM_INPUTCAPTURE_DUALEDGE_BOTHEDGE    3u     /*!< Ë«±ßÑØ */
/**
  * @}
  */
    
/** @defgroup FTM_DualCapture_Mode FTMË«±È½Ïģʽ
  * @{
  */    
#define FTM_INPUTCAPTURE_DUALEDGE_ONESHOT     2u     /*!< µ¥´Î²¶»ñģʽ */ 
#define FTM_INPUTCAPTURE_DUALEDGE_CONTINUOUS  1u     /*!< Á¬Ðø²¶»ñģʽ */
/**
  * @}
  */
    
/** @defgroup FTM_OutCompare_Mode FTMÊä³ö±È½Ïģʽ
  * @{
  */        
#define FTM_OUTPUT_TOGGLE                        1u           /*!< Æ¥ÅäʱÇл»Êä³ö */
#define FTM_OUTPUT_CLEAR                        2u           /*!< Æ¥ÅäʱÇåÁãÊä³ö */
#define FTM_OUTPUT_SET                           3u           /*!< Æ¥ÅäʱÖÃλÊä³ö */
/**
  * @}
  */
    
    
/** @defgroup FTM_SYNC_TRIGGER_List FTMͬ²½´¥·¢¹¦ÄÜÁбí
  * @{
  */    
#define FTM_SYNC_TRIGGER_TRIGGER0             0x10         /*!< Í¬²½Ó²¼þ´¥·¢0 */
#define FTM_SYNC_TRIGGER_TRIGGER1             0x20         /*!< Í¬²½Ó²¼þ´¥·¢1 */
#define FTM_SYNC_TRIGGER_TRIGGER2             0x40         /*!< Í¬²½Ó²¼þ´¥·¢2 */
/**
  * @}
  */
    
/** @defgroup FTM_Update_SYNC_TRIGGER_List FTM¸üÐÂͬ²½´¥·¢¹¦ÄÜÁбí
  * @{
  */    
#define FTM_UPDATE_RISINGCLK                  0u         /*!< ¼Ä´æÆ÷½«ÔÚËùÓÐSYSCLKµÄÉÏÉýÑØÒﮊȼ³åÇøµÄÊýÖµ½øÐиüР*/
#define FTM_UPDATE_PWMSYNC                    1u         /*!< ¼Ä´æÆ÷½öͨ¹ýPWM Í¬²½Òﮊȼ³åÇøÖµ½øÐиüР*/
/**
  * @}
  */
    
/** @defgroup FTM_Synchronization_Mode_list FTMͬ²½Ä£Ê½
  * @{
  */    
#define FTM_SYNCMODE_LEGACY                   0u         /*!< Ñ¡Ôñ´«Í³PWMͬ²½ */
#define FTM_SYNCMODE_ENHANCED                 1u         /*!< Ñ¡ÔñÔöÇ¿PWMͬ²½ */
/**
  * @}
  */ 
 
 
/** @defgroup FTM_PWM_Synchronization_Mode_list FTM_PWMÈíÓ²¼þ´¥·¢Ä£Ê½Ñ¡Ôñ
  * @{
  */    
#define FTM_PWMSYNC_NORESTRICT                0u         /*!< ÎÞÏÞÖÆ£¬Ñ¡Ôñ¿ÉÓÃÓÚMOD¡¢CnV¡¢OUTMASK ºÍFTM ¼ÆÊýÆ÷ͬ²½µÄÈí¼þºÍÓ²¼þ´¥·¢ */
#define FTM_PWMSYNC_SWANDHW                   1u         /*!< Èí¼þ´¥·¢Ö»ÄÜÓÃÓÚMOD ºÍCnV Í¬²½£¬Ó²¼þ´¥·¢Ö»ÄÜÓÃÓÚFTM¼ÆÊýÆ÷ͬ²½ */
/**
  * @}
  */ 
    
/** @defgroup FTM_Hardware_Trigger_Mode_list FTMÓ²¼þ´¥·¢Ä£Ê½ÆÁ±Î
  * @{
  */    
#define FTM_HWTRIGMODE_CLEAR                  0u         /*!< ¼ì²âµ½Ó²¼þ´¥·¢jʱ£¨j=0¡¢1¡¢2£©£¬FTMÇåÁãTRIGjλ */
#define FTM_HWTRIGMODE_UNCLEAR                1u         /*!< ¼ì²âµ½Ó²¼þ´¥·¢jʱ£¨j=0¡¢1¡¢2£©£¬FTM²»ÇåÁãTRIGjλ */
/**
  * @}
  */
 
/** @defgroup FTM_Synconf_Reg_List FTMͬ²½
  * @{
  */    
#define FTM_SYNCONF_CNTREG                    0u         /*!< FTMͬ²½¼ÆÊýÆ÷ */
#define FTM_SYNCONF_MODCNTINCVREG            1u           /*!< MOD, CNTIN,ºÍCVͬ²½¼Ä´æÆ÷ */
#define FTM_SYNCONF_OUTMASKREG                2u         /*!< Í¬²½Êä³öÆÁ±Î */
#define FTM_SYNCONF_INVCTRLREG                3u         /*!< INVCTRL¼Ä´æÆ÷ͬ²½ */
#define FTM_SYNCONF_SWOCTRLREG                4u         /*!< SWOCTRL¼Ä´æÆ÷ͬ²½ */
/**
  * @}
  */
 
/** @defgroup FTM_Synchronization_Mode_Seclect FTMͬ²½Ä£Ê½´¥·¢Ñ¡Ôñ
  * @{
  */    
#define FTM_SYNCONF_SWTRIGGER                 0u         /*!< Í¬²½Èí¼þ´¥·¢ */
#define FTM_SYNCONF_HWTRIGGER                 1u         /*!< Í¬²½Ó²¼þ´¥·¢ */
/**
  * @}
  */
    
/** @defgroup FTM_Reinitialization_List FTM¸üÐÂÊä³öÖµ
  * @{
  */
#define FTM_REINIT_NORMALLY                      0u         /*!< FTM¼ÆÊýÆ÷¼ÌÐøÕý³£¼ÆÊý */
#define FTM_REINIT_UPDATED                       1u         /*!< FTM¼ÆÊýÆ÷ÒÔÆä³õʼֵ¸üР*/
/**
  * @}
  */
    
/** @defgroup FTM_Channel_List FTMͨµÀÁбí
  * @{
  */
#define FTM_CHANNEL0                     0u           /*!< FTMxͨµÀ0 */
#define FTM_CHANNEL1                     1u           /*!< FTMxͨµÀ1 */
#define FTM_CHANNEL2                     2u           /*!< FTMxͨµÀ2 */
#define FTM_CHANNEL3                     3u           /*!< FTMxͨµÀ3 */
#define FTM_CHANNEL4                     4u           /*!< FTMxͨµÀ4 */
#define FTM_CHANNEL5                     5u           /*!< FTMxͨµÀ5 */
#define FTM_CHANNEL6                     6u           /*!< FTMxͨµÀ6 */
#define FTM_CHANNEL7                     7u           /*!< FTMxͨµÀ7 */
/**
  * @}
  */
 
/** @defgroup FTM_ChannelPair_List FTM×éºÏģʽͨµÀÁбí
  * @{
  */    
#define FTM_CHANNELPAIR0                 0u           /*!< Í¨µÀ¶Ô0:ch0 & ch1 */
#define FTM_CHANNELPAIR1                 2u           /*!< Í¨µÀ¶Ô1:ch2 & ch3 */
#define FTM_CHANNELPAIR2                 4u           /*!< Í¨µÀ¶Ô2:ch4 & ch5 */
#define FTM_CHANNELPAIR3                 6u           /*!< Í¨µÀ¶Ô3:ch6 & ch7 */
/**
  * @}
  */
 
/** @defgroup FTM_ChannelFlag_List FTMͨµÀ±êÖ¾Áбí
  * @{
  */
#define FTM_CHANNEL0_FLAG                0u           /*!< FTMͨµÀ±êÖ¾0 */
#define FTM_CHANNEL1_FLAG                1u           /*!< FTMͨµÀ±êÖ¾1 */
#define FTM_CHANNEL2_FLAG                2u           /*!< FTMͨµÀ±êÖ¾2 */
#define FTM_CHANNEL3_FLAG                3u           /*!< FTMͨµÀ±êÖ¾3 */
#define FTM_CHANNEL4_FLAG                4u           /*!< FTMͨµÀ±êÖ¾4 */
#define FTM_CHANNEL5_FLAG                5u           /*!< FTMͨµÀ±êÖ¾5 */
#define FTM_CHANNEL6_FLAG                6u           /*!< FTMͨµÀ±êÖ¾6 */
#define FTM_CHANNEL7_FLAG                7u           /*!< FTMͨµÀ±êÖ¾7 */
/**
  * @}
  */
 
/** @defgroup FTM_IntialValue_list FTM³õʼֵÁбí
  * @{
  */
#define FTM_INITIALVALUE0                        0u          /*!< FTM³õʼֵ0 */
#define FTM_INITIALVALUE1                        1u          /*!< FTM³õʼֵ1 */
/**
  * @}
  */
    
/** @defgroup FTM_ChannelPolarity_List FTMͨµÀ¼«ÐÔÁбí
  * @{
  */
#define FTM_CHANNELPOLARITY_HIGH                 0u          /*!< FTMͨµÀ¼«ÐÔΪ¸ßµçƽ */
#define FTM_CHANNELPOLARITY_LOW                  1u          /*!< FTMͨµÀ¼«ÐÔΪµÍµçƽ */
/**
  * @}
  */
    
/** @defgroup FTM_FaultDetectionFlag_List FTMͨµÀ´íÎó±êÖ¾Áбí
  * @{
  */
#define FTM_FAULTDETECTION_FLAG0                 0u          /*!< ¹ÊÕϼì²â±êÖ¾0 */
#define FTM_FAULTDETECTION_FLAG1                 1u          /*!< ¹ÊÕϼì²â±êÖ¾1 */
#define FTM_FAULTDETECTION_FLAG2                2u          /*!< ¹ÊÕϼì²â±êÖ¾2 */
#define FTM_FAULTDETECTION_FLAG3                 3u          /*!< ¹ÊÕϼì²â±êÖ¾3 */
/**
  * @}
  */
    
 
/** @defgroup FaultControlChanne_List FTM¹ÊÕÏ¿ØÖÆÍ¨µÀÁбí
  * @{
  */
#define FaultControlChanne0                 0x00000040u          /*!< ¹ÊÕÏ¿ØÖÆÍ¨µÀ0 */
#define FaultControlChanne1                 0x00004000u          /*!< ¹ÊÕÏ¿ØÖÆÍ¨µÀ1 */
#define FaultControlChanne2                    0x00400000u          /*!< ¹ÊÕÏ¿ØÖÆÍ¨µÀ2 */
#define FaultControlChanne3                 0x40000000u          /*!< ¹ÊÕÏ¿ØÖÆÍ¨µÀ3 */
/**
  * @}
  */
    
 
 
    
/** @defgroup FTM_InputFilterChannel_List FTMÊäÈëÂ˲¨Í¨µÀÁбí
  * @{
  */
#define FTM_INPUTFILTER_CHANNEL0                 0u          /*!< Í¨µÀ0ÊäÈëÂ˲¨ */
#define FTM_INPUTFILTER_CHANNEL1                 1u          /*!< Í¨µÀ1ÊäÈëÂ˲¨ */
#define FTM_INPUTFILTER_CHANNEL2                 2u          /*!< Í¨µÀ2ÊäÈëÂ˲¨ */
#define FTM_INPUTFILTER_CHANNEL3                 3u          /*!< Í¨µÀ3ÊäÈëÂ˲¨ */
/**
  * @}
  */
    
/** @defgroup FTM_FaultInput_List FTM¹ÊÕÏÊäÈëÁбí
  * @{
  */
#define FTM_FAULT_INPUT0                         0u          /*!< ¹ÊÕÏÊäÈë0  */
#define FTM_FAULT_INPUT1                         1u          /*!< ¹ÊÕÏÊäÈë1  */
#define FTM_FAULT_INPUT2                         2u          /*!< ¹ÊÕÏÊäÈë2  */
#define FTM_FAULT_INPUT3                         3u          /*!< ¹ÊÕÏÊäÈë3  */
/**
  * @}
  */
    
/** @defgroup FTM_FaultInputFilter_List FTM¹ÊÕÏÂ˲¨ÊäÈëÁбí
  * @{
  */
#define FTM_FAULTINPUT_FILTER0                   0u          /*!< ¹ÊÕÏÂ˲¨ÊäÈë0       */   
#define FTM_FAULTINPUT_FILTER1                   1u          /*!< ¹ÊÕÏÂ˲¨ÊäÈë1       */ 
#define FTM_FAULTINPUT_FILTER2                   2u          /*!< ¹ÊÕÏÂ˲¨ÊäÈë2       */ 
#define FTM_FAULTINPUT_FILTER3                   3u          /*!< ¹ÊÕÏÂ˲¨ÊäÈë3       */ 
/**
  * @}
  */
    
/** @defgroup FTM_FaultPolarityFilter_List FTM¹ÊÕÏÂ˲¨ÊäÈëÁбí
  * @{
  */
#define FTM_FAULTINPOLARITY_HIGH                 0u          /*!< ¹ÊÕÏÊäÈ뼫ÐÔΪ¸ß         */
#define FTM_FAULTINPOLARITY_LOW                  1u          /*!< ¹ÊÕÏÊäÈ뼫ÐÔΪµÍ         */
/**
  * @}
  */
    
/** @defgroup FTM_invert_pair_channel_list FTMͨµÀ·´×ª
  * @{
  */
#define FTM_INVERT_PAIRCHANNEL0                  0u          /*!< Í¨µÀ¶Ô0·´×ªÊ¹ÄÜ        */
#define FTM_INVERT_PAIRCHANNEL1                 1u          /*!< Í¨µÀ¶Ô1·´×ªÊ¹ÄÜ        */
#define FTM_INVERT_PAIRCHANNEL2                  2u          /*!< Í¨µÀ¶Ô2·´×ªÊ¹ÄÜ        */
#define FTM_INVERT_PAIRCHANNEL3                  3u          /*!< Í¨µÀ¶Ô3·´×ªÊ¹ÄÜ        */
/**
  * @}
  */
 
/** @defgroup FTM_Software_Control_Outvalue_list FTMÈí¼þ¿ØÖÆÊä³öÖµÁбí
  * @{
  */
#define FTM_SWCONTROL_OUT0                       0u          /*!< FTMÈí¼þ¿ØÖÆÊä³öÖµÇ¿ÖÆÎª0 */
#define FTM_SWCONTROL_OUT1                       1u          /*!< FTMÈí¼þ¿ØÖÆÊä³öÖµÇ¿ÖÆÎª1 */
/**
  * @}
  */
    
/** @defgroup FTM_ChannelMatch_list FTMͨµÀÆ¥Åä¿ØÖÆÁбí
  * @{
  */
#define FTM_CHANNELMATCH_NOTINCLUDE           0u          /*!< Æ¥Åä¹ý³ÌÖв»°üÀ¨Í¨µÀ */
#define FTM_CHANNELMATCH_INCLUDE              1u          /*!< Æ¥Åä¹ý³ÌÖаüÀ¨Í¨µÀ */
/**
  * @}
  */
    
/** @defgroup FTM_Software_Sync_Activate FTMÈí¼þͬ²½´¥·¢¹¦ÄÜ
  * @{
  */    
#define FTM_SOFTWARE_SYN_CNT                             FTM_SYNCONF_SWRSTCNT_MASK
#define FTM_SOFTWARE_SYN_MOD_CNTIN_CV                    FTM_SYNCONF_SWWRBUF_MASK 
#define FTM_SOFTWARE_SYN_OUTMASK                        FTM_SYNCONF_SWOM_MASK
#define FTM_SOFTWARE_SYN_INVCTRL                        FTM_SYNCONF_SWINVC_MASK
#define FTM_SOFTWARE_SYN_OUTCTRL                        FTM_SYNCONF_SWSOC_MASK
/**
  * @}
  */
    
/** @defgroup FTM_Shardware_Sync_Activate FTMÓ²¼þͬ²½´¥·¢¹¦ÄÜ
  * @{
  */
#define FTM_HARDWARE_SYN_CNT                            FTM_SYNCONF_HWRSTCNT_MASK
#define FTM_HARDWARE_SYN_MOD_CNTIN_CV                    FTM_SYNCONF_HWWRBUF_MASK
#define FTM_HARDWARE_SYN_OUTMASK                        FTM_SYNCONF_HWOM_MASK
#define FTM_HARDWARE_SYN_INVCTRL                        FTM_SYNCONF_HWINVC_MASK
#define FTM_HARDWARE_SYN_OUTCTRL                        FTM_SYNCONF_HWSOC_MASK 
/**
  * @}
  */
 
 
/** @defgroup FTM Interrupt Enable FTMÖжÏʹÄÜ
  * @{
  */
typedef enum {
    FTM_ALLDISABLE= 0,                      /*!< ËùÓÐͨµÀ½ûÓùÊÕÏ¿ØÖÆ */
    FTM_EVENENABLE_MANUALCLEAR,             /*!< ½öÕë¶ÔżÊýÐŵÀ£¨ÐŵÀ0¡¢2¡¢4 ºÍ6£©Ê¹ÄܹÊÕÏ¿ØÖÆ£¬ËùѡģʽΪÊÖ¶¯¹ÊÕÏÇåÁã */
    FTM_ALLENABLE_MANUALCLEAR,              /*!< ËùÓÐͨµÀʹÄܹÊÕÏ¿ØÖÆ£¬ËùѡģʽΪÊÖ¶¯¹ÊÕÏÇåÁã */
    FTM_ALLENABLE_AUTOCLEAR                 /*!< ËùÓÐͨµÀʹÄܹÊÕÏ¿ØÖÆ£¬ËùѡģʽΪ×Ô¶¯¹ÊÕÏÇåÁã */
 
} FTM_FaultControlModeDef;
/**
  * @}
  */
 
/**
    * @}
    */
 
 
/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ 
void FTM_WriteProtectEnable(FTM_Type* FTMx);
void FTM_WriteProtectDisable(FTM_Type* FTMx);
void FTM_DeInit(FTM_Type* FTMx);
void FTM_Init(FTM_Type* FTMx, const FTM_InitTypeDef* FTM_InitStruct);
 
void FTM_EdgeAlignedPWMInit(FTM_Type* FTMx, uint8_t FTM_Channel, uint8_t PWMEdgeSelect);
void FTM_CenterAlignedPWMInit(FTM_Type* FTMx, uint8_t FTM_Channel, uint8_t PWMEdgeSelect);
void FTM_CombinePWMPWMInit(FTM_Type* FTMx, const FTM_CombinePWMTypeDef *FTM_CombinePWMStruct);
void FTM_PWMInit(FTM_Type* FTMx, uint8_t PWMModeSelect, uint8_t PWMEdgeSelect);
 
void FTM_InputCaptureInit(FTM_Type* FTMx, uint8_t FTM_Channel, uint8_t CaptureMode);
void FTM_DualEdgeCaptureInit(FTM_Type* FTMx, const FTM_DualEdgeCaptureTypeDef* FTM_DualEdgeStruct);
void FTM_OutputCompareInit(FTM_Type* FTMx, uint8_t FTM_Channel, uint32_t CompareMode);
 
void FTM_OverflowITCmd(FTM_Type* FTMx, FunctionalState NewState);
FlagStatus FTM_GetOverFlowFlag(const FTM_Type* FTMx);
void FTM_ClrOverFlowFlag(FTM_Type* FTMx);
 
uint16_t FTM_GetCountValue(const FTM_Type* FTMx);
void FTM_SetModValue(FTM_Type* FTMx, uint16_t ModValue);
void FTM_SetCountInitValue(FTM_Type* FTMx, uint16_t InitialValue);
 
void FTM_ChannelIntCmd(FTM_Type* FTMx, uint8_t FTM_Channel, FunctionalState NewState);
FlagStatus FTM_GetChannelFlag(const FTM_Type* FTMx, uint8_t FTM_Channel);
void FTM_ClrChannelFlag(FTM_Type* FTMx, uint8_t FTM_Channel);
void FTM_SetChannelValue(FTM_Type* FTMx, uint8_t FTM_Channel, uint16_t ChannelValue);
uint16_t FTM_GetChannelValue(const FTM_Type* FTMx, uint8_t FTM_Channel );
 
uint32_t FTM_GetStatusRegFlag(const FTM_Type* FTMx);
void FTM_ClrStatusRegFlag(FTM_Type* FTMx);
FlagStatus FTM_GetStatusChannelFlag(const FTM_Type* FTMx, uint8_t ChannelFlag);
void FTM_ClrStatusChannelFlag(FTM_Type* FTMx, uint8_t ChannelFlag);
 
void FTM_FaultITCmd(FTM_Type* FTMx, FunctionalState NewState);
void FTM_SetFaultControlMode(FTM_Type* FTMx, FTM_FaultControlModeDef FTM_FaultControlMode);
void FTM_CaptureTestCmd(FTM_Type* FTMx, FunctionalState NewState);
 
void FTM_SoftwareSync(FTM_Type* FTMx, FunctionalState NewState);
void FTM_HardwareSync(FTM_Type* FTMx, uint8_t TriggerN, FunctionalState NewState);
void FTM_RegSyncCmd(FTM_Type* FTMx, uint8_t TriggerType, uint8_t RegType, FunctionalState NewState);
void FTM_OutMaskSync(FTM_Type* FTMx,  uint8_t update);
void FTM_CNTINCSync(FTM_Type* FTMx,  uint8_t update);
void FTM_INVCSync(FTM_Type* FTMx,  uint8_t update);
void FTM_SWOCSync(FTM_Type* FTMx,  uint8_t update);
void FTM_SetSyncMode(FTM_Type* FTMx,  uint8_t mode);
void FTM_SetPWMSyncMode(FTM_Type* FTMx,  uint8_t mode);
void FTM_SetHardwareTriggerMode(FTM_Type* FTMx,  uint8_t mode);
 
void FTM_CNTMAXCmd(FTM_Type* FTMx, FunctionalState NewState);
void FTM_CNTMINCmd(FTM_Type* FTMx, FunctionalState NewState);
void FTM_Reinitialization(FTM_Type* FTMx,  uint8_t mode);
 
void FTM_SetInitOut(FTM_Type* FTMx, uint8_t initialvalue);
void FTM_SetChannelOutInitValue(FTM_Type* FTMx,uint8_t FTM_Channel, uint8_t initialvalue);
 
void FTM_SetOutMask(FTM_Type* FTMx, uint8_t outmask);
void FTM_SetChannelOutMaskCmd(FTM_Type* FTMx, uint8_t FTM_Channel, FunctionalState NewState);
 
void FTM_PWMDeadtimeSet(FTM_Type* FTMx, uint32_t PrescalerValue, uint32_t DeadtimeValue);
 
FlagStatus FTM_GetExternalTriggerFlag(const FTM_Type* FTMx);
void FTM_ClrExternalTriggerFlag(FTM_Type* FTMx);
void FTM_SetChnTriggerCmd(FTM_Type* FTMx, uint8_t FTM_Channel, FunctionalState NewState);
void FTM_SetInitTriggerCmd(FTM_Type* FTMx, FunctionalState NewState);
 
void FTM_SetChannelsPolarity(FTM_Type* FTMx, uint8_t PolarityValue);
void FTM_SetSingleChannelPolarity(FTM_Type* FTMx, uint8_t FTM_Channel, uint8_t FTM_Polarity);
 
FlagStatus FTM_GetFaultDetectLogicORFlag(const FTM_Type* FTMx);
FlagStatus FTM_GetFaultDetectFlag(const FTM_Type* FTMx, uint8_t FaultDetectFlag);
uint32_t FTM_GetFaultInLogicORValue(const FTM_Type* FTMx);
void FTM_ClrFaultDetectLogicORFlag(FTM_Type* FTMx);
void FTM_ClrFaultDetectFlag(FTM_Type* FTMx, uint8_t FaultDetectFlag);
 
void FTM_SetChannelInFilter(FTM_Type* FTMx, uint8_t FTM_FilterChannel, uint32_t FilterValue);
void FTM_SetInCapFilter(FTM_Type* FTMx, uint16_t filter);
 
void FTM_FaultPinCmd(FTM_Type* FTMx, uint8_t FaultInput, FunctionalState NewState);
void FTM_FaultPinFilterCmd(FTM_Type* FTMx, uint8_t FaultFilter, FunctionalState NewState);
void FTM_SetFaultInFilter(FTM_Type* FTMx, uint32_t FilterValue);
 
void FTM_GTBEENCmd(FTM_Type* FTMx, FunctionalState NewState);
void FTM_GTBEOUTCmd(FTM_Type* FTMx, FunctionalState NewState);
void FTM_SetDebugModeBehavior(FTM_Type* FTMx, uint32_t DebugMode);
 
void FTM_SetFaultInPolarity(FTM_Type* FTMx, uint8_t FaultInput, uint8_t polarity);
 
void FTM_PairChannelsInvertCmd(FTM_Type* FTMx, uint8_t channelpair, FunctionalState NewState);
 
void FTM_SWOutControlCmd(FTM_Type* FTMx, uint8_t FTM_Channel, FunctionalState NewState);
void FTM_SetSWOutControlValue(FTM_Type* FTMx, uint8_t FTM_Channel, uint8_t outvalue);
 
void FTM_SetLoadMatchChannels(FTM_Type* FTMx, uint32_t Matchchannel);
void FTM_SetLoadMatchChannel(FTM_Type* FTMx, uint8_t FTM_Channel, uint8_t include);
void FTM_SetLoadCmd(FTM_Type* FTMx, FunctionalState NewState);
 
 
void FTM_CVSyncEnable(FTM_Type* FTMx,uint8_t FTM_Channel,FunctionalState State);
 
void FTM_SoftSyncActivateTypeEnable(FTM_Type* FTMx,  uint32_t type, FunctionalState NewState);
void FTM_HardSyncActivateTypeEnable(FTM_Type* FTMx,  uint32_t type, FunctionalState NewState);
 
void FTM_SyncLoadEnable(FTM_Type* FTMx, FunctionalState NewState);
void FTM_FaultControlEnable(FTM_Type* FTMx, uint32_t FaultControlChannel,FunctionalState NewState);
#ifdef __cplusplus
}
#endif
 
#endif    /*__XL_FTM_H__ */
/**
  * @}
  */
 
/**
  * @}
  */