64 #if !defined (USING_OS_FREERTOS)
65 #error "Wrong OSIF selected. Please define symbol USING_OS_FREERTOS in project settings or change the OSIF variant"
79 #define MSEC_TO_TICK(msec) (pdMS_TO_TICKS(msec))
88 static inline bool osif_IsIsrContext(
void)
116 vTaskDelay(MSEC_TO_TICK(delay));
135 return (uint32_t)((((uint64_t) xTaskGetTickCount()) * 1000u) / configTICK_RATE_HZ);
146 const uint32_t timeout)
151 uint32_t timeoutTicks;
153 TaskHandle_t mutex_holder_handle;
154 TaskHandle_t current_task_handle;
155 BaseType_t operation_status = pdFAIL;
162 mutex_holder_handle = xSemaphoreGetMutexHolder(*pMutex);
163 current_task_handle = xTaskGetCurrentTaskHandle();
166 if (mutex_holder_handle == current_task_handle)
175 timeoutTicks = portMAX_DELAY;
179 timeoutTicks = MSEC_TO_TICK(timeout);
183 operation_status = xSemaphoreTake(*pMutex, timeoutTicks);
189 return osif_ret_code;
206 TaskHandle_t mutex_holder_handle;
207 TaskHandle_t current_task_handle;
208 BaseType_t operation_status = pdFAIL;
215 mutex_holder_handle = xSemaphoreGetMutexHolder(*pMutex);
216 current_task_handle = xTaskGetCurrentTaskHandle();
219 if (mutex_holder_handle != current_task_handle)
225 operation_status = xSemaphoreGive(*pMutex);
230 return osif_ret_code;
249 *pMutex = xSemaphoreCreateMutex();
256 return osif_ret_code;
274 vSemaphoreDelete(*pMutex);
289 const uint32_t timeout)
293 uint32_t timeoutTicks;
294 BaseType_t operation_status;
300 timeoutTicks = portMAX_DELAY;
304 timeoutTicks = MSEC_TO_TICK(timeout);
308 operation_status = xSemaphoreTake(*pSem, timeoutTicks);
312 return osif_ret_code;
326 BaseType_t operation_status = pdFAIL;
330 bool is_isr = osif_IsIsrContext();
334 BaseType_t taskWoken = pdFALSE;
335 operation_status = xSemaphoreGiveFromISR(*pSem, &taskWoken);
337 if (operation_status == pdPASS)
340 portYIELD_FROM_ISR(taskWoken);
346 operation_status = xSemaphoreGive(*pSem);
352 return osif_ret_code;
363 const uint8_t initValue)
369 *pSem = xSemaphoreCreateCounting(0xFFu, initValue);
376 return osif_ret_code;
391 vSemaphoreDelete(*pSem);
status_t OSIF_MutexDestroy(const mutex_t *const pMutex)
Destroys a previously created mutex.
status_t OSIF_SemaDestroy(const semaphore_t *const pSem)
Destroys a previously created semaphore.
void OSIF_TimeDelay(uint32_t delay)
Delays execution for a number of milliseconds.
status_t OSIF_MutexUnlock(const mutex_t *const pMutex)
Unlocks a previously locked mutex.
status_t OSIF_MutexLock(const mutex_t *const pMutex, const uint32_t timeout)
Waits for a mutex and locks it.
uint32_t OSIF_GetMilliseconds(void)
Returns the number of miliseconds elapsed since starting the internal timer or starting the scheduler...
status_t OSIF_SemaCreate(semaphore_t *const pSem, const uint8_t initValue)
Creates a semaphore with a given value.
status_t OSIF_MutexCreate(mutex_t *const pMutex)
Create an unlocked mutex.
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
#define S32_SCB_ICSR_VECTACTIVE_SHIFT
status_t OSIF_SemaWait(semaphore_t *const pSem, const uint32_t timeout)
Decrement a semaphore with timeout.
#define OSIF_WAIT_FOREVER
status_t OSIF_SemaPost(semaphore_t *const pSem)
Increment a semaphore.
#define S32_SCB_ICSR_VECTACTIVE_MASK