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
218
219
223
224
225
226
227
228
231
232
233
234
235
238
239
240
243
247
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
292
293
294
295
296
297
298
302
303
304
305
306
307
308
309
310
311
312
313
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
340
341
342
343
344
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
393
394
395
396
400
401
402
403
404
405
412
413
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
434
443
444
449
458
459
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
488
489
490
491
492
493
494
495
496
497
498
499
520
541
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
792
793
794
798
799
800
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
844
849
850
851
855
856
857
858
859
860
861
862
863
870
871
872
873
874
875
876
880
881
882
886
887
888
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
920
921
922
923
924
925
926
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
948
949
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1033
1034
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
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
1122
1123
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1289
1290
1291
1292
1293
1295
1296
1297
1298
1299
1300
1301
1305
1306
1307
1308
1309
1310
1312
1313
1314
1315
1316
1317
1318
1322
1323
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1457
1458
1459
1460
1461
1463
1464
1465
1466
1467
1468
1469
1473
1474
1475
1476
1477
1478
1480
1481
1482
1483
1484
1485
1486
1490
1491
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1653
1654
1655
1659
1660
1661
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1752
1753
1754
1758
1759
1760
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1856
1857
1858
1862
1863
1864
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1918
1919
1920
1921
1922
1923
1924
1925
1926
1931
1932
1933
1934
1935
1936
1939
1940
1941
1946
1947
1948
1949
1950
1951
1954
1955
1956
1961
1962
1963
1964
1965
1966
1969
1970
1971
1976
1977
1978
1979
1980
1981
1984
1985
1986
1991
1992
1993
1994
1995
1996
1999
2000
2001
2006
2007
2008
2009
2010
2011
2014
2015
2016
2021
2022
2023
2024
2025
2026
2029
2030
2031
2036
2037
2038
2039
2040
2041
2044
2045
2046
2051
2052
2053
2054
2055
2056
2059
2060
2061
2066
2067
2068
2069
2070
2071
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2107
2108
2109
2110
2111
2112
2113
2114
2115
2118
2121
2124
2127
2130
2133
2136
2139
2142
2145
2148
2151
2157
2158
2159
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2224
2227
2230
2233
2236
2239
2242
2245
2248
2251
2254
2257
2263
2264
2265
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2324
2329
2330
2335
2339
2340
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2399
2400
2401
2402
2403
2404
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2463
2464
2465
2466
2467
2468
2473
2477
2478
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2503
2504
2505
2506
2507
2508
2509
2510
2511
2515
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2549
2550
2551
2552
2553
2554
2555
2556
2557
2560
2561
2564
2565
2568
2569
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2901
2902
2905
2906
2907
2910
2911
2914
2915
/* ... */
#include "stm32f4xx_hal.h"
#if defined(QUADSPI)
/* ... */
/* ... */
#ifdef HAL_QSPI_MODULE_ENABLED
/* ... */
#define QSPI_FUNCTIONAL_MODE_INDIRECT_WRITE 0x00000000U
#define QSPI_FUNCTIONAL_MODE_INDIRECT_READ ((uint32_t)QUADSPI_CCR_FMODE_0)
#define QSPI_FUNCTIONAL_MODE_AUTO_POLLING ((uint32_t)QUADSPI_CCR_FMODE_1)
#define QSPI_FUNCTIONAL_MODE_MEMORY_MAPPED ((uint32_t)QUADSPI_CCR_FMODE)
/* ... */
/* ... */
#define IS_QSPI_FUNCTIONAL_MODE(MODE) (((MODE) == QSPI_FUNCTIONAL_MODE_INDIRECT_WRITE) || \
((MODE) == QSPI_FUNCTIONAL_MODE_INDIRECT_READ) || \
((MODE) == QSPI_FUNCTIONAL_MODE_AUTO_POLLING) || \
((MODE) == QSPI_FUNCTIONAL_MODE_MEMORY_MAPPED))...
5 defines
/* ... */
static void QSPI_DMARxCplt(DMA_HandleTypeDef *hdma);
static void QSPI_DMATxCplt(DMA_HandleTypeDef *hdma);
static void QSPI_DMARxHalfCplt(DMA_HandleTypeDef *hdma);
static void QSPI_DMATxHalfCplt(DMA_HandleTypeDef *hdma);
static void QSPI_DMAError(DMA_HandleTypeDef *hdma);
static void QSPI_DMAAbortCplt(DMA_HandleTypeDef *hdma);
static HAL_StatusTypeDef QSPI_WaitFlagStateUntilTimeout(QSPI_HandleTypeDef *hqspi, uint32_t Flag, FlagStatus State, uint32_t Tickstart, uint32_t Timeout);
static HAL_StatusTypeDef QSPI_WaitFlagStateUntilTimeout_CPUCycle(QSPI_HandleTypeDef *hqspi, uint32_t Flag, FlagStatus State, uint32_t Timeout);
static void QSPI_Config(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, uint32_t FunctionalMode);
Private function prototypes
/* ... */
/* ... */
/* ... */
HAL_StatusTypeDef HAL_QSPI_Init(QSPI_HandleTypeDef *hqspi)
{
HAL_StatusTypeDef status;
uint32_t tickstart = HAL_GetTick();
if(hqspi == NULL)
{
return HAL_ERROR;
}if (hqspi == NULL) { ... }
assert_param(IS_QSPI_ALL_INSTANCE(hqspi->Instance));
assert_param(IS_QSPI_CLOCK_PRESCALER(hqspi->Init.ClockPrescaler));
assert_param(IS_QSPI_FIFO_THRESHOLD(hqspi->Init.FifoThreshold));
assert_param(IS_QSPI_SSHIFT(hqspi->Init.SampleShifting));
assert_param(IS_QSPI_FLASH_SIZE(hqspi->Init.FlashSize));
assert_param(IS_QSPI_CS_HIGH_TIME(hqspi->Init.ChipSelectHighTime));
assert_param(IS_QSPI_CLOCK_MODE(hqspi->Init.ClockMode));
assert_param(IS_QSPI_DUAL_FLASH_MODE(hqspi->Init.DualFlash));
if (hqspi->Init.DualFlash != QSPI_DUALFLASH_ENABLE )
{
assert_param(IS_QSPI_FLASH_ID(hqspi->Init.FlashID));
}if (hqspi->Init.DualFlash != QSPI_DUALFLASH_ENABLE) { ... }
if(hqspi->State == HAL_QSPI_STATE_RESET)
{
hqspi->Lock = HAL_UNLOCKED;
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->ErrorCallback = HAL_QSPI_ErrorCallback;
hqspi->AbortCpltCallback = HAL_QSPI_AbortCpltCallback;
hqspi->FifoThresholdCallback = HAL_QSPI_FifoThresholdCallback;
hqspi->CmdCpltCallback = HAL_QSPI_CmdCpltCallback;
hqspi->RxCpltCallback = HAL_QSPI_RxCpltCallback;
hqspi->TxCpltCallback = HAL_QSPI_TxCpltCallback;
hqspi->RxHalfCpltCallback = HAL_QSPI_RxHalfCpltCallback;
hqspi->TxHalfCpltCallback = HAL_QSPI_TxHalfCpltCallback;
hqspi->StatusMatchCallback = HAL_QSPI_StatusMatchCallback;
hqspi->TimeOutCallback = HAL_QSPI_TimeOutCallback;
if(hqspi->MspInitCallback == NULL)
{
hqspi->MspInitCallback = HAL_QSPI_MspInit;
}if (hqspi->MspInitCallback == NULL) { ... }
hqspi->MspInitCallback(hqspi);/* ... */
#else
HAL_QSPI_MspInit(hqspi);/* ... */
#endif
HAL_QSPI_SetTimeout(hqspi, HAL_QSPI_TIMEOUT_DEFAULT_VALUE);
}if (hqspi->State == HAL_QSPI_STATE_RESET) { ... }
MODIFY_REG(hqspi->Instance->CR, QUADSPI_CR_FTHRES,
((hqspi->Init.FifoThreshold - 1U) << QUADSPI_CR_FTHRES_Pos));
status = QSPI_WaitFlagStateUntilTimeout(hqspi, QSPI_FLAG_BUSY, RESET, tickstart, hqspi->Timeout);
if(status == HAL_OK)
{
MODIFY_REG(hqspi->Instance->CR, (QUADSPI_CR_PRESCALER | QUADSPI_CR_SSHIFT | QUADSPI_CR_FSEL | QUADSPI_CR_DFM),
((hqspi->Init.ClockPrescaler << QUADSPI_CR_PRESCALER_Pos) |
hqspi->Init.SampleShifting | hqspi->Init.FlashID | hqspi->Init.DualFlash));
MODIFY_REG(hqspi->Instance->DCR, (QUADSPI_DCR_FSIZE | QUADSPI_DCR_CSHT | QUADSPI_DCR_CKMODE),
((hqspi->Init.FlashSize << QUADSPI_DCR_FSIZE_Pos) |
hqspi->Init.ChipSelectHighTime | hqspi->Init.ClockMode));
__HAL_QSPI_ENABLE(hqspi);
hqspi->ErrorCode = HAL_QSPI_ERROR_NONE;
hqspi->State = HAL_QSPI_STATE_READY;
}if (status == HAL_OK) { ... }
__HAL_UNLOCK(hqspi);
return status;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_DeInit(QSPI_HandleTypeDef *hqspi)
{
if(hqspi == NULL)
{
return HAL_ERROR;
}if (hqspi == NULL) { ... }
__HAL_QSPI_DISABLE(hqspi);
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
if(hqspi->MspDeInitCallback == NULL)
{
hqspi->MspDeInitCallback = HAL_QSPI_MspDeInit;
}if (hqspi->MspDeInitCallback == NULL) { ... }
hqspi->MspDeInitCallback(hqspi);/* ... */
#else
HAL_QSPI_MspDeInit(hqspi);/* ... */
#endif
hqspi->ErrorCode = HAL_QSPI_ERROR_NONE;
hqspi->State = HAL_QSPI_STATE_RESET;
__HAL_UNLOCK(hqspi);
return HAL_OK;
}{ ... }
/* ... */
__weak void HAL_QSPI_MspInit(QSPI_HandleTypeDef *hqspi)
{
UNUSED(hqspi);
/* ... */
}{ ... }
/* ... */
__weak void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef *hqspi)
{
UNUSED(hqspi);
/* ... */
}{ ... }
/* ... */
/* ... */
/* ... */
void HAL_QSPI_IRQHandler(QSPI_HandleTypeDef *hqspi)
{
__IO uint32_t *data_reg;
uint32_t flag = READ_REG(hqspi->Instance->SR);
uint32_t itsource = READ_REG(hqspi->Instance->CR);
if(((flag & QSPI_FLAG_FT) != 0U) && ((itsource & QSPI_IT_FT) != 0U))
{
data_reg = &hqspi->Instance->DR;
if(hqspi->State == HAL_QSPI_STATE_BUSY_INDIRECT_TX)
{
while(__HAL_QSPI_GET_FLAG(hqspi, QSPI_FLAG_FT) != RESET)
{
if (hqspi->TxXferCount > 0U)
{
*((__IO uint8_t *)data_reg) = *hqspi->pTxBuffPtr;
hqspi->pTxBuffPtr++;
hqspi->TxXferCount--;
}if (hqspi->TxXferCount > 0U) { ... }
else
{
__HAL_QSPI_DISABLE_IT(hqspi, QSPI_IT_FT);
break;
}else { ... }
}while (__HAL_QSPI_GET_FLAG(hqspi, QSPI_FLAG_FT) != RESET) { ... }
}if (hqspi->State == HAL_QSPI_STATE_BUSY_INDIRECT_TX) { ... }
else if(hqspi->State == HAL_QSPI_STATE_BUSY_INDIRECT_RX)
{
while(__HAL_QSPI_GET_FLAG(hqspi, QSPI_FLAG_FT) != RESET)
{
if (hqspi->RxXferCount > 0U)
{
*hqspi->pRxBuffPtr = *((__IO uint8_t *)data_reg);
hqspi->pRxBuffPtr++;
hqspi->RxXferCount--;
}if (hqspi->RxXferCount > 0U) { ... }
else
{
__HAL_QSPI_DISABLE_IT(hqspi, QSPI_IT_FT);
break;
}else { ... }
}while (__HAL_QSPI_GET_FLAG(hqspi, QSPI_FLAG_FT) != RESET) { ... }
}else if (hqspi->State == HAL_QSPI_STATE_BUSY_INDIRECT_RX) { ... }
else
{
}else { ... }
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->FifoThresholdCallback(hqspi);
#else
HAL_QSPI_FifoThresholdCallback(hqspi);
#endif
}if (((flag & QSPI_FLAG_FT) != 0U) && ((itsource & QSPI_IT_FT) != 0U)) { ... }
QSPI Fifo Threshold interrupt occurred
else if(((flag & QSPI_FLAG_TC) != 0U) && ((itsource & QSPI_IT_TC) != 0U))
{
WRITE_REG(hqspi->Instance->FCR, QSPI_FLAG_TC);
__HAL_QSPI_DISABLE_IT(hqspi, QSPI_IT_TC | QSPI_IT_TE | QSPI_IT_FT);
if(hqspi->State == HAL_QSPI_STATE_BUSY_INDIRECT_TX)
{
if ((hqspi->Instance->CR & QUADSPI_CR_DMAEN) != 0U)
{
CLEAR_BIT(hqspi->Instance->CR, QUADSPI_CR_DMAEN);
__HAL_DMA_DISABLE(hqspi->hdma);
}if ((hqspi->Instance->CR & QUADSPI_CR_DMAEN) != 0U) { ... }
HAL_QSPI_Abort_IT(hqspi);
hqspi->State = HAL_QSPI_STATE_READY;
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->TxCpltCallback(hqspi);
#else
HAL_QSPI_TxCpltCallback(hqspi);
#endif
}if (hqspi->State == HAL_QSPI_STATE_BUSY_INDIRECT_TX) { ... }
else if(hqspi->State == HAL_QSPI_STATE_BUSY_INDIRECT_RX)
{
if ((hqspi->Instance->CR & QUADSPI_CR_DMAEN) != 0U)
{
CLEAR_BIT(hqspi->Instance->CR, QUADSPI_CR_DMAEN);
__HAL_DMA_DISABLE(hqspi->hdma);
}if ((hqspi->Instance->CR & QUADSPI_CR_DMAEN) != 0U) { ... }
else
{
data_reg = &hqspi->Instance->DR;
while(READ_BIT(hqspi->Instance->SR, QUADSPI_SR_FLEVEL) != 0U)
{
if (hqspi->RxXferCount > 0U)
{
*hqspi->pRxBuffPtr = *((__IO uint8_t *)data_reg);
hqspi->pRxBuffPtr++;
hqspi->RxXferCount--;
}if (hqspi->RxXferCount > 0U) { ... }
else
{
break;
}else { ... }
}while (READ_BIT(hqspi->Instance->SR, QUADSPI_SR_FLEVEL) != 0U) { ... }
}else { ... }
HAL_QSPI_Abort_IT(hqspi);
hqspi->State = HAL_QSPI_STATE_READY;
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->RxCpltCallback(hqspi);
#else
HAL_QSPI_RxCpltCallback(hqspi);
#endif
}else if (hqspi->State == HAL_QSPI_STATE_BUSY_INDIRECT_RX) { ... }
else if(hqspi->State == HAL_QSPI_STATE_BUSY)
{
hqspi->State = HAL_QSPI_STATE_READY;
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->CmdCpltCallback(hqspi);
#else
HAL_QSPI_CmdCpltCallback(hqspi);
#endif
}else if (hqspi->State == HAL_QSPI_STATE_BUSY) { ... }
else if(hqspi->State == HAL_QSPI_STATE_ABORT)
{
CLEAR_BIT(hqspi->Instance->CCR, QUADSPI_CCR_FMODE);
hqspi->State = HAL_QSPI_STATE_READY;
if (hqspi->ErrorCode == HAL_QSPI_ERROR_NONE)
{
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->AbortCpltCallback(hqspi);
#else
HAL_QSPI_AbortCpltCallback(hqspi);
#endif
}if (hqspi->ErrorCode == HAL_QSPI_ERROR_NONE) { ... }
else
{
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->ErrorCallback(hqspi);
#else
HAL_QSPI_ErrorCallback(hqspi);
#endif
}else { ... }
}else if (hqspi->State == HAL_QSPI_STATE_ABORT) { ... }
else
{
}else { ... }
}else if (((flag & QSPI_FLAG_TC) != 0U) && ((itsource & QSPI_IT_TC) != 0U)) { ... }
QSPI Transfer Complete interrupt occurred
else if(((flag & QSPI_FLAG_SM) != 0U) && ((itsource & QSPI_IT_SM) != 0U))
{
WRITE_REG(hqspi->Instance->FCR, QSPI_FLAG_SM);
if(READ_BIT(hqspi->Instance->CR, QUADSPI_CR_APMS) != 0U)
{
__HAL_QSPI_DISABLE_IT(hqspi, (QSPI_IT_SM | QSPI_IT_TE));
hqspi->State = HAL_QSPI_STATE_READY;
}if (READ_BIT(hqspi->Instance->CR, QUADSPI_CR_APMS) != 0U) { ... }
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->StatusMatchCallback(hqspi);
#else
HAL_QSPI_StatusMatchCallback(hqspi);
#endif
}else if (((flag & QSPI_FLAG_SM) != 0U) && ((itsource & QSPI_IT_SM) != 0U)) { ... }
QSPI Status Match interrupt occurred
else if(((flag & QSPI_FLAG_TE) != 0U) && ((itsource & QSPI_IT_TE) != 0U))
{
WRITE_REG(hqspi->Instance->FCR, QSPI_FLAG_TE);
__HAL_QSPI_DISABLE_IT(hqspi, QSPI_IT_SM | QSPI_IT_TC | QSPI_IT_TE | QSPI_IT_FT);
hqspi->ErrorCode |= HAL_QSPI_ERROR_TRANSFER;
if ((hqspi->Instance->CR & QUADSPI_CR_DMAEN) != 0U)
{
CLEAR_BIT(hqspi->Instance->CR, QUADSPI_CR_DMAEN);
hqspi->hdma->XferAbortCallback = QSPI_DMAAbortCplt;
if (HAL_DMA_Abort_IT(hqspi->hdma) != HAL_OK)
{
hqspi->ErrorCode |= HAL_QSPI_ERROR_DMA;
hqspi->State = HAL_QSPI_STATE_READY;
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->ErrorCallback(hqspi);
#else
HAL_QSPI_ErrorCallback(hqspi);
#endif
}if (HAL_DMA_Abort_IT(hqspi->hdma) != HAL_OK) { ... }
}if ((hqspi->Instance->CR & QUADSPI_CR_DMAEN) != 0U) { ... }
else
{
hqspi->State = HAL_QSPI_STATE_READY;
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->ErrorCallback(hqspi);
#else
HAL_QSPI_ErrorCallback(hqspi);
#endif
}else { ... }
}else if (((flag & QSPI_FLAG_TE) != 0U) && ((itsource & QSPI_IT_TE) != 0U)) { ... }
QSPI Transfer Error interrupt occurred
else if(((flag & QSPI_FLAG_TO) != 0U) && ((itsource & QSPI_IT_TO) != 0U))
{
WRITE_REG(hqspi->Instance->FCR, QSPI_FLAG_TO);
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->TimeOutCallback(hqspi);
#else
HAL_QSPI_TimeOutCallback(hqspi);
#endif
}else if (((flag & QSPI_FLAG_TO) != 0U) && ((itsource & QSPI_IT_TO) != 0U)) { ... }
else
{
}else { ... }
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_Command(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, uint32_t Timeout)
{
HAL_StatusTypeDef status;
uint32_t tickstart = HAL_GetTick();
assert_param(IS_QSPI_INSTRUCTION_MODE(cmd->InstructionMode));
if (cmd->InstructionMode != QSPI_INSTRUCTION_NONE)
{
assert_param(IS_QSPI_INSTRUCTION(cmd->Instruction));
}if (cmd->InstructionMode != QSPI_INSTRUCTION_NONE) { ... }
assert_param(IS_QSPI_ADDRESS_MODE(cmd->AddressMode));
if (cmd->AddressMode != QSPI_ADDRESS_NONE)
{
assert_param(IS_QSPI_ADDRESS_SIZE(cmd->AddressSize));
}if (cmd->AddressMode != QSPI_ADDRESS_NONE) { ... }
assert_param(IS_QSPI_ALTERNATE_BYTES_MODE(cmd->AlternateByteMode));
if (cmd->AlternateByteMode != QSPI_ALTERNATE_BYTES_NONE)
{
assert_param(IS_QSPI_ALTERNATE_BYTES_SIZE(cmd->AlternateBytesSize));
}if (cmd->AlternateByteMode != QSPI_ALTERNATE_BYTES_NONE) { ... }
assert_param(IS_QSPI_DUMMY_CYCLES(cmd->DummyCycles));
assert_param(IS_QSPI_DATA_MODE(cmd->DataMode));
assert_param(IS_QSPI_DDR_MODE(cmd->DdrMode));
assert_param(IS_QSPI_DDR_HHC(cmd->DdrHoldHalfCycle));
assert_param(IS_QSPI_SIOO_MODE(cmd->SIOOMode));
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
hqspi->ErrorCode = HAL_QSPI_ERROR_NONE;
hqspi->State = HAL_QSPI_STATE_BUSY;
status = QSPI_WaitFlagStateUntilTimeout(hqspi, QSPI_FLAG_BUSY, RESET, tickstart, Timeout);
if (status == HAL_OK)
{
QSPI_Config(hqspi, cmd, QSPI_FUNCTIONAL_MODE_INDIRECT_WRITE);
if (cmd->DataMode == QSPI_DATA_NONE)
{
/* ... */
status = QSPI_WaitFlagStateUntilTimeout(hqspi, QSPI_FLAG_TC, SET, tickstart, Timeout);
if (status == HAL_OK)
{
__HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_TC);
hqspi->State = HAL_QSPI_STATE_READY;
}if (status == HAL_OK) { ... }
}if (cmd->DataMode == QSPI_DATA_NONE) { ... }
else
{
hqspi->State = HAL_QSPI_STATE_READY;
}else { ... }
}if (status == HAL_OK) { ... }
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else
{
status = HAL_BUSY;
}else { ... }
__HAL_UNLOCK(hqspi);
return status;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_Command_IT(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd)
{
HAL_StatusTypeDef status;
assert_param(IS_QSPI_INSTRUCTION_MODE(cmd->InstructionMode));
if (cmd->InstructionMode != QSPI_INSTRUCTION_NONE)
{
assert_param(IS_QSPI_INSTRUCTION(cmd->Instruction));
}if (cmd->InstructionMode != QSPI_INSTRUCTION_NONE) { ... }
assert_param(IS_QSPI_ADDRESS_MODE(cmd->AddressMode));
if (cmd->AddressMode != QSPI_ADDRESS_NONE)
{
assert_param(IS_QSPI_ADDRESS_SIZE(cmd->AddressSize));
}if (cmd->AddressMode != QSPI_ADDRESS_NONE) { ... }
assert_param(IS_QSPI_ALTERNATE_BYTES_MODE(cmd->AlternateByteMode));
if (cmd->AlternateByteMode != QSPI_ALTERNATE_BYTES_NONE)
{
assert_param(IS_QSPI_ALTERNATE_BYTES_SIZE(cmd->AlternateBytesSize));
}if (cmd->AlternateByteMode != QSPI_ALTERNATE_BYTES_NONE) { ... }
assert_param(IS_QSPI_DUMMY_CYCLES(cmd->DummyCycles));
assert_param(IS_QSPI_DATA_MODE(cmd->DataMode));
assert_param(IS_QSPI_DDR_MODE(cmd->DdrMode));
assert_param(IS_QSPI_DDR_HHC(cmd->DdrHoldHalfCycle));
assert_param(IS_QSPI_SIOO_MODE(cmd->SIOOMode));
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
hqspi->ErrorCode = HAL_QSPI_ERROR_NONE;
hqspi->State = HAL_QSPI_STATE_BUSY;
status = QSPI_WaitFlagStateUntilTimeout_CPUCycle(hqspi, QSPI_FLAG_BUSY, RESET, hqspi->Timeout);
if (status == HAL_OK)
{
if (cmd->DataMode == QSPI_DATA_NONE)
{
__HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_TE | QSPI_FLAG_TC);
}if (cmd->DataMode == QSPI_DATA_NONE) { ... }
QSPI_Config(hqspi, cmd, QSPI_FUNCTIONAL_MODE_INDIRECT_WRITE);
if (cmd->DataMode == QSPI_DATA_NONE)
{
/* ... */
__HAL_UNLOCK(hqspi);
__HAL_QSPI_ENABLE_IT(hqspi, QSPI_IT_TE | QSPI_IT_TC);
}if (cmd->DataMode == QSPI_DATA_NONE) { ... }
else
{
hqspi->State = HAL_QSPI_STATE_READY;
__HAL_UNLOCK(hqspi);
}else { ... }
}if (status == HAL_OK) { ... }
else
{
__HAL_UNLOCK(hqspi);
}else { ... }
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else
{
status = HAL_BUSY;
__HAL_UNLOCK(hqspi);
}else { ... }
return status;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_Transmit(QSPI_HandleTypeDef *hqspi, uint8_t *pData, uint32_t Timeout)
{
HAL_StatusTypeDef status = HAL_OK;
uint32_t tickstart = HAL_GetTick();
__IO uint32_t *data_reg = &hqspi->Instance->DR;
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
hqspi->ErrorCode = HAL_QSPI_ERROR_NONE;
if(pData != NULL )
{
hqspi->State = HAL_QSPI_STATE_BUSY_INDIRECT_TX;
hqspi->TxXferCount = READ_REG(hqspi->Instance->DLR) + 1U;
hqspi->TxXferSize = READ_REG(hqspi->Instance->DLR) + 1U;
hqspi->pTxBuffPtr = pData;
MODIFY_REG(hqspi->Instance->CCR, QUADSPI_CCR_FMODE, QSPI_FUNCTIONAL_MODE_INDIRECT_WRITE);
while(hqspi->TxXferCount > 0U)
{
status = QSPI_WaitFlagStateUntilTimeout(hqspi, QSPI_FLAG_FT, SET, tickstart, Timeout);
if (status != HAL_OK)
{
break;
}if (status != HAL_OK) { ... }
*((__IO uint8_t *)data_reg) = *hqspi->pTxBuffPtr;
hqspi->pTxBuffPtr++;
hqspi->TxXferCount--;
}while (hqspi->TxXferCount > 0U) { ... }
if (status == HAL_OK)
{
status = QSPI_WaitFlagStateUntilTimeout(hqspi, QSPI_FLAG_TC, SET, tickstart, Timeout);
if (status == HAL_OK)
{
__HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_TC);
status = HAL_QSPI_Abort(hqspi);
}if (status == HAL_OK) { ... }
}if (status == HAL_OK) { ... }
hqspi->State = HAL_QSPI_STATE_READY;
}if (pData != NULL) { ... }
else
{
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_PARAM;
status = HAL_ERROR;
}else { ... }
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else
{
status = HAL_BUSY;
}else { ... }
__HAL_UNLOCK(hqspi);
return status;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_Receive(QSPI_HandleTypeDef *hqspi, uint8_t *pData, uint32_t Timeout)
{
HAL_StatusTypeDef status = HAL_OK;
uint32_t tickstart = HAL_GetTick();
uint32_t addr_reg = READ_REG(hqspi->Instance->AR);
__IO uint32_t *data_reg = &hqspi->Instance->DR;
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
hqspi->ErrorCode = HAL_QSPI_ERROR_NONE;
if(pData != NULL )
{
hqspi->State = HAL_QSPI_STATE_BUSY_INDIRECT_RX;
hqspi->RxXferCount = READ_REG(hqspi->Instance->DLR) + 1U;
hqspi->RxXferSize = READ_REG(hqspi->Instance->DLR) + 1U;
hqspi->pRxBuffPtr = pData;
MODIFY_REG(hqspi->Instance->CCR, QUADSPI_CCR_FMODE, QSPI_FUNCTIONAL_MODE_INDIRECT_READ);
WRITE_REG(hqspi->Instance->AR, addr_reg);
while(hqspi->RxXferCount > 0U)
{
status = QSPI_WaitFlagStateUntilTimeout(hqspi, (QSPI_FLAG_FT | QSPI_FLAG_TC), SET, tickstart, Timeout);
if (status != HAL_OK)
{
break;
}if (status != HAL_OK) { ... }
*hqspi->pRxBuffPtr = *((__IO uint8_t *)data_reg);
hqspi->pRxBuffPtr++;
hqspi->RxXferCount--;
}while (hqspi->RxXferCount > 0U) { ... }
if (status == HAL_OK)
{
status = QSPI_WaitFlagStateUntilTimeout(hqspi, QSPI_FLAG_TC, SET, tickstart, Timeout);
if (status == HAL_OK)
{
__HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_TC);
status = HAL_QSPI_Abort(hqspi);
}if (status == HAL_OK) { ... }
}if (status == HAL_OK) { ... }
hqspi->State = HAL_QSPI_STATE_READY;
}if (pData != NULL) { ... }
else
{
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_PARAM;
status = HAL_ERROR;
}else { ... }
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else
{
status = HAL_BUSY;
}else { ... }
__HAL_UNLOCK(hqspi);
return status;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_Transmit_IT(QSPI_HandleTypeDef *hqspi, uint8_t *pData)
{
HAL_StatusTypeDef status = HAL_OK;
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
hqspi->ErrorCode = HAL_QSPI_ERROR_NONE;
if(pData != NULL )
{
hqspi->State = HAL_QSPI_STATE_BUSY_INDIRECT_TX;
hqspi->TxXferCount = READ_REG(hqspi->Instance->DLR) + 1U;
hqspi->TxXferSize = READ_REG(hqspi->Instance->DLR) + 1U;
hqspi->pTxBuffPtr = pData;
__HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_TE | QSPI_FLAG_TC);
MODIFY_REG(hqspi->Instance->CCR, QUADSPI_CCR_FMODE, QSPI_FUNCTIONAL_MODE_INDIRECT_WRITE);
__HAL_UNLOCK(hqspi);
__HAL_QSPI_ENABLE_IT(hqspi, QSPI_IT_TE | QSPI_IT_FT | QSPI_IT_TC);
}if (pData != NULL) { ... }
else
{
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_PARAM;
status = HAL_ERROR;
__HAL_UNLOCK(hqspi);
}else { ... }
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else
{
status = HAL_BUSY;
__HAL_UNLOCK(hqspi);
}else { ... }
return status;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_Receive_IT(QSPI_HandleTypeDef *hqspi, uint8_t *pData)
{
HAL_StatusTypeDef status = HAL_OK;
uint32_t addr_reg = READ_REG(hqspi->Instance->AR);
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
hqspi->ErrorCode = HAL_QSPI_ERROR_NONE;
if(pData != NULL )
{
hqspi->State = HAL_QSPI_STATE_BUSY_INDIRECT_RX;
hqspi->RxXferCount = READ_REG(hqspi->Instance->DLR) + 1U;
hqspi->RxXferSize = READ_REG(hqspi->Instance->DLR) + 1U;
hqspi->pRxBuffPtr = pData;
__HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_TE | QSPI_FLAG_TC);
MODIFY_REG(hqspi->Instance->CCR, QUADSPI_CCR_FMODE, QSPI_FUNCTIONAL_MODE_INDIRECT_READ);
WRITE_REG(hqspi->Instance->AR, addr_reg);
__HAL_UNLOCK(hqspi);
__HAL_QSPI_ENABLE_IT(hqspi, QSPI_IT_TE | QSPI_IT_FT | QSPI_IT_TC);
}if (pData != NULL) { ... }
else
{
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_PARAM;
status = HAL_ERROR;
__HAL_UNLOCK(hqspi);
}else { ... }
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else
{
status = HAL_BUSY;
__HAL_UNLOCK(hqspi);
}else { ... }
return status;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_Transmit_DMA(QSPI_HandleTypeDef *hqspi, uint8_t *pData)
{
HAL_StatusTypeDef status = HAL_OK;
uint32_t data_size = (READ_REG(hqspi->Instance->DLR) + 1U);
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
hqspi->ErrorCode = HAL_QSPI_ERROR_NONE;
if(pData != NULL )
{
if (hqspi->hdma->Init.PeriphDataAlignment == DMA_PDATAALIGN_BYTE)
{
hqspi->TxXferCount = data_size;
}if (hqspi->hdma->Init.PeriphDataAlignment == DMA_PDATAALIGN_BYTE) { ... }
else if (hqspi->hdma->Init.PeriphDataAlignment == DMA_PDATAALIGN_HALFWORD)
{
if (((data_size % 2U) != 0U) || ((hqspi->Init.FifoThreshold % 2U) != 0U))
{
/* ... */
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_PARAM;
status = HAL_ERROR;
__HAL_UNLOCK(hqspi);
}if (((data_size % 2U) != 0U) || ((hqspi->Init.FifoThreshold % 2U) != 0U)) { ... }
else
{
hqspi->TxXferCount = (data_size >> 1U);
}else { ... }
}else if (hqspi->hdma->Init.PeriphDataAlignment == DMA_PDATAALIGN_HALFWORD) { ... }
else if (hqspi->hdma->Init.PeriphDataAlignment == DMA_PDATAALIGN_WORD)
{
if (((data_size % 4U) != 0U) || ((hqspi->Init.FifoThreshold % 4U) != 0U))
{
/* ... */
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_PARAM;
status = HAL_ERROR;
__HAL_UNLOCK(hqspi);
}if (((data_size % 4U) != 0U) || ((hqspi->Init.FifoThreshold % 4U) != 0U)) { ... }
else
{
hqspi->TxXferCount = (data_size >> 2U);
}else { ... }
}else if (hqspi->hdma->Init.PeriphDataAlignment == DMA_PDATAALIGN_WORD) { ... }
else
{
}else { ... }
if (status == HAL_OK)
{
hqspi->State = HAL_QSPI_STATE_BUSY_INDIRECT_TX;
__HAL_QSPI_CLEAR_FLAG(hqspi, (QSPI_FLAG_TE | QSPI_FLAG_TC));
hqspi->TxXferSize = hqspi->TxXferCount;
hqspi->pTxBuffPtr = pData;
MODIFY_REG(hqspi->Instance->CCR, QUADSPI_CCR_FMODE, QSPI_FUNCTIONAL_MODE_INDIRECT_WRITE);
hqspi->hdma->XferCpltCallback = QSPI_DMATxCplt;
hqspi->hdma->XferHalfCpltCallback = QSPI_DMATxHalfCplt;
hqspi->hdma->XferErrorCallback = QSPI_DMAError;
hqspi->hdma->XferAbortCallback = NULL;
#if defined (QSPI1_V2_1L)
/* ... */
hqspi->hdma->Init.PeriphInc = DMA_PINC_ENABLE;
hqspi->hdma->Init.MemInc = DMA_MINC_DISABLE;
MODIFY_REG(hqspi->hdma->Instance->CR, (DMA_SxCR_MINC | DMA_SxCR_PINC), (hqspi->hdma->Init.MemInc | hqspi->hdma->Init.PeriphInc));
hqspi->hdma->Init.Direction = DMA_PERIPH_TO_MEMORY;/* ... */
#else
hqspi->hdma->Init.Direction = DMA_MEMORY_TO_PERIPH;/* ... */
#endif
MODIFY_REG(hqspi->hdma->Instance->CR, DMA_SxCR_DIR, hqspi->hdma->Init.Direction);
if (HAL_DMA_Start_IT(hqspi->hdma, (uint32_t)pData, (uint32_t)&hqspi->Instance->DR, hqspi->TxXferSize) == HAL_OK)
{
__HAL_UNLOCK(hqspi);
__HAL_QSPI_ENABLE_IT(hqspi, QSPI_IT_TE);
SET_BIT(hqspi->Instance->CR, QUADSPI_CR_DMAEN);
}if (HAL_DMA_Start_IT(hqspi->hdma, (uint32_t)pData, (uint32_t)&hqspi->Instance->DR, hqspi->TxXferSize) == HAL_OK) { ... }
else
{
status = HAL_ERROR;
hqspi->ErrorCode |= HAL_QSPI_ERROR_DMA;
hqspi->State = HAL_QSPI_STATE_READY;
__HAL_UNLOCK(hqspi);
}else { ... }
}if (status == HAL_OK) { ... }
}if (pData != NULL) { ... }
else
{
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_PARAM;
status = HAL_ERROR;
__HAL_UNLOCK(hqspi);
}else { ... }
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else
{
status = HAL_BUSY;
__HAL_UNLOCK(hqspi);
}else { ... }
return status;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_Receive_DMA(QSPI_HandleTypeDef *hqspi, uint8_t *pData)
{
HAL_StatusTypeDef status = HAL_OK;
uint32_t addr_reg = READ_REG(hqspi->Instance->AR);
uint32_t data_size = (READ_REG(hqspi->Instance->DLR) + 1U);
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
hqspi->ErrorCode = HAL_QSPI_ERROR_NONE;
if(pData != NULL )
{
if (hqspi->hdma->Init.PeriphDataAlignment == DMA_PDATAALIGN_BYTE)
{
hqspi->RxXferCount = data_size;
}if (hqspi->hdma->Init.PeriphDataAlignment == DMA_PDATAALIGN_BYTE) { ... }
else if (hqspi->hdma->Init.PeriphDataAlignment == DMA_PDATAALIGN_HALFWORD)
{
if (((data_size % 2U) != 0U) || ((hqspi->Init.FifoThreshold % 2U) != 0U))
{
/* ... */
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_PARAM;
status = HAL_ERROR;
__HAL_UNLOCK(hqspi);
}if (((data_size % 2U) != 0U) || ((hqspi->Init.FifoThreshold % 2U) != 0U)) { ... }
else
{
hqspi->RxXferCount = (data_size >> 1U);
}else { ... }
}else if (hqspi->hdma->Init.PeriphDataAlignment == DMA_PDATAALIGN_HALFWORD) { ... }
else if (hqspi->hdma->Init.PeriphDataAlignment == DMA_PDATAALIGN_WORD)
{
if (((data_size % 4U) != 0U) || ((hqspi->Init.FifoThreshold % 4U) != 0U))
{
/* ... */
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_PARAM;
status = HAL_ERROR;
__HAL_UNLOCK(hqspi);
}if (((data_size % 4U) != 0U) || ((hqspi->Init.FifoThreshold % 4U) != 0U)) { ... }
else
{
hqspi->RxXferCount = (data_size >> 2U);
}else { ... }
}else if (hqspi->hdma->Init.PeriphDataAlignment == DMA_PDATAALIGN_WORD) { ... }
else
{
}else { ... }
if (status == HAL_OK)
{
hqspi->State = HAL_QSPI_STATE_BUSY_INDIRECT_RX;
__HAL_QSPI_CLEAR_FLAG(hqspi, (QSPI_FLAG_TE | QSPI_FLAG_TC));
hqspi->RxXferSize = hqspi->RxXferCount;
hqspi->pRxBuffPtr = pData;
hqspi->hdma->XferCpltCallback = QSPI_DMARxCplt;
hqspi->hdma->XferHalfCpltCallback = QSPI_DMARxHalfCplt;
hqspi->hdma->XferErrorCallback = QSPI_DMAError;
hqspi->hdma->XferAbortCallback = NULL;
#if defined (QSPI1_V2_1L)
/* ... */
hqspi->hdma->Init.PeriphInc = DMA_PINC_ENABLE;
hqspi->hdma->Init.MemInc = DMA_MINC_DISABLE;
MODIFY_REG(hqspi->hdma->Instance->CR, (DMA_SxCR_MINC | DMA_SxCR_PINC), (hqspi->hdma->Init.MemInc | hqspi->hdma->Init.PeriphInc));
hqspi->hdma->Init.Direction = DMA_MEMORY_TO_PERIPH;
/* ... */
WRITE_REG(hqspi->Instance->DLR, (data_size - 1U + 16U));
MODIFY_REG(hqspi->hdma->Instance->CR, DMA_SxCR_DIR, hqspi->hdma->Init.Direction);
MODIFY_REG(hqspi->Instance->CCR, QUADSPI_CCR_FMODE, QSPI_FUNCTIONAL_MODE_INDIRECT_READ);
WRITE_REG(hqspi->Instance->AR, addr_reg);
if(HAL_DMA_Start_IT(hqspi->hdma, (uint32_t)&hqspi->Instance->DR, (uint32_t)pData, hqspi->RxXferSize) == HAL_OK)
{
SET_BIT(hqspi->Instance->CR, QUADSPI_CR_DMAEN);
__HAL_UNLOCK(hqspi);
__HAL_QSPI_ENABLE_IT(hqspi, QSPI_IT_TE);
}if (HAL_DMA_Start_IT(hqspi->hdma, (uint32_t)&hqspi->Instance->DR, (uint32_t)pData, hqspi->RxXferSize) == HAL_OK) { ... }
else
{
status = HAL_ERROR;
hqspi->ErrorCode |= HAL_QSPI_ERROR_DMA;
hqspi->State = HAL_QSPI_STATE_READY;
__HAL_UNLOCK(hqspi);
}else { ... }
/* ... */#else
hqspi->hdma->Init.Direction = DMA_PERIPH_TO_MEMORY;
MODIFY_REG(hqspi->hdma->Instance->CR, DMA_SxCR_DIR, hqspi->hdma->Init.Direction);
if(HAL_DMA_Start_IT(hqspi->hdma, (uint32_t)&hqspi->Instance->DR, (uint32_t)pData, hqspi->RxXferSize)== HAL_OK)
{
MODIFY_REG(hqspi->Instance->CCR, QUADSPI_CCR_FMODE, QSPI_FUNCTIONAL_MODE_INDIRECT_READ);
WRITE_REG(hqspi->Instance->AR, addr_reg);
__HAL_UNLOCK(hqspi);
__HAL_QSPI_ENABLE_IT(hqspi, QSPI_IT_TE);
SET_BIT(hqspi->Instance->CR, QUADSPI_CR_DMAEN);
}if (HAL_DMA_Start_IT(hqspi->hdma, (uint32_t)&hqspi->Instance->DR, (uint32_t)pData, hqspi->RxXferSize)== HAL_OK) { ... }
else
{
status = HAL_ERROR;
hqspi->ErrorCode |= HAL_QSPI_ERROR_DMA;
hqspi->State = HAL_QSPI_STATE_READY;
__HAL_UNLOCK(hqspi);
}else { ... }
/* ... */#endif
}if (status == HAL_OK) { ... }
}if (pData != NULL) { ... }
else
{
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_PARAM;
status = HAL_ERROR;
__HAL_UNLOCK(hqspi);
}else { ... }
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else
{
status = HAL_BUSY;
__HAL_UNLOCK(hqspi);
}else { ... }
return status;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_AutoPolling(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_AutoPollingTypeDef *cfg, uint32_t Timeout)
{
HAL_StatusTypeDef status;
uint32_t tickstart = HAL_GetTick();
assert_param(IS_QSPI_INSTRUCTION_MODE(cmd->InstructionMode));
if (cmd->InstructionMode != QSPI_INSTRUCTION_NONE)
{
assert_param(IS_QSPI_INSTRUCTION(cmd->Instruction));
}if (cmd->InstructionMode != QSPI_INSTRUCTION_NONE) { ... }
assert_param(IS_QSPI_ADDRESS_MODE(cmd->AddressMode));
if (cmd->AddressMode != QSPI_ADDRESS_NONE)
{
assert_param(IS_QSPI_ADDRESS_SIZE(cmd->AddressSize));
}if (cmd->AddressMode != QSPI_ADDRESS_NONE) { ... }
assert_param(IS_QSPI_ALTERNATE_BYTES_MODE(cmd->AlternateByteMode));
if (cmd->AlternateByteMode != QSPI_ALTERNATE_BYTES_NONE)
{
assert_param(IS_QSPI_ALTERNATE_BYTES_SIZE(cmd->AlternateBytesSize));
}if (cmd->AlternateByteMode != QSPI_ALTERNATE_BYTES_NONE) { ... }
assert_param(IS_QSPI_DUMMY_CYCLES(cmd->DummyCycles));
assert_param(IS_QSPI_DATA_MODE(cmd->DataMode));
assert_param(IS_QSPI_DDR_MODE(cmd->DdrMode));
assert_param(IS_QSPI_DDR_HHC(cmd->DdrHoldHalfCycle));
assert_param(IS_QSPI_SIOO_MODE(cmd->SIOOMode));
assert_param(IS_QSPI_INTERVAL(cfg->Interval));
assert_param(IS_QSPI_STATUS_BYTES_SIZE(cfg->StatusBytesSize));
assert_param(IS_QSPI_MATCH_MODE(cfg->MatchMode));
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
hqspi->ErrorCode = HAL_QSPI_ERROR_NONE;
hqspi->State = HAL_QSPI_STATE_BUSY_AUTO_POLLING;
status = QSPI_WaitFlagStateUntilTimeout(hqspi, QSPI_FLAG_BUSY, RESET, tickstart, Timeout);
if (status == HAL_OK)
{
WRITE_REG(hqspi->Instance->PSMAR, cfg->Match);
WRITE_REG(hqspi->Instance->PSMKR, cfg->Mask);
WRITE_REG(hqspi->Instance->PIR, cfg->Interval);
/* ... */
MODIFY_REG(hqspi->Instance->CR, (QUADSPI_CR_PMM | QUADSPI_CR_APMS),
(cfg->MatchMode | QSPI_AUTOMATIC_STOP_ENABLE));
cmd->NbData = cfg->StatusBytesSize;
QSPI_Config(hqspi, cmd, QSPI_FUNCTIONAL_MODE_AUTO_POLLING);
status = QSPI_WaitFlagStateUntilTimeout(hqspi, QSPI_FLAG_SM, SET, tickstart, Timeout);
if (status == HAL_OK)
{
__HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_SM);
hqspi->State = HAL_QSPI_STATE_READY;
}if (status == HAL_OK) { ... }
}if (status == HAL_OK) { ... }
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else
{
status = HAL_BUSY;
}else { ... }
__HAL_UNLOCK(hqspi);
return status;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_AutoPolling_IT(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_AutoPollingTypeDef *cfg)
{
HAL_StatusTypeDef status;
assert_param(IS_QSPI_INSTRUCTION_MODE(cmd->InstructionMode));
if (cmd->InstructionMode != QSPI_INSTRUCTION_NONE)
{
assert_param(IS_QSPI_INSTRUCTION(cmd->Instruction));
}if (cmd->InstructionMode != QSPI_INSTRUCTION_NONE) { ... }
assert_param(IS_QSPI_ADDRESS_MODE(cmd->AddressMode));
if (cmd->AddressMode != QSPI_ADDRESS_NONE)
{
assert_param(IS_QSPI_ADDRESS_SIZE(cmd->AddressSize));
}if (cmd->AddressMode != QSPI_ADDRESS_NONE) { ... }
assert_param(IS_QSPI_ALTERNATE_BYTES_MODE(cmd->AlternateByteMode));
if (cmd->AlternateByteMode != QSPI_ALTERNATE_BYTES_NONE)
{
assert_param(IS_QSPI_ALTERNATE_BYTES_SIZE(cmd->AlternateBytesSize));
}if (cmd->AlternateByteMode != QSPI_ALTERNATE_BYTES_NONE) { ... }
assert_param(IS_QSPI_DUMMY_CYCLES(cmd->DummyCycles));
assert_param(IS_QSPI_DATA_MODE(cmd->DataMode));
assert_param(IS_QSPI_DDR_MODE(cmd->DdrMode));
assert_param(IS_QSPI_DDR_HHC(cmd->DdrHoldHalfCycle));
assert_param(IS_QSPI_SIOO_MODE(cmd->SIOOMode));
assert_param(IS_QSPI_INTERVAL(cfg->Interval));
assert_param(IS_QSPI_STATUS_BYTES_SIZE(cfg->StatusBytesSize));
assert_param(IS_QSPI_MATCH_MODE(cfg->MatchMode));
assert_param(IS_QSPI_AUTOMATIC_STOP(cfg->AutomaticStop));
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
hqspi->ErrorCode = HAL_QSPI_ERROR_NONE;
hqspi->State = HAL_QSPI_STATE_BUSY_AUTO_POLLING;
status = QSPI_WaitFlagStateUntilTimeout_CPUCycle(hqspi, QSPI_FLAG_BUSY, RESET, hqspi->Timeout);
if (status == HAL_OK)
{
WRITE_REG(hqspi->Instance->PSMAR, cfg->Match);
WRITE_REG(hqspi->Instance->PSMKR, cfg->Mask);
WRITE_REG(hqspi->Instance->PIR, cfg->Interval);
MODIFY_REG(hqspi->Instance->CR, (QUADSPI_CR_PMM | QUADSPI_CR_APMS),
(cfg->MatchMode | cfg->AutomaticStop));
__HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_TE | QSPI_FLAG_SM);
cmd->NbData = cfg->StatusBytesSize;
QSPI_Config(hqspi, cmd, QSPI_FUNCTIONAL_MODE_AUTO_POLLING);
__HAL_UNLOCK(hqspi);
__HAL_QSPI_ENABLE_IT(hqspi, (QSPI_IT_SM | QSPI_IT_TE));
}if (status == HAL_OK) { ... }
else
{
__HAL_UNLOCK(hqspi);
}else { ... }
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else
{
status = HAL_BUSY;
__HAL_UNLOCK(hqspi);
}else { ... }
return status;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_MemoryMapped(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_MemoryMappedTypeDef *cfg)
{
HAL_StatusTypeDef status;
uint32_t tickstart = HAL_GetTick();
assert_param(IS_QSPI_INSTRUCTION_MODE(cmd->InstructionMode));
if (cmd->InstructionMode != QSPI_INSTRUCTION_NONE)
{
assert_param(IS_QSPI_INSTRUCTION(cmd->Instruction));
}if (cmd->InstructionMode != QSPI_INSTRUCTION_NONE) { ... }
assert_param(IS_QSPI_ADDRESS_MODE(cmd->AddressMode));
if (cmd->AddressMode != QSPI_ADDRESS_NONE)
{
assert_param(IS_QSPI_ADDRESS_SIZE(cmd->AddressSize));
}if (cmd->AddressMode != QSPI_ADDRESS_NONE) { ... }
assert_param(IS_QSPI_ALTERNATE_BYTES_MODE(cmd->AlternateByteMode));
if (cmd->AlternateByteMode != QSPI_ALTERNATE_BYTES_NONE)
{
assert_param(IS_QSPI_ALTERNATE_BYTES_SIZE(cmd->AlternateBytesSize));
}if (cmd->AlternateByteMode != QSPI_ALTERNATE_BYTES_NONE) { ... }
assert_param(IS_QSPI_DUMMY_CYCLES(cmd->DummyCycles));
assert_param(IS_QSPI_DATA_MODE(cmd->DataMode));
assert_param(IS_QSPI_DDR_MODE(cmd->DdrMode));
assert_param(IS_QSPI_DDR_HHC(cmd->DdrHoldHalfCycle));
assert_param(IS_QSPI_SIOO_MODE(cmd->SIOOMode));
assert_param(IS_QSPI_TIMEOUT_ACTIVATION(cfg->TimeOutActivation));
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
hqspi->ErrorCode = HAL_QSPI_ERROR_NONE;
hqspi->State = HAL_QSPI_STATE_BUSY_MEM_MAPPED;
status = QSPI_WaitFlagStateUntilTimeout(hqspi, QSPI_FLAG_BUSY, RESET, tickstart, hqspi->Timeout);
if (status == HAL_OK)
{
MODIFY_REG(hqspi->Instance->CR, QUADSPI_CR_TCEN, cfg->TimeOutActivation);
if (cfg->TimeOutActivation == QSPI_TIMEOUT_COUNTER_ENABLE)
{
assert_param(IS_QSPI_TIMEOUT_PERIOD(cfg->TimeOutPeriod));
WRITE_REG(hqspi->Instance->LPTR, cfg->TimeOutPeriod);
__HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_TO);
__HAL_QSPI_ENABLE_IT(hqspi, QSPI_IT_TO);
}if (cfg->TimeOutActivation == QSPI_TIMEOUT_COUNTER_ENABLE) { ... }
QSPI_Config(hqspi, cmd, QSPI_FUNCTIONAL_MODE_MEMORY_MAPPED);
}if (status == HAL_OK) { ... }
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else
{
status = HAL_BUSY;
}else { ... }
__HAL_UNLOCK(hqspi);
return status;
}{ ... }
/* ... */
__weak void HAL_QSPI_ErrorCallback(QSPI_HandleTypeDef *hqspi)
{
UNUSED(hqspi);
/* ... */
}{ ... }
/* ... */
__weak void HAL_QSPI_AbortCpltCallback(QSPI_HandleTypeDef *hqspi)
{
UNUSED(hqspi);
/* ... */
}{ ... }
/* ... */
__weak void HAL_QSPI_CmdCpltCallback(QSPI_HandleTypeDef *hqspi)
{
UNUSED(hqspi);
/* ... */
}{ ... }
/* ... */
__weak void HAL_QSPI_RxCpltCallback(QSPI_HandleTypeDef *hqspi)
{
UNUSED(hqspi);
/* ... */
}{ ... }
/* ... */
__weak void HAL_QSPI_TxCpltCallback(QSPI_HandleTypeDef *hqspi)
{
UNUSED(hqspi);
/* ... */
}{ ... }
/* ... */
__weak void HAL_QSPI_RxHalfCpltCallback(QSPI_HandleTypeDef *hqspi)
{
UNUSED(hqspi);
/* ... */
}{ ... }
/* ... */
__weak void HAL_QSPI_TxHalfCpltCallback(QSPI_HandleTypeDef *hqspi)
{
UNUSED(hqspi);
/* ... */
}{ ... }
/* ... */
__weak void HAL_QSPI_FifoThresholdCallback(QSPI_HandleTypeDef *hqspi)
{
UNUSED(hqspi);
/* ... */
}{ ... }
/* ... */
__weak void HAL_QSPI_StatusMatchCallback(QSPI_HandleTypeDef *hqspi)
{
UNUSED(hqspi);
/* ... */
}{ ... }
/* ... */
__weak void HAL_QSPI_TimeOutCallback(QSPI_HandleTypeDef *hqspi)
{
UNUSED(hqspi);
/* ... */
}{ ... }
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
/* ... */
HAL_StatusTypeDef HAL_QSPI_RegisterCallback (QSPI_HandleTypeDef *hqspi, HAL_QSPI_CallbackIDTypeDef CallbackId, pQSPI_CallbackTypeDef pCallback)
{
HAL_StatusTypeDef status = HAL_OK;
if(pCallback == NULL)
{
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_CALLBACK;
return HAL_ERROR;
}if (pCallback == NULL) { ... }
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
switch (CallbackId)
{
case HAL_QSPI_ERROR_CB_ID :
hqspi->ErrorCallback = pCallback;
break;case HAL_QSPI_ERROR_CB_ID :
case HAL_QSPI_ABORT_CB_ID :
hqspi->AbortCpltCallback = pCallback;
break;case HAL_QSPI_ABORT_CB_ID :
case HAL_QSPI_FIFO_THRESHOLD_CB_ID :
hqspi->FifoThresholdCallback = pCallback;
break;case HAL_QSPI_FIFO_THRESHOLD_CB_ID :
case HAL_QSPI_CMD_CPLT_CB_ID :
hqspi->CmdCpltCallback = pCallback;
break;case HAL_QSPI_CMD_CPLT_CB_ID :
case HAL_QSPI_RX_CPLT_CB_ID :
hqspi->RxCpltCallback = pCallback;
break;case HAL_QSPI_RX_CPLT_CB_ID :
case HAL_QSPI_TX_CPLT_CB_ID :
hqspi->TxCpltCallback = pCallback;
break;case HAL_QSPI_TX_CPLT_CB_ID :
case HAL_QSPI_RX_HALF_CPLT_CB_ID :
hqspi->RxHalfCpltCallback = pCallback;
break;case HAL_QSPI_RX_HALF_CPLT_CB_ID :
case HAL_QSPI_TX_HALF_CPLT_CB_ID :
hqspi->TxHalfCpltCallback = pCallback;
break;case HAL_QSPI_TX_HALF_CPLT_CB_ID :
case HAL_QSPI_STATUS_MATCH_CB_ID :
hqspi->StatusMatchCallback = pCallback;
break;case HAL_QSPI_STATUS_MATCH_CB_ID :
case HAL_QSPI_TIMEOUT_CB_ID :
hqspi->TimeOutCallback = pCallback;
break;case HAL_QSPI_TIMEOUT_CB_ID :
case HAL_QSPI_MSP_INIT_CB_ID :
hqspi->MspInitCallback = pCallback;
break;case HAL_QSPI_MSP_INIT_CB_ID :
case HAL_QSPI_MSP_DEINIT_CB_ID :
hqspi->MspDeInitCallback = pCallback;
break;case HAL_QSPI_MSP_DEINIT_CB_ID :
default :
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
break;default
}switch (CallbackId) { ... }
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else if (hqspi->State == HAL_QSPI_STATE_RESET)
{
switch (CallbackId)
{
case HAL_QSPI_MSP_INIT_CB_ID :
hqspi->MspInitCallback = pCallback;
break;case HAL_QSPI_MSP_INIT_CB_ID :
case HAL_QSPI_MSP_DEINIT_CB_ID :
hqspi->MspDeInitCallback = pCallback;
break;case HAL_QSPI_MSP_DEINIT_CB_ID :
default :
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
break;default
}switch (CallbackId) { ... }
}else if (hqspi->State == HAL_QSPI_STATE_RESET) { ... }
else
{
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
}else { ... }
__HAL_UNLOCK(hqspi);
return status;
}HAL_QSPI_RegisterCallback (QSPI_HandleTypeDef *hqspi, HAL_QSPI_CallbackIDTypeDef CallbackId, pQSPI_CallbackTypeDef pCallback) { ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_UnRegisterCallback (QSPI_HandleTypeDef *hqspi, HAL_QSPI_CallbackIDTypeDef CallbackId)
{
HAL_StatusTypeDef status = HAL_OK;
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
switch (CallbackId)
{
case HAL_QSPI_ERROR_CB_ID :
hqspi->ErrorCallback = HAL_QSPI_ErrorCallback;
break;case HAL_QSPI_ERROR_CB_ID :
case HAL_QSPI_ABORT_CB_ID :
hqspi->AbortCpltCallback = HAL_QSPI_AbortCpltCallback;
break;case HAL_QSPI_ABORT_CB_ID :
case HAL_QSPI_FIFO_THRESHOLD_CB_ID :
hqspi->FifoThresholdCallback = HAL_QSPI_FifoThresholdCallback;
break;case HAL_QSPI_FIFO_THRESHOLD_CB_ID :
case HAL_QSPI_CMD_CPLT_CB_ID :
hqspi->CmdCpltCallback = HAL_QSPI_CmdCpltCallback;
break;case HAL_QSPI_CMD_CPLT_CB_ID :
case HAL_QSPI_RX_CPLT_CB_ID :
hqspi->RxCpltCallback = HAL_QSPI_RxCpltCallback;
break;case HAL_QSPI_RX_CPLT_CB_ID :
case HAL_QSPI_TX_CPLT_CB_ID :
hqspi->TxCpltCallback = HAL_QSPI_TxCpltCallback;
break;case HAL_QSPI_TX_CPLT_CB_ID :
case HAL_QSPI_RX_HALF_CPLT_CB_ID :
hqspi->RxHalfCpltCallback = HAL_QSPI_RxHalfCpltCallback;
break;case HAL_QSPI_RX_HALF_CPLT_CB_ID :
case HAL_QSPI_TX_HALF_CPLT_CB_ID :
hqspi->TxHalfCpltCallback = HAL_QSPI_TxHalfCpltCallback;
break;case HAL_QSPI_TX_HALF_CPLT_CB_ID :
case HAL_QSPI_STATUS_MATCH_CB_ID :
hqspi->StatusMatchCallback = HAL_QSPI_StatusMatchCallback;
break;case HAL_QSPI_STATUS_MATCH_CB_ID :
case HAL_QSPI_TIMEOUT_CB_ID :
hqspi->TimeOutCallback = HAL_QSPI_TimeOutCallback;
break;case HAL_QSPI_TIMEOUT_CB_ID :
case HAL_QSPI_MSP_INIT_CB_ID :
hqspi->MspInitCallback = HAL_QSPI_MspInit;
break;case HAL_QSPI_MSP_INIT_CB_ID :
case HAL_QSPI_MSP_DEINIT_CB_ID :
hqspi->MspDeInitCallback = HAL_QSPI_MspDeInit;
break;case HAL_QSPI_MSP_DEINIT_CB_ID :
default :
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
break;default
}switch (CallbackId) { ... }
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else if (hqspi->State == HAL_QSPI_STATE_RESET)
{
switch (CallbackId)
{
case HAL_QSPI_MSP_INIT_CB_ID :
hqspi->MspInitCallback = HAL_QSPI_MspInit;
break;case HAL_QSPI_MSP_INIT_CB_ID :
case HAL_QSPI_MSP_DEINIT_CB_ID :
hqspi->MspDeInitCallback = HAL_QSPI_MspDeInit;
break;case HAL_QSPI_MSP_DEINIT_CB_ID :
default :
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
break;default
}switch (CallbackId) { ... }
}else if (hqspi->State == HAL_QSPI_STATE_RESET) { ... }
else
{
hqspi->ErrorCode |= HAL_QSPI_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
}else { ... }
__HAL_UNLOCK(hqspi);
return status;
}HAL_QSPI_UnRegisterCallback (QSPI_HandleTypeDef *hqspi, HAL_QSPI_CallbackIDTypeDef CallbackId) { ... }
/* ... */#endif
/* ... */
/* ... */
/* ... */
HAL_QSPI_StateTypeDef HAL_QSPI_GetState(QSPI_HandleTypeDef *hqspi)
{
return hqspi->State;
}{ ... }
/* ... */
uint32_t HAL_QSPI_GetError(QSPI_HandleTypeDef *hqspi)
{
return hqspi->ErrorCode;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_Abort(QSPI_HandleTypeDef *hqspi)
{
HAL_StatusTypeDef status = HAL_OK;
uint32_t tickstart = HAL_GetTick();
if (((uint32_t)hqspi->State & 0x2U) != 0U)
{
__HAL_UNLOCK(hqspi);
if ((hqspi->Instance->CR & QUADSPI_CR_DMAEN) != 0U)
{
CLEAR_BIT(hqspi->Instance->CR, QUADSPI_CR_DMAEN);
status = HAL_DMA_Abort(hqspi->hdma);
if(status != HAL_OK)
{
hqspi->ErrorCode |= HAL_QSPI_ERROR_DMA;
}if (status != HAL_OK) { ... }
}if ((hqspi->Instance->CR & QUADSPI_CR_DMAEN) != 0U) { ... }
if (__HAL_QSPI_GET_FLAG(hqspi, QSPI_FLAG_BUSY) != RESET)
{
SET_BIT(hqspi->Instance->CR, QUADSPI_CR_ABORT);
status = QSPI_WaitFlagStateUntilTimeout(hqspi, QSPI_FLAG_TC, SET, tickstart, hqspi->Timeout);
if (status == HAL_OK)
{
__HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_TC);
status = QSPI_WaitFlagStateUntilTimeout(hqspi, QSPI_FLAG_BUSY, RESET, tickstart, hqspi->Timeout);
}if (status == HAL_OK) { ... }
if (status == HAL_OK)
{
CLEAR_BIT(hqspi->Instance->CCR, QUADSPI_CCR_FMODE);
hqspi->State = HAL_QSPI_STATE_READY;
}if (status == HAL_OK) { ... }
}if (__HAL_QSPI_GET_FLAG(hqspi, QSPI_FLAG_BUSY) != RESET) { ... }
else
{
hqspi->State = HAL_QSPI_STATE_READY;
}else { ... }
}if (((uint32_t)hqspi->State & 0x2U) != 0U) { ... }
return status;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_Abort_IT(QSPI_HandleTypeDef *hqspi)
{
HAL_StatusTypeDef status = HAL_OK;
if (((uint32_t)hqspi->State & 0x2U) != 0U)
{
__HAL_UNLOCK(hqspi);
hqspi->State = HAL_QSPI_STATE_ABORT;
__HAL_QSPI_DISABLE_IT(hqspi, (QSPI_IT_TO | QSPI_IT_SM | QSPI_IT_FT | QSPI_IT_TC | QSPI_IT_TE));
if ((hqspi->Instance->CR & QUADSPI_CR_DMAEN) != 0U)
{
CLEAR_BIT(hqspi->Instance->CR, QUADSPI_CR_DMAEN);
hqspi->hdma->XferAbortCallback = QSPI_DMAAbortCplt;
if (HAL_DMA_Abort_IT(hqspi->hdma) != HAL_OK)
{
hqspi->State = HAL_QSPI_STATE_READY;
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->AbortCpltCallback(hqspi);
#else
HAL_QSPI_AbortCpltCallback(hqspi);
#endif
}if (HAL_DMA_Abort_IT(hqspi->hdma) != HAL_OK) { ... }
}if ((hqspi->Instance->CR & QUADSPI_CR_DMAEN) != 0U) { ... }
else
{
if (__HAL_QSPI_GET_FLAG(hqspi, QSPI_FLAG_BUSY) != RESET)
{
__HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_TC);
__HAL_QSPI_ENABLE_IT(hqspi, QSPI_IT_TC);
SET_BIT(hqspi->Instance->CR, QUADSPI_CR_ABORT);
}if (__HAL_QSPI_GET_FLAG(hqspi, QSPI_FLAG_BUSY) != RESET) { ... }
else
{
hqspi->State = HAL_QSPI_STATE_READY;
}else { ... }
}else { ... }
}if (((uint32_t)hqspi->State & 0x2U) != 0U) { ... }
return status;
}{ ... }
/* ... */
void HAL_QSPI_SetTimeout(QSPI_HandleTypeDef *hqspi, uint32_t Timeout)
{
hqspi->Timeout = Timeout;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_SetFifoThreshold(QSPI_HandleTypeDef *hqspi, uint32_t Threshold)
{
HAL_StatusTypeDef status = HAL_OK;
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
hqspi->Init.FifoThreshold = Threshold;
MODIFY_REG(hqspi->Instance->CR, QUADSPI_CR_FTHRES,
((hqspi->Init.FifoThreshold - 1U) << QUADSPI_CR_FTHRES_Pos));
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else
{
status = HAL_BUSY;
}else { ... }
__HAL_UNLOCK(hqspi);
return status;
}{ ... }
/* ... */
uint32_t HAL_QSPI_GetFifoThreshold(QSPI_HandleTypeDef *hqspi)
{
return ((READ_BIT(hqspi->Instance->CR, QUADSPI_CR_FTHRES) >> QUADSPI_CR_FTHRES_Pos) + 1U);
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_QSPI_SetFlashID(QSPI_HandleTypeDef *hqspi, uint32_t FlashID)
{
HAL_StatusTypeDef status = HAL_OK;
assert_param(IS_QSPI_FLASH_ID(FlashID));
__HAL_LOCK(hqspi);
if(hqspi->State == HAL_QSPI_STATE_READY)
{
hqspi->Init.FlashID = FlashID;
MODIFY_REG(hqspi->Instance->CR, QUADSPI_CR_FSEL, FlashID);
}if (hqspi->State == HAL_QSPI_STATE_READY) { ... }
else
{
status = HAL_BUSY;
}else { ... }
__HAL_UNLOCK(hqspi);
return status;
}{ ... }
/* ... */
/* ... */
/* ... */
/* ... */
static void QSPI_DMARxCplt(DMA_HandleTypeDef *hdma)
{
QSPI_HandleTypeDef* hqspi = (QSPI_HandleTypeDef*)(hdma->Parent);
hqspi->RxXferCount = 0U;
__HAL_QSPI_ENABLE_IT(hqspi, QSPI_IT_TC);
}{ ... }
/* ... */
static void QSPI_DMATxCplt(DMA_HandleTypeDef *hdma)
{
QSPI_HandleTypeDef* hqspi = (QSPI_HandleTypeDef*)(hdma->Parent);
hqspi->TxXferCount = 0U;
__HAL_QSPI_ENABLE_IT(hqspi, QSPI_IT_TC);
}{ ... }
/* ... */
static void QSPI_DMARxHalfCplt(DMA_HandleTypeDef *hdma)
{
QSPI_HandleTypeDef* hqspi = (QSPI_HandleTypeDef*)(hdma->Parent);
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->RxHalfCpltCallback(hqspi);
#else
HAL_QSPI_RxHalfCpltCallback(hqspi);
#endif
}{ ... }
/* ... */
static void QSPI_DMATxHalfCplt(DMA_HandleTypeDef *hdma)
{
QSPI_HandleTypeDef* hqspi = (QSPI_HandleTypeDef*)(hdma->Parent);
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->TxHalfCpltCallback(hqspi);
#else
HAL_QSPI_TxHalfCpltCallback(hqspi);
#endif
}{ ... }
/* ... */
static void QSPI_DMAError(DMA_HandleTypeDef *hdma)
{
QSPI_HandleTypeDef* hqspi = ( QSPI_HandleTypeDef* )(hdma->Parent);
if(HAL_DMA_GetError(hdma) != HAL_DMA_ERROR_FE)
{
hqspi->RxXferCount = 0U;
hqspi->TxXferCount = 0U;
hqspi->ErrorCode |= HAL_QSPI_ERROR_DMA;
CLEAR_BIT(hqspi->Instance->CR, QUADSPI_CR_DMAEN);
(void)HAL_QSPI_Abort_IT(hqspi);
}if (HAL_DMA_GetError(hdma) != HAL_DMA_ERROR_FE) { ... }
}{ ... }
/* ... */
static void QSPI_DMAAbortCplt(DMA_HandleTypeDef *hdma)
{
QSPI_HandleTypeDef* hqspi = ( QSPI_HandleTypeDef* )(hdma->Parent);
hqspi->RxXferCount = 0U;
hqspi->TxXferCount = 0U;
if(hqspi->State == HAL_QSPI_STATE_ABORT)
{
__HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_TC);
__HAL_QSPI_ENABLE_IT(hqspi, QSPI_IT_TC);
SET_BIT(hqspi->Instance->CR, QUADSPI_CR_ABORT);
}if (hqspi->State == HAL_QSPI_STATE_ABORT) { ... }
else
{
hqspi->State = HAL_QSPI_STATE_READY;
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
hqspi->ErrorCallback(hqspi);
#else
HAL_QSPI_ErrorCallback(hqspi);
#endif
}else { ... }
}{ ... }
/* ... */
static HAL_StatusTypeDef QSPI_WaitFlagStateUntilTimeout(QSPI_HandleTypeDef *hqspi, uint32_t Flag,
FlagStatus State, uint32_t Tickstart, uint32_t Timeout)
{
while((__HAL_QSPI_GET_FLAG(hqspi, Flag)) != State)
{
if (Timeout != HAL_MAX_DELAY)
{
if(((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U))
{
hqspi->State = HAL_QSPI_STATE_ERROR;
hqspi->ErrorCode |= HAL_QSPI_ERROR_TIMEOUT;
return HAL_ERROR;
}if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U)) { ... }
}if (Timeout != HAL_MAX_DELAY) { ... }
}while ((__HAL_QSPI_GET_FLAG(hqspi, Flag)) != State) { ... }
return HAL_OK;
}{ ... }
/* ... */
static HAL_StatusTypeDef QSPI_WaitFlagStateUntilTimeout_CPUCycle(QSPI_HandleTypeDef *hqspi, uint32_t Flag, FlagStatus State, uint32_t Timeout)
{
__IO uint32_t count = Timeout * (SystemCoreClock / 16U / 1000U);
do
{
if (count-- == 0U)
{
hqspi->State = HAL_QSPI_STATE_ERROR;
hqspi->ErrorCode |= HAL_QSPI_ERROR_TIMEOUT;
return HAL_TIMEOUT;
}if (count-- == 0U) { ... }
...}
while ((__HAL_QSPI_GET_FLAG(hqspi, Flag)) != State);
return HAL_OK;
}{ ... }
/* ... */
static void QSPI_Config(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, uint32_t FunctionalMode)
{
assert_param(IS_QSPI_FUNCTIONAL_MODE(FunctionalMode));
if ((cmd->DataMode != QSPI_DATA_NONE) && (FunctionalMode != QSPI_FUNCTIONAL_MODE_MEMORY_MAPPED))
{
WRITE_REG(hqspi->Instance->DLR, (cmd->NbData - 1U));
}if ((cmd->DataMode != QSPI_DATA_NONE) && (FunctionalMode != QSPI_FUNCTIONAL_MODE_MEMORY_MAPPED)) { ... }
if (cmd->InstructionMode != QSPI_INSTRUCTION_NONE)
{
if (cmd->AlternateByteMode != QSPI_ALTERNATE_BYTES_NONE)
{
WRITE_REG(hqspi->Instance->ABR, cmd->AlternateBytes);
if (cmd->AddressMode != QSPI_ADDRESS_NONE)
{
WRITE_REG(hqspi->Instance->CCR, (cmd->DdrMode | cmd->DdrHoldHalfCycle | cmd->SIOOMode |
cmd->DataMode | (cmd->DummyCycles << QUADSPI_CCR_DCYC_Pos) |
cmd->AlternateBytesSize | cmd->AlternateByteMode |
cmd->AddressSize | cmd->AddressMode | cmd->InstructionMode |
cmd->Instruction | FunctionalMode));
if (FunctionalMode != QSPI_FUNCTIONAL_MODE_MEMORY_MAPPED)
{
WRITE_REG(hqspi->Instance->AR, cmd->Address);
}if (FunctionalMode != QSPI_FUNCTIONAL_MODE_MEMORY_MAPPED) { ... }
}if (cmd->AddressMode != QSPI_ADDRESS_NONE) { ... }
else
{
WRITE_REG(hqspi->Instance->CCR, (cmd->DdrMode | cmd->DdrHoldHalfCycle | cmd->SIOOMode |
cmd->DataMode | (cmd->DummyCycles << QUADSPI_CCR_DCYC_Pos) |
cmd->AlternateBytesSize | cmd->AlternateByteMode |
cmd->AddressMode | cmd->InstructionMode |
cmd->Instruction | FunctionalMode));
}else { ... }
}if (cmd->AlternateByteMode != QSPI_ALTERNATE_BYTES_NONE) { ... }
else
{
if (cmd->AddressMode != QSPI_ADDRESS_NONE)
{
WRITE_REG(hqspi->Instance->CCR, (cmd->DdrMode | cmd->DdrHoldHalfCycle | cmd->SIOOMode |
cmd->DataMode | (cmd->DummyCycles << QUADSPI_CCR_DCYC_Pos) |
cmd->AlternateByteMode | cmd->AddressSize | cmd->AddressMode |
cmd->InstructionMode | cmd->Instruction | FunctionalMode));
if (FunctionalMode != QSPI_FUNCTIONAL_MODE_MEMORY_MAPPED)
{
WRITE_REG(hqspi->Instance->AR, cmd->Address);
}if (FunctionalMode != QSPI_FUNCTIONAL_MODE_MEMORY_MAPPED) { ... }
}if (cmd->AddressMode != QSPI_ADDRESS_NONE) { ... }
else
{
WRITE_REG(hqspi->Instance->CCR, (cmd->DdrMode | cmd->DdrHoldHalfCycle | cmd->SIOOMode |
cmd->DataMode | (cmd->DummyCycles << QUADSPI_CCR_DCYC_Pos) |
cmd->AlternateByteMode | cmd->AddressMode |
cmd->InstructionMode | cmd->Instruction | FunctionalMode));
}else { ... }
}else { ... }
}if (cmd->InstructionMode != QSPI_INSTRUCTION_NONE) { ... }
else
{
if (cmd->AlternateByteMode != QSPI_ALTERNATE_BYTES_NONE)
{
WRITE_REG(hqspi->Instance->ABR, cmd->AlternateBytes);
if (cmd->AddressMode != QSPI_ADDRESS_NONE)
{
WRITE_REG(hqspi->Instance->CCR, (cmd->DdrMode | cmd->DdrHoldHalfCycle | cmd->SIOOMode |
cmd->DataMode | (cmd->DummyCycles << QUADSPI_CCR_DCYC_Pos) |
cmd->AlternateBytesSize | cmd->AlternateByteMode |
cmd->AddressSize | cmd->AddressMode |
cmd->InstructionMode | FunctionalMode));
if (FunctionalMode != QSPI_FUNCTIONAL_MODE_MEMORY_MAPPED)
{
WRITE_REG(hqspi->Instance->AR, cmd->Address);
}if (FunctionalMode != QSPI_FUNCTIONAL_MODE_MEMORY_MAPPED) { ... }
}if (cmd->AddressMode != QSPI_ADDRESS_NONE) { ... }
else
{
WRITE_REG(hqspi->Instance->CCR, (cmd->DdrMode | cmd->DdrHoldHalfCycle | cmd->SIOOMode |
cmd->DataMode | (cmd->DummyCycles << QUADSPI_CCR_DCYC_Pos) |
cmd->AlternateBytesSize | cmd->AlternateByteMode |
cmd->AddressMode | cmd->InstructionMode | FunctionalMode));
}else { ... }
}if (cmd->AlternateByteMode != QSPI_ALTERNATE_BYTES_NONE) { ... }
else
{
if (cmd->AddressMode != QSPI_ADDRESS_NONE)
{
WRITE_REG(hqspi->Instance->CCR, (cmd->DdrMode | cmd->DdrHoldHalfCycle | cmd->SIOOMode |
cmd->DataMode | (cmd->DummyCycles << QUADSPI_CCR_DCYC_Pos) |
cmd->AlternateByteMode | cmd->AddressSize |
cmd->AddressMode | cmd->InstructionMode | FunctionalMode));
if (FunctionalMode != QSPI_FUNCTIONAL_MODE_MEMORY_MAPPED)
{
WRITE_REG(hqspi->Instance->AR, cmd->Address);
}if (FunctionalMode != QSPI_FUNCTIONAL_MODE_MEMORY_MAPPED) { ... }
}if (cmd->AddressMode != QSPI_ADDRESS_NONE) { ... }
else
{
if (cmd->DataMode != QSPI_DATA_NONE)
{
WRITE_REG(hqspi->Instance->CCR, (cmd->DdrMode | cmd->DdrHoldHalfCycle | cmd->SIOOMode |
cmd->DataMode | (cmd->DummyCycles << QUADSPI_CCR_DCYC_Pos) |
cmd->AlternateByteMode | cmd->AddressMode |
cmd->InstructionMode | FunctionalMode));
}if (cmd->DataMode != QSPI_DATA_NONE) { ... }
}else { ... }
}else { ... }
}else { ... }
}{ ... }
/* ... */
/* ... */
/* ... */
#endif
/* ... */
/* ... */
/* ... */
#endif