S32 SDK
OS Interface (OSIF)

Detailed Description

OS Interface Layer (OSIF)

This module is for SDK internal use only. It provides an abstract OS interface to SDK drivers (even if no OS is present) for basic OS operations (mutex and semaphore handling and time delay service).

FreeRTOS

A compile-time symbol, USING_OS_FREERTOS, needs to be defined.

FreeRTOSConfig.h necessities

FreeRTOS configuration file needs to have these options activated:

Bare-metal

If no OS is present, the corresponding bare-metal version of OSIF needs to be linked.

Mutex operations are dummy operations (always return success) and semaphore is implemented as a simple counter.

Time delay is implemented using the core Systick timer.

Constraints

To correctly measure time, a hardware timer is required. The Systick is employed for this purpose. As a consequence, the Systick timer is a blocked resource to the user application.

Macros

#define OSIF_WAIT_FOREVER   0xFFFFFFFFu
 

Functions

void OSIF_TimeDelay (const uint32_t delay)
 Delays execution for a number of milliseconds. More...
 
uint32_t OSIF_GetMilliseconds (void)
 Returns the number of miliseconds elapsed since starting the internal timer or starting the scheduler. More...
 
status_t OSIF_MutexLock (const mutex_t *const pMutex, const uint32_t timeout)
 Waits for a mutex and locks it. More...
 
status_t OSIF_MutexUnlock (const mutex_t *const pMutex)
 Unlocks a previously locked mutex. More...
 
status_t OSIF_MutexCreate (mutex_t *const pMutex)
 Create an unlocked mutex. More...
 
status_t OSIF_MutexDestroy (const mutex_t *const pMutex)
 Destroys a previously created mutex. More...
 
status_t OSIF_SemaWait (semaphore_t *const pSem, const uint32_t timeout)
 Decrement a semaphore with timeout. More...
 
status_t OSIF_SemaPost (semaphore_t *const pSem)
 Increment a semaphore. More...
 
status_t OSIF_SemaCreate (semaphore_t *const pSem, const uint8_t initValue)
 Creates a semaphore with a given value. More...
 
status_t OSIF_SemaDestroy (const semaphore_t *const pSem)
 Destroys a previously created semaphore. More...
 

Macro Definition Documentation

#define OSIF_WAIT_FOREVER   0xFFFFFFFFu

Definition at line 65 of file osif.h.

Function Documentation

uint32_t OSIF_GetMilliseconds ( void  )

Returns the number of miliseconds elapsed since starting the internal timer or starting the scheduler.

Returns
the number of miliseconds elapsed

Definition at line 138 of file osif_baremetal.c.

status_t OSIF_MutexCreate ( mutex_t *const  pMutex)

Create an unlocked mutex.

Parameters
[in]pMutexreference to the mutex object
Returns
One of the possible status codes:
  • STATUS_SUCCESS: mutex created
  • STATUS_ERROR: mutex could not be created

Definition at line 186 of file osif_baremetal.c.

status_t OSIF_MutexDestroy ( const mutex_t *const  pMutex)

Destroys a previously created mutex.

Parameters
[in]pMutexreference to the mutex object
Returns
One of the possible status codes:
  • STATUS_SUCCESS: mutex destroyed

Definition at line 200 of file osif_baremetal.c.

status_t OSIF_MutexLock ( const mutex_t *const  pMutex,
const uint32_t  timeout 
)

Waits for a mutex and locks it.

Parameters
[in]pMutexreference to the mutex object
[in]timeouttime-out value in milliseconds
Returns
One of the possible status codes:
  • STATUS_SUCCESS: mutex lock operation success
  • STATUS_ERROR: mutex already owned by current thread
  • STATUS_TIMEOUT: mutex lock operation timed out

Definition at line 156 of file osif_baremetal.c.

status_t OSIF_MutexUnlock ( const mutex_t *const  pMutex)

Unlocks a previously locked mutex.

Parameters
[in]pMutexreference to the mutex object
Returns
One of the possible status codes:
  • STATUS_SUCCESS: mutex unlock operation success
  • STATUS_ERROR: mutex unlock failed

Definition at line 172 of file osif_baremetal.c.

status_t OSIF_SemaCreate ( semaphore_t *const  pSem,
const uint8_t  initValue 
)

Creates a semaphore with a given value.

Parameters
[in]pSemreference to the semaphore object
[in]initValueinitial value of the semaphore
Returns
One of the possible status codes:
  • STATUS_SUCCESS: semaphore created
  • STATUS_ERROR: semaphore could not be created

Definition at line 292 of file osif_baremetal.c.

status_t OSIF_SemaDestroy ( const semaphore_t *const  pSem)

Destroys a previously created semaphore.

Parameters
[in]pSemreference to the semaphore object
Returns
One of the possible status codes:
  • STATUS_SUCCESS: semaphore destroyed

Definition at line 311 of file osif_baremetal.c.

status_t OSIF_SemaPost ( semaphore_t *const  pSem)

Increment a semaphore.

Parameters
[in]pSemreference to the semaphore object
Returns
One of the possible status codes:
  • STATUS_SUCCESS: semaphore post operation success
  • STATUS_ERROR: semaphore could not be incremented

Definition at line 265 of file osif_baremetal.c.

status_t OSIF_SemaWait ( semaphore_t *const  pSem,
const uint32_t  timeout 
)

Decrement a semaphore with timeout.

Parameters
[in]pSemreference to the semaphore object
[in]timeouttime-out value in milliseconds
Returns
One of the possible status codes:
  • STATUS_SUCCESS: semaphore wait operation success
  • STATUS_TIMEOUT: semaphore wait timed out

Definition at line 214 of file osif_baremetal.c.

void OSIF_TimeDelay ( const uint32_t  delay)

Delays execution for a number of milliseconds.

Parameters
[in]delayTime delay in milliseconds.

Definition at line 113 of file osif_baremetal.c.