1
10
11
12
13
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
44
45
54
55
56
57
58
59
61
62
63
64
65
66
67
68
69
85
86
99
100
101
102
103
104
105
106
107
108
109
110
113
114
115
116
117
120
121
122
123
124
125
126
127
128
129
132
133
134
137
138
141
142
143
144
145
146
147
151
152
153
157
158
159
160
161
162
163
164
165
166
170
171
172
173
174
175
176
181
182
183
184
185
186
187
195
196
197
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
228
229
230
231
232
236
237
243
244
249
250
251
252
255
256
257
258
261
262
263
264
265
266
267
268
269
270
271
272
273
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
331
332
333
334
335
336
337
341
342
343
344
345
346
350
351
352
353
354
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
390
391
392
395
396
397
401
402
403
404
405
406
407
408
409
410
416
417
418
419
420
421
428
429
430
431
432
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
471
472
473
474
475
476
477
478
479
480
486
487
488
489
490
491
492
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
523
524
525
529
530
531
532
533
534
535
536
537
538
539
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
569
570
571
572
573
574
575
576
577
578
579
580
585
586
587
591
592
593
594
595
596
597
598
602
603
604
605
606
607
608
609
610
611
612
613
614
619
620
621
622
623
624
628
629
630
631
632
633
634
635
636
637
638
643
644
645
649
650
651
652
653
654
655
656
657
658
659
660
661
662
665
666
667
668
669
670
671
674
675
676
680
681
685
686
690
691
692
693
694
695
696
697
698
702
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
729
730
731
732
738
739
740
741
742
743
744
745
746
747
748
749
750
755
756
757
758
759
760
761
762
763
764
765
779
780
781
782
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
814
815
816
817
818
819
820
821
822
834
835
836
837
844
845
846
847
848
849
850
851
852
853
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
892
893
894
895
896
897
900
901
902
903
904
905
906
907
908
913
914
915
916
917
918
919
922
926
930
934
942
946
947
948
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
995
996
997
998
1003
1004
1005
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1059
1060
1061
1064
1065
1066
1067
1068
1069
1070
1071
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1094
1095
1096
1097
1098
1099
1100
1101
1104
1105
1106
1107
1108
1109
1113
1114
1115
1121
1122
1123
1124
1125
1126
1127
1128
1129
1133
1134
1135
1138
1139
1140
1141
1142
1143
1144
1145
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1184
1185
1186
1189
1190
1191
1192
1193
1194
1195
1196
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1216
1217
1218
1219
1220
1221
1222
1223
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1241
1242
1246
1247
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1265
1266
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1316
1317
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1348
1349
1350
1351
1352
1358
1359
1360
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1414
1415
1416
1417
1418
1424
1425
1426
1430
1431
1432
1436
1437
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1476
1477
1478
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1501
1502
1503
1506
1507
1508
1509
1510
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1530
1531
1532
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1549
1550
1551
1554
1555
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1577
1578
1579
1580
1583
1584
1585
1586
1587
1592
1593
1594
1595
1596
1600
1601
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1662
1663
1667
1668
1669
1670
1673
1674
1675
1676
1677
1682
1683
1684
1685
1686
1687
1688
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1743
1744
1745
1746
1749
1750
1751
1752
1753
1758
1759
1760
1761
1762
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
1800
1801
1802
1803
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1847
1848
1849
1850
1851
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1886
1887
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1906
1907
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1939
1940
1941
1942
1943
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1980
1981
1982
1991
1992
1993
1994
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2028
2029
2030
2033
2034
2035
2036
2037
2038
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2057
2058
2059
2060
2061
2062
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2080
2081
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2104
2105
2118
2119
2120
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2140
2141
2142
2146
2147
2148
2149
2150
2151
2152
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2177
2178
2179
2180
2185
2186
2187
2188
2189
2190
2191
2192
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2211
2212
2213
2214
2215
2216
2222
2223
2224
2225
2226
2227
2228
2229
2230
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2256
2257
2258
2261
2262
2263
2264
2265
2266
2267
2268
2275
2276
2277
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2304
2305
2306
2307
2308
2309
2310
2311
2316
2317
2318
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2337
2338
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2357
2358
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2415
2416
2421
2425
2426
2427
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2453
2454
2459
2463
2464
2465
2469
2470
2471
2472
2473
2474
2475
2476
2477
2483
2484
2485
2486
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2557
2558
2559
2560
2565
2569
2570
2571
2575
2576
2577
2578
2579
2580
2581
2582
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2667
2668
2669
2672
2673
2674
2675
2679
2680
2681
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2707
2708
2709
2710
2711
2712
2716
2717
2718
2719
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2789
2790
2791
2794
2795
2796
2797
2798
2799
...
...
...
#include <stdint.h>
#include <tx_api.h>
#include <tx_thread.h>
#include <tx_semaphore.h>
#include <tx_queue.h>
#include "FreeRTOS.h"
6 includes
#if (INCLUDE_vTaskDelete == 1)
static TX_THREAD txfr_idle_task;
#ifdef TX_FREERTOS_IDLE_STACK
static UINT txfr_idle_stack[TX_FREERTOS_IDLE_STACK];
#else
static UINT txfr_idle_stack[configMINIMAL_STACK_SIZE];
#endif
static TX_SEMAPHORE txfr_idle_sem;
static txfr_task_t *p_delete_task_head;/* ... */
#endif
UBaseType_t g_txfr_task_count;
#ifdef configTOTAL_HEAP_SIZE
static uint8_t txfr_heap_mem[configTOTAL_HEAP_SIZE];
static TX_BYTE_POOL txfr_heap;/* ... */
#endif
static UINT txfr_heap_initialized;
#if (TX_FREERTOS_AUTO_INIT == 1)
static UINT txfr_initialized;
#endif
void *txfr_malloc(size_t len)
{
void *p;
UINT ret;
if(txfr_heap_initialized == 1u) {
ret = tx_byte_allocate(&txfr_heap, &p, len, 0u);
if(ret != TX_SUCCESS) {
return NULL;
}if (ret != TX_SUCCESS) { ... }
}if (txfr_heap_initialized == 1u) { ... } else {
return NULL;
}else { ... }
return p;
}{ ... }
void txfr_free(void *p)
{
UINT ret;
if(txfr_heap_initialized == 1u) {
ret = tx_byte_release(p);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
}if (ret != TX_SUCCESS) { ... }
}if (txfr_heap_initialized == 1u) { ... }
return;
}{ ... }
#if (INCLUDE_vTaskDelete == 1)
static void txfr_idle_task_entry(ULONG id)
{
txfr_task_t *p_task;
UINT ret;
TX_INTERRUPT_SAVE_AREA;
for(;;) {
ret = tx_semaphore_get(&txfr_idle_sem, TX_WAIT_FOREVER);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
}if (ret != TX_SUCCESS) { ... }
TX_DISABLE;
p_task = p_delete_task_head;
if(p_task != NULL) {
p_delete_task_head = p_task->p_next;
}if (p_task != NULL) { ... }
g_txfr_task_count--;
TX_RESTORE;
if(p_task != NULL) {
(void)tx_thread_terminate(&p_task->thread);
ret = tx_thread_delete(&p_task->thread);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
}if (ret != TX_SUCCESS) { ... }
ret = tx_semaphore_delete(&p_task->notification_sem);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
}if (ret != TX_SUCCESS) { ... }
if(p_task->allocated == 1u) {
txfr_free(p_task);
}if (p_task->allocated == 1u) { ... }
}if (p_task != NULL) { ... }
}for (;;) { ... }
}{ ... }
/* ... */#endif
static uint32_t txfr_prio_fr_to_tx(uint32_t prio)
{
return TX_MAX_PRIORITIES - 1u - prio;
}{ ... }
static uint32_t txfr_prio_tx_to_fr(uint32_t prio)
{
return TX_MAX_PRIORITIES - 1u - prio;
}{ ... }
#if (TX_FREERTOS_AUTO_INIT == 1)
static void tx_freertos_auto_init(void)
{
UINT ret;
tx_kernel_enter();
ret = tx_freertos_init();
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return;
}if (ret != TX_SUCCESS) { ... }
txfr_initialized = 1u;
}tx_freertos_auto_init (void) { ... }
/* ... */#endif
#if (TX_FREERTOS_AUTO_INIT == 1)
VOID tx_application_define(VOID * first_unused_memory)
{
}tx_application_define (VOID * first_unused_memory) { ... }
/* ... */#endif
UINT tx_freertos_init(void)
{
UINT ret;
#ifdef configTOTAL_HEAP_SIZE
if(configTOTAL_HEAP_SIZE > 0u) {
ret = tx_byte_pool_create(&txfr_heap, "txfr_byte_pool", txfr_heap_mem, configTOTAL_HEAP_SIZE);
if(ret != TX_SUCCESS) {
return ret;
}if (ret != TX_SUCCESS) { ... }
txfr_heap_initialized = 1u;
}if (configTOTAL_HEAP_SIZE > 0u) { ... }
/* ... */#endif
#if (INCLUDE_vTaskDelete == 1)
ret = tx_semaphore_create(&txfr_idle_sem, "txfr_idle_semaphore", 0u);
if(ret != TX_SUCCESS) {
return ret;
}if (ret != TX_SUCCESS) { ... }
ret = tx_thread_create(&txfr_idle_task, "txfr_idle_task", txfr_idle_task_entry, 0u,
txfr_idle_stack, sizeof(txfr_idle_stack), TX_MAX_PRIORITIES - 1u, TX_MAX_PRIORITIES - 1u, 0u, TX_AUTO_START);
if(ret != TX_SUCCESS) {
return ret;
}if (ret != TX_SUCCESS) { ... }
/* ... */#endif
return TX_SUCCESS;
}{ ... }
void txfr_thread_wrapper(ULONG id)
{
TX_THREAD *p_thread;
txfr_task_t *p_txfr_task;
p_thread = tx_thread_identify();
p_txfr_task = p_thread->txfr_thread_ptr;
p_txfr_task->p_task_func(p_txfr_task->p_task_arg);
#if (INCLUDE_vTaskDelete == 1)
vTaskDelete(NULL);
#else
TX_FREERTOS_ASSERT_FAIL();/* ... */
#endif
}{ ... }
void *pvPortMalloc(size_t xWantedSize)
{
return txfr_malloc(xWantedSize);
}{ ... }
void vPortFree(void *pv)
{
txfr_free(pv);
return;
}{ ... }
void vPortEnterCritical(void)
{
portDISABLE_INTERRUPTS();
_tx_thread_preempt_disable++;
}{ ... }
void vPortExitCritical(void)
{
if(_tx_thread_preempt_disable == 0u) {
TX_FREERTOS_ASSERT_FAIL();
}if (_tx_thread_preempt_disable == 0u) { ... }
_tx_thread_preempt_disable--;
if(_tx_thread_preempt_disable == 0u) {
portENABLE_INTERRUPTS();
}if (_tx_thread_preempt_disable == 0u) { ... }
}{ ... }
void vTaskStartScheduler(void)
{
#if (TX_FREERTOS_AUTO_INIT == 1)
_tx_thread_schedule();
#else
#endif
}{ ... }
BaseType_t xTaskGetSchedulerState(void)
{
if(_tx_thread_preempt_disable > 0u) {
return taskSCHEDULER_SUSPENDED;
}if (_tx_thread_preempt_disable > 0u) { ... } else {
return taskSCHEDULER_RUNNING;
}else { ... }
}{ ... }
void vTaskSuspendAll(void)
{
TX_INTERRUPT_SAVE_AREA;
TX_DISABLE;
_tx_thread_preempt_disable++;
TX_RESTORE;
}{ ... }
BaseType_t xTaskResumeAll(void)
{
TX_INTERRUPT_SAVE_AREA;
TX_DISABLE;
_tx_thread_preempt_disable--;
TX_RESTORE;
return pdFALSE;
}{ ... }
void vTaskDelay(const TickType_t xTicksToDelay)
{
tx_thread_sleep(xTicksToDelay);
}{ ... }
TaskHandle_t xTaskCreateStatic(TaskFunction_t pxTaskCode,
const char *const pcName,
const configSTACK_DEPTH_TYPE ulStackDepth,
void *const pvParameters,
UBaseType_t uxPriority,
StackType_t *const puxStackBuffer,
StaticTask_t *const pxTaskBuffer)
{
UINT prio;
UINT ret;
TX_INTERRUPT_SAVE_AREA;
configASSERT(pxTaskCode != NULL);
configASSERT(ulStackDepth >= configMINIMAL_STACK_SIZE);
configASSERT(uxPriority < configMAX_PRIORITIES);
configASSERT(puxStackBuffer != NULL);
configASSERT(pxTaskBuffer != NULL);
#if (TX_FREERTOS_AUTO_INIT == 1)
if(txfr_initialized != 1u) {
tx_freertos_auto_init();
}if (txfr_initialized != 1u) { ... }
/* ... */#endif
TX_MEMSET(pxTaskBuffer, 0, sizeof(*pxTaskBuffer));
pxTaskBuffer->p_task_arg = pvParameters;
pxTaskBuffer->p_task_func = pxTaskCode;
ret = tx_semaphore_create(&pxTaskBuffer->notification_sem, "", 0u);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return NULL;
}if (ret != TX_SUCCESS) { ... }
prio = txfr_prio_fr_to_tx(uxPriority);
ret = tx_thread_create(&pxTaskBuffer->thread, (CHAR *)pcName, txfr_thread_wrapper, (ULONG)pvParameters,
puxStackBuffer, ulStackDepth, prio, prio, 0u, TX_DONT_START);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return NULL;
}if (ret != TX_SUCCESS) { ... }
pxTaskBuffer->thread.txfr_thread_ptr = pxTaskBuffer;
ret = tx_thread_resume(&pxTaskBuffer->thread);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return NULL;
}if (ret != TX_SUCCESS) { ... }
TX_DISABLE;
g_txfr_task_count++;
TX_RESTORE;
return pxTaskBuffer;
}{ ... }
BaseType_t xTaskCreate(TaskFunction_t pvTaskCode,
const char * const pcName,
const configSTACK_DEPTH_TYPE usStackDepth,
void *pvParameters,
UBaseType_t uxPriority,
TaskHandle_t * const pxCreatedTask)
{
void *p_stack;
txfr_task_t *p_task;
UINT ret;
UINT prio;
TX_INTERRUPT_SAVE_AREA;
configASSERT(pvTaskCode != NULL);
configASSERT(usStackDepth >= configMINIMAL_STACK_SIZE);
configASSERT(uxPriority < configMAX_PRIORITIES);
configASSERT(pxCreatedTask != NULL);
#if (TX_FREERTOS_AUTO_INIT == 1)
if(txfr_initialized != 1u) {
tx_freertos_auto_init();
}if (txfr_initialized != 1u) { ... }
/* ... */#endif
p_stack = txfr_malloc(usStackDepth);
if(p_stack == NULL) {
return errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;
}if (p_stack == NULL) { ... }
p_task = txfr_malloc(sizeof(txfr_task_t));
if(p_task == NULL) {
txfr_free(p_stack);
return errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;
}if (p_task == NULL) { ... }
*pxCreatedTask = p_task;
TX_MEMSET(p_task, 0, sizeof(*p_task));
p_task->allocated = 1u;
p_task->p_task_arg = pvParameters;
p_task->p_task_func = pvTaskCode;
ret = tx_semaphore_create(&p_task->notification_sem, "", 0u);
if(ret != TX_SUCCESS) {
txfr_free(p_stack);
txfr_free(p_task);
TX_FREERTOS_ASSERT_FAIL();
return (BaseType_t)NULL;
}if (ret != TX_SUCCESS) { ... }
prio = txfr_prio_fr_to_tx(uxPriority);
ret = tx_thread_create(&p_task->thread, (CHAR *)pcName, txfr_thread_wrapper, (ULONG)pvParameters,
p_stack, usStackDepth, prio, prio, 0u, TX_DONT_START);
if(ret != TX_SUCCESS) {
(void)tx_semaphore_delete(&p_task->notification_sem);
txfr_free(p_stack);
txfr_free(p_task);
TX_FREERTOS_ASSERT_FAIL();
return (BaseType_t)NULL;
}if (ret != TX_SUCCESS) { ... }
p_task->thread.txfr_thread_ptr = p_task;
ret = tx_thread_resume(&p_task->thread);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
}if (ret != TX_SUCCESS) { ... }
TX_DISABLE;
g_txfr_task_count++;
TX_RESTORE;
return pdPASS;
}{ ... }
UBaseType_t uxTaskGetNumberOfTasks(void)
{
UBaseType_t count;
TX_INTERRUPT_SAVE_AREA;
TX_DISABLE;
count = g_txfr_task_count;
TX_RESTORE;
return count;
}{ ... }
#if (INCLUDE_vTaskDelete == 1)
void vTaskDelete(TaskHandle_t xTask)
{
UINT ret;
TX_THREAD *p_thread;
txfr_task_t *p_txfr_thread;
TX_INTERRUPT_SAVE_AREA;
if(xTask == NULL) {
TX_THREAD_GET_CURRENT(p_thread);
p_txfr_thread = (txfr_task_t *)p_thread->txfr_thread_ptr;
}if (xTask == NULL) { ... } else {
p_txfr_thread = xTask;
p_thread = &xTask->thread;
}else { ... }
TX_DISABLE;
p_txfr_thread->p_next = p_delete_task_head;
p_delete_task_head = p_txfr_thread;
_tx_thread_preempt_disable++;
ret = tx_semaphore_put(&txfr_idle_sem);
if(ret != TX_SUCCESS) {
_tx_thread_preempt_disable--;
TX_RESTORE;
TX_FREERTOS_ASSERT_FAIL();
return;
}if (ret != TX_SUCCESS) { ... }
_tx_thread_preempt_disable--;
TX_RESTORE;
ret = tx_thread_terminate(p_thread);
if(ret != TX_SUCCESS) {
TX_RESTORE;
TX_FREERTOS_ASSERT_FAIL();
return;
}if (ret != TX_SUCCESS) { ... }
return;
}{ ... }
/* ... */#endif
TaskHandle_t xTaskGetCurrentTaskHandle(void)
{
TX_THREAD *p_thread;
p_thread = tx_thread_identify();
return p_thread->txfr_thread_ptr;
}{ ... }
void vTaskSuspend(TaskHandle_t xTaskToSuspend)
{
TX_THREAD *p_thread;
UINT ret;
if(xTaskToSuspend == NULL) {
p_thread = tx_thread_identify();
}if (xTaskToSuspend == NULL) { ... } else {
p_thread = &xTaskToSuspend->thread;
}else { ... }
ret = tx_thread_suspend(p_thread);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return;
}if (ret != TX_SUCCESS) { ... }
}{ ... }
void vTaskResume(TaskHandle_t xTaskToResume)
{
UINT ret;
configASSERT(xTaskToResume != NULL);
ret = tx_thread_resume(&xTaskToResume->thread);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return;
}if (ret != TX_SUCCESS) { ... }
}{ ... }
BaseType_t xTaskResumeFromISR(TaskHandle_t xTaskToResume)
{
configASSERT(xTaskToResume != NULL);
vTaskResume(xTaskToResume);
return pdFALSE;
}{ ... }
BaseType_t xTaskAbortDelay(TaskHandle_t xTask)
{
TX_THREAD *p_thread;
UINT ret;
configASSERT(xTask != NULL);
p_thread = &xTask->thread;
ret = tx_thread_wait_abort(p_thread);
if(ret != TX_SUCCESS) {
return pdFAIL;
}if (ret != TX_SUCCESS) { ... }
return pdPASS;
}{ ... }
UBaseType_t uxTaskPriorityGet(const TaskHandle_t xTask)
{
TX_THREAD *p_thread;
UINT priority;
UINT ret;
if(xTask == NULL) {
p_thread = tx_thread_identify();
}if (xTask == NULL) { ... } else {
p_thread = &xTask->thread;
}else { ... }
ret = tx_thread_info_get(p_thread, NULL, NULL, NULL, &priority, NULL, NULL, NULL, NULL);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return 0;
}if (ret != TX_SUCCESS) { ... }
priority = txfr_prio_tx_to_fr(priority);
return priority;
}{ ... }
UBaseType_t uxTaskPriorityGetFromISR(const TaskHandle_t xTask)
{
return uxTaskPriorityGet(xTask);
}{ ... }
void vTaskPrioritySet(TaskHandle_t xTask,
UBaseType_t uxNewPriority)
{
TX_THREAD *p_thread;
UINT priority;
UINT old_priority;
UINT ret;
configASSERT(uxNewPriority < configMAX_PRIORITIES);
if(xTask == NULL) {
p_thread = tx_thread_identify();
}if (xTask == NULL) { ... } else {
p_thread = &xTask->thread;
}else { ... }
priority = uxNewPriority;
priority = txfr_prio_fr_to_tx(priority);
ret = tx_thread_priority_change(p_thread, priority, &old_priority);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return;
}if (ret != TX_SUCCESS) { ... }
}{ ... }
char *pcTaskGetName(TaskHandle_t xTaskToQuery)
{
TX_THREAD *p_thread;
char *p_task_name;
UINT ret;
if(xTaskToQuery == NULL) {
p_thread = tx_thread_identify();
}if (xTaskToQuery == NULL) { ... } else {
p_thread = &xTaskToQuery->thread;
}else { ... }
ret = tx_thread_info_get(p_thread, &p_task_name, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return 0;
}if (ret != TX_SUCCESS) { ... }
return p_task_name;
}{ ... }
eTaskState eTaskGetState(TaskHandle_t xTask)
{
UINT thread_state;
eTaskState ret_state;
TX_THREAD *p_thread;
TX_INTERRUPT_SAVE_AREA;
if(xTask == NULL) {
return eInvalid;
}if (xTask == NULL) { ... }
TX_DISABLE;
thread_state = xTask->thread.tx_thread_state;
p_thread = &xTask->thread;
TX_RESTORE;
if(p_thread == tx_thread_identify()) {
return eRunning;
}if (p_thread == tx_thread_identify()) { ... }
switch(thread_state) {
case TX_READY:
ret_state = eReady;
break;
case TX_READY:
case TX_COMPLETED:
case TX_TERMINATED:
ret_state = eDeleted;
break;
case TX_TERMINATED:
case TX_SUSPENDED:
case TX_SLEEP:
ret_state = eSuspended;
break;
case TX_SLEEP:
case TX_QUEUE_SUSP:
case TX_SEMAPHORE_SUSP:
case TX_EVENT_FLAG:
case TX_BLOCK_MEMORY:
case TX_BYTE_MEMORY:
case TX_IO_DRIVER:
case TX_FILE:
case TX_TCP_IP:
case TX_MUTEX_SUSP:
ret_state = eBlocked;
break;
case TX_MUTEX_SUSP:
default:
ret_state = eInvalid;
break;default
}switch (thread_state) { ... }
return ret_state;
}{ ... }
void vTaskDelayUntil(TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement)
{
TickType_t tick_cur;
tick_cur = (uint16_t)tx_time_get();
tx_thread_sleep(xTimeIncrement - (tick_cur - *pxPreviousWakeTime));
*pxPreviousWakeTime = *pxPreviousWakeTime + xTimeIncrement;
}{ ... }
BaseType_t xTaskNotifyGive(TaskHandle_t xTaskToNotify)
{
configASSERT(xTaskToNotify != NULL);
return xTaskNotify(xTaskToNotify, 0u, eIncrement);
}{ ... }
void vTaskNotifyGiveFromISR(TaskHandle_t xTaskToNotify,
BaseType_t *pxHigherPriorityTaskWoken)
{
configASSERT(xTaskToNotify != NULL);
(void)xTaskNotify(xTaskToNotify, 0u, eIncrement);
}{ ... }
uint32_t ulTaskNotifyTake(BaseType_t xClearCountOnExit,
TickType_t xTicksToWait)
{
TX_THREAD *p_thread;
uint32_t val;
UINT ret;
UCHAR pend;
txfr_task_t *p_task;
UINT timeout;
if(xTicksToWait == portMAX_DELAY) {
timeout = TX_WAIT_FOREVER;
}if (xTicksToWait == portMAX_DELAY) { ... } else {
timeout = (UINT)xTicksToWait;
}else { ... }
pend = TX_FALSE;
p_thread = tx_thread_identify();
p_task = p_thread->txfr_thread_ptr;
TX_INTERRUPT_SAVE_AREA;
TX_DISABLE;
ret = tx_semaphore_get(&p_task->notification_sem, 0u);
if(ret == TX_SUCCESS) {
val = p_task->task_notify_val;
p_task->p_notify_val_ret = NULL;
if(xClearCountOnExit != pdFALSE) {
p_task->task_notify_val = 0u;
}if (xClearCountOnExit != pdFALSE) { ... } else {
p_task->task_notify_val--;
}else { ... }
}if (ret == TX_SUCCESS) { ... } else {
pend = TX_TRUE;
p_task->p_notify_val_ret = &val;
p_task->clear_on_pend = xClearCountOnExit;
p_task->clear_mask = (uint32_t)-1;
}else { ... }
TX_RESTORE;
if(pend == TX_TRUE) {
ret = tx_semaphore_get(&p_task->notification_sem, timeout);
p_task->p_notify_val_ret = NULL;
if(ret != TX_SUCCESS) {
return 0u;
}if (ret != TX_SUCCESS) { ... }
}if (pend == TX_TRUE) { ... }
return val;
}{ ... }
BaseType_t xTaskNotifyWait(uint32_t ulBitsToClearOnEntry,
uint32_t ulBitsToClearOnExit,
uint32_t *pulNotificationValue,
TickType_t xTicksToWait)
{
TX_INTERRUPT_SAVE_AREA;
TX_THREAD *p_thread;
uint32_t val;
BaseType_t ret_val;
UINT ret;
UCHAR pend;
txfr_task_t *p_task;
UINT timeout;
ret_val = pdPASS;
if(xTicksToWait == portMAX_DELAY) {
timeout = TX_WAIT_FOREVER;
}if (xTicksToWait == portMAX_DELAY) { ... } else {
timeout = (UINT)xTicksToWait;
}else { ... }
pend = TX_FALSE;
p_thread = tx_thread_identify();
p_task = p_thread->txfr_thread_ptr;
TX_DISABLE;
ret = tx_semaphore_get(&p_task->notification_sem, 0u);
if(ret == TX_SUCCESS) {
val = p_task->task_notify_val;
p_task->p_notify_val_ret = NULL;
if(ulBitsToClearOnExit != 0u) {
p_task->task_notify_val &= ~ulBitsToClearOnExit;
}if (ulBitsToClearOnExit != 0u) { ... }
}if (ret == TX_SUCCESS) { ... } else {
pend = TX_TRUE;
p_task->p_notify_val_ret = &val;
p_task->clear_on_pend = 1u;
p_task->clear_mask = ulBitsToClearOnExit;
}else { ... }
TX_RESTORE;
if(pend == TX_TRUE) {
ret = tx_semaphore_get(&p_task->notification_sem, timeout);
p_task->p_notify_val_ret = NULL;
if(ret != TX_SUCCESS) {
return 0u;
}if (ret != TX_SUCCESS) { ... }
}if (pend == TX_TRUE) { ... }
*pulNotificationValue = val;
return ret_val;
}{ ... }
BaseType_t xTaskNotify(TaskHandle_t xTaskToNotify,
uint32_t ulValue,
eNotifyAction eAction)
{
configASSERT(TXFR_NOTIFYACTION_VALID(eAction));
return xTaskNotifyAndQuery(xTaskToNotify, ulValue, eAction, NULL);
}{ ... }
BaseType_t xTaskNotifyFromISR(TaskHandle_t xTaskToNotify,
uint32_t ulValue,
eNotifyAction eAction,
BaseType_t *pxHigherPriorityTaskWoken)
{
configASSERT(xTaskToNotify != NULL);
configASSERT(TXFR_NOTIFYACTION_VALID(eAction));
return xTaskNotify(xTaskToNotify, ulValue, eAction);
}{ ... }
BaseType_t xTaskNotifyAndQuery(TaskHandle_t xTaskToNotify,
uint32_t ulValue,
eNotifyAction eAction,
uint32_t *pulPreviousNotifyValue)
{
UINT ret;
UCHAR notified;
TX_INTERRUPT_SAVE_AREA;
BaseType_t ret_val;
UCHAR waiting;
configASSERT(xTaskToNotify != NULL);
configASSERT(TXFR_NOTIFYACTION_VALID(eAction));
TX_DISABLE;
if(pulPreviousNotifyValue != NULL) {
*pulPreviousNotifyValue = xTaskToNotify->task_notify_val;
}if (pulPreviousNotifyValue != NULL) { ... }
waiting = TX_FALSE;
notified = TX_FALSE;
ret_val = pdPASS;
if(xTaskToNotify->notification_sem.tx_semaphore_suspended_count != 0u) {
waiting = TX_TRUE;
}if (xTaskToNotify->notification_sem.tx_semaphore_suspended_count != 0u) { ... }
if(xTaskToNotify->notification_sem.tx_semaphore_count == 0u) {
_tx_thread_preempt_disable++;
ret = tx_semaphore_put(&xTaskToNotify->notification_sem);
_tx_thread_preempt_disable--;
if(ret != TX_SUCCESS) {
TX_RESTORE;
TX_FREERTOS_ASSERT_FAIL();
return pdFAIL;
}if (ret != TX_SUCCESS) { ... }
xTaskToNotify->task_notify_val_pend = xTaskToNotify->task_notify_val;
notified = TX_TRUE;
}if (xTaskToNotify->notification_sem.tx_semaphore_count == 0u) { ... }
switch (eAction) {
case eNoAction:
break;
case eNoAction:
case eSetBits:
xTaskToNotify->task_notify_val |= ulValue;
break;
case eSetBits:
case eIncrement:
xTaskToNotify->task_notify_val++;
break;
case eIncrement:
case eSetValueWithOverwrite:
xTaskToNotify->task_notify_val = ulValue;
break;
case eSetValueWithOverwrite:
case eSetValueWithoutOverwrite:
if(notified == TX_TRUE) {
xTaskToNotify->task_notify_val = ulValue;
}if (notified == TX_TRUE) { ... } else {
ret_val = pdFALSE;
}else { ... }
break;
case eSetValueWithoutOverwrite:
default:
TX_RESTORE;
return pdFAIL;
break;default
}switch (eAction) { ... }
if(waiting == TX_TRUE) {
*xTaskToNotify->p_notify_val_ret = xTaskToNotify->task_notify_val;
if(xTaskToNotify->clear_on_pend == TX_TRUE) {
xTaskToNotify->task_notify_val &= ~xTaskToNotify->clear_mask;
}if (xTaskToNotify->clear_on_pend == TX_TRUE) { ... } else {
xTaskToNotify->task_notify_val--;
}else { ... }
}if (waiting == TX_TRUE) { ... }
TX_RESTORE;
_tx_thread_system_preempt_check();
return ret_val;
}{ ... }
BaseType_t xTaskNotifyAndQueryFromISR(TaskHandle_t xTaskToNotify,
uint32_t ulValue,
eNotifyAction eAction,
uint32_t *pulPreviousNotifyValue,
BaseType_t *pxHigherPriorityTaskWoken)
{
configASSERT(xTaskToNotify != NULL);
configASSERT(TXFR_NOTIFYACTION_VALID(eAction));
return xTaskNotifyAndQuery(xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue);
}{ ... }
BaseType_t xTaskNotifyStateClear(TaskHandle_t xTask)
{
BaseType_t ret_val;
UINT ret;
TX_THREAD *p_thread;
txfr_task_t *p_task;
TX_INTERRUPT_SAVE_AREA;
if(xTask == NULL) {
p_thread = tx_thread_identify();
p_task = p_thread->txfr_thread_ptr;
}if (xTask == NULL) { ... } else {
p_thread = &xTask->thread;
p_task = xTask;
}else { ... }
TX_DISABLE;
if(p_task->notification_sem.tx_semaphore_suspended_count != 0u) {
ret_val = pdTRUE;
}if (p_task->notification_sem.tx_semaphore_suspended_count != 0u) { ... } else {
ret_val = pdFALSE;
}else { ... }
ret = tx_semaphore_get(&p_task->notification_sem, 0u);
if(ret != TX_SUCCESS) {
TX_RESTORE;
TX_FREERTOS_ASSERT_FAIL();
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
TX_RESTORE;
return ret_val;
}{ ... }
uint32_t ulTaskNotifyValueClear(TaskHandle_t xTask,
uint32_t ulBitsToClear)
{
BaseType_t ret_val;
TX_THREAD *p_thread;
txfr_task_t *p_task;
TX_INTERRUPT_SAVE_AREA;
if(xTask == NULL) {
p_thread = tx_thread_identify();
p_task = p_thread->txfr_thread_ptr;
}if (xTask == NULL) { ... } else {
p_thread = &xTask->thread;
p_task = xTask;
}else { ... }
TX_DISABLE;
ret_val = p_task->task_notify_val;
p_task->task_notify_val &= ~ulBitsToClear;
TX_RESTORE;
return ret_val;
}{ ... }
SemaphoreHandle_t xSemaphoreCreateCounting(UBaseType_t uxMaxCount,
UBaseType_t uxInitialCount)
{
txfr_sem_t *p_sem;
UINT ret;
configASSERT(uxMaxCount != 0u);
configASSERT(uxInitialCount <= uxMaxCount);
#if (TX_FREERTOS_AUTO_INIT == 1)
if(txfr_initialized != 1u) {
tx_freertos_auto_init();
}if (txfr_initialized != 1u) { ... }
/* ... */#endif
p_sem = txfr_malloc(sizeof(txfr_sem_t));
if(p_sem == NULL) {
return NULL;
}if (p_sem == NULL) { ... }
TX_MEMSET(p_sem, 0, sizeof(*p_sem));
p_sem->max_count = uxMaxCount;
p_sem->allocated = 1u;
p_sem->is_mutex = 0u;
ret = tx_semaphore_create(&p_sem->sem, "", uxInitialCount);
if(ret != TX_SUCCESS) {
txfr_free(p_sem);
return NULL;
}if (ret != TX_SUCCESS) { ... }
return p_sem;
}{ ... }
SemaphoreHandle_t xSemaphoreCreateCountingStatic(UBaseType_t uxMaxCount,
UBaseType_t uxInitialCount,
StaticSemaphore_t *pxSemaphoreBuffer)
{
UINT ret;
configASSERT(uxMaxCount != 0u);
configASSERT(uxInitialCount <= uxMaxCount);
configASSERT(pxSemaphoreBuffer != NULL);
#if (TX_FREERTOS_AUTO_INIT == 1)
if(txfr_initialized != 1u) {
tx_freertos_auto_init();
}if (txfr_initialized != 1u) { ... }
/* ... */#endif
TX_MEMSET(pxSemaphoreBuffer, 0, sizeof(*pxSemaphoreBuffer));
pxSemaphoreBuffer->max_count = uxMaxCount;
pxSemaphoreBuffer->allocated = 0u;
pxSemaphoreBuffer->is_mutex = 0u;
ret = tx_semaphore_create(&pxSemaphoreBuffer->sem, "", uxInitialCount);
if(ret != TX_SUCCESS) {
return NULL;
}if (ret != TX_SUCCESS) { ... }
return pxSemaphoreBuffer;
}{ ... }
SemaphoreHandle_t xSemaphoreCreateBinary(void)
{
return xSemaphoreCreateCounting(1u, 0u);
}{ ... }
SemaphoreHandle_t xSemaphoreCreateBinaryStatic(StaticSemaphore_t *pxSemaphoreBuffer)
{
configASSERT(pxSemaphoreBuffer != NULL);
return xSemaphoreCreateCountingStatic(1u, 0u, pxSemaphoreBuffer);
}{ ... }
SemaphoreHandle_t xSemaphoreCreateMutex(void)
{
txfr_sem_t *p_sem;
UINT ret;
#if (TX_FREERTOS_AUTO_INIT == 1)
if(txfr_initialized != 1u) {
tx_freertos_auto_init();
}if (txfr_initialized != 1u) { ... }
/* ... */#endif
p_sem = txfr_malloc(sizeof(txfr_sem_t));
if(p_sem == NULL) {
return NULL;
}if (p_sem == NULL) { ... }
TX_MEMSET(p_sem, 0, sizeof(*p_sem));
p_sem->max_count = 1u;
p_sem->allocated = 1u;
p_sem->is_mutex = 1u;
ret = tx_mutex_create(&p_sem->mutex, "", TX_NO_INHERIT);
if(ret != TX_SUCCESS) {
txfr_free(p_sem);
return NULL;
}if (ret != TX_SUCCESS) { ... }
return p_sem;
}{ ... }
SemaphoreHandle_t xSemaphoreCreateMutexStatic(StaticSemaphore_t *pxMutexBuffer)
{
UINT ret;
configASSERT(pxMutexBuffer != NULL);
TX_MEMSET(pxMutexBuffer, 0, sizeof(*pxMutexBuffer));
pxMutexBuffer->max_count = 1u;
pxMutexBuffer->allocated = 0u;
pxMutexBuffer->is_mutex = 1u;
ret = tx_mutex_create(&pxMutexBuffer->mutex, "", TX_NO_INHERIT);
if(ret != TX_SUCCESS) {
return NULL;
}if (ret != TX_SUCCESS) { ... }
return pxMutexBuffer;
}{ ... }
SemaphoreHandle_t xSemaphoreCreateRecursiveMutex(void)
{
txfr_sem_t *p_sem;
UINT ret;
#if (TX_FREERTOS_AUTO_INIT == 1)
if(txfr_initialized != 1u) {
tx_freertos_auto_init();
}if (txfr_initialized != 1u) { ... }
/* ... */#endif
p_sem = txfr_malloc(sizeof(txfr_sem_t));
if(p_sem == NULL) {
return NULL;
}if (p_sem == NULL) { ... }
TX_MEMSET(p_sem, 0, sizeof(*p_sem));
p_sem->max_count = 1u;
p_sem->allocated = 1u;
p_sem->is_mutex = 1u;
ret = tx_mutex_create(&p_sem->mutex, "", TX_INHERIT);
if(ret != TX_SUCCESS) {
txfr_free(p_sem);
return NULL;
}if (ret != TX_SUCCESS) { ... }
return p_sem;
}{ ... }
SemaphoreHandle_t xSemaphoreCreateRecursiveMutexStatic(StaticSemaphore_t *pxMutexBuffer)
{
UINT ret;
configASSERT(pxMutexBuffer != NULL);
#if (TX_FREERTOS_AUTO_INIT == 1)
if(txfr_initialized != 1u) {
tx_freertos_auto_init();
}if (txfr_initialized != 1u) { ... }
/* ... */#endif
TX_MEMSET(pxMutexBuffer, 0, sizeof(*pxMutexBuffer));
pxMutexBuffer->max_count = 1u;
pxMutexBuffer->allocated = 0u;
pxMutexBuffer->is_mutex = 1u;
ret = tx_mutex_create(&pxMutexBuffer->mutex, "", TX_INHERIT);
if(ret != TX_SUCCESS) {
return NULL;
}if (ret != TX_SUCCESS) { ... }
return pxMutexBuffer;
}{ ... }
void vSemaphoreDelete(SemaphoreHandle_t xSemaphore)
{
UINT ret;
configASSERT(xSemaphore != NULL);
if(xSemaphore->is_mutex == 0u) {
ret = tx_semaphore_delete(&xSemaphore->sem);
}if (xSemaphore->is_mutex == 0u) { ... } else {
ret = tx_mutex_delete(&xSemaphore->mutex);
}else { ... }
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return;
}if (ret != TX_SUCCESS) { ... }
if(xSemaphore->allocated == 1u) {
vPortFree(xSemaphore);
}if (xSemaphore->allocated == 1u) { ... }
}{ ... }
BaseType_t xSemaphoreTake(SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait)
{
UINT timeout;
UINT ret;
configASSERT(xSemaphore != NULL);
if(xTicksToWait == portMAX_DELAY) {
timeout = TX_WAIT_FOREVER;
}if (xTicksToWait == portMAX_DELAY) { ... } else {
timeout = (UINT)xTicksToWait;
}else { ... }
if(xSemaphore->is_mutex == 1u) {
if(xSemaphore->mutex.tx_mutex_owner == tx_thread_identify()) {
return pdFALSE;
}if (xSemaphore->mutex.tx_mutex_owner == tx_thread_identify()) { ... }
ret = tx_mutex_get(&xSemaphore->mutex, timeout);
if(ret != TX_SUCCESS) {
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
}if (xSemaphore->is_mutex == 1u) { ... } else {
ret = tx_semaphore_get(&xSemaphore->sem, timeout);
if(ret != TX_SUCCESS) {
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
}else { ... }
return pdTRUE;
}{ ... }
BaseType_t xSemaphoreTakeFromISR(SemaphoreHandle_t xSemaphore, BaseType_t *pxHigherPriorityTaskWoken)
{
UINT ret;
configASSERT(xSemaphore != NULL);
if(xSemaphore->is_mutex == 1u) {
return pdFALSE;
}if (xSemaphore->is_mutex == 1u) { ... } else {
ret = tx_semaphore_get(&xSemaphore->sem, 0u);
if(ret != TX_SUCCESS) {
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
}else { ... }
return pdTRUE;
}{ ... }
BaseType_t xSemaphoreTakeRecursive(SemaphoreHandle_t xMutex, TickType_t xTicksToWait)
{
UINT timeout;
UINT ret;
configASSERT(xMutex != NULL);
if(xTicksToWait == portMAX_DELAY) {
timeout = TX_WAIT_FOREVER;
}if (xTicksToWait == portMAX_DELAY) { ... } else {
timeout = (UINT)xTicksToWait;
}else { ... }
if(xMutex->is_mutex == 1u) {
ret = tx_mutex_get(&xMutex->mutex, timeout);
if(ret != TX_SUCCESS) {
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
}if (xMutex->is_mutex == 1u) { ... } else {
ret = tx_semaphore_get(&xMutex->sem, timeout);
if(ret != TX_SUCCESS) {
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
}else { ... }
return pdTRUE;
}{ ... }
BaseType_t xSemaphoreGive(SemaphoreHandle_t xSemaphore)
{
TX_INTERRUPT_SAVE_AREA
UINT ret;
configASSERT(xSemaphore != NULL);
if(xSemaphore->is_mutex == 1u) {
ret = tx_mutex_put(&xSemaphore->mutex);
if(ret != TX_SUCCESS) {
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
return pdTRUE;
}if (xSemaphore->is_mutex == 1u) { ... }
TX_DISABLE;
_tx_thread_preempt_disable++;
if(xSemaphore->sem.tx_semaphore_count >= xSemaphore->max_count) {
_tx_thread_preempt_disable--;
TX_RESTORE
return pdFALSE;
}if (xSemaphore->sem.tx_semaphore_count >= xSemaphore->max_count) { ... }
ret = tx_semaphore_put(&xSemaphore->sem);
if(ret != TX_SUCCESS) {
_tx_thread_preempt_disable--;
TX_RESTORE;
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
if(xSemaphore->p_set != NULL) {
ret = tx_queue_send(&xSemaphore->p_set->queue, &xSemaphore, TX_NO_WAIT);
if((ret != TX_SUCCESS) && (ret != TX_QUEUE_FULL)) {
_tx_thread_preempt_disable--;
TX_RESTORE;
TX_FREERTOS_ASSERT_FAIL();
return pdFALSE;
}if ((ret != TX_SUCCESS) && (ret != TX_QUEUE_FULL)) { ... }
}if (xSemaphore->p_set != NULL) { ... }
_tx_thread_preempt_disable--;
TX_RESTORE;
_tx_thread_system_preempt_check();
return pdTRUE;
}{ ... }
BaseType_t xSemaphoreGiveFromISR(SemaphoreHandle_t xSemaphore, BaseType_t *pxHigherPriorityTaskWoken)
{
configASSERT(xSemaphore != NULL);
return xSemaphoreGive(xSemaphore);
}{ ... }
BaseType_t xSemaphoreGiveRecursive(SemaphoreHandle_t xMutex)
{
configASSERT(xMutex != NULL);
return xSemaphoreGive(xMutex);
}{ ... }
UBaseType_t uxSemaphoreGetCount(SemaphoreHandle_t xSemaphore)
{
UINT ret;
ULONG count;
configASSERT(xSemaphore != NULL);
ret = tx_semaphore_info_get(&xSemaphore->sem, NULL, &count, NULL, NULL, NULL);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return 0;
}if (ret != TX_SUCCESS) { ... }
return count;
}{ ... }
TaskHandle_t xSemaphoreGetMutexHolder(SemaphoreHandle_t xMutex)
{
configASSERT(xMutex != NULL);
return xMutex->mutex.tx_mutex_owner->txfr_thread_ptr;
}{ ... }
TaskHandle_t xSemaphoreGetMutexHolderFromISR(SemaphoreHandle_t xMutex)
{
return xSemaphoreGetMutexHolder(xMutex);
}{ ... }
TickType_t xTaskGetTickCount(void)
{
return tx_time_get();
}{ ... }
TickType_t xTaskGetTickCountFromISR(void)
{
return tx_time_get();
}{ ... }
QueueHandle_t xQueueCreateStatic(UBaseType_t uxQueueLength,
UBaseType_t uxItemSize,
uint8_t *pucQueueStorageBuffer,
StaticQueue_t *pxQueueBuffer)
{
UINT ret;
configASSERT(uxQueueLength != 0u);
configASSERT(uxItemSize >= sizeof(UINT));
configASSERT(pucQueueStorageBuffer != NULL);
configASSERT(pxQueueBuffer != NULL);
#if (TX_FREERTOS_AUTO_INIT == 1)
if(txfr_initialized != 1u) {
tx_freertos_auto_init();
}if (txfr_initialized != 1u) { ... }
/* ... */#endif
TX_MEMSET(pucQueueStorageBuffer, 0, uxQueueLength * uxItemSize);
TX_MEMSET(pxQueueBuffer, 0, sizeof(*pxQueueBuffer));
pxQueueBuffer->allocated = 0u;
pxQueueBuffer->p_mem = pucQueueStorageBuffer;
pxQueueBuffer->id = TX_QUEUE_ID;
pxQueueBuffer->p_write = (uint8_t *)pucQueueStorageBuffer;
pxQueueBuffer->p_read = (uint8_t *)pucQueueStorageBuffer;
pxQueueBuffer->msg_size = uxItemSize;
pxQueueBuffer->queue_length = uxQueueLength;
ret = tx_semaphore_create(&pxQueueBuffer->read_sem, "", 0u);
if(ret != TX_SUCCESS) {
return NULL;
}if (ret != TX_SUCCESS) { ... }
ret = tx_semaphore_create(&pxQueueBuffer->write_sem, "", uxQueueLength);
if(ret != TX_SUCCESS) {
return NULL;
}if (ret != TX_SUCCESS) { ... }
return pxQueueBuffer;
}{ ... }
QueueHandle_t xQueueCreate(UBaseType_t uxQueueLength, UBaseType_t uxItemSize)
{
txfr_queue_t *p_queue;
void *p_mem;
size_t mem_size;
UINT ret;
configASSERT(uxQueueLength != 0u);
configASSERT(uxItemSize >= sizeof(UINT));
#if (TX_FREERTOS_AUTO_INIT == 1)
if(txfr_initialized != 1u) {
tx_freertos_auto_init();
}if (txfr_initialized != 1u) { ... }
/* ... */#endif
p_queue = txfr_malloc(sizeof(txfr_queue_t));
if(p_queue == NULL) {
return NULL;
}if (p_queue == NULL) { ... }
mem_size = uxQueueLength*(uxItemSize);
p_mem = txfr_malloc(mem_size);
if(p_mem == NULL) {
txfr_free(p_queue);
return NULL;
}if (p_mem == NULL) { ... }
TX_MEMSET(p_mem, 0, mem_size);
TX_MEMSET(p_queue, 0, sizeof(*p_queue));
p_queue->allocated = 1u;
p_queue->p_mem = p_mem;
p_queue->id = TX_QUEUE_ID;
p_queue->p_write = (uint8_t *)p_mem;
p_queue->p_read = (uint8_t *)p_mem;
p_queue->msg_size = uxItemSize;
p_queue->queue_length = uxQueueLength;
ret = tx_semaphore_create(&p_queue->read_sem, "", 0u);
if(ret != TX_SUCCESS) {
return NULL;
}if (ret != TX_SUCCESS) { ... }
ret = tx_semaphore_create(&p_queue->write_sem, "", uxQueueLength);
if(ret != TX_SUCCESS) {
return NULL;
}if (ret != TX_SUCCESS) { ... }
return p_queue;
}{ ... }
void vQueueDelete(QueueHandle_t xQueue)
{
UINT ret;
configASSERT(xQueue != NULL);
ret = tx_semaphore_delete(&xQueue->read_sem);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
}if (ret != TX_SUCCESS) { ... }
ret = tx_semaphore_delete(&xQueue->write_sem);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
}if (ret != TX_SUCCESS) { ... }
if(xQueue->allocated == 1u) {
vPortFree(xQueue->p_mem);
vPortFree(xQueue);
}if (xQueue->allocated == 1u) { ... }
}{ ... }
BaseType_t xQueueSend(QueueHandle_t xQueue,
const void *pvItemToQueue,
TickType_t xTicksToWait)
{
TX_INTERRUPT_SAVE_AREA;
UINT timeout;
UINT ret;
configASSERT(xQueue != NULL);
configASSERT(pvItemToQueue != NULL);
if(xTicksToWait == portMAX_DELAY) {
timeout = TX_WAIT_FOREVER;
}if (xTicksToWait == portMAX_DELAY) { ... } else {
timeout = (UINT)xTicksToWait;
}else { ... }
ret = tx_semaphore_get(&xQueue->write_sem, timeout);
if(ret != TX_SUCCESS) {
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
TX_DISABLE;
memcpy(xQueue->p_write, pvItemToQueue, xQueue->msg_size);
if(xQueue->p_write >= (xQueue->p_mem + (xQueue->msg_size * (xQueue->queue_length - 1u)))) {
xQueue->p_write = xQueue->p_mem;
}if (xQueue->p_write >= (xQueue->p_mem + (xQueue->msg_size * (xQueue->queue_length - 1u)))) { ... } else {
xQueue->p_write += xQueue->msg_size;
}else { ... }
TX_RESTORE;
ret = tx_semaphore_put(&xQueue->read_sem);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
if(xQueue->p_set != NULL) {
ret = tx_queue_send(&xQueue->p_set->queue, &xQueue, TX_NO_WAIT);
if((ret != TX_SUCCESS) && (ret != TX_QUEUE_FULL)) {
TX_FREERTOS_ASSERT_FAIL();
return pdFALSE;
}if ((ret != TX_SUCCESS) && (ret != TX_QUEUE_FULL)) { ... }
}if (xQueue->p_set != NULL) { ... }
return pdPASS;
}{ ... }
BaseType_t xQueueSendFromISR(QueueHandle_t xQueue,
const void * pvItemToQueue,
BaseType_t *pxHigherPriorityTaskWoken)
{
configASSERT(xQueue != NULL);
configASSERT(pvItemToQueue != NULL);
return xQueueSend(xQueue, pvItemToQueue, 0u);
}{ ... }
BaseType_t xQueueSendToBack(QueueHandle_t xQueue,
const void * pvItemToQueue,
TickType_t xTicksToWait)
{
configASSERT(xQueue != NULL);
configASSERT(pvItemToQueue != NULL);
return xQueueSend(xQueue, pvItemToQueue, xTicksToWait);
}{ ... }
BaseType_t xQueueSendToBackFromISR(QueueHandle_t xQueue,
const void * pvItemToQueue,
BaseType_t *pxHigherPriorityTaskWoken)
{
configASSERT(xQueue != NULL);
configASSERT(pvItemToQueue != NULL);
return xQueueSend(xQueue, pvItemToQueue, 0u);
}{ ... }
BaseType_t xQueueSendToFront(QueueHandle_t xQueue,
const void *pvItemToQueue,
TickType_t xTicksToWait)
{
TX_INTERRUPT_SAVE_AREA;
UINT timeout;
UINT ret;
configASSERT(xQueue != NULL);
configASSERT(pvItemToQueue != NULL);
if(xTicksToWait == portMAX_DELAY) {
timeout = TX_WAIT_FOREVER;
}if (xTicksToWait == portMAX_DELAY) { ... } else {
timeout = (UINT)xTicksToWait;
}else { ... }
if(xQueue->p_set != NULL) {
TX_DISABLE;
_tx_thread_preempt_disable++;
}if (xQueue->p_set != NULL) { ... }
ret = tx_semaphore_get(&xQueue->write_sem, timeout);
if(ret != TX_SUCCESS) {
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
TX_DISABLE;
if(xQueue->p_read == xQueue->p_mem) {
xQueue->p_read = xQueue->p_mem + (xQueue->msg_size * (xQueue->queue_length - 1u));
}if (xQueue->p_read == xQueue->p_mem) { ... } else {
xQueue->p_read -= xQueue->msg_size;
}else { ... }
memcpy(xQueue->p_read, pvItemToQueue, xQueue->msg_size);
TX_RESTORE;
ret = tx_semaphore_put(&xQueue->read_sem);
if(ret != TX_SUCCESS) {
if(xQueue->p_set != NULL) {
_tx_thread_preempt_disable--;
TX_RESTORE;
}if (xQueue->p_set != NULL) { ... }
TX_FREERTOS_ASSERT_FAIL();
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
if(xQueue->p_set != NULL) {
ret = tx_queue_send(&xQueue->p_set->queue, &xQueue, TX_NO_WAIT);
if((ret != TX_SUCCESS) && (ret != TX_QUEUE_FULL)) {
_tx_thread_preempt_disable--;
TX_RESTORE;
TX_FREERTOS_ASSERT_FAIL();
return pdFALSE;
}if ((ret != TX_SUCCESS) && (ret != TX_QUEUE_FULL)) { ... }
TX_RESTORE;
_tx_thread_preempt_disable--;
_tx_thread_system_preempt_check();
}if (xQueue->p_set != NULL) { ... }
return pdPASS;
}{ ... }
BaseType_t xQueueSendToFrontFromISR(QueueHandle_t xQueue,
const void * pvItemToQueue,
BaseType_t *pxHigherPriorityTaskWoken)
{
configASSERT(xQueue != NULL);
configASSERT(pvItemToQueue != NULL);
return xQueueSendToFront(xQueue, pvItemToQueue, 0u);
}{ ... }
BaseType_t xQueueReceive(QueueHandle_t xQueue,
void *pvBuffer,
TickType_t xTicksToWait)
{
TX_INTERRUPT_SAVE_AREA;
UINT timeout;
UINT ret;
configASSERT(xQueue != NULL);
configASSERT(pvBuffer != NULL);
if(xTicksToWait == portMAX_DELAY) {
timeout = TX_WAIT_FOREVER;
}if (xTicksToWait == portMAX_DELAY) { ... } else {
timeout = (UINT)xTicksToWait;
}else { ... }
ret = tx_semaphore_get(&xQueue->read_sem, timeout);
if(ret != TX_SUCCESS) {
return pdFAIL;
}if (ret != TX_SUCCESS) { ... }
TX_DISABLE
memcpy(pvBuffer, xQueue->p_read, xQueue->msg_size);
if(xQueue->p_read >= (xQueue->p_mem + (xQueue->msg_size * (xQueue->queue_length - 1u)))) {
xQueue->p_read = xQueue->p_mem;
}if (xQueue->p_read >= (xQueue->p_mem + (xQueue->msg_size * (xQueue->queue_length - 1u)))) { ... } else {
xQueue->p_read += xQueue->msg_size;
}else { ... }
TX_RESTORE
ret = tx_semaphore_put(&xQueue->write_sem);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
return pdPASS;
}{ ... }
BaseType_t xQueueReceiveFromISR(QueueHandle_t xQueue,
void *pvBuffer,
BaseType_t *pxHigherPriorityTaskWoken)
{
BaseType_t ret;
configASSERT(xQueue != NULL);
configASSERT(pvBuffer != NULL);
ret = xQueueReceive(xQueue, pvBuffer, 0u);
return ret;
}{ ... }
BaseType_t xQueuePeek(QueueHandle_t xQueue,
void *pvBuffer,
TickType_t xTicksToWait)
{
TX_INTERRUPT_SAVE_AREA;
UINT timeout;
UINT ret;
configASSERT(xQueue != NULL);
configASSERT(pvBuffer != NULL);
if(xTicksToWait == portMAX_DELAY) {
timeout = TX_WAIT_FOREVER;
}if (xTicksToWait == portMAX_DELAY) { ... } else {
timeout = (UINT)xTicksToWait;
}else { ... }
ret = tx_semaphore_get(&xQueue->read_sem, timeout);
if(ret != TX_SUCCESS) {
return pdFAIL;
}if (ret != TX_SUCCESS) { ... }
TX_DISABLE;
_tx_thread_preempt_disable++;
memcpy(pvBuffer, xQueue->p_read, xQueue->msg_size);
ret = tx_semaphore_put(&xQueue->read_sem);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
_tx_thread_preempt_disable--;
TX_RESTORE;
return pdPASS;
}{ ... }
BaseType_t xQueuePeekFromISR(QueueHandle_t xQueue,
void *pvBuffer)
{
configASSERT(xQueue != NULL);
configASSERT(pvBuffer != NULL);
return xQueuePeek(xQueue, pvBuffer, 0u);
}{ ... }
UBaseType_t uxQueueMessagesWaiting(QueueHandle_t xQueue)
{
ULONG count;
UINT ret;
configASSERT(xQueue != NULL);
ret = tx_semaphore_info_get(&xQueue->read_sem, NULL, &count, NULL, NULL, NULL);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return 0;
}if (ret != TX_SUCCESS) { ... }
return count;
}{ ... }
UBaseType_t uxQueueMessagesWaitingFromISR(QueueHandle_t xQueue)
{
configASSERT(xQueue != NULL);
return uxQueueMessagesWaiting(xQueue);
}{ ... }
UBaseType_t uxQueueSpacesAvailable(QueueHandle_t xQueue)
{
ULONG count;
UINT ret;
configASSERT(xQueue != NULL);
ret = tx_semaphore_info_get(&xQueue->write_sem, NULL, &count, NULL, NULL, NULL);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return 0;
}if (ret != TX_SUCCESS) { ... }
return count;
}{ ... }
BaseType_t xQueueIsQueueEmptyFromISR(const QueueHandle_t xQueue)
{
ULONG count;
UINT ret;
configASSERT(xQueue != NULL);
ret = tx_semaphore_info_get(&xQueue->read_sem, NULL, &count, NULL, NULL, NULL);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return 0;
}if (ret != TX_SUCCESS) { ... }
if(count == 0u) {
return pdTRUE;
}if (count == 0u) { ... } else {
return pdFALSE;
}else { ... }
}{ ... }
BaseType_t xQueueIsQueueFullFromISR(const QueueHandle_t xQueue)
{
ULONG count;
UINT ret;
configASSERT(xQueue != NULL);
ret = tx_semaphore_info_get(&xQueue->write_sem, NULL, &count, NULL, NULL, NULL);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return 0;
}if (ret != TX_SUCCESS) { ... }
if(count == 0u) {
return pdTRUE;
}if (count == 0u) { ... } else {
return pdFALSE;
}else { ... }
}{ ... }
BaseType_t xQueueReset(QueueHandle_t xQueue)
{
TX_INTERRUPT_SAVE_AREA;
UINT ret;
UINT write_post;
configASSERT(xQueue != NULL);
write_post = 0u;
TX_DISABLE;
_tx_thread_preempt_disable++;
xQueue->p_write = xQueue->p_mem;
xQueue->p_read = xQueue->p_mem;
xQueue->read_sem.tx_semaphore_count = 0u;
if(xQueue->write_sem.tx_semaphore_count != xQueue->queue_length) {
write_post = 1u;
xQueue->write_sem.tx_semaphore_count = xQueue->queue_length - 1u;
}if (xQueue->write_sem.tx_semaphore_count != xQueue->queue_length) { ... }
_tx_thread_preempt_disable--;
TX_RESTORE;
if(write_post == 1u) {
ret = tx_semaphore_put(&xQueue->write_sem);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
}if (write_post == 1u) { ... } else {
_tx_thread_system_preempt_check();
}else { ... }
return pdPASS;
}{ ... }
BaseType_t xQueueOverwrite(QueueHandle_t xQueue,
const void * pvItemToQueue)
{
TX_INTERRUPT_SAVE_AREA;
UINT ret;
UINT read_post;
uint8_t *p_write_temp;
configASSERT(xQueue != NULL);
configASSERT(pvItemToQueue != NULL);
read_post = 0u;
TX_DISABLE;
if(xQueue->read_sem.tx_semaphore_count != 0u) {
p_write_temp = xQueue->p_write;
if(p_write_temp == xQueue->p_mem) {
p_write_temp = (xQueue->p_mem + (xQueue->msg_size * (xQueue->queue_length - 1u)));
}if (p_write_temp == xQueue->p_mem) { ... } else {
p_write_temp -= xQueue->msg_size;
}else { ... }
memcpy(p_write_temp, pvItemToQueue, xQueue->msg_size);
}if (xQueue->read_sem.tx_semaphore_count != 0u) { ... } else {
memcpy(xQueue->p_write, pvItemToQueue, xQueue->msg_size);
if(xQueue->p_write >= (xQueue->p_mem + (xQueue->msg_size * (xQueue->queue_length - 1u)))) {
xQueue->p_write = xQueue->p_mem;
}if (xQueue->p_write >= (xQueue->p_mem + (xQueue->msg_size * (xQueue->queue_length - 1u)))) { ... } else {
xQueue->p_write += xQueue->msg_size;
}else { ... }
read_post = 1u;
}else { ... }
TX_RESTORE;
if(read_post == 1u) {
ret = tx_semaphore_put(&xQueue->read_sem);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
}if (read_post == 1u) { ... }
return pdPASS;
}{ ... }
BaseType_t xQueueOverwriteFromISR(QueueHandle_t xQueue,
const void * pvItemToQueue,
BaseType_t *pxHigherPriorityTaskWoken)
{
configASSERT(xQueue != NULL);
configASSERT(pvItemToQueue != NULL);
return xQueueOverwrite(xQueue, pvItemToQueue);
}{ ... }
EventGroupHandle_t xEventGroupCreate(void)
{
txfr_event_t *p_event;
UINT ret;
#if (TX_FREERTOS_AUTO_INIT == 1)
if(txfr_initialized != 1u) {
tx_freertos_auto_init();
}if (txfr_initialized != 1u) { ... }
/* ... */#endif
p_event = txfr_malloc(sizeof(txfr_event_t));
if(p_event == NULL) {
return NULL;
}if (p_event == NULL) { ... }
TX_MEMSET(p_event, 0, sizeof(*p_event));
p_event->allocated = 1u;
ret = tx_event_flags_create(&p_event->event, "");
if(ret != TX_SUCCESS) {
txfr_free(p_event);
return NULL;
}if (ret != TX_SUCCESS) { ... }
return p_event;
}{ ... }
EventGroupHandle_t xEventGroupCreateStatic(StaticEventGroup_t *pxEventGroupBuffer)
{
UINT ret;
configASSERT(pxEventGroupBuffer != NULL);
#if (TX_FREERTOS_AUTO_INIT == 1)
if(txfr_initialized != 1u) {
tx_freertos_auto_init();
}if (txfr_initialized != 1u) { ... }
/* ... */#endif
TX_MEMSET(pxEventGroupBuffer, 0, sizeof(*pxEventGroupBuffer));
pxEventGroupBuffer->allocated = 0u;
ret = tx_event_flags_create(&pxEventGroupBuffer->event, "");
if(ret != TX_SUCCESS) {
return NULL;
}if (ret != TX_SUCCESS) { ... }
return pxEventGroupBuffer;
}{ ... }
void vEventGroupDelete(EventGroupHandle_t xEventGroup)
{
UINT ret;
configASSERT(xEventGroup != NULL);
ret = tx_event_flags_delete(&xEventGroup->event);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return;
}if (ret != TX_SUCCESS) { ... }
if(xEventGroup->allocated == 1u) {
vPortFree(xEventGroup);
}if (xEventGroup->allocated == 1u) { ... }
}{ ... }
EventBits_t xEventGroupWaitBits(const EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToWaitFor,
const BaseType_t xClearOnExit,
const BaseType_t xWaitForAllBits,
TickType_t xTicksToWait)
{
ULONG bits;
UINT timeout;
UINT ret;
UINT get_option;
configASSERT(xEventGroup != NULL);
if(xTicksToWait == portMAX_DELAY) {
timeout = TX_WAIT_FOREVER;
}if (xTicksToWait == portMAX_DELAY) { ... } else {
timeout = (UINT)xTicksToWait;
}else { ... }
if(xWaitForAllBits == pdFALSE) {
if(xClearOnExit == pdFALSE) {
get_option = TX_OR;
}if (xClearOnExit == pdFALSE) { ... } else {
get_option = TX_OR_CLEAR;
}else { ... }
}if (xWaitForAllBits == pdFALSE) { ... } else {
if(xClearOnExit == pdFALSE) {
get_option = TX_AND;
}if (xClearOnExit == pdFALSE) { ... } else {
get_option = TX_AND_CLEAR;
}else { ... }
}else { ... }
ret = tx_event_flags_get(&xEventGroup->event, uxBitsToWaitFor, get_option, &bits, timeout);
if(ret != TX_SUCCESS) {
return 0;
}if (ret != TX_SUCCESS) { ... }
return bits;
}{ ... }
EventBits_t xEventGroupSetBits(EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToSet)
{
UINT ret;
ULONG bits;
configASSERT(xEventGroup != NULL);
ret = tx_event_flags_set(&xEventGroup->event, uxBitsToSet, TX_OR);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return 0u;
}if (ret != TX_SUCCESS) { ... }
ret = tx_event_flags_info_get(&xEventGroup->event, NULL, &bits, NULL, NULL, NULL);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return 0u;
}if (ret != TX_SUCCESS) { ... }
return bits;
}{ ... }
BaseType_t xEventGroupSetBitsFromISR(EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToSet,
BaseType_t *pxHigherPriorityTaskWoken)
{
configASSERT(xEventGroup != NULL);
return xEventGroupSetBits(xEventGroup, uxBitsToSet);
}{ ... }
EventBits_t xEventGroupClearBits(EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToClear)
{
UINT ret;
ULONG bits;
ULONG bits_before;
TX_INTERRUPT_SAVE_AREA;
configASSERT(xEventGroup != NULL);
TX_DISABLE;
ret = tx_event_flags_info_get(&xEventGroup->event, NULL, &bits_before, NULL, NULL, NULL);
if(ret != TX_SUCCESS) {
TX_RESTORE;
TX_FREERTOS_ASSERT_FAIL();
return 0u;
}if (ret != TX_SUCCESS) { ... }
bits = uxBitsToClear;
ret = tx_event_flags_set(&xEventGroup->event, ~bits, TX_AND);
if(ret != TX_SUCCESS) {
TX_RESTORE;
TX_FREERTOS_ASSERT_FAIL();
return 0u;
}if (ret != TX_SUCCESS) { ... }
TX_RESTORE;
return bits_before;
}{ ... }
BaseType_t xEventGroupClearBitsFromISR(EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToClear)
{
configASSERT(xEventGroup != NULL);
return xEventGroupClearBits(xEventGroup, uxBitsToClear);
}{ ... }
EventBits_t xEventGroupGetBits(EventGroupHandle_t xEventGroup)
{
UINT ret;
ULONG bits;
configASSERT(xEventGroup != NULL);
ret = tx_event_flags_info_get(&xEventGroup->event, NULL, &bits, NULL, NULL, NULL);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return 0u;
}if (ret != TX_SUCCESS) { ... }
return bits;
}{ ... }
EventBits_t xEventGroupGetBitsFromISR(EventGroupHandle_t xEventGroup)
{
configASSERT(xEventGroup != NULL);
return xEventGroupGetBits(xEventGroup);
}{ ... }
void txfr_timer_callback_wrapper(ULONG id)
{
txfr_timer_t *p_timer;
p_timer = (txfr_timer_t *)id;
if(p_timer == NULL) {
TX_FREERTOS_ASSERT_FAIL();
}if (p_timer == NULL) { ... }
p_timer->callback(p_timer);
}{ ... }
TimerHandle_t xTimerCreate(const char * const pcTimerName,
const TickType_t xTimerPeriod,
const UBaseType_t uxAutoReload,
void * const pvTimerID,
TimerCallbackFunction_t pxCallbackFunction)
{
txfr_timer_t *p_timer;
UINT ret;
ULONG resch_ticks;
configASSERT(xTimerPeriod != 0u);
configASSERT(pxCallbackFunction != NULL);
#if (TX_FREERTOS_AUTO_INIT == 1)
if(txfr_initialized != 1u) {
tx_freertos_auto_init();
}if (txfr_initialized != 1u) { ... }
/* ... */#endif
p_timer = txfr_malloc(sizeof(txfr_timer_t));
if(p_timer == NULL) {
return NULL;
}if (p_timer == NULL) { ... }
TX_MEMSET(p_timer, 0, sizeof(*p_timer));
p_timer->allocated = 1u;
p_timer->period = xTimerPeriod;
p_timer->id = pvTimerID;
p_timer->callback = pxCallbackFunction;
if(uxAutoReload != pdFALSE) {
resch_ticks = xTimerPeriod;
p_timer->one_shot = 1u;
}if (uxAutoReload != pdFALSE) { ... } else {
p_timer->one_shot = 0u;
resch_ticks = 0u;
}else { ... }
ret = tx_timer_create(&p_timer->timer, (char *)pcTimerName, txfr_timer_callback_wrapper, (ULONG)p_timer, xTimerPeriod, resch_ticks, TX_NO_ACTIVATE);
if(ret != TX_SUCCESS) {
txfr_free(p_timer);
return NULL;
}if (ret != TX_SUCCESS) { ... }
return p_timer;
}{ ... }
TimerHandle_t xTimerCreateStatic(const char * const pcTimerName,
const TickType_t xTimerPeriod,
const UBaseType_t uxAutoReload,
void * const pvTimerID,
TimerCallbackFunction_t pxCallbackFunction,
StaticTimer_t *pxTimerBuffer)
{
UINT ret;
ULONG resch_ticks;
configASSERT(xTimerPeriod != 0u);
configASSERT(pxCallbackFunction != NULL);
configASSERT(pxTimerBuffer != NULL);
#if (TX_FREERTOS_AUTO_INIT == 1)
if(txfr_initialized != 1u) {
tx_freertos_auto_init();
}if (txfr_initialized != 1u) { ... }
/* ... */#endif
TX_MEMSET(pxTimerBuffer, 0, sizeof(*pxTimerBuffer));
pxTimerBuffer->allocated = 0u;
pxTimerBuffer->period = xTimerPeriod;
pxTimerBuffer->id = pvTimerID;
pxTimerBuffer->callback = pxCallbackFunction;
if(uxAutoReload != pdFALSE) {
resch_ticks = xTimerPeriod;
}if (uxAutoReload != pdFALSE) { ... } else {
resch_ticks = 0u;
}else { ... }
ret = tx_timer_create(&pxTimerBuffer->timer, (char *)pcTimerName, txfr_timer_callback_wrapper, (ULONG)pxTimerBuffer, xTimerPeriod, resch_ticks, TX_NO_ACTIVATE);
if(ret != TX_SUCCESS) {
return NULL;
}if (ret != TX_SUCCESS) { ... }
return pxTimerBuffer;
}{ ... }
BaseType_t xTimerDelete(TimerHandle_t xTimer, TickType_t xBlockTime)
{
UINT ret;
configASSERT(xTimer != NULL);
ret = tx_timer_delete(&xTimer->timer);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return pdFAIL;
}if (ret != TX_SUCCESS) { ... }
if(xTimer->allocated == 1u) {
vPortFree(xTimer);
}if (xTimer->allocated == 1u) { ... }
return pdPASS;
}{ ... }
BaseType_t xTimerIsTimerActive(TimerHandle_t xTimer)
{
UINT ret;
UINT is_active;
configASSERT(xTimer != NULL);
ret = tx_timer_info_get(&xTimer->timer, NULL, &is_active, NULL, NULL, NULL);
if(ret != TX_SUCCESS) {
return pdFALSE;
}if (ret != TX_SUCCESS) { ... }
if(is_active == TX_TRUE) {
return pdTRUE;
}if (is_active == TX_TRUE) { ... } else {
return pdFALSE;
}else { ... }
}{ ... }
BaseType_t xTimerStart(TimerHandle_t xTimer,
TickType_t xBlockTime)
{
UINT ret;
configASSERT(xTimer != NULL);
ret = tx_timer_activate(&xTimer->timer);
if(ret != TX_SUCCESS) {
return pdFAIL;
}if (ret != TX_SUCCESS) { ... }
return pdPASS;
}{ ... }
BaseType_t xTimerStop(TimerHandle_t xTimer,
TickType_t xBlockTime)
{
UINT ret;
configASSERT(xTimer != NULL);
ret = tx_timer_deactivate(&xTimer->timer);
if(ret != TX_SUCCESS) {
return pdFAIL;
}if (ret != TX_SUCCESS) { ... }
return pdPASS;
}{ ... }
BaseType_t xTimerChangePeriod(TimerHandle_t xTimer,
TickType_t xNewPeriod,
TickType_t xBlockTime)
{
UINT ret;
TX_INTERRUPT_SAVE_AREA;
configASSERT(xTimer != NULL);
configASSERT(xNewPeriod != 0u);
TX_DISABLE;
ret = tx_timer_deactivate(&xTimer->timer);
if(ret != TX_SUCCESS) {
TX_RESTORE;
return pdFAIL;
}if (ret != TX_SUCCESS) { ... }
if(xTimer->one_shot != 0u) {
ret = tx_timer_change(&xTimer->timer, xNewPeriod, xNewPeriod);
}if (xTimer->one_shot != 0u) { ... } else {
ret = tx_timer_change(&xTimer->timer, xNewPeriod, 0u);
}else { ... }
if(ret != TX_SUCCESS) {
TX_RESTORE;
return pdFAIL;
}if (ret != TX_SUCCESS) { ... }
ret = tx_timer_activate(&xTimer->timer);
if(ret != TX_SUCCESS) {
TX_RESTORE;
return pdFAIL;
}if (ret != TX_SUCCESS) { ... }
TX_RESTORE;
return pdPASS;
}{ ... }
BaseType_t xTimerReset(TimerHandle_t xTimer,
TickType_t xBlockTime)
{
UINT ret;
TX_INTERRUPT_SAVE_AREA;
configASSERT(xTimer != NULL);
TX_DISABLE;
ret = tx_timer_deactivate(&xTimer->timer);
if(ret != TX_SUCCESS) {
TX_RESTORE;
return pdFAIL;
}if (ret != TX_SUCCESS) { ... }
if(xTimer->one_shot != 0u) {
ret = tx_timer_change(&xTimer->timer, xTimer->period, xTimer->period);
}if (xTimer->one_shot != 0u) { ... } else {
ret = tx_timer_change(&xTimer->timer, xTimer->period, 0u);
}else { ... }
if(ret != TX_SUCCESS) {
TX_RESTORE;
return pdFAIL;
}if (ret != TX_SUCCESS) { ... }
ret = tx_timer_activate(&xTimer->timer);
if(ret != TX_SUCCESS) {
TX_RESTORE;
return pdFAIL;
}if (ret != TX_SUCCESS) { ... }
TX_RESTORE;
return pdPASS;
}{ ... }
BaseType_t xTimerStartFromISR(TimerHandle_t xTimer,
BaseType_t *pxHigherPriorityTaskWoken)
{
configASSERT(xTimer != NULL);
return xTimerStart(xTimer, 0u);
}{ ... }
BaseType_t xTimerStopFromISR(TimerHandle_t xTimer,
BaseType_t *pxHigherPriorityTaskWoken)
{
configASSERT(xTimer != NULL);
return xTimerStop(xTimer, 0u);
}{ ... }
BaseType_t xTimerChangePeriodFromISR(TimerHandle_t xTimer,
TickType_t xNewPeriod,
BaseType_t *pxHigherPriorityTaskWoken)
{
configASSERT(xTimer != NULL);
configASSERT(xNewPeriod != 0u);
return xTimerChangePeriod(xTimer, xNewPeriod, 0u);
}{ ... }
BaseType_t xTimerResetFromISR(TimerHandle_t xTimer,
BaseType_t *pxHigherPriorityTaskWoken)
{
configASSERT(xTimer != NULL);
return xTimerReset(xTimer, 0u);
}{ ... }
void *pvTimerGetTimerID(TimerHandle_t xTimer)
{
TX_INTERRUPT_SAVE_AREA;
void *p_id;
configASSERT(xTimer != NULL);
TX_DISABLE;
p_id = xTimer->id;
TX_RESTORE;
return p_id;
}{ ... }
void vTimerSetTimerID(TimerHandle_t xTimer, void *pvNewID)
{
TX_INTERRUPT_SAVE_AREA;
configASSERT(xTimer != NULL);
TX_DISABLE;
xTimer->id = pvNewID;
TX_RESTORE;
return;
}{ ... }
void vTimerSetReloadMode(TimerHandle_t xTimer,
const UBaseType_t uxAutoReload)
{
UINT ret;
TX_INTERRUPT_SAVE_AREA;
ULONG left;
configASSERT(xTimer != NULL);
TX_DISABLE;
ret = tx_timer_deactivate(&xTimer->timer);
if(ret != TX_SUCCESS) {
TX_RESTORE;
return;
}if (ret != TX_SUCCESS) { ... }
left = xTimer->timer.tx_timer_internal.tx_timer_internal_remaining_ticks;
if(uxAutoReload != pdFALSE) {
ret = tx_timer_change(&xTimer->timer, left, xTimer->period);
}if (uxAutoReload != pdFALSE) { ... } else {
ret = tx_timer_change(&xTimer->timer, left, 0u);
}else { ... }
if(ret != TX_SUCCESS) {
TX_RESTORE;
return;
}if (ret != TX_SUCCESS) { ... }
ret = tx_timer_activate(&xTimer->timer);
if(ret != TX_SUCCESS) {
TX_RESTORE;
return;
}if (ret != TX_SUCCESS) { ... }
TX_RESTORE;
return;
}{ ... }
const char * pcTimerGetName(TimerHandle_t xTimer)
{
configASSERT(xTimer != NULL);
return (const char *)xTimer->timer.tx_timer_name;
}{ ... }
TickType_t xTimerGetPeriod(TimerHandle_t xTimer)
{
TX_INTERRUPT_SAVE_AREA;
TickType_t period;
configASSERT(xTimer != NULL);
TX_DISABLE;
period = xTimer->period;
TX_RESTORE;
return period;
}{ ... }
TickType_t xTimerGetExpiryTime(TimerHandle_t xTimer)
{
TX_INTERRUPT_SAVE_AREA;
ULONG time_tx;
TickType_t time;
UINT ret;
configASSERT(xTimer != NULL);
TX_DISABLE;
ret = tx_timer_info_get(&xTimer->timer, NULL, NULL, &time_tx, NULL, NULL);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return 0u;
}if (ret != TX_SUCCESS) { ... }
time = (TickType_t)(tx_time_get() + time_tx);
TX_RESTORE;
return time;
}{ ... }
UBaseType_t uxTimerGetReloadMode(TimerHandle_t xTimer)
{
TX_INTERRUPT_SAVE_AREA;
UBaseType_t type;
configASSERT(xTimer != NULL);
TX_DISABLE;
if(xTimer->one_shot == 0u) {
type = pdTRUE;
}if (xTimer->one_shot == 0u) { ... } else {
type = pdFALSE;
}else { ... }
TX_RESTORE;
return type;
}{ ... }
QueueSetHandle_t xQueueCreateSet(const UBaseType_t uxEventQueueLength)
{
txfr_queueset_t *p_set;
void *p_mem;
ULONG queue_size;
UINT ret;
configASSERT(uxEventQueueLength != 0u);
#if (TX_FREERTOS_AUTO_INIT == 1)
if(txfr_initialized != 1u) {
tx_freertos_auto_init();
}if (txfr_initialized != 1u) { ... }
/* ... */#endif
p_set = txfr_malloc(sizeof(txfr_queueset_t));
if(p_set == NULL) {
return NULL;
}if (p_set == NULL) { ... }
queue_size = sizeof(void *) * uxEventQueueLength;
p_mem = txfr_malloc(queue_size);
if(p_mem == NULL) {
txfr_free(p_set);
return NULL;
}if (p_mem == NULL) { ... }
ret = tx_queue_create(&p_set->queue, "", sizeof(void *) / sizeof(UINT), p_mem, queue_size);
if(ret != TX_SUCCESS) {
TX_FREERTOS_ASSERT_FAIL();
return NULL;
}if (ret != TX_SUCCESS) { ... }
return p_set;
}{ ... }
BaseType_t xQueueAddToSet(QueueSetMemberHandle_t xQueueOrSemaphore,
QueueSetHandle_t xQueueSet)
{
txfr_sem_t *p_sem;
txfr_queue_t *p_queue;
TX_INTERRUPT_SAVE_AREA;
configASSERT(xQueueOrSemaphore != NULL);
configASSERT(xQueueSet != NULL);
TX_DISABLE;
if(*((ULONG *)(xQueueOrSemaphore)) == TX_SEMAPHORE_ID) {
p_sem = (txfr_sem_t *)xQueueOrSemaphore;
if(p_sem->p_set != NULL) {
TX_RESTORE;
return pdFAIL;
}if (p_sem->p_set != NULL) { ... }
p_sem->p_set = xQueueSet;
}if (*((ULONG *)(xQueueOrSemaphore)) == TX_SEMAPHORE_ID) { ... } else if(*((ULONG *)(xQueueOrSemaphore)) == TX_QUEUE_ID) {
p_queue = (txfr_queue_t *)xQueueOrSemaphore;
if(p_queue->p_set != NULL) {
TX_RESTORE;
return pdFAIL;
}if (p_queue->p_set != NULL) { ... }
p_queue->p_set = xQueueSet;
}else if (*((ULONG *)(xQueueOrSemaphore)) == TX_QUEUE_ID) { ... } else {
TX_RESTORE;
configASSERT(0u);
return pdFAIL;
}else { ... }
TX_RESTORE;
return pdPASS;
}{ ... }
BaseType_t xQueueRemoveFromSet(QueueSetMemberHandle_t xQueueOrSemaphore,
QueueSetHandle_t xQueueSet)
{
txfr_sem_t *p_sem;
txfr_queue_t *p_queue;
TX_INTERRUPT_SAVE_AREA;
configASSERT(xQueueOrSemaphore != NULL);
configASSERT(xQueueSet != NULL);
TX_DISABLE;
if(*((ULONG *)(xQueueOrSemaphore)) == TX_SEMAPHORE_ID) {
p_sem = (txfr_sem_t *)xQueueOrSemaphore;
if(p_sem->p_set != xQueueSet) {
TX_RESTORE;
return pdFAIL;
}if (p_sem->p_set != xQueueSet) { ... } else {
p_sem->p_set = NULL;
}else { ... }
}if (*((ULONG *)(xQueueOrSemaphore)) == TX_SEMAPHORE_ID) { ... } else if(*((ULONG *)(xQueueOrSemaphore)) == TX_QUEUE_ID) {
p_queue = (txfr_queue_t *)xQueueOrSemaphore;
if(p_queue->p_set != xQueueSet) {
TX_RESTORE;
return pdFAIL;
}if (p_queue->p_set != xQueueSet) { ... } else {
p_queue->p_set = NULL;
}else { ... }
}else if (*((ULONG *)(xQueueOrSemaphore)) == TX_QUEUE_ID) { ... } else {
TX_RESTORE;
configASSERT(0u);
return pdFAIL;
}else { ... }
TX_RESTORE;
return pdPASS;
}{ ... }
QueueSetMemberHandle_t xQueueSelectFromSet(QueueSetHandle_t xQueueSet,
const TickType_t xTicksToWait)
{
void *p_ptr;
UINT ret;
UINT timeout;
configASSERT(xQueueSet != NULL);
if(xTicksToWait == portMAX_DELAY) {
timeout = TX_WAIT_FOREVER;
}if (xTicksToWait == portMAX_DELAY) { ... } else {
timeout = (UINT)xTicksToWait;
}else { ... }
ret = tx_queue_receive(&xQueueSet->queue, &p_ptr, timeout);
if(ret != TX_SUCCESS) {
return NULL;
}if (ret != TX_SUCCESS) { ... }
return p_ptr;
}{ ... }
QueueSetMemberHandle_t xQueueSelectFromSetFromISR(QueueSetHandle_t xQueueSet)
{
return xQueueSelectFromSet(xQueueSet, 0u);
}{ ... }