CC33XX API Documentation  2.30.00.15
Files | Macros | Typedefs | Functions
osi_freertos

This porting file provides the adaptation layer for the OS. More...

Files

file  osi_freertos.c
 osi_freertos porting file
 

Macros

#define ASSERT_ON_MALLOC_FAIL
 
#define TICK_PERIOD_US   (1000000 / configTICK_RATE_HZ)
 

Typedefs

typedef void(* func) (void *)
 

Functions

void assert (uint32_t condition)
 Assert function for the upper MAC library. More...
 
UINT32 osi_EnterCritical (void)
 This function used to enter into critical section. More...
 
UINT32 osi_ExitCritical (uint32_t ulKey)
 This function used to exit critical section. More...
 
OsiReturnVal_e osi_SyncObjCreate (OsiSyncObj_t *pSyncObj)
 This function creates a sync object. More...
 
OsiReturnVal_e osi_SyncObjDelete (OsiSyncObj_t *pSyncObj)
 This function deletes a sync object. More...
 
OsiReturnVal_e osi_SyncObjSignal (OsiSyncObj_t *pSyncObj)
 This function generates a sync signal for the object. More...
 
OsiReturnVal_e osi_SyncObjSignalFromISR (OsiSyncObj_t *pSyncObj)
 This function generates a sync signal for the object from ISR context. More...
 
OsiReturnVal_e osi_SyncObjWait (OsiSyncObj_t *pSyncObj, OsiTime_t Timeout)
 This function waits for a sync signal of the specific sync object. More...
 
OsiReturnVal_e osi_SyncObjClear (OsiSyncObj_t *pSyncObj)
 This function clears a sync object. More...
 
OsiReturnVal_e osi_TaskCreate (P_OSI_TASK_ENTRY pEntry, const signed char *const pcName, unsigned short usStackDepth, void *pvParameters, unsigned long uxPriority, OsiTaskHandle *pTaskHandle)
 This function creates a Task. More...
 
void osi_TaskDelete (OsiTaskHandle *pTaskHandle)
 This function Deletes a Task. More...
 
OsiReturnVal_e osi_LockObjCreate (OsiLockObj_t *pLockObj)
 This function creates a locking object. More...
 
OsiReturnVal_e osi_LockObjDelete (OsiLockObj_t *pLockObj)
 This function deletes a locking object. More...
 
OsiReturnVal_e osi_LockObjLock (OsiLockObj_t *pLockObj, OsiTime_t Timeout)
 This function locks a locking object. More...
 
OsiReturnVal_e osi_LockObjUnlock (OsiLockObj_t *pLockObj)
 This function unlock a locking object. More...
 
OsiReturnVal_e osi_MsgQCreate (OsiMsgQ_t *pMsgQ, char *pMsgQName, UINT32 MsgSize, UINT32 MaxMsgs)
 This function is used to create the MsgQ. More...
 
OsiReturnVal_e osi_MsgQDelete (OsiMsgQ_t *pMsgQ)
 This function is used to delete the MsgQ. More...
 
OsiReturnVal_e osi_MsgQWrite (OsiMsgQ_t *pMsgQ, void *pMsg, OsiTime_t Timeout)
 This function is used to write data to the MsgQ. More...
 
OsiReturnVal_e osi_MsgQRead (OsiMsgQ_t *pMsgQ, void *pMsg, OsiTime_t Timeout)
 This function is used to read data from the MsgQ. More...
 
UINT32 osi_MsgQCount (OsiMsgQ_t *pMsgQ)
 This function returns the number of messages ready in the Queue. More...
 
BOOLEAN osi_MsgQIsEmpty (OsiMsgQ_t *pMsgQ)
 This function returns whether there are any messages ready in the Queue. More...
 
void * os_malloc (size_t size)
 Allocate dynamic memory. More...
 
void * os_realloc (void *ptr, size_t newsize)
 Re-allocate dynamic memory. More...
 
void * os_realloc_array (void *ptr, size_t nmemb, size_t size)
 Re-Allocate and zero memory blocks. More...
 
void * os_calloc (size_t nmemb, size_t size)
 Allocate and zero memory blocks. More...
 
void * os_zalloc (size_t size)
 Allocate and zero memory. More...
 
void os_free (void *ptr)
 Free memory. More...
 
OsiReturnVal_e osi_Sleep (OsiTime_t sec)
 Put the thread to sleep. More...
 
OsiReturnVal_e osi_uSleep (OsiTime_t usec)
 Put the thread to sleep in micro seconds. More...
 
UINT32 osi_GetTimeMS ()
 Get free running time in mili seconds. More...
 
void timerGeneralCallBack (TimerHandle_t tmr)
 
OsiReturnVal_e osi_TimerCreate (OsiTimer_t *pTimer, char *pTimerName, P_TIMER_EXPIRY_LEGACY_FUNCTION pExpiryFunc, void *pParam)
 Creates a timer in the OS. More...
 
OsiReturnVal_e osi_TimerDelete (OsiTimer_t *pTimer)
 Deletes a timer in the OS. More...
 
OsiReturnVal_e osi_TimerStart (OsiTimer_t *pTimer, OsiTime_t DurationMiliSec, BOOLEAN Periodic)
 Start a created timer. More...
 
OsiReturnVal_e osi_TimerStop (OsiTimer_t *pTimer)
 Stops a created timer. More...
 
OsiTime_t osi_TimerGetRemainingTime (OsiTimer_t *pTimer)
 Get the remaining time for a timer to expire. More...
 
OsiReturnVal_e osi_ThreadCreate (OsiThread_t *pThread, char *pThreadName, UINT32 StackSize, UINT32 Priority, P_THREAD_ENTRY_FUNCTION pEntryFunc, void *pParam)
 Creates a thread in the OS. More...
 
OsiReturnVal_e osi_ThreadDelete (OsiThread_t *pThread)
 Deletes a thread in the OS. More...
 

Detailed Description

This porting file provides the adaptation layer for the OS.

Function Documentation

§ assert()

void assert ( uint32_t  condition)

Assert function for the upper MAC library.

Parameters
Conditionif TRUE, assert will occur
Returns
Note
Warning

§ os_calloc()

void* os_calloc ( size_t  nmemb,
size_t  size 
)

Allocate and zero memory blocks.

Parameters
nmembnumber of blocks to allocate
sizesize of each block in bytes
Returns
- Allocated buffer or NULL on failure
Note

§ os_free()

void os_free ( void *  ptr)

Free memory.

Parameters
ptr- pointer to release
Returns
Note

§ os_malloc()

void* os_malloc ( size_t  size)

Allocate dynamic memory.

Parameters
size
Returns
- ptr to buffer or NULL
Note
Warning

§ os_realloc()

void* os_realloc ( void *  ptr,
size_t  newsize 
)

Re-allocate dynamic memory.

Parameters
ptrOld buffer from os_malloc() or os_realloc()
newsizeof the new buffer
Returns
- Allocated buffer or NULL on failure
Note
Warning
- Caller is responsible for freeing the returned buffer with os_free(). If re-allocation fails, NULL is returned and the original buffer (ptr) is not freed and caller is still responsible for freeing it.

§ os_realloc_array()

void* os_realloc_array ( void *  ptr,
size_t  nmemb,
size_t  size 
)

Re-Allocate and zero memory blocks.

Parameters
ptrto old array
nmembnumber of blocks to allocate
sizesize of each block in bytes
Returns
- Allocated buffer or NULL on failure
Note

§ os_zalloc()

void* os_zalloc ( size_t  size)

Allocate and zero memory.

Parameters
size- in bytes
Returns
- Allocated buffer or NULL on failure
Note

§ osi_EnterCritical()

UINT32 osi_EnterCritical ( void  )

This function used to enter into critical section.

Parameters
void
Returns
- void
Note
Warning

§ osi_ExitCritical()

UINT32 osi_ExitCritical ( uint32_t  ulKey)

This function used to exit critical section.

Parameters
void
Returns
- void
Note
Warning

§ osi_GetTimeMS()

UINT32 osi_GetTimeMS ( )

Get free running time in mili seconds.

Parameters

§ osi_LockObjCreate()

OsiReturnVal_e osi_LockObjCreate ( OsiLockObj_t *  pLockObj)

This function creates a locking object.

The locking object is used for protecting a shared resources between different threads.

Parameters
pLockObj- pointer to the locking object control block
Returns
upon successful creation the function should return 0 Otherwise, a negative value indicating the error code shall be returned
Note
Warning

§ osi_LockObjDelete()

OsiReturnVal_e osi_LockObjDelete ( OsiLockObj_t *  pLockObj)

This function deletes a locking object.

Parameters
pLockObj- pointer to the locking object control block
Returns
upon successful deletion the function should return 0 Otherwise, a negative value indicating the error code shall be returned
Note
Warning

§ osi_LockObjLock()

OsiReturnVal_e osi_LockObjLock ( OsiLockObj_t *  pLockObj,
OsiTime_t  Timeout 
)

This function locks a locking object.

All other threads that call this function before this thread calls the osi_LockObjUnlock would be suspended

Parameters
pLockObj- pointer to the locking object control block
Timeout- numeric value specifies the maximum number of mSec to stay suspended while waiting for the locking object Currently, the simple link driver uses only two values:
  • OSI_WAIT_FOREVER
  • OSI_NO_WAIT
Returns
upon successful reception of the locking object the function should return 0 Otherwise, a negative value indicating the error code shall be returned
Note
Warning

§ osi_LockObjUnlock()

OsiReturnVal_e osi_LockObjUnlock ( OsiLockObj_t *  pLockObj)

This function unlock a locking object.

Parameters
pLockObj- pointer to the locking object control block
Returns
upon successful unlocking the function should return 0 Otherwise, a negative value indicating the error code shall be returned
Note
Warning

§ osi_MsgQCount()

UINT32 osi_MsgQCount ( OsiMsgQ_t *  pMsgQ)

This function returns the number of messages ready in the Queue.

Parameters
pMsgQ- pointer to the message queue
Returns
- The number of messages available in the queue.
Note
Warning

§ osi_MsgQCreate()

OsiReturnVal_e osi_MsgQCreate ( OsiMsgQ_t *  pMsgQ,
char *  pMsgQName,
UINT32  MsgSize,
UINT32  MaxMsgs 
)

This function is used to create the MsgQ.

Parameters
pMsgQ- pointer to the message queue
pMsgQName- msg queue name
MsgSize- size of message on the queue
MaxMsgs- max. number of msgs that the queue can hold
Returns
- OsiReturnVal_e
Note
Warning

§ osi_MsgQDelete()

OsiReturnVal_e osi_MsgQDelete ( OsiMsgQ_t *  pMsgQ)

This function is used to delete the MsgQ.

Parameters
pMsgQ- pointer to the message queue
Returns
- OsiReturnVal_e
Note
Warning

§ osi_MsgQIsEmpty()

BOOLEAN osi_MsgQIsEmpty ( OsiMsgQ_t *  pMsgQ)

This function returns whether there are any messages ready in the Queue.

Parameters
pMsgQ- pointer to the message queue
Returns
- BOOLEAN
Note
Warning

§ osi_MsgQRead()

OsiReturnVal_e osi_MsgQRead ( OsiMsgQ_t *  pMsgQ,
void *  pMsg,
OsiTime_t  Timeout 
)

This function is used to read data from the MsgQ.

Parameters
pMsgQ- pointer to the message queue
pMsg- pointer to the Msg strut to read into
Timeout- timeout to wait for the Msg to be available
Returns
- OsiReturnVal_e
Note
Warning

§ osi_MsgQWrite()

OsiReturnVal_e osi_MsgQWrite ( OsiMsgQ_t *  pMsgQ,
void *  pMsg,
OsiTime_t  Timeout 
)

This function is used to write data to the MsgQ.

Parameters
pMsgQ- pointer to the message queue
pMsg- pointer to the Msg strut to read into
Timeout- timeout to wait for the Msg to be available
Returns
- OsiReturnVal_e
Note
Warning

§ osi_Sleep()

OsiReturnVal_e osi_Sleep ( OsiTime_t  sec)

Put the thread to sleep.

Parameters
sec
Returns
- OSI_OK
Note
Warning

§ osi_SyncObjClear()

OsiReturnVal_e osi_SyncObjClear ( OsiSyncObj_t *  pSyncObj)

This function clears a sync object.

Parameters
pSyncObj- pointer to the sync object control block
Returns
upon successful clearing the function should return 0 Otherwise, a negative value indicating the error code shall be returned
Note
Warning

§ osi_SyncObjCreate()

OsiReturnVal_e osi_SyncObjCreate ( OsiSyncObj_t *  pSyncObj)

This function creates a sync object.

The sync object is used for synchronization between different thread or ISR and a thread.

Parameters
pSyncObj- pointer to the sync object control block
Returns
upon successful creation the function should return 0 Otherwise, a negative value indicating the error code shall be returned
Note
Warning

§ osi_SyncObjDelete()

OsiReturnVal_e osi_SyncObjDelete ( OsiSyncObj_t *  pSyncObj)

This function deletes a sync object.

Parameters
pSyncObj- pointer to the sync object control block
Returns
upon successful deletion the function should return 0 Otherwise, a negative value indicating the error code shall be returned
Note
Warning

§ osi_SyncObjSignal()

OsiReturnVal_e osi_SyncObjSignal ( OsiSyncObj_t *  pSyncObj)

This function generates a sync signal for the object.

All suspended threads waiting on this sync object are resumed

Parameters
pSyncObj- pointer to the sync object control block
Returns
upon successful signaling the function should return 0 Otherwise, a negative value indicating the error code shall be returned
Note
the function could be called from ISR context
Warning

§ osi_SyncObjSignalFromISR()

OsiReturnVal_e osi_SyncObjSignalFromISR ( OsiSyncObj_t *  pSyncObj)

This function generates a sync signal for the object from ISR context.

All suspended threads waiting on this sync object are resumed

Parameters
pSyncObj- pointer to the sync object control block
Returns
upon successful signalling the function should return 0 Otherwise, a negative value indicating the error code shall be returned
Note
the function is called from ISR context
Warning

§ osi_SyncObjWait()

OsiReturnVal_e osi_SyncObjWait ( OsiSyncObj_t *  pSyncObj,
OsiTime_t  Timeout 
)

This function waits for a sync signal of the specific sync object.

Parameters
pSyncObj- pointer to the sync object control block
Timeout- numeric value specifies the maximum number of mSec to stay suspended while waiting for the sync signal Currently, the simple link driver uses only two values:
  • OSI_WAIT_FOREVER
  • OSI_NO_WAIT
Returns
upon successful reception of the signal within the timeout window return 0 Otherwise, a negative value indicating the error code shall be returned
Note
Warning

§ osi_TaskCreate()

OsiReturnVal_e osi_TaskCreate ( P_OSI_TASK_ENTRY  pEntry,
const signed char *const  pcName,
unsigned short  usStackDepth,
void *  pvParameters,
unsigned long  uxPriority,
OsiTaskHandle *  pTaskHandle 
)

This function creates a Task.

Creates a new Task and add it to the last of tasks that are ready to run

Parameters
pEntry- pointer to the Task Function
pcName- Task Name String
usStackDepth- Stack Size in bytes
pvParameters- pointer to structure to be passed to the Task Function
uxPriority- Task Priority - 0 is lowest (IDLE) and (configMAX_PRIORITIES - 1) max
pTaskHandle- output ptr filled with taskHandler
Returns
upon successful creation the function should return 0 Otherwise, a negative value indicating the error code shall be returned
Note
Warning

§ osi_TaskDelete()

void osi_TaskDelete ( OsiTaskHandle *  pTaskHandle)

This function Deletes a Task.

Deletes a Task and remove it from list of running task

Parameters
pTaskHandle- Task Handle
Note
Warning

§ osi_ThreadCreate()

OsiReturnVal_e osi_ThreadCreate ( OsiThread_t *  pThread,
char *  pThreadName,
UINT32  StackSize,
UINT32  Priority,
P_THREAD_ENTRY_FUNCTION  pEntryFunc,
void *  pParam 
)

Creates a thread in the OS.

Parameters
pThread- return handler for the created thread
pThreadName- thread name
StackSize- stack size to be dynamically allocated inside the create function
Priority- priority - 0 is lowest (IDLE) and (configMAX_PRIORITIES - 1) max
pEntryFunc- thread entry function
pParam- parameters to move to the thread entry function
Returns
- OSI_xxx
Note
Warning

§ osi_ThreadDelete()

OsiReturnVal_e osi_ThreadDelete ( OsiThread_t *  pThread)

Deletes a thread in the OS.

Parameters
pThread- return handler for the created thread
Returns
- OSI_xxx
Note
Warning
thread should to be in a safe code - while (1) loop for example in order to be deleted

§ osi_TimerCreate()

OsiReturnVal_e osi_TimerCreate ( OsiTimer_t *  pTimer,
char *  pTimerName,
P_TIMER_EXPIRY_LEGACY_FUNCTION  pExpiryFunc,
void *  pParam 
)

Creates a timer in the OS.

Parameters
pTimer- timer object preallocated allocated
pTimerName- timer name
pExpiryFunc- expiry callback function
pParam- expiry callback parameters
Returns
- OSI_xxx
Note
Warning

§ osi_TimerDelete()

OsiReturnVal_e osi_TimerDelete ( OsiTimer_t *  pTimer)

Deletes a timer in the OS.

Parameters
pTimer- timer object
Returns
- OSI_xxx
Note
Warning

§ osi_TimerGetRemainingTime()

OsiTime_t osi_TimerGetRemainingTime ( OsiTimer_t *  pTimer)

Get the remaining time for a timer to expire.

Parameters
pTimer- timer object
Returns
- expiry in mili seconds
Note
Warning

§ osi_TimerStart()

OsiReturnVal_e osi_TimerStart ( OsiTimer_t *  pTimer,
OsiTime_t  DurationMiliSec,
BOOLEAN  Periodic 
)

Start a created timer.

Parameters
pTimer- timer object
DurationMiliSec
Periodic- is this timer periodic
Returns
- OSI_xxx
Note
Warning

§ osi_TimerStop()

OsiReturnVal_e osi_TimerStop ( OsiTimer_t *  pTimer)

Stops a created timer.

Parameters
pTimer- timer object
Returns
- OSI_xxx
Note
Warning

§ osi_uSleep()

OsiReturnVal_e osi_uSleep ( OsiTime_t  usec)

Put the thread to sleep in micro seconds.

Parameters
usec- time in micro seconds
Returns
- OSI_OK
Note
Warning