summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/RISC-V_RV64_PolarFire_SoftConsole/polarfire_hal/platform/drivers/mss/mss_mmuart/mss_uart.h
blob: b2ff63d0690e26d618da48c1651a3ee0eac44cbd (plain)
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
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
/*******************************************************************************
 * Copyright 2019-2020 Microchip FPGA Embedded Systems Solutions.
 *
 * SPDX-License-Identifier: MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 *
 * 
 * PolarFire SoC Microprocessor Subsystem MMUART bare metal software driver
 * public API.
 *
 */
/*=========================================================================*//**
  @mainpage PolarFire SoC MSS UART Bare Metal Driver.
  
  ==============================================================================
  Introduction
  ==============================================================================
  The PolarFire SoC Microprocessor subsystem (MSS) includes five multi-mode UART
  (MMUART) peripherals for serial communication. This driver provides a set of
  functions for controlling the MSS MMUARTs as part of a bare metal system
  where no operating system is available. These drivers can be adapted for use
  as part of an operating system, but the implementation of the adaptation layer
  between this driver and the operating system's driver model is outside the
  scope of this driver.
  Note: MSS UART is synonymous with MSS MMUART in this document.
  
  ==============================================================================
  Hardware Flow Dependencies
  ==============================================================================
  The configuration of all features of the MSS MMUART peripherals is covered by
  this driver with the exception of the PolarFire SoC IOMUX configuration.
  PolarFire SoC allows multiple non-concurrent uses of some external pins 
  through IOMUX configuration. This feature allows optimization of external pin 
  usage by assigning external pins for use by either the microprocessor
  subsystem or the FPGA fabric. The MSS MMUART serial signals are routed through
  IOMUXs to the PolarFire SoC device external pins. The MSS MMUART serial 
  signals may also be routed through IOMUXs to the PolarFire SoC FPGA fabric. 
  For more information on IOMUX, refer to the I/O Configuration section of the
  PolarFire SoC Microprocessor Subsystem (MSS) User's Guide.

  The IOMUXs are configured using the PolarFire SoC MSS configurator tool. You
  must ensure that the MSS MMUART peripherals are enabled and configured in the
  PolarFire SoC MSS configurator if you wish to use them. For more information 
  on IOMUXs, refer to the IOMUX section of the PolarFire SoC microprocessor
  Subsystem (MSS) User's Guide.

  On PolarFire SoC an AXI switch forms a bus matrix interconnect among multiple 
  masters and multiple slaves. Five RISC-V CPUs connect to the Master ports 
  M10 to M14 of the AXI switch. By default, all the APB peripherals are 
  accessible on AXI-Slave 5 of the AXI switch via the AXI to AHB and AHB to APB
  bridges (referred as main APB bus). However, to support logical separation in 
  the Asymmetric Multi-Processing (AMP) mode of operation, the APB peripherals 
  can alternatively be accessed on the AXI-Slave 6 via the AXI to AHB and AHB to 
  APB bridges (referred as the AMP APB bus).
  
  Application must make sure that the desired MMUART instance is appropriately 
  configured on one of the APB bus described above by configuring the PolarFire 
  SoC system registers (SYSREG) as per the application need and that the 
  appropriate data structures are provided to this driver as parameter to the 
  functions provided by this driver.

  The base address and register addresses are defined in this driver as 
  constants. The interrupt number assignment for the MSS MMUART peripherals are 
  defined as constants in the MPFS HAL. You must ensure that the latest MPFS HAL 
  is included in the project settings of the SoftConsole tool chain and that it 
  is generated into your project.
  
  ==============================================================================
  Theory of Operation
  ==============================================================================
  The MSS MMUART driver functions are grouped into the following categories:
    - Initialization and configuration functions
    - Polled transmit and receive functions
    - Interrupt driven transmit and receive functions
    
  --------------------------------
  Initialization and Configuration
  --------------------------------
  The MSS MMUART supports the following four broad modes of operation:
    - UART or USART mode
    - LIN mode
    - IrDA mode
    - Smartcard or ISO 7816 mode
    
  The MSS MMUART driver provides the MSS_UART_init(), MSS_UART_lin_init(),
  MSS_UART_irda_init() and MSS_UART_smartcard_init() functions to initialize the
  MSS MMUARTs for operation in one of these modes. One of these initialization
  functions must be called before any other MSS MMUART driver functions can be
  called. The MSS MMUART operating modes are mutually exclusive; therefore only
  one of the initialization functions must be called. The first parameter of the
  initialization functions is a pointer to one of ten global data structures
  used to store state information for each MSS MMUART. A pointer to these data
  structures is also used as the first parameter to many of the driver functions
  to identify which MSS MMUART will be used by the called function. The names of
  these data structures are:
    - g_mss_uart0_lo
    - g_mss_uart1_lo
    - g_mss_uart2_lo
    - g_mss_uart3_lo
    - g_mss_uart4_lo
    - g_mss_uart0_hi
    - g_mss_uart1_hi
    - g_mss_uart2_hi
    - g_mss_uart3_hi
    - g_mss_uart4_hi
    
  Therefore, any call to an MSS MMUART function should be of the form 
  MSS_UART_function_name( &g_mss_uart0_lo, ... ) or
  MSS_UART_function_name( &g_mss_uart1_hi, ... ).
  
  UART or USART Mode
  For the UART or USART modes of operation, the MSS MMUART driver is initialized
  through a call to the MSS_UART_init() function. This function takes the UART's
  configuration as its parameters. The MSS_UART_init() function must be called
  before any other MSS MMUART driver functions can be called.
  The MSS_UART_init() function configures the baud rate based on the input baud
  rate parameter and if possible uses a fractional baud rate for greater
  precision. This function disables the LIN, IrDA and SmartCard modes.
  
  LIN mode
  For the LIN mode of operation, the MSS MMUART driver is initialized through a
  call to the MSS_UART_lin_init() function. This function takes the LIN node's
  configuration as its parameters. The MSS_UART_lin_init() function must be
  called before any other MSS MMUART driver functions can be called. The
  MSS_UART_lin_init() function configures the baud rate based on the input baud
  rate parameter and if possible uses a fractional baud rate for greater
  precision. This function disables the IrDA and SmartCard modes.
  The driver also provides the following LIN mode configuration functions:
    - MSS_UART_set_break()
    - MSS_UART_clear_break()
    - MSS_UART_set_pidpei_handler()
    - MSS_UART_set_linbreak_handler()
    - MSS_UART_set_linsync_handler()
    
  Note: These LIN mode configuration functions can only be called after the
  MSS_UART_lin_init() function is called.
  
  IrDA mode
  For the IrDA mode of operation, the driver is initialized through a call to
  the MSS_UART_irda_init() function. This function takes the IrDA node's
  configuration as its parameters. The MSS_UART_irda_init() function must be
  called before any other MSS MMUART driver functions can be called. The
  MSS_UART_irda_init() function configures the baud rate based on the input baud
  rate parameter and if possible uses a fractional baud rate for greater
  precision. This function disables the LIN and SmartCard modes.
  
  Smartcard or ISO 7816 mode
  For the Smartcard or ISO 7816 mode of operation, the driver is initialized
  through a call to the MSS_UART_smartcard_init() function. This function takes
  the smartcard configuration as its parameters. The MSS_UART_smartcard_init()
  function must be called before any other MSS MMUART driver functions can be
  called. The MSS_UART_smartcard_init() function configures the baud rate based
  on the input baud rate parameter and if possible uses a fractional baud rate
  for greater precision. This function disables the LIN and IrDA modes.
  The driver also provides the following Smartcard mode configuration functions:
    - MSS_UART_enable_halfduplex()
    - MSS_UART_disable_halfduplex()
    - MSS_UART_set_nack_handler()
    
  Note: These Smartcard mode configuration functions can only be called after
  the MSS_UART_smartcard_init() function is called.
  
  Common Configuration Functions
  The driver also provides the configuration functions that can be used with all
  MSS MMUART operating modes. These common configuration functions are as
  follows:
    - MSS_UART_set_rx_endian()
    - MSS_UART_set_tx_endian()
    - MSS_UART_enable_afclear()
    - MSS_UART_disable_afclear()
    - MSS_UART_enable_rx_timeout()
    - MSS_UART_disable_rx_timeout()
    - MSS_UART_enable_tx_time_guard()
    - MSS_UART_disable_tx_time_guard()
    - MSS_UART_set_address()
    - MSS_UART_set_ready_mode()
    - MSS_UART_set_usart_mode()
    - MSS_UART_set_filter_length()
    - MSS_UART_enable_afm()
    - MSS_UART_disable_afm()
    
  Note: These configuration functions can only be called after one of the
        MSS_UART_init(), MSS_UART_lin_init(), MSS_UART_irda_init() or
        MSS_UART_smartcard_init() functions is called.
  
  --------------------------------------  
  Polled Transmit and Receive Operations
  --------------------------------------
  The driver can be used to transmit and receive data once initialized. 
  Data is transmitted using the MSS_UART_polled_tx() function. This function is
  blocking, meaning that it will only return once the data passed to the
  function has been sent to the MSS MMUART hardware transmitter. Data received
  by the MSS MMUART hardware receiver can be read by the MSS_UART_get_rx()
  function.
  The MSS_UART_polled_tx_string() function is provided to transmit a NUL ('\0')
  terminated string in polled mode. This function is blocking, meaning that it
  will only return once the data passed to the function has been sent to the MSS
  MMUART hardware transmitter.
  The MSS_UART_fill_tx_fifo() function fills the MSS MMUART hardware transmit
  FIFO with data from a buffer passed as a parameter and returns the number of
  bytes transferred to the FIFO. If the transmit FIFO is not empty when the
  MSS_UART_fill_tx_fifo() function is called it returns immediately without
  transferring any data to the FIFO.
  
  ---------------------------
  Interrupt Driven Operations
  ---------------------------
  The driver can also transmit or receive data under interrupt control, freeing
  your application to perform other tasks until an interrupt occurs indicating
  that the driver's attention is required.
  
  Local or PLIC interrupt:
  PolarFire SoC architecture provides flexibility in terms of how the MMUART 
  interrupt is seen by the PolarFire SoC Core Complex. Each of the 5 MMUART
  instance interrupt line is connected to the PolarFire SoC Core Complex PLIC. 
  The MMUART0 instance interrupt line is also available as local interrupt on
  E51 processor. The MMUART1 instance interrupt onwards are available as local
  interrupt on the U54_1 processor onwards. e.g. MMUART2 interrupt is available 
  as local interrupt on U54_2. 

  Interrupt Handlers
  The MSS MMUART driver supports all types of interrupt triggered by the MSS
  MMUART. The driver's internal top level interrupt handler identifies the
  source of the MSS MMUART interrupt and calls the corresponding lower level
  handler function that you previously registered with the driver through calls
  to the MSS_UART_set_rx_handler(), MSS_UART_set_tx_handler(),
  MSS_UART_set_rxstatus_handler(), and MSS_UART_set_modemstatus_handler()
  functions. You are responsible for creating these lower level interrupt
  handlers as part of your application program and registering them with the
  driver.
  Note: The PolarFire SoC HAL defines the interrupt handler functions for all 
        5 MMUART instances(with weak linkage) and assigns them as the interrupt 
        service routines (ISR) for the MSS MMUART interrupt inputs to the 
        PolarFire SoC Core Complex PLIC or the Local interrupts on each of the 
        respective CPUs. The MSS MMUART driver provides the implementation 
        functions all these ISRs from which it calls its own internal top level,
        interrupt handler function.
        
  The MSS_UART_enable_irq() and MSS_UART_disable_irq() functions are used to
  enable or disable the received line status, received data available/character
  time-out, transmit holding register empty and modem status interrupts at the
  MSS MMUART level. The MSS_UART_enable_irq() function also enables the MSS
  MMUART instance interrupt at the PolarFire SoC Core Complex level.
  
  Note that the MSS_UART_enable_irq() and MSS_UART_disable_irq() and all the
  calls to set the handler functions assume that the MMUART interrupt is
  connected to the PolarFire SoC Core Complex PLIC. If you want the MMUART
  interrupt to appear as a local interrupt to the corresponding HART then you
  must explicitly call the MSS_UART_enable_local_irq() function. This function
  will disable the PLIC interrupt (if it was previously enable) and enable the
  local interrupt on the HART on which this function is being executed.

  Transmitting Data
  Interrupt-driven transmit is initiated by a call to MSS_UART_irq_tx(),
  specifying the block of data to transmit. Your application is then free to
  perform other tasks and inquire later whether transmit has completed by
  calling the MSS_UART_tx_complete() function. The MSS_UART_irq_tx() function
  enables the UART's transmit holding register empty (THRE) interrupt and then,
  when the interrupt goes active, the driver's default THRE interrupt handler
  transfers the data block to the UART until the entire block is transmitted.
  Note: You can use the MSS_UART_set_tx_handler() function to assign an
        alternative handler to the THRE interrupt. In this case, you must not
        use the MSS_UART_irq_tx() function to initiate the transmit, as this
        will re-assign the driver's default THRE interrupt handler to the THRE
        interrupt. Instead, your alternative THRE interrupt handler must include
        a call to the MSS_UART_fill_tx_fifo() function to transfer the data to
        the UART.
  
  Receiving Data
  Interrupt-driven receive is performed by first calling
  MSS_UART_set_rx_handler() to register a receive handler function that will be
  called by the driver whenever receive data is available. You must provide this
  receive handler function which must include a call to the MSS_UART_get_rx()
  function to actually read the received data.
  
  -----------
  UART Status
  -----------
  The function MSS_UART_get_rx_status() is used to read the receiver error
  status. This function returns the overrun, parity, framing, break, and FIFO
  error status of the receiver.
  The function MSS_UART_get_tx_status() is used to read the transmitter status.
  This function returns the transmit empty (TEMT) and transmit holding register
  empty (THRE) status of the transmitter.
  The function MSS_UART_get_modem_status() is used to read the modem status
  flags. This function returns the current value of the modem status register.
  
  --------
  Loopback
  --------
  The MSS_UART_set_loopback() function can be used to locally loopback the Tx
  and Rx lines of a UART. This is not to be confused with the loopback of UART0
  to UART1, which can be achieved through the microprocessor subsystem's system
  registers.
  
 *//*=========================================================================*/
