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
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
|
/*!
* @file apm32f0xx_tmr.c
*
* @brief This file contains all the functions for the TMR peripheral
*
* @version V1.0.3
*
* @date 2022-09-20
*
* @attention
*
* Copyright (C) 2020-2022 Geehy Semiconductor
*
* You may not use this file except in compliance with the
* GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
*
* The program is only for reference, which is distributed in the hope
* that it will be useful and instructional for customers to develop
* their software. Unless required by applicable law or agreed to in
* writing, the program is distributed on an "AS IS" BASIS, WITHOUT
* ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
* See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
* and limitations under the License.
*/
#include "apm32f0xx_tmr.h"
#include "apm32f0xx_rcm.h"
/** @addtogroup APM32F0xx_StdPeriphDriver
@{
*/
/** @addtogroup TMR_Driver TMR Driver
@{
*/
/** @defgroup TMR_Marcos Marcos
@{
*/
/**@} end of group TMR_Marcos */
/** @defgroup TMR_Enumerations Enumerations
@{
*/
/**@} end of group TMR_Enumerations */
/** @defgroup TMR_Structures Structures
@{
*/
/**@} end of group TMR_Structures */
/** @defgroup TMR_Variables Variables
@{
*/
/**@} end of group TMR_Variables */
/** @defgroup TMR_Functions Functions
@{
*/
/*!
* @brief Reset the TMR peripheral registers to their default reset values
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @retval None
*
* @note TMR2 TMR15 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_Reset(TMR_T* TMRx)
{
if (TMRx == TMR1)
{
RCM_EnableAPB2PeriphReset(RCM_APB2_PERIPH_TMR1);
RCM_DisableAPB2PeriphReset(RCM_APB2_PERIPH_TMR1);
}
else if (TMRx == TMR2)
{
RCM_EnableAPB1PeriphReset(RCM_APB1_PERIPH_TMR2);
RCM_DisableAPB1PeriphReset(RCM_APB1_PERIPH_TMR2);
}
else if (TMRx == TMR3)
{
RCM_EnableAPB1PeriphReset(RCM_APB1_PERIPH_TMR3);
RCM_DisableAPB1PeriphReset(RCM_APB1_PERIPH_TMR3);
}
else if (TMRx == TMR6)
{
RCM_EnableAPB1PeriphReset(RCM_APB1_PERIPH_TMR6);
RCM_DisableAPB1PeriphReset(RCM_APB1_PERIPH_TMR6);
}
else if (TMRx == TMR7)
{
RCM_EnableAPB1PeriphReset(RCM_APB1_PERIPH_TMR7);
RCM_DisableAPB1PeriphReset(RCM_APB1_PERIPH_TMR7);
}
else if (TMRx == TMR14)
{
RCM_EnableAPB1PeriphReset(RCM_APB1_PERIPH_TMR14);
RCM_DisableAPB1PeriphReset(RCM_APB1_PERIPH_TMR14);
}
else if (TMRx == TMR15)
{
RCM_EnableAPB2PeriphReset(RCM_APB2_PERIPH_TMR15);
RCM_DisableAPB2PeriphReset(RCM_APB2_PERIPH_TMR15);
}
else if (TMRx == TMR16)
{
RCM_EnableAPB2PeriphReset(RCM_APB2_PERIPH_TMR16);
RCM_DisableAPB2PeriphReset(RCM_APB2_PERIPH_TMR16);
}
else if (TMRx == TMR17)
{
RCM_EnableAPB2PeriphReset(RCM_APB2_PERIPH_TMR17);
RCM_DisableAPB2PeriphReset(RCM_APB2_PERIPH_TMR17);
}
}
/*!
* @brief Initializes the TMRx Time Base Unit peripheral according to
* the specified parameters in the TMR_ConfigTimeBase
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @param timeBaseConfig: pointer to a TMR_TimeBase_T structure that contains
* the configuration information for the specified TMR peripheral
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_ConfigTimeBase(TMR_T* TMRx, TMR_TimeBase_T* timeBaseConfig)
{
if ((TMRx == TMR1) || (TMRx == TMR3))
{
/** Select the Counter Mode */
TMRx->CTRL1_B.CNTDIR = timeBaseConfig->counterMode;
TMRx->CTRL1_B.CAMSEL = (timeBaseConfig->counterMode) >> 1;
}
if (TMRx != TMR6)
{
/** Set the clock division */
TMRx->CTRL1_B.CLKDIV = timeBaseConfig->clockDivision;
}
/** Set the Autoreload value */
TMRx->AUTORLD = timeBaseConfig->period ;
/** Set the Prescaler value */
TMRx->PSC = timeBaseConfig->div ;
if ((TMRx == TMR1) || (TMRx == TMR15) || (TMRx == TMR16) || (TMRx == TMR17))
{
/** Set the Repetition Counter value */
TMRx->REPCNT = timeBaseConfig->repetitionCounter;
}
/** Enable Update generation */
TMRx->CEG_B.UEG = BIT_SET;
}
/*!
* @brief Fills each TMR_ConfigTimeBaseStruct member with its default value
*
* @param timeBaseConfig: pointer to a TMR_TimeBase_T structure that contains
* the configuration information for the specified TMR peripheral
*
* @retval None
*/
void TMR_ConfigTimeBaseStruct(TMR_TimeBase_T* timeBaseConfig)
{
timeBaseConfig->period = 0xFFFFFFFF;
timeBaseConfig->div = 0x0000;
timeBaseConfig->clockDivision = TMR_CKD_DIV1;
timeBaseConfig->counterMode = TMR_COUNTER_MODE_UP;
timeBaseConfig->repetitionCounter = 0x0000;
}
/*!
* @brief Configures the TMRx Div
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @param div: specifies the Div Register value
*
* @param mode: specifies the TMR Prescaler Reload mode
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_ConfigDIV(TMR_T* TMRx, uint16_t div, TMR_PRESCALER_RELOAD_T mode)
{
TMRx->PSC = div;
TMRx->CEG_B.UEG = mode;
}
/*!
* @brief Specifies the TMRx Counter Mode to be used
*
* @param TMRx: x can be can be 1 or 3 to select Timer
*
* @param mode : specifies the Counter Mode to be used
*
* @retval None
*/
void TMR_ConfigCounterMode(TMR_T* TMRx, TMR_COUNTER_MODE_T mode)
{
TMRx->CTRL1_B.CNTDIR = mode;
TMRx->CTRL1_B.CAMSEL = (mode) >> 1;
}
/*!
* @brief Sets the TMRx Counter Register value
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @param counter: specifies the Counter register new value
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_SetCounter(TMR_T* TMRx, uint32_t counter)
{
TMRx->CNT = counter;
}
/*!
* @brief Read the TMRx Counter value
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @retval Counter Register value
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
uint32_t TMR_ReadCounter(TMR_T* TMRx)
{
return (uint32_t)TMRx->CNT;
}
/*!
* @brief Sets the AutoReload Register value
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @param autoReload: autoReload register new value
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_SetAutoReload(TMR_T* TMRx, uint32_t autoReload)
{
TMRx->AUTORLD = autoReload;
}
/*!
* @brief Read the TMRx Div value
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @retval Div Register value
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
uint32_t TMR_ReadDiv(TMR_T* TMRx)
{
return (uint32_t)TMRx->PSC;
}
/*!
* @brief Enable the No update event
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_EnableNGUpdate(TMR_T* TMRx)
{
TMRx->CTRL1_B.UD = ENABLE;
}
/*!
* @brief Enable the No update event
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_DisableNGUpdate(TMR_T* TMRx)
{
TMRx->CTRL1_B.UD = DISABLE;
}
/*!
* @brief Configures the Update Request Interrupt source.
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @param source: Config the Update source
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_ConfigUPdateRequest(TMR_T* TMRx, TMR_UPDATE_SOURCE_T source)
{
if (source != TMR_UPDATE_SOURCE_GLOBAL)
{
TMRx->CTRL1_B.URSSEL = BIT_SET;
}
else
{
TMRx->CTRL1_B.URSSEL = BIT_RESET;
}
}
/*!
* @brief Enables peripheral Preload register on AUTORLD
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_EnableAUTOReload(TMR_T* TMRx)
{
TMRx->CTRL1_B.ARPEN = ENABLE;
}
/*!
* @brief Disable peripheral Preload register on AUTORLD
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_DisableAUTOReload(TMR_T* TMRx)
{
TMRx->CTRL1_B.ARPEN = DISABLE;
}
/*!
* @brief Selects the One Pulse Mode
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @param OPMode:Config OP Mode to be used
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_SelectOnePulseMode(TMR_T* TMRx, TMR_OPMODE_T OPMode)
{
TMRx->CTRL1_B.SPMEN = OPMode;
}
/*!
* @brief Sets the Clock Division value
*
* @param TMRx: x can be can be 1��2��3, 14, 15, 16 and 17 to select Timer
*
* @param clockDivision: clock division value
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_SetClockDivision(TMR_T* TMRx, TMR_CKD_T clockDivision)
{
TMRx->CTRL1_B.CLKDIV = clockDivision;
}
/*!
* @brief Enable the specified TMR peripheral
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_Enable(TMR_T* TMRx)
{
TMRx->CTRL1_B.CNTEN = ENABLE;
}
/*!
* @brief Disable the specified TMR peripheral
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_Disable(TMR_T* TMRx)
{
TMRx->CTRL1_B.CNTEN = DISABLE;
}
/*!
* @brief Configures the: Break feature, dead time, Lock level, the OSSI
*
* @param TMRx: x can be can be 1, 15, 16 and 17 to select Timer
*
* @param structure: pointer to a TMR_BDTInit_T structure that contains
* the BDT Register configuration information for the TMR peripheral
*
* @retval None
*/
void TMR_ConfigBDT(TMR_T* TMRx, TMR_BDTInit_T* structure)
{
TMRx->BDT = (uint32_t)(((uint32_t)structure->automaticOutput) << 14) |
(((uint32_t)structure->breakPolarity) << 13) |
(((uint32_t)structure->breakState) << 12) |
(((uint32_t)structure->RMOS_State) << 11) |
(((uint32_t)structure->IMOS_State) << 10) |
(((uint32_t)structure->lockLevel) << 8) |
((uint32_t)structure->deadTime);
}
/*!
* @brief Initialize the BDT timer with its default value.
*
* @param structure: pointer to a TMR_BDTInit_T structure that contains
* the BDT Register configuration information for the TMR peripheral
*
* @retval None
*/
void TMR_ConfigBDTStructInit(TMR_BDTInit_T* structure)
{
structure->RMOS_State = TMR_RMOS_STATE_DISABLE;
structure->IMOS_State = TMR_IMOS_STATE_DISABLE;
structure->lockLevel = TMR_LOCK_LEVEL_OFF;
structure->deadTime = 0x00;
structure->breakState = TMR_BREAK_STATE_DISABLE;
structure->breakPolarity = TMR_BREAK_POLARITY_LOW;
structure->automaticOutput = TMR_AUTOMATIC_OUTPUT_DISABLE;
}
/*!
* @brief Enable TMRx PWM output.
*
* @param TMRx: x can be can be 1, 15, 16 and 17 to select Timer
*
* @retval None
*/
void TMR_EnablePWMOutputs(TMR_T* TMRx)
{
TMRx->BDT_B.MOEN = ENABLE;
}
/*!
* @brief Disable TMRx PWM output.
*
* @param TMRx: x can be can be 1, 15, 16 and 17 to select Timer
*
* @retval None
*/
void TMR_DisablePWMOutputs(TMR_T* TMRx)
{
TMRx->BDT_B.MOEN = DISABLE;
}
/*!
* @brief Configure channel 1 according to parameters
*
* @param TMRx: x can be can be 1, 2, 3, 14, 15, 16 and 17 to select Timer
*
* @param OCcongigStruct: Channel configuration structure
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC1Config(TMR_T* TMRx, TMR_OCConfig_T* OCcongigStruct)
{
/** Disable the Channel 1: Reset the CC1EN Bit */
TMRx->CCEN_B.CC1EN = BIT_RESET;
/** Reset and Select the Output Compare Mode Bits */
TMRx->CCM1_OUTPUT_B.CC1SEL = BIT_RESET;
TMRx->CCM1_OUTPUT_B.OC1MOD = OCcongigStruct->OC_Mode;
/** Reset and Set the Output Polarity level */
TMRx->CCEN_B.CC1POL = OCcongigStruct->OC_Polarity;
/** Set the Output State */
TMRx->CCEN_B.CC1EN = OCcongigStruct->OC_OutputState;
if ((TMRx == TMR1) || (TMRx == TMR15) || (TMRx == TMR16)
|| (TMRx == TMR17))
{
/** Reset and Set the Output N Polarity level */
TMRx->CCEN_B.CC1NPOL = OCcongigStruct->OC_NPolarity;
/** Reset and Set the Output N State */
TMRx->CCEN_B.CC1NEN = OCcongigStruct->OC_OutputNState;
/** Reset the Output Compare and Output Compare N IDLE State */
TMRx->CTRL2_B.OC1OIS = BIT_RESET;
TMRx->CTRL2_B.OC1NOIS = BIT_RESET;
/** Set the Output Idle state */
TMRx->CTRL2_B.OC1OIS = OCcongigStruct->OC_Idlestate;
/** Set the Output N State */
TMRx->CTRL2_B.OC1NOIS = OCcongigStruct->OC_NIdlestate;
}
/** Set the Capture Compare Register value */
TMRx->CC1 = OCcongigStruct->Pulse;
}
/*!
* @brief Configure channel 2 according to parameters
*
* @param TMRx: x can be can be 1��2��3 and 15 to select Timer
*
* @param OCcongigStruct: Channel configuration structure
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC2Config(TMR_T* TMRx, TMR_OCConfig_T* OCcongigStruct)
{
/** Disable the Channel 2: Reset the CC2EN Bit */
TMRx->CCEN_B.CC2EN = BIT_RESET;
/** Reset and Select the Output Compare Mode Bits */
TMRx->CCM1_OUTPUT_B.CC2SEL = BIT_RESET;
TMRx->CCM1_OUTPUT_B.OC2MOD = OCcongigStruct->OC_Mode;
/** Reset and Set the Output Polarity level */
TMRx->CCEN_B.CC2POL = BIT_RESET;
TMRx->CCEN_B.CC2POL = OCcongigStruct->OC_Polarity;
/** Set the Output State */
TMRx->CCEN_B.CC2EN = OCcongigStruct->OC_OutputState;
if (TMRx == TMR1)
{
/** Reset and Set the Output N Polarity level */
TMRx->CCEN_B.CC2NPOL = BIT_RESET;
TMRx->CCEN_B.CC2NPOL = OCcongigStruct->OC_NPolarity;
/** Reset and Set the Output N State */
TMRx->CCEN_B.CC2NEN = BIT_RESET;
TMRx->CCEN_B.CC2NEN = OCcongigStruct->OC_OutputNState;
/** Reset the Output Compare and Output Compare N IDLE State */
TMRx->CTRL2_B.OC2OIS = BIT_RESET;
TMRx->CTRL2_B.OC2NOIS = BIT_RESET;
/** Set the Output Idle state */
TMRx->CTRL2_B.OC2OIS = OCcongigStruct->OC_Idlestate;
/** Set the Output N State */
TMRx->CTRL2_B.OC2NOIS = OCcongigStruct->OC_NIdlestate;
}
/** Set the Capture Compare Register value */
TMRx->CC2 = OCcongigStruct->Pulse;
}
/*!
* @brief Configure channel 3 according to parameters
*
* @param TMRx: x can be can be 1, 2, 3 to select Timer
*
* @param OCcongigStruct: Channel configuration structure
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC3Config(TMR_T* TMRx, TMR_OCConfig_T* OCcongigStruct)
{
/** Disable the Channel 3: Reset the CC3EN Bit */
TMRx->CCEN_B.CC3EN = BIT_RESET;
/** Reset and Select the Output Compare Mode Bits */
TMRx->CCM2_OUTPUT_B.CC3SEL = BIT_RESET;
TMRx->CCM2_OUTPUT_B.OC3MOD = OCcongigStruct->OC_Mode;
/** Reset and Set the Output Polarity level */
TMRx->CCEN_B.CC3POL = BIT_RESET;
TMRx->CCEN_B.CC3POL = OCcongigStruct->OC_Polarity;
/** Set the Output State */
TMRx->CCEN_B.CC3EN = OCcongigStruct->OC_OutputState;
if (TMRx == TMR1)
{
/** Reset and Set the Output N Polarity level */
TMRx->CCEN_B.CC3NPOL = BIT_RESET;
TMRx->CCEN_B.CC3NPOL = OCcongigStruct->OC_NPolarity;
/** Reset and Set the Output N State */
TMRx->CCEN_B.CC3NEN = BIT_RESET;
TMRx->CCEN_B.CC3NEN = OCcongigStruct->OC_OutputNState;
/** Reset the Output Compare and Output Compare N IDLE State */
TMRx->CTRL2_B.OC3OIS = BIT_RESET;
TMRx->CTRL2_B.OC3NOIS = BIT_RESET;
/** Set the Output Idle state */
TMRx->CTRL2_B.OC3OIS = OCcongigStruct->OC_Idlestate;
/** Set the Output N State */
TMRx->CTRL2_B.OC3NOIS = OCcongigStruct->OC_NIdlestate;
}
/** Set the Capture Compare Register value */
TMRx->CC3 = OCcongigStruct->Pulse;
}
/*!
* @brief Configure channel 4 according to parameters
*
* @param TMRx: x can be can be 1, 2, 3 to select Timer
*
* @param OCcongigStruct: Channel configuration structure
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC4Config(TMR_T* TMRx, TMR_OCConfig_T* OCcongigStruct)
{
/** Disable the Channel 4: Reset the CC4EN Bit */
TMRx->CCEN_B.CC4EN = BIT_RESET;
/** Reset and Select the Output Compare Mode Bits */
TMRx->CCM2_OUTPUT_B.CC4SEL = BIT_RESET;
TMRx->CCM2_OUTPUT_B.OC4MOD = OCcongigStruct->OC_Mode;
/** Reset and Set the Output Polarity level */
TMRx->CCEN_B.CC4POL = BIT_RESET;
TMRx->CCEN_B.CC4POL = OCcongigStruct->OC_Polarity;
/** Set the Output State */
TMRx->CCEN_B.CC4EN = OCcongigStruct->OC_OutputState;
if (TMRx == TMR1)
{
/** Reset the Output Compare and Output Compare IDLE State */
TMRx->CTRL2_B.OC4OIS = BIT_RESET;
/** Set the Output Idle state */
TMRx->CTRL2_B.OC4OIS = OCcongigStruct->OC_Idlestate;
}
/** Set the Capture Compare Register value */
TMRx->CC4 = OCcongigStruct->Pulse;
}
/*!
* @brief Initialize the OC timer with its default value.
*
* @param OCcongigStruct: Channel configuration structure
*
* @retval None
*/
void TMR_OCConfigStructInit(TMR_OCConfig_T* OCcongigStruct)
{
/** Set the default configuration */
OCcongigStruct->OC_Mode = TMR_OC_MODE_TMRING;
OCcongigStruct->OC_OutputState = TMR_OUTPUT_STATE_DISABLE;
OCcongigStruct->OC_OutputNState = TMR_OUTPUT_NSTATE_DISABLE;
OCcongigStruct->Pulse = 0x0000;
OCcongigStruct->OC_Polarity = TMR_OC_POLARITY_HIGH;
OCcongigStruct->OC_NPolarity = TMR_OC_NPOLARITY_HIGH;
OCcongigStruct->OC_Idlestate = TMR_OCIDLESTATE_RESET;
OCcongigStruct->OC_NIdlestate = TMR_OCNIDLESTATE_RESET;
}
/*!
* @brief Selects the Output Compare Mode.
*
* @param TMRx: x can be can be 1��2��3, 14, 15, 16 and 17 to select Timer
*
* @param channel: specifies the TMR Channel
* This parameter can be one of the following values:
* @arg TMR_CHANNEL_1
* @arg TMR_CHANNEL_2
* @arg TMR_CHANNEL_3
* @arg TMR_CHANNEL_4
*
* @param OCMode: specifies the TMR Output Compare Mode
* This parameter can be one of the following values:
* @arg TMR_OC_MODE_TMRING
* @arg TMR_OC_MODE_ACTIVE
* @arg TMR_OC_MODE_INACTIVE
* @arg TMR_OC_MODE_LOWLEVEL
* @arg TMR_OC_MODE_HIGHLEVEL
* @arg TMR_OC_MODE_PWM1
* @arg TMR_OC_MODE_PWM2
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_SelectOCxMode(TMR_T* TMRx, TMR_CHANNEL_T channel, TMR_OC_MODE_T mode)
{
TMRx->CCEN &= BIT_RESET << channel;
if (channel == TMR_CHANNEL_1)
{
TMRx->CCM1_OUTPUT_B.OC1MOD = mode;
}
else if (channel == TMR_CHANNEL_2)
{
TMRx->CCM1_OUTPUT_B.OC2MOD = mode;
}
else if (channel == TMR_CHANNEL_3)
{
TMRx->CCM2_OUTPUT_B.OC3MOD = mode;
}
else if (channel == TMR_CHANNEL_4)
{
TMRx->CCM2_OUTPUT_B.OC4MOD = mode;
}
}
/*!
* @brief Sets the Capture Compare1 Register value
*
* @param TMRx: x can be can be 1��2��3, 14, 15, 16 and 17 to select Timer
*
* @param compare: specifies the Capture Compare1 register new value
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_SetCompare1(TMR_T* TMRx, uint32_t compare)
{
TMRx->CC1 = compare;
}
/*!
* @brief Sets the Capture Compare2 Register value
*
* @param TMRx: x can be can be 1��2��3 and 15 to select Timer
*
* @param compare: specifies the Capture Compare1 register new value
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_SetCompare2(TMR_T* TMRx, uint32_t compare)
{
TMRx->CC2 = compare;
}
/*!
* @brief Sets the Capture Compare3 Register value
*
* @param TMRx: x can be can be 1, 2, 3 to select Timer
*
* @param compare: specifies the Capture Compare1 register new value
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_SetCompare3(TMR_T* TMRx, uint32_t compare)
{
TMRx->CC3 = compare;
}
/*!
* @brief Sets the Capture Compare4 Register value
*
* @param TMRx: x can be can be 1, 2, 3 to select Timer
*
* @param compare: specifies the Capture Compare1 register new value
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_SetCompare4(TMR_T* TMRx, uint32_t compare)
{
TMRx->CC4 = compare;
}
/*!
* @brief Forces the output 1 waveform to active or inactive level
*
* @param TMRx: x can be can be 1��2��3, 14, 15, 16 and 17 to select Timer
*
* @param action: forced Action to be set to the output waveform
* This parameter can be one of the following values:
* @arg TMR_FORCEDACTION_INACTIVE
* @arg TMR_FORCEDACTION_ACTIVE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ForcedOC1Config(TMR_T* TMRx, TMR_FORCED_ACTION_T action)
{
TMRx->CCM1_OUTPUT_B.OC1MOD = action;
}
/*!
* @brief Forces the output 2 waveform to active or inactive level
*
* @param TMRx: x can be can be 1��2��3 and 15 to select Timer
*
* @param action: forced Action to be set to the output waveform
* This parameter can be one of the following values:
* @arg TMR_FORCEDACTION_INACTIVE
* @arg TMR_FORCEDACTION_ACTIVE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ForcedOC2Config(TMR_T* TMRx, TMR_FORCED_ACTION_T action)
{
TMRx->CCM1_OUTPUT_B.OC2MOD = action;
}
/*!
* @brief Forces the output 3 waveform to active or inactive level
*
* @param TMRx: x can be can be 1, 2, 3 to select Timer
*
* @param action: forced Action to be set to the output waveform
* This parameter can be one of the following values:
* @arg TMR_FORCEDACTION_INACTIVE
* @arg TMR_FORCEDACTION_ACTIVE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ForcedOC3Config(TMR_T* TMRx, TMR_FORCED_ACTION_T action)
{
TMRx->CCM2_OUTPUT_B.OC3MOD = action;
}
/*!
* @brief Forces the output 4 waveform to active or inactive level
*
* @param TMRx: x can be can be 1, 2, 3 to select Timer
*
* @param action: forced Action to be set to the output waveform
* This parameter can be one of the following values:
* @arg TMR_FORCEDACTION_INACTIVE
* @arg TMR_FORCEDACTION_ACTIVE
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ForcedOC4Config(TMR_T* TMRx, TMR_FORCED_ACTION_T action)
{
TMRx->CCM2_OUTPUT_B.OC4MOD = action;
}
/*!
* @brief Sets Capture Compare Preload Control bit
*
* @param TMRx: x can be can be 1��2��3 and 15 to select Timer
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_EnableCCPreload(TMR_T* TMRx)
{
TMRx->CTRL2_B.CCPEN = ENABLE;
}
/*!
* @brief Resets Capture Compare Preload Control bit
*
* @param TMRx: x can be can be 1��2��3 and 15 to select Timer
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_DisableCCPreload(TMR_T* TMRx)
{
TMRx->CTRL2_B.CCPEN = DISABLE;
}
/*!
* @brief Enables or disables the peripheral Preload register on CC1
*
* @param TMRx: x can be can be 1, 2, 3 ,14, 15, 16 and 17 to select Timer
*
* @param OCPreload: new state of the TMRx peripheral Preload register
* This parameter can be one of the following values:
* @arg TMR_OC_PRELOAD_DISABLE
* @arg TMR_OC_PRELOAD_ENABLE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC1PreloadConfig(TMR_T* TMRx, TMR_OC_PRELOAD_T OCPreload)
{
TMRx->CCM1_OUTPUT_B.OC1PEN = OCPreload;
}
/*!
* @brief Enables or disables the peripheral Preload register on CC2
*
* @param TMRx: x can be can be 1, 2, 3 and 15 to select Timer
*
* @param OCPreload: new state of the TMRx peripheral Preload register
* This parameter can be one of the following values:
* @arg TMR_OC_PRELOAD_DISABLE
* @arg TMR_OC_PRELOAD_ENABLE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC2PreloadConfig(TMR_T* TMRx, TMR_OC_PRELOAD_T OCPreload)
{
TMRx->CCM1_OUTPUT_B.OC2PEN = OCPreload;
}
/*!
* @brief Enables or disables the peripheral Preload register on CC3
*
* @param TMRx: x can be can be 1, 2, 3 to select Timer
*
* @param OCPreload: new state of the TMRx peripheral Preload register
* This parameter can be one of the following values:
* @arg TMR_OC_PRELOAD_DISABLE
* @arg TMR_OC_PRELOAD_ENABLE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC3PreloadConfig(TMR_T* TMRx, TMR_OC_PRELOAD_T OCPreload)
{
TMRx->CCM2_OUTPUT_B.OC3PEN = OCPreload;
}
/*!
* @brief Enables or disables the peripheral Preload register on CC4
*
* @param TMRx: x can be can be 1, 2, 3 to select Timer
*
* @param OCPreload: new state of the TMRx peripheral Preload register
* This parameter can be one of the following values:
* @arg TMR_OC_PRELOAD_DISABLE
* @arg TMR_OC_PRELOAD_ENABLE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC4PreloadConfig(TMR_T* TMRx, TMR_OC_PRELOAD_T OCPreload)
{
TMRx->CCM2_OUTPUT_B.OC4PEN = OCPreload;
}
/*!
* @brief Configures the Output Compare 1 Fast feature
*
* @param TMRx: where x can be 1, 2, 3, 14, 15, 16 and 17 to select the TMR peripheral
*
* @param OCFast: new state of the Output Compare Fast Enable Bit
* This parameter can be one of the following values:
* @arg TMR_OCFAST_DISABLE
* @arg TMR_OCFAST_ENABLE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC1FastConfit(TMR_T* TMRx, TMR_OCFAST_T OCFast)
{
TMRx->CCM1_OUTPUT_B.OC1FEN = OCFast;
}
/*!
* @brief Configures the Output Compare 2 Fast feature
*
* @param TMRx: where x can be 1, 2, 3 and 15 to select the TMR peripheral
*
* @param OCFast: new state of the Output Compare Fast Enable Bit
* This parameter can be one of the following values:
* @arg TMR_OCFAST_DISABLE
* @arg TMR_OCFAST_ENABLE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC2FastConfit(TMR_T* TMRx, TMR_OCFAST_T OCFast)
{
TMRx->CCM1_OUTPUT_B.OC2FEN = OCFast;
}
/*!
* @brief Configures the Output Compare 3 Fast feature
*
* @param TMRx: where x can be 1, 2, 3 to select the TMR peripheral
*
* @param OCFast: new state of the Output Compare Fast Enable Bit
* This parameter can be one of the following values:
* @arg TMR_OCFAST_DISABLE
* @arg TMR_OCFAST_ENABLE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC3FastConfit(TMR_T* TMRx, TMR_OCFAST_T OCFast)
{
TMRx->CCM2_OUTPUT_B.OC3FEN = OCFast;
}
/*!
* @brief Configures the Output Compare 4 Fast feature
*
* @param TMRx: where x can be 1, 2, 3 to select the TMR peripheral
*
* @param OCFast: new state of the Output Compare Fast Enable Bit
* This parameter can be one of the following values:
* @arg TMR_OCFAST_DISABLE
* @arg TMR_OCFAST_ENABLE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC4FastConfit(TMR_T* TMRx, TMR_OCFAST_T OCFast)
{
TMRx->CCM2_OUTPUT_B.OC4FEN = OCFast;
}
/*!
* @brief Clears or safeguards the OCREF1 signal on an external event
*
* @param TMRx: where x can be 1, 2, 3, 14, 15, 16 and 17 to select the TMR peripheral
*
* @param OCCler: new state of the Output Compare Clear Enable Bit
* This parameter can be one of the following values:
* @arg TMR_OCCLER_DISABLE
* @arg TMR_OCCLER_ENABLE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ClearOC1Ref(TMR_T* TMRx, TMR_OCCLER_T OCCler)
{
TMRx->CCM1_OUTPUT_B.OC1CEN = OCCler;
}
/*!
* @brief Clears or safeguards the OCREF2 signal on an external event
*
* @param TMRx: where x can be 1, 2, 3 and 15 to select the TMR peripheral
*
* @param OCCler: new state of the Output Compare Clear Enable Bit
* This parameter can be one of the following values:
* @arg TMR_OCCLER_DISABLE
* @arg TMR_OCCLER_ENABLE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ClearOC2Ref(TMR_T* TMRx, TMR_OCCLER_T OCCler)
{
TMRx->CCM1_OUTPUT_B.OC2CEN = OCCler;
}
/*!
* @brief Clears or safeguards the OCREF3 signal on an external event
*
* @param TMRx: where x can be 1, 2, 3 to select the TMR peripheral
*
* @param OCCler: new state of the Output Compare Clear Enable Bit
* This parameter can be one of the following values:
* @arg TMR_OCCLER_DISABLE
* @arg TMR_OCCLER_ENABLE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ClearOC3Ref(TMR_T* TMRx, TMR_OCCLER_T OCCler)
{
TMRx->CCM2_OUTPUT_B.OC3CEN = OCCler;
}
/*!
* @brief Clears or safeguards the OCREF4 signal on an external event
*
* @param TMRx: where x can be 1, 2, 3 to select the TMR peripheral
*
* @param OCCler: new state of the Output Compare Clear Enable Bit
* This parameter can be one of the following values:
* @arg TMR_OCCLER_DISABLE
* @arg TMR_OCCLER_ENABLE
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ClearOC4Ref(TMR_T* TMRx, TMR_OCCLER_T OCCler)
{
TMRx->CCM2_OUTPUT_B.OC4CEN = OCCler;
}
/*!
* @brief Configures the channel 1 polarity
*
* @param TMRx: where x can be 1, 2, 3, 14, 15, 16 and 17 to select the TMR peripheral
*
* @param OCPolarity: specifies the OC1 Polarity
* This parameter can be one of the following values:
* @arg TMR_OC_POLARITY_HIGH
* @arg TMR_OC_POLARITY_LOW
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC1PolarityConfig(TMR_T* TMRx, TMR_OC_POLARITY_T OCPolarity)
{
TMRx->CCEN_B.CC1POL = OCPolarity;
}
/*!
* @brief Configures the channel 1N polarity
*
* @param TMRx: where x can be 1, 15, 16 and 17 to select the TMR peripheral
*
* @param OCNPolarity: specifies the OC1 NPolarity
* This parameter can be one of the following values:
* @arg TMR_OC_NPOLARITY_HIGH
* @arg TMR_OC_NPOLARITY_LOW
* @retval None
*/
void TMR_OC1NPolarityConfig(TMR_T* TMRx, TMR_OC_NPOLARITY_T OCNPolarity)
{
TMRx->CCEN_B.CC1NPOL = OCNPolarity;
}
/*!
* @brief Configures the channel 2 polarity
*
* @param TMRx: where x can be 1, 2, 3 and 15 to select the TMR peripheral
*
* @param OCPolarity: specifies the OC2 Polarity
* This parameter can be one of the following values:
* @arg TMR_OC_POLARITY_HIGH
* @arg TMR_OC_POLARITY_LOW
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC2PolarityConfig(TMR_T* TMRx, TMR_OC_POLARITY_T OCPolarity)
{
TMRx->CCEN_B.CC2POL = OCPolarity;
}
/*!
* @brief Configures the channel 2N polarity
*
* @param TMRx: where x can be 1 to select the TMR peripheral
*
* @param OCNPolarity: specifies the OC2 NPolarity
* This parameter can be one of the following values:
* @arg TMR_OC_NPOLARITY_HIGH
* @arg TMR_OC_NPOLARITY_LOW
* @retval None
*/
void TMR_OC2NPolarityConfig(TMR_T* TMRx, TMR_OC_NPOLARITY_T OCNPolarity)
{
TMRx->CCEN_B.CC2NPOL = OCNPolarity;
}
/*!
* @brief Configures the channel 3 polarity
*
* @param TMRx: where x can be 1, 2, 3 to select the TMR peripheral
*
* @param OCPolarity: specifies the OC3 Polarity
* This parameter can be one of the following values:
* @arg TMR_OC_POLARITY_HIGH
* @arg TMR_OC_POLARITY_LOW
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC3PolarityConfig(TMR_T* TMRx, TMR_OC_POLARITY_T OCPolarity)
{
TMRx->CCEN_B.CC3POL = OCPolarity;
}
/*!
* @brief Configures the channel 3N polarity
*
* @param TMRx: where x can be 1 to select the TMR peripheral
*
* @param OCNPolarity: specifies the OC3 NPolarity
* This parameter can be one of the following values:
* @arg TMR_OC_NPOLARITY_HIGH
* @arg TMR_OC_NPOLARITY_LOW
* @retval None
*/
void TMR_OC3NPolarityConfig(TMR_T* TMRx, TMR_OC_NPOLARITY_T OCNPolarity)
{
TMRx->CCEN_B.CC3NPOL = OCNPolarity;
}
/*!
* @brief Configures the channel 4 polarity
*
* @param TMRx: where x can be 1, 2, 3 to select the TMR peripheral
*
* @param OCPolarity: specifies the OC4 Polarity
* This parameter can be one of the following values:
* @arg TMR_OC_POLARITY_HIGH
* @arg TMR_OC_POLARITY_LOW
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_OC4PolarityConfig(TMR_T* TMRx, TMR_OC_POLARITY_T OCPolarity)
{
TMRx->CCEN_B.CC4POL = OCPolarity;
}
/*!
* @brief Selects the OCReference Clear source
*
* @param TMRx: x can be 1, 2, 3 to select Timer.
*
* @param OCReferenceClear: specifies the OCReference Clear source
* This parameter can be one of the following values:
* @arg TMR_OCCS_ETRF
* @arg TMR_OCCS_OCREFCLR
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_SelectOCREFClear(TMR_T* TMRx, TMR_OCCSEL_T OCReferenceClear)
{
TMRx->SMCTRL_B.OCCSEL = OCReferenceClear;
}
/*!
* @brief Enables the Capture Compare Channel x
*
* @param TMRx: where x can be 1, 2, 3, 14, 15, 16 and 17 to select the TMR peripheral
*
* @param channel: TMR channel
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_EnableCCxChannel(TMR_T* TMRx, TMR_CHANNEL_T channel)
{
TMRx->CCEN |= BIT_SET << channel;
}
/*!
* @brief Disables the Capture Compare Channel x
*
* @param TMRx: where x can be 1, 2, 3, 14, 15, 16 and 17 to select the TMR peripheral
*
* @param channel: TMR channel
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_DisableCCxChannel(TMR_T* TMRx, TMR_CHANNEL_T channel)
{
TMRx->CCEN &= ~(BIT_SET << channel);
}
/*!
* @brief Enables the Capture Compare Channel xN.
*
* @param TMRx: where x can be 1, 15, 16 and 17 to select the TMR peripheral
*
* @param channel: TMR channel
*
* @retval None
*/
void TMR_EnableCCxNChannel(TMR_T* TMRx, TMR_CHANNEL_T channel)
{
TMRx->CCEN |= 0x04 << channel;
}
/*!
* @brief Disables the Capture Compare Channel xN
*
* @param TMRx: where x can be 1, 15, 16 and 17 to select the TMR peripheral
*
* @param channel: TMR channel
*
* @retval None
*/
void TMR_DisableCCxNChannel(TMR_T* TMRx, TMR_CHANNEL_T channel)
{
TMRx->CCEN &= ~(0x04 << channel);
}
/*!
* @brief Enable Selects the TMR peripheral Commutation event
*
* @param TMRx: where x can be 1, 15, 16 and 17 to select the TMR peripheral
*
* @retval None
*/
void TMR_EnableSelectCOM(TMR_T* TMRx)
{
TMRx->CTRL2_B.CCUSEL = ENABLE;
}
/*!
* @brief Disable Selects the TMR peripheral Commutation event
*
* @param TMRx: where x can be 1, 15, 16 and 17 to select the TMR peripheral
*
* @retval None
*/
void TMR_DisableSelectCOM(TMR_T* TMRx)
{
TMRx->CTRL2_B.CCUSEL = DISABLE;
}
/*!
* @brief Configure the TI1 as Input.
*
* @param TMRx: where x can be 1, 2, 3, 14, 15, 16 and 17 to select the TMR peripheral
*
* @param ICpolarity: The Input Polarity.
*
* @param ICselection: specifies the input to be used.
*
* @param ICfilter: Specifies the Input Capture Filter
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
static void TI1Config(TMR_T* TMRx, uint16_t ICpolarity, uint16_t ICselection, uint16_t ICfilter)
{
uint16_t tmpchctrl = 0;
/** Disable the Channel 1: Reset the CC1EN Bit */
TMRx->CCEN_B.CC1EN = BIT_RESET;
/** Select the Input and set the filter */
TMRx->CCM1_INPUT_B.CC1SEL = BIT_RESET;
TMRx->CCM1_INPUT_B.IC1F = BIT_RESET;
TMRx->CCM1_INPUT_B.CC1SEL = ICselection;
TMRx->CCM1_INPUT_B.IC1F = ICfilter;
/** Select the Polarity */
tmpchctrl = TMRx->CCEN;
tmpchctrl &= (uint16_t)~((uint16_t)TMR_IC_POLARITY_BOTHEDGE);
tmpchctrl |= ICpolarity;
TMRx->CCEN = tmpchctrl;
/** Set the CC1EN Bit */
TMRx->CCEN_B.CC1EN = BIT_SET;
}
/*!
* @brief Configure the TI2 as Input
*
* @param TMRx: where x can be 1, 2, 3, 14, 15, 16 and 17 to select the TMR periphera
*
* @param ICpolarity: The Input Polarity.
*
* @param ICselection: specifies the input to be used.
*
* @param ICfilter: Specifies the Input Capture Filter
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
static void TI2Config(TMR_T* TMRx, uint16_t ICpolarity, uint16_t ICselection, uint16_t ICfilter)
{
uint16_t tmpchctrl = 0;
/** Disable the Channel 2: Reset the CC2EN Bit */
TMRx->CCEN_B.CC2EN = BIT_RESET;
/** Select the Input and set the filter */
TMRx->CCM1_INPUT_B.CC2SEL = BIT_RESET;
TMRx->CCM1_INPUT_B.IC2F = BIT_RESET;
TMRx->CCM1_INPUT_B.CC2SEL = ICselection;
TMRx->CCM1_INPUT_B.IC2F = ICfilter;
/** Select the Polarity */
tmpchctrl = TMRx->CCEN;
tmpchctrl &= (uint16_t)~((uint16_t)TMR_IC_POLARITY_BOTHEDGE << 4);
tmpchctrl |= (uint16_t)(ICpolarity << 4);
TMRx->CCEN = tmpchctrl;
/** Set the CC2EN Bit */
TMRx->CCEN_B.CC2EN = BIT_SET;
}
/*!
* @brief Configure the TI3 as Input.
*
* @param TMRx: where x can be 1, 2, 3, 14, 15, 16 or 17 to select the TMR peripheral
*
* @param ICpolarity: The Input Polarity.
*
* @param ICselection: specifies the input to be used.
*
* @param ICfilter: Specifies the Input Capture Filter
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
static void TI3Config(TMR_T* TMRx, uint16_t ICpolarity, uint16_t ICselection, uint16_t ICfilter)
{
uint16_t tmpchctrl = 0;
/** Disable the Channel 3: Reset the CC3EN Bit */
TMRx->CCEN_B.CC3EN = BIT_RESET;
/** Select the Input and set the filter */
TMRx->CCM2_INPUT_B.CC3SEL = BIT_RESET;
TMRx->CCM2_INPUT_B.IC3F = BIT_RESET;
TMRx->CCM2_INPUT_B.CC3SEL = ICselection;
TMRx->CCM2_INPUT_B.IC3F = ICfilter;
/** Select the Polarity */
tmpchctrl = TMRx->CCEN;
tmpchctrl &= (uint16_t)~((uint16_t)TMR_IC_POLARITY_BOTHEDGE << 8);
tmpchctrl |= (uint16_t)(ICpolarity << 8);
TMRx->CCEN = tmpchctrl;
/** Set the CC3EN Bit */
TMRx->CCEN_B.CC3EN = BIT_SET;
}
/*!
* @brief Configure the TI4 as Input
*
* @param TMRx: where x can be 1, 2, 3, 14, 15, 16 or 17 to select the TMR peripheral
*
* @param ICpolarity: The Input Polarity.
*
* @param ICselection: specifies the input to be used.
*
* @param ICfilter: Specifies the Input Capture Filter
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
static void TI4Config(TMR_T* TMRx, uint16_t ICpolarity, uint16_t ICselection, uint16_t ICfilter)
{
uint16_t tmpchctrl = 0;
/** Disable the Channel 4: Reset the CC4EN Bit */
TMRx->CCEN_B.CC4EN = BIT_RESET;
/** Select the Input and set the filter */
TMRx->CCM2_INPUT_B.CC4SEL = BIT_RESET;
TMRx->CCM2_INPUT_B.IC4F = BIT_RESET;
TMRx->CCM2_INPUT_B.CC4SEL = ICselection;
TMRx->CCM2_INPUT_B.IC4F = ICfilter;
/** Select the Polarity */
tmpchctrl = TMRx->CCEN;
tmpchctrl &= (uint16_t)~((uint16_t)TMR_IC_POLARITY_BOTHEDGE << 12);
tmpchctrl |= (uint16_t)(ICpolarity << 12);
TMRx->CCEN = tmpchctrl;
/** Set the CC4EN Bit */
TMRx->CCEN_B.CC4EN = BIT_SET;
}
/*!
* @brief Configure Peripheral equipment
*
* @param TMRx: where x can be 1, 2, 3, 14, 15, 16 or 17 to select the TMR peripheral
*
* @param ICconfigstruct: pointer to a TMR_ICConfig_T structure
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ICConfig(TMR_T* TMRx, TMR_ICConfig_T* ICconfigstruct)
{
if (ICconfigstruct->channel == TMR_CHANNEL_1)
{
/** TI1 Configuration */
TI1Config(TMRx, ICconfigstruct->ICpolarity, ICconfigstruct->ICselection, ICconfigstruct->ICfilter);
TMR_SetIC1Prescal(TMRx, ICconfigstruct->ICprescaler);
}
else if (ICconfigstruct->channel == TMR_CHANNEL_2)
{
/** TI2 Configuration */
TI2Config(TMRx, ICconfigstruct->ICpolarity, ICconfigstruct->ICselection, ICconfigstruct->ICfilter);
TMR_SetIC2Prescal(TMRx, ICconfigstruct->ICprescaler);
}
else if (ICconfigstruct->channel == TMR_CHANNEL_3)
{
/** TI3 Configuration */
TI3Config(TMRx, ICconfigstruct->ICpolarity, ICconfigstruct->ICselection, ICconfigstruct->ICfilter);
TMR_SetIC3Prescal(TMRx, ICconfigstruct->ICprescaler);
}
else if (ICconfigstruct->channel == TMR_CHANNEL_4)
{
/** TI4 Configuration */
TI4Config(TMRx, ICconfigstruct->ICpolarity, ICconfigstruct->ICselection, ICconfigstruct->ICfilter);
TMR_SetIC4Prescal(TMRx, ICconfigstruct->ICprescaler);
}
}
/*!
* @brief Initialize the IC timer with its default value.
*
* @param ICconfigstruct: pointer to a TMR_ICConfig_T structure
*
* @retval None
*/
void TMR_ICConfigStructInit(TMR_ICConfig_T* ICconfigstruct)
{
ICconfigstruct->channel = TMR_CHANNEL_1;
ICconfigstruct->ICpolarity = TMR_IC_POLARITY_RISING;
ICconfigstruct->ICselection = TMR_IC_SELECTION_DIRECT_TI;
ICconfigstruct->ICprescaler = TMR_ICPSC_DIV1;
ICconfigstruct->ICfilter = 0x00;
}
/*!
* @brief Config of PWM output
*
* @param TMRx: where x can be 1, 2, 3 and 15 to select the TMR peripheral
*
* @param ICconfigstruct: pointer to a TMR_ICConfig_T structure
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_PWMConfig(TMR_T* TMRx, TMR_ICConfig_T* ICconfigstruct)
{
uint16_t icpolarity = TMR_IC_POLARITY_RISING;
uint16_t icselection = TMR_IC_SELECTION_DIRECT_TI;
/** Select the Opposite Input Polarity */
if (ICconfigstruct->ICpolarity == TMR_IC_POLARITY_RISING)
{
icpolarity = TMR_IC_POLARITY_FALLING;
}
else
{
icpolarity = TMR_IC_POLARITY_RISING;
}
/** Select the Opposite Input */
if (ICconfigstruct->ICselection == TMR_IC_SELECTION_DIRECT_TI)
{
icselection = TMR_IC_SELECTION_INDIRECT_TI;
}
else
{
icselection = TMR_IC_SELECTION_DIRECT_TI;
}
if (ICconfigstruct->channel == TMR_CHANNEL_1)
{
/** TI1 Configuration */
TI1Config(TMRx, ICconfigstruct->ICpolarity, ICconfigstruct->ICselection, ICconfigstruct->ICfilter);
/** Set the Input Capture Prescaler value */
TMR_SetIC1Prescal(TMRx, ICconfigstruct->ICprescaler);
/** TI2 Configuration */
TI2Config(TMRx, icpolarity, icselection, ICconfigstruct->ICfilter);
/** Set the Input Capture Prescaler value */
TMR_SetIC2Prescal(TMRx, ICconfigstruct->ICprescaler);
}
else
{
/** TI2 Configuration */
TI2Config(TMRx, ICconfigstruct->ICpolarity, ICconfigstruct->ICselection, ICconfigstruct->ICfilter);
/** Set the Input Capture Prescaler value */
TMR_SetIC2Prescal(TMRx, ICconfigstruct->ICprescaler);
/** TI1 Configuration */
TI1Config(TMRx, icpolarity, icselection, ICconfigstruct->ICfilter);
/** Set the Input Capture Prescaler value */
TMR_SetIC1Prescal(TMRx, ICconfigstruct->ICprescaler);
}
}
/*!
* @brief Read Input Capture 1 value
*
* @param TMRx: where x can be 1, 2, 3, 14, 15, 16 and 17 to select the TMR peripheral
*
* @retval Capture Compare 1 Register value
*
* @note TMR2 it's not for APM32F030 devices
*/
uint16_t TMR_ReadCaputer1(TMR_T* TMRx)
{
return TMRx->CC1;
}
/*!
* @brief Read Input Capture 2 value
*
* @param TMRx: where x can be 1, 2, 3 and 15 to select the TMR peripheral
*
* @retval Capture Compare 2 Register value
*
* @note TMR2 it's not for APM32F030 devices
*/
uint16_t TMR_ReadCaputer2(TMR_T* TMRx)
{
return TMRx->CC2;
}
/*!
* @brief Read Input Capture 3 value
*
* @param TMRx: where x can be 1, 2, 3 to select the TMR peripheral
*
* @retval Capture Compare 3 Register value
*
* @note TMR2 it's not for APM32F030 devices
*/
uint16_t TMR_ReadCaputer3(TMR_T* TMRx)
{
return TMRx->CC3;
}
/*!
* @brief Read Input Capture 4 value
*
* @param TMRx: where x can be 1, 2, 3 to select the TMR peripheral
*
* @retval Capture Compare 4 Register value
*
* @note TMR2 it's not for APM32F030 devices
*/
uint16_t TMR_ReadCaputer4(TMR_T* TMRx)
{
return TMRx->CC4;
}
/*!
* @brief Sets the TMRx Input Capture 1 prescaler
*
* @param TMRx: where x can be 1, 2, 3, 14, 15, 16 and 17 to select the TMR peripheral
*
* @param prescaler: specifies the Input Capture 1 prescaler new value
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_SetIC1Prescal(TMR_T* TMRx, TMR_IC_PRESCALER_T prescaler)
{
TMRx->CCM1_INPUT_B.IC1PSC = BIT_RESET;
TMRx->CCM1_INPUT_B.IC1PSC = prescaler;
}
/*!
* @brief Sets the TMRx Input Capture 2 prescaler
*
* @param TMRx: where x can be 1, 2, 3 and 15 to select the TMR peripheral
*
* @param prescaler: specifies the Input Capture 2 prescaler new value
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_SetIC2Prescal(TMR_T* TMRx, TMR_IC_PRESCALER_T prescaler)
{
TMRx->CCM1_INPUT_B.IC2PSC = BIT_RESET;
TMRx->CCM1_INPUT_B.IC2PSC = prescaler;
}
/*!
* @brief Sets the TMRx Input Capture 3 prescaler
*
* @param TMRx: where x can be 1, 2, 3 to select the TMR peripheral
*
* @param prescaler: specifies the Input Capture 3 prescaler new value
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_SetIC3Prescal(TMR_T* TMRx, TMR_IC_PRESCALER_T prescaler)
{
TMRx->CCM2_INPUT_B.IC3PSC = BIT_RESET;
TMRx->CCM2_INPUT_B.IC3PSC = prescaler;
}
/*!
* @brief Sets the TMRx Input Capture 4 prescaler
*
* @param TMRx: where x can be 1, 2, 3 to select the TMR peripheral
*
* @param prescaler: specifies the Input Capture 4 prescaler new value
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_SetIC4Prescal(TMR_T* TMRx, TMR_IC_PRESCALER_T prescaler)
{
TMRx->CCM2_INPUT_B.IC4PSC = BIT_RESET;
TMRx->CCM2_INPUT_B.IC4PSC = prescaler;
}
/*!
* @brief Enable intterupts
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @param interrupt: specifies the TMR interrupts sources
* The parameter can be any combination of following values:
* @arg TMR_INT_UPDATE: TMR update Interrupt source
* @arg TMR_INT_CH1: TMR Capture Compare 1 Interrupt source
* @arg TMR_INT_CH2: TMR Capture Compare 2 Interrupt source
* @arg TMR_INT_CH3: TMR Capture Compare 3 Interrupt source
* @arg TMR_INT_CH4: TMR Capture Compare 4 Interrupt source
* @arg TMR_INT_CCU: TMR Commutation Interrupt source
* @arg TMR_INT_TRG: TMR Trigger Interrupt source
* @arg TMR_INT_BRK: TMR Break Interrupt source
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_EnableInterrupt(TMR_T* TMRx, uint16_t interrupt)
{
TMRx->DIEN |= interrupt;
}
/*!
* @brief Disable intterupts
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @param interrupt: specifies the TMR interrupts sources
* The parameter can be any combination of following values:
* @arg TMR_INT_UPDATE: TMR update Interrupt source
* @arg TMR_INT_CH1: TMR Capture Compare 1 Interrupt source
* @arg TMR_INT_CH2: TMR Capture Compare 2 Interrupt source
* @arg TMR_INT_CH3: TMR Capture Compare 3 Interrupt source
* @arg TMR_INT_CH4: TMR Capture Compare 4 Interrupt source
* @arg TMR_INT_CCU: TMR Commutation Interrupt source
* @arg TMR_INT_TRG: TMR Trigger Interrupt source
* @arg TMR_INT_BRK: TMR Break Interrupt source
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_DisableInterrupt(TMR_T* TMRx, uint16_t interrupt)
{
TMRx->DIEN &= ~interrupt;
}
/*!
* @brief Configures the TMRx event to be generate by software
*
* @param TMRx: where x can be 1��2��3, 14, 15, 16 and 17 to select the TMR peripheral
*
* @param event: specifies the TMR generate event
* The parameter can be any combination of following values:
* @arg TMR_EVENT_UPDATE: TMR update Interrupt source
* @arg TMR_EVENT_CH1: TMR Capture Compare 1 Interrupt source
* @arg TMR_EVENT_CH2: TMR Capture Compare 2 Interrupt source
* @arg TMR_EVENT_CH3: TMR Capture Compare 3 Interrupt source
* @arg TMR_EVENT_CH4: TMR Capture Compare 4 Interrupt source
* @arg TMR_EVENT_CCU: TMR Commutation Interrupt source
* @arg TMR_EVENT_TRG: TMR Trigger Interrupt source
* @arg TMR_EVENT_BRK: TMR Break Interrupt source
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
* TMR6 and TMR7 only TMR_EVENT_UPDATE
* TMR_EVENT_CCU and TMR_EVENT_BRK are used only with TMR1
*/
void TMR_GenerateEvent(TMR_T* TMRx, uint16_t event)
{
TMRx->CEG |= event;
}
/*!
* @brief Check whether the flag is set or reset
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*
* @param flag: specifies the TMR flag
* The parameter can be one of following values:
* @arg TMR_FLAG_UPDATA: TMR update Flag
* @arg TMR_FLAG_CH1: TMR Capture Compare 1 flag
* @arg TMR_FLAG_CH2: TMR Capture Compare 2 flag
* @arg TMR_FLAG_CH3: TMR Capture Compare 3 flag
* @arg TMR_FLAG_CH4: TMR Capture Compare 4 flag
* @arg TMR_FLAG_CCU: TMR Commutation flag
* @arg TMR_FLAG_TRG: TMR Trigger flag
* @arg TMR_FLAG_BRK: TMR Break flag
* @arg TMR_FLAG_CH1OC: TMR Capture Compare 1 overcapture flag
* @arg TMR_FLAG_CH2OC: TMR Capture Compare 2 overcapture flag
* @arg TMR_FLAG_CH3OC: TMR Capture Compare 3 overcapture flag
* @arg TMR_FLAG_CH4OC: TMR Capture Compare 4 overcapture flag
*
* @retval The new state of the flag is SET or RESET
*
* @note TMR15 can have only TMR_FLAG_UPDATA, TMR_FLAG_CH1, TMR_FLAG_CH2 and TMR_FLAG_TRG
* TMR14, TMR16 and TMR17 can have TMR_FLAG_UPDATA and TMR_FLAG_CH1
* TMR6, TMR7 only TMR_FLAG_UPDATA
* TMR_FLAG_BRK is used only with TMR1 and TMR15.
* TMR_FLAG_CCU is used only with TMR1, TMR15, TMR16 and TMR17
*/
uint16_t TMR_ReadStatusFlag(TMR_T* TMRx, TMR_FLAG_T flag)
{
if ((TMRx->STS & flag) != RESET)
{
return SET;
}
else
{
return RESET;
}
}
/*!
* @brief Clears the TMR's pending flags
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*
* @param flag: specifies the TMR flag
* The parameter can be any combination of following values:
* @arg TMR_FLAG_UPDATA: TMR update Flag
* @arg TMR_FLAG_CH1: TMR Capture Compare 1 flag
* @arg TMR_FLAG_CH2: TMR Capture Compare 2 flag
* @arg TMR_FLAG_CH3: TMR Capture Compare 3 flag
* @arg TMR_FLAG_CH4: TMR Capture Compare 4 flag
* @arg TMR_FLAG_CCU: TMR Commutation flag
* @arg TMR_FLAG_TRG: TMR Trigger flag
* @arg TMR_FLAG_BRK: TMR Break flag
* @arg TMR_FLAG_CH1OC: TMR Capture Compare 1 overcapture flag
* @arg TMR_FLAG_CH2OC: TMR Capture Compare 2 overcapture flag
* @arg TMR_FLAG_CH3OC: TMR Capture Compare 3 overcapture flag
* @arg TMR_FLAG_CH4OC: TMR Capture Compare 4 overcapture flag
*
* @retval None
*/
void TMR_ClearStatusFlag(TMR_T* TMRx, uint16_t flag)
{
TMRx->STS = ~flag;
}
/*!
* @brief Check whether the TMR Interrupt flag is set or reset
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*
* @param flag: specifies the TMR interrupts flag
* The parameter can be one of following values:
* @arg TMR_INT_FLAG_UPDATE: TMR update Interrupt flag
* @arg TMR_INT_FLAG_CH1: TMR Capture Compare 1 Interrupt flag
* @arg TMR_INT_FLAG_CH2: TMR Capture Compare 2 Interrupt flag
* @arg TMR_INT_FLAG_CH3: TMR Capture Compare 3 Interrupt flag
* @arg TMR_INT_FLAG_CH4: TMR Capture Compare 4 Interrupt flag
* @arg TMR_INT_FLAG_CCU: TMR Commutation Interrupt flag
* @arg TMR_INT_FLAG_TRG: TMR Trigger Interrupt flag
* @arg TMR_INT_FLAG_BRK: TMR Break Interrupt flag
*
* @retval The new state of the INT flag is SET or RESET
*
* @note TMR15 can have only TMR_INT_FLAG_UPDATE, TMR_INT_FLAG_CH1, TMR_INT_FLAG_CH2 and TMR_INT_FLAG_TRG
* TMR14, TMR16 and TMR17 can have TMR_INT_FLAG_UPDATE and TMR_INT_FLAG_CH1
* TMR6, TMR7 only TMR_INT_FLAG_UPDATE
* TMR_INT_FLAG_BRK is used only with TMR1 and TMR15.
* TMR_INT_FLAG_CCU is used only with TMR1, TMR15, TMR16 and TMR17
*/
uint16_t TMR_ReadIntFlag(TMR_T* TMRx, TMR_INT_FLAG_T flag)
{
if (((TMRx->STS & flag) != RESET) && ((TMRx->DIEN & flag) != RESET))
{
return SET;
}
else
{
return RESET;
}
}
/*!
* @brief Clears the TMR's interrupt pending bits
*
* @param TMRx: x can be can be 1, 2, 3, 6, 7, 14, 15, 16 and 17 to select Timer
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*
* @param flag: specifies the TMR interrupts flag
* The parameter can be any combination of following values:
* @arg TMR_INT_FLAG_UPDATE: TMR update Interrupt flag
* @arg TMR_INT_FLAG_CH1: TMR Capture Compare 1 Interrupt flag
* @arg TMR_INT_FLAG_CH2: TMR Capture Compare 2 Interrupt flag
* @arg TMR_INT_FLAG_CH3: TMR Capture Compare 3 Interrupt flag
* @arg TMR_INT_FLAG_CH4: TMR Capture Compare 4 Interrupt flag
* @arg TMR_INT_FLAG_CCU: TMR Commutation Interrupt flag
* @arg TMR_INT_FLAG_TRG: TMR Trigger Interrupt flag
* @arg TMR_INT_FLAG_BRK: TMR Break Interrupt flag
*
* @retval None
*/
void TMR_ClearIntFlag(TMR_T* TMRx, uint16_t flag)
{
TMRx->STS = ~flag;
}
/*!
* @brief Configures the TMRx's DMA interface.
*
* @param TMRx: where x can be 1, 2, 3, 15, 16 and 17 to select the TMR peripheral
*
* @param address: DMA Base address
*
* @param lenght: DMA Burst length
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ConfigDMA(TMR_T* TMRx, TMR_DMA_BASE_ADDERSS_T address, TMR_DMA_BURST_LENGHT_T lenght)
{
TMRx->DCTRL = (uint32_t)address | (uint32_t)lenght;
}
/*!
* @brief Enable TMRx Requests
*
* @param TMRx: where x can be 1, 2, 3, 6, 7, 15, 16 and 17 to select the TMR peripheral
*
* @param souces: specifies the TMR DMA souces
* The parameter can be any combination of following values:
* @arg TMR_DMA_UPDATE: TMR update DMA souces
* @arg TMR_DMA_CH1: TMR Capture Compare 1 DMA souces
* @arg TMR_DMA_CH2: TMR Capture Compare 2 DMA souces
* @arg TMR_DMA_CH3: TMR Capture Compare 3 DMA souces
* @arg TMR_DMA_CH4: TMR Capture Compare 4 DMA souces
* @arg TMR_DMA_CCU: TMR Commutation DMA souces
* @arg TMR_DMA_TRG: TMR Trigger DMA souces
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_EnableDMASoure(TMR_T* TMRx, uint16_t souces)
{
TMRx->DIEN |= souces;
}
/*!
* @brief Disable TMRx Requests
*
* @param TMRx: where x can be 1, 2, 3, 6, 7, 15, 16 and 17 to select the TMR peripheral
*
* @param souces: specifies the TMR DMA souces
* The parameter can be any combination of following values:
* @arg TMR_DMA_UPDATE: TMR update DMA souces
* @arg TMR_DMA_CH1: TMR Capture Compare 1 DMA souces
* @arg TMR_DMA_CH2: TMR Capture Compare 2 DMA souces
* @arg TMR_DMA_CH3: TMR Capture Compare 3 DMA souces
* @arg TMR_DMA_CH4: TMR Capture Compare 4 DMA souces
* @arg TMR_DMA_CCU: TMR Commutation DMA souces
* @arg TMR_DMA_TRG: TMR Trigger DMA souces
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_DisableDMASoure(TMR_T* TMRx, uint16_t souces)
{
TMRx->DIEN &= ~souces;
}
/*!
* @brief Enable Capture Compare DMA source
*
* @param TMRx: where x can be 1, 2, 3, 15, 16 and 17 to select the TMR peripheral
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_EnableCCDMA(TMR_T* TMRx)
{
TMRx->CTRL2_B.CCDSEL = ENABLE;
}
/*!
* @brief Disable Capture Compare DMA source
*
* @param TMRx: where x can be 1, 2, 3, 15, 16 and 17 to select the TMR peripheral
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_DisableCCDMA(TMR_T* TMRx)
{
TMRx->CTRL2_B.CCDSEL = DISABLE;
}
/*!
* @brief Configures the TMRx internal Clock
*
* @param TMRx: where x can be 1, 2, 3, and 15 select the TMR peripheral
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ConfigInternalClock(TMR_T* TMRx)
{
TMRx->SMCTRL_B.SMFSEL = DISABLE;
}
/*!
* @brief Configures the TMRx Internal Trigger as External Clock
*
* @param TMRx: where x can be 1, 2, 3, and 15 select the TMR peripheral
*
* @param input: specifies the TMR trigger souces
* The parameter can be one of following values:
* @arg TMR_TS_ITR0: TMR Internal Trigger 0
* @arg TMR_TS_ITR1: TMR Internal Trigger 1
* @arg TMR_TS_ITR2: TMR Internal Trigger 2
* @arg TMR_TS_ITR3: TMR Internal Trigger 3
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ConfigITRxExternalClock(TMR_T* TMRx, TMR_INPUT_TRIGGER_SOURCE_T input)
{
TMR_SelectInputTrigger(TMRx, input);
TMRx->SMCTRL_B.SMFSEL = 0x07;
}
/*!
* @brief Configures the TMRx Trigger as External Clock
*
* @param TMRx: where x can be 1, 2, 3, and 15 select the TMR peripheral
*
* @param input: specifies the TMR trigger souces
* The parameter can be one of following values:
* @arg TMR_TS_TI1F_ED: TI1 Edge Detector
* @arg TMR_TS_TI1FP1: Filtered Timer Input 1
* @arg TMR_TS_TI2FP2: Filtered Timer Input 2
*
* @param ICpolarity: specifies the TMR IC polarity
* The parameter can be one of following values:
* @arg TMR_IC_POLARITY_RISING: TMR IC polarity rising
* @arg TMR_IC_POLARITY_FALLING: TMR IC polarity falling
*
* @param ICfilter:specifies the filter value.This parameter must be a value between 0x00 and 0x0F.
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ConfigTIxExternalClock(TMR_T* TMRx, TMR_INPUT_TRIGGER_SOURCE_T input,
TMR_IC_POLARITY_T ICpolarity, uint16_t ICfilter)
{
if (input == TMR_TS_TI2FP2)
{
TI2Config(TMRx, ICpolarity, TMR_IC_SELECTION_DIRECT_TI, ICfilter);
}
else
{
TI1Config(TMRx, ICpolarity, TMR_IC_SELECTION_DIRECT_TI, ICfilter);
}
TMR_SelectInputTrigger(TMRx, input);
TMRx->SMCTRL_B.SMFSEL = 0x07;
}
/*!
* @brief Configures the External clock Mode1
*
* @param TMRx: where x can be 1, 2, 3 select the TMR peripheral
*
* @param prescaler: The external Trigger Prescaler.
*
* @param polarity: The external Trigger Polarity.
*
* @param filter: External Trigger Filter.
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ConfigExternalClockMode1(TMR_T* TMRx, TMR_EXTTRG_PRESCALER_T prescaler,
TMR_EXTTRG_POLARITY_T polarity, uint16_t filter)
{
TMR_ConfigExternalTrigger(TMRx, prescaler, polarity, filter);
TMRx->SMCTRL_B.SMFSEL = BIT_RESET;
TMRx->SMCTRL_B.SMFSEL = 0x07;
TMRx->SMCTRL_B.TRGSEL = 0x07;
}
/*!
* @brief Configures the External clock Mode2
*
* @param TMRx: where x can be 1, 2, 3 select the TMR peripheral
*
* @param prescaler: The external Trigger Prescaler
*
* @param polarity: The external Trigger Polarity
*
* @param filter: External Trigger Filter
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ConfigExternalClockMode2(TMR_T* TMRx, TMR_EXTTRG_PRESCALER_T prescaler,
TMR_EXTTRG_POLARITY_T polarity, uint16_t filter)
{
TMR_ConfigExternalTrigger(TMRx, prescaler, polarity, filter);
TMRx->SMCTRL_B.ECEN = ENABLE;
}
/*!
* @brief Selects the Input Trigger source
*
* @param TMRx: where x can be 1, 2, 3 and 15 select the TMR peripheral
*
* @param input: specifies the TMR trigger souces
* The parameter can be one of following values:
* @arg TMR_TS_ITR0: TMR Internal Trigger 0
* @arg TMR_TS_ITR1: TMR Internal Trigger 1
* @arg TMR_TS_ITR2: TMR Internal Trigger 2
* @arg TMR_TS_ITR3: TMR Internal Trigger 3
* @arg TMR_TS_TI1F_ED: TI1 Edge Detector
* @arg TMR_TS_TI1FP1: Filtered Timer Input 1
* @arg TMR_TS_TI2FP2: Filtered Timer Input 2
* @arg TMR_TS_ETRF: External Trigger input
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_SelectInputTrigger(TMR_T* TMRx, TMR_INPUT_TRIGGER_SOURCE_T input)
{
TMRx->SMCTRL_B.TRGSEL = BIT_RESET;
TMRx->SMCTRL_B.TRGSEL = input;
}
/*!
* @brief Selects the Trigger Output Mode.
*
* @param TMRx: where x can be 1, 2, 3, 6, 7 and 15 select the TMR peripheral
*
* @param source: specifies the TMR trigger souces
* The parameter can be one of following values:
* For all TMR:
* @arg TMR_TRGOSOURCE_RESET
* @arg TMR_TRGOSOURCE_ENABLE
* @arg TMR_TRGOSOURCE_UPDATE
For all TMR except TMR6 and TMR7
* @arg TMR_TRGOSOURCE_OC1,
* @arg TMR_TRGOSOURCE_OC1REF
* @arg TMR_TRGOSOURCE_OC2REF
* @arg TMR_TRGOSOURCE_OC3REF
* @arg TMR_TRGOSOURCE_OC4REF
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
* TMR7 it's only for APM32F072 and APM32F091 devices
*/
void TMR_SelectOutputTrigger(TMR_T* TMRx, TMR_TRGOSOURCE_T source)
{
TMRx->CTRL2_B.MMSEL = source;
}
/*!
* @brief Selects the Slave Mode.
*
* @param TMRx: where x can be 1, 2, 3 and 15 select the TMR peripheral
*
* @param mode: TMR_SLAVEMODE_T
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_SelectSlaveMode(TMR_T* TMRx, TMR_SLAVEMODE_T mode)
{
TMRx->SMCTRL_B.SMFSEL = mode;
}
/*!
* @brief Enable the Master Slave Mode
*
* @param TMRx: where x can be 1, 2, 3 and 15 select the TMR peripheral
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_EnableMasterSlaveMode(TMR_T* TMRx)
{
TMRx->SMCTRL_B.MSMEN = ENABLE ;
}
/*!
* @brief Disable the Master Slave Mode
*
* @param TMRx: where x can be 1, 2, 3 and 15 select the TMR peripheral
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_DisableMasterSlaveMode(TMR_T* TMRx)
{
TMRx->SMCTRL_B.MSMEN = DISABLE ;
}
/*!
* @brief Configures the TMRx External Trigger (ETR)
*
* @param TMRx: where x can be 1, 2, 3 select the TMR peripheral
*
* @param prescaler: The external Trigger Prescaler
*
* @param polarity: The external Trigger Polarity
*
* @param filter: External Trigger Filter
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ConfigExternalTrigger(TMR_T* TMRx, TMR_EXTTRG_PRESCALER_T prescaler,
TMR_EXTTRG_POLARITY_T polarity, uint16_t filter)
{
TMRx->SMCTRL &= 0x00FF;
TMRx->SMCTRL_B.ETPCFG = prescaler;
TMRx->SMCTRL_B.ETPOL = polarity;
TMRx->SMCTRL_B.ETFCFG = filter;
}
/*!
* @brief Configures the Encoder Interface
*
* @param TMRx: where x can be 1, 2, 3 select the TMR peripheral
*
* @param encodeMode: specifies the Encoder Mode
*
* @param IC1Polarity: specifies the IC1 Polarity
*
* @param IC2Polarity: specifies the IC2 Polarity
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ConfigEncodeInterface(TMR_T* TMRx, TMR_ENCODER_MODE_T encodeMode, TMR_IC_POLARITY_T IC1Polarity,
TMR_IC_POLARITY_T IC2Polarity)
{
/** Set the encoder Mode */
TMRx->SMCTRL_B.SMFSEL = BIT_RESET;
TMRx->SMCTRL_B.SMFSEL = encodeMode;
/** Select the Capture Compare 1 and the Capture Compare 2 as input */
TMRx->CCM1_INPUT_B.CC1SEL = BIT_RESET ;
TMRx->CCM1_INPUT_B.CC2SEL = BIT_RESET ;
TMRx->CCM1_INPUT_B.CC1SEL = BIT_SET ;
TMRx->CCM1_INPUT_B.CC2SEL = BIT_SET ;
/** Set the TI1 and the TI2 Polarities */
TMRx->CCEN &= ~(TMR_IC_POLARITY_BOTHEDGE) & ~(TMR_IC_POLARITY_BOTHEDGE << 4);
TMRx->CCEN |= (IC1Polarity | IC2Polarity << 4);
}
/*!
* @brief Enables Hall sensor interface.
*
* @param TMRx: where x can be 1, 2, 3 select the TMR peripheral
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_EnableHallSensor(TMR_T* TMRx)
{
TMRx->CTRL2_B.TI1SEL = ENABLE;
}
/*!
* @brief Disable Hall sensor interface.
*
* @param TMRx: where x can be 1, 2, 3 select the TMR peripheral
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_DisableHallSensor(TMR_T* TMRx)
{
TMRx->CTRL2_B.TI1SEL = DISABLE;
}
/*!
* @brief Configures the TMR14 Remapping input Capabilities.
*
* @param TMRx: where x can only for 14 select the TMR peripheral
*
* @param remap: specifies the TMR input reampping source
* The parameter can be one of following values:
* @arg TMR_REMAP_GPIO
* @arg TMR_REMAP_RTC_CLK
* @arg TMR_REMAP_HSEDiv32
* @arg TMR_REMAP_MCO
*
* @retval None
*
* @note TMR2 it's not for APM32F030 devices
*/
void TMR_ConfigRemap(TMR_T* TMRx, TMR_REMAP_T remap)
{
TMRx->OPT_B.RMPSEL = remap;
}
/**@} end of group TMR_Functions*/
/**@} end of group TMR_Driver */
/**@} end of group APM32F0xx_StdPeriphDriver*/
|