25 static TickType_t OSAL_FreeRTOS_convert_time_to_tick(uint32_t milliseconds);
43 return OSAL_WRONG_ARGS;
46 int32_t stack_size = (int)stack;
48 if(xTaskCreate((TaskFunction_t)entry_point, (
char const*) name,
49 (stack_size/(
sizeof( portSTACK_TYPE ))),
51 (
unsigned portBASE_TYPE) priority,
52 (TaskHandle_t*) handle) != pdPASS)
71 return OSAL_WRONG_ARGS;
74 vTaskDelete((TaskHandle_t)*handle);
90 return OSAL_WRONG_ARGS;
94 *handle = xQueueCreate(size,
sizeof(
void*));
114 return OSAL_WRONG_ARGS;
117 vQueueDelete(*handle);
131 if(xQueueSend(*handle, &msg, 0) != pdTRUE)
152 return OSAL_WRONG_ARGS;
155 TickType_t timeout_in_tick = OSAL_FreeRTOS_convert_time_to_tick(timeout);
156 if(xQueueReceive((QueueHandle_t)*handle, msg, timeout_in_tick) != pdTRUE)
177 return OSAL_WRONG_ARGS;
180 *handle = (OSAL_binary_semaphore_handle_t)xSemaphoreCreateCounting(max_count, initial_count);
181 if((*handle) == NULL)
199 return OSAL_WRONG_ARGS;
202 vSemaphoreDelete((SemaphoreHandle_t)*handle);
220 return OSAL_WRONG_ARGS;
223 TickType_t timeout_in_tick = OSAL_FreeRTOS_convert_time_to_tick(timeout);
224 if(xSemaphoreTake((SemaphoreHandle_t)*handle, timeout_in_tick) != pdTRUE)
243 return OSAL_WRONG_ARGS;
246 if(xSemaphoreGive((SemaphoreHandle_t)*handle) != pdTRUE)
266 return OSAL_WRONG_ARGS;
269 *handle = (OSAL_binary_semaphore_handle_t)xSemaphoreCreateBinary();
270 if((*handle) == NULL)
288 return OSAL_WRONG_ARGS;
291 vSemaphoreDelete((SemaphoreHandle_t)*handle);
309 return OSAL_WRONG_ARGS;
312 TickType_t timeout_in_tick = OSAL_FreeRTOS_convert_time_to_tick(timeout);
313 if(xSemaphoreTake((SemaphoreHandle_t)*handle, timeout_in_tick) != pdTRUE)
332 return OSAL_WRONG_ARGS;
335 if(xSemaphoreGive((SemaphoreHandle_t)*handle) != pdTRUE)
354 return OSAL_WRONG_ARGS;
357 *handle = (OSAL_mutex_handle_t)xSemaphoreCreateMutex();
358 if((*handle) == NULL)
376 return OSAL_WRONG_ARGS;
379 vSemaphoreDelete((SemaphoreHandle_t)*handle);
395 return OSAL_WRONG_ARGS;
398 TickType_t timeout_in_tick = OSAL_FreeRTOS_convert_time_to_tick(timeout);
399 if(xSemaphoreTake((SemaphoreHandle_t)*handle, timeout_in_tick) != pdTRUE)
417 return OSAL_WRONG_ARGS;
420 if(xSemaphoreGive((SemaphoreHandle_t)*handle) != pdTRUE)
462 TickType_t delay_in_ticks = OSAL_FreeRTOS_convert_time_to_tick(milliseconds);
464 vTaskDelay(delay_in_ticks);
468 static TickType_t OSAL_FreeRTOS_convert_time_to_tick(uint32_t milliseconds)
470 TickType_t time_to_tick_timeout;
472 if(milliseconds == OSAL_INFINITE_TIME)
474 time_to_tick_timeout = portMAX_DELAY;
478 time_to_tick_timeout = milliseconds / portTICK_PERIOD_MS;
480 return time_to_tick_timeout;
OSAL_status_t OSAL_queue_create(uint8_t *name, uint32_t size, OSAL_queue_handle_t *handle)
Create an OS queue with a predefined queue size.
OSAL_status_t OSAL_task_delete(OSAL_task_handle_t *handle)
Delete an OS task and start it.
OSAL_status_t OSAL_queue_post(OSAL_queue_handle_t *handle, void *msg)
Post a message in an OS queue.
OSAL_status_t OSAL_enable_context_switching(void)
Reenable the OS scheduling that was disabled by OSAL_disable_context_switching. This method may be ca...
OSAL_status_t OSAL_task_create(OSAL_task_entry_point_t entry_point, uint8_t *name, OSAL_task_stack_t stack, int32_t priority, void *parameters, OSAL_task_handle_t *handle)
Create an OS task and start it.
OSAL_status_t OSAL_sleep(uint32_t milliseconds)
Asleep the current task during specified number of milliseconds.
OSAL_status_t OSAL_queue_fetch(OSAL_queue_handle_t *handle, void **msg, uint32_t timeout)
Fetch a message from an OS queue. Blocks until a message arrived or a timeout occurred.
OSAL_status_t OSAL_binary_semaphore_give(OSAL_binary_semaphore_handle_t *handle)
Give operation on OS binary semaphore. Increase the binary semaphore count value by 1 and unblock the...
OSAL_status_t OSAL_counter_semaphore_delete(OSAL_counter_semaphore_handle_t *handle)
Delete an OS counter semaphore.
OSAL_status_t OSAL_counter_semaphore_create(uint8_t *name, uint32_t initial_count, uint32_t max_count, OSAL_counter_semaphore_handle_t *handle)
Create an OS counter semaphore with a semaphore count initial value.
OSAL_status_t OSAL_disable_context_switching(void)
Disable the OS scheduler context switching. Prevent the OS from scheduling the current thread calling...
OSAL_status_t OSAL_counter_semaphore_take(OSAL_counter_semaphore_handle_t *handle, uint32_t timeout)
Take operation on OS counter semaphore. Block the current task until counter semaphore become availab...
int32_t OSAL_task_stack_t
OS task stack.
OSAL_status_t OSAL_binary_semaphore_delete(OSAL_binary_semaphore_handle_t *handle)
Delete an OS binary semaphore.
OSAL_status_t OSAL_binary_semaphore_create(uint8_t *name, uint32_t initial_count, OSAL_binary_semaphore_handle_t *handle)
Create an OS binary semaphore with a semaphore count initial value (0 or 1).
OSAL_status_t OSAL_counter_semaphore_give(OSAL_counter_semaphore_handle_t *handle)
Give operation on OS counter semaphore. Increase the counter semaphore count value by 1 and unblock t...
OSAL_status_t OSAL_queue_delete(OSAL_queue_handle_t *handle)
Delete an OS queue.
OSAL_status_t OSAL_mutex_give(OSAL_mutex_handle_t *handle)
Give operation on OS mutex.
OSAL_status_t OSAL_binary_semaphore_take(OSAL_binary_semaphore_handle_t *handle, uint32_t timeout)
Take operation on OS binary semaphore. Block the current task until binary semaphore become available...
OSAL_status_t OSAL_mutex_take(OSAL_mutex_handle_t *handle, uint32_t timeout)
Take operation on OS mutex.
OSAL_status_t OSAL_mutex_create(uint8_t *name, OSAL_mutex_handle_t *handle)
Create an OS mutex.
OSAL_status_t OSAL_mutex_delete(OSAL_mutex_handle_t *handle)
Delete an OS mutex.