#ifndef __MSS_UART_H_
#define __MSS_UART_H_ 1

#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif


/***************************************************************************//**
  Baud rates
  ==========
  The following definitions are used to specify standard baud rates as a
  parameter to the MSS_UART_init() function.
  
  | Constant             | Description      |
  |----------------------|------------------|
  | MSS_UART_110_BAUD    |    110 baud rate |
  | MSS_UART_300_BAUD    |    300 baud rate |
  | MSS_UART_600_BAUD    |    600 baud rate |
  | MSS_UART_1200_BAUD   |   1200 baud rate |
  | MSS_UART_2400_BAUD   |   2400 baud rate |
  | MSS_UART_4800_BAUD   |   4800 baud rate |
  | MSS_UART_9600_BAUD   |   9600 baud rate |
  | MSS_UART_19200_BAUD  |  19200 baud rate |
  | MSS_UART_38400_BAUD  |  38400 baud rate |
  | MSS_UART_57600_BAUD  |  57600 baud rate |
  | MSS_UART_115200_BAUD | 115200 baud rate |
  | MSS_UART_230400_BAUD | 230400 baud rate |
  | MSS_UART_460800_BAUD | 460800 baud rate |
  | MSS_UART_921600_BAUD | 921600 baud rate |
  
 */
#define MSS_UART_110_BAUD       110U
#define MSS_UART_300_BAUD       300U
#define MSS_UART_600_BAUD       600U
#define MSS_UART_1200_BAUD      1200U
#define MSS_UART_2400_BAUD      2400U
#define MSS_UART_4800_BAUD      4800U
#define MSS_UART_9600_BAUD      9600U
#define MSS_UART_19200_BAUD     19200U
#define MSS_UART_38400_BAUD     38400U
#define MSS_UART_57600_BAUD     57600U
#define MSS_UART_115200_BAUD    115200U
#define MSS_UART_230400_BAUD    230400U
#define MSS_UART_460800_BAUD    460800U
#define MSS_UART_921600_BAUD    921600U

/***************************************************************************//**
  Data Bits Length
  ================
  The following defines are used to build the value of the MSS_UART_init()
  function line_config parameter.
  
  | Constant             | Description                |
  |----------------------|----------------------------|
  | MSS_UART_DATA_5_BITS | 5 bits of data transmitted |
  | MSS_UART_DATA_6_BITS | 6 bits of data transmitted |
  | MSS_UART_DATA_7_BITS | 7 bits of data transmitted |
  | MSS_UART_DATA_8_BITS | 8 bits of data transmitted |
  
 */
#define MSS_UART_DATA_5_BITS     ((uint8_t) 0x00)
#define MSS_UART_DATA_6_BITS     ((uint8_t) 0x01)
#define MSS_UART_DATA_7_BITS     ((uint8_t) 0x02)
#define MSS_UART_DATA_8_BITS     ((uint8_t) 0x03)

/***************************************************************************//**
  Parity
  ======
  The following defines are used to build the value of the MSS_UART_init()
  function line_config parameter.
  
  | Constant                | Description              |
  |-------------------------|--------------------------|
  | MSS_UART_NO_PARITY      | No parity                |
  | MSS_UART_ODD_PARITY     | Odd Parity               |
  | MSS_UART_EVEN_PARITY    | Even parity              |
  | MSS_UART_STICK_PARITY_0 | Stick parity bit to zero |
  | MSS_UART_STICK_PARITY_1 | Stick parity bit to one  |

 */
#define MSS_UART_NO_PARITY           ((uint8_t) 0x00)
#define MSS_UART_ODD_PARITY          ((uint8_t) 0x08)
#define MSS_UART_EVEN_PARITY         ((uint8_t) 0x18)
#define MSS_UART_STICK_PARITY_0      ((uint8_t) 0x38)
#define MSS_UART_STICK_PARITY_1      ((uint8_t) 0x28)

/***************************************************************************//**
  Number of Stop Bits
  ===================
  The following defines are used to build the value of the MSS_UART_init()
  function line_config parameter.
  
  | Constant                  | Description              |
  |---------------------------|--------------------------|
  | MSS_UART_ONE_STOP_BIT     | One stop bit             |
  | MSS_UART_ONEHALF_STOP_BIT | One and a half stop bits |
  | MSS_UART_TWO_STOP_BITS    | Two stop bits            |
  
 */
#define MSS_UART_ONE_STOP_BIT        ((uint8_t) 0x00)
#define MSS_UART_ONEHALF_STOP_BIT    ((uint8_t) 0x04)
#define MSS_UART_TWO_STOP_BITS       ((uint8_t) 0x04)

/***************************************************************************//**
  Receiver Error Status
  =====================
  The following defines are used to determine the UART receiver error type.
  These bit mask constants are used with the return value of the
  MSS_UART_get_rx_status() function to find out if any errors occurred while
  receiving data.
  
  
  | Constant               | Description                                |
  |------------------------|--------------------------------------------|
  | MSS_UART_NO_ERROR      | No error bit mask (0x00)                   |
  | MSS_UART_OVERUN_ERROR  | Overrun error bit mask (0x02)              |
  | MSS_UART_PARITY_ERROR  | Parity error bit mask (0x04)               |
  | MSS_UART_FRAMING_ERROR | Framing error bit mask (0x08)              |
  | MSS_UART_BREAK_ERROR   | Break error bit mask (0x10)                |
  | MSS_UART_FIFO_ERROR    | FIFO error bit mask (0x80)                 |
  | MSS_UART_INVALID_PARAM | Invalid function parameter bit mask (0xFF) |

 */
#define MSS_UART_INVALID_PARAM    ((uint8_t)0xFF)
#define MSS_UART_NO_ERROR         ((uint8_t)0x00 )
#define MSS_UART_OVERUN_ERROR     ((uint8_t)0x02)
#define MSS_UART_PARITY_ERROR     ((uint8_t)0x04)
#define MSS_UART_FRAMING_ERROR    ((uint8_t)0x08)
#define MSS_UART_BREAK_ERROR      ((uint8_t)0x10)
#define MSS_UART_FIFO_ERROR       ((uint8_t)0x80)

/***************************************************************************//**
  Transmitter Status
  ==================
  The following definitions are used to determine the UART transmitter status.
  These bit mask constants are used with the return value of the
  MSS_UART_get_tx_status() function to find out the status of the transmitter.
    
  | Constant         | Description                                        |
  |------------------|----------------------------------------------------|
  | MSS_UART_TX_BUSY | Transmitter busy (0x00)                            |
  | MSS_UART_THRE    | Transmitter holding register empty bit mask (0x20) |
  | MSS_UART_TEMT    | Transmitter empty bit mask (0x40)                  |
  
 */
#define MSS_UART_TX_BUSY          ((uint8_t) 0x00)
#define MSS_UART_THRE             ((uint8_t) 0x20)
#define MSS_UART_TEMT             ((uint8_t) 0x40)

/***************************************************************************//**
  Modem Status
  ============
  The following defines are used to determine the modem status. These bit
  mask constants are used with the return value of the
  MSS_UART_get_modem_status() function to find out the modem status of
  the UART.
  
  | Constant      | Description                                     |
  |---------------|-------------------------------------------------|
  | MSS_UART_DCTS | Delta clear to send bit mask (0x01)             |
  | MSS_UART_DDSR | Delta data set ready bit mask (0x02)            |
  | MSS_UART_TERI | Trailing edge of ring indicator bit mask (0x04) |
  | MSS_UART_DDCD | Delta data carrier detect bit mask (0x08)       |
  | MSS_UART_CTS  | Clear to send bit mask (0x10)                   |
  | MSS_UART_DSR  | Data set ready bit mask (0x20)                  |
  | MSS_UART_RI   | Ring indicator bit mask (0x40)                  |
  | MSS_UART_DCD  | Data carrier detect bit mask (0x80)             |

 */
#define MSS_UART_DCTS             ((uint8_t) 0x01)
#define MSS_UART_DDSR             ((uint8_t) 0x02)
#define MSS_UART_TERI             ((uint8_t) 0x04)
#define MSS_UART_DDCD             ((uint8_t) 0x08)
#define MSS_UART_CTS              ((uint8_t) 0x10)
#define MSS_UART_DSR              ((uint8_t) 0x20)
#define MSS_UART_RI               ((uint8_t) 0x40)
#define MSS_UART_DCD              ((uint8_t) 0x80)

/***************************************************************************//**
  This typedef specifies the irq_mask parameter for the MSS_UART_enable_irq()
  and MSS_UART_disable_irq() functions. The driver defines a set of bit masks
  that are used to build the value of the irq_mask parameter. A bitwise OR of
  these bit masks is used to enable or disable multiple MSS MMUART interrupts.
 */
typedef uint16_t mss_uart_irq_t;

/***************************************************************************//**
  MSS MMUART Interrupts
  =====================
  The following defines specify the interrupt masks to enable and disable MSS
  MMUART interrupts. They are used to build the value of the irq_mask parameter
  for the MSS_UART_enable_irq() and MSS_UART_disable_irq() functions. A bitwise
  OR of these constants is used to enable or disable multiple interrupts.
  
  
  | Constant           | Description                                                   |
  |--------------------|---------------------------------------------------------------|
  | MSS_UART_RBF_IRQ   | Receive Data Available Interrupt bit mask (0x001)             |
  | MSS_UART_TBE_IRQ   | Transmitter Holding Register Empty interrupt bit mask (0x002) |
  | MSS_UART_LS_IRQ    | Receiver Line Status interrupt bit mask (0x004)               |
  | MSS_UART_MS_IRQ    | Modem Status interrupt bit mask (0x008)                       |
  | MSS_UART_RTO_IRQ   | Receiver time-out interrupt bit mask (0x010)                  |
  | MSS_UART_NACK_IRQ  | NACK / ERR signal interrupt bit mask (0x020)                  |
  | MSS_UART_PIDPE_IRQ | PID parity error interrupt bit mask (0x040)                   |
  | MSS_UART_LINB_IRQ  | LIN break detection interrupt bit mask (0x080)                |
  | MSS_UART_LINS_IRQ  | LIN Sync detection interrupt bit mask (0x100)                 |

 */
#define MSS_UART_RBF_IRQ        0x001
#define MSS_UART_TBE_IRQ        0x002
#define MSS_UART_LS_IRQ         0x004
#define MSS_UART_MS_IRQ         0x008
#define MSS_UART_RTO_IRQ        0x010
#define MSS_UART_NACK_IRQ       0x020
#define MSS_UART_PIDPE_IRQ      0x040
#define MSS_UART_LINB_IRQ       0x080
#define MSS_UART_LINS_IRQ       0x100
#define MSS_UART_INVALID_IRQ    UINT16_MAX

/***************************************************************************//**
  This enumeration specifies the receiver FIFO trigger level. This is the number
  of bytes that must be received before the UART generates a receive data
  available interrupt. It provides the allowed values for the
  MSS_UART_set_rx_handler() function trigger_level parameter.
 */
typedef enum {
    MSS_UART_FIFO_SINGLE_BYTE    = 0x00,
    MSS_UART_FIFO_FOUR_BYTES     = 0x40,
    MSS_UART_FIFO_EIGHT_BYTES    = 0x80,
    MSS_UART_FIFO_FOURTEEN_BYTES = 0xC0,
    MSS_UART_FIFO_INVALID_TRIG_LEVEL

} mss_uart_rx_trig_level_t;

/***************************************************************************//**
  This enumeration specifies the loopback configuration of the UART. It provides
  the allowed values for the MSS_UART_set_loopback() function's loopback
  parameter. Use MSS_UART_LOCAL_LOOPBACK_ON to set up the UART to locally
  loopback its Tx and Rx lines. Use MSS_UART_REMOTE_LOOPBACK_ON to set up the
  UART in remote loopback mode.
 */
typedef enum {
    MSS_UART_LOCAL_LOOPBACK_OFF,
    MSS_UART_LOCAL_LOOPBACK_ON,
    MSS_UART_REMOTE_LOOPBACK_OFF,
    MSS_UART_REMOTE_LOOPBACK_ON,
    MSS_UART_AUTO_ECHO_OFF,
    MSS_UART_AUTO_ECHO_ON,
    MSS_UART_INVALID_LOOPBACK

} mss_uart_loopback_t;

/***************************************************************************//**
  IrDA input / output polarity.
  This enumeration specifies the RZI modem polarity for input and output signals. 
  This is passed as parameters in MSS_UART_irda_init() function.
 */
typedef enum {
    MSS_UART_ACTIVE_LOW = 0u,
    MSS_UART_ACTIVE_HIGH = 1u,
    MSS_UART_INVALID_POLARITY

} mss_uart_rzi_polarity_t;

/***************************************************************************//**
  IrDA input / output pulse width.
  This enumeration specifies the RZI modem pulse width for input and output 
  signals. This is passed as parameters in MSS_UART_irda_init() function.
 */
typedef enum {
    MSS_UART_3_BY_16 = 0u,
    MSS_UART_1_BY_4 = 1u,
    MSS_UART_INVALID_PW

} mss_uart_rzi_pulsewidth_t;

/***************************************************************************//**
  Tx / Rx endianess.
  This enumeration specifies the MSB first or LSB first for MSS UART transmitter 
  and receiver. The parameter of this type shall be passed in 
  MSS_UART_set_rx_endian()and MSS_UART_set_tx_endian() functions.
 */
typedef enum {
    MSS_UART_LITTLEEND,
    MSS_UART_BIGEND,
    MSS_UART_INVALID_ENDIAN

} mss_uart_endian_t;

/***************************************************************************//**
  Glitch filter length.
  This enumeration specifies the glitch filter length. The function 
  MSS_UART_set_filter_length() accepts the parameter of this type.
 */
typedef enum {
    MSS_UART_LEN0 = 0,
    MSS_UART_LEN1 = 1,
    MSS_UART_LEN2 = 2,
    MSS_UART_LEN3 = 3,
    MSS_UART_LEN4 = 4,
    MSS_UART_LEN5 = 5,
    MSS_UART_LEN6 = 6,
    MSS_UART_LEN7 = 7,
    MSS_UART_INVALID_FILTER_LENGTH = 8

} mss_uart_filter_length_t;

/***************************************************************************//**
  TXRDY and RXRDY mode.
  This enumeration specifies the TXRDY and RXRDY signal modes. The function 
  MSS_UART_set_ready_mode() accepts the parameter of this type.
 */
typedef enum {
    MSS_UART_READY_MODE0,
    MSS_UART_READY_MODE1,
    MSS_UART_INVALID_READY_MODE

} mss_uart_ready_mode_t;

/***************************************************************************//**
  USART mode of operation.
  This enumeration specifies the mode of operation of MSS UART when operating 
  as USART. The function MSS_UART_set_usart_mode() accepts the parameter of this 
  type.
 */
typedef enum {
    MSS_UART_ASYNC_MODE               = 0,
    MSS_UART_SYNC_SLAVE_POS_EDGE_CLK  = 1,
    MSS_UART_SYNC_SLAVE_NEG_EDGE_CLK  = 2,
    MSS_UART_SYNC_MASTER_POS_EDGE_CLK = 3,
    MSS_UART_SYNC_MASTER_NEG_EDGE_CLK = 4,
    MSS_UART_INVALID_SYNC_MODE        = 5

} mss_uart_usart_mode_t;


typedef enum {
    MSS_UART0_LO    = 0,
    MSS_UART1_LO    = 1,
    MSS_UART2_LO    = 2,
    MSS_UART3_LO    = 3,
    MSS_UART4_LO    = 4,
    MSS_UART0_HI    = 5,
    MSS_UART1_HI    = 6,
    MSS_UART2_HI    = 7,
    MSS_UART3_HI    = 8,
    MSS_UAR4_HI     = 9,

} mss_uart_num_t;

/***************************************************************************//**
  MSS UART instance type.
  This is type definition for MSS UART instance. You need to create and
  maintain a record of this type. This holds all data regarding the MSS UART
  instance
 */
typedef struct  mss_uart_instance mss_uart_instance_t;

/***************************************************************************//**
  Interrupt handler prototype.
  This typedef specifies the function prototype for MSS UART interrupt handlers.
  All interrupt handlers registered with the MSS UART driver must be of this type.
  The interrupt handlers are registered with the driver through the
  MSS_UART_set_rx_handler(), MSS_UART_set_tx_handler(),
  MSS_UART_set_rxstatus_handler(), and MSS_UART_set_modemstatus_handler()
  functions.
  The this_uart parameter is a pointer to either g_mss_uart0 or g_mss_uart1 to
  identify the MSS UART to associate with the handler function.
 */
typedef void (*mss_uart_irq_handler_t)( mss_uart_instance_t * this_uart );

/*----------------------------------------------------------------------------*/
/*----------------------------------- UART -----------------------------------*/
/*----------------------------------------------------------------------------*/

typedef struct
{
    union
    {
        volatile const uint8_t    RBR;
        volatile uint8_t    THR;
        volatile uint8_t    DLR;
        uint32_t RESERVED0;
    };

    union
    {
        volatile uint8_t  DMR;
        volatile uint8_t  IER;
        uint32_t RESERVED1;
    };

    union
    {
        volatile uint8_t  IIR;
        volatile uint8_t  FCR;
        uint32_t RESERVED2;
    };

    volatile uint8_t  LCR;
    uint8_t  RESERVED3[3];

    volatile uint8_t  MCR;
    uint8_t  RESERVED4[3];

    volatile const  uint8_t  LSR;
    uint8_t  RESERVED5[3];

    volatile const  uint8_t  MSR;
    uint8_t  RESERVED6[3];

    volatile uint8_t  SR;
    uint8_t  RESERVED7[7];

    volatile uint8_t  IEM;
    uint8_t  RESERVED8[3];

    volatile uint8_t  IIM;
    uint8_t  RESERVED9[7];

    volatile uint8_t  MM0;
    uint8_t  RESERVED10[3];

    volatile uint8_t  MM1;
    uint8_t  RESERVED11[3];

    volatile uint8_t  MM2;
    uint8_t  RESERVED12[3];

    volatile uint8_t  DFR;
    uint8_t  RESERVED13[7];

    volatile uint8_t GFR;
    uint8_t  RESERVED14[3];

    volatile uint8_t TTG;
    uint8_t  RESERVED15[3];

    volatile uint8_t RTO;
    uint8_t  RESERVED16[3];

    volatile uint8_t ADR;
    uint8_t  RESERVED17[3];

} MSS_UART_TypeDef;


/***************************************************************************//**
  mss_uart_instance.
  There is one instance of this structure for each instance of the
  microprocessor subsystem's UARTs. Instances of this structure are used to
  identify a specific UART. A pointer to an initialized instance of the
  mss_uart_instance_t structure is passed as the first parameter to
  MSS UART driver functions to identify which UART should perform the
  requested operation.
 */
struct mss_uart_instance{
    /* CMSIS related defines identifying the UART hardware. */
    MSS_UART_TypeDef *      hw_reg;     /*!< Pointer to UART registers. */
    uint32_t                baudrate;   /*!< Operating baud rate. */
    uint8_t                 lineconfig; /*!< Line configuration parameters. */
    uint8_t                 status;     /*!< Sticky line status. */
    uint16_t                padding;    /*!< Padding for alignment */

    /* transmit related info (used with interrupt driven transmit): */
    const uint8_t * tx_buffer;          /*!< Pointer to transmit buffer. */
    uint32_t        tx_buff_size;       /*!< Transmit buffer size. */
    uint32_t        tx_idx;             /*!< Index within transmit buffer of next byte to transmit.*/

    /* line status interrupt handler:*/
    mss_uart_irq_handler_t linests_handler;   /*!< Pointer to user registered line status handler. */
    /* receive interrupt handler:*/
    mss_uart_irq_handler_t rx_handler;        /*!< Pointer to user registered receiver handler. */
    /* transmit interrupt handler:*/
    mss_uart_irq_handler_t tx_handler;        /*!< Pointer to user registered transmit handler. */
    /* modem status interrupt handler:*/
    mss_uart_irq_handler_t modemsts_handler;  /*!< Pointer to user registered modem status handler. */
    /* receiver timeout interrupt handler */
    mss_uart_irq_handler_t rto_handler;       /*!< Pointer to user registered receiver timeout handler. */
    /* NACK interrupt handler */
    mss_uart_irq_handler_t nack_handler;      /*!< Pointer to user registered NACK handler. */
    /* PID parity perror interrupt handler */
    mss_uart_irq_handler_t pid_pei_handler;   /*!< Pointer to user registered PID parity error handler. */
    /* LIN break interrupt handler */
    mss_uart_irq_handler_t break_handler;     /*!< Pointer to user registered LIN break handler. */
    /* LIN sync detection interrupt handler */
    mss_uart_irq_handler_t sync_handler;      /*!< Pointer to user registered LIN sync detection handler. */
    uint8_t                local_irq_enabled;  /*!< check if local interrupt were enabled on this instance*/
    uint8_t                padding1[7];        /*!< padding for alignment */
    void* user_data;                          /*!< Pointer to user provided pointer for user specific use. */

};

/***************************************************************************//**
  This instance of mss_uart_instance_t holds all data related to the operations
  performed by the MMUART. The function MSS_UART_init() initializes this structure.
  A pointer to g_mss_uart0_lo is passed as the first parameter to MSS UART driver
  functions to indicate that MMUART0 should perform the requested operation.
 */

extern mss_uart_instance_t g_mss_uart0_lo;
extern mss_uart_instance_t g_mss_uart1_lo;
extern mss_uart_instance_t g_mss_uart2_lo;
extern mss_uart_instance_t g_mss_uart3_lo;
extern mss_uart_instance_t g_mss_uart4_lo;

extern mss_uart_instance_t g_mss_uart0_hi;
extern mss_uart_instance_t g_mss_uart1_hi;
extern mss_uart_instance_t g_mss_uart2_hi;
extern mss_uart_instance_t g_mss_uart3_hi;
extern mss_uart_instance_t g_mss_uart4_hi;


/***************************************************************************//**
  The MSS_UART_init() function initializes and configures one of the PolarFire SoC
  MSS UARTs with the configuration passed as a parameter. The configuration
  parameters are the baud_rate which is used to generate the baud value and the
  line_config which is used to specify the line configuration (bit length,
  stop bits and parity).

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

    Note that if you are using the UART on the AMP APB bus, the hardware
    configuration to connect UART on AMP APB bus must already be done by the
    application using SYSREG registers before initializing the UART instance
    structure.

  @param baud_rate
    The baud_rate parameter specifies the baud rate. It can be specified for
    common baud rates using the following defines:
    - MSS_UART_110_BAUD
    - MSS_UART_300_BAUD
    - MSS_UART_600_BAUD
    - MSS_UART_1200_BAUD
    - MSS_UART_2400_BAUD
    - MSS_UART_4800_BAUD
    - MSS_UART_9600_BAUD
    - MSS_UART_19200_BAUD
    - MSS_UART_38400_BAUD
    - MSS_UART_57600_BAUD
    - MSS_UART_115200_BAUD
    - MSS_UART_230400_BAUD
    - MSS_UART_460800_BAUD
    - MSS_UART_921600_BAUD
    
    Alternatively, any nonstandard baud rate can be specified by simply passing
    the actual required baud rate as the value for this parameter.

  @param line_config
    The line_config parameter is the line configuration specifying the bit length,
    number of stop bits and parity settings.
    
    This is a bitwise OR of one value from each of the following groups of
    allowed values:
    
    One of the following to specify the transmit/receive data bit length:
     - MSS_UART_DATA_5_BITS
     - MSS_UART_DATA_6_BITS,
     - MSS_UART_DATA_7_BITS
     - MSS_UART_DATA_8_BITS
     
    One of the following to specify the parity setting:
     - MSS_UART_NO_PARITY
     - MSS_UART_EVEN_PARITY
     - MSS_UART_ODD_PARITY
     - MSS_UART_STICK_PARITY_0
     - MSS_UART_STICK_PARITY_1
        
    One of the following to specify the number of stop bits:
     - MSS_UART_ONE_STOP_BIT
     - MSS_UART_ONEHALF_STOP_BIT
     - MSS_UART_TWO_STOP_BITS

  @return
    This function does not return a value.

  Example:
  @code
  #include "mss_uart.h"

  int main(void)
  {
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
                   
     return(0);
  }
  @endcode
 */
void
MSS_UART_init
(
    mss_uart_instance_t* this_uart,
    uint32_t baud_rate,
    uint8_t line_config
);

/***************************************************************************//**
 The MSS_UART_lin_init() function is used to initialize the MSS UART for 
 LIN mode of operation. The configuration parameters are the baud_rate which is 
 used to generate the baud value and the line_config which is used to specify 
 the line configuration (bit length, stop bits and parity).

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

    Note that if you are using the UART on the AMP APB bus, the hardware
    configuration to connect UART on AMP APB bus must already be done by the
    application using SYSREG registers before initializing the UART instance
    structure.

  @param baud_rate
    The baud_rate parameter specifies the baud rate. It can be specified for
    common baud rates using the following defines:
    - MSS_UART_110_BAUD
    - MSS_UART_300_BAUD
    - MSS_UART_600_BAUD
    - MSS_UART_1200_BAUD
    - MSS_UART_2400_BAUD
    - MSS_UART_4800_BAUD
    - MSS_UART_9600_BAUD
    - MSS_UART_19200_BAUD
    - MSS_UART_38400_BAUD
    - MSS_UART_57600_BAUD
    - MSS_UART_115200_BAUD
    - MSS_UART_230400_BAUD
    - MSS_UART_460800_BAUD
    - MSS_UART_921600_BAUD
    
    Alternatively, any nonstandard baud rate can be specified by simply passing
    the actual required baud rate as the value for this parameter.

  @param line_config
    The line_config parameter is the line configuration specifying the bit length,
    number of stop bits and parity settings.
    
    This is a bitwise OR of one value from each of the following groups of
    allowed values:
    
    One of the following to specify the transmit/receive data bit length:
     - MSS_UART_DATA_5_BITS
     - MSS_UART_DATA_6_BITS,
     - MSS_UART_DATA_7_BITS
     - MSS_UART_DATA_8_BITS
     
    One of the following to specify the parity setting:
     - MSS_UART_NO_PARITY
     - MSS_UART_EVEN_PARITY
     - MSS_UART_ODD_PARITY
     - MSS_UART_STICK_PARITY_0
     - MSS_UART_STICK_PARITY_1
        
    One of the following to specify the number of stop bits:
     - MSS_UART_ONE_STOP_BIT
     - MSS_UART_ONEHALF_STOP_BIT
     - MSS_UART_TWO_STOP_BITS

  @return
    This function does not return a value.

  Example:
  @code
  #include "mss_uart.h"

  int main(void)
  {
     MSS_UART_lin_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
                       
     return(0);
  }
  @endcode
 */
void 
MSS_UART_lin_init
(
    mss_uart_instance_t* this_uart, 
    uint32_t baud_rate,
    uint8_t line_config
);

/***************************************************************************//**
  The MSS_UART_irda_init() function is used to initialize the MSS UART instance 
  referenced by the parameter this_uart  for IrDA mode of operation. This 
  function must be called before calling any other IrDA functionality specific 
  functions.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

    Note that if you are using the UART on the AMP APB bus, the hardware
    configuration to connect UART on AMP APB bus must already be done by the
    application using SYSREG registers before initializing the UART instance
    structure.

  @param baud_rate
    The baud_rate parameter specifies the baud rate. It can be specified for
    common baud rates using the following defines:
    - MSS_UART_110_BAUD
    - MSS_UART_300_BAUD
    - MSS_UART_600_BAUD
    - MSS_UART_1200_BAUD
    - MSS_UART_2400_BAUD
    - MSS_UART_4800_BAUD
    - MSS_UART_9600_BAUD
    - MSS_UART_19200_BAUD
    - MSS_UART_38400_BAUD
    - MSS_UART_57600_BAUD
    - MSS_UART_115200_BAUD
    - MSS_UART_230400_BAUD
    - MSS_UART_460800_BAUD
    - MSS_UART_921600_BAUD
    
    Alternatively, any nonstandard baud rate can be specified by simply passing
    the actual required baud rate as the value for this parameter.

  @param line_config
    The line_config parameter is the line configuration specifying the bit
    length, number of stop bits and parity settings.
    
    This is a bitwise OR of one value from each of the following groups of
    allowed values:
    
    One of the following to specify the transmit/receive data bit length:
     - MSS_UART_DATA_5_BITS
     - MSS_UART_DATA_6_BITS,
     - MSS_UART_DATA_7_BITS
     - MSS_UART_DATA_8_BITS
     
    One of the following to specify the parity setting:
     - MSS_UART_NO_PARITY
     - MSS_UART_EVEN_PARITY
     - MSS_UART_ODD_PARITY
     - MSS_UART_STICK_PARITY_0
     - MSS_UART_STICK_PARITY_1
     
    One of the following to specify the number of stop bits:
     - MSS_UART_ONE_STOP_BIT
     - MSS_UART_ONEHALF_STOP_BIT
     - MSS_UART_TWO_STOP_BITS

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_irda_init(&g_mss_uart0_lo,
              MSS_UART_57600_BAUD,
              MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT,
              MSS_UART_ACTIVE_LOW,
              MSS_UART_ACTIVE_LOW,
              MSS_UART_3_BY_16);
  @endcode
 */
void 
MSS_UART_irda_init
(
    mss_uart_instance_t* this_uart, 
    uint32_t baud_rate,
    uint8_t line_config,
    mss_uart_rzi_polarity_t rxpol,
    mss_uart_rzi_polarity_t txpol,
    mss_uart_rzi_pulsewidth_t pw
);

/***************************************************************************//**
  The MSS_UART_smartcard_init() function is used to initialize the MSS UART 
  for ISO 7816 (smartcard) mode of operation. The configuration parameters are 
  the baud_rate which is used to generate the baud value and the line_config 
  which is used to specify the line configuration (bit length, stop bits and
  parity). This function disables all other modes of the MSS UART instance
  pointed by the parameter this_uart.
  
  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

    Note that if you are using the UART on the AMP APB bus, the hardware
    configuration to connect UART on AMP APB bus must already be done by the
    application using SYSREG registers before initializing the UART instance
    structure.

  @param baud_rate
    The baud_rate parameter specifies the baud rate. It can be specified for
    common baud rates using the following defines:
    - MSS_UART_110_BAUD
    - MSS_UART_300_BAUD
    - MSS_UART_600_BAUD
    - MSS_UART_1200_BAUD
    - MSS_UART_2400_BAUD
    - MSS_UART_4800_BAUD
    - MSS_UART_9600_BAUD
    - MSS_UART_19200_BAUD
    - MSS_UART_38400_BAUD
    - MSS_UART_57600_BAUD
    - MSS_UART_115200_BAUD
    - MSS_UART_230400_BAUD
    - MSS_UART_460800_BAUD
    - MSS_UART_921600_BAUD
    
    Alternatively, any nonstandard baud rate can be specified by simply passing
    the actual required baud rate as the value for this parameter.

  @param line_config
    The line_config parameter is the line configuration specifying the bit
    length, number of stop bits and parity settings.
    
    This is a bitwise OR of one value from each of the following groups of
    allowed values:
    
    One of the following to specify the transmit/receive data bit length:
     - MSS_UART_DATA_5_BITS
     - MSS_UART_DATA_6_BITS,
     - MSS_UART_DATA_7_BITS
     - MSS_UART_DATA_8_BITS
        
    One of the following to specify the parity setting:
     - MSS_UART_NO_PARITY
     - MSS_UART_EVEN_PARITY
     - MSS_UART_ODD_PARITY
     - MSS_UART_STICK_PARITY_0
     - MSS_UART_STICK_PARITY_1
        
    One of the following to specify the number of stop bits:
     - MSS_UART_ONE_STOP_BIT
     - MSS_UART_ONEHALF_STOP_BIT
     - MSS_UART_TWO_STOP_BITS

  @return
    This function does not return a value.

  Example:
  @code
    #include "mss_uart.h"

      int main(void)
      {
         MSS_UART_smartcard_init(&g_mss_uart0_lo,
              MSS_UART_57600_BAUD,
              MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
                                 
         return(0);
      }
  @endcode
 */
void 
MSS_UART_smartcard_init
(
    mss_uart_instance_t* this_uart, 
    uint32_t baud_rate,
    uint8_t line_config
);

/***************************************************************************//**
  The function MSS_UART_polled_tx() is used to transmit data. It transfers the
  contents of the transmitter data buffer, passed as a function parameter, into
  the UART's hardware transmitter FIFO. It returns when the full content of the
  transmit data buffer has been transferred to the UART's transmit FIFO. It is
  safe to release or reuse the memory used as the transmitter data buffer once
  this function returns.

  Note:     This function reads the UART's line status register (LSR) to poll
  for the active state of the transmitter holding register empty (THRE) bit
  before transferring data from the data buffer to the transmitter FIFO. It
  transfers data to the transmitter FIFO in blocks of 16 bytes or less and
  allows the FIFO to empty before transferring the next block of data.

  Note:     The actual transmission over the serial connection will still be
  in progress when this function returns. Use the MSS_UART_get_tx_status()
  function if you need to know when the transmitter is empty.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param pbuff
    The pbuff parameter is a pointer to a buffer containing the data to
    be transmitted.

  @param tx_size
    The tx_size parameter specifies the size, in bytes, of the data to
    be transmitted.

  @return
    This function does not return a value.

  Example:
  @code
  #include "mss_uart.h"

  int main(void)
  {
     uint8_t message[12] = "Hello World";

     MSS_UART_init(&g_mss_uart0_lo,
              MSS_UART_57600_BAUD,
              SS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

     MSS_UART_polled_tx(&g_mss_uart0_lo, message, sizeof(message));
     
     return(0);
  }
  @endcode
 */
void
MSS_UART_polled_tx
(
    mss_uart_instance_t * this_uart,
    const uint8_t * pbuff,
    uint32_t tx_size
);

/***************************************************************************//**
  The function MSS_UART_polled_tx_string() is used to transmit a NUL ('\0')
  terminated string. It transfers the text string, from the buffer starting at
  the address pointed to by p_sz_string into the UART's hardware transmitter
  FIFO. It returns when the complete string has been transferred to the UART's
  transmit FIFO. It is safe to release or reuse the memory used as the string
  buffer once this function returns.

  Note:     This function reads the UART's line status register (LSR) to poll
  for the active state of the transmitter holding register empty (THRE) bit
  before transferring data from the data buffer to the transmitter FIFO. It
  transfers data to the transmitter FIFO in blocks of 16 bytes or less and
  allows the FIFO to empty before transferring the next block of data.

  Note:     The actual transmission over the serial connection will still be
  in progress when this function returns. Use the MSS_UART_get_tx_status()
  function if you need to know when the transmitter is empty.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param p_sz_string
    The p_sz_string parameter is a pointer to a buffer containing the NUL ('\0')
    terminated string to be transmitted.

  @return
    This function does not return a value.

  Example:
  @code
  #include "mss_uart.h"

  int main(void)
  {
     uint8_t message[12] = "Hello World";

     MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
                   
     MSS_UART_polled_tx_string(&g_mss_uart0_lo, message);
     
     return(0);
  }
  @endcode

 */
void
MSS_UART_polled_tx_string
(
    mss_uart_instance_t * this_uart,
    const uint8_t * p_sz_string
);

/***************************************************************************//**
  The function MSS_UART_irq_tx() is used to initiate an interrupt-driven
  transmit. It returns immediately after making a note of the transmit buffer
  location and enabling transmit interrupts both at the UART and the PolarFire
  SoC Core Complex PLIC level. This function takes a pointer via the pbuff
  parameter to a memory buffer containing the data to transmit. The memory
  buffer specified through this pointer must remain allocated and contain the
  data to transmit until the transmit completion has been detected through calls
  to function MSS_UART_tx_complete(). The actual transmission over the serial 
  connection is still in progress until calls to the MSS_UART_tx_complete() 
  function indicate transmit completion.

  Note:     The MSS_UART_irq_tx() function enables both the transmit holding
  register empty (THRE) interrupt in the UART and the MSS UART instance
  interrupt in the PolarFire SoC Core Complex PLIC as part of its implementation.

  Note:     The MSS_UART_irq_tx() function assigns an internal default transmit
  interrupt handler function to the UART's THRE interrupt. This interrupt
  handler overrides any custom interrupt handler that you may have previously
  registered using the MSS_UART_set_tx_handler() function.

  Note:     The MSS_UART_irq_tx() function's default transmit interrupt
  handler disables the UART's THRE interrupt when all of the data has
  been transferred to the UART's transmit FIFO.


  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param pbuff
    The pbuff parameter is a pointer to a buffer containing the data
    to be transmitted.

  @param tx_size
    The tx_size parameter specifies the size, in bytes, of the data
    to be transmitted.

  @return
    This function does not return a value.

  Example:
  @code
  #include "mss_uart.h"

  int main(void)
  {
     uint8_t tx_buff[10] = "abcdefghi";
     
     MSS_UART_init(&g_mss_uart0_lo,
              MSS_UART_57600_BAUD,
              MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
                   
     MSS_UART_irq_tx(&g_mss_uart0_lo, tx_buff, sizeof(tx_buff));
     
     while(0 == MSS_UART_tx_complete(&g_mss_uart0_lo))
     {
         ;
     }
     return(0);
  }
  @endcode
 */
void
MSS_UART_irq_tx
(
    mss_uart_instance_t * this_uart,
    const uint8_t * pbuff,
    uint32_t tx_size
);

/***************************************************************************//**
  The MSS_UART_tx_complete() function is used to find out if the
  interrupt-driven transmit previously initiated through a call to
  MSS_UART_irq_tx() is complete. This is typically used to find out when it is
  safe to reuse or release the memory buffer holding transmit data.

  Note:     The transfer of all of the data from the memory buffer to the UART's
  transmit FIFO and the actual transmission over the serial connection are both
  complete when a call to the MSS_UART_tx_complete() function indicates transmit
  completion.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @return
    This function return a non-zero value if transmit has completed, otherwise
    it returns zero.

  Example:
    See the MSS_UART_irq_tx() function for an example that uses the
    MSS_UART_tx_complete() function.

 */
int8_t
MSS_UART_tx_complete
(
   mss_uart_instance_t * this_uart
);

/***************************************************************************//**
  The MSS_UART_get_rx() function reads the content of the UART receiver's FIFO
  and stores it in the receive buffer that is passed via the rx_buff function
  parameter. It copies either the full contents of the FIFO into the receive
  buffer, or just enough data from the FIFO to fill the receive buffer,
  dependent upon the size of the receive buffer passed by the buff_size
  parameter. The MSS_UART_get_rx() function returns the number of bytes copied
  into the receive buffer .This function is non-blocking and will return 0
  immediately if no data has been received.

  Note:     The MSS_UART_get_rx() function reads and accumulates the receiver
  status of the MSS UART instance before reading each byte from the receiver's
  data register/FIFO. This allows the driver to maintain a sticky record of any
  receiver errors that occur as the UART receives each data byte; receiver
  errors would otherwise be lost after each read from the receiver's data
  register. A call to the MSS_UART_get_rx_status() function returns any receiver
  errors accumulated during the execution of the MSS_UART_get_rx() function.

  Note:     If you need to read the error status for each byte received, set
  the buff_size to 1 and read the receive line error status for each byte
  using the MSS_UART_get_rx_status() function.

  The MSS_UART_get_rx() function can be used in polled mode, where it is called
  at regular intervals to find out if any data has been received, or in
  interrupt driven-mode, where it is called as part of a receive handler that is
  called by the driver as a result of data being received.

  Note:     In interrupt driven mode you should call the MSS_UART_get_rx()
  function as part of the receive handler function that you register with
  the MSS UART driver through a call to MSS_UART_set_rx_handler().

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param rx_buff
    The rx_buff parameter is a pointer to a buffer where the received
    data is copied.

  @param buff_size
    The buff_size parameter specifies the size of the receive buffer in bytes.

  @return
    This function returns the number of bytes that were copied into the
    rx_buff buffer. It returns 0 if no data has been received.

  Polled mode example:
  @code
   int main( void )
   {
      uint8_t rx_buff[RX_BUFF_SIZE];
      uint32_t rx_idx  = 0;

      MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
                    
      while(1)
      {
          rx_size = MSS_UART_get_rx(&g_mss_uart0_lo, rx_buff, sizeof(rx_buff));
          if(rx_size > 0)
          {
              process_rx_data(rx_buff, rx_size);
          }
          task_a();
          task_b();
      }
      return 0;
   }
  @endcode

  Interrupt driven example:
  @code
   int main( void )
   {
      MSS_UART_init(&g_mss_uart1,
              MSS_UART_57600_BAUD,
              MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
                    
      MSS_UART_set_rx_handler(&g_mss_uart1,
                              uart1_rx_handler,
                              MSS_UART_FIFO_SINGLE_BYTE);
      
      while(1)
      {
          task_a();
          task_b();
      }
      return 0;
   }

   void uart1_rx_handler(mss_uart_instance_t * this_uart)
   {
      uint8_t rx_buff[RX_BUFF_SIZE];
      uint32_t rx_idx  = 0;
      rx_size = MSS_UART_get_rx(this_uart, rx_buff, sizeof(rx_buff));
      process_rx_data(rx_buff, rx_size);
   }
  @endcode
 */
size_t
MSS_UART_get_rx
(
   mss_uart_instance_t * this_uart,
   uint8_t * rx_buff,
   size_t buff_size
);

/***************************************************************************//**
  The MSS_UART_set_rx_handler() function is used to register a receive handler
  function that is called by the driver when a UART receive data available (RDA)
  interrupt occurs. You must create and register the receive handler function
  to suit your application and it must include a call to the MSS_UART_get_rx()
  function to actually read the received data.

  Note:     The MSS_UART_set_rx_handler() function enables both the RDA
  interrupt in the MSS UART instance. It also enables the corresponding 
  MSS UART instance interrupt in the PolarFire SoC Core Complex PLIC  as part
  of its implementation.

  Note:     You can disable the RDA interrupt when required by calling the 
  MSS_UART_disable_irq() function. This is your choice and is dependent upon
  your application.
  
  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param handler
    The handler parameter is a pointer to a receive interrupt handler function
    provided by your application that will be called as a result of a UART RDA
    interrupt. This handler function must be of type mss_uart_irq_handler_t.

  @param trigger_level
    The trigger_level parameter is the receive FIFO trigger level. This
    specifies the number of bytes that must be received before the UART
    triggers an RDA interrupt.

  @return
    This function does not return a value.

  Example:
  @code
  #include "mss_uart.h"

  #define RX_BUFF_SIZE    64

  uint8_t g_rx_buff[RX_BUFF_SIZE];

  void uart0_rx_handler(mss_uart_instance_t * this_uart)
  {
      MSS_UART_get_rx(this_uart, &g_rx_buff[g_rx_idx], sizeof(g_rx_buff));
  }

  int main(void)
  {
      MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
                    
      MSS_UART_set_rx_handler(&g_mss_uart0_lo,
                              uart0_rx_handler,
                              MSS_UART_FIFO_SINGLE_BYTE);
                              
      while(1)
      {
         ;
      }
      return(0);
   }
  @endcode
 */
void
MSS_UART_set_rx_handler
(
    mss_uart_instance_t *       this_uart,
    mss_uart_irq_handler_t          handler,
    mss_uart_rx_trig_level_t    trigger_level
);

/***************************************************************************//**
  The MSS_UART_set_loopback() function is used to locally loop-back the Tx and
  Rx lines of a UART. This is not to be confused with the loop-back of UART0
  to UART1, which can be achieved through the microprocessor subsystem's
  system registers.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param loopback
    The loopback parameter indicates whether or not the UART's transmit and 
    receive lines should be looped back. Allowed values are as follows:
      - MSS_UART_LOCAL_LOOPBACK_ON
      - MSS_UART_LOCAL_LOOPBACK_OFF 
      - MSS_UART_REMOTE_LOOPBACK_ON
      - MSS_UART_REMOTE_LOOPBACK_OFF 
      - MSS_UART_AUTO_ECHO_ON
      - MSS_UART_AUTO_ECHO_OFF
      
  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

      MSS_UART_set_loopback(&g_mss_uart0_lo, MSS_UART_LOCAL_LOOPBACK_OFF);
  @endcode
 */
void
MSS_UART_set_loopback
(
    mss_uart_instance_t *   this_uart,
    mss_uart_loopback_t     loopback
);

/***************************************************************************//**
  The MSS_UART_enable_irq() function enables the MSS UART interrupts specified
  by the irq_mask parameter. The irq_mask parameter identifies the MSS UART
  interrupts by bit position, as defined in the interrupt enable register (IER)
  of MSS UART. The MSS UART interrupts and their identifying irq_mask bit
  positions are as follows:
  When an irq_mask bit position is set to 1, this function enables the
  corresponding MSS UART interrupt in the IER register. When an irq_mask bit
  position is set to 0, the state of the corresponding interrupt remains 
  unchanged in the IER register.
  
  Note: The MSS_UART_enable_irq() function also enables the MSS UART instance
        interrupt in the PolarFire SoC Core Complex PLIC.
        
  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param irq_mask
    The irq_mask parameter is used to select which of the MSS UART's interrupts
    you want to enable. The allowed value for the irq_mask parameter is one of
    the following constants or a bitwise OR of more than one:
      - MSS_UART_RBF_IRQ        (bit mask = 0x001)
      - MSS_UART_TBE_IRQ        (bit mask = 0x002)
      - MSS_UART_LS_IRQ         (bit mask = 0x004)
      - MSS_UART_MS_IRQ         (bit mask = 0x008)
      - MSS_UART_RTO_IRQ        (bit mask = 0x010)
      - MSS_UART_NACK_IRQ       (bit mask = 0x020)
      - MSS_UART_PIDPE_IRQ      (bit mask = 0x040)
      - MSS_UART_LINB_IRQ       (bit mask = 0x080)
      - MSS_UART_LINS_IRQ       (bit mask = 0x100)
      
  @return
     This function does not return a value.

  Example:
  @code
      #include "mss_uart.h"

      int main(void)
      {
         uint8_t tx_buff[10] = "abcdefghi";

         MSS_UART_init(&g_mss_uart0_lo,
                  MSS_UART_57600_BAUD,
                  MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

         MSS_UART_enable_irq(&g_mss_uart0_lo,(MSS_UART_RBF_IRQ | MSS_UART_TBE_IRQ));

         return(0);
      }

  @endcode
 */
void
MSS_UART_enable_irq
(
    mss_uart_instance_t * this_uart,
    mss_uart_irq_t irq_mask
);

/***************************************************************************//**
  The MSS_UART_disable_irq() function disables the MSS UART interrupts specified
  by the irq_mask parameter. The irq_mask parameter identifies the MSS UART
  interrupts by bit position, as defined in the interrupt enable register (IER)
  of MSS UART. The MSS UART interrupts and their identifying bit positions are
  as follows:
  When an irq_mask bit position is set to 1, this function disables the
  corresponding MSS UART interrupt in the IER register. When an irq_mask bit
  position is set to 0, the state of the corresponding interrupt remains 
  unchanged in the IER register.
  
  Note: If you disable all four of the UART's interrupts, the
        MSS_UART_disable_irq() function also disables the MSS UART instance
        interrupt in the PolarFire SoC Core Complex PLIC.
        
  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param irq_mask
    The irq_mask parameter is used to select which of the MSS UART's interrupts
    you want to disable. The allowed value for the irq_mask parameter is one of
    the following constants or a bitwise OR of more than one:
      - MSS_UART_RBF_IRQ    (bit mask = 0x001)
      - MSS_UART_TBE_IRQ    (bit mask = 0x002)
      - MSS_UART_LS_IRQ     (bit mask = 0x004)
      - MSS_UART_MS_IRQ     (bit mask = 0x008)
      - MSS_UART_RTO_IRQ    (bit mask = 0x010)
      - MSS_UART_NACK_IRQ   (bit mask = 0x020)
      - MSS_UART_PIDPE_IRQ  (bit mask = 0x040)
      - MSS_UART_LINB_IRQ   (bit mask = 0x080)
      - MSS_UART_LINS_IRQ   (bit mask = 0x100)
      
  @return
     This function does not return a value.

  Example:
  @code
      #include "mss_uart.h"

  int main(void)
  {
     uint8_t tx_buff[10] = "abcdefghi";

     MSS_UART_init(&g_mss_uart0_lo,
              MSS_UART_57600_BAUD,
              MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

     MSS_UART_disable_irq(&g_mss_uart0_lo,(MSS_UART_RBF_IRQ | MSS_UART_TBE_IRQ));

     return(0);
  }

  @endcode
 */
void
MSS_UART_disable_irq
(
    mss_uart_instance_t * this_uart,
    mss_uart_irq_t irq_mask
);

/***************************************************************************//**
  The MSS_UART_set_pidpei_handler() function is used assign a custom interrupt 
  handler for the PIDPEI (PID parity error interrupt) when the MSS UART is 
  operating in LIN mode.

  Note:     The MSS_UART_set_pidpei_handler() function enables both the PIDPEI 
  interrupt in the MSS UART instance. It also enables the corresponding 
  MSS UART instance interrupt in the PolarFire SoC Core Complex PLIC as part of
  its implementation.

  Note:     You can disable the PIDPEI interrupt when required by calling the 
  MSS_UART_disable_irq() function. This is your choice and is dependent upon
  your application.
  
  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param handler
    The handler parameter is the pointer to the custom handler function. 
    This parameter is of type mss_uart_irq_handler_t.

  @return
    This function does not return a value.

  Example:
  @code
  #include "mss_uart.h"

  int main(void)
  {
     uint8_t tx_buff[10] = "abcdefghi";

     MSS_UART_init(&g_mss_uart0_lo,
            MSS_UART_57600_BAUD,
            MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

     MSS_UART_set_pidpei_handler(&g_mss_uart0_lo, my_pidpei_handler);

     return(0);
  }
  @endcode
 */
void
MSS_UART_set_pidpei_handler
(
    mss_uart_instance_t * this_uart,
    mss_uart_irq_handler_t handler
);

/***************************************************************************//**
  The MSS_UART_set_linbreak_handler () function is used assign a custom 
  interrupt handler for the LIN Break detection interrupt  when the MSS UART 
  is operating in LIN mode.

  Note:     The MSS_UART_set_linbreak_handler() function enables both the LIN
  BREAK interrupt in the MSS UART instance. It also enables the corresponding 
  MSS UART instance interrupt in the PolarFire SoC Core Complex PLIC as part of
  its implementation.

  Note:     You can disable the LIN BREAK interrupt when required by calling the 
  MSS_UART_disable_irq() function. This is your choice and is dependent upon
  your application.
  
  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param handler
    The handler parameter is the pointer to the custom handler function. 
    This parameter is of type mss_uart_irq_handler_t.

  @return
    This function does not return a value.
  Example:
  @code
  #include "mss_uart.h"

  int main(void)
  {
     uint8_t tx_buff[10] = "abcdefghi";

     MSS_UART_init(&g_mss_uart0_lo,
              MSS_UART_57600_BAUD,
              MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

     MSS_UART_set_linbreak_handler(&g_mss_uart0_lo, my_break_handler);

     return(0);
  }

  @endcode
 */
void
MSS_UART_set_linbreak_handler
(
    mss_uart_instance_t * this_uart,
    mss_uart_irq_handler_t handler
);

/***************************************************************************//**
  The MSS_UART_set_linsync_handler() function is used assign a custom interrupt 
  handler for the LIN Sync character detection interrupt  when the MSS UART is 
  operating in LIN mode.

  Note:     The MSS_UART_set_linsync_handler() function enables both the LIN
  SYNC interrupt in the MSS UART instance. It also enables the corresponding 
  MSS UART instance interrupt in the PolarFire SoC Core Complex PLIC as part of
  its implementation.

  Note:     You can disable the LIN SYNC interrupt when required by calling the 
  MSS_UART_disable_irq() function. This is your choice and is dependent upon
  your application.
  
  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param handler
    The handler parameter is the pointer to the custom handler function. 
    This parameter is of type mss_uart_irq_handler_t.

  @return
    This function does not return a value.
    
  Example:
  @code
  #include "mss_uart.h"

  int main(void)
  {
     uint8_t tx_buff[10] = "abcdefghi";

     MSS_UART_init(&g_mss_uart0_lo,
              MSS_UART_57600_BAUD,
              MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

     MSS_UART_set_linsync_handler(&g_mss_uart0_lo, my_linsync_handler);

     return(0);
  }

  @endcode
 */
void
MSS_UART_set_linsync_handler
(
    mss_uart_instance_t * this_uart,
    mss_uart_irq_handler_t handler
);

/***************************************************************************//**
  The MSS_UART_set_nack_handler() function is used assign a custom interrupt 
  handler for the NACK character detection interrupt  when the MSS UART 
  is operating in Smartcard mode.

  Note:     The MSS_UART_set_nack_handler() function enables both the NAK
  interrupt in the MSS UART instance. It also enables the corresponding 
  MSS UART instance interrupt in the PolarFire SoC Core Complex PLIC as part of
  its implementation.

  Note:     You can disable the NAK interrupt when required by calling the 
  MSS_UART_disable_irq() function. This is your choice and is dependent upon
  your application.
  
  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param handler
    The handler parameter is the pointer to the custom handler function. 
    This parameter is of type mss_uart_irq_handler_t.

  @return
    This function does not return a value.
    
  Example:
  @code
  #include "mss_uart.h"

  int main(void)
  {
     uint8_t tx_buff[10] = "abcdefghi";

     MSS_UART_init(&g_mss_uart0_lo,
              MSS_UART_57600_BAUD,
              MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

     MSS_UART_set_nack_handler(&g_mss_uart0_lo, my_nack_handler);

     return(0);
  }

  @endcode
 */
void
MSS_UART_set_nack_handler
(
    mss_uart_instance_t * this_uart,
    mss_uart_irq_handler_t handler
);

/***************************************************************************//**
  The MSS_UART_set_rx_timeout_handler() function is used assign a custom 
  interrupt handler for the receiver timeout interrupt  when the MSS UART is 
  operating in mode. It finds application in IrDA mode of operation.
  
  Note:     The MSS_UART_set_rx_timeout_handler() function enables both the 
  time-out interrupt in the MSS UART instance. It also enables the corresponding 
  MSS UART instance interrupt in the PolarFire SoC Core Complex PLIC as part of
  its implementation.

  Note:     You can disable the RX time-out interrupt when required by calling 
  the MSS_UART_disable_irq() function. This is your choice and is dependent upon
  your application.
  
  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param handler
    The handler parameter is the pointer to the custom handler function. 
    This parameter is of type mss_uart_irq_handler_t.

  @return
    This function does not return a value.
    
  Example:
  @code
    #include "mss_uart.h"

  int main(void)
  {
     uint8_t tx_buff[10] = "abcdefghi";

     MSS_UART_init(&g_mss_uart0_lo,
              MSS_UART_57600_BAUD,
              MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

     MSS_UART_set_rx_timeout_handler(&g_mss_uart0_lo, my_rxtimeout_handler);

     return(0);
  }

  @endcode
 */
void
MSS_UART_set_rx_timeout_handler
(
    mss_uart_instance_t * this_uart,
    mss_uart_irq_handler_t handler
);

/***************************************************************************//**
  The MSS_UART_set_rxstatus_handler() function is used to register a receiver
  status handler function that is called by the driver when a UART receiver
  line status (RLS) interrupt occurs. You must create and register the handler
  function to suit your application.

  Note:     The MSS_UART_set_rxstatus_handler() function enables both the RLS
  interrupt in the MSS UART instance. It also enables the corresponding MSS UART
  instance interrupt in the PolarFire SoC Core Complex PLIC as part of its
  implementation.

  Note:     You can disable the RLS interrupt when required by calling the
  MSS_UART_disable_irq() function. This is your choice and is dependent upon
  your application.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param handler
     The handler parameter is a pointer to a receiver line status interrupt
     handler function provided by your application that will be called as a
     result of a UART RLS interrupt. This handler function must be of type
     mss_uart_irq_handler_t.

  @return
     This function does not return a value.

  Example:
  @code
  #include "mss_uart.h"

  void uart_rxsts_handler(mss_uart_instance_t * this_uart)
  {
    uint8_t status;
    status = MSS_UART_get_rx_status(this_uart);
    if(status & MSS_UART_OVERUN_ERROR)
    {
        discard_rx_data();
    }
  }

  int main(void)
  {
    MSS_UART_init( &g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
                                       
    MSS_UART_set_rxstatus_handler(&g_mss_uart0_lo, uart_rxsts_handler);

    while(1)
    {
        ;
    }
    return(0);
  }
  @endcode
 */
void
MSS_UART_set_rxstatus_handler
(
    mss_uart_instance_t * this_uart,
    mss_uart_irq_handler_t handler
);

/***************************************************************************//**
  The MSS_UART_set_tx_handler() function is used to register a transmit handler
  function that is called by the driver when a UART transmit holding register
  empty (THRE) interrupt occurs. You must create and register the transmit
  handler function to suit your application. You can use the
  MSS_UART_fill_tx_fifo() function in your transmit handler function to
  write data to the transmitter.

  Note:     The MSS_UART_set_tx_handler() function enables both the THRE
  interrupt in the MSS UART instance. It also enables the corresponding MSS UART
  instance interrupt in the PolarFire SoC Core Complex PLIC as part of its
  implementation.


  Note:     You can disable the THRE interrupt when required by calling the
  MSS_UART_disable_irq() function. This is your choice and is dependent upon
  your application.

  Note:     The MSS_UART_irq_tx() function does not use the transmit handler
  function that you register with the MSS_UART_set_tx_handler() function.
  It uses its own internal THRE interrupt handler function that overrides
  any custom interrupt handler that you register using the
  MSS_UART_set_tx_handler() function.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

   @param handler
     The handler parameter is a pointer to a transmit interrupt handler
     function provided by your application that will be called as a result
     of a UART THRE interrupt. This handler function must be of type
     mss_uart_irq_handler_t.

   @return
     This function does not return a value.

   Example:
   @code
    #include "mss_uart.h"

    uint8_t * g_tx_buffer;
    size_t g_tx_size = 0;

    void uart_tx_handler(mss_uart_instance_t * this_uart)
    {
        size_t size_in_fifo;
        size_in_fifo = MSS_UART_fill_tx_fifo(this_uart,
                                             (const uint8_t *)g_tx_buffer,
                                             g_tx_size);
                                             
        if(size_in_fifo  ==  g_tx_size)
        {
            g_tx_size = 0;
            MSS_UART_disable_irq(this_uart, MSS_UART_TBE_IRQ);
        }
        else
        {
            g_tx_buffer = &g_tx_buffer[size_in_fifo];
            g_tx_size = g_tx_size - size_in_fifo;
        }
    }

    int main(void)
    {
        uint8_t message[12] = "Hello world";

        MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

        g_tx_buffer = message;
        g_tx_size = sizeof(message);

        MSS_UART_set_tx_handler(&g_mss_uart0_lo, uart_tx_handler);

        while(1)
        {
            ;
        }
        return(0);
    }
   @endcode
 */
void
MSS_UART_set_tx_handler
(
    mss_uart_instance_t * this_uart,
    mss_uart_irq_handler_t handler
);

/***************************************************************************//**
  The MSS_UART_set_modemstatus_handler() function is used to register a modem
  status handler function that is called by the driver when a UART modem status
  (MS) interrupt occurs. You must create and register the handler function to
  suit your application.

  Note:     The MSS_UART_set_modemstatus_handler() function enables both the MS
  interrupt in the MSS UART instance. It also enables the corresponding MSS UART
  instance interrupt in the PolarFire SoC Core Complex PLIC as part of its
  implementation.

  Note:     You can disable the MS interrupt when required by calling the
  MSS_UART_disable_irq() function. This is your choice and is dependent
  upon your application.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

   @param handler
     The handler parameter is a pointer to a modem status interrupt handler
     function provided by your application that will be called as a result
     of a UART MS interrupt. This handler function must be of type
     mss_uart_irq_handler_t.

   @return
     This function does not return a value.

   Example:
   @code
   #include "mss_uart.h"

   void uart_modem_handler(mss_uart_instance_t * this_uart)
   {
     uint8_t status;
     status = MSS_UART_get_modem_status(this_uart);
     if(status & MSS_UART_CTS)
     {
        uart_cts_handler();
     }
   }

   int main(void)
   {
      MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

      MSS_UART_set_modemstatus_handler(&g_mss_uart0_lo, uart_modem_handler);

      while(1)
      {
        ;
      }
      return(0);
   }
   @endcode
 */

void
MSS_UART_set_modemstatus_handler
(
    mss_uart_instance_t * this_uart,
    mss_uart_irq_handler_t handler
);

/***************************************************************************//**
  The MSS_UART_fill_tx_fifo() function fills the UART's hardware transmitter
  FIFO with the data found in the transmitter buffer that is passed via the
  tx_buffer function parameter. If the transmitter FIFO is not empty when
  the function is called, the function returns immediately without transferring
  any data to the FIFO; otherwise, the function transfers data from the
  transmitter buffer to the FIFO until it is full or until the complete
  contents of the transmitter buffer have been copied into the FIFO. The
  function returns the number of bytes copied into the UART's transmitter FIFO.

  Note:     This function reads the UART's line status register (LSR) to check
  for the active state of the transmitter holding register empty (THRE) bit
  before transferring data from the data buffer to the transmitter FIFO. If
  THRE is 0, the function returns immediately, without transferring any data
  to the FIFO. If THRE is 1, the function transfers up to 16 bytes of data
  to the FIFO and then returns.

  Note:     The actual transmission over the serial connection will still be
  in progress when this function returns. Use the MSS_UART_get_tx_status()
  function if you need to know when the transmitter is empty.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param tx_buffer
    The tx_buffer parameter is a pointer to a buffer containing the data
    to be transmitted.

  @param tx_size
    The tx_size parameter is the size in bytes, of the data to be transmitted.

  @return
    This function returns the number of bytes copied into the UART's
    transmitter FIFO.

  Example:
  @code
     void send_using_interrupt(uint8_t * pbuff, size_t tx_size)
     {
        size_t size_in_fifo;
        size_in_fifo = MSS_UART_fill_tx_fifo(&g_mss_uart0_lo, pbuff, tx_size);
     }
  @endcode
 */
size_t
MSS_UART_fill_tx_fifo
(
    mss_uart_instance_t * this_uart,
    const uint8_t * tx_buffer,
    size_t tx_size
);

/***************************************************************************//**
  The MSS_UART_get_rx_status() function returns the receiver error status of the
  MSS UART instance. It reads both the current error status of the receiver from
  the UART's line status register (LSR) and the accumulated error status from
  preceding calls to the MSS_UART_get_rx() function, and it combines them using
  a bitwise OR. It returns the cumulative overrun, parity, framing, break and
  FIFO error status of the receiver, since the previous call to
  MSS_UART_get_rx_status(), as an 8-bit encoded value.

  Note:     The MSS_UART_get_rx() function reads and accumulates the receiver
  status of the MSS UART instance before reading each byte from the receiver's
  data register/FIFO. The driver maintains a sticky record of the cumulative
  receiver error status, which persists after the MSS_UART_get_rx() function
  returns. The MSS_UART_get_rx_status() function clears the driver's sticky
  receiver error record before returning.

  Note:     The driver's transmit functions also read the line status
  register (LSR) as part of their implementation. When the driver reads the
  LSR, the UART clears any active receiver error bits in the LSR. This could
  result in the driver losing receiver errors. To avoid any loss of receiver
  errors, the transmit functions also update the driver's sticky record of the
  cumulative receiver error status whenever they read the LSR.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @return
    This function returns the UART's receiver error status as an 8-bit unsigned
    integer. The returned value is 0 if no receiver errors occurred. The driver
    provides a set of bit mask constants that should be compared with and/or
    used to mask the returned value to determine the receiver error status.
    When the return value is compared to the following bit masks, a non-zero
    result indicates that the corresponding error occurred:
        - MSS_UART_OVERRUN_ERROR      (bit mask = 0x02)
        - MSS_UART_PARITY_ERROR       (bit mask = 0x04)
        - MSS_UART_FRAMING_ERROR      (bit mask = 0x08)
        - MSS_UART_BREAK_ERROR        (bit mask = 0x10)
        - MSS_UART_FIFO_ERROR         (bit mask = 0x80)
        
    When the return value is compared to the following bit mask, a non-zero
    result indicates that no error occurred:
        - MSS_UART_NO_ERROR       (bit mask = 0x00)
        
    Upon unsuccessful execution, this function returns:
        - MSS_UART_INVALID_PARAM      (bit mask = 0xFF)

  Example:
  @code
    uint8_t rx_data[MAX_RX_DATA_SIZE];
    uint8_t err_status;
    err_status = MSS_UART_get_rx_status(&g_mss_uart0);

    if(MSS_UART_NO_ERROR == err_status)
    {
       rx_size = MSS_UART_get_rx(&g_mss_uart0_lo, rx_data, MAX_RX_DATA_SIZE);
    }
  @endcode
 */
uint8_t
MSS_UART_get_rx_status
(
    mss_uart_instance_t * this_uart
);

/***************************************************************************//**
  The MSS_UART_get_modem_status() function returns the modem status of the
  MSS UART instance. It reads the modem status register (MSR) and returns
  the 8 bit value. The bit encoding of the returned value is exactly the
  same as the definition of the bits in the MSR.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @return
    This function returns current state of the UART's MSR as an 8 bit
    unsigned integer. The driver provides the following set of bit mask
    constants that should be compared with and/or used to mask the
    returned value to determine the modem status:
        - MSS_UART_DCTS   (bit mask = 0x01)
        - MSS_UART_DDSR   (bit mask = 0x02)
        - MSS_UART_TERI   (bit mask = 0x04)
        - MSS_UART_DDCD   (bit mask = 0x08)
        - MSS_UART_CTS    (bit mask = 0x10)
        - MSS_UART_DSR    (bit mask = 0x20)
        - MSS_UART_RI     (bit mask = 0x40)
        - MSS_UART_DCD    (bit mask = 0x80)

  Example:
  @code
    void uart_modem_status_isr(mss_uart_instance_t * this_uart)
    {
        uint8_t status;
        status = MSS_UART_get_modem_status(this_uart);
        if( status & MSS_UART_DCTS )
        {
            uart_dcts_handler();
        }
        if( status & MSS_UART_CTS )
        {
            uart_cts_handler();
        }
    }
  @endcode
 */
uint8_t
MSS_UART_get_modem_status
(
    const mss_uart_instance_t * this_uart
);

/***************************************************************************//**
  The MSS_UART_get_tx_status() function returns the transmitter status of the
  MSS UART instance. It reads both the UART's line status register (LSR) and
  returns the status of the transmit holding register empty (THRE) and
  transmitter empty (TEMT) bits.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @return
    This function returns the UART's transmitter status as an 8-bit unsigned
    integer. The returned value is 0 if the transmitter status bits are not
    set or the function execution failed. The driver provides a set of bit
    mask constants that should be compared with and/or used to mask the
    returned value to determine the transmitter status.
    When the return value is compared to the following bit mask, a non-zero
    result indicates that the corresponding transmitter status bit is set:
      - MSS_UART_THRE       (bit mask = 0x20)
      - MSS_UART_TEMT       (bit mask = 0x40)
        
    When the return value is compared to the following bit mask, a non-zero
    result indicates that the transmitter is busy or the function execution
    failed.
      - MSS_UART_TX_BUSY        (bit mask = 0x00)

  Example:
  @code
    uint8_t tx_buff[10] = "abcdefghi";
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_polled_tx(&g_mss_uart0_lo, tx_buff, sizeof(tx_buff));

    while(!(MSS_UART_TEMT & MSS_UART_get_tx_status(&g_mss_uart0)))
    {
        ;
    }
  @endcode
 */
uint8_t
MSS_UART_get_tx_status
(
    mss_uart_instance_t * this_uart
);

/***************************************************************************//**
  The MSS_UART_set_break() function is used to send the break 
  (9 zeros after stop bit) signal on the TX line. This function can be used 
  only when the MSS UART is initialized in LIN mode by using MSS_UART_lin_init().

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @return
    This function does not return a value. 

  Example:
  @code
    MSS_UART_lin_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
  
    MSS_UART_set_break(&g_mss_uart0);
  @endcode
 */
void
MSS_UART_set_break
(
    mss_uart_instance_t * this_uart
);

/***************************************************************************//**
  The MSS_UART_clear_break() function is used to remove the break signal on the 
  TX line. This function can be used only when the MSS UART is initialized in 
  LIN mode by using MSS_UART_lin_init().

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @return
    This function does not return a value. 

  Example:
  @code
    MSS_UART_lin_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_clear_break(&g_mss_uart0_lo);
  @endcode
 */
void
MSS_UART_clear_break
(
    mss_uart_instance_t * this_uart
);

/***************************************************************************//**
  The MSS_UART_enable_half_duplex() function is used to enable the half-duplex 
  (single wire) mode for the MSS UART. Though it finds application in Smartcard 
  mode, half-duplex mode can be used in other modes as well.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_enable_half_duplex(&g_mss_uart0_lo);
  @endcode
 */
void 
MSS_UART_enable_half_duplex
(
    mss_uart_instance_t * this_uart
);

/***************************************************************************//**
  The MSS_UART_disable_half_duplex() function is used to disable the half-duplex 
  (single wire) mode for the MSS UART. Though it finds application in Smartcard 
  mode, half-duplex mode can be used in other modes as well.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_disable_half_duplex(&g_mss_uart0_lo);
  @endcode
 */
void 
MSS_UART_disable_half_duplex
(
    mss_uart_instance_t * this_uart
);

/***************************************************************************//**
  The MSS_UART_set_rx_endian() function is used to configure the LSB first or 
  MSB first setting for MSS UART receiver

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param endian
    The endian parameter tells the LSB first or MSB first configuration. 
    This parameter is of type mss_uart_endian_t.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_set_rx_endian(&g_mss_uart0_lo, MSS_UART_LITTLEEND);
  @endcode
 */
void
MSS_UART_set_rx_endian
(
    mss_uart_instance_t * this_uart,
    mss_uart_endian_t endian    
);

/***************************************************************************//**
  The MSS_UART_set_tx_endian() function is used to configure the LSB first or 
  MSB first setting for MSS UART transmitter.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param endian
    The endian parameter tells the LSB first or MSB first configuration. 
    This parameter is of type mss_uart_endian_t.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_set_tx_endian(&g_mss_uart0_lo, MSS_UART_LITTLEEND);
  @endcode
 */
void
MSS_UART_set_tx_endian
(
    mss_uart_instance_t * this_uart,
    mss_uart_endian_t endian    
);

/***************************************************************************//**
  The MSS_UART_set_filter_length () function is used to configure the glitch 
  filter length of the MSS UART. This should be configured in accordance with 
  the chosen baud rate.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param length
    The length parameter is of mss_uart_filter_length_t type that determines 
    the length of the glitch filter.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_set_filter_length(&g_mss_uart0_lo, MSS_UART_LEN2);
  @endcode
 */
void
MSS_UART_set_filter_length
(
    mss_uart_instance_t * this_uart,
    mss_uart_filter_length_t length
);

/***************************************************************************//**
  The MSS_UART_enable_afm() function is used to enable address flag detection 
  mode of the MSS UART

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_enable_afm(&g_mss_uart0_lo);
  @endcode
 */
void
MSS_UART_enable_afm
(
     mss_uart_instance_t * this_uart
);

/***************************************************************************//**
  The MSS_UART_disable_afm() function is used to disable address flag detection 
  mode of the MSS UART.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

    Note that if you are using the UART on the AMP APB bus, the hardware
    configuration to connect UART on AMP APB bus must already be done by the
    application using SYSREG registers before initializing the UART instance
    structure.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_disable_afm(&g_mss_uart0_lo);
  @endcode
 */
void
MSS_UART_disable_afm
(
     mss_uart_instance_t * this_uart
);

/***************************************************************************//**
  The MSS_UART_enable_afclear () function is used to enable address flag clear 
  of the MSS UART. This should be used in conjunction with address flag 
  detection mode (AFM).

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_enable_afclear(&g_mss_uart0_lo);
  @endcode
 */
void
MSS_UART_enable_afclear
(
     mss_uart_instance_t * this_uart
);

/***************************************************************************//**
  The MSS_UART_disable_afclear () function is used to disable address flag 
  clear of the MSS UART. This should be used in conjunction with address flag 
  detection mode (AFM).

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

    Note that if you are using the UART on the AMP APB bus, the hardware
    configuration to connect UART on AMP APB bus must already be done by the
    application using SYSREG registers before initializing the UART instance
    structure.

  @return
    This function does not return a value.
  
  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_disable_afclear(&g_mss_uart0_lo);
  @endcode
 */
void
MSS_UART_disable_afclear
(
     mss_uart_instance_t * this_uart
);

/***************************************************************************//**
  The MSS_UART_enable_rx_timeout() function is used to enable and configure 
  the receiver timeout functionality of MSS UART. This function accepts the 
  timeout parameter and applies the timeout based up on the baud rate as per 
  the formula 4 x timeout x bit time.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param timeout
    The timeout parameter specifies the receiver timeout multiple. 
    It should be configured according to the baud rate in use.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_enable_rx_timeout(&g_mss_uart0_lo, 24);
  @endcode
 */
void 
MSS_UART_enable_rx_timeout
(
    mss_uart_instance_t * this_uart,
    uint8_t timeout
);

/***************************************************************************//**
  The MSS_UART_disable_rx_timeout() function is used to disable the receiver 
  timeout functionality of MSS UART. 

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

    Note that if you are using the UART on the AMP APB bus, the hardware
    configuration to connect UART on AMP APB bus must already be done by the
    application using SYSREG registers before initializing the UART instance
    structure.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_disable_rx_timeout(&g_mss_uart0_lo);
  @endcode
 */
void 
MSS_UART_disable_rx_timeout
(
    mss_uart_instance_t * this_uart
);

/***************************************************************************//**
  The MSS_UART_enable_tx_time_guard() function is used to enable and configure 
  the transmitter time guard functionality of MSS UART. This function accepts 
  the timeguard parameter and applies the timeguard based up on the baud rate
  as per the formula timeguard x bit time.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

    Note that if you are using the UART on the AMP APB bus, the hardware
    configuration to connect UART on AMP APB bus must already be done by the
    application using SYSREG registers before initializing the UART instance
    structure.

  @param timeguard
    The timeguard parameter specifies the transmitter time guard multiple.
    It should be configured according to the baud rate in use.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_enable_tx_time_guard(&g_mss_uart0_lo, 24);
  @endcode
 */
void 
MSS_UART_enable_tx_time_guard
(
    mss_uart_instance_t * this_uart,
    uint8_t timeguard
);

/***************************************************************************//**
  The MSS_UART_disable_tx_time_guard() function is used to disable the 
  transmitter time guard functionality of MSS UART. 

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

    Note that if you are using the UART on the AMP APB bus, the hardware
    configuration to connect UART on AMP APB bus must already be done by the
    application using SYSREG registers before initializing the UART instance
    structure.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
                  
    MSS_UART_disable_tx_time_guard(&g_mss_uart0_lo);
  @endcode
 */
void 
MSS_UART_disable_tx_time_guard
(
    mss_uart_instance_t * this_uart
);

/***************************************************************************//**
  The MSS_UART_set_address() function is used to set the 8-bit address for 
  the MSS UART referenced by this_uart parameter. 

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param address
    The address parameter is the 8-bit address which is to be configured 
    to the MSS UART referenced by this_uart parameter.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
                  
    MSS_UART_set_address(&g_mss_uart0_lo, 0xAA);
  @endcode
 */
void
MSS_UART_set_address
(
    mss_uart_instance_t * this_uart,
    uint8_t address
);

/***************************************************************************//**
  The MSS_UART_set_ready_mode() function is used to configure the MODE0 or MODE1 
  to the TXRDY and RXRDY signals of the MSS UART referenced by this_uart 
  parameter. The mode parameter is used to provide the mode to be configured.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param mode
    The mode parameter is the mss_uart_ready_mode_t type which is used to 
    configure the TXRDY and RXRDY signal modes.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_set_ready_mode(&g_mss_uart0_lo, MSS_UART_READY_MODE0);
  @endcode
 */
void 
MSS_UART_set_ready_mode
(
    mss_uart_instance_t * this_uart,
    mss_uart_ready_mode_t mode    
);

/***************************************************************************//**
  The MSS_UART_set_usart_mode() function is used to configure the MSS UART 
  referenced by the parameter this_uart in USART mode. Various USART modes 
  are supported which can be configured by the parameter mode of type 
  mss_uart_usart_mode_t.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @param mode
    The mode parameter is the USART mode to be configured. 
    This parameter is of type mss_uart_usart_mode_t.

  @return
    This function does not return a value.

  Example:
  @code
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_set_usart_mode(&g_mss_uart0_lo, MSS_UART_SYNC_MASTER_POS_EDGE_CLK);
  @endcode
 */
void 
MSS_UART_set_usart_mode
(
    mss_uart_instance_t * this_uart,
    mss_uart_usart_mode_t mode
);

/***************************************************************************//**
  The MSS_UART_enable_local_irq() function is used to enable the MMUART
  interrupt as a local interrupt to the hart rather than via PLIC.
  MMUART interrupt can be configured to trigger an interrupt via PLIC or it
  can be configured to trigger a local interrupt. The arrangement is such that
  the UART0 interrupt can appear as local interrupt on E51. The UART1 to UART4
  interrupts can appear as local interrupt to U51_1 to U54_4 respectively.
  The UART0 to UART4 can appear as PLIC interrupt. Multiple HARTs can enable
  and receive the PLIC interrupt, the HART that claims the interrupt processes
  it. For rest of the HARTs the IRQ gets silently skipped as the interrupt
  claim has already been taken.

  By default, the PLIC interrupt is enabled by this driver when
  MSS_UART_enable_irq() or the APIs to set the interrupt handler is called.
  To enable the local interrupt application must explicitly call
  MSS_UART_enable_local_irq() function. Note that this function disables the
  interrupt over PLIC if it was previously enabled.

  This function must be called after the MMUART is initialized, the required
  interrupt hander functions are set and before initiating any data transfers.
  If you want to register multiple register handlers such as tx handler, rx
  handler etc. then this function must be called after all such handlers are set.

  Call to this function is treated as one time activity. The driver gives no
  option to disable the local interrupt and enable the PLIC interrupt again at
  runtime.

  @param this_uart
    The this_uart parameter is a pointer to an mss_uart_instance_t
    structure identifying the MSS UART hardware block that will perform
    the requested function. There are ten such data structures,
    g_mss_uart0_lo to g_mss_uart4_lo, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 5 (main APB bus) and
    g_mss_uart0_hi to g_mss_uart4_hi, associated with MSS UART0 to MSS UART4
    when they are connected on the AXI switch slave 6 (AMP APB bus).
    This parameter must point to one of these ten global data structure defined
    within the UART driver.

  @return
    This function does not return a value.

  Example:
  @code


    __enable_irq();
    MSS_UART_init(&g_mss_uart0_lo,
             MSS_UART_57600_BAUD,
             MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);

    MSS_UART_set_rx_handler(&g_mss_uart0_lo,
                            uart0_rx_handler,
                            MSS_UART_FIFO_SINGLE_BYTE);

    MSS_UART_enable_local_irq(&g_mss_uart0_lo);

  @endcode
 */
void
MSS_UART_enable_local_irq
(
    mss_uart_instance_t * this_uart
);

#ifdef __cplusplus
}
#endif

#endif /* __MSS_UART_H_ */