58 #include "HL_sys_core.h"
76 if (OS_ENABLE_CACHE ==
true) {
82 vTaskStartScheduler();
88 StaticTask_t **ppxIdleTaskTCBBuffer,
89 StackType_t **ppxIdleTaskStackBuffer,
90 uint32_t *pulIdleTaskStackSize) {
92 static StaticTask_t os_idleTask = {0};
94 static StackType_t os_stackSizeIdle[OS_IDLE_TASK_STACK_SIZE] = {0};
98 *ppxIdleTaskTCBBuffer = &os_idleTask;
99 *ppxIdleTaskStackBuffer = &os_stackSizeIdle[0];
100 *pulIdleTaskStackSize = OS_IDLE_TASK_STACK_SIZE;
103 #if (configUSE_TIMERS > 0) && (configSUPPORT_STATIC_ALLOCATION == 1)
104 void vApplicationGetTimerTaskMemory(
105 StaticTask_t **ppxTimerTaskTCBBuffer,
106 StackType_t **ppxTimerTaskStackBuffer,
107 uint32_t *pulTimerTaskStackSize) {
108 #if (configUSE_TIMERS > 0) && (configSUPPORT_STATIC_ALLOCATION == 1)
110 static StaticTask_t os_timerTask;
113 #if (configUSE_TIMERS > 0) && (configSUPPORT_STATIC_ALLOCATION == 1)
115 static StackType_t os_stackSizeTimer[OS_TIMER_TASK_STACK_SIZE];
117 *ppxTimerTaskTCBBuffer = &os_timerTask;
118 *ppxTimerTaskStackBuffer = &os_stackSizeTimer[0];
119 *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
127 #if (configCHECK_FOR_STACK_OVERFLOW > 0)
129 void vApplicationStackOverflowHook(TaskHandle_t xTask,
char *pcTaskName) {
135 taskENTER_CRITICAL();
143 return xTaskGetTickCount();
149 uint32_t ticks = (milliseconds / OS_TICK_RATE_MS);
150 if ((uint32_t)ticks < 1u) {
153 vTaskDelayUntil((TickType_t *)pPreviousWakeTime, (TickType_t)ticks);
168 BaseType_t xNotificationReceived = xTaskNotifyWait(UINT32_MAX, UINT32_MAX, pNotifiedValue, timeout);
170 if (xNotificationReceived == pdTRUE) {
173 return notificationReceived;
181 BaseType_t xHigherPriorityTaskWoken = pdFALSE;
183 BaseType_t xNotification =
184 xTaskNotifyFromISR(taskToNotify, notifiedValue, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
185 if (xNotification == pdTRUE) {
190 portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
195 uint32_t indexToWaitOn,
196 uint32_t *pNotifiedValue,
205 BaseType_t xNotificationReceived =
206 xTaskNotifyWaitIndexed(indexToWaitOn, UINT32_MAX, UINT32_MAX, pNotifiedValue, timeout);
208 if (xNotificationReceived == pdTRUE) {
211 return notificationReceived;
215 TaskHandle_t taskToNotify,
216 uint32_t indexToNotify,
217 uint32_t notifiedValue) {
222 BaseType_t xHigherPriorityTaskWoken = pdFALSE;
224 BaseType_t xNotification = xTaskNotifyIndexedFromISR(
225 taskToNotify, indexToNotify, notifiedValue, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
226 if (xNotification == pdTRUE) {
231 portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
240 BaseType_t xNotificationWasPending = xTaskNotifyStateClearIndexed(
NULL, indexToClear);
242 if (xNotificationWasPending == pdTRUE) {
245 return notificationWasPending;
253 BaseType_t xQueueReceiveSuccess = xQueueReceive(xQueue, pvBuffer, (TickType_t)ticksToWait);
255 if (xQueueReceiveSuccess == pdTRUE) {
258 return queueReceiveSuccessfully;
265 BaseType_t xQueueSendSuccess = xQueueSendToBack(xQueue, pvItemToQueue, (TickType_t)ticksToWait);
267 if (xQueueSendSuccess == pdTRUE) {
270 return queueSendSuccessfully;
275 const void *
const pvItemToQueue,
276 long *
const pxHigherPriorityTaskWoken) {
280 BaseType_t xQueueSendSuccess =
281 xQueueSendToBackFromISR(xQueue, pvItemToQueue, (BaseType_t *)pxHigherPriorityTaskWoken);
283 if (xQueueSendSuccess == pdTRUE) {
286 return queueSendSuccessfully;
290 long numberOfMessages = uxQueueMessagesWaiting(xQueue);
291 return (uint32_t)numberOfMessages;
295 #ifdef UNITY_UNIT_TEST
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
#define NULL
NULL definition.
#define NULL_PTR
Null pointer.
Header of task driver implementation.
void FTSK_RunUserCodeIdle(void)
Idle task.
Declaration of the OS wrapper interface.
OS_STD_RETURN_e OS_NotifyFromIsr(TaskHandle_t taskToNotify, uint32_t notifiedValue)
Notify a task.
OS_STD_RETURN_e OS_WaitForNotification(uint32_t *pNotifiedValue, uint32_t timeout)
Wait for a notification.
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize)
OS_STD_RETURN_e OS_ClearNotificationIndexed(uint32_t indexToClear)
Clear pending notification of a task, with index.
OS_STD_RETURN_e OS_ReceiveFromQueue(OS_QUEUE xQueue, void *const pvBuffer, uint32_t ticksToWait)
Receive an item from a queue.
void OS_StartScheduler(void)
Starts the operating system scheduler.
void OS_DelayTaskUntil(uint32_t *pPreviousWakeTime, uint32_t milliseconds)
Delay a task until a specified time.
OS_STD_RETURN_e OS_SendToBackOfQueueFromIsr(OS_QUEUE xQueue, const void *const pvItemToQueue, long *const pxHigherPriorityTaskWoken)
Post an item to the back the provided queue during an ISR.
void OS_MarkTaskAsRequiringFpuContext(void)
Marks the current task as requiring FPU context.
uint32_t OS_GetNumberOfStoredMessagesInQueue(OS_QUEUE xQueue)
Check if messages are waiting for queue.
OS_STD_RETURN_e OS_WaitForNotificationIndexed(uint32_t indexToWaitOn, uint32_t *pNotifiedValue, uint32_t timeout)
Wait for a notification, with index.
OS_STD_RETURN_e OS_NotifyIndexedFromIsr(TaskHandle_t taskToNotify, uint32_t indexToNotify, uint32_t notifiedValue)
Notify a task, with index.
void OS_ExitTaskCritical(void)
Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
void vApplicationIdleHook(void)
Hook function for the idle task.
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
OS_STD_RETURN_e OS_SendToBackOfQueue(OS_QUEUE xQueue, const void *const pvItemToQueue, uint32_t ticksToWait)
Post an item to the back the provided queue.
void OS_InitializeScheduler(void)
Initialization function for the scheduler.
uint32_t OS_GetTickCount(void)
Returns OS based system tick value.