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
328
329
333
334
335
336
337
338
339
340
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
362
363
364
365
367
368
370
371
373
374
376
377
379
380
382
383
384
385
386
388
390
392
393
395
396
397
398
399
400
403
404
405
408
409
410
413
414
415
416
417
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
491
492
493
494
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
536
537
538
539
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
576
577
578
579
580
582
583
584
585
586
587
588
589
590
594
595
596
597
598
599
603
607
608
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
651
652
653
654
658
659
660
661
662
663
664
665
666
667
668
675
676
678
679
680
681
682
683
684
685
686
687
688
689
690
691
697
706
707
713
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
759
760
761
762
763
764
768
772
776
780
784
788
792
796
800
804
808
815
816
817
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
885
889
893
897
901
905
909
913
917
921
925
932
933
934
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
986
987
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
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
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1153
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
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1207
1208
1214
1220
1221
1222
1223
1224
1225
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
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
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1296
1302
1303
1304
1305
1306
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1327
1328
1334
1340
1341
1342
1343
1344
1345
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1445
1446
1447
1448
1449
1450
1451
1457
1458
1459
1460
1461
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1492
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1592
1593
1594
1595
1596
1597
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
1645
1646
1647
1648
1649
1650
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1714
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1742
1743
1744
1745
1746
1749
1750
1751
1752
1754
1755
1756
1757
1758
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1804
1809
1810
1811
1812
1813
1814
1815
1816
1817
1820
1821
1822
1823
1825
1826
1827
1828
1829
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
1884
1885
1886
1887
1889
1890
1891
1892
1893
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
1934
1935
1936
1937
1939
1940
1941
1942
1943
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1991
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
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
2097
2098
2099
2101
2102
2103
2104
2105
2106
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2153
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
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
2244
2245
2246
2248
2249
2250
2251
2252
2253
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
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
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
2383
2384
2385
2386
2387
2388
2389
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
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
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
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
2527
2528
2529
2530
2531
2532
2533
2534
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2555
2556
2557
2562
2567
2568
2569
2570
2571
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2592
2593
2599
2605
2606
2607
2608
2609
2610
2611
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
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
2664
2665
2666
2667
2668
2669
2670
2671
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2692
2693
2694
2695
2701
2707
2708
2709
2710
2711
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2732
2733
2739
2745
2746
2747
2748
2749
2750
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2799
2800
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
2847
2848
2849
2850
2852
2853
2854
2855
2856
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2887
2888
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
2934
2935
2936
2937
2939
2940
2941
2942
2943
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
2976
2977
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
3000
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
3066
3067
3068
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
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
3122
3123
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3146
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
3212
3213
3214
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
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
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
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3409
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3432
3433
3438
3439
3440
3441
3442
3443
3444
3448
3449
3450
3451
3455
3459
3460
3461
3462
3463
3466
3467
3468
3470
3471
3472
3473
3474
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3524
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3547
3548
3553
3554
3555
3556
3557
3558
3559
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3605
3609
3610
3611
3612
3613
3614
3615
3616
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3651
3655
3656
3657
3658
3659
3662
3663
3664
3666
3667
3668
3669
3670
3671
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3719
3724
3725
3727
3728
3733
3734
3735
3736
3737
3738
3739
3743
3744
3745
3746
3747
3748
3749
3750
3751
3754
3755
3756
3757
3758
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3807
3812
3813
3815
3816
3821
3822
3823
3824
3825
3826
3827
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3917
3918
3919
3921
3922
3923
3924
3925
3926
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3981
3982
3983
3984
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4014
4015
4016
4017
4018
4021
4022
4023
4024
4025
4026
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4082
4083
4084
4085
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4104
4105
4106
4107
4112
4113
4114
4115
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4195
4196
4197
4198
4199
4200
4201
4202
4205
4206
4207
4208
4209
4210
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4265
4266
4267
4268
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4298
4299
4300
4301
4302
4305
4306
4307
4308
4309
4310
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4366
4367
4368
4369
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4388
4389
4390
4391
4396
4397
4398
4399
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4479
4480
4481
4482
4483
4484
4485
4486
4489
4490
4491
4492
4493
4494
4498
4499
4500
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4522
4523
4524
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4576
4581
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4599
4600
4601
4602
4603
4609
4610
4611
4614
4615
4618
4619
4625
4626
4627
4628
4629
4630
4631
4632
4636
4637
4638
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4688
4689
4690
4696
4697
4698
4699
4700
4701
4704
4705
4706
4712
4713
4714
4715
4716
4717
4720
4721
4722
4727
4728
4729
4730
4731
4732
4735
4736
4737
4743
4744
4745
4746
4747
4748
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4771
4772
4773
4779
4780
4781
4782
4783
4784
4787
4788
4789
4795
4796
4797
4798
4799
4800
4803
4804
4805
4811
4812
4813
4814
4815
4816
4819
4820
4821
4827
4828
4829
4830
4831
4832
4835
4836
4837
4843
4844
4845
4846
4847
4848
4851
4852
4853
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4878
4883
4884
4890
4894
4895
4901
4905
4906
4909
4910
4913
4914
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4995
4999
5000
5001
5015
5016
5031
5032
5059
5063
5064
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5158
5162
5163
5164
5165
5171
5172
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5192
5193
5194
5195
5196
5200
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5222
5223
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5272
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5331
5332
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5364
5365
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5429
5433
5434
5435
5447
5448
5449
5450
5451
5452
5453
5454
5455
5459
5463
5464
5479
5480
5507
5513
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5585
5589
5590
5591
5592
5598
5599
5600
5601
5602
5603
5607
5611
5612
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5632
5633
5634
5635
5636
5640
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5666
5670
5671
5677
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5734
5735
5736
5746
5747
5748
5749
5750
5752
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5792
5796
5800
5801
5802
5803
5804
5805
5806
5811
5812
5817
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5851
5852
5853
5858
5859
5860
5861
5862
5863
5864
5865
5869
5870
5871
5872
5873
5874
5875
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5906
5907
5908
5913
5914
5915
5916
5917
5918
5919
5920
5924
5925
5926
5927
5928
5929
5930
5934
5935
5936
5937
5938
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6092
6093
6094
6095
6096
6097
6098
6099
6100
6105
6110
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6158
6159
6160
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6181
6186
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6214
6215
6216
6217
6218
6219
6220
6221
6222
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6301
6302
6303
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6325
6330
6335
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6359
6360
6361
6362
6363
6364
6365
6369
6370
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6392
6393
6394
6395
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6413
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6644
6645
6646
6647
6649
6650
6651
6652
6653
6654
6655
6660
6661
6665
6666
6667
6668
6669
6670
6674
6675
6676
6677
6679
6680
6681
6682
6683
6684
6685
6690
6691
6695
6696
6700
6701
6702
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6745
6746
6747
6748
6749
6753
6754
6755
6759
6760
6761
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6780
6781
6782
6783
6784
6785
6786
6787
6791
6795
6796
6797
6803
6808
6809
6810
6811
6812
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6838
6839
6840
6841
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6860
6861
6862
6863
6864
6865
6866
6867
6879
6883
6884
6885
6891
6896
6897
6898
6899
6900
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6926
6927
6928
6929
6934
6935
6936
6937
6938
6939
6940
6947
6948
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6974
6975
6976
6977
6978
6979
6980
6984
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7135
7136
7137
7138
7139
7140
7141
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7381
7382
7387
7388
7393
7394
7399
7400
7405
7406
7407
7408
7409
7414
7415
7420
7421
7426
7427
7432
7433
7438
7439
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7473
7474
7475
7476
7477
7478
7479
7480
7485
7486
7487
7492
7493
7498
7499
7504
7505
7510
7511
7512
7513
7514
7515
7516
7517
7522
7523
7524
7525
7526
7527
7531
7532
7533
7534
7535
7539
7543
7544
7545
7548
7549
7550
7551
7554
7555
/* ... */
#include "stm32f4xx_hal.h"
/* ... */
/* ... */
#ifdef HAL_FMPI2C_MODULE_ENABLED
#if defined(FMPI2C_CR1_PE)
/* ... */
#define TIMING_CLEAR_MASK (0xF0FFFFFFU)
#define FMPI2C_TIMEOUT_ADDR (10000U)
#define FMPI2C_TIMEOUT_BUSY (25U)
#define FMPI2C_TIMEOUT_DIR (25U)
#define FMPI2C_TIMEOUT_RXNE (25U)
#define FMPI2C_TIMEOUT_STOPF (25U)
#define FMPI2C_TIMEOUT_TC (25U)
#define FMPI2C_TIMEOUT_TCR (25U)
#define FMPI2C_TIMEOUT_TXIS (25U)
#define FMPI2C_TIMEOUT_FLAG (25U)
#define MAX_NBYTE_SIZE 255U
#define SLAVE_ADDR_SHIFT 7U
#define SLAVE_ADDR_MSK 0x06U
#define FMPI2C_STATE_MSK ((uint32_t)((uint32_t)((uint32_t)HAL_FMPI2C_STATE_BUSY_TX | \
(uint32_t)HAL_FMPI2C_STATE_BUSY_RX) & \
(uint32_t)(~((uint32_t)HAL_FMPI2C_STATE_READY))))...
#define FMPI2C_STATE_NONE ((uint32_t)(HAL_FMPI2C_MODE_NONE))
#define FMPI2C_STATE_MASTER_BUSY_TX ((uint32_t)(((uint32_t)HAL_FMPI2C_STATE_BUSY_TX & FMPI2C_STATE_MSK) | \
(uint32_t)HAL_FMPI2C_MODE_MASTER))...
#define FMPI2C_STATE_MASTER_BUSY_RX ((uint32_t)(((uint32_t)HAL_FMPI2C_STATE_BUSY_RX & FMPI2C_STATE_MSK) | \
(uint32_t)HAL_FMPI2C_MODE_MASTER))...
#define FMPI2C_STATE_SLAVE_BUSY_TX ((uint32_t)(((uint32_t)HAL_FMPI2C_STATE_BUSY_TX & FMPI2C_STATE_MSK) | \
(uint32_t)HAL_FMPI2C_MODE_SLAVE))...
#define FMPI2C_STATE_SLAVE_BUSY_RX ((uint32_t)(((uint32_t)HAL_FMPI2C_STATE_BUSY_RX & FMPI2C_STATE_MSK) | \
(uint32_t)HAL_FMPI2C_MODE_SLAVE))...
#define FMPI2C_STATE_MEM_BUSY_TX ((uint32_t)(((uint32_t)HAL_FMPI2C_STATE_BUSY_TX & FMPI2C_STATE_MSK) | \
(uint32_t)HAL_FMPI2C_MODE_MEM))...
#define FMPI2C_STATE_MEM_BUSY_RX ((uint32_t)(((uint32_t)HAL_FMPI2C_STATE_BUSY_RX & FMPI2C_STATE_MSK) | \
(uint32_t)HAL_FMPI2C_MODE_MEM))...
#define FMPI2C_XFER_TX_IT (uint16_t)(0x0001U)
/* ... */
#define FMPI2C_XFER_RX_IT (uint16_t)(0x0002U)
/* ... */
#define FMPI2C_XFER_LISTEN_IT (uint16_t)(0x8000U)
/* ... */
#define FMPI2C_XFER_ERROR_IT (uint16_t)(0x0010U)
/* ... */
#define FMPI2C_XFER_CPLT_IT (uint16_t)(0x0020U)
#define FMPI2C_XFER_RELOAD_IT (uint16_t)(0x0040U)
#define FMPI2C_NO_OPTION_FRAME (0xFFFF0000U)
/* ... */
/* ... */
#define FMPI2C_GET_DMA_REMAIN_DATA(__HANDLE__) __HAL_DMA_GET_COUNTER(__HANDLE__)
29 defines
/* ... */
/* ... */
static void FMPI2C_DMAMasterTransmitCplt(DMA_HandleTypeDef *hdma);
static void FMPI2C_DMAMasterReceiveCplt(DMA_HandleTypeDef *hdma);
static void FMPI2C_DMASlaveTransmitCplt(DMA_HandleTypeDef *hdma);
static void FMPI2C_DMASlaveReceiveCplt(DMA_HandleTypeDef *hdma);
static void FMPI2C_DMAError(DMA_HandleTypeDef *hdma);
static void FMPI2C_DMAAbort(DMA_HandleTypeDef *hdma);
static void FMPI2C_ITAddrCplt(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags);
static void FMPI2C_ITMasterSeqCplt(FMPI2C_HandleTypeDef *hfmpi2c);
static void FMPI2C_ITSlaveSeqCplt(FMPI2C_HandleTypeDef *hfmpi2c);
static void FMPI2C_ITMasterCplt(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags);
static void FMPI2C_ITSlaveCplt(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags);
static void FMPI2C_ITListenCplt(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags);
static void FMPI2C_ITError(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ErrorCode);
static HAL_StatusTypeDef FMPI2C_RequestMemoryWrite(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress,
uint16_t MemAddress, uint16_t MemAddSize, uint32_t Timeout,
uint32_t Tickstart);
static HAL_StatusTypeDef FMPI2C_RequestMemoryRead(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress,
uint16_t MemAddress, uint16_t MemAddSize, uint32_t Timeout,
uint32_t Tickstart);
static HAL_StatusTypeDef FMPI2C_Master_ISR_IT(struct __FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags,
uint32_t ITSources);
static HAL_StatusTypeDef FMPI2C_Mem_ISR_IT(struct __FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags,
uint32_t ITSources);
static HAL_StatusTypeDef FMPI2C_Slave_ISR_IT(struct __FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags,
uint32_t ITSources);
static HAL_StatusTypeDef FMPI2C_Master_ISR_DMA(struct __FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags,
uint32_t ITSources);
static HAL_StatusTypeDef FMPI2C_Mem_ISR_DMA(struct __FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags,
uint32_t ITSources);
static HAL_StatusTypeDef FMPI2C_Slave_ISR_DMA(struct __FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags,
uint32_t ITSources);
static HAL_StatusTypeDef FMPI2C_WaitOnFlagUntilTimeout(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t Flag, FlagStatus Status,
uint32_t Timeout, uint32_t Tickstart);
static HAL_StatusTypeDef FMPI2C_WaitOnTXISFlagUntilTimeout(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t Timeout,
uint32_t Tickstart);
static HAL_StatusTypeDef FMPI2C_WaitOnRXNEFlagUntilTimeout(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t Timeout,
uint32_t Tickstart);
static HAL_StatusTypeDef FMPI2C_WaitOnSTOPFlagUntilTimeout(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t Timeout,
uint32_t Tickstart);
static HAL_StatusTypeDef FMPI2C_IsErrorOccurred(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t Timeout,
uint32_t Tickstart);
static void FMPI2C_Enable_IRQ(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t InterruptRequest);
static void FMPI2C_Disable_IRQ(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t InterruptRequest);
static void FMPI2C_TreatErrorCallback(FMPI2C_HandleTypeDef *hfmpi2c);
static void FMPI2C_Flush_TXDR(FMPI2C_HandleTypeDef *hfmpi2c);
static void FMPI2C_TransferConfig(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t Size, uint32_t Mode,
uint32_t Request);
static void FMPI2C_ConvertOtherXferOptions(FMPI2C_HandleTypeDef *hfmpi2c);
/* ... */
Private function prototypes
/* ... */
/* ... */
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Init(FMPI2C_HandleTypeDef *hfmpi2c)
{
if (hfmpi2c == NULL)
{
return HAL_ERROR;
}if (hfmpi2c == NULL) { ... }
assert_param(IS_FMPI2C_ALL_INSTANCE(hfmpi2c->Instance));
assert_param(IS_FMPI2C_OWN_ADDRESS1(hfmpi2c->Init.OwnAddress1));
assert_param(IS_FMPI2C_ADDRESSING_MODE(hfmpi2c->Init.AddressingMode));
assert_param(IS_FMPI2C_DUAL_ADDRESS(hfmpi2c->Init.DualAddressMode));
assert_param(IS_FMPI2C_OWN_ADDRESS2(hfmpi2c->Init.OwnAddress2));
assert_param(IS_FMPI2C_OWN_ADDRESS2_MASK(hfmpi2c->Init.OwnAddress2Masks));
assert_param(IS_FMPI2C_GENERAL_CALL(hfmpi2c->Init.GeneralCallMode));
assert_param(IS_FMPI2C_NO_STRETCH(hfmpi2c->Init.NoStretchMode));
if (hfmpi2c->State == HAL_FMPI2C_STATE_RESET)
{
hfmpi2c->Lock = HAL_UNLOCKED;
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->MasterTxCpltCallback = HAL_FMPI2C_MasterTxCpltCallback;
hfmpi2c->MasterRxCpltCallback = HAL_FMPI2C_MasterRxCpltCallback;
hfmpi2c->SlaveTxCpltCallback = HAL_FMPI2C_SlaveTxCpltCallback;
hfmpi2c->SlaveRxCpltCallback = HAL_FMPI2C_SlaveRxCpltCallback;
hfmpi2c->ListenCpltCallback = HAL_FMPI2C_ListenCpltCallback;
hfmpi2c->MemTxCpltCallback = HAL_FMPI2C_MemTxCpltCallback;
hfmpi2c->MemRxCpltCallback = HAL_FMPI2C_MemRxCpltCallback;
hfmpi2c->ErrorCallback = HAL_FMPI2C_ErrorCallback;
hfmpi2c->AbortCpltCallback = HAL_FMPI2C_AbortCpltCallback;
hfmpi2c->AddrCallback = HAL_FMPI2C_AddrCallback;
if (hfmpi2c->MspInitCallback == NULL)
{
hfmpi2c->MspInitCallback = HAL_FMPI2C_MspInit;
}if (hfmpi2c->MspInitCallback == NULL) { ... }
hfmpi2c->MspInitCallback(hfmpi2c);/* ... */
#else
HAL_FMPI2C_MspInit(hfmpi2c);/* ... */
#endif
}if (hfmpi2c->State == HAL_FMPI2C_STATE_RESET) { ... }
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY;
__HAL_FMPI2C_DISABLE(hfmpi2c);
hfmpi2c->Instance->TIMINGR = hfmpi2c->Init.Timing & TIMING_CLEAR_MASK;
---------------------------- FMPI2Cx TIMINGR Configuration
hfmpi2c->Instance->OAR1 &= ~FMPI2C_OAR1_OA1EN;
if (hfmpi2c->Init.AddressingMode == FMPI2C_ADDRESSINGMODE_7BIT)
{
hfmpi2c->Instance->OAR1 = (FMPI2C_OAR1_OA1EN | hfmpi2c->Init.OwnAddress1);
}if (hfmpi2c->Init.AddressingMode == FMPI2C_ADDRESSINGMODE_7BIT) { ... }
else
{
hfmpi2c->Instance->OAR1 = (FMPI2C_OAR1_OA1EN | FMPI2C_OAR1_OA1MODE | hfmpi2c->Init.OwnAddress1);
}else { ... }
---------------------------- FMPI2Cx OAR1 Configuration
if (hfmpi2c->Init.AddressingMode == FMPI2C_ADDRESSINGMODE_10BIT)
{
SET_BIT(hfmpi2c->Instance->CR2, FMPI2C_CR2_ADD10);
}if (hfmpi2c->Init.AddressingMode == FMPI2C_ADDRESSINGMODE_10BIT) { ... }
else
{
CLEAR_BIT(hfmpi2c->Instance->CR2, FMPI2C_CR2_ADD10);
}else { ... }
hfmpi2c->Instance->CR2 |= (FMPI2C_CR2_AUTOEND | FMPI2C_CR2_NACK);
---------------------------- FMPI2Cx CR2 Configuration
hfmpi2c->Instance->OAR2 &= ~FMPI2C_DUALADDRESS_ENABLE;
hfmpi2c->Instance->OAR2 = (hfmpi2c->Init.DualAddressMode | hfmpi2c->Init.OwnAddress2 | \
(hfmpi2c->Init.OwnAddress2Masks << 8));
---------------------------- FMPI2Cx OAR2 Configuration
hfmpi2c->Instance->CR1 = (hfmpi2c->Init.GeneralCallMode | hfmpi2c->Init.NoStretchMode);
__HAL_FMPI2C_ENABLE(hfmpi2c);
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->PreviousState = FMPI2C_STATE_NONE;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
return HAL_OK;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_DeInit(FMPI2C_HandleTypeDef *hfmpi2c)
{
if (hfmpi2c == NULL)
{
return HAL_ERROR;
}if (hfmpi2c == NULL) { ... }
assert_param(IS_FMPI2C_ALL_INSTANCE(hfmpi2c->Instance));
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY;
__HAL_FMPI2C_DISABLE(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
if (hfmpi2c->MspDeInitCallback == NULL)
{
hfmpi2c->MspDeInitCallback = HAL_FMPI2C_MspDeInit;
}if (hfmpi2c->MspDeInitCallback == NULL) { ... }
hfmpi2c->MspDeInitCallback(hfmpi2c);/* ... */
#else
HAL_FMPI2C_MspDeInit(hfmpi2c);/* ... */
#endif
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->State = HAL_FMPI2C_STATE_RESET;
hfmpi2c->PreviousState = FMPI2C_STATE_NONE;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
return HAL_OK;
}{ ... }
/* ... */
__weak void HAL_FMPI2C_MspInit(FMPI2C_HandleTypeDef *hfmpi2c)
{
UNUSED(hfmpi2c);
/* ... */
}{ ... }
/* ... */
__weak void HAL_FMPI2C_MspDeInit(FMPI2C_HandleTypeDef *hfmpi2c)
{
UNUSED(hfmpi2c);
/* ... */
}{ ... }
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_RegisterCallback(FMPI2C_HandleTypeDef *hfmpi2c, HAL_FMPI2C_CallbackIDTypeDef CallbackID,
pFMPI2C_CallbackTypeDef pCallback)
{
HAL_StatusTypeDef status = HAL_OK;
if (pCallback == NULL)
{
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_INVALID_CALLBACK;
return HAL_ERROR;
}if (pCallback == NULL) { ... }
if (HAL_FMPI2C_STATE_READY == hfmpi2c->State)
{
switch (CallbackID)
{
case HAL_FMPI2C_MASTER_TX_COMPLETE_CB_ID :
hfmpi2c->MasterTxCpltCallback = pCallback;
break;
case HAL_FMPI2C_MASTER_TX_COMPLETE_CB_ID :
case HAL_FMPI2C_MASTER_RX_COMPLETE_CB_ID :
hfmpi2c->MasterRxCpltCallback = pCallback;
break;
case HAL_FMPI2C_MASTER_RX_COMPLETE_CB_ID :
case HAL_FMPI2C_SLAVE_TX_COMPLETE_CB_ID :
hfmpi2c->SlaveTxCpltCallback = pCallback;
break;
case HAL_FMPI2C_SLAVE_TX_COMPLETE_CB_ID :
case HAL_FMPI2C_SLAVE_RX_COMPLETE_CB_ID :
hfmpi2c->SlaveRxCpltCallback = pCallback;
break;
case HAL_FMPI2C_SLAVE_RX_COMPLETE_CB_ID :
case HAL_FMPI2C_LISTEN_COMPLETE_CB_ID :
hfmpi2c->ListenCpltCallback = pCallback;
break;
case HAL_FMPI2C_LISTEN_COMPLETE_CB_ID :
case HAL_FMPI2C_MEM_TX_COMPLETE_CB_ID :
hfmpi2c->MemTxCpltCallback = pCallback;
break;
case HAL_FMPI2C_MEM_TX_COMPLETE_CB_ID :
case HAL_FMPI2C_MEM_RX_COMPLETE_CB_ID :
hfmpi2c->MemRxCpltCallback = pCallback;
break;
case HAL_FMPI2C_MEM_RX_COMPLETE_CB_ID :
case HAL_FMPI2C_ERROR_CB_ID :
hfmpi2c->ErrorCallback = pCallback;
break;
case HAL_FMPI2C_ERROR_CB_ID :
case HAL_FMPI2C_ABORT_CB_ID :
hfmpi2c->AbortCpltCallback = pCallback;
break;
case HAL_FMPI2C_ABORT_CB_ID :
case HAL_FMPI2C_MSPINIT_CB_ID :
hfmpi2c->MspInitCallback = pCallback;
break;
case HAL_FMPI2C_MSPINIT_CB_ID :
case HAL_FMPI2C_MSPDEINIT_CB_ID :
hfmpi2c->MspDeInitCallback = pCallback;
break;
case HAL_FMPI2C_MSPDEINIT_CB_ID :
default :
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
break;default
}switch (CallbackID) { ... }
}if (HAL_FMPI2C_STATE_READY == hfmpi2c->State) { ... }
else if (HAL_FMPI2C_STATE_RESET == hfmpi2c->State)
{
switch (CallbackID)
{
case HAL_FMPI2C_MSPINIT_CB_ID :
hfmpi2c->MspInitCallback = pCallback;
break;
case HAL_FMPI2C_MSPINIT_CB_ID :
case HAL_FMPI2C_MSPDEINIT_CB_ID :
hfmpi2c->MspDeInitCallback = pCallback;
break;
case HAL_FMPI2C_MSPDEINIT_CB_ID :
default :
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
break;default
}switch (CallbackID) { ... }
}else if (HAL_FMPI2C_STATE_RESET == hfmpi2c->State) { ... }
else
{
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
}else { ... }
return status;
}HAL_FMPI2C_RegisterCallback (FMPI2C_HandleTypeDef *hfmpi2c, HAL_FMPI2C_CallbackIDTypeDef CallbackID, pFMPI2C_CallbackTypeDef pCallback) { ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_UnRegisterCallback(FMPI2C_HandleTypeDef *hfmpi2c, HAL_FMPI2C_CallbackIDTypeDef CallbackID)
{
HAL_StatusTypeDef status = HAL_OK;
if (HAL_FMPI2C_STATE_READY == hfmpi2c->State)
{
switch (CallbackID)
{
case HAL_FMPI2C_MASTER_TX_COMPLETE_CB_ID :
hfmpi2c->MasterTxCpltCallback = HAL_FMPI2C_MasterTxCpltCallback;
break;
case HAL_FMPI2C_MASTER_TX_COMPLETE_CB_ID :
case HAL_FMPI2C_MASTER_RX_COMPLETE_CB_ID :
hfmpi2c->MasterRxCpltCallback = HAL_FMPI2C_MasterRxCpltCallback;
break;
case HAL_FMPI2C_MASTER_RX_COMPLETE_CB_ID :
case HAL_FMPI2C_SLAVE_TX_COMPLETE_CB_ID :
hfmpi2c->SlaveTxCpltCallback = HAL_FMPI2C_SlaveTxCpltCallback;
break;
case HAL_FMPI2C_SLAVE_TX_COMPLETE_CB_ID :
case HAL_FMPI2C_SLAVE_RX_COMPLETE_CB_ID :
hfmpi2c->SlaveRxCpltCallback = HAL_FMPI2C_SlaveRxCpltCallback;
break;
case HAL_FMPI2C_SLAVE_RX_COMPLETE_CB_ID :
case HAL_FMPI2C_LISTEN_COMPLETE_CB_ID :
hfmpi2c->ListenCpltCallback = HAL_FMPI2C_ListenCpltCallback;
break;
case HAL_FMPI2C_LISTEN_COMPLETE_CB_ID :
case HAL_FMPI2C_MEM_TX_COMPLETE_CB_ID :
hfmpi2c->MemTxCpltCallback = HAL_FMPI2C_MemTxCpltCallback;
break;
case HAL_FMPI2C_MEM_TX_COMPLETE_CB_ID :
case HAL_FMPI2C_MEM_RX_COMPLETE_CB_ID :
hfmpi2c->MemRxCpltCallback = HAL_FMPI2C_MemRxCpltCallback;
break;
case HAL_FMPI2C_MEM_RX_COMPLETE_CB_ID :
case HAL_FMPI2C_ERROR_CB_ID :
hfmpi2c->ErrorCallback = HAL_FMPI2C_ErrorCallback;
break;
case HAL_FMPI2C_ERROR_CB_ID :
case HAL_FMPI2C_ABORT_CB_ID :
hfmpi2c->AbortCpltCallback = HAL_FMPI2C_AbortCpltCallback;
break;
case HAL_FMPI2C_ABORT_CB_ID :
case HAL_FMPI2C_MSPINIT_CB_ID :
hfmpi2c->MspInitCallback = HAL_FMPI2C_MspInit;
break;
case HAL_FMPI2C_MSPINIT_CB_ID :
case HAL_FMPI2C_MSPDEINIT_CB_ID :
hfmpi2c->MspDeInitCallback = HAL_FMPI2C_MspDeInit;
break;
case HAL_FMPI2C_MSPDEINIT_CB_ID :
default :
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
break;default
}switch (CallbackID) { ... }
}if (HAL_FMPI2C_STATE_READY == hfmpi2c->State) { ... }
else if (HAL_FMPI2C_STATE_RESET == hfmpi2c->State)
{
switch (CallbackID)
{
case HAL_FMPI2C_MSPINIT_CB_ID :
hfmpi2c->MspInitCallback = HAL_FMPI2C_MspInit;
break;
case HAL_FMPI2C_MSPINIT_CB_ID :
case HAL_FMPI2C_MSPDEINIT_CB_ID :
hfmpi2c->MspDeInitCallback = HAL_FMPI2C_MspDeInit;
break;
case HAL_FMPI2C_MSPDEINIT_CB_ID :
default :
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
break;default
}switch (CallbackID) { ... }
}else if (HAL_FMPI2C_STATE_RESET == hfmpi2c->State) { ... }
else
{
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
}else { ... }
return status;
}HAL_FMPI2C_UnRegisterCallback (FMPI2C_HandleTypeDef *hfmpi2c, HAL_FMPI2C_CallbackIDTypeDef CallbackID) { ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_RegisterAddrCallback(FMPI2C_HandleTypeDef *hfmpi2c, pFMPI2C_AddrCallbackTypeDef pCallback)
{
HAL_StatusTypeDef status = HAL_OK;
if (pCallback == NULL)
{
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_INVALID_CALLBACK;
return HAL_ERROR;
}if (pCallback == NULL) { ... }
if (HAL_FMPI2C_STATE_READY == hfmpi2c->State)
{
hfmpi2c->AddrCallback = pCallback;
}if (HAL_FMPI2C_STATE_READY == hfmpi2c->State) { ... }
else
{
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
}else { ... }
return status;
}HAL_FMPI2C_RegisterAddrCallback (FMPI2C_HandleTypeDef *hfmpi2c, pFMPI2C_AddrCallbackTypeDef pCallback) { ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_UnRegisterAddrCallback(FMPI2C_HandleTypeDef *hfmpi2c)
{
HAL_StatusTypeDef status = HAL_OK;
if (HAL_FMPI2C_STATE_READY == hfmpi2c->State)
{
hfmpi2c->AddrCallback = HAL_FMPI2C_AddrCallback;
}if (HAL_FMPI2C_STATE_READY == hfmpi2c->State) { ... }
else
{
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
}else { ... }
return status;
}HAL_FMPI2C_UnRegisterAddrCallback (FMPI2C_HandleTypeDef *hfmpi2c) { ... }
/* ... */
#endif
/* ... */
/* ... */
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Master_Transmit(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData,
uint16_t Size, uint32_t Timeout)
{
uint32_t tickstart;
uint32_t xfermode;
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
__HAL_LOCK(hfmpi2c);
tickstart = HAL_GetTick();
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_BUSY, SET, FMPI2C_TIMEOUT_BUSY, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_BUSY, SET, FMPI2C_TIMEOUT_BUSY, tickstart) != HAL_OK) { ... }
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_TX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MASTER;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferISR = NULL;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
xfermode = FMPI2C_RELOAD_MODE;
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
xfermode = FMPI2C_AUTOEND_MODE;
}else { ... }
if (hfmpi2c->XferSize > 0U)
{
hfmpi2c->Instance->TXDR = *hfmpi2c->pBuffPtr;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferCount--;
hfmpi2c->XferSize--;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)(hfmpi2c->XferSize + 1U), xfermode,
FMPI2C_GENERATE_START_WRITE);
}if (hfmpi2c->XferSize > 0U) { ... }
else
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, xfermode,
FMPI2C_GENERATE_START_WRITE);
}else { ... }
while (hfmpi2c->XferCount > 0U)
{
if (FMPI2C_WaitOnTXISFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnTXISFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK) { ... }
hfmpi2c->Instance->TXDR = *hfmpi2c->pBuffPtr;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferCount--;
hfmpi2c->XferSize--;
if ((hfmpi2c->XferCount != 0U) && (hfmpi2c->XferSize == 0U))
{
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_TCR, RESET, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_TCR, RESET, Timeout, tickstart) != HAL_OK) { ... }
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_RELOAD_MODE,
FMPI2C_NO_STARTSTOP);
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_AUTOEND_MODE,
FMPI2C_NO_STARTSTOP);
}else { ... }
}if ((hfmpi2c->XferCount != 0U) && (hfmpi2c->XferSize == 0U)) { ... }
}while (hfmpi2c->XferCount > 0U) { ... }
if (FMPI2C_WaitOnSTOPFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnSTOPFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK) { ... }
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
FMPI2C_RESET_CR2(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Master_Receive(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData,
uint16_t Size, uint32_t Timeout)
{
uint32_t tickstart;
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
__HAL_LOCK(hfmpi2c);
tickstart = HAL_GetTick();
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_BUSY, SET, FMPI2C_TIMEOUT_BUSY, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_BUSY, SET, FMPI2C_TIMEOUT_BUSY, tickstart) != HAL_OK) { ... }
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_RX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MASTER;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferISR = NULL;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = 1U;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_RELOAD_MODE,
FMPI2C_GENERATE_START_READ);
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_AUTOEND_MODE,
FMPI2C_GENERATE_START_READ);
}else { ... }
while (hfmpi2c->XferCount > 0U)
{
if (FMPI2C_WaitOnRXNEFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnRXNEFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK) { ... }
*hfmpi2c->pBuffPtr = (uint8_t)hfmpi2c->Instance->RXDR;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferSize--;
hfmpi2c->XferCount--;
if ((hfmpi2c->XferCount != 0U) && (hfmpi2c->XferSize == 0U))
{
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_TCR, RESET, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_TCR, RESET, Timeout, tickstart) != HAL_OK) { ... }
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_RELOAD_MODE,
FMPI2C_NO_STARTSTOP);
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_AUTOEND_MODE,
FMPI2C_NO_STARTSTOP);
}else { ... }
}if ((hfmpi2c->XferCount != 0U) && (hfmpi2c->XferSize == 0U)) { ... }
}while (hfmpi2c->XferCount > 0U) { ... }
if (FMPI2C_WaitOnSTOPFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnSTOPFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK) { ... }
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
FMPI2C_RESET_CR2(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Slave_Transmit(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size,
uint32_t Timeout)
{
uint32_t tickstart;
uint16_t tmpXferCount;
HAL_StatusTypeDef error;
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if ((pData == NULL) || (Size == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_INVALID_PARAM;
return HAL_ERROR;
}if ((pData == NULL) || (Size == 0U)) { ... }
__HAL_LOCK(hfmpi2c);
tickstart = HAL_GetTick();
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_TX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_SLAVE;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferISR = NULL;
hfmpi2c->Instance->CR2 &= ~FMPI2C_CR2_NACK;
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_ADDR, RESET, Timeout, tickstart) != HAL_OK)
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_ADDR, RESET, Timeout, tickstart) != HAL_OK) { ... }
if (hfmpi2c->Init.NoStretchMode == FMPI2C_NOSTRETCH_ENABLE)
{
hfmpi2c->Instance->TXDR = *hfmpi2c->pBuffPtr;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferCount--;
}if (hfmpi2c->Init.NoStretchMode == FMPI2C_NOSTRETCH_ENABLE) { ... }
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_ADDR);
if (hfmpi2c->Init.AddressingMode == FMPI2C_ADDRESSINGMODE_10BIT)
{
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_ADDR, RESET, Timeout, tickstart) != HAL_OK)
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_ADDR, RESET, Timeout, tickstart) != HAL_OK) { ... }
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_ADDR);
}if (hfmpi2c->Init.AddressingMode == FMPI2C_ADDRESSINGMODE_10BIT) { ... }
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_DIR, RESET, Timeout, tickstart) != HAL_OK)
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_DIR, RESET, Timeout, tickstart) != HAL_OK) { ... }
while (hfmpi2c->XferCount > 0U)
{
if (FMPI2C_WaitOnTXISFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK)
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
return HAL_ERROR;
}if (FMPI2C_WaitOnTXISFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK) { ... }
hfmpi2c->Instance->TXDR = *hfmpi2c->pBuffPtr;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferCount--;
}while (hfmpi2c->XferCount > 0U) { ... }
error = FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_AF, RESET, Timeout, tickstart);
if (error != HAL_OK)
{
tmpXferCount = hfmpi2c->XferCount;
if ((hfmpi2c->ErrorCode == HAL_FMPI2C_ERROR_AF) && (tmpXferCount == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
}if ((hfmpi2c->ErrorCode == HAL_FMPI2C_ERROR_AF) && (tmpXferCount == 0U)) { ... }
else
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
return HAL_ERROR;
}else { ... }
}if (error != HAL_OK) { ... }
else
{
FMPI2C_Flush_TXDR(hfmpi2c);
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
if (FMPI2C_WaitOnSTOPFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK)
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
return HAL_ERROR;
}if (FMPI2C_WaitOnSTOPFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK) { ... }
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
}else { ... }
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_BUSY, SET, Timeout, tickstart) != HAL_OK)
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_BUSY, SET, Timeout, tickstart) != HAL_OK) { ... }
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Slave_Receive(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size,
uint32_t Timeout)
{
uint32_t tickstart;
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if ((pData == NULL) || (Size == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_INVALID_PARAM;
return HAL_ERROR;
}if ((pData == NULL) || (Size == 0U)) { ... }
__HAL_LOCK(hfmpi2c);
tickstart = HAL_GetTick();
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_RX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_SLAVE;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferSize = hfmpi2c->XferCount;
hfmpi2c->XferISR = NULL;
hfmpi2c->Instance->CR2 &= ~FMPI2C_CR2_NACK;
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_ADDR, RESET, Timeout, tickstart) != HAL_OK)
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_ADDR, RESET, Timeout, tickstart) != HAL_OK) { ... }
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_ADDR);
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_DIR, SET, Timeout, tickstart) != HAL_OK)
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_DIR, SET, Timeout, tickstart) != HAL_OK) { ... }
while (hfmpi2c->XferCount > 0U)
{
if (FMPI2C_WaitOnRXNEFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK)
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_RXNE) == SET)
{
*hfmpi2c->pBuffPtr = (uint8_t)hfmpi2c->Instance->RXDR;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferCount--;
hfmpi2c->XferSize--;
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_RXNE) == SET) { ... }
return HAL_ERROR;
}if (FMPI2C_WaitOnRXNEFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK) { ... }
*hfmpi2c->pBuffPtr = (uint8_t)hfmpi2c->Instance->RXDR;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferCount--;
hfmpi2c->XferSize--;
}while (hfmpi2c->XferCount > 0U) { ... }
if (FMPI2C_WaitOnSTOPFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK)
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
return HAL_ERROR;
}if (FMPI2C_WaitOnSTOPFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK) { ... }
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_BUSY, SET, Timeout, tickstart) != HAL_OK)
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_BUSY, SET, Timeout, tickstart) != HAL_OK) { ... }
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Master_Transmit_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData,
uint16_t Size)
{
uint32_t xfermode;
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET)
{
return HAL_BUSY;
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET) { ... }
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_TX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MASTER;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->XferISR = FMPI2C_Master_ISR_IT;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
xfermode = FMPI2C_RELOAD_MODE;
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
xfermode = FMPI2C_AUTOEND_MODE;
}else { ... }
if (hfmpi2c->XferSize > 0U)
{
hfmpi2c->Instance->TXDR = *hfmpi2c->pBuffPtr;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferCount--;
hfmpi2c->XferSize--;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)(hfmpi2c->XferSize + 1U), xfermode,
FMPI2C_GENERATE_START_WRITE);
}if (hfmpi2c->XferSize > 0U) { ... }
else
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, xfermode,
FMPI2C_GENERATE_START_WRITE);
}else { ... }
__HAL_UNLOCK(hfmpi2c);
/* ... */
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Master_Receive_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData,
uint16_t Size)
{
uint32_t xfermode;
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET)
{
return HAL_BUSY;
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET) { ... }
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_RX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MASTER;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->XferISR = FMPI2C_Master_ISR_IT;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = 1U;
xfermode = FMPI2C_RELOAD_MODE;
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
xfermode = FMPI2C_AUTOEND_MODE;
}else { ... }
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, xfermode, FMPI2C_GENERATE_START_READ);
__HAL_UNLOCK(hfmpi2c);
/* ... */
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Slave_Transmit_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size)
{
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_TX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_SLAVE;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->Instance->CR2 &= ~FMPI2C_CR2_NACK;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferSize = hfmpi2c->XferCount;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->XferISR = FMPI2C_Slave_ISR_IT;
if (hfmpi2c->Init.NoStretchMode == FMPI2C_NOSTRETCH_ENABLE)
{
hfmpi2c->Instance->TXDR = *hfmpi2c->pBuffPtr;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferCount--;
hfmpi2c->XferSize--;
}if (hfmpi2c->Init.NoStretchMode == FMPI2C_NOSTRETCH_ENABLE) { ... }
__HAL_UNLOCK(hfmpi2c);
/* ... */
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT | FMPI2C_XFER_LISTEN_IT);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Slave_Receive_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size)
{
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_RX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_SLAVE;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->Instance->CR2 &= ~FMPI2C_CR2_NACK;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferSize = hfmpi2c->XferCount;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->XferISR = FMPI2C_Slave_ISR_IT;
__HAL_UNLOCK(hfmpi2c);
/* ... */
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT | FMPI2C_XFER_LISTEN_IT);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Master_Transmit_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData,
uint16_t Size)
{
uint32_t xfermode;
HAL_StatusTypeDef dmaxferstatus;
uint32_t sizetoxfer = 0U;
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET)
{
return HAL_BUSY;
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET) { ... }
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_TX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MASTER;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->XferISR = FMPI2C_Master_ISR_DMA;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
xfermode = FMPI2C_RELOAD_MODE;
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
xfermode = FMPI2C_AUTOEND_MODE;
}else { ... }
if (hfmpi2c->XferSize > 0U)
{
hfmpi2c->Instance->TXDR = *hfmpi2c->pBuffPtr;
hfmpi2c->pBuffPtr++;
sizetoxfer = hfmpi2c->XferSize;
hfmpi2c->XferCount--;
hfmpi2c->XferSize--;
}if (hfmpi2c->XferSize > 0U) { ... }
if (hfmpi2c->XferSize > 0U)
{
if (hfmpi2c->hdmatx != NULL)
{
hfmpi2c->hdmatx->XferCpltCallback = FMPI2C_DMAMasterTransmitCplt;
hfmpi2c->hdmatx->XferErrorCallback = FMPI2C_DMAError;
hfmpi2c->hdmatx->XferHalfCpltCallback = NULL;
hfmpi2c->hdmatx->XferAbortCallback = NULL;
dmaxferstatus = HAL_DMA_Start_IT(hfmpi2c->hdmatx, (uint32_t)hfmpi2c->pBuffPtr,
(uint32_t)&hfmpi2c->Instance->TXDR, hfmpi2c->XferSize);
}if (hfmpi2c->hdmatx != NULL) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA_PARAM;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
if (dmaxferstatus == HAL_OK)
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)(hfmpi2c->XferSize + 1U),
xfermode, FMPI2C_GENERATE_START_WRITE);
hfmpi2c->XferCount -= hfmpi2c->XferSize;
__HAL_UNLOCK(hfmpi2c);
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_ERROR_IT);
hfmpi2c->Instance->CR1 |= FMPI2C_CR1_TXDMAEN;
}if (dmaxferstatus == HAL_OK) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
}if (hfmpi2c->XferSize > 0U) { ... }
else
{
hfmpi2c->XferISR = FMPI2C_Master_ISR_IT;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)sizetoxfer, FMPI2C_AUTOEND_MODE,
FMPI2C_GENERATE_START_WRITE);
__HAL_UNLOCK(hfmpi2c);
/* ... */
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
}else { ... }
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Master_Receive_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData,
uint16_t Size)
{
uint32_t xfermode;
HAL_StatusTypeDef dmaxferstatus;
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET)
{
return HAL_BUSY;
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET) { ... }
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_RX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MASTER;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->XferISR = FMPI2C_Master_ISR_DMA;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = 1U;
xfermode = FMPI2C_RELOAD_MODE;
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
xfermode = FMPI2C_AUTOEND_MODE;
}else { ... }
if (hfmpi2c->XferSize > 0U)
{
if (hfmpi2c->hdmarx != NULL)
{
hfmpi2c->hdmarx->XferCpltCallback = FMPI2C_DMAMasterReceiveCplt;
hfmpi2c->hdmarx->XferErrorCallback = FMPI2C_DMAError;
hfmpi2c->hdmarx->XferHalfCpltCallback = NULL;
hfmpi2c->hdmarx->XferAbortCallback = NULL;
dmaxferstatus = HAL_DMA_Start_IT(hfmpi2c->hdmarx, (uint32_t)&hfmpi2c->Instance->RXDR, (uint32_t)pData,
hfmpi2c->XferSize);
}if (hfmpi2c->hdmarx != NULL) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA_PARAM;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
if (dmaxferstatus == HAL_OK)
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, xfermode, FMPI2C_GENERATE_START_READ);
hfmpi2c->XferCount -= hfmpi2c->XferSize;
__HAL_UNLOCK(hfmpi2c);
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_ERROR_IT);
hfmpi2c->Instance->CR1 |= FMPI2C_CR1_RXDMAEN;
}if (dmaxferstatus == HAL_OK) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
}if (hfmpi2c->XferSize > 0U) { ... }
else
{
hfmpi2c->XferISR = FMPI2C_Master_ISR_IT;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_AUTOEND_MODE,
FMPI2C_GENERATE_START_READ);
__HAL_UNLOCK(hfmpi2c);
/* ... */
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT);
}else { ... }
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Slave_Transmit_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size)
{
HAL_StatusTypeDef dmaxferstatus;
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if ((pData == NULL) || (Size == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_INVALID_PARAM;
return HAL_ERROR;
}if ((pData == NULL) || (Size == 0U)) { ... }
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_TX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_SLAVE;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferSize = hfmpi2c->XferCount;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->XferISR = FMPI2C_Slave_ISR_DMA;
if (hfmpi2c->Init.NoStretchMode == FMPI2C_NOSTRETCH_ENABLE)
{
hfmpi2c->Instance->TXDR = *hfmpi2c->pBuffPtr;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferCount--;
hfmpi2c->XferSize--;
}if (hfmpi2c->Init.NoStretchMode == FMPI2C_NOSTRETCH_ENABLE) { ... }
if (hfmpi2c->XferCount != 0U)
{
if (hfmpi2c->hdmatx != NULL)
{
hfmpi2c->hdmatx->XferCpltCallback = FMPI2C_DMASlaveTransmitCplt;
hfmpi2c->hdmatx->XferErrorCallback = FMPI2C_DMAError;
hfmpi2c->hdmatx->XferHalfCpltCallback = NULL;
hfmpi2c->hdmatx->XferAbortCallback = NULL;
dmaxferstatus = HAL_DMA_Start_IT(hfmpi2c->hdmatx,
(uint32_t)hfmpi2c->pBuffPtr, (uint32_t)&hfmpi2c->Instance->TXDR,
hfmpi2c->XferSize);
}if (hfmpi2c->hdmatx != NULL) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_LISTEN;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA_PARAM;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
if (dmaxferstatus == HAL_OK)
{
hfmpi2c->Instance->CR2 &= ~FMPI2C_CR2_NACK;
__HAL_UNLOCK(hfmpi2c);
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT);
hfmpi2c->Instance->CR1 |= FMPI2C_CR1_TXDMAEN;
}if (dmaxferstatus == HAL_OK) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_LISTEN;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
}if (hfmpi2c->XferCount != 0U) { ... }
else
{
hfmpi2c->Instance->CR2 &= ~FMPI2C_CR2_NACK;
__HAL_UNLOCK(hfmpi2c);
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT);
}else { ... }
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Slave_Receive_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size)
{
HAL_StatusTypeDef dmaxferstatus;
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if ((pData == NULL) || (Size == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_INVALID_PARAM;
return HAL_ERROR;
}if ((pData == NULL) || (Size == 0U)) { ... }
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_RX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_SLAVE;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferSize = hfmpi2c->XferCount;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->XferISR = FMPI2C_Slave_ISR_DMA;
if (hfmpi2c->hdmarx != NULL)
{
hfmpi2c->hdmarx->XferCpltCallback = FMPI2C_DMASlaveReceiveCplt;
hfmpi2c->hdmarx->XferErrorCallback = FMPI2C_DMAError;
hfmpi2c->hdmarx->XferHalfCpltCallback = NULL;
hfmpi2c->hdmarx->XferAbortCallback = NULL;
dmaxferstatus = HAL_DMA_Start_IT(hfmpi2c->hdmarx, (uint32_t)&hfmpi2c->Instance->RXDR, (uint32_t)pData,
hfmpi2c->XferSize);
}if (hfmpi2c->hdmarx != NULL) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_LISTEN;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA_PARAM;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
if (dmaxferstatus == HAL_OK)
{
hfmpi2c->Instance->CR2 &= ~FMPI2C_CR2_NACK;
__HAL_UNLOCK(hfmpi2c);
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT);
hfmpi2c->Instance->CR1 |= FMPI2C_CR1_RXDMAEN;
}if (dmaxferstatus == HAL_OK) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_LISTEN;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Mem_Write(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint16_t MemAddress,
uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout)
{
uint32_t tickstart;
assert_param(IS_FMPI2C_MEMADD_SIZE(MemAddSize));
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if ((pData == NULL) || (Size == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_INVALID_PARAM;
return HAL_ERROR;
}if ((pData == NULL) || (Size == 0U)) { ... }
__HAL_LOCK(hfmpi2c);
tickstart = HAL_GetTick();
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_BUSY, SET, FMPI2C_TIMEOUT_BUSY, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_BUSY, SET, FMPI2C_TIMEOUT_BUSY, tickstart) != HAL_OK) { ... }
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_TX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MEM;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferISR = NULL;
if (FMPI2C_RequestMemoryWrite(hfmpi2c, DevAddress, MemAddress, MemAddSize, Timeout, tickstart) != HAL_OK)
{
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}if (FMPI2C_RequestMemoryWrite(hfmpi2c, DevAddress, MemAddress, MemAddSize, Timeout, tickstart) != HAL_OK) { ... }
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_RELOAD_MODE, FMPI2C_NO_STARTSTOP);
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_AUTOEND_MODE, FMPI2C_NO_STARTSTOP);
}else { ... }
do
{
if (FMPI2C_WaitOnTXISFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnTXISFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK) { ... }
hfmpi2c->Instance->TXDR = *hfmpi2c->pBuffPtr;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferCount--;
hfmpi2c->XferSize--;
if ((hfmpi2c->XferCount != 0U) && (hfmpi2c->XferSize == 0U))
{
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_TCR, RESET, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_TCR, RESET, Timeout, tickstart) != HAL_OK) { ... }
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_RELOAD_MODE,
FMPI2C_NO_STARTSTOP);
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_AUTOEND_MODE,
FMPI2C_NO_STARTSTOP);
}else { ... }
}if ((hfmpi2c->XferCount != 0U) && (hfmpi2c->XferSize == 0U)) { ... }
...} while (hfmpi2c->XferCount > 0U);
if (FMPI2C_WaitOnSTOPFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnSTOPFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK) { ... }
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
FMPI2C_RESET_CR2(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Mem_Read(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint16_t MemAddress,
uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout)
{
uint32_t tickstart;
assert_param(IS_FMPI2C_MEMADD_SIZE(MemAddSize));
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if ((pData == NULL) || (Size == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_INVALID_PARAM;
return HAL_ERROR;
}if ((pData == NULL) || (Size == 0U)) { ... }
__HAL_LOCK(hfmpi2c);
tickstart = HAL_GetTick();
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_BUSY, SET, FMPI2C_TIMEOUT_BUSY, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_BUSY, SET, FMPI2C_TIMEOUT_BUSY, tickstart) != HAL_OK) { ... }
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_RX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MEM;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferISR = NULL;
if (FMPI2C_RequestMemoryRead(hfmpi2c, DevAddress, MemAddress, MemAddSize, Timeout, tickstart) != HAL_OK)
{
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}if (FMPI2C_RequestMemoryRead(hfmpi2c, DevAddress, MemAddress, MemAddSize, Timeout, tickstart) != HAL_OK) { ... }
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = 1U;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_RELOAD_MODE,
FMPI2C_GENERATE_START_READ);
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_AUTOEND_MODE,
FMPI2C_GENERATE_START_READ);
}else { ... }
do
{
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_RXNE, RESET, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_RXNE, RESET, Timeout, tickstart) != HAL_OK) { ... }
*hfmpi2c->pBuffPtr = (uint8_t)hfmpi2c->Instance->RXDR;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferSize--;
hfmpi2c->XferCount--;
if ((hfmpi2c->XferCount != 0U) && (hfmpi2c->XferSize == 0U))
{
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_TCR, RESET, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_TCR, RESET, Timeout, tickstart) != HAL_OK) { ... }
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = 1U;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t) hfmpi2c->XferSize, FMPI2C_RELOAD_MODE,
FMPI2C_NO_STARTSTOP);
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_AUTOEND_MODE,
FMPI2C_NO_STARTSTOP);
}else { ... }
}if ((hfmpi2c->XferCount != 0U) && (hfmpi2c->XferSize == 0U)) { ... }
...} while (hfmpi2c->XferCount > 0U);
if (FMPI2C_WaitOnSTOPFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnSTOPFlagUntilTimeout(hfmpi2c, Timeout, tickstart) != HAL_OK) { ... }
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
FMPI2C_RESET_CR2(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Mem_Write_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint16_t MemAddress,
uint16_t MemAddSize, uint8_t *pData, uint16_t Size)
{
assert_param(IS_FMPI2C_MEMADD_SIZE(MemAddSize));
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if ((pData == NULL) || (Size == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_INVALID_PARAM;
return HAL_ERROR;
}if ((pData == NULL) || (Size == 0U)) { ... }
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET)
{
return HAL_BUSY;
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET) { ... }
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_TX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MEM;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->XferSize = 0U;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->XferISR = FMPI2C_Mem_ISR_IT;
hfmpi2c->Devaddress = DevAddress;
if (MemAddSize == FMPI2C_MEMADD_SIZE_8BIT)
{
hfmpi2c->Instance->TXDR = FMPI2C_MEM_ADD_LSB(MemAddress);
hfmpi2c->Memaddress = 0xFFFFFFFFU;
}if (MemAddSize == FMPI2C_MEMADD_SIZE_8BIT) { ... }
else
{
hfmpi2c->Instance->TXDR = FMPI2C_MEM_ADD_MSB(MemAddress);
hfmpi2c->Memaddress = FMPI2C_MEM_ADD_LSB(MemAddress);
}else { ... }
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)MemAddSize, FMPI2C_RELOAD_MODE, FMPI2C_GENERATE_START_WRITE);
__HAL_UNLOCK(hfmpi2c);
/* ... */
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Mem_Read_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint16_t MemAddress,
uint16_t MemAddSize, uint8_t *pData, uint16_t Size)
{
assert_param(IS_FMPI2C_MEMADD_SIZE(MemAddSize));
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if ((pData == NULL) || (Size == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_INVALID_PARAM;
return HAL_ERROR;
}if ((pData == NULL) || (Size == 0U)) { ... }
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET)
{
return HAL_BUSY;
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET) { ... }
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_RX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MEM;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->XferISR = FMPI2C_Mem_ISR_IT;
hfmpi2c->Devaddress = DevAddress;
if (MemAddSize == FMPI2C_MEMADD_SIZE_8BIT)
{
hfmpi2c->Instance->TXDR = FMPI2C_MEM_ADD_LSB(MemAddress);
hfmpi2c->Memaddress = 0xFFFFFFFFU;
}if (MemAddSize == FMPI2C_MEMADD_SIZE_8BIT) { ... }
else
{
hfmpi2c->Instance->TXDR = FMPI2C_MEM_ADD_MSB(MemAddress);
hfmpi2c->Memaddress = FMPI2C_MEM_ADD_LSB(MemAddress);
}else { ... }
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)MemAddSize, FMPI2C_SOFTEND_MODE, FMPI2C_GENERATE_START_WRITE);
__HAL_UNLOCK(hfmpi2c);
/* ... */
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Mem_Write_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint16_t MemAddress,
uint16_t MemAddSize, uint8_t *pData, uint16_t Size)
{
HAL_StatusTypeDef dmaxferstatus;
assert_param(IS_FMPI2C_MEMADD_SIZE(MemAddSize));
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if ((pData == NULL) || (Size == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_INVALID_PARAM;
return HAL_ERROR;
}if ((pData == NULL) || (Size == 0U)) { ... }
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET)
{
return HAL_BUSY;
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET) { ... }
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_TX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MEM;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->XferISR = FMPI2C_Mem_ISR_DMA;
hfmpi2c->Devaddress = DevAddress;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
}else { ... }
if (MemAddSize == FMPI2C_MEMADD_SIZE_8BIT)
{
hfmpi2c->Instance->TXDR = FMPI2C_MEM_ADD_LSB(MemAddress);
hfmpi2c->Memaddress = 0xFFFFFFFFU;
}if (MemAddSize == FMPI2C_MEMADD_SIZE_8BIT) { ... }
else
{
hfmpi2c->Instance->TXDR = FMPI2C_MEM_ADD_MSB(MemAddress);
hfmpi2c->Memaddress = FMPI2C_MEM_ADD_LSB(MemAddress);
}else { ... }
if (hfmpi2c->hdmatx != NULL)
{
hfmpi2c->hdmatx->XferCpltCallback = FMPI2C_DMAMasterTransmitCplt;
hfmpi2c->hdmatx->XferErrorCallback = FMPI2C_DMAError;
hfmpi2c->hdmatx->XferHalfCpltCallback = NULL;
hfmpi2c->hdmatx->XferAbortCallback = NULL;
dmaxferstatus = HAL_DMA_Start_IT(hfmpi2c->hdmatx, (uint32_t)pData, (uint32_t)&hfmpi2c->Instance->TXDR,
hfmpi2c->XferSize);
}if (hfmpi2c->hdmatx != NULL) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA_PARAM;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
if (dmaxferstatus == HAL_OK)
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)MemAddSize, FMPI2C_RELOAD_MODE, FMPI2C_GENERATE_START_WRITE);
__HAL_UNLOCK(hfmpi2c);
/* ... */
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
}if (dmaxferstatus == HAL_OK) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Mem_Read_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint16_t MemAddress,
uint16_t MemAddSize, uint8_t *pData, uint16_t Size)
{
HAL_StatusTypeDef dmaxferstatus;
assert_param(IS_FMPI2C_MEMADD_SIZE(MemAddSize));
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if ((pData == NULL) || (Size == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_INVALID_PARAM;
return HAL_ERROR;
}if ((pData == NULL) || (Size == 0U)) { ... }
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET)
{
return HAL_BUSY;
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET) { ... }
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_RX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MEM;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->XferISR = FMPI2C_Mem_ISR_DMA;
hfmpi2c->Devaddress = DevAddress;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
}else { ... }
if (MemAddSize == FMPI2C_MEMADD_SIZE_8BIT)
{
hfmpi2c->Instance->TXDR = FMPI2C_MEM_ADD_LSB(MemAddress);
hfmpi2c->Memaddress = 0xFFFFFFFFU;
}if (MemAddSize == FMPI2C_MEMADD_SIZE_8BIT) { ... }
else
{
hfmpi2c->Instance->TXDR = FMPI2C_MEM_ADD_MSB(MemAddress);
hfmpi2c->Memaddress = FMPI2C_MEM_ADD_LSB(MemAddress);
}else { ... }
if (hfmpi2c->hdmarx != NULL)
{
hfmpi2c->hdmarx->XferCpltCallback = FMPI2C_DMAMasterReceiveCplt;
hfmpi2c->hdmarx->XferErrorCallback = FMPI2C_DMAError;
hfmpi2c->hdmarx->XferHalfCpltCallback = NULL;
hfmpi2c->hdmarx->XferAbortCallback = NULL;
dmaxferstatus = HAL_DMA_Start_IT(hfmpi2c->hdmarx, (uint32_t)&hfmpi2c->Instance->RXDR, (uint32_t)pData,
hfmpi2c->XferSize);
}if (hfmpi2c->hdmarx != NULL) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA_PARAM;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
if (dmaxferstatus == HAL_OK)
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)MemAddSize, FMPI2C_SOFTEND_MODE, FMPI2C_GENERATE_START_WRITE);
__HAL_UNLOCK(hfmpi2c);
/* ... */
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
}if (dmaxferstatus == HAL_OK) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_IsDeviceReady(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint32_t Trials,
uint32_t Timeout)
{
uint32_t tickstart;
__IO uint32_t FMPI2C_Trials = 0UL;
FlagStatus tmp1;
FlagStatus tmp2;
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET)
{
return HAL_BUSY;
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET) { ... }
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
do
{
hfmpi2c->Instance->CR2 = FMPI2C_GENERATE_START(hfmpi2c->Init.AddressingMode, DevAddress);
tickstart = HAL_GetTick();
tmp1 = __HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
tmp2 = __HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
while ((tmp1 == RESET) && (tmp2 == RESET))
{
if (Timeout != HAL_MAX_DELAY)
{
if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_TIMEOUT;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U)) { ... }
}if (Timeout != HAL_MAX_DELAY) { ... }
tmp1 = __HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
tmp2 = __HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
}while ((tmp1 == RESET) && (tmp2 == RESET)) { ... }
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_AF) == RESET)
{
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_STOPF, RESET, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_STOPF, RESET, Timeout, tickstart) != HAL_OK) { ... }
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
__HAL_UNLOCK(hfmpi2c);
return HAL_OK;
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_AF) == RESET) { ... }
else
{
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_STOPF, RESET, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_STOPF, RESET, Timeout, tickstart) != HAL_OK) { ... }
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
}else { ... }
FMPI2C_Trials++;
...} while (FMPI2C_Trials < Trials);
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_TIMEOUT;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Master_Seq_Transmit_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData,
uint16_t Size, uint32_t XferOptions)
{
uint32_t xfermode;
uint32_t xferrequest = FMPI2C_GENERATE_START_WRITE;
uint32_t sizetoxfer = 0U;
assert_param(IS_FMPI2C_TRANSFER_OPTIONS_REQUEST(XferOptions));
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_TX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MASTER;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferOptions = XferOptions;
hfmpi2c->XferISR = FMPI2C_Master_ISR_IT;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
xfermode = FMPI2C_RELOAD_MODE;
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
xfermode = hfmpi2c->XferOptions;
}else { ... }
if ((hfmpi2c->XferSize > 0U) && ((XferOptions == FMPI2C_FIRST_FRAME) || \
(XferOptions == FMPI2C_FIRST_AND_LAST_FRAME)))
{
hfmpi2c->Instance->TXDR = *hfmpi2c->pBuffPtr;
hfmpi2c->pBuffPtr++;
sizetoxfer = hfmpi2c->XferSize;
hfmpi2c->XferCount--;
hfmpi2c->XferSize--;
}if ((hfmpi2c->XferSize > 0U) && ((XferOptions == FMPI2C_FIRST_FRAME) || \ (XferOptions == FMPI2C_FIRST_AND_LAST_FRAME))) { ... }
/* ... */
if ((hfmpi2c->PreviousState == FMPI2C_STATE_MASTER_BUSY_TX) && \
(IS_FMPI2C_TRANSFER_OTHER_OPTIONS_REQUEST(XferOptions) == 0))
{
xferrequest = FMPI2C_NO_STARTSTOP;
}if ((hfmpi2c->PreviousState == FMPI2C_STATE_MASTER_BUSY_TX) && \ (IS_FMPI2C_TRANSFER_OTHER_OPTIONS_REQUEST(XferOptions) == 0)) { ... }
else
{
FMPI2C_ConvertOtherXferOptions(hfmpi2c);
if (hfmpi2c->XferCount <= MAX_NBYTE_SIZE)
{
xfermode = hfmpi2c->XferOptions;
}if (hfmpi2c->XferCount <= MAX_NBYTE_SIZE) { ... }
}else { ... }
if ((XferOptions == FMPI2C_FIRST_FRAME) || (XferOptions == FMPI2C_FIRST_AND_LAST_FRAME))
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)sizetoxfer, xfermode, xferrequest);
}if ((XferOptions == FMPI2C_FIRST_FRAME) || (XferOptions == FMPI2C_FIRST_AND_LAST_FRAME)) { ... }
else
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, xfermode, xferrequest);
}else { ... }
__HAL_UNLOCK(hfmpi2c);
/* ... */
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Master_Seq_Transmit_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData,
uint16_t Size, uint32_t XferOptions)
{
uint32_t xfermode;
uint32_t xferrequest = FMPI2C_GENERATE_START_WRITE;
HAL_StatusTypeDef dmaxferstatus;
uint32_t sizetoxfer = 0U;
assert_param(IS_FMPI2C_TRANSFER_OPTIONS_REQUEST(XferOptions));
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_TX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MASTER;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferOptions = XferOptions;
hfmpi2c->XferISR = FMPI2C_Master_ISR_DMA;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
xfermode = FMPI2C_RELOAD_MODE;
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
xfermode = hfmpi2c->XferOptions;
}else { ... }
if ((hfmpi2c->XferSize > 0U) && ((XferOptions == FMPI2C_FIRST_FRAME) || \
(XferOptions == FMPI2C_FIRST_AND_LAST_FRAME)))
{
hfmpi2c->Instance->TXDR = *hfmpi2c->pBuffPtr;
hfmpi2c->pBuffPtr++;
sizetoxfer = hfmpi2c->XferSize;
hfmpi2c->XferCount--;
hfmpi2c->XferSize--;
}if ((hfmpi2c->XferSize > 0U) && ((XferOptions == FMPI2C_FIRST_FRAME) || \ (XferOptions == FMPI2C_FIRST_AND_LAST_FRAME))) { ... }
/* ... */
if ((hfmpi2c->PreviousState == FMPI2C_STATE_MASTER_BUSY_TX) && \
(IS_FMPI2C_TRANSFER_OTHER_OPTIONS_REQUEST(XferOptions) == 0))
{
xferrequest = FMPI2C_NO_STARTSTOP;
}if ((hfmpi2c->PreviousState == FMPI2C_STATE_MASTER_BUSY_TX) && \ (IS_FMPI2C_TRANSFER_OTHER_OPTIONS_REQUEST(XferOptions) == 0)) { ... }
else
{
FMPI2C_ConvertOtherXferOptions(hfmpi2c);
if (hfmpi2c->XferCount <= MAX_NBYTE_SIZE)
{
xfermode = hfmpi2c->XferOptions;
}if (hfmpi2c->XferCount <= MAX_NBYTE_SIZE) { ... }
}else { ... }
if (hfmpi2c->XferSize > 0U)
{
if (hfmpi2c->hdmatx != NULL)
{
hfmpi2c->hdmatx->XferCpltCallback = FMPI2C_DMAMasterTransmitCplt;
hfmpi2c->hdmatx->XferErrorCallback = FMPI2C_DMAError;
hfmpi2c->hdmatx->XferHalfCpltCallback = NULL;
hfmpi2c->hdmatx->XferAbortCallback = NULL;
dmaxferstatus = HAL_DMA_Start_IT(hfmpi2c->hdmatx, (uint32_t)hfmpi2c->pBuffPtr,
(uint32_t)&hfmpi2c->Instance->TXDR, hfmpi2c->XferSize);
}if (hfmpi2c->hdmatx != NULL) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA_PARAM;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
if (dmaxferstatus == HAL_OK)
{
if ((XferOptions == FMPI2C_FIRST_FRAME) || (XferOptions == FMPI2C_FIRST_AND_LAST_FRAME))
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)sizetoxfer, xfermode, xferrequest);
}if ((XferOptions == FMPI2C_FIRST_FRAME) || (XferOptions == FMPI2C_FIRST_AND_LAST_FRAME)) { ... }
else
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, xfermode, xferrequest);
}else { ... }
hfmpi2c->XferCount -= hfmpi2c->XferSize;
__HAL_UNLOCK(hfmpi2c);
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_ERROR_IT);
hfmpi2c->Instance->CR1 |= FMPI2C_CR1_TXDMAEN;
}if (dmaxferstatus == HAL_OK) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
}if (hfmpi2c->XferSize > 0U) { ... }
else
{
hfmpi2c->XferISR = FMPI2C_Master_ISR_IT;
if ((XferOptions == FMPI2C_FIRST_FRAME) || (XferOptions == FMPI2C_FIRST_AND_LAST_FRAME))
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)sizetoxfer, xfermode, xferrequest);
}if ((XferOptions == FMPI2C_FIRST_FRAME) || (XferOptions == FMPI2C_FIRST_AND_LAST_FRAME)) { ... }
else
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, xfermode, xferrequest);
}else { ... }
__HAL_UNLOCK(hfmpi2c);
/* ... */
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
}else { ... }
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Master_Seq_Receive_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData,
uint16_t Size, uint32_t XferOptions)
{
uint32_t xfermode;
uint32_t xferrequest = FMPI2C_GENERATE_START_READ;
assert_param(IS_FMPI2C_TRANSFER_OPTIONS_REQUEST(XferOptions));
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_RX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MASTER;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferOptions = XferOptions;
hfmpi2c->XferISR = FMPI2C_Master_ISR_IT;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
xfermode = FMPI2C_RELOAD_MODE;
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
xfermode = hfmpi2c->XferOptions;
}else { ... }
/* ... */
if ((hfmpi2c->PreviousState == FMPI2C_STATE_MASTER_BUSY_RX) && \
(IS_FMPI2C_TRANSFER_OTHER_OPTIONS_REQUEST(XferOptions) == 0))
{
xferrequest = FMPI2C_NO_STARTSTOP;
}if ((hfmpi2c->PreviousState == FMPI2C_STATE_MASTER_BUSY_RX) && \ (IS_FMPI2C_TRANSFER_OTHER_OPTIONS_REQUEST(XferOptions) == 0)) { ... }
else
{
FMPI2C_ConvertOtherXferOptions(hfmpi2c);
if (hfmpi2c->XferCount <= MAX_NBYTE_SIZE)
{
xfermode = hfmpi2c->XferOptions;
}if (hfmpi2c->XferCount <= MAX_NBYTE_SIZE) { ... }
}else { ... }
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, xfermode, xferrequest);
__HAL_UNLOCK(hfmpi2c);
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Master_Seq_Receive_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData,
uint16_t Size, uint32_t XferOptions)
{
uint32_t xfermode;
uint32_t xferrequest = FMPI2C_GENERATE_START_READ;
HAL_StatusTypeDef dmaxferstatus;
assert_param(IS_FMPI2C_TRANSFER_OPTIONS_REQUEST(XferOptions));
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_RX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MASTER;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferOptions = XferOptions;
hfmpi2c->XferISR = FMPI2C_Master_ISR_DMA;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
xfermode = FMPI2C_RELOAD_MODE;
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
xfermode = hfmpi2c->XferOptions;
}else { ... }
/* ... */
if ((hfmpi2c->PreviousState == FMPI2C_STATE_MASTER_BUSY_RX) && \
(IS_FMPI2C_TRANSFER_OTHER_OPTIONS_REQUEST(XferOptions) == 0))
{
xferrequest = FMPI2C_NO_STARTSTOP;
}if ((hfmpi2c->PreviousState == FMPI2C_STATE_MASTER_BUSY_RX) && \ (IS_FMPI2C_TRANSFER_OTHER_OPTIONS_REQUEST(XferOptions) == 0)) { ... }
else
{
FMPI2C_ConvertOtherXferOptions(hfmpi2c);
if (hfmpi2c->XferCount <= MAX_NBYTE_SIZE)
{
xfermode = hfmpi2c->XferOptions;
}if (hfmpi2c->XferCount <= MAX_NBYTE_SIZE) { ... }
}else { ... }
if (hfmpi2c->XferSize > 0U)
{
if (hfmpi2c->hdmarx != NULL)
{
hfmpi2c->hdmarx->XferCpltCallback = FMPI2C_DMAMasterReceiveCplt;
hfmpi2c->hdmarx->XferErrorCallback = FMPI2C_DMAError;
hfmpi2c->hdmarx->XferHalfCpltCallback = NULL;
hfmpi2c->hdmarx->XferAbortCallback = NULL;
dmaxferstatus = HAL_DMA_Start_IT(hfmpi2c->hdmarx, (uint32_t)&hfmpi2c->Instance->RXDR, (uint32_t)pData,
hfmpi2c->XferSize);
}if (hfmpi2c->hdmarx != NULL) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA_PARAM;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
if (dmaxferstatus == HAL_OK)
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, xfermode, xferrequest);
hfmpi2c->XferCount -= hfmpi2c->XferSize;
__HAL_UNLOCK(hfmpi2c);
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_ERROR_IT);
hfmpi2c->Instance->CR1 |= FMPI2C_CR1_RXDMAEN;
}if (dmaxferstatus == HAL_OK) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
}if (hfmpi2c->XferSize > 0U) { ... }
else
{
hfmpi2c->XferISR = FMPI2C_Master_ISR_IT;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_AUTOEND_MODE,
FMPI2C_GENERATE_START_READ);
__HAL_UNLOCK(hfmpi2c);
/* ... */
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT);
}else { ... }
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Slave_Seq_Transmit_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size,
uint32_t XferOptions)
{
FlagStatus tmp;
assert_param(IS_FMPI2C_TRANSFER_OPTIONS_REQUEST(XferOptions));
if (((uint32_t)hfmpi2c->State & (uint32_t)HAL_FMPI2C_STATE_LISTEN) == (uint32_t)HAL_FMPI2C_STATE_LISTEN)
{
if ((pData == NULL) || (Size == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_INVALID_PARAM;
return HAL_ERROR;
}if ((pData == NULL) || (Size == 0U)) { ... }
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT | FMPI2C_XFER_TX_IT);
__HAL_LOCK(hfmpi2c);
if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX_LISTEN)
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT);
if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_RXDMAEN) == FMPI2C_CR1_RXDMAEN)
{
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_RXDMAEN;
if (hfmpi2c->hdmarx != NULL)
{
/* ... */
hfmpi2c->hdmarx->XferAbortCallback = FMPI2C_DMAAbort;
if (HAL_DMA_Abort_IT(hfmpi2c->hdmarx) != HAL_OK)
{
hfmpi2c->hdmarx->XferAbortCallback(hfmpi2c->hdmarx);
}if (HAL_DMA_Abort_IT(hfmpi2c->hdmarx) != HAL_OK) { ... }
}if (hfmpi2c->hdmarx != NULL) { ... }
}if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_RXDMAEN) == FMPI2C_CR1_RXDMAEN) { ... }
}if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX_LISTEN) { ... }
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_TX_LISTEN;
hfmpi2c->Mode = HAL_FMPI2C_MODE_SLAVE;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->Instance->CR2 &= ~FMPI2C_CR2_NACK;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferSize = hfmpi2c->XferCount;
hfmpi2c->XferOptions = XferOptions;
hfmpi2c->XferISR = FMPI2C_Slave_ISR_IT;
tmp = __HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_ADDR);
if ((FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE) && (tmp != RESET))
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_ADDR);
}if ((FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE) && (tmp != RESET)) { ... }
__HAL_UNLOCK(hfmpi2c);
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT | FMPI2C_XFER_LISTEN_IT);
return HAL_OK;
}if (((uint32_t)hfmpi2c->State & (uint32_t)HAL_FMPI2C_STATE_LISTEN) == (uint32_t)HAL_FMPI2C_STATE_LISTEN) { ... }
else
{
return HAL_ERROR;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Slave_Seq_Transmit_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size,
uint32_t XferOptions)
{
FlagStatus tmp;
HAL_StatusTypeDef dmaxferstatus;
assert_param(IS_FMPI2C_TRANSFER_OPTIONS_REQUEST(XferOptions));
if (((uint32_t)hfmpi2c->State & (uint32_t)HAL_FMPI2C_STATE_LISTEN) == (uint32_t)HAL_FMPI2C_STATE_LISTEN)
{
if ((pData == NULL) || (Size == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_INVALID_PARAM;
return HAL_ERROR;
}if ((pData == NULL) || (Size == 0U)) { ... }
__HAL_LOCK(hfmpi2c);
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT | FMPI2C_XFER_TX_IT);
if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX_LISTEN)
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT);
if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_RXDMAEN) == FMPI2C_CR1_RXDMAEN)
{
if (hfmpi2c->hdmarx != NULL)
{
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_RXDMAEN;
/* ... */
hfmpi2c->hdmarx->XferAbortCallback = FMPI2C_DMAAbort;
if (HAL_DMA_Abort_IT(hfmpi2c->hdmarx) != HAL_OK)
{
hfmpi2c->hdmarx->XferAbortCallback(hfmpi2c->hdmarx);
}if (HAL_DMA_Abort_IT(hfmpi2c->hdmarx) != HAL_OK) { ... }
}if (hfmpi2c->hdmarx != NULL) { ... }
}if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_RXDMAEN) == FMPI2C_CR1_RXDMAEN) { ... }
}if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX_LISTEN) { ... }
else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX_LISTEN)
{
if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_TXDMAEN) == FMPI2C_CR1_TXDMAEN)
{
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_TXDMAEN;
if (hfmpi2c->hdmatx != NULL)
{
/* ... */
hfmpi2c->hdmatx->XferAbortCallback = FMPI2C_DMAAbort;
if (HAL_DMA_Abort_IT(hfmpi2c->hdmatx) != HAL_OK)
{
hfmpi2c->hdmatx->XferAbortCallback(hfmpi2c->hdmatx);
}if (HAL_DMA_Abort_IT(hfmpi2c->hdmatx) != HAL_OK) { ... }
}if (hfmpi2c->hdmatx != NULL) { ... }
}if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_TXDMAEN) == FMPI2C_CR1_TXDMAEN) { ... }
}else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX_LISTEN) { ... }
else
{
}else { ... }
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_TX_LISTEN;
hfmpi2c->Mode = HAL_FMPI2C_MODE_SLAVE;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->Instance->CR2 &= ~FMPI2C_CR2_NACK;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferSize = hfmpi2c->XferCount;
hfmpi2c->XferOptions = XferOptions;
hfmpi2c->XferISR = FMPI2C_Slave_ISR_DMA;
if (hfmpi2c->hdmatx != NULL)
{
hfmpi2c->hdmatx->XferCpltCallback = FMPI2C_DMASlaveTransmitCplt;
hfmpi2c->hdmatx->XferErrorCallback = FMPI2C_DMAError;
hfmpi2c->hdmatx->XferHalfCpltCallback = NULL;
hfmpi2c->hdmatx->XferAbortCallback = NULL;
dmaxferstatus = HAL_DMA_Start_IT(hfmpi2c->hdmatx, (uint32_t)pData, (uint32_t)&hfmpi2c->Instance->TXDR,
hfmpi2c->XferSize);
}if (hfmpi2c->hdmatx != NULL) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_LISTEN;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA_PARAM;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
if (dmaxferstatus == HAL_OK)
{
hfmpi2c->XferCount -= hfmpi2c->XferSize;
hfmpi2c->XferSize = 0;
}if (dmaxferstatus == HAL_OK) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_LISTEN;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
tmp = __HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_ADDR);
if ((FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE) && (tmp != RESET))
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_ADDR);
}if ((FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE) && (tmp != RESET)) { ... }
__HAL_UNLOCK(hfmpi2c);
hfmpi2c->Instance->CR1 |= FMPI2C_CR1_TXDMAEN;
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT);
return HAL_OK;
}if (((uint32_t)hfmpi2c->State & (uint32_t)HAL_FMPI2C_STATE_LISTEN) == (uint32_t)HAL_FMPI2C_STATE_LISTEN) { ... }
else
{
return HAL_ERROR;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Slave_Seq_Receive_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size,
uint32_t XferOptions)
{
FlagStatus tmp;
assert_param(IS_FMPI2C_TRANSFER_OPTIONS_REQUEST(XferOptions));
if (((uint32_t)hfmpi2c->State & (uint32_t)HAL_FMPI2C_STATE_LISTEN) == (uint32_t)HAL_FMPI2C_STATE_LISTEN)
{
if ((pData == NULL) || (Size == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_INVALID_PARAM;
return HAL_ERROR;
}if ((pData == NULL) || (Size == 0U)) { ... }
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT | FMPI2C_XFER_RX_IT);
__HAL_LOCK(hfmpi2c);
if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX_LISTEN)
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_TXDMAEN) == FMPI2C_CR1_TXDMAEN)
{
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_TXDMAEN;
if (hfmpi2c->hdmatx != NULL)
{
/* ... */
hfmpi2c->hdmatx->XferAbortCallback = FMPI2C_DMAAbort;
if (HAL_DMA_Abort_IT(hfmpi2c->hdmatx) != HAL_OK)
{
hfmpi2c->hdmatx->XferAbortCallback(hfmpi2c->hdmatx);
}if (HAL_DMA_Abort_IT(hfmpi2c->hdmatx) != HAL_OK) { ... }
}if (hfmpi2c->hdmatx != NULL) { ... }
}if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_TXDMAEN) == FMPI2C_CR1_TXDMAEN) { ... }
}if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX_LISTEN) { ... }
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_RX_LISTEN;
hfmpi2c->Mode = HAL_FMPI2C_MODE_SLAVE;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->Instance->CR2 &= ~FMPI2C_CR2_NACK;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferSize = hfmpi2c->XferCount;
hfmpi2c->XferOptions = XferOptions;
hfmpi2c->XferISR = FMPI2C_Slave_ISR_IT;
tmp = __HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_ADDR);
if ((FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_TRANSMIT) && (tmp != RESET))
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_ADDR);
}if ((FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_TRANSMIT) && (tmp != RESET)) { ... }
__HAL_UNLOCK(hfmpi2c);
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT | FMPI2C_XFER_LISTEN_IT);
return HAL_OK;
}if (((uint32_t)hfmpi2c->State & (uint32_t)HAL_FMPI2C_STATE_LISTEN) == (uint32_t)HAL_FMPI2C_STATE_LISTEN) { ... }
else
{
return HAL_ERROR;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Slave_Seq_Receive_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size,
uint32_t XferOptions)
{
FlagStatus tmp;
HAL_StatusTypeDef dmaxferstatus;
assert_param(IS_FMPI2C_TRANSFER_OPTIONS_REQUEST(XferOptions));
if (((uint32_t)hfmpi2c->State & (uint32_t)HAL_FMPI2C_STATE_LISTEN) == (uint32_t)HAL_FMPI2C_STATE_LISTEN)
{
if ((pData == NULL) || (Size == 0U))
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_INVALID_PARAM;
return HAL_ERROR;
}if ((pData == NULL) || (Size == 0U)) { ... }
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT | FMPI2C_XFER_RX_IT);
__HAL_LOCK(hfmpi2c);
if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX_LISTEN)
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_TXDMAEN) == FMPI2C_CR1_TXDMAEN)
{
if (hfmpi2c->hdmatx != NULL)
{
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_TXDMAEN;
/* ... */
hfmpi2c->hdmatx->XferAbortCallback = FMPI2C_DMAAbort;
if (HAL_DMA_Abort_IT(hfmpi2c->hdmatx) != HAL_OK)
{
hfmpi2c->hdmatx->XferAbortCallback(hfmpi2c->hdmatx);
}if (HAL_DMA_Abort_IT(hfmpi2c->hdmatx) != HAL_OK) { ... }
}if (hfmpi2c->hdmatx != NULL) { ... }
}if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_TXDMAEN) == FMPI2C_CR1_TXDMAEN) { ... }
}if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX_LISTEN) { ... }
else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX_LISTEN)
{
if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_RXDMAEN) == FMPI2C_CR1_RXDMAEN)
{
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_RXDMAEN;
if (hfmpi2c->hdmarx != NULL)
{
/* ... */
hfmpi2c->hdmarx->XferAbortCallback = FMPI2C_DMAAbort;
if (HAL_DMA_Abort_IT(hfmpi2c->hdmarx) != HAL_OK)
{
hfmpi2c->hdmarx->XferAbortCallback(hfmpi2c->hdmarx);
}if (HAL_DMA_Abort_IT(hfmpi2c->hdmarx) != HAL_OK) { ... }
}if (hfmpi2c->hdmarx != NULL) { ... }
}if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_RXDMAEN) == FMPI2C_CR1_RXDMAEN) { ... }
}else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX_LISTEN) { ... }
else
{
}else { ... }
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_RX_LISTEN;
hfmpi2c->Mode = HAL_FMPI2C_MODE_SLAVE;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
hfmpi2c->Instance->CR2 &= ~FMPI2C_CR2_NACK;
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferSize = hfmpi2c->XferCount;
hfmpi2c->XferOptions = XferOptions;
hfmpi2c->XferISR = FMPI2C_Slave_ISR_DMA;
if (hfmpi2c->hdmarx != NULL)
{
hfmpi2c->hdmarx->XferCpltCallback = FMPI2C_DMASlaveReceiveCplt;
hfmpi2c->hdmarx->XferErrorCallback = FMPI2C_DMAError;
hfmpi2c->hdmarx->XferHalfCpltCallback = NULL;
hfmpi2c->hdmarx->XferAbortCallback = NULL;
dmaxferstatus = HAL_DMA_Start_IT(hfmpi2c->hdmarx, (uint32_t)&hfmpi2c->Instance->RXDR,
(uint32_t)pData, hfmpi2c->XferSize);
}if (hfmpi2c->hdmarx != NULL) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_LISTEN;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA_PARAM;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
if (dmaxferstatus == HAL_OK)
{
hfmpi2c->XferCount -= hfmpi2c->XferSize;
hfmpi2c->XferSize = 0;
}if (dmaxferstatus == HAL_OK) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_LISTEN;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_DMA;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}else { ... }
tmp = __HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_ADDR);
if ((FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_TRANSMIT) && (tmp != RESET))
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_ADDR);
}if ((FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_TRANSMIT) && (tmp != RESET)) { ... }
__HAL_UNLOCK(hfmpi2c);
hfmpi2c->Instance->CR1 |= FMPI2C_CR1_RXDMAEN;
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT | FMPI2C_XFER_LISTEN_IT);
return HAL_OK;
}if (((uint32_t)hfmpi2c->State & (uint32_t)HAL_FMPI2C_STATE_LISTEN) == (uint32_t)HAL_FMPI2C_STATE_LISTEN) { ... }
else
{
return HAL_ERROR;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_EnableListen_IT(FMPI2C_HandleTypeDef *hfmpi2c)
{
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
hfmpi2c->State = HAL_FMPI2C_STATE_LISTEN;
hfmpi2c->XferISR = FMPI2C_Slave_ISR_IT;
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_DisableListen_IT(FMPI2C_HandleTypeDef *hfmpi2c)
{
uint32_t tmp;
if (hfmpi2c->State == HAL_FMPI2C_STATE_LISTEN)
{
tmp = (uint32_t)(hfmpi2c->State) & FMPI2C_STATE_MSK;
hfmpi2c->PreviousState = tmp | (uint32_t)(hfmpi2c->Mode);
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->XferISR = NULL;
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT);
return HAL_OK;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_LISTEN) { ... }
else
{
return HAL_BUSY;
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_FMPI2C_Master_Abort_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress)
{
if (hfmpi2c->Mode == HAL_FMPI2C_MODE_MASTER)
{
__HAL_LOCK(hfmpi2c);
if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX)
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
hfmpi2c->PreviousState = FMPI2C_STATE_MASTER_BUSY_TX;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX) { ... }
else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX)
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT);
hfmpi2c->PreviousState = FMPI2C_STATE_MASTER_BUSY_RX;
}else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX) { ... }
else
{
}else { ... }
hfmpi2c->State = HAL_FMPI2C_STATE_ABORT;
FMPI2C_TransferConfig(hfmpi2c, DevAddress, 1, FMPI2C_AUTOEND_MODE, FMPI2C_GENERATE_STOP);
__HAL_UNLOCK(hfmpi2c);
/* ... */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_CPLT_IT);
return HAL_OK;
}if (hfmpi2c->Mode == HAL_FMPI2C_MODE_MASTER) { ... }
else
{
return HAL_ERROR;
}else { ... }
}{ ... }
/* ... */
/* ... */
/* ... */
void HAL_FMPI2C_EV_IRQHandler(FMPI2C_HandleTypeDef *hfmpi2c)
{
uint32_t itflags = READ_REG(hfmpi2c->Instance->ISR);
uint32_t itsources = READ_REG(hfmpi2c->Instance->CR1);
if (hfmpi2c->XferISR != NULL)
{
hfmpi2c->XferISR(hfmpi2c, itflags, itsources);
}if (hfmpi2c->XferISR != NULL) { ... }
...}
/* ... */
void HAL_FMPI2C_ER_IRQHandler(FMPI2C_HandleTypeDef *hfmpi2c)
{
uint32_t itflags = READ_REG(hfmpi2c->Instance->ISR);
uint32_t itsources = READ_REG(hfmpi2c->Instance->CR1);
uint32_t tmperror;
if ((FMPI2C_CHECK_FLAG(itflags, FMPI2C_FLAG_BERR) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(itsources, FMPI2C_IT_ERRI) != RESET))
{
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_BERR;
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_BERR);
}if ((FMPI2C_CHECK_FLAG(itflags, FMPI2C_FLAG_BERR) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(itsources, FMPI2C_IT_ERRI) != RESET)) { ... }
FMPI2C Bus error interrupt occurred
if ((FMPI2C_CHECK_FLAG(itflags, FMPI2C_FLAG_OVR) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(itsources, FMPI2C_IT_ERRI) != RESET))
{
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_OVR;
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_OVR);
}if ((FMPI2C_CHECK_FLAG(itflags, FMPI2C_FLAG_OVR) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(itsources, FMPI2C_IT_ERRI) != RESET)) { ... }
FMPI2C Over-Run/Under-Run interrupt occurred
if ((FMPI2C_CHECK_FLAG(itflags, FMPI2C_FLAG_ARLO) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(itsources, FMPI2C_IT_ERRI) != RESET))
{
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_ARLO;
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_ARLO);
}if ((FMPI2C_CHECK_FLAG(itflags, FMPI2C_FLAG_ARLO) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(itsources, FMPI2C_IT_ERRI) != RESET)) { ... }
tmperror = hfmpi2c->ErrorCode;
if ((tmperror & (HAL_FMPI2C_ERROR_BERR | HAL_FMPI2C_ERROR_OVR | HAL_FMPI2C_ERROR_ARLO)) != HAL_FMPI2C_ERROR_NONE)
{
FMPI2C_ITError(hfmpi2c, tmperror);
}if ((tmperror & (HAL_FMPI2C_ERROR_BERR | HAL_FMPI2C_ERROR_OVR | HAL_FMPI2C_ERROR_ARLO)) != HAL_FMPI2C_ERROR_NONE) { ... }
}{ ... }
/* ... */
__weak void HAL_FMPI2C_MasterTxCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c)
{
UNUSED(hfmpi2c);
/* ... */
}{ ... }
/* ... */
__weak void HAL_FMPI2C_MasterRxCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c)
{
UNUSED(hfmpi2c);
/* ... */
}{ ... }
/* ... */
__weak void HAL_FMPI2C_SlaveTxCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c)
{
UNUSED(hfmpi2c);
/* ... */
}{ ... }
/* ... */
__weak void HAL_FMPI2C_SlaveRxCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c)
{
UNUSED(hfmpi2c);
/* ... */
}{ ... }
/* ... */
__weak void HAL_FMPI2C_AddrCallback(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t TransferDirection, uint16_t AddrMatchCode)
{
UNUSED(hfmpi2c);
UNUSED(TransferDirection);
UNUSED(AddrMatchCode);
/* ... */
}{ ... }
/* ... */
__weak void HAL_FMPI2C_ListenCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c)
{
UNUSED(hfmpi2c);
/* ... */
}{ ... }
/* ... */
__weak void HAL_FMPI2C_MemTxCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c)
{
UNUSED(hfmpi2c);
/* ... */
}{ ... }
/* ... */
__weak void HAL_FMPI2C_MemRxCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c)
{
UNUSED(hfmpi2c);
/* ... */
}{ ... }
/* ... */
__weak void HAL_FMPI2C_ErrorCallback(FMPI2C_HandleTypeDef *hfmpi2c)
{
UNUSED(hfmpi2c);
/* ... */
}{ ... }
/* ... */
__weak void HAL_FMPI2C_AbortCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c)
{
UNUSED(hfmpi2c);
/* ... */
}{ ... }
/* ... */
/* ... */
/* ... */
HAL_FMPI2C_StateTypeDef HAL_FMPI2C_GetState(const FMPI2C_HandleTypeDef *hfmpi2c)
{
return hfmpi2c->State;
}{ ... }
/* ... */
HAL_FMPI2C_ModeTypeDef HAL_FMPI2C_GetMode(const FMPI2C_HandleTypeDef *hfmpi2c)
{
return hfmpi2c->Mode;
}{ ... }
/* ... */
uint32_t HAL_FMPI2C_GetError(const FMPI2C_HandleTypeDef *hfmpi2c)
{
return hfmpi2c->ErrorCode;
}{ ... }
/* ... */
/* ... */
/* ... */
/* ... */
static HAL_StatusTypeDef FMPI2C_Master_ISR_IT(struct __FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags,
uint32_t ITSources)
{
uint16_t devaddress;
uint32_t tmpITFlags = ITFlags;
__HAL_LOCK(hfmpi2c);
if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_AF) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_NACKI) != RESET))
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_AF;
FMPI2C_Flush_TXDR(hfmpi2c);
}if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_AF) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_NACKI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_RXNE) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_RXI) != RESET))
{
tmpITFlags &= ~FMPI2C_FLAG_RXNE;
*hfmpi2c->pBuffPtr = (uint8_t)hfmpi2c->Instance->RXDR;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferSize--;
hfmpi2c->XferCount--;
}else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_RXNE) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_RXI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TC) == RESET) && \
((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TXIS) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TXI) != RESET)))
{
if (hfmpi2c->XferCount != 0U)
{
hfmpi2c->Instance->TXDR = *hfmpi2c->pBuffPtr;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferSize--;
hfmpi2c->XferCount--;
}if (hfmpi2c->XferCount != 0U) { ... }
}else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TC) == RESET) && \ ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TXIS) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TXI) != RESET))) { ... }
else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TCR) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET))
{
if ((hfmpi2c->XferCount != 0U) && (hfmpi2c->XferSize == 0U))
{
devaddress = (uint16_t)(hfmpi2c->Instance->CR2 & FMPI2C_CR2_SADD);
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
if (FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE)
{
hfmpi2c->XferSize = 1U;
}if (FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE) { ... }
else
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
}else { ... }
FMPI2C_TransferConfig(hfmpi2c, devaddress, (uint8_t)hfmpi2c->XferSize, FMPI2C_RELOAD_MODE, FMPI2C_NO_STARTSTOP);
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
if (hfmpi2c->XferOptions != FMPI2C_NO_OPTION_FRAME)
{
FMPI2C_TransferConfig(hfmpi2c, devaddress, (uint8_t)hfmpi2c->XferSize,
hfmpi2c->XferOptions, FMPI2C_NO_STARTSTOP);
}if (hfmpi2c->XferOptions != FMPI2C_NO_OPTION_FRAME) { ... }
else
{
FMPI2C_TransferConfig(hfmpi2c, devaddress, (uint8_t)hfmpi2c->XferSize,
FMPI2C_AUTOEND_MODE, FMPI2C_NO_STARTSTOP);
}else { ... }
}else { ... }
}if ((hfmpi2c->XferCount != 0U) && (hfmpi2c->XferSize == 0U)) { ... }
else
{
if (FMPI2C_GET_STOP_MODE(hfmpi2c) != FMPI2C_AUTOEND_MODE)
{
FMPI2C_ITMasterSeqCplt(hfmpi2c);
}if (FMPI2C_GET_STOP_MODE(hfmpi2c) != FMPI2C_AUTOEND_MODE) { ... }
else
{
FMPI2C_ITError(hfmpi2c, HAL_FMPI2C_ERROR_SIZE);
}else { ... }
}else { ... }
}else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TCR) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TC) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET))
{
if (hfmpi2c->XferCount == 0U)
{
if (FMPI2C_GET_STOP_MODE(hfmpi2c) != FMPI2C_AUTOEND_MODE)
{
if (hfmpi2c->XferOptions == FMPI2C_NO_OPTION_FRAME)
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_STOP;
}if (hfmpi2c->XferOptions == FMPI2C_NO_OPTION_FRAME) { ... }
else
{
FMPI2C_ITMasterSeqCplt(hfmpi2c);
}else { ... }
}if (FMPI2C_GET_STOP_MODE(hfmpi2c) != FMPI2C_AUTOEND_MODE) { ... }
}if (hfmpi2c->XferCount == 0U) { ... }
else
{
FMPI2C_ITError(hfmpi2c, HAL_FMPI2C_ERROR_SIZE);
}else { ... }
}else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TC) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET)) { ... }
else
{
}else { ... }
if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_STOPF) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_STOPI) != RESET))
{
FMPI2C_ITMasterCplt(hfmpi2c, tmpITFlags);
}if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_STOPF) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_STOPI) != RESET)) { ... }
__HAL_UNLOCK(hfmpi2c);
return HAL_OK;
}{ ... }
/* ... */
static HAL_StatusTypeDef FMPI2C_Mem_ISR_IT(struct __FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags,
uint32_t ITSources)
{
uint32_t direction = FMPI2C_GENERATE_START_WRITE;
uint32_t tmpITFlags = ITFlags;
__HAL_LOCK(hfmpi2c);
if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_AF) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_NACKI) != RESET))
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_AF;
FMPI2C_Flush_TXDR(hfmpi2c);
}if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_AF) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_NACKI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_RXNE) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_RXI) != RESET))
{
tmpITFlags &= ~FMPI2C_FLAG_RXNE;
*hfmpi2c->pBuffPtr = (uint8_t)hfmpi2c->Instance->RXDR;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferSize--;
hfmpi2c->XferCount--;
}else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_RXNE) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_RXI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TXIS) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TXI) != RESET))
{
if (hfmpi2c->Memaddress == 0xFFFFFFFFU)
{
hfmpi2c->Instance->TXDR = *hfmpi2c->pBuffPtr;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferSize--;
hfmpi2c->XferCount--;
}if (hfmpi2c->Memaddress == 0xFFFFFFFFU) { ... }
else
{
hfmpi2c->Instance->TXDR = hfmpi2c->Memaddress;
hfmpi2c->Memaddress = 0xFFFFFFFFU;
}else { ... }
}else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TXIS) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TXI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TCR) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET))
{
if ((hfmpi2c->XferCount != 0U) && (hfmpi2c->XferSize == 0U))
{
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
if (FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE)
{
hfmpi2c->XferSize = 1U;
}if (FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE) { ... }
else
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
}else { ... }
FMPI2C_TransferConfig(hfmpi2c, (uint16_t)hfmpi2c->Devaddress, (uint8_t)hfmpi2c->XferSize,
FMPI2C_RELOAD_MODE, FMPI2C_NO_STARTSTOP);
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
FMPI2C_TransferConfig(hfmpi2c, (uint16_t)hfmpi2c->Devaddress, (uint8_t)hfmpi2c->XferSize,
FMPI2C_AUTOEND_MODE, FMPI2C_NO_STARTSTOP);
}else { ... }
}if ((hfmpi2c->XferCount != 0U) && (hfmpi2c->XferSize == 0U)) { ... }
else
{
FMPI2C_ITError(hfmpi2c, HAL_FMPI2C_ERROR_SIZE);
}else { ... }
}else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TCR) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TC) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET))
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT);
if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX)
{
direction = FMPI2C_GENERATE_START_READ;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX) { ... }
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
if (FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE)
{
hfmpi2c->XferSize = 1U;
}if (FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE) { ... }
else
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
}else { ... }
FMPI2C_TransferConfig(hfmpi2c, (uint16_t)hfmpi2c->Devaddress, (uint8_t)hfmpi2c->XferSize,
FMPI2C_RELOAD_MODE, direction);
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
FMPI2C_TransferConfig(hfmpi2c, (uint16_t)hfmpi2c->Devaddress, (uint8_t)hfmpi2c->XferSize,
FMPI2C_AUTOEND_MODE, direction);
}else { ... }
}else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TC) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET)) { ... }
else
{
}else { ... }
if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_STOPF) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_STOPI) != RESET))
{
FMPI2C_ITMasterCplt(hfmpi2c, tmpITFlags);
}if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_STOPF) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_STOPI) != RESET)) { ... }
__HAL_UNLOCK(hfmpi2c);
return HAL_OK;
}{ ... }
/* ... */
static HAL_StatusTypeDef FMPI2C_Slave_ISR_IT(struct __FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags,
uint32_t ITSources)
{
uint32_t tmpoptions = hfmpi2c->XferOptions;
uint32_t tmpITFlags = ITFlags;
__HAL_LOCK(hfmpi2c);
if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_STOPF) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_STOPI) != RESET))
{
FMPI2C_ITSlaveCplt(hfmpi2c, tmpITFlags);
}if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_STOPF) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_STOPI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_AF) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_NACKI) != RESET))
{
if (hfmpi2c->XferCount == 0U)
{
if ((hfmpi2c->State == HAL_FMPI2C_STATE_LISTEN) && (tmpoptions == FMPI2C_FIRST_AND_LAST_FRAME))
/* ... */
{
FMPI2C_ITListenCplt(hfmpi2c, tmpITFlags);
...}
else if ((hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX_LISTEN) && (tmpoptions != FMPI2C_NO_OPTION_FRAME))
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
FMPI2C_Flush_TXDR(hfmpi2c);
FMPI2C_ITSlaveSeqCplt(hfmpi2c);
}else if ((hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX_LISTEN) && (tmpoptions != FMPI2C_NO_OPTION_FRAME)) { ... }
else
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
}else { ... }
}if (hfmpi2c->XferCount == 0U) { ... }
else
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_AF;
if ((tmpoptions == FMPI2C_FIRST_FRAME) || (tmpoptions == FMPI2C_NEXT_FRAME))
{
FMPI2C_ITError(hfmpi2c, hfmpi2c->ErrorCode);
}if ((tmpoptions == FMPI2C_FIRST_FRAME) || (tmpoptions == FMPI2C_NEXT_FRAME)) { ... }
}else { ... }
}else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_AF) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_NACKI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_RXNE) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_RXI) != RESET))
{
if (hfmpi2c->XferCount > 0U)
{
*hfmpi2c->pBuffPtr = (uint8_t)hfmpi2c->Instance->RXDR;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferSize--;
hfmpi2c->XferCount--;
}if (hfmpi2c->XferCount > 0U) { ... }
if ((hfmpi2c->XferCount == 0U) && \
(tmpoptions != FMPI2C_NO_OPTION_FRAME))
{
FMPI2C_ITSlaveSeqCplt(hfmpi2c);
}if ((hfmpi2c->XferCount == 0U) && \ (tmpoptions != FMPI2C_NO_OPTION_FRAME)) { ... }
}else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_RXNE) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_RXI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_ADDR) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_ADDRI) != RESET))
{
FMPI2C_ITAddrCplt(hfmpi2c, tmpITFlags);
}else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_ADDR) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_ADDRI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TXIS) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TXI) != RESET))
{
if (hfmpi2c->XferCount > 0U)
{
hfmpi2c->Instance->TXDR = *hfmpi2c->pBuffPtr;
hfmpi2c->pBuffPtr++;
hfmpi2c->XferCount--;
hfmpi2c->XferSize--;
}if (hfmpi2c->XferCount > 0U) { ... }
else
{
if ((tmpoptions == FMPI2C_NEXT_FRAME) || (tmpoptions == FMPI2C_FIRST_FRAME))
{
FMPI2C_ITSlaveSeqCplt(hfmpi2c);
}if ((tmpoptions == FMPI2C_NEXT_FRAME) || (tmpoptions == FMPI2C_FIRST_FRAME)) { ... }
}else { ... }
}else if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_TXIS) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TXI) != RESET)) { ... }
else
{
}else { ... }
__HAL_UNLOCK(hfmpi2c);
return HAL_OK;
}{ ... }
/* ... */
static HAL_StatusTypeDef FMPI2C_Master_ISR_DMA(struct __FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags,
uint32_t ITSources)
{
uint16_t devaddress;
uint32_t xfermode;
__HAL_LOCK(hfmpi2c);
if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_AF) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_NACKI) != RESET))
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_AF;
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_CPLT_IT);
FMPI2C_Flush_TXDR(hfmpi2c);
}if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_AF) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_NACKI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_TCR) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET))
{
__HAL_FMPI2C_DISABLE_IT(hfmpi2c, FMPI2C_IT_TCI);
if (hfmpi2c->XferCount != 0U)
{
devaddress = (uint16_t)(hfmpi2c->Instance->CR2 & FMPI2C_CR2_SADD);
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
if (FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE)
{
hfmpi2c->XferSize = 1U;
}if (FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE) { ... }
else
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
}else { ... }
xfermode = FMPI2C_RELOAD_MODE;
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
if (hfmpi2c->XferOptions != FMPI2C_NO_OPTION_FRAME)
{
xfermode = hfmpi2c->XferOptions;
}if (hfmpi2c->XferOptions != FMPI2C_NO_OPTION_FRAME) { ... }
else
{
xfermode = FMPI2C_AUTOEND_MODE;
}else { ... }
}else { ... }
FMPI2C_TransferConfig(hfmpi2c, devaddress, (uint8_t)hfmpi2c->XferSize, xfermode, FMPI2C_NO_STARTSTOP);
hfmpi2c->XferCount -= hfmpi2c->XferSize;
if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX)
{
hfmpi2c->Instance->CR1 |= FMPI2C_CR1_RXDMAEN;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX) { ... }
else
{
hfmpi2c->Instance->CR1 |= FMPI2C_CR1_TXDMAEN;
}else { ... }
}if (hfmpi2c->XferCount != 0U) { ... }
else
{
if (FMPI2C_GET_STOP_MODE(hfmpi2c) != FMPI2C_AUTOEND_MODE)
{
FMPI2C_ITMasterSeqCplt(hfmpi2c);
}if (FMPI2C_GET_STOP_MODE(hfmpi2c) != FMPI2C_AUTOEND_MODE) { ... }
else
{
FMPI2C_ITError(hfmpi2c, HAL_FMPI2C_ERROR_SIZE);
}else { ... }
}else { ... }
}else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_TCR) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_TC) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET))
{
if (hfmpi2c->XferCount == 0U)
{
if (FMPI2C_GET_STOP_MODE(hfmpi2c) != FMPI2C_AUTOEND_MODE)
{
if (hfmpi2c->XferOptions == FMPI2C_NO_OPTION_FRAME)
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_STOP;
}if (hfmpi2c->XferOptions == FMPI2C_NO_OPTION_FRAME) { ... }
else
{
FMPI2C_ITMasterSeqCplt(hfmpi2c);
}else { ... }
}if (FMPI2C_GET_STOP_MODE(hfmpi2c) != FMPI2C_AUTOEND_MODE) { ... }
}if (hfmpi2c->XferCount == 0U) { ... }
else
{
FMPI2C_ITError(hfmpi2c, HAL_FMPI2C_ERROR_SIZE);
}else { ... }
}else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_TC) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_STOPF) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_STOPI) != RESET))
{
FMPI2C_ITMasterCplt(hfmpi2c, ITFlags);
}else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_STOPF) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_STOPI) != RESET)) { ... }
else
{
}else { ... }
__HAL_UNLOCK(hfmpi2c);
return HAL_OK;
}{ ... }
/* ... */
static HAL_StatusTypeDef FMPI2C_Mem_ISR_DMA(struct __FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags,
uint32_t ITSources)
{
uint32_t direction = FMPI2C_GENERATE_START_WRITE;
__HAL_LOCK(hfmpi2c);
if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_AF) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_NACKI) != RESET))
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_AF;
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_CPLT_IT);
FMPI2C_Flush_TXDR(hfmpi2c);
}if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_AF) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_NACKI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_TXIS) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TXI) != RESET))
{
hfmpi2c->Instance->TXDR = hfmpi2c->Memaddress;
hfmpi2c->Memaddress = 0xFFFFFFFFU;
}else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_TXIS) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TXI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_TCR) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET))
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_ERROR_IT);
if (hfmpi2c->XferCount != 0U)
{
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
if (FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE)
{
hfmpi2c->XferSize = 1U;
}if (FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE) { ... }
else
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
}else { ... }
FMPI2C_TransferConfig(hfmpi2c, (uint16_t)hfmpi2c->Devaddress, (uint8_t)hfmpi2c->XferSize,
FMPI2C_RELOAD_MODE, FMPI2C_NO_STARTSTOP);
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
FMPI2C_TransferConfig(hfmpi2c, (uint16_t)hfmpi2c->Devaddress, (uint8_t)hfmpi2c->XferSize,
FMPI2C_AUTOEND_MODE, FMPI2C_NO_STARTSTOP);
}else { ... }
hfmpi2c->XferCount -= hfmpi2c->XferSize;
if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX)
{
hfmpi2c->Instance->CR1 |= FMPI2C_CR1_RXDMAEN;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX) { ... }
else
{
hfmpi2c->Instance->CR1 |= FMPI2C_CR1_TXDMAEN;
}else { ... }
}if (hfmpi2c->XferCount != 0U) { ... }
else
{
FMPI2C_ITError(hfmpi2c, HAL_FMPI2C_ERROR_SIZE);
}else { ... }
}else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_TCR) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_TC) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET))
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_ERROR_IT);
if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX)
{
direction = FMPI2C_GENERATE_START_READ;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX) { ... }
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
if (FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE)
{
hfmpi2c->XferSize = 1U;
}if (FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE) { ... }
else
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
}else { ... }
FMPI2C_TransferConfig(hfmpi2c, (uint16_t)hfmpi2c->Devaddress, (uint8_t)hfmpi2c->XferSize,
FMPI2C_RELOAD_MODE, direction);
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
FMPI2C_TransferConfig(hfmpi2c, (uint16_t)hfmpi2c->Devaddress, (uint8_t)hfmpi2c->XferSize,
FMPI2C_AUTOEND_MODE, direction);
}else { ... }
hfmpi2c->XferCount -= hfmpi2c->XferSize;
if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX)
{
hfmpi2c->Instance->CR1 |= FMPI2C_CR1_RXDMAEN;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX) { ... }
else
{
hfmpi2c->Instance->CR1 |= FMPI2C_CR1_TXDMAEN;
}else { ... }
}else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_TC) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_TCI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_STOPF) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_STOPI) != RESET))
{
FMPI2C_ITMasterCplt(hfmpi2c, ITFlags);
}else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_STOPF) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_STOPI) != RESET)) { ... }
else
{
}else { ... }
__HAL_UNLOCK(hfmpi2c);
return HAL_OK;
}{ ... }
/* ... */
static HAL_StatusTypeDef FMPI2C_Slave_ISR_DMA(struct __FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags,
uint32_t ITSources)
{
uint32_t tmpoptions = hfmpi2c->XferOptions;
uint32_t treatdmanack = 0U;
HAL_FMPI2C_StateTypeDef tmpstate;
__HAL_LOCK(hfmpi2c);
if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_STOPF) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_STOPI) != RESET))
{
FMPI2C_ITSlaveCplt(hfmpi2c, ITFlags);
}if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_STOPF) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_STOPI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_AF) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_NACKI) != RESET))
{
if ((FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_CR1_TXDMAEN) != RESET) ||
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_CR1_RXDMAEN) != RESET))
{
if (hfmpi2c->hdmarx != NULL)
{
if (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_CR1_RXDMAEN) != RESET)
{
if (FMPI2C_GET_DMA_REMAIN_DATA(hfmpi2c->hdmarx) == 0U)
{
treatdmanack = 1U;
}if (FMPI2C_GET_DMA_REMAIN_DATA(hfmpi2c->hdmarx) == 0U) { ... }
}if (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_CR1_RXDMAEN) != RESET) { ... }
}if (hfmpi2c->hdmarx != NULL) { ... }
if (hfmpi2c->hdmatx != NULL)
{
if (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_CR1_TXDMAEN) != RESET)
{
if (FMPI2C_GET_DMA_REMAIN_DATA(hfmpi2c->hdmatx) == 0U)
{
treatdmanack = 1U;
}if (FMPI2C_GET_DMA_REMAIN_DATA(hfmpi2c->hdmatx) == 0U) { ... }
}if (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_CR1_TXDMAEN) != RESET) { ... }
}if (hfmpi2c->hdmatx != NULL) { ... }
if (treatdmanack == 1U)
{
if ((hfmpi2c->State == HAL_FMPI2C_STATE_LISTEN) && (tmpoptions == FMPI2C_FIRST_AND_LAST_FRAME))
/* ... */
{
FMPI2C_ITListenCplt(hfmpi2c, ITFlags);
...}
else if ((hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX_LISTEN) && (tmpoptions != FMPI2C_NO_OPTION_FRAME))
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
FMPI2C_Flush_TXDR(hfmpi2c);
FMPI2C_ITSlaveSeqCplt(hfmpi2c);
}else if ((hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX_LISTEN) && (tmpoptions != FMPI2C_NO_OPTION_FRAME)) { ... }
else
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
}else { ... }
}if (treatdmanack == 1U) { ... }
else
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_AF;
tmpstate = hfmpi2c->State;
if ((tmpoptions == FMPI2C_FIRST_FRAME) || (tmpoptions == FMPI2C_NEXT_FRAME))
{
if ((tmpstate == HAL_FMPI2C_STATE_BUSY_TX) || (tmpstate == HAL_FMPI2C_STATE_BUSY_TX_LISTEN))
{
hfmpi2c->PreviousState = FMPI2C_STATE_SLAVE_BUSY_TX;
}if ((tmpstate == HAL_FMPI2C_STATE_BUSY_TX) || (tmpstate == HAL_FMPI2C_STATE_BUSY_TX_LISTEN)) { ... }
else if ((tmpstate == HAL_FMPI2C_STATE_BUSY_RX) || (tmpstate == HAL_FMPI2C_STATE_BUSY_RX_LISTEN))
{
hfmpi2c->PreviousState = FMPI2C_STATE_SLAVE_BUSY_RX;
}else if ((tmpstate == HAL_FMPI2C_STATE_BUSY_RX) || (tmpstate == HAL_FMPI2C_STATE_BUSY_RX_LISTEN)) { ... }
else
{
}else { ... }
FMPI2C_ITError(hfmpi2c, hfmpi2c->ErrorCode);
}if ((tmpoptions == FMPI2C_FIRST_FRAME) || (tmpoptions == FMPI2C_NEXT_FRAME)) { ... }
}else { ... }
}if ((FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_CR1_TXDMAEN) != RESET) || (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_CR1_RXDMAEN) != RESET)) { ... }
else
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
}else { ... }
}else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_AF) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_NACKI) != RESET)) { ... }
else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_ADDR) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_ADDRI) != RESET))
{
FMPI2C_ITAddrCplt(hfmpi2c, ITFlags);
}else if ((FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_ADDR) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(ITSources, FMPI2C_IT_ADDRI) != RESET)) { ... }
else
{
}else { ... }
__HAL_UNLOCK(hfmpi2c);
return HAL_OK;
}{ ... }
/* ... */
static HAL_StatusTypeDef FMPI2C_RequestMemoryWrite(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress,
uint16_t MemAddress, uint16_t MemAddSize, uint32_t Timeout,
uint32_t Tickstart)
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)MemAddSize, FMPI2C_RELOAD_MODE, FMPI2C_GENERATE_START_WRITE);
if (FMPI2C_WaitOnTXISFlagUntilTimeout(hfmpi2c, Timeout, Tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnTXISFlagUntilTimeout(hfmpi2c, Timeout, Tickstart) != HAL_OK) { ... }
if (MemAddSize == FMPI2C_MEMADD_SIZE_8BIT)
{
hfmpi2c->Instance->TXDR = FMPI2C_MEM_ADD_LSB(MemAddress);
}if (MemAddSize == FMPI2C_MEMADD_SIZE_8BIT) { ... }
else
{
hfmpi2c->Instance->TXDR = FMPI2C_MEM_ADD_MSB(MemAddress);
if (FMPI2C_WaitOnTXISFlagUntilTimeout(hfmpi2c, Timeout, Tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnTXISFlagUntilTimeout(hfmpi2c, Timeout, Tickstart) != HAL_OK) { ... }
hfmpi2c->Instance->TXDR = FMPI2C_MEM_ADD_LSB(MemAddress);
}else { ... }
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_TCR, RESET, Timeout, Tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_TCR, RESET, Timeout, Tickstart) != HAL_OK) { ... }
return HAL_OK;
}{ ... }
/* ... */
static HAL_StatusTypeDef FMPI2C_RequestMemoryRead(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress,
uint16_t MemAddress, uint16_t MemAddSize, uint32_t Timeout,
uint32_t Tickstart)
{
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)MemAddSize, FMPI2C_SOFTEND_MODE, FMPI2C_GENERATE_START_WRITE);
if (FMPI2C_WaitOnTXISFlagUntilTimeout(hfmpi2c, Timeout, Tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnTXISFlagUntilTimeout(hfmpi2c, Timeout, Tickstart) != HAL_OK) { ... }
if (MemAddSize == FMPI2C_MEMADD_SIZE_8BIT)
{
hfmpi2c->Instance->TXDR = FMPI2C_MEM_ADD_LSB(MemAddress);
}if (MemAddSize == FMPI2C_MEMADD_SIZE_8BIT) { ... }
else
{
hfmpi2c->Instance->TXDR = FMPI2C_MEM_ADD_MSB(MemAddress);
if (FMPI2C_WaitOnTXISFlagUntilTimeout(hfmpi2c, Timeout, Tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnTXISFlagUntilTimeout(hfmpi2c, Timeout, Tickstart) != HAL_OK) { ... }
hfmpi2c->Instance->TXDR = FMPI2C_MEM_ADD_LSB(MemAddress);
}else { ... }
if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_TC, RESET, Timeout, Tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_WaitOnFlagUntilTimeout(hfmpi2c, FMPI2C_FLAG_TC, RESET, Timeout, Tickstart) != HAL_OK) { ... }
return HAL_OK;
}{ ... }
/* ... */
static void FMPI2C_ITAddrCplt(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags)
{
uint8_t transferdirection;
uint16_t slaveaddrcode;
uint16_t ownadd1code;
uint16_t ownadd2code;
UNUSED(ITFlags);
if (((uint32_t)hfmpi2c->State & (uint32_t)HAL_FMPI2C_STATE_LISTEN) == (uint32_t)HAL_FMPI2C_STATE_LISTEN)
{
transferdirection = FMPI2C_GET_DIR(hfmpi2c);
slaveaddrcode = FMPI2C_GET_ADDR_MATCH(hfmpi2c);
ownadd1code = FMPI2C_GET_OWN_ADDRESS1(hfmpi2c);
ownadd2code = FMPI2C_GET_OWN_ADDRESS2(hfmpi2c);
if (hfmpi2c->Init.AddressingMode == FMPI2C_ADDRESSINGMODE_10BIT)
{
if ((slaveaddrcode & SLAVE_ADDR_MSK) == ((ownadd1code >> SLAVE_ADDR_SHIFT) & SLAVE_ADDR_MSK))
{
slaveaddrcode = ownadd1code;
hfmpi2c->AddrEventCount++;
if (hfmpi2c->AddrEventCount == 2U)
{
hfmpi2c->AddrEventCount = 0U;
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_ADDR);
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->AddrCallback(hfmpi2c, transferdirection, slaveaddrcode);
#else
HAL_FMPI2C_AddrCallback(hfmpi2c, transferdirection, slaveaddrcode);
#endif
}if (hfmpi2c->AddrEventCount == 2U) { ... }
}if ((slaveaddrcode & SLAVE_ADDR_MSK) == ((ownadd1code >> SLAVE_ADDR_SHIFT) & SLAVE_ADDR_MSK)) { ... }
else
{
slaveaddrcode = ownadd2code;
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT);
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->AddrCallback(hfmpi2c, transferdirection, slaveaddrcode);
#else
HAL_FMPI2C_AddrCallback(hfmpi2c, transferdirection, slaveaddrcode);
#endif
}else { ... }
}if (hfmpi2c->Init.AddressingMode == FMPI2C_ADDRESSINGMODE_10BIT) { ... }
else
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT);
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->AddrCallback(hfmpi2c, transferdirection, slaveaddrcode);
#else
HAL_FMPI2C_AddrCallback(hfmpi2c, transferdirection, slaveaddrcode);
#endif
}else { ... }
}if (((uint32_t)hfmpi2c->State & (uint32_t)HAL_FMPI2C_STATE_LISTEN) == (uint32_t)HAL_FMPI2C_STATE_LISTEN) { ... }
else
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_ADDR);
__HAL_UNLOCK(hfmpi2c);
}else { ... }
}{ ... }
/* ... */
static void FMPI2C_ITMasterSeqCplt(FMPI2C_HandleTypeDef *hfmpi2c)
{
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX)
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->PreviousState = FMPI2C_STATE_MASTER_BUSY_TX;
hfmpi2c->XferISR = NULL;
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->MasterTxCpltCallback(hfmpi2c);
#else
HAL_FMPI2C_MasterTxCpltCallback(hfmpi2c);
#endif
}if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->PreviousState = FMPI2C_STATE_MASTER_BUSY_RX;
hfmpi2c->XferISR = NULL;
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT);
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->MasterRxCpltCallback(hfmpi2c);
#else
HAL_FMPI2C_MasterRxCpltCallback(hfmpi2c);
#endif
}else { ... }
}{ ... }
/* ... */
static void FMPI2C_ITSlaveSeqCplt(FMPI2C_HandleTypeDef *hfmpi2c)
{
uint32_t tmpcr1value = READ_REG(hfmpi2c->Instance->CR1);
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
if (FMPI2C_CHECK_IT_SOURCE(tmpcr1value, FMPI2C_CR1_TXDMAEN) != RESET)
{
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_TXDMAEN;
}if (FMPI2C_CHECK_IT_SOURCE(tmpcr1value, FMPI2C_CR1_TXDMAEN) != RESET) { ... }
else if (FMPI2C_CHECK_IT_SOURCE(tmpcr1value, FMPI2C_CR1_RXDMAEN) != RESET)
{
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_RXDMAEN;
}else if (FMPI2C_CHECK_IT_SOURCE(tmpcr1value, FMPI2C_CR1_RXDMAEN) != RESET) { ... }
else
{
}else { ... }
if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX_LISTEN)
{
hfmpi2c->State = HAL_FMPI2C_STATE_LISTEN;
hfmpi2c->PreviousState = FMPI2C_STATE_SLAVE_BUSY_TX;
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->SlaveTxCpltCallback(hfmpi2c);
#else
HAL_FMPI2C_SlaveTxCpltCallback(hfmpi2c);
#endif
}if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX_LISTEN) { ... }
else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX_LISTEN)
{
hfmpi2c->State = HAL_FMPI2C_STATE_LISTEN;
hfmpi2c->PreviousState = FMPI2C_STATE_SLAVE_BUSY_RX;
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT);
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->SlaveRxCpltCallback(hfmpi2c);
#else
HAL_FMPI2C_SlaveRxCpltCallback(hfmpi2c);
#endif
}else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX_LISTEN) { ... }
else
{
}else { ... }
}{ ... }
/* ... */
static void FMPI2C_ITMasterCplt(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags)
{
uint32_t tmperror;
uint32_t tmpITFlags = ITFlags;
__IO uint32_t tmpreg;
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX)
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
hfmpi2c->PreviousState = FMPI2C_STATE_MASTER_BUSY_TX;
}if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX) { ... }
else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX)
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT);
hfmpi2c->PreviousState = FMPI2C_STATE_MASTER_BUSY_RX;
}else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX) { ... }
else
{
}else { ... }
FMPI2C_RESET_CR2(hfmpi2c);
hfmpi2c->XferISR = NULL;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
if (FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_AF) != RESET)
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_AF;
}if (FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_AF) != RESET) { ... }
if ((hfmpi2c->State == HAL_FMPI2C_STATE_ABORT) && (FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_RXNE) != RESET))
{
tmpreg = (uint8_t)hfmpi2c->Instance->RXDR;
UNUSED(tmpreg);
}if ((hfmpi2c->State == HAL_FMPI2C_STATE_ABORT) && (FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_RXNE) != RESET)) { ... }
FMPI2C_Flush_TXDR(hfmpi2c);
tmperror = hfmpi2c->ErrorCode;
if ((hfmpi2c->State == HAL_FMPI2C_STATE_ABORT) || (tmperror != HAL_FMPI2C_ERROR_NONE))
{
FMPI2C_ITError(hfmpi2c, hfmpi2c->ErrorCode);
}if ((hfmpi2c->State == HAL_FMPI2C_STATE_ABORT) || (tmperror != HAL_FMPI2C_ERROR_NONE)) { ... }
else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX)
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->PreviousState = FMPI2C_STATE_NONE;
if (hfmpi2c->Mode == HAL_FMPI2C_MODE_MEM)
{
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->MemTxCpltCallback(hfmpi2c);
#else
HAL_FMPI2C_MemTxCpltCallback(hfmpi2c);
#endif
}if (hfmpi2c->Mode == HAL_FMPI2C_MODE_MEM) { ... }
else
{
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->MasterTxCpltCallback(hfmpi2c);
#else
HAL_FMPI2C_MasterTxCpltCallback(hfmpi2c);
#endif
}else { ... }
}else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX) { ... }
else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX)
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->PreviousState = FMPI2C_STATE_NONE;
if (hfmpi2c->Mode == HAL_FMPI2C_MODE_MEM)
{
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->MemRxCpltCallback(hfmpi2c);
#else
HAL_FMPI2C_MemRxCpltCallback(hfmpi2c);
#endif
}if (hfmpi2c->Mode == HAL_FMPI2C_MODE_MEM) { ... }
else
{
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->MasterRxCpltCallback(hfmpi2c);
#else
HAL_FMPI2C_MasterRxCpltCallback(hfmpi2c);
#endif
}else { ... }
}else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX) { ... }
else
{
}else { ... }
}{ ... }
/* ... */
static void FMPI2C_ITSlaveCplt(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags)
{
uint32_t tmpcr1value = READ_REG(hfmpi2c->Instance->CR1);
uint32_t tmpITFlags = ITFlags;
uint32_t tmpoptions = hfmpi2c->XferOptions;
HAL_FMPI2C_StateTypeDef tmpstate = hfmpi2c->State;
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
if ((tmpstate == HAL_FMPI2C_STATE_BUSY_TX) || (tmpstate == HAL_FMPI2C_STATE_BUSY_TX_LISTEN))
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT | FMPI2C_XFER_TX_IT);
hfmpi2c->PreviousState = FMPI2C_STATE_SLAVE_BUSY_TX;
}if ((tmpstate == HAL_FMPI2C_STATE_BUSY_TX) || (tmpstate == HAL_FMPI2C_STATE_BUSY_TX_LISTEN)) { ... }
else if ((tmpstate == HAL_FMPI2C_STATE_BUSY_RX) || (tmpstate == HAL_FMPI2C_STATE_BUSY_RX_LISTEN))
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT | FMPI2C_XFER_RX_IT);
hfmpi2c->PreviousState = FMPI2C_STATE_SLAVE_BUSY_RX;
}else if ((tmpstate == HAL_FMPI2C_STATE_BUSY_RX) || (tmpstate == HAL_FMPI2C_STATE_BUSY_RX_LISTEN)) { ... }
else if (tmpstate == HAL_FMPI2C_STATE_LISTEN)
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT | FMPI2C_XFER_TX_IT | FMPI2C_XFER_RX_IT);
hfmpi2c->PreviousState = FMPI2C_STATE_NONE;
}else if (tmpstate == HAL_FMPI2C_STATE_LISTEN) { ... }
else
{
}else { ... }
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
FMPI2C_RESET_CR2(hfmpi2c);
FMPI2C_Flush_TXDR(hfmpi2c);
if (FMPI2C_CHECK_IT_SOURCE(tmpcr1value, FMPI2C_CR1_TXDMAEN) != RESET)
{
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_TXDMAEN;
if (hfmpi2c->hdmatx != NULL)
{
hfmpi2c->XferCount = (uint16_t)FMPI2C_GET_DMA_REMAIN_DATA(hfmpi2c->hdmatx);
}if (hfmpi2c->hdmatx != NULL) { ... }
}if (FMPI2C_CHECK_IT_SOURCE(tmpcr1value, FMPI2C_CR1_TXDMAEN) != RESET) { ... }
else if (FMPI2C_CHECK_IT_SOURCE(tmpcr1value, FMPI2C_CR1_RXDMAEN) != RESET)
{
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_RXDMAEN;
if (hfmpi2c->hdmarx != NULL)
{
hfmpi2c->XferCount = (uint16_t)FMPI2C_GET_DMA_REMAIN_DATA(hfmpi2c->hdmarx);
}if (hfmpi2c->hdmarx != NULL) { ... }
}else if (FMPI2C_CHECK_IT_SOURCE(tmpcr1value, FMPI2C_CR1_RXDMAEN) != RESET) { ... }
else
{
}else { ... }
if (FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_RXNE) != RESET)
{
tmpITFlags &= ~FMPI2C_FLAG_RXNE;
*hfmpi2c->pBuffPtr = (uint8_t)hfmpi2c->Instance->RXDR;
hfmpi2c->pBuffPtr++;
if ((hfmpi2c->XferSize > 0U))
{
hfmpi2c->XferSize--;
hfmpi2c->XferCount--;
}if ((hfmpi2c->XferSize > 0U)) { ... }
}if (FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_RXNE) != RESET) { ... }
if (hfmpi2c->XferCount != 0U)
{
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_AF;
}if (hfmpi2c->XferCount != 0U) { ... }
if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_AF) != RESET) && \
(FMPI2C_CHECK_IT_SOURCE(tmpcr1value, FMPI2C_IT_NACKI) != RESET))
{
if (hfmpi2c->XferCount == 0U)
{
if ((hfmpi2c->State == HAL_FMPI2C_STATE_LISTEN) && (tmpoptions == FMPI2C_FIRST_AND_LAST_FRAME))
/* ... */
{
FMPI2C_ITListenCplt(hfmpi2c, tmpITFlags);
...}
else if ((hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX_LISTEN) && (tmpoptions != FMPI2C_NO_OPTION_FRAME))
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
FMPI2C_Flush_TXDR(hfmpi2c);
FMPI2C_ITSlaveSeqCplt(hfmpi2c);
}else if ((hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_TX_LISTEN) && (tmpoptions != FMPI2C_NO_OPTION_FRAME)) { ... }
else
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
}else { ... }
}if (hfmpi2c->XferCount == 0U) { ... }
else
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_AF;
if ((tmpoptions == FMPI2C_FIRST_FRAME) || (tmpoptions == FMPI2C_NEXT_FRAME))
{
FMPI2C_ITError(hfmpi2c, hfmpi2c->ErrorCode);
}if ((tmpoptions == FMPI2C_FIRST_FRAME) || (tmpoptions == FMPI2C_NEXT_FRAME)) { ... }
}else { ... }
}if ((FMPI2C_CHECK_FLAG(tmpITFlags, FMPI2C_FLAG_AF) != RESET) && \ (FMPI2C_CHECK_IT_SOURCE(tmpcr1value, FMPI2C_IT_NACKI) != RESET)) { ... }
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->XferISR = NULL;
if (hfmpi2c->ErrorCode != HAL_FMPI2C_ERROR_NONE)
{
FMPI2C_ITError(hfmpi2c, hfmpi2c->ErrorCode);
if (hfmpi2c->State == HAL_FMPI2C_STATE_LISTEN)
{
FMPI2C_ITListenCplt(hfmpi2c, tmpITFlags);
}if (hfmpi2c->State == HAL_FMPI2C_STATE_LISTEN) { ... }
}if (hfmpi2c->ErrorCode != HAL_FMPI2C_ERROR_NONE) { ... }
else if (hfmpi2c->XferOptions != FMPI2C_NO_OPTION_FRAME)
{
FMPI2C_ITSlaveSeqCplt(hfmpi2c);
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->PreviousState = FMPI2C_STATE_NONE;
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->ListenCpltCallback(hfmpi2c);
#else
HAL_FMPI2C_ListenCpltCallback(hfmpi2c);
#endif
}else if (hfmpi2c->XferOptions != FMPI2C_NO_OPTION_FRAME) { ... }
else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX)
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->PreviousState = FMPI2C_STATE_NONE;
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->SlaveRxCpltCallback(hfmpi2c);
#else
HAL_FMPI2C_SlaveRxCpltCallback(hfmpi2c);
#endif
}else if (hfmpi2c->State == HAL_FMPI2C_STATE_BUSY_RX) { ... }
else
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->PreviousState = FMPI2C_STATE_NONE;
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->SlaveTxCpltCallback(hfmpi2c);
#else
HAL_FMPI2C_SlaveTxCpltCallback(hfmpi2c);
#endif
}else { ... }
}{ ... }
/* ... */
static void FMPI2C_ITListenCplt(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags)
{
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->PreviousState = FMPI2C_STATE_NONE;
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->XferISR = NULL;
if (FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_RXNE) != RESET)
{
*hfmpi2c->pBuffPtr = (uint8_t)hfmpi2c->Instance->RXDR;
hfmpi2c->pBuffPtr++;
if ((hfmpi2c->XferSize > 0U))
{
hfmpi2c->XferSize--;
hfmpi2c->XferCount--;
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_AF;
}if ((hfmpi2c->XferSize > 0U)) { ... }
}if (FMPI2C_CHECK_FLAG(ITFlags, FMPI2C_FLAG_RXNE) != RESET) { ... }
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT | FMPI2C_XFER_RX_IT | FMPI2C_XFER_TX_IT);
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->ListenCpltCallback(hfmpi2c);
#else
HAL_FMPI2C_ListenCpltCallback(hfmpi2c);
#endif
}{ ... }
/* ... */
static void FMPI2C_ITError(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ErrorCode)
{
HAL_FMPI2C_StateTypeDef tmpstate = hfmpi2c->State;
uint32_t tmppreviousstate;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->XferCount = 0U;
hfmpi2c->ErrorCode |= ErrorCode;
if ((tmpstate == HAL_FMPI2C_STATE_LISTEN) ||
(tmpstate == HAL_FMPI2C_STATE_BUSY_TX_LISTEN) ||
(tmpstate == HAL_FMPI2C_STATE_BUSY_RX_LISTEN))
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_RX_IT | FMPI2C_XFER_TX_IT);
hfmpi2c->State = HAL_FMPI2C_STATE_LISTEN;
hfmpi2c->XferISR = FMPI2C_Slave_ISR_IT;
}if ((tmpstate == HAL_FMPI2C_STATE_LISTEN) || (tmpstate == HAL_FMPI2C_STATE_BUSY_TX_LISTEN) || (tmpstate == HAL_FMPI2C_STATE_BUSY_RX_LISTEN)) { ... }
else
{
FMPI2C_Disable_IRQ(hfmpi2c, FMPI2C_XFER_LISTEN_IT | FMPI2C_XFER_RX_IT | FMPI2C_XFER_TX_IT);
FMPI2C_Flush_TXDR(hfmpi2c);
if (hfmpi2c->State != HAL_FMPI2C_STATE_ABORT)
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF) == SET)
{
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_AF) == SET)
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_AF;
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_AF) == SET) { ... }
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF) == SET) { ... }
}if (hfmpi2c->State != HAL_FMPI2C_STATE_ABORT) { ... }
hfmpi2c->XferISR = NULL;
}else { ... }
tmppreviousstate = hfmpi2c->PreviousState;
if ((hfmpi2c->hdmatx != NULL) && ((tmppreviousstate == FMPI2C_STATE_MASTER_BUSY_TX) || \
(tmppreviousstate == FMPI2C_STATE_SLAVE_BUSY_TX)))
{
if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_TXDMAEN) == FMPI2C_CR1_TXDMAEN)
{
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_TXDMAEN;
}if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_TXDMAEN) == FMPI2C_CR1_TXDMAEN) { ... }
if (HAL_DMA_GetState(hfmpi2c->hdmatx) != HAL_DMA_STATE_READY)
{
/* ... */
hfmpi2c->hdmatx->XferAbortCallback = FMPI2C_DMAAbort;
__HAL_UNLOCK(hfmpi2c);
if (HAL_DMA_Abort_IT(hfmpi2c->hdmatx) != HAL_OK)
{
hfmpi2c->hdmatx->XferAbortCallback(hfmpi2c->hdmatx);
}if (HAL_DMA_Abort_IT(hfmpi2c->hdmatx) != HAL_OK) { ... }
}if (HAL_DMA_GetState(hfmpi2c->hdmatx) != HAL_DMA_STATE_READY) { ... }
else
{
FMPI2C_TreatErrorCallback(hfmpi2c);
}else { ... }
}if ((hfmpi2c->hdmatx != NULL) && ((tmppreviousstate == FMPI2C_STATE_MASTER_BUSY_TX) || \ (tmppreviousstate == FMPI2C_STATE_SLAVE_BUSY_TX))) { ... }
else if ((hfmpi2c->hdmarx != NULL) && ((tmppreviousstate == FMPI2C_STATE_MASTER_BUSY_RX) || \
(tmppreviousstate == FMPI2C_STATE_SLAVE_BUSY_RX)))
{
if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_RXDMAEN) == FMPI2C_CR1_RXDMAEN)
{
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_RXDMAEN;
}if ((hfmpi2c->Instance->CR1 & FMPI2C_CR1_RXDMAEN) == FMPI2C_CR1_RXDMAEN) { ... }
if (HAL_DMA_GetState(hfmpi2c->hdmarx) != HAL_DMA_STATE_READY)
{
/* ... */
hfmpi2c->hdmarx->XferAbortCallback = FMPI2C_DMAAbort;
__HAL_UNLOCK(hfmpi2c);
if (HAL_DMA_Abort_IT(hfmpi2c->hdmarx) != HAL_OK)
{
hfmpi2c->hdmarx->XferAbortCallback(hfmpi2c->hdmarx);
}if (HAL_DMA_Abort_IT(hfmpi2c->hdmarx) != HAL_OK) { ... }
}if (HAL_DMA_GetState(hfmpi2c->hdmarx) != HAL_DMA_STATE_READY) { ... }
else
{
FMPI2C_TreatErrorCallback(hfmpi2c);
}else { ... }
}else if ((hfmpi2c->hdmarx != NULL) && ((tmppreviousstate == FMPI2C_STATE_MASTER_BUSY_RX) || \ (tmppreviousstate == FMPI2C_STATE_SLAVE_BUSY_RX))) { ... }
else
{
FMPI2C_TreatErrorCallback(hfmpi2c);
}else { ... }
}{ ... }
/* ... */
static void FMPI2C_TreatErrorCallback(FMPI2C_HandleTypeDef *hfmpi2c)
{
if (hfmpi2c->State == HAL_FMPI2C_STATE_ABORT)
{
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->PreviousState = FMPI2C_STATE_NONE;
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->AbortCpltCallback(hfmpi2c);
#else
HAL_FMPI2C_AbortCpltCallback(hfmpi2c);
#endif
}if (hfmpi2c->State == HAL_FMPI2C_STATE_ABORT) { ... }
else
{
hfmpi2c->PreviousState = FMPI2C_STATE_NONE;
__HAL_UNLOCK(hfmpi2c);
#if (USE_HAL_FMPI2C_REGISTER_CALLBACKS == 1)
hfmpi2c->ErrorCallback(hfmpi2c);
#else
HAL_FMPI2C_ErrorCallback(hfmpi2c);
#endif
}else { ... }
}{ ... }
/* ... */
static void FMPI2C_Flush_TXDR(FMPI2C_HandleTypeDef *hfmpi2c)
{
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_TXIS) != RESET)
{
hfmpi2c->Instance->TXDR = 0x00U;
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_TXIS) != RESET) { ... }
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_TXE) == RESET)
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_TXE);
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_TXE) == RESET) { ... }
}{ ... }
/* ... */
static void FMPI2C_DMAMasterTransmitCplt(DMA_HandleTypeDef *hdma)
{
FMPI2C_HandleTypeDef *hfmpi2c = (FMPI2C_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent);
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_TXDMAEN;
if (hfmpi2c->XferCount == 0U)
{
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_CPLT_IT);
}if (hfmpi2c->XferCount == 0U) { ... }
else
{
hfmpi2c->pBuffPtr += hfmpi2c->XferSize;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
}else { ... }
if (HAL_DMA_Start_IT(hfmpi2c->hdmatx, (uint32_t)hfmpi2c->pBuffPtr, (uint32_t)&hfmpi2c->Instance->TXDR,
hfmpi2c->XferSize) != HAL_OK)
{
FMPI2C_ITError(hfmpi2c, HAL_FMPI2C_ERROR_DMA);
}if (HAL_DMA_Start_IT(hfmpi2c->hdmatx, (uint32_t)hfmpi2c->pBuffPtr, (uint32_t)&hfmpi2c->Instance->TXDR, hfmpi2c->XferSize) != HAL_OK) { ... }
else
{
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_RELOAD_IT);
}else { ... }
}else { ... }
}{ ... }
/* ... */
static void FMPI2C_DMASlaveTransmitCplt(DMA_HandleTypeDef *hdma)
{
FMPI2C_HandleTypeDef *hfmpi2c = (FMPI2C_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent);
uint32_t tmpoptions = hfmpi2c->XferOptions;
if ((tmpoptions == FMPI2C_NEXT_FRAME) || (tmpoptions == FMPI2C_FIRST_FRAME))
{
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_TXDMAEN;
FMPI2C_ITSlaveSeqCplt(hfmpi2c);
}if ((tmpoptions == FMPI2C_NEXT_FRAME) || (tmpoptions == FMPI2C_FIRST_FRAME)) { ... }
else
{
}else { ... }
}{ ... }
/* ... */
static void FMPI2C_DMAMasterReceiveCplt(DMA_HandleTypeDef *hdma)
{
FMPI2C_HandleTypeDef *hfmpi2c = (FMPI2C_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent);
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_RXDMAEN;
if (hfmpi2c->XferCount == 0U)
{
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_CPLT_IT);
}if (hfmpi2c->XferCount == 0U) { ... }
else
{
hfmpi2c->pBuffPtr += hfmpi2c->XferSize;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
if (FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE)
{
hfmpi2c->XferSize = 1U;
}if (FMPI2C_GET_DIR(hfmpi2c) == FMPI2C_DIRECTION_RECEIVE) { ... }
else
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
}else { ... }
}if (hfmpi2c->XferCount > MAX_NBYTE_SIZE) { ... }
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
}else { ... }
if (HAL_DMA_Start_IT(hfmpi2c->hdmarx, (uint32_t)&hfmpi2c->Instance->RXDR, (uint32_t)hfmpi2c->pBuffPtr,
hfmpi2c->XferSize) != HAL_OK)
{
FMPI2C_ITError(hfmpi2c, HAL_FMPI2C_ERROR_DMA);
}if (HAL_DMA_Start_IT(hfmpi2c->hdmarx, (uint32_t)&hfmpi2c->Instance->RXDR, (uint32_t)hfmpi2c->pBuffPtr, hfmpi2c->XferSize) != HAL_OK) { ... }
else
{
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_RELOAD_IT);
}else { ... }
}else { ... }
}{ ... }
/* ... */
static void FMPI2C_DMASlaveReceiveCplt(DMA_HandleTypeDef *hdma)
{
FMPI2C_HandleTypeDef *hfmpi2c = (FMPI2C_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent);
uint32_t tmpoptions = hfmpi2c->XferOptions;
if ((FMPI2C_GET_DMA_REMAIN_DATA(hfmpi2c->hdmarx) == 0U) && \
(tmpoptions != FMPI2C_NO_OPTION_FRAME))
{
hfmpi2c->Instance->CR1 &= ~FMPI2C_CR1_RXDMAEN;
FMPI2C_ITSlaveSeqCplt(hfmpi2c);
}if ((FMPI2C_GET_DMA_REMAIN_DATA(hfmpi2c->hdmarx) == 0U) && \ (tmpoptions != FMPI2C_NO_OPTION_FRAME)) { ... }
else
{
}else { ... }
}{ ... }
/* ... */
static void FMPI2C_DMAError(DMA_HandleTypeDef *hdma)
{
uint32_t treatdmaerror = 0U;
FMPI2C_HandleTypeDef *hfmpi2c = (FMPI2C_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent);
if (hfmpi2c->hdmatx != NULL)
{
if (FMPI2C_GET_DMA_REMAIN_DATA(hfmpi2c->hdmatx) == 0U)
{
treatdmaerror = 1U;
}if (FMPI2C_GET_DMA_REMAIN_DATA(hfmpi2c->hdmatx) == 0U) { ... }
}if (hfmpi2c->hdmatx != NULL) { ... }
if (hfmpi2c->hdmarx != NULL)
{
if (FMPI2C_GET_DMA_REMAIN_DATA(hfmpi2c->hdmarx) == 0U)
{
treatdmaerror = 1U;
}if (FMPI2C_GET_DMA_REMAIN_DATA(hfmpi2c->hdmarx) == 0U) { ... }
}if (hfmpi2c->hdmarx != NULL) { ... }
if (!((HAL_DMA_GetError(hdma) == HAL_DMA_ERROR_FE)) && (treatdmaerror != 0U))
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_NACK;
FMPI2C_ITError(hfmpi2c, HAL_FMPI2C_ERROR_DMA);
}if (!((HAL_DMA_GetError(hdma) == HAL_DMA_ERROR_FE)) && (treatdmaerror != 0U)) { ... }
}{ ... }
/* ... */
static void FMPI2C_DMAAbort(DMA_HandleTypeDef *hdma)
{
FMPI2C_HandleTypeDef *hfmpi2c = (FMPI2C_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent);
if (hfmpi2c->hdmatx != NULL)
{
hfmpi2c->hdmatx->XferAbortCallback = NULL;
}if (hfmpi2c->hdmatx != NULL) { ... }
if (hfmpi2c->hdmarx != NULL)
{
hfmpi2c->hdmarx->XferAbortCallback = NULL;
}if (hfmpi2c->hdmarx != NULL) { ... }
FMPI2C_TreatErrorCallback(hfmpi2c);
}{ ... }
/* ... */
static HAL_StatusTypeDef FMPI2C_WaitOnFlagUntilTimeout(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t Flag, FlagStatus Status,
uint32_t Timeout, uint32_t Tickstart)
{
while (__HAL_FMPI2C_GET_FLAG(hfmpi2c, Flag) == Status)
{
if (FMPI2C_IsErrorOccurred(hfmpi2c, Timeout, Tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_IsErrorOccurred(hfmpi2c, Timeout, Tickstart) != HAL_OK) { ... }
if (Timeout != HAL_MAX_DELAY)
{
if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U))
{
if ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, Flag) == Status))
{
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_TIMEOUT;
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}if ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, Flag) == Status)) { ... }
}if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U)) { ... }
}if (Timeout != HAL_MAX_DELAY) { ... }
}while (__HAL_FMPI2C_GET_FLAG(hfmpi2c, Flag) == Status) { ... }
return HAL_OK;
}{ ... }
/* ... */
static HAL_StatusTypeDef FMPI2C_WaitOnTXISFlagUntilTimeout(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t Timeout,
uint32_t Tickstart)
{
while (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_TXIS) == RESET)
{
if (FMPI2C_IsErrorOccurred(hfmpi2c, Timeout, Tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_IsErrorOccurred(hfmpi2c, Timeout, Tickstart) != HAL_OK) { ... }
if (Timeout != HAL_MAX_DELAY)
{
if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U))
{
if ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_TXIS) == RESET))
{
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_TIMEOUT;
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}if ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_TXIS) == RESET)) { ... }
}if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U)) { ... }
}if (Timeout != HAL_MAX_DELAY) { ... }
}while (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_TXIS) == RESET) { ... }
return HAL_OK;
}{ ... }
/* ... */
static HAL_StatusTypeDef FMPI2C_WaitOnSTOPFlagUntilTimeout(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t Timeout,
uint32_t Tickstart)
{
while (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF) == RESET)
{
if (FMPI2C_IsErrorOccurred(hfmpi2c, Timeout, Tickstart) != HAL_OK)
{
return HAL_ERROR;
}if (FMPI2C_IsErrorOccurred(hfmpi2c, Timeout, Tickstart) != HAL_OK) { ... }
if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U))
{
if ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF) == RESET))
{
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_TIMEOUT;
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
return HAL_ERROR;
}if ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF) == RESET)) { ... }
}if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U)) { ... }
}while (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF) == RESET) { ... }
return HAL_OK;
}{ ... }
/* ... */
static HAL_StatusTypeDef FMPI2C_WaitOnRXNEFlagUntilTimeout(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t Timeout,
uint32_t Tickstart)
{
HAL_StatusTypeDef status = HAL_OK;
while ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_RXNE) == RESET) && (status == HAL_OK))
{
if (FMPI2C_IsErrorOccurred(hfmpi2c, Timeout, Tickstart) != HAL_OK)
{
status = HAL_ERROR;
}if (FMPI2C_IsErrorOccurred(hfmpi2c, Timeout, Tickstart) != HAL_OK) { ... }
if ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF) == SET) && (status == HAL_OK))
{
if ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_RXNE) == SET) && (hfmpi2c->XferSize > 0U))
{
status = HAL_OK;
}if ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_RXNE) == SET) && (hfmpi2c->XferSize > 0U)) { ... }
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_AF) == SET)
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_AF;
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
FMPI2C_RESET_CR2(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
status = HAL_ERROR;
}if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_AF) == SET) { ... }
else
{
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
}else { ... }
}if ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF) == SET) && (status == HAL_OK)) { ... }
if ((((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U)) && (status == HAL_OK))
{
if ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_RXNE) == RESET))
{
hfmpi2c->ErrorCode |= HAL_FMPI2C_ERROR_TIMEOUT;
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
__HAL_UNLOCK(hfmpi2c);
status = HAL_ERROR;
}if ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_RXNE) == RESET)) { ... }
}if ((((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U)) && (status == HAL_OK)) { ... }
}while ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_RXNE) == RESET) && (status == HAL_OK)) { ... }
return status;
}{ ... }
/* ... */
static HAL_StatusTypeDef FMPI2C_IsErrorOccurred(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t Timeout, uint32_t Tickstart)
{
HAL_StatusTypeDef status = HAL_OK;
uint32_t itflag = hfmpi2c->Instance->ISR;
uint32_t error_code = 0;
uint32_t tickstart = Tickstart;
uint32_t tmp1;
HAL_FMPI2C_ModeTypeDef tmp2;
if (HAL_IS_BIT_SET(itflag, FMPI2C_FLAG_AF))
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_AF);
while ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF) == RESET) && (status == HAL_OK))
{
if (Timeout != HAL_MAX_DELAY)
{
if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
{
tmp1 = (uint32_t)(hfmpi2c->Instance->CR2 & FMPI2C_CR2_STOP);
tmp2 = hfmpi2c->Mode;
if ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) != RESET) && \
(tmp1 != FMPI2C_CR2_STOP) && \
(tmp2 != HAL_FMPI2C_MODE_SLAVE))
{
hfmpi2c->Instance->CR2 |= FMPI2C_CR2_STOP;
tickstart = HAL_GetTick();
}if ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) != RESET) && \ (tmp1 != FMPI2C_CR2_STOP) && \ (tmp2 != HAL_FMPI2C_MODE_SLAVE)) { ... }
while (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF) == RESET)
{
if ((HAL_GetTick() - tickstart) > FMPI2C_TIMEOUT_STOPF)
{
error_code |= HAL_FMPI2C_ERROR_TIMEOUT;
status = HAL_ERROR;
break;
}if ((HAL_GetTick() - tickstart) > FMPI2C_TIMEOUT_STOPF) { ... }
}while (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF) == RESET) { ... }
}if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U)) { ... }
}if (Timeout != HAL_MAX_DELAY) { ... }
}while ((__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF) == RESET) && (status == HAL_OK)) { ... }
if (status == HAL_OK)
{
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_STOPF);
}if (status == HAL_OK) { ... }
error_code |= HAL_FMPI2C_ERROR_AF;
status = HAL_ERROR;
}if (HAL_IS_BIT_SET(itflag, FMPI2C_FLAG_AF)) { ... }
itflag = hfmpi2c->Instance->ISR;
if (HAL_IS_BIT_SET(itflag, FMPI2C_FLAG_BERR))
{
error_code |= HAL_FMPI2C_ERROR_BERR;
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_BERR);
status = HAL_ERROR;
}if (HAL_IS_BIT_SET(itflag, FMPI2C_FLAG_BERR)) { ... }
if (HAL_IS_BIT_SET(itflag, FMPI2C_FLAG_OVR))
{
error_code |= HAL_FMPI2C_ERROR_OVR;
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_OVR);
status = HAL_ERROR;
}if (HAL_IS_BIT_SET(itflag, FMPI2C_FLAG_OVR)) { ... }
if (HAL_IS_BIT_SET(itflag, FMPI2C_FLAG_ARLO))
{
error_code |= HAL_FMPI2C_ERROR_ARLO;
__HAL_FMPI2C_CLEAR_FLAG(hfmpi2c, FMPI2C_FLAG_ARLO);
status = HAL_ERROR;
}if (HAL_IS_BIT_SET(itflag, FMPI2C_FLAG_ARLO)) { ... }
if (status != HAL_OK)
{
FMPI2C_Flush_TXDR(hfmpi2c);
FMPI2C_RESET_CR2(hfmpi2c);
hfmpi2c->ErrorCode |= error_code;
hfmpi2c->State = HAL_FMPI2C_STATE_READY;
hfmpi2c->Mode = HAL_FMPI2C_MODE_NONE;
__HAL_UNLOCK(hfmpi2c);
}if (status != HAL_OK) { ... }
return status;
}{ ... }
/* ... */
static void FMPI2C_TransferConfig(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t Size, uint32_t Mode,
uint32_t Request)
{
assert_param(IS_FMPI2C_ALL_INSTANCE(hfmpi2c->Instance));
assert_param(IS_TRANSFER_MODE(Mode));
assert_param(IS_TRANSFER_REQUEST(Request));
uint32_t tmp = ((uint32_t)(((uint32_t)DevAddress & FMPI2C_CR2_SADD) | \
(((uint32_t)Size << FMPI2C_CR2_NBYTES_Pos) & FMPI2C_CR2_NBYTES) | \
(uint32_t)Mode | (uint32_t)Request) & (~0x80000000U));
MODIFY_REG(hfmpi2c->Instance->CR2, \
((FMPI2C_CR2_SADD | FMPI2C_CR2_NBYTES | FMPI2C_CR2_RELOAD | FMPI2C_CR2_AUTOEND | \
(FMPI2C_CR2_RD_WRN & (uint32_t)(Request >> (31U - FMPI2C_CR2_RD_WRN_Pos))) | \
FMPI2C_CR2_START | FMPI2C_CR2_STOP)), tmp);
}{ ... }
/* ... */
static void FMPI2C_Enable_IRQ(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t InterruptRequest)
{
uint32_t tmpisr = 0U;
if ((hfmpi2c->XferISR != FMPI2C_Master_ISR_DMA) && \
(hfmpi2c->XferISR != FMPI2C_Slave_ISR_DMA) && \
(hfmpi2c->XferISR != FMPI2C_Mem_ISR_DMA))
{
if ((InterruptRequest & FMPI2C_XFER_LISTEN_IT) == FMPI2C_XFER_LISTEN_IT)
{
tmpisr |= FMPI2C_IT_ADDRI | FMPI2C_IT_STOPI | FMPI2C_IT_NACKI | FMPI2C_IT_ERRI;
}if ((InterruptRequest & FMPI2C_XFER_LISTEN_IT) == FMPI2C_XFER_LISTEN_IT) { ... }
if ((InterruptRequest & FMPI2C_XFER_TX_IT) == FMPI2C_XFER_TX_IT)
{
tmpisr |= FMPI2C_IT_ERRI | FMPI2C_IT_TCI | FMPI2C_IT_STOPI | FMPI2C_IT_NACKI | FMPI2C_IT_TXI;
}if ((InterruptRequest & FMPI2C_XFER_TX_IT) == FMPI2C_XFER_TX_IT) { ... }
if ((InterruptRequest & FMPI2C_XFER_RX_IT) == FMPI2C_XFER_RX_IT)
{
tmpisr |= FMPI2C_IT_ERRI | FMPI2C_IT_TCI | FMPI2C_IT_STOPI | FMPI2C_IT_NACKI | FMPI2C_IT_RXI;
}if ((InterruptRequest & FMPI2C_XFER_RX_IT) == FMPI2C_XFER_RX_IT) { ... }
if (InterruptRequest == FMPI2C_XFER_ERROR_IT)
{
tmpisr |= FMPI2C_IT_ERRI | FMPI2C_IT_NACKI;
}if (InterruptRequest == FMPI2C_XFER_ERROR_IT) { ... }
if (InterruptRequest == FMPI2C_XFER_CPLT_IT)
{
tmpisr |= FMPI2C_IT_STOPI;
}if (InterruptRequest == FMPI2C_XFER_CPLT_IT) { ... }
}if ((hfmpi2c->XferISR != FMPI2C_Master_ISR_DMA) && \ (hfmpi2c->XferISR != FMPI2C_Slave_ISR_DMA) && \ (hfmpi2c->XferISR != FMPI2C_Mem_ISR_DMA)) { ... }
else
{
if ((InterruptRequest & FMPI2C_XFER_LISTEN_IT) == FMPI2C_XFER_LISTEN_IT)
{
tmpisr |= FMPI2C_IT_ADDRI | FMPI2C_IT_STOPI | FMPI2C_IT_NACKI | FMPI2C_IT_ERRI;
}if ((InterruptRequest & FMPI2C_XFER_LISTEN_IT) == FMPI2C_XFER_LISTEN_IT) { ... }
if ((InterruptRequest & FMPI2C_XFER_TX_IT) == FMPI2C_XFER_TX_IT)
{
tmpisr |= FMPI2C_IT_ERRI | FMPI2C_IT_TCI | FMPI2C_IT_STOPI | FMPI2C_IT_NACKI | FMPI2C_IT_TXI;
}if ((InterruptRequest & FMPI2C_XFER_TX_IT) == FMPI2C_XFER_TX_IT) { ... }
if ((InterruptRequest & FMPI2C_XFER_RX_IT) == FMPI2C_XFER_RX_IT)
{
tmpisr |= FMPI2C_IT_ERRI | FMPI2C_IT_TCI | FMPI2C_IT_STOPI | FMPI2C_IT_NACKI | FMPI2C_IT_RXI;
}if ((InterruptRequest & FMPI2C_XFER_RX_IT) == FMPI2C_XFER_RX_IT) { ... }
if (InterruptRequest == FMPI2C_XFER_ERROR_IT)
{
tmpisr |= FMPI2C_IT_ERRI | FMPI2C_IT_NACKI;
}if (InterruptRequest == FMPI2C_XFER_ERROR_IT) { ... }
if (InterruptRequest == FMPI2C_XFER_CPLT_IT)
{
tmpisr |= (FMPI2C_IT_STOPI | FMPI2C_IT_TCI);
}if (InterruptRequest == FMPI2C_XFER_CPLT_IT) { ... }
if (InterruptRequest == FMPI2C_XFER_RELOAD_IT)
{
tmpisr |= FMPI2C_IT_TCI;
}if (InterruptRequest == FMPI2C_XFER_RELOAD_IT) { ... }
}else { ... }
__HAL_FMPI2C_ENABLE_IT(hfmpi2c, tmpisr);
}{ ... }
/* ... */
static void FMPI2C_Disable_IRQ(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t InterruptRequest)
{
uint32_t tmpisr = 0U;
if ((InterruptRequest & FMPI2C_XFER_TX_IT) == FMPI2C_XFER_TX_IT)
{
tmpisr |= FMPI2C_IT_TCI | FMPI2C_IT_TXI;
if (((uint32_t)hfmpi2c->State & (uint32_t)HAL_FMPI2C_STATE_LISTEN) != (uint32_t)HAL_FMPI2C_STATE_LISTEN)
{
tmpisr |= FMPI2C_IT_STOPI | FMPI2C_IT_NACKI | FMPI2C_IT_ERRI;
}if (((uint32_t)hfmpi2c->State & (uint32_t)HAL_FMPI2C_STATE_LISTEN) != (uint32_t)HAL_FMPI2C_STATE_LISTEN) { ... }
}if ((InterruptRequest & FMPI2C_XFER_TX_IT) == FMPI2C_XFER_TX_IT) { ... }
if ((InterruptRequest & FMPI2C_XFER_RX_IT) == FMPI2C_XFER_RX_IT)
{
tmpisr |= FMPI2C_IT_TCI | FMPI2C_IT_RXI;
if (((uint32_t)hfmpi2c->State & (uint32_t)HAL_FMPI2C_STATE_LISTEN) != (uint32_t)HAL_FMPI2C_STATE_LISTEN)
{
tmpisr |= FMPI2C_IT_STOPI | FMPI2C_IT_NACKI | FMPI2C_IT_ERRI;
}if (((uint32_t)hfmpi2c->State & (uint32_t)HAL_FMPI2C_STATE_LISTEN) != (uint32_t)HAL_FMPI2C_STATE_LISTEN) { ... }
}if ((InterruptRequest & FMPI2C_XFER_RX_IT) == FMPI2C_XFER_RX_IT) { ... }
if ((InterruptRequest & FMPI2C_XFER_LISTEN_IT) == FMPI2C_XFER_LISTEN_IT)
{
tmpisr |= FMPI2C_IT_ADDRI | FMPI2C_IT_STOPI | FMPI2C_IT_NACKI | FMPI2C_IT_ERRI;
}if ((InterruptRequest & FMPI2C_XFER_LISTEN_IT) == FMPI2C_XFER_LISTEN_IT) { ... }
if (InterruptRequest == FMPI2C_XFER_ERROR_IT)
{
tmpisr |= FMPI2C_IT_ERRI | FMPI2C_IT_NACKI;
}if (InterruptRequest == FMPI2C_XFER_ERROR_IT) { ... }
if (InterruptRequest == FMPI2C_XFER_CPLT_IT)
{
tmpisr |= FMPI2C_IT_STOPI;
}if (InterruptRequest == FMPI2C_XFER_CPLT_IT) { ... }
if (InterruptRequest == FMPI2C_XFER_RELOAD_IT)
{
tmpisr |= FMPI2C_IT_TCI;
}if (InterruptRequest == FMPI2C_XFER_RELOAD_IT) { ... }
__HAL_FMPI2C_DISABLE_IT(hfmpi2c, tmpisr);
}{ ... }
/* ... */
static void FMPI2C_ConvertOtherXferOptions(FMPI2C_HandleTypeDef *hfmpi2c)
{
if (hfmpi2c->XferOptions == FMPI2C_OTHER_FRAME)
{
hfmpi2c->XferOptions = FMPI2C_FIRST_FRAME;
}if (hfmpi2c->XferOptions == FMPI2C_OTHER_FRAME) { ... }
else if (hfmpi2c->XferOptions == FMPI2C_OTHER_AND_LAST_FRAME)
{
hfmpi2c->XferOptions = FMPI2C_FIRST_AND_LAST_FRAME;
}else if (hfmpi2c->XferOptions == FMPI2C_OTHER_AND_LAST_FRAME) { ... }
else
{
}else { ... }
}{ ... }
/* ... */
/* ... */
#endif /* ... */
#endif
/* ... */
/* ... */