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
39
40
41
42
43
44
45
46
47
48
49
50
51
55
56
57
62
63
65
66
71
72
73
82
83
84
85
90
91
96
97
99
100
101
102
103
107
108
109
110
111
116
117
118
119
120
121
122
126
127
128
129
130
131
132
133
134
135
137
138
139
140
141
142
143
144
145
146
147
148
150
151
152
153
154
155
157
158
159
160
161
165
166
167
170
175
176
179
180
181
184
185
186
187
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
210
211
212
217
218
219
220
224
225
226
227
228
231
232
233
234
235
241
242
243
247
248
249
250
251
252
253
258
259
260
261
262
263
272
273
274
275
276
277
281
294
295
300
310
315
325
326
327
328
329
330
331
332
333
334
335
339
340
341
342
343
344
345
346
347
348
349
350
351
357
358
381
387
388
389
390
394
395
396
397
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
415
416
417
418
419
420
422
423
424
425
426
427
430
431
432
433
434
435
436
437
438
441
442
443
451
452
453
454
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
551
552
553
554
562
563
564
565
570
571
576
577
578
579
580
581
582
583
584
585
586
587
588
589
591
592
593
601
606
607
609
610
611
612
613
618
619
624
625
626
627
628
629
630
631
632
633
634
635
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
713
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
743
747
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
773
774
775
776
777
782
783
784
785
791
795
796
797
798
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
825
826
827
828
833
834
835
836
837
840
844
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
880
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
915
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
944
945
948
949
950
951
952
956
957
958
959
960
961
962
963
964
965
966
987
988
989
991
1006
1014
1018
1019
1020
1021
1022
1023
1024
1026
1041
1049
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1065
1066
1067
1069
1070
1071
1072
1079
1084
1085
1086
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1116
1117
1118
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1137
1138
1139
1144
1148
1149
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
1205
1206
1207
1208
1209
1210
1211
1212
1214
1215
1216
1217
1218
1219
1224
1225
1226
1228
1229
1230
1289
1290
1310
1314
1315
1316
1317
1318
1319
1320
1330
1331
1332
1333
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1357
1358
1359
1360
1362
1363
1364
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1392
1393
1394
1395
1396
1397
1399
1400
1401
1402
1403
1404
1410
1411
1412
1414
1496
1506
1507
1508
1509
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1535
1536
1537
1538
1543
1544
1547
1548
1549
1550
1551
1552
1553
1555
1556
1557
1558
1559
1560
1561
1562
1565
1576
1580
1581
1582
1583
1584
1585
1586
1587
1588
1590
1591
1592
1593
1594
1601
1606
1607
1608
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1638
1639
1640
1642
1643
1644
1645
1646
1647
1648
1649
1651
1652
1653
1654
1655
1656
1657
1661
1665
1666
1673
1674
1675
1676
1678
1679
1680
1681
1686
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1713
1714
1715
1716
1721
1722
1725
1726
1727
1728
1729
1731
1732
1733
1735
1736
1737
1738
1739
1740
1742
1743
1744
1758
1759
1761
1772
1776
1777
1778
1779
1780
1781
1782
1783
1784
1786
1787
1788
1789
1790
1797
1802
1803
1804
1809
1810
1811
1812
1813
1814
1816
1817
1829
1830
1831
1832
1833
1834
1836
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1860
1861
1862
1864
1865
1866
1867
1868
1869
1870
1871
1875
1876
1877
1878
1879
1895
1896
1897
1898
1899
1903
1907
1908
1915
1916
1917
1918
1919
1920
1921
1922
1926
1927
1928
1929
1930
1933
1934
1935
1936
1937
1938
1939
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1980
1981
1982
1983
1988
1989
1992
1993
1994
1995
1996
1997
1998
2000
2001
2002
2005
2006
2007
2008
2009
2010
2011
2012
2013
2015
2027
2031
2032
2033
2034
2035
2036
2037
2038
2039
2041
2042
2043
2044
2045
2053
2058
2059
2060
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2090
2091
2092
2094
2095
2096
2097
2098
2099
2100
2101
2103
2104
2105
2106
2107
2108
2109
2113
2117
2118
2125
2126
2127
2128
2130
2131
2132
2133
2138
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2188
2189
2190
2191
2192
2193
2194
2195
2199
2226
2236
2237
2238
2239
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2288
2289
2290
2291
2292
2293
2294
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2363
2364
2390
2391
2392
2393
2394
2400
2401
2402
2403
2404
2411
2412
2413
2414
2415
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2436
2440
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2479
2480
2481
2482
2483
2484
2488
2492
2493
2494
2495
2496
2497
2498
2502
2506
2507
2522
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2545
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2564
2565
2566
2567
2568
2569
2570
2571
2573
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2657
2661
2662
2663
2664
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2711
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2754
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2775
2776
2777
2778
2779
2781
2782
2783
2785
2786
2787
2788
2789
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2824
2828
2829
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2854
2855
2856
2857
2858
2860
2861
2862
2864
2865
2866
2867
2868
2873
2874
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2892
2896
2897
2898
2899
2900
2901
2902
2903
2918
2922
2923
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2946
2947
2948
2949
2950
2952
2970
2974
2975
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2997
2998
2999
3000
3001
3002
3006
3010
3011
3012
3013
3014
3032
3036
3037
3038
3039
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3062
3063
3064
3065
3066
3068
3069
3070
3071
3076
3077
3081
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3115
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3152
3153
3154
3156
3157
3158
3159
3160
3161
3162
3163
3166
3167
3168
3169
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
3200
3201
3202
3213
3214
3219
3223
3224
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3298
3305
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3361
3362
3363
3364
3366
3367
3368
3369
3370
3371
3372
3373
3375
3376
3377
3378
3379
3380
3381
3382
3401
3409
3410
3414
3415
3416
3417
3418
3419
3420
3421
/* ... */
#include <stdlib.h>
#include <string.h>
/* ... */
#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "esp_private/freertos_idf_additions_priv.h"
#if ( configUSE_CO_ROUTINES == 1 )
#include "croutine.h"
#endif
/* ... */
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
/* ... */
#if ( configNUMBER_OF_CORES > 1 )
#define queueUSE_LOCKS 0
#define queueUNLOCKED ( ( int8_t ) 0 )/* ... */
#else
#define queueUSE_LOCKS 1
#define queueUNLOCKED ( ( int8_t ) -1 )
#define queueLOCKED_UNMODIFIED ( ( int8_t ) 0 )
#define queueINT8_MAX ( ( int8_t ) 127 )/* ... */
#endif
/* ... */
#define uxQueueType pcHead
#define queueQUEUE_IS_MUTEX NULL
typedef struct QueuePointers
{
int8_t * pcTail;
int8_t * pcReadFrom;
}{ ... } QueuePointers_t;
typedef struct SemaphoreData
{
TaskHandle_t xMutexHolder;
UBaseType_t uxRecursiveCallCount;
}{ ... } SemaphoreData_t;
/* ... */
#define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( UBaseType_t ) 0 )
#define queueMUTEX_GIVE_BLOCK_TIME ( ( TickType_t ) 0U )
#if ( configUSE_PREEMPTION == 0 )
/* ... */
#define queueYIELD_IF_USING_PREEMPTION()/* ... */
#else
#define queueYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API()
#endif
/* ... */
typedef struct QueueDefinition
{
int8_t * pcHead;
int8_t * pcWriteTo;
union
{
QueuePointers_t xQueue;
SemaphoreData_t xSemaphore;
}{ ... } u;
List_t xTasksWaitingToSend;
List_t xTasksWaitingToReceive;
volatile UBaseType_t uxMessagesWaiting;
UBaseType_t uxLength;
UBaseType_t uxItemSize;
#if ( queueUSE_LOCKS == 1 )
volatile int8_t cRxLock;
volatile int8_t cTxLock; /* ... */
#endif
#if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
uint8_t ucStaticallyAllocated;
#endif
#if ( configUSE_QUEUE_SETS == 1 )
struct QueueDefinition * pxQueueSetContainer;
#endif
#if ( configUSE_TRACE_FACILITY == 1 )
UBaseType_t uxQueueNumber;
uint8_t ucQueueType;/* ... */
#endif
portMUX_TYPE xQueueLock;
}{...} xQUEUE;
/* ... */
typedef xQUEUE Queue_t;
/* ... */
#if ( configQUEUE_REGISTRY_SIZE > 0 )
/* ... */
typedef struct QUEUE_REGISTRY_ITEM
{
const char * pcQueueName;
QueueHandle_t xHandle;
}{...} xQueueRegistryItem;
/* ... */
typedef xQueueRegistryItem QueueRegistryItem_t;
/* ... */
PRIVILEGED_DATA QueueRegistryItem_t xQueueRegistry[ configQUEUE_REGISTRY_SIZE ];
#if ( configNUMBER_OF_CORES > 1 )
static portMUX_TYPE xQueueRegistryLock = portMUX_INITIALIZER_UNLOCKED;/* ... */
#endif
/* ... */
#endif
#if ( queueUSE_LOCKS == 1 )
/* ... */
static void prvUnlockQueue( Queue_t * const pxQueue ) PRIVILEGED_FUNCTION;
/* ... */
static BaseType_t prvIsQueueEmpty( const Queue_t * pxQueue ) PRIVILEGED_FUNCTION;
/* ... */
static BaseType_t prvIsQueueFull( const Queue_t * pxQueue ) PRIVILEGED_FUNCTION;/* ... */
#endif
/* ... */
static BaseType_t prvCopyDataToQueue( Queue_t * const pxQueue,
const void * pvItemToQueue,
const BaseType_t xPosition ) PRIVILEGED_FUNCTION;
/* ... */
static void prvCopyDataFromQueue( Queue_t * const pxQueue,
void * const pvBuffer ) PRIVILEGED_FUNCTION;
#if ( configUSE_QUEUE_SETS == 1 )
/* ... */
static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue ) PRIVILEGED_FUNCTION;/* ... */
#endif
/* ... */
static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength,
const UBaseType_t uxItemSize,
uint8_t * pucQueueStorage,
const uint8_t ucQueueType,
Queue_t * pxNewQueue ) PRIVILEGED_FUNCTION;
/* ... */
#if ( configUSE_MUTEXES == 1 )
static void prvInitialiseMutex( Queue_t * pxNewQueue ) PRIVILEGED_FUNCTION;
#endif
#if ( configUSE_MUTEXES == 1 )
/* ... */
static UBaseType_t prvGetDisinheritPriorityAfterTimeout( const Queue_t * const pxQueue ) PRIVILEGED_FUNCTION;/* ... */
#endif
#if ( queueUSE_LOCKS == 1 )
/* ... */
#define prvLockQueue( pxQueue ) \
taskENTER_CRITICAL( &( pxQueue->xQueueLock ) ); \
{ \
if( ( pxQueue )->cRxLock == queueUNLOCKED ) \
{ \
( pxQueue )->cRxLock = queueLOCKED_UNMODIFIED; \
}{...} \
if( ( pxQueue )->cTxLock == queueUNLOCKED ) \
{ \
( pxQueue )->cTxLock = queueLOCKED_UNMODIFIED; \
}{...} \
}{...} \
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) )...
/* ... */
#define prvIncrementQueueTxLock( pxQueue, cTxLock ) \
{ \
const UBaseType_t uxNumberOfTasks = uxTaskGetNumberOfTasks(); \
if( ( UBaseType_t ) ( cTxLock ) < uxNumberOfTasks ) \
{ \
configASSERT( ( cTxLock ) != queueINT8_MAX ); \
( pxQueue )->cTxLock = ( int8_t ) ( ( cTxLock ) + ( int8_t ) 1 ); \
}{...} \
}{...}
...
/* ... */
#define prvIncrementQueueRxLock( pxQueue, cRxLock ) \
{ \
const UBaseType_t uxNumberOfTasks = uxTaskGetNumberOfTasks(); \
if( ( UBaseType_t ) ( cRxLock ) < uxNumberOfTasks ) \
{ \
configASSERT( ( cRxLock ) != queueINT8_MAX ); \
( pxQueue )->cRxLock = ( int8_t ) ( ( cRxLock ) + ( int8_t ) 1 ); \
}{...} \
}{...}
...#endif/* ... */
BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
BaseType_t xNewQueue )
{
BaseType_t xReturn = pdPASS;
Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
if( xNewQueue == pdTRUE )
{
portMUX_INITIALIZE( &( pxQueue->xQueueLock ) );
}{...}
if( ( pxQueue != NULL ) &&
( pxQueue->uxLength >= 1U ) &&
( ( SIZE_MAX / pxQueue->uxLength ) >= pxQueue->uxItemSize ) )
{
taskENTER_CRITICAL( &( pxQueue->xQueueLock ) );
{
pxQueue->u.xQueue.pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize );
pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U;
pxQueue->pcWriteTo = pxQueue->pcHead;
pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - 1U ) * pxQueue->uxItemSize );
#if ( queueUSE_LOCKS == 1 )
{
pxQueue->cRxLock = queueUNLOCKED;
pxQueue->cTxLock = queueUNLOCKED;
}/* ... */
{...} #endif
if( xNewQueue == pdFALSE )
{
/* ... */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
{
queueYIELD_IF_USING_PREEMPTION();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
vListInitialise( &( pxQueue->xTasksWaitingToSend ) );
vListInitialise( &( pxQueue->xTasksWaitingToReceive ) );
}{...}
}{...}
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
}{...}
else
{
xReturn = pdFAIL;
}{...}
configASSERT( xReturn != pdFAIL );
/* ... */
return xReturn;
}{ ... }
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
const UBaseType_t uxItemSize,
uint8_t * pucQueueStorage,
StaticQueue_t * pxStaticQueue,
const uint8_t ucQueueType )
{
Queue_t * pxNewQueue = NULL;
/* ... */
configASSERT( pxStaticQueue );
if( ( uxQueueLength > ( UBaseType_t ) 0 ) &&
( pxStaticQueue != NULL ) &&
/* ... */
( !( ( pucQueueStorage != NULL ) && ( uxItemSize == 0 ) ) ) &&
( !( ( pucQueueStorage == NULL ) && ( uxItemSize != 0 ) ) ) )
{
#if ( configASSERT_DEFINED == 1 )
{
/* ... */
volatile size_t xSize = sizeof( StaticQueue_t );
configASSERT( xSize == sizeof( Queue_t ) );
( void ) xSize;
}/* ... */
{...} #endif
/* ... */
pxNewQueue = ( Queue_t * ) pxStaticQueue;
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
{
/* ... */
pxNewQueue->ucStaticallyAllocated = pdTRUE;
}/* ... */
{...} #endif
prvInitialiseNewQueue( uxQueueLength, uxItemSize, pucQueueStorage, ucQueueType, pxNewQueue );
}{...}
else
{
configASSERT( pxNewQueue );
mtCOVERAGE_TEST_MARKER();
}{...}
return pxNewQueue;
}{ ... }
/* ... */#endif
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
BaseType_t xQueueGenericGetStaticBuffers( QueueHandle_t xQueue,
uint8_t ** ppucQueueStorage,
StaticQueue_t ** ppxStaticQueue )
{
BaseType_t xReturn;
Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
configASSERT( ppxStaticQueue );
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
{
if( pxQueue->ucStaticallyAllocated == ( uint8_t ) pdTRUE )
{
if( ppucQueueStorage != NULL )
{
*ppucQueueStorage = ( uint8_t * ) pxQueue->pcHead;
}{...}
*ppxStaticQueue = ( StaticQueue_t * ) pxQueue;
xReturn = pdTRUE;
}{...}
else
{
xReturn = pdFALSE;
}{...}
}/* ... */
{...} #else
{
if( ppucQueueStorage != NULL )
{
*ppucQueueStorage = ( uint8_t * ) pxQueue->pcHead;
}{...}
*ppxStaticQueue = ( StaticQueue_t * ) pxQueue;
xReturn = pdTRUE;
}/* ... */
{...} #endif
return xReturn;
}{ ... }
/* ... */#endif
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength,
const UBaseType_t uxItemSize,
const uint8_t ucQueueType )
{
Queue_t * pxNewQueue = NULL;
size_t xQueueSizeInBytes;
uint8_t * pucQueueStorage;
if( ( uxQueueLength > ( UBaseType_t ) 0 ) &&
( ( SIZE_MAX / uxQueueLength ) >= uxItemSize ) &&
( ( SIZE_MAX - sizeof( Queue_t ) ) >= ( uxQueueLength * uxItemSize ) ) )
{
/* ... */
xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize );
/* ... */
pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes );
if( pxNewQueue != NULL )
{
/* ... */
pucQueueStorage = ( uint8_t * ) pxNewQueue;
pucQueueStorage += sizeof( Queue_t );
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
{
/* ... */
pxNewQueue->ucStaticallyAllocated = pdFALSE;
}/* ... */
{...} #endif
prvInitialiseNewQueue( uxQueueLength, uxItemSize, pucQueueStorage, ucQueueType, pxNewQueue );
}{...}
else
{
traceQUEUE_CREATE_FAILED( ucQueueType );
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
configASSERT( pxNewQueue );
mtCOVERAGE_TEST_MARKER();
}{...}
return pxNewQueue;
}{ ... }
/* ... */#endif
static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength,
const UBaseType_t uxItemSize,
uint8_t * pucQueueStorage,
const uint8_t ucQueueType,
Queue_t * pxNewQueue )
{
/* ... */
( void ) ucQueueType;
if( uxItemSize == ( UBaseType_t ) 0 )
{
/* ... */
pxNewQueue->pcHead = ( int8_t * ) pxNewQueue;
}{...}
else
{
pxNewQueue->pcHead = ( int8_t * ) pucQueueStorage;
}{...}
/* ... */
pxNewQueue->uxLength = uxQueueLength;
pxNewQueue->uxItemSize = uxItemSize;
( void ) xQueueGenericReset( pxNewQueue, pdTRUE );
#if ( configUSE_TRACE_FACILITY == 1 )
{
pxNewQueue->ucQueueType = ucQueueType;
}/* ... */
{...} #endif
#if ( configUSE_QUEUE_SETS == 1 )
{
pxNewQueue->pxQueueSetContainer = NULL;
}/* ... */
{...} #endif
traceQUEUE_CREATE( pxNewQueue );
}{ ... }
#if ( configUSE_MUTEXES == 1 )
static void prvInitialiseMutex( Queue_t * pxNewQueue )
{
if( pxNewQueue != NULL )
{
/* ... */
pxNewQueue->u.xSemaphore.xMutexHolder = NULL;
pxNewQueue->uxQueueType = queueQUEUE_IS_MUTEX;
pxNewQueue->u.xSemaphore.uxRecursiveCallCount = 0;
portMUX_INITIALIZE( &( pxNewQueue->xQueueLock ) );
traceCREATE_MUTEX( pxNewQueue );
( void ) xQueueGenericSend( pxNewQueue, NULL, ( TickType_t ) 0U, queueSEND_TO_BACK );
}{...}
else
{
traceCREATE_MUTEX_FAILED();
}{...}
}{ ... }
/* ... */#endif
#if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType )
{
QueueHandle_t xNewQueue;
const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0;
xNewQueue = xQueueGenericCreate( uxMutexLength, uxMutexSize, ucQueueType );
prvInitialiseMutex( ( Queue_t * ) xNewQueue );
return xNewQueue;
}{ ... }
/* ... */#endif
#if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType,
StaticQueue_t * pxStaticQueue )
{
QueueHandle_t xNewQueue;
const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0;
/* ... */
( void ) ucQueueType;
xNewQueue = xQueueGenericCreateStatic( uxMutexLength, uxMutexSize, NULL, pxStaticQueue, ucQueueType );
prvInitialiseMutex( ( Queue_t * ) xNewQueue );
return xNewQueue;
}{ ... }
/* ... */#endif
#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore )
{
TaskHandle_t pxReturn;
Queue_t * const pxSemaphore = ( Queue_t * ) xSemaphore;
configASSERT( xSemaphore );
/* ... */
taskENTER_CRITICAL( &( pxSemaphore->xQueueLock ) );
{
if( pxSemaphore->uxQueueType == queueQUEUE_IS_MUTEX )
{
pxReturn = pxSemaphore->u.xSemaphore.xMutexHolder;
}{...}
else
{
pxReturn = NULL;
}{...}
}{...}
taskEXIT_CRITICAL( &( pxSemaphore->xQueueLock ) );
return pxReturn;
}{ ... }
/* ... */
#endif
#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore )
{
TaskHandle_t pxReturn;
configASSERT( xSemaphore );
/* ... */
if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX )
{
pxReturn = ( ( Queue_t * ) xSemaphore )->u.xSemaphore.xMutexHolder;
}{...}
else
{
pxReturn = NULL;
}{...}
return pxReturn;
}{ ... }
/* ... */
#endif
#if ( configUSE_RECURSIVE_MUTEXES == 1 )
BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex )
{
BaseType_t xReturn;
Queue_t * const pxMutex = ( Queue_t * ) xMutex;
configASSERT( pxMutex );
/* ... */
if( pxMutex->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle() )
{
traceGIVE_MUTEX_RECURSIVE( pxMutex );
/* ... */
( pxMutex->u.xSemaphore.uxRecursiveCallCount )--;
if( pxMutex->u.xSemaphore.uxRecursiveCallCount == ( UBaseType_t ) 0 )
{
/* ... */
( void ) xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK );
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
xReturn = pdPASS;
}{...}
else
{
/* ... */
xReturn = pdFAIL;
traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex );
}{...}
return xReturn;
}{ ... }
/* ... */#endif
#if ( configUSE_RECURSIVE_MUTEXES == 1 )
BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex,
TickType_t xTicksToWait )
{
BaseType_t xReturn;
Queue_t * const pxMutex = ( Queue_t * ) xMutex;
configASSERT( pxMutex );
/* ... */
traceTAKE_MUTEX_RECURSIVE( pxMutex );
if( pxMutex->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle() )
{
( pxMutex->u.xSemaphore.uxRecursiveCallCount )++;
xReturn = pdPASS;
}{...}
else
{
xReturn = xQueueSemaphoreTake( pxMutex, xTicksToWait );
/* ... */
if( xReturn != pdFAIL )
{
( pxMutex->u.xSemaphore.uxRecursiveCallCount )++;
}{...}
else
{
traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex );
}{...}
}{...}
return xReturn;
}{ ... }
/* ... */#endif
#if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
const UBaseType_t uxInitialCount,
StaticQueue_t * pxStaticQueue )
{
QueueHandle_t xHandle = NULL;
if( ( uxMaxCount != 0 ) &&
( uxInitialCount <= uxMaxCount ) )
{
xHandle = xQueueGenericCreateStatic( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticQueue, queueQUEUE_TYPE_COUNTING_SEMAPHORE );
if( xHandle != NULL )
{
( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount;
traceCREATE_COUNTING_SEMAPHORE();
}{...}
else
{
traceCREATE_COUNTING_SEMAPHORE_FAILED();
}{...}
}{...}
else
{
configASSERT( xHandle );
mtCOVERAGE_TEST_MARKER();
}{...}
return xHandle;
}{ ... }
/* ... */#endif
#if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
const UBaseType_t uxInitialCount )
{
QueueHandle_t xHandle = NULL;
if( ( uxMaxCount != 0 ) &&
( uxInitialCount <= uxMaxCount ) )
{
xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );
if( xHandle != NULL )
{
( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount;
traceCREATE_COUNTING_SEMAPHORE();
}{...}
else
{
traceCREATE_COUNTING_SEMAPHORE_FAILED();
}{...}
}{...}
else
{
configASSERT( xHandle );
mtCOVERAGE_TEST_MARKER();
}{...}
return xHandle;
}{ ... }
/* ... */#endif
BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
const void * const pvItemToQueue,
TickType_t xTicksToWait,
const BaseType_t xCopyPosition )
{
BaseType_t xEntryTimeSet = pdFALSE, xYieldRequired;
TimeOut_t xTimeOut;
Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );
configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) );
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
{
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
}/* ... */
{...} #endif
/* ... */
for( ; ; )
{
taskENTER_CRITICAL( &( pxQueue->xQueueLock ) );
{
/* ... */
if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )
{
traceQUEUE_SEND( pxQueue );
#if ( configUSE_QUEUE_SETS == 1 )
{
const UBaseType_t uxPreviousMessagesWaiting = pxQueue->uxMessagesWaiting;
xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
if( pxQueue->pxQueueSetContainer != NULL )
{
if( ( xCopyPosition == queueOVERWRITE ) && ( uxPreviousMessagesWaiting != ( UBaseType_t ) 0 ) )
{
/* ... */
mtCOVERAGE_TEST_MARKER();
}{...}
else if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )
{
/* ... */
queueYIELD_IF_USING_PREEMPTION();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
/* ... */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* ... */
queueYIELD_IF_USING_PREEMPTION();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else if( xYieldRequired != pdFALSE )
{
/* ... */
queueYIELD_IF_USING_PREEMPTION();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
}/* ... */
{...} #else
{
xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
/* ... */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* ... */
queueYIELD_IF_USING_PREEMPTION();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else if( xYieldRequired != pdFALSE )
{
/* ... */
queueYIELD_IF_USING_PREEMPTION();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}/* ... */
{...} #endif
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
return pdPASS;
}{...}
else
{
if( xTicksToWait == ( TickType_t ) 0 )
{
/* ... */
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
/* ... */
traceQUEUE_SEND_FAILED( pxQueue );
return errQUEUE_FULL;
}{...}
else if( xEntryTimeSet == pdFALSE )
{
/* ... */
vTaskInternalSetTimeOutState( &xTimeOut );
xEntryTimeSet = pdTRUE;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
/* ... */
#if ( queueUSE_LOCKS == 0 )
{
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
{
traceBLOCKING_ON_QUEUE_SEND( pxQueue );
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );
portYIELD_WITHIN_API();
}{...}
else
{
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
traceQUEUE_SEND_FAILED( pxQueue );
return errQUEUE_FULL;
}{...}
}/* ... */
{...} #endif
}{...}
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
/* ... */
#if ( queueUSE_LOCKS == 1 )
{
/* ... */
vTaskSuspendAll();
prvLockQueue( pxQueue );
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
{
if( prvIsQueueFull( pxQueue ) != pdFALSE )
{
traceBLOCKING_ON_QUEUE_SEND( pxQueue );
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );
/* ... */
prvUnlockQueue( pxQueue );
/* ... */
if( xTaskResumeAll() == pdFALSE )
{
portYIELD_WITHIN_API();
}{...}
}{...}
else
{
prvUnlockQueue( pxQueue );
( void ) xTaskResumeAll();
}{...}
}{...}
else
{
prvUnlockQueue( pxQueue );
( void ) xTaskResumeAll();
traceQUEUE_SEND_FAILED( pxQueue );
return errQUEUE_FULL;
}{...}
}/* ... */
{...} #endif
}{...}
}{ ... }
BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue,
const void * const pvItemToQueue,
BaseType_t * const pxHigherPriorityTaskWoken,
const BaseType_t xCopyPosition )
{
BaseType_t xReturn;
UBaseType_t uxSavedInterruptStatus;
Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );
configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) );
/* ... */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
/* ... */
prvENTER_CRITICAL_OR_MASK_ISR( &( pxQueue->xQueueLock ), uxSavedInterruptStatus );
{
if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )
{
#if ( queueUSE_LOCKS == 1 )
const int8_t cTxLock = pxQueue->cTxLock;
#else
const int8_t cTxLock = queueUNLOCKED;/* ... */
#endif
const UBaseType_t uxPreviousMessagesWaiting = pxQueue->uxMessagesWaiting;
traceQUEUE_SEND_FROM_ISR( pxQueue );
/* ... */
( void ) prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
/* ... */
if( cTxLock == queueUNLOCKED )
{
#if ( configUSE_QUEUE_SETS == 1 )
{
if( pxQueue->pxQueueSetContainer != NULL )
{
if( ( xCopyPosition == queueOVERWRITE ) && ( uxPreviousMessagesWaiting != ( UBaseType_t ) 0 ) )
{
/* ... */
mtCOVERAGE_TEST_MARKER();
}{...}
else if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )
{
/* ... */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* ... */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
}/* ... */
{...} #else
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* ... */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
( void ) uxPreviousMessagesWaiting;
}/* ... */
{...} #endif
}{...}
else
{
#if ( queueUSE_LOCKS == 1 )
{
/* ... */
prvIncrementQueueTxLock( pxQueue, cTxLock );
}/* ... */
{...} #endif
}{...}
xReturn = pdPASS;
}{...}
else
{
traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue );
xReturn = errQUEUE_FULL;
}{...}
}{...}
prvEXIT_CRITICAL_OR_UNMASK_ISR( &( pxQueue->xQueueLock ), uxSavedInterruptStatus );
return xReturn;
}{ ... }
BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
BaseType_t * const pxHigherPriorityTaskWoken )
{
BaseType_t xReturn;
UBaseType_t uxSavedInterruptStatus;
Queue_t * const pxQueue = xQueue;
/* ... */
configASSERT( pxQueue );
/* ... */
configASSERT( pxQueue->uxItemSize == 0 );
/* ... */
configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->u.xSemaphore.xMutexHolder != NULL ) ) );
/* ... */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
prvENTER_CRITICAL_OR_MASK_ISR( &( pxQueue->xQueueLock ), uxSavedInterruptStatus );
{
const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting;
/* ... */
if( uxMessagesWaiting < pxQueue->uxLength )
{
#if ( queueUSE_LOCKS == 1 )
const int8_t cTxLock = pxQueue->cTxLock;
#else
const int8_t cTxLock = queueUNLOCKED;/* ... */
#endif
traceQUEUE_GIVE_FROM_ISR( pxQueue );
/* ... */
pxQueue->uxMessagesWaiting = uxMessagesWaiting + ( UBaseType_t ) 1;
/* ... */
if( cTxLock == queueUNLOCKED )
{
#if ( configUSE_QUEUE_SETS == 1 )
{
if( pxQueue->pxQueueSetContainer != NULL )
{
if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )
{
/* ... */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* ... */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
}/* ... */
{...} #else
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* ... */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}/* ... */
{...} #endif
}{...}
else
{
#if ( queueUSE_LOCKS == 1 )
{
/* ... */
prvIncrementQueueTxLock( pxQueue, cTxLock );
}/* ... */
{...} #endif
}{...}
xReturn = pdPASS;
}{...}
else
{
traceQUEUE_GIVE_FROM_ISR_FAILED( pxQueue );
xReturn = errQUEUE_FULL;
}{...}
}{...}
prvEXIT_CRITICAL_OR_UNMASK_ISR( &( pxQueue->xQueueLock ), uxSavedInterruptStatus );
return xReturn;
}{ ... }
BaseType_t xQueueReceive( QueueHandle_t xQueue,
void * const pvBuffer,
TickType_t xTicksToWait )
{
BaseType_t xEntryTimeSet = pdFALSE;
TimeOut_t xTimeOut;
Queue_t * const pxQueue = xQueue;
configASSERT( ( pxQueue ) );
/* ... */
configASSERT( !( ( ( pvBuffer ) == NULL ) && ( ( pxQueue )->uxItemSize != ( UBaseType_t ) 0U ) ) );
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
{
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
}/* ... */
{...} #endif
/* ... */
for( ; ; )
{
taskENTER_CRITICAL( &( pxQueue->xQueueLock ) );
{
const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting;
/* ... */
if( uxMessagesWaiting > ( UBaseType_t ) 0 )
{
prvCopyDataFromQueue( pxQueue, pvBuffer );
traceQUEUE_RECEIVE( pxQueue );
pxQueue->uxMessagesWaiting = uxMessagesWaiting - ( UBaseType_t ) 1;
/* ... */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
{
queueYIELD_IF_USING_PREEMPTION();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
return pdPASS;
}{...}
else
{
if( xTicksToWait == ( TickType_t ) 0 )
{
/* ... */
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
traceQUEUE_RECEIVE_FAILED( pxQueue );
return errQUEUE_EMPTY;
}{...}
else if( xEntryTimeSet == pdFALSE )
{
/* ... */
vTaskInternalSetTimeOutState( &xTimeOut );
xEntryTimeSet = pdTRUE;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
/* ... */
#if ( queueUSE_LOCKS == 0 )
{
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
{
traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
portYIELD_WITHIN_API();
}{...}
else
{
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
traceQUEUE_RECEIVE_FAILED( pxQueue );
return errQUEUE_EMPTY;
}{...}
}/* ... */
{...} #endif
}{...}
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
/* ... */
#if ( queueUSE_LOCKS == 1 )
{
/* ... */
vTaskSuspendAll();
prvLockQueue( pxQueue );
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
{
/* ... */
if( prvIsQueueEmpty( pxQueue ) != pdFALSE )
{
traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
prvUnlockQueue( pxQueue );
if( xTaskResumeAll() == pdFALSE )
{
portYIELD_WITHIN_API();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
/* ... */
prvUnlockQueue( pxQueue );
( void ) xTaskResumeAll();
}{...}
}{...}
else
{
/* ... */
prvUnlockQueue( pxQueue );
( void ) xTaskResumeAll();
if( prvIsQueueEmpty( pxQueue ) != pdFALSE )
{
traceQUEUE_RECEIVE_FAILED( pxQueue );
return errQUEUE_EMPTY;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
}/* ... */
{...} #endif
}{...}
}{ ... }
BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue,
TickType_t xTicksToWait )
{
BaseType_t xEntryTimeSet = pdFALSE;
TimeOut_t xTimeOut;
Queue_t * const pxQueue = xQueue;
#if ( configUSE_MUTEXES == 1 )
BaseType_t xInheritanceOccurred = pdFALSE;
#endif
configASSERT( ( pxQueue ) );
/* ... */
configASSERT( pxQueue->uxItemSize == 0 );
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
{
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
}/* ... */
{...} #endif
/* ... */
for( ; ; )
{
taskENTER_CRITICAL( &( pxQueue->xQueueLock ) );
{
/* ... */
const UBaseType_t uxSemaphoreCount = pxQueue->uxMessagesWaiting;
/* ... */
if( uxSemaphoreCount > ( UBaseType_t ) 0 )
{
traceQUEUE_SEMAPHORE_RECEIVE( pxQueue );
/* ... */
pxQueue->uxMessagesWaiting = uxSemaphoreCount - ( UBaseType_t ) 1;
#if ( configUSE_MUTEXES == 1 )
{
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
{
/* ... */
pxQueue->u.xSemaphore.xMutexHolder = pvTaskIncrementMutexHeldCount();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}/* ... */
{...} #endif
/* ... */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
{
queueYIELD_IF_USING_PREEMPTION();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
return pdPASS;
}{...}
else
{
if( xTicksToWait == ( TickType_t ) 0 )
{
/* ... */
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
traceQUEUE_RECEIVE_FAILED( pxQueue );
return errQUEUE_EMPTY;
}{...}
else if( xEntryTimeSet == pdFALSE )
{
/* ... */
vTaskInternalSetTimeOutState( &xTimeOut );
xEntryTimeSet = pdTRUE;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
/* ... */
#if ( queueUSE_LOCKS == 0 )
{
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
{
/* ... */
traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );
#if ( configUSE_MUTEXES == 1 )
{
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
{
xInheritanceOccurred = xTaskPriorityInherit( pxQueue->u.xSemaphore.xMutexHolder );
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}/* ... */
{...} #endif
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
portYIELD_WITHIN_API();
}{...}
else
{
/* ... */
#if ( configUSE_MUTEXES == 1 )
{
if( xInheritanceOccurred != pdFALSE )
{
UBaseType_t uxHighestWaitingPriority;
uxHighestWaitingPriority = prvGetDisinheritPriorityAfterTimeout( pxQueue );
vTaskPriorityDisinheritAfterTimeout( pxQueue->u.xSemaphore.xMutexHolder, uxHighestWaitingPriority );
}{...}
}/* ... */
{...} #endif
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
traceQUEUE_RECEIVE_FAILED( pxQueue );
return errQUEUE_EMPTY;
}{...}
}/* ... */
{...} #endif
}{...}
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
/* ... */
#if ( queueUSE_LOCKS == 1 )
{
/* ... */
vTaskSuspendAll();
prvLockQueue( pxQueue );
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
{
/* ... */
if( prvIsQueueEmpty( pxQueue ) != pdFALSE )
{
traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );
#if ( configUSE_MUTEXES == 1 )
{
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
{
taskENTER_CRITICAL( &( pxQueue->xQueueLock ) );
{
xInheritanceOccurred = xTaskPriorityInherit( pxQueue->u.xSemaphore.xMutexHolder );
}{...}
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}/* ... */
{...} #endif
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
prvUnlockQueue( pxQueue );
if( xTaskResumeAll() == pdFALSE )
{
portYIELD_WITHIN_API();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
/* ... */
prvUnlockQueue( pxQueue );
( void ) xTaskResumeAll();
}{...}
}{...}
else
{
prvUnlockQueue( pxQueue );
( void ) xTaskResumeAll();
/* ... */
if( prvIsQueueEmpty( pxQueue ) != pdFALSE )
{
#if ( configUSE_MUTEXES == 1 )
{
/* ... */
if( xInheritanceOccurred != pdFALSE )
{
taskENTER_CRITICAL( &( pxQueue->xQueueLock ) );
{
UBaseType_t uxHighestWaitingPriority;
/* ... */
uxHighestWaitingPriority = prvGetDisinheritPriorityAfterTimeout( pxQueue );
vTaskPriorityDisinheritAfterTimeout( pxQueue->u.xSemaphore.xMutexHolder, uxHighestWaitingPriority );
}{...}
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
}{...}
}/* ... */
{...} #endif
traceQUEUE_RECEIVE_FAILED( pxQueue );
return errQUEUE_EMPTY;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
}/* ... */
{...} #endif
}{...}
}{ ... }
BaseType_t xQueuePeek( QueueHandle_t xQueue,
void * const pvBuffer,
TickType_t xTicksToWait )
{
BaseType_t xEntryTimeSet = pdFALSE;
TimeOut_t xTimeOut;
int8_t * pcOriginalReadPosition;
Queue_t * const pxQueue = xQueue;
configASSERT( ( pxQueue ) );
/* ... */
configASSERT( !( ( ( pvBuffer ) == NULL ) && ( ( pxQueue )->uxItemSize != ( UBaseType_t ) 0U ) ) );
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
{
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
}/* ... */
{...} #endif
/* ... */
for( ; ; )
{
taskENTER_CRITICAL( &( pxQueue->xQueueLock ) );
{
const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting;
/* ... */
if( uxMessagesWaiting > ( UBaseType_t ) 0 )
{
/* ... */
pcOriginalReadPosition = pxQueue->u.xQueue.pcReadFrom;
prvCopyDataFromQueue( pxQueue, pvBuffer );
traceQUEUE_PEEK( pxQueue );
pxQueue->u.xQueue.pcReadFrom = pcOriginalReadPosition;
/* ... */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
queueYIELD_IF_USING_PREEMPTION();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
return pdPASS;
}{...}
else
{
if( xTicksToWait == ( TickType_t ) 0 )
{
/* ... */
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
traceQUEUE_PEEK_FAILED( pxQueue );
return errQUEUE_EMPTY;
}{...}
else if( xEntryTimeSet == pdFALSE )
{
/* ... */
vTaskInternalSetTimeOutState( &xTimeOut );
xEntryTimeSet = pdTRUE;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
/* ... */
#if ( queueUSE_LOCKS == 0 )
{
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
{
traceBLOCKING_ON_QUEUE_PEEK( pxQueue );
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
portYIELD_WITHIN_API();
}{...}
else
{
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
traceQUEUE_PEEK_FAILED( pxQueue );
return errQUEUE_EMPTY;
}{...}
}/* ... */
{...} #endif
}{...}
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
/* ... */
#if ( queueUSE_LOCKS == 1 )
{
/* ... */
vTaskSuspendAll();
prvLockQueue( pxQueue );
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
{
/* ... */
if( prvIsQueueEmpty( pxQueue ) != pdFALSE )
{
traceBLOCKING_ON_QUEUE_PEEK( pxQueue );
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
prvUnlockQueue( pxQueue );
if( xTaskResumeAll() == pdFALSE )
{
portYIELD_WITHIN_API();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
/* ... */
prvUnlockQueue( pxQueue );
( void ) xTaskResumeAll();
}{...}
}{...}
else
{
/* ... */
prvUnlockQueue( pxQueue );
( void ) xTaskResumeAll();
if( prvIsQueueEmpty( pxQueue ) != pdFALSE )
{
traceQUEUE_PEEK_FAILED( pxQueue );
return errQUEUE_EMPTY;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
}/* ... */
{...} #endif
}{...}
}{ ... }
BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue,
void * const pvBuffer,
BaseType_t * const pxHigherPriorityTaskWoken )
{
BaseType_t xReturn;
UBaseType_t uxSavedInterruptStatus;
Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );
/* ... */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
prvENTER_CRITICAL_OR_MASK_ISR( &( pxQueue->xQueueLock ), uxSavedInterruptStatus );
{
const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting;
if( uxMessagesWaiting > ( UBaseType_t ) 0 )
{
#if ( queueUSE_LOCKS == 1 )
const int8_t cRxLock = pxQueue->cRxLock;
#else
const int8_t cRxLock = queueUNLOCKED;/* ... */
#endif
traceQUEUE_RECEIVE_FROM_ISR( pxQueue );
prvCopyDataFromQueue( pxQueue, pvBuffer );
pxQueue->uxMessagesWaiting = uxMessagesWaiting - ( UBaseType_t ) 1;
/* ... */
if( cRxLock == queueUNLOCKED )
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
{
/* ... */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
#if ( queueUSE_LOCKS == 1 )
{
/* ... */
prvIncrementQueueRxLock( pxQueue, cRxLock );
}/* ... */
{...} #endif
}{...}
xReturn = pdPASS;
}{...}
else
{
xReturn = pdFAIL;
traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue );
}{...}
}{...}
prvEXIT_CRITICAL_OR_UNMASK_ISR( &( pxQueue->xQueueLock ), uxSavedInterruptStatus );
return xReturn;
}{ ... }
BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue,
void * const pvBuffer )
{
BaseType_t xReturn;
UBaseType_t uxSavedInterruptStatus;
int8_t * pcOriginalReadPosition;
Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );
configASSERT( pxQueue->uxItemSize != 0 );
/* ... */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
prvENTER_CRITICAL_OR_MASK_ISR( &( pxQueue->xQueueLock ), uxSavedInterruptStatus );
{
if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )
{
traceQUEUE_PEEK_FROM_ISR( pxQueue );
/* ... */
pcOriginalReadPosition = pxQueue->u.xQueue.pcReadFrom;
prvCopyDataFromQueue( pxQueue, pvBuffer );
pxQueue->u.xQueue.pcReadFrom = pcOriginalReadPosition;
xReturn = pdPASS;
}{...}
else
{
xReturn = pdFAIL;
traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue );
}{...}
}{...}
prvEXIT_CRITICAL_OR_UNMASK_ISR( &( pxQueue->xQueueLock ), uxSavedInterruptStatus );
return xReturn;
}{ ... }
UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue )
{
UBaseType_t uxReturn;
configASSERT( xQueue );
taskENTER_CRITICAL( &( ( ( Queue_t * ) xQueue )->xQueueLock ) );
{
uxReturn = ( ( Queue_t * ) xQueue )->uxMessagesWaiting;
}{...}
taskEXIT_CRITICAL( &( ( ( Queue_t * ) xQueue )->xQueueLock ) );
return uxReturn;
}{ ... }
UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue )
{
UBaseType_t uxReturn;
Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
taskENTER_CRITICAL( &( pxQueue->xQueueLock ) );
{
uxReturn = pxQueue->uxLength - pxQueue->uxMessagesWaiting;
}{...}
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
return uxReturn;
}{ ... }
UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue )
{
UBaseType_t uxReturn;
Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
uxReturn = pxQueue->uxMessagesWaiting;
return uxReturn;
}{ ... }
void vQueueDelete( QueueHandle_t xQueue )
{
Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
traceQUEUE_DELETE( pxQueue );
#if ( configQUEUE_REGISTRY_SIZE > 0 )
{
vQueueUnregisterQueue( pxQueue );
}/* ... */
{...} #endif
#if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) )
{
/* ... */
vPortFree( pxQueue );
}/* ... */
{...} #elif ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
{
/* ... */
if( pxQueue->ucStaticallyAllocated == ( uint8_t ) pdFALSE )
{
vPortFree( pxQueue );
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}/* ... */
{...} #else
{
/* ... */
( void ) pxQueue;
}/* ... */
{...} #endif
}{ ... }
#if ( configUSE_TRACE_FACILITY == 1 )
UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue )
{
return ( ( Queue_t * ) xQueue )->uxQueueNumber;
}{...}
/* ... */
#endif
#if ( configUSE_TRACE_FACILITY == 1 )
void vQueueSetQueueNumber( QueueHandle_t xQueue,
UBaseType_t uxQueueNumber )
{
( ( Queue_t * ) xQueue )->uxQueueNumber = uxQueueNumber;
}{...}
/* ... */
#endif
#if ( configUSE_TRACE_FACILITY == 1 )
uint8_t ucQueueGetQueueType( QueueHandle_t xQueue )
{
return ( ( Queue_t * ) xQueue )->ucQueueType;
}{...}
/* ... */
#endif
#if ( configUSE_MUTEXES == 1 )
static UBaseType_t prvGetDisinheritPriorityAfterTimeout( const Queue_t * const pxQueue )
{
UBaseType_t uxHighestPriorityOfWaitingTasks;
/* ... */
if( listCURRENT_LIST_LENGTH( &( pxQueue->xTasksWaitingToReceive ) ) > 0U )
{
uxHighestPriorityOfWaitingTasks = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) listGET_ITEM_VALUE_OF_HEAD_ENTRY( &( pxQueue->xTasksWaitingToReceive ) );
}{...}
else
{
uxHighestPriorityOfWaitingTasks = tskIDLE_PRIORITY;
}{...}
return uxHighestPriorityOfWaitingTasks;
}{ ... }
/* ... */#endif
static BaseType_t prvCopyDataToQueue( Queue_t * const pxQueue,
const void * pvItemToQueue,
const BaseType_t xPosition )
{
BaseType_t xReturn = pdFALSE;
UBaseType_t uxMessagesWaiting;
uxMessagesWaiting = pxQueue->uxMessagesWaiting;
if( pxQueue->uxItemSize == ( UBaseType_t ) 0 )
{
#if ( configUSE_MUTEXES == 1 )
{
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
{
xReturn = xTaskPriorityDisinherit( pxQueue->u.xSemaphore.xMutexHolder );
pxQueue->u.xSemaphore.xMutexHolder = NULL;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}/* ... */
{...} #endif
}{...}
else if( xPosition == queueSEND_TO_BACK )
{
( void ) memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( size_t ) pxQueue->uxItemSize );
pxQueue->pcWriteTo += pxQueue->uxItemSize;
if( pxQueue->pcWriteTo >= pxQueue->u.xQueue.pcTail )
{
pxQueue->pcWriteTo = pxQueue->pcHead;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
( void ) memcpy( ( void * ) pxQueue->u.xQueue.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize );
pxQueue->u.xQueue.pcReadFrom -= pxQueue->uxItemSize;
if( pxQueue->u.xQueue.pcReadFrom < pxQueue->pcHead )
{
pxQueue->u.xQueue.pcReadFrom = ( pxQueue->u.xQueue.pcTail - pxQueue->uxItemSize );
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
if( xPosition == queueOVERWRITE )
{
if( uxMessagesWaiting > ( UBaseType_t ) 0 )
{
/* ... */
--uxMessagesWaiting;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
pxQueue->uxMessagesWaiting = uxMessagesWaiting + ( UBaseType_t ) 1;
return xReturn;
}{ ... }
static void prvCopyDataFromQueue( Queue_t * const pxQueue,
void * const pvBuffer )
{
if( pxQueue->uxItemSize != ( UBaseType_t ) 0 )
{
pxQueue->u.xQueue.pcReadFrom += pxQueue->uxItemSize;
if( pxQueue->u.xQueue.pcReadFrom >= pxQueue->u.xQueue.pcTail )
{
pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.xQueue.pcReadFrom, ( size_t ) pxQueue->uxItemSize );
}{...}
}{ ... }
#if ( queueUSE_LOCKS == 1 )
static void prvUnlockQueue( Queue_t * const pxQueue )
{
/* ... */
taskENTER_CRITICAL( &( pxQueue->xQueueLock ) );
{
int8_t cTxLock = pxQueue->cTxLock;
while( cTxLock > queueLOCKED_UNMODIFIED )
{
/* ... */
#if ( configUSE_QUEUE_SETS == 1 )
{
if( pxQueue->pxQueueSetContainer != NULL )
{
if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )
{
/* ... */
vTaskMissedYield();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
/* ... */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* ... */
vTaskMissedYield();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
break;
}{...}
}{...}
}/* ... */
{...} #else
{
/* ... */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* ... */
vTaskMissedYield();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
break;
}{...}
}/* ... */
{...} #endif
--cTxLock;
}{...}
pxQueue->cTxLock = queueUNLOCKED;
}{...}
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
taskENTER_CRITICAL( &( pxQueue->xQueueLock ) );
{
int8_t cRxLock = pxQueue->cRxLock;
while( cRxLock > queueLOCKED_UNMODIFIED )
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
{
vTaskMissedYield();
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
--cRxLock;
}{...}
else
{
break;
}{...}
}{...}
pxQueue->cRxLock = queueUNLOCKED;
}{...}
taskEXIT_CRITICAL( &( pxQueue->xQueueLock ) );
}{...}
/* ... */#endif
#if ( queueUSE_LOCKS == 1 )
static BaseType_t prvIsQueueEmpty( const Queue_t * pxQueue )
{
BaseType_t xReturn;
taskENTER_CRITICAL( &( ( ( Queue_t * ) pxQueue )->xQueueLock ) );
{
if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 )
{
xReturn = pdTRUE;
}{...}
else
{
xReturn = pdFALSE;
}{...}
}{...}
taskEXIT_CRITICAL( &( ( ( Queue_t * ) pxQueue )->xQueueLock ) );
return xReturn;
}{...}
/* ... */#endif
BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue )
{
BaseType_t xReturn;
Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 )
{
xReturn = pdTRUE;
}{...}
else
{
xReturn = pdFALSE;
}{...}
return xReturn;
}{ ... }
#if ( queueUSE_LOCKS == 1 )
static BaseType_t prvIsQueueFull( const Queue_t * pxQueue )
{
BaseType_t xReturn;
taskENTER_CRITICAL( &( ( ( Queue_t * ) pxQueue )->xQueueLock ) );
{
if( pxQueue->uxMessagesWaiting == pxQueue->uxLength )
{
xReturn = pdTRUE;
}{...}
else
{
xReturn = pdFALSE;
}{...}
}{...}
taskEXIT_CRITICAL( &( ( ( Queue_t * ) pxQueue )->xQueueLock ) );
return xReturn;
}{...}
/* ... */#endif
BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue )
{
BaseType_t xReturn;
Queue_t * const pxQueue = xQueue;
configASSERT( pxQueue );
if( pxQueue->uxMessagesWaiting == pxQueue->uxLength )
{
xReturn = pdTRUE;
}{...}
else
{
xReturn = pdFALSE;
}{...}
return xReturn;
}{ ... }
#if ( configUSE_CO_ROUTINES == 1 )
BaseType_t xQueueCRSend( QueueHandle_t xQueue,
const void * pvItemToQueue,
TickType_t xTicksToWait )
{
BaseType_t xReturn;
Queue_t * const pxQueue = xQueue;
/* ... */
portDISABLE_INTERRUPTS();
{
if( prvIsQueueFull( pxQueue ) != pdFALSE )
{
/* ... */
if( xTicksToWait > ( TickType_t ) 0 )
{
/* ... */
vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToSend ) );
portENABLE_INTERRUPTS();
return errQUEUE_BLOCKED;
}{...}
else
{
portENABLE_INTERRUPTS();
return errQUEUE_FULL;
}{...}
}{...}
}{...}
portENABLE_INTERRUPTS();
portDISABLE_INTERRUPTS();
{
if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
{
prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK );
xReturn = pdPASS;
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
/* ... */
if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* ... */
xReturn = errQUEUE_YIELD;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
xReturn = errQUEUE_FULL;
}{...}
}{...}
portENABLE_INTERRUPTS();
return xReturn;
}{...}
/* ... */
#endif
#if ( configUSE_CO_ROUTINES == 1 )
BaseType_t xQueueCRReceive( QueueHandle_t xQueue,
void * pvBuffer,
TickType_t xTicksToWait )
{
BaseType_t xReturn;
Queue_t * const pxQueue = xQueue;
/* ... */
portDISABLE_INTERRUPTS();
{
if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 )
{
/* ... */
if( xTicksToWait > ( TickType_t ) 0 )
{
/* ... */
vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToReceive ) );
portENABLE_INTERRUPTS();
return errQUEUE_BLOCKED;
}{...}
else
{
portENABLE_INTERRUPTS();
return errQUEUE_FULL;
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
portENABLE_INTERRUPTS();
portDISABLE_INTERRUPTS();
{
if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )
{
pxQueue->u.xQueue.pcReadFrom += pxQueue->uxItemSize;
if( pxQueue->u.xQueue.pcReadFrom >= pxQueue->u.xQueue.pcTail )
{
pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
--( pxQueue->uxMessagesWaiting );
( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.xQueue.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
xReturn = pdPASS;
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
{
/* ... */
if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
{
xReturn = errQUEUE_YIELD;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
xReturn = pdFAIL;
}{...}
}{...}
portENABLE_INTERRUPTS();
return xReturn;
}{...}
/* ... */
#endif
#if ( configUSE_CO_ROUTINES == 1 )
BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue,
const void * pvItemToQueue,
BaseType_t xCoRoutinePreviouslyWoken )
{
Queue_t * const pxQueue = xQueue;
/* ... */
if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
{
prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK );
/* ... */
if( xCoRoutinePreviouslyWoken == pdFALSE )
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
return pdTRUE;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
return xCoRoutinePreviouslyWoken;
}{...}
/* ... */
#endif
#if ( configUSE_CO_ROUTINES == 1 )
BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue,
void * pvBuffer,
BaseType_t * pxCoRoutineWoken )
{
BaseType_t xReturn;
Queue_t * const pxQueue = xQueue;
/* ... */
if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )
{
pxQueue->u.xQueue.pcReadFrom += pxQueue->uxItemSize;
if( pxQueue->u.xQueue.pcReadFrom >= pxQueue->u.xQueue.pcTail )
{
pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
--( pxQueue->uxMessagesWaiting );
( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.xQueue.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
if( ( *pxCoRoutineWoken ) == pdFALSE )
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
{
if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
{
*pxCoRoutineWoken = pdTRUE;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
xReturn = pdPASS;
}{...}
else
{
xReturn = pdFAIL;
}{...}
return xReturn;
}{...}
/* ... */
#endif
#if ( configQUEUE_REGISTRY_SIZE > 0 )
void vQueueAddToRegistry( QueueHandle_t xQueue,
const char * pcQueueName )
{
UBaseType_t ux;
QueueRegistryItem_t * pxEntryToWrite = NULL;
configASSERT( xQueue );
/* ... */
prvENTER_CRITICAL_SMP_ONLY( &xQueueRegistryLock );
{
if( pcQueueName != NULL )
{
/* ... */
for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ )
{
if( xQueue == xQueueRegistry[ ux ].xHandle )
{
pxEntryToWrite = &( xQueueRegistry[ ux ] );
break;
}{...}
else if( ( pxEntryToWrite == NULL ) && ( xQueueRegistry[ ux ].pcQueueName == NULL ) )
{
pxEntryToWrite = &( xQueueRegistry[ ux ] );
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
}{...}
if( pxEntryToWrite != NULL )
{
pxEntryToWrite->pcQueueName = pcQueueName;
pxEntryToWrite->xHandle = xQueue;
traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName );
}{...}
}{...}
prvEXIT_CRITICAL_SMP_ONLY( &xQueueRegistryLock );
}{...}
/* ... */
#endif
#if ( configQUEUE_REGISTRY_SIZE > 0 )
const char * pcQueueGetName( QueueHandle_t xQueue )
{
UBaseType_t ux;
const char * pcReturn = NULL;
configASSERT( xQueue );
/* ... */
prvENTER_CRITICAL_SMP_ONLY( &xQueueRegistryLock );
{
/* ... */
for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ )
{
if( xQueueRegistry[ ux ].xHandle == xQueue )
{
pcReturn = xQueueRegistry[ ux ].pcQueueName;
break;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
}{...}
prvEXIT_CRITICAL_SMP_ONLY( &xQueueRegistryLock );
return pcReturn;
}{...}
/* ... */
#endif
#if ( configQUEUE_REGISTRY_SIZE > 0 )
void vQueueUnregisterQueue( QueueHandle_t xQueue )
{
UBaseType_t ux;
configASSERT( xQueue );
/* ... */
prvENTER_CRITICAL_SMP_ONLY( &xQueueRegistryLock );
{
/* ... */
for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ )
{
if( xQueueRegistry[ ux ].xHandle == xQueue )
{
xQueueRegistry[ ux ].pcQueueName = NULL;
/* ... */
xQueueRegistry[ ux ].xHandle = ( QueueHandle_t ) 0;
break;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
}{...}
prvEXIT_CRITICAL_SMP_ONLY( &xQueueRegistryLock );
}{...}
/* ... */
#endif
#if ( configUSE_TIMERS == 1 )
void vQueueWaitForMessageRestricted( QueueHandle_t xQueue,
TickType_t xTicksToWait,
const BaseType_t xWaitIndefinitely )
{
Queue_t * const pxQueue = xQueue;
/* ... */
/* ... */
prvENTER_CRITICAL_SMP_ONLY( &( pxQueue->xQueueLock ) );
{
#if ( queueUSE_LOCKS == 1 )
{
/* ... */
prvLockQueue( pxQueue );
}/* ... */
{...} #endif
if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0U )
{
vTaskPlaceOnEventListRestricted( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait, xWaitIndefinitely );
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
#if ( queueUSE_LOCKS == 1 )
{
prvUnlockQueue( pxQueue );
}/* ... */
{...} #endif
}{...}
prvEXIT_CRITICAL_SMP_ONLY( &( pxQueue->xQueueLock ) );
}{ ... }
/* ... */#endif
#if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength )
{
QueueSetHandle_t pxQueue;
pxQueue = xQueueGenericCreate( uxEventQueueLength, ( UBaseType_t ) sizeof( Queue_t * ), queueQUEUE_TYPE_SET );
return pxQueue;
}{ ... }
/* ... */#endif
#if ( configUSE_QUEUE_SETS == 1 )
BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore,
QueueSetHandle_t xQueueSet )
{
BaseType_t xReturn;
taskENTER_CRITICAL( &( ( ( Queue_t * ) xQueueOrSemaphore )->xQueueLock ) );
{
if( ( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer != NULL )
{
xReturn = pdFAIL;
}{...}
else if( ( ( Queue_t * ) xQueueOrSemaphore )->uxMessagesWaiting != ( UBaseType_t ) 0 )
{
/* ... */
xReturn = pdFAIL;
}{...}
else
{
( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer = xQueueSet;
xReturn = pdPASS;
}{...}
}{...}
taskEXIT_CRITICAL( &( ( ( Queue_t * ) xQueueOrSemaphore )->xQueueLock ) );
return xReturn;
}{ ... }
/* ... */#endif
#if ( configUSE_QUEUE_SETS == 1 )
BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
QueueSetHandle_t xQueueSet )
{
BaseType_t xReturn;
Queue_t * const pxQueueOrSemaphore = ( Queue_t * ) xQueueOrSemaphore;
if( pxQueueOrSemaphore->pxQueueSetContainer != xQueueSet )
{
xReturn = pdFAIL;
}{...}
else if( pxQueueOrSemaphore->uxMessagesWaiting != ( UBaseType_t ) 0 )
{
/* ... */
xReturn = pdFAIL;
}{...}
else
{
taskENTER_CRITICAL( &( ( ( Queue_t * ) pxQueueOrSemaphore )->xQueueLock ) );
{
pxQueueOrSemaphore->pxQueueSetContainer = NULL;
}{...}
taskEXIT_CRITICAL( &( ( ( Queue_t * ) pxQueueOrSemaphore )->xQueueLock ) );
xReturn = pdPASS;
}{...}
return xReturn;
}{ ... }
/* ... */
#endif
#if ( configUSE_QUEUE_SETS == 1 )
QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet,
TickType_t const xTicksToWait )
{
QueueSetMemberHandle_t xReturn = NULL;
( void ) xQueueReceive( ( QueueHandle_t ) xQueueSet, &xReturn, xTicksToWait );
return xReturn;
}{ ... }
/* ... */#endif
#if ( configUSE_QUEUE_SETS == 1 )
QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet )
{
QueueSetMemberHandle_t xReturn = NULL;
( void ) xQueueReceiveFromISR( ( QueueHandle_t ) xQueueSet, &xReturn, NULL );
return xReturn;
}{ ... }
/* ... */#endif
#if ( configUSE_QUEUE_SETS == 1 )
static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue )
{
Queue_t * pxQueueSetContainer = pxQueue->pxQueueSetContainer;
BaseType_t xReturn = pdFALSE;
/* ... */
configASSERT( pxQueueSetContainer );
configASSERT( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength );
/* ... */
prvENTER_CRITICAL_SAFE_SMP_ONLY( &( pxQueueSetContainer->xQueueLock ) );
{
if( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength )
{
#if ( queueUSE_LOCKS == 1 )
const int8_t cTxLock = pxQueueSetContainer->cTxLock;
#else
const int8_t cTxLock = queueUNLOCKED;/* ... */
#endif
traceQUEUE_SET_SEND( pxQueueSetContainer );
xReturn = prvCopyDataToQueue( pxQueueSetContainer, &pxQueue, queueSEND_TO_BACK );
if( cTxLock == queueUNLOCKED )
{
if( listLIST_IS_EMPTY( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) != pdFALSE )
{
xReturn = pdTRUE;
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
else
{
#if ( queueUSE_LOCKS == 1 )
{
prvIncrementQueueTxLock( pxQueueSetContainer, cTxLock );
}/* ... */
{...} #endif
}{...}
}{...}
else
{
mtCOVERAGE_TEST_MARKER();
}{...}
}{...}
prvEXIT_CRITICAL_SAFE_SMP_ONLY( &( pxQueueSetContainer->xQueueLock ) );
return xReturn;
}{ ... }
/* ... */#endif