task.h
1 /*
2  * Copyright (C) 2019 Gunar Schorcht
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  *
8  * FreeRTOS to RIOT-OS adaption module for source code compatibility
9  */
10 
11 #ifndef FREERTOS_TASK_H
12 #define FREERTOS_TASK_H
13 
14 #ifndef DOXYGEN
15 
16 #include <limits.h> /* for INT_MAX */
17 
18 #include "thread.h"
19 #include "freertos/FreeRTOS.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #define xTaskHandle TaskHandle_t
26 #define tskNO_AFFINITY INT_MAX
27 
28 #define taskDISABLE_INTERRUPTS portDISABLE_INTERRUPTS
29 #define taskENABLE_INTERRUPTS portENABLE_INTERRUPTS
30 
31 #define taskENTER_CRITICAL portENTER_CRITICAL
32 #define taskEXIT_CRITICAL portEXIT_CRITICAL
33 
34 #define taskSCHEDULER_NOT_STARTED 1
35 #define taskSCHEDULER_RUNNING 2
36 
37 typedef enum {
38  eNoAction = 0,
39  eSetBits,
40  eIncrement,
41  eSetValueWithOverwrite,
42  eSetValueWithoutOverwrite,
43 } eNotifyAction;
44 
45 typedef void (*TaskFunction_t)(void *);
46 typedef void (*TlsDeleteCallbackFunction_t)( int, void * );
47 
48 typedef void* TaskHandle_t;
49 
50 BaseType_t xTaskCreate(TaskFunction_t pvTaskCode,
51  const char * const pcName,
52  const uint32_t usStackDepth,
53  void * const pvParameters,
54  UBaseType_t uxPriority,
55  TaskHandle_t * const pvCreatedTask);
56 
57 BaseType_t xTaskCreatePinnedToCore(TaskFunction_t pvTaskCode,
58  const char * const pcName,
59  const uint32_t usStackDepth,
60  void * const pvParameters,
61  UBaseType_t uxPriority,
62  TaskHandle_t * const pvCreatedTask,
63  const BaseType_t xCoreID);
64 
65 void vTaskDelete(TaskHandle_t xTaskToDelete);
66 void vTaskSuspend(TaskHandle_t xTaskToSuspend);
67 void vTaskResume(TaskHandle_t xTaskToResume);
68 void vTaskDelay(const TickType_t xTicksToDelay);
69 void vTaskSuspendAll(void);
70 
71 TaskHandle_t xTaskGetCurrentTaskHandle(void);
72 
73 const char *pcTaskGetTaskName(TaskHandle_t xTaskToQuery);
74 
75 UBaseType_t uxTaskGetStackHighWaterMark(TaskHandle_t xTask);
76 
77 void *pvTaskGetThreadLocalStoragePointer(TaskHandle_t xTaskToQuery,
78  BaseType_t xIndex);
79 void vTaskSetThreadLocalStoragePointerAndDelCallback(TaskHandle_t xTaskToSet,
80  BaseType_t xIndex,
81  void *pvValue,
82  TlsDeleteCallbackFunction_t pvDelCallback);
83 
84 void vTaskEnterCritical(portMUX_TYPE *mux);
85 void vTaskExitCritical(portMUX_TYPE *mux);
86 
87 TickType_t xTaskGetTickCount(void);
88 
89 BaseType_t xTaskNotify(TaskHandle_t xTaskToNotify, uint32_t ulValue,
90  eNotifyAction eAction);
91 BaseType_t xTaskNotifyWait(uint32_t ulBitsToClearOnEntry,
92  uint32_t ulBitsToClearOnExit,
93  uint32_t *pulNotificationValue,
94  TickType_t xTicksToWait);
95 
96 BaseType_t xTaskNotifyGive(TaskHandle_t xTaskToNotify);
97 void vTaskNotifyGiveFromISR(TaskHandle_t xTaskToNotify,
98  BaseType_t *pxHigherPriorityTaskWoken);
99 uint32_t ulTaskNotifyTake(BaseType_t xClearCountOnExit,
100  TickType_t xTicksToWait);
101 
102 #ifdef __cplusplus
103 }
104 #endif
105 
106 #endif /* DOXYGEN */
107 #endif /* FREERTOS_TASK_H */