MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
OSA_Adapter: Operatin System Abstraction Adapter

Overview

Modules

 OSA BM
 
 OSA FreeRTOS
 

Data Structures

struct  osa_task_def_t
 Thread Definition structure contains startup information of a thread. More...
 
struct  osa_thread_link_handle_t
 Thread Link Definition structure . More...
 
struct  osa_time_def_t
 Definition structure contains timer parameters. More...
 

Macros

#define osaWaitForever_c   ((uint32_t)(-1))
 Constant to pass as timeout value in order to wait indefinitely. More...
 
#define SEMAPHORE_HANDLE_BUFFER_DEFINE(name)   uint32_t name[((OSA_SEM_HANDLE_SIZE - 1) >> 2) + 1]
 Defines the semaphore handle buffer. More...
 
#define SEMAPHORE_HANDLE_BUFFER_GET(name)   (osa_semaphore_handle_t *)&name[0]
 \ More...
 
#define MUTEX_HANDLE_BUFFER_DEFINE(name)   uint32_t name[((OSA_MUTEX_HANDLE_SIZE - 1) >> 2) + 1]
 Defines the mutex handle buffer. More...
 
#define MUTEX_HANDLE_BUFFER_GET(name)   (osa_mutex_handle_t *)&name[0]
 \ More...
 
#define EVENT_HANDLE_BUFFER_DEFINE(name)   uint32_t name[((OSA_EVENT_HANDLE_SIZE - 1) >> 2) + 1]
 Defines the enent handle buffer. More...
 
#define EVENT_HANDLE_BUFFER_GET(name)   (osa_event_handle_t *)&name[0]
 \ More...
 
#define MSGQ_HANDLE_BUFFER_DEFINE(name, numberOfMsgs, msgSize)   uint32_t name[(((OSA_MSGQ_HANDLE_SIZE + numberOfMsgs * msgSize) - 1) >> 2) + 1]
 Defines the message handle buffer. More...
 
#define MSGQ_HANDLE_BUFFER_GET(name)   (osa_msgq_handle_t) & name[0]
 \ More...
 
#define TASK_HANDLE_BUFFER_DEFINE(name)   uint32_t name[((OSA_TASK_HANDLE_SIZE - 1) >> 2) + 1]
 Defines the task handle buffer. More...
 
#define TASK_HANDLE_BUFFER_GET(name)   (osa_task_handle_t) & name[0]
 \ More...
 

Typedefs

typedef uint16_t osa_task_priority_t
 Type for the Task Priority.
 
typedef void * osa_task_handle_t
 Type for a task handler.
 
typedef void * osa_task_param_t
 Type for the parameter to be passed to the task at its creation.
 
typedef void(* osa_task_ptr_t )(osa_task_param_t task_param)
 Type for task pointer. More...
 
typedef void * osa_semaphore_handle_t
 Type for the semaphore handler.
 
typedef void * osa_mutex_handle_t
 Type for the mutex handler.
 
typedef void * osa_event_handle_t
 Type for the event handler.
 
typedef uint32_t osa_event_flags_t
 Type for an event flags group, bit 32 is reserved. More...
 
typedef void * osa_msg_handle_t
 Message definition. More...
 
typedef void * osa_msgq_handle_t
 Type for the message queue handler.
 
typedef void * osa_timer_handle_t
 Type for the Timer handler.
 
typedef void(* osa_timer_fct_ptr_t )(void const *argument)
 Type for the Timer callback function pointer. More...
 

Enumerations

enum  osa_timer_t {
  KOSA_TimerOnce = 0,
  KOSA_TimerPeriodic = 1
}
 Type for the timer definition. More...
 
enum  osa_status_t {
  KOSA_StatusSuccess = kStatus_Success,
  KOSA_StatusError = MAKE_STATUS(kStatusGroup_OSA, 1),
  KOSA_StatusTimeout = MAKE_STATUS(kStatusGroup_OSA, 2),
  KOSA_StatusIdle = MAKE_STATUS(kStatusGroup_OSA, 3)
}
 Defines the return status of OSA's functions. More...
 

Functions

void * OSA_MemoryAllocate (uint32_t length)
 Reserves the requested amount of memory in bytes. More...
 
void OSA_MemoryFree (void *p)
 Frees the memory previously reserved. More...
 
void OSA_EnterCritical (uint32_t *sr)
 Enter critical with nesting mode. More...
 
void OSA_ExitCritical (uint32_t sr)
 Exit critical with nesting mode. More...
 

Task management

osa_status_t OSA_TaskCreate (osa_task_handle_t taskHandle, osa_task_def_t *thread_def, osa_task_param_t task_param)
 Creates a task. More...
 
osa_task_handle_t OSA_TaskGetCurrentHandle (void)
 Gets the handler of active task. More...
 
osa_status_t OSA_TaskYield (void)
 Puts the active task to the end of scheduler's queue. More...
 
osa_task_priority_t OSA_TaskGetPriority (osa_task_handle_t taskHandle)
 Gets the priority of a task. More...
 
osa_status_t OSA_TaskSetPriority (osa_task_handle_t taskHandle, osa_task_priority_t taskPriority)
 Sets the priority of a task. More...
 
osa_status_t OSA_TaskDestroy (osa_task_handle_t taskHandle)
 Destroys a previously created task. More...
 
osa_status_t OSA_SemaphoreCreate (osa_semaphore_handle_t semaphoreHandle, uint32_t initValue)
 Creates a semaphore with a given value. More...
 
osa_status_t OSA_SemaphoreDestroy (osa_semaphore_handle_t semaphoreHandle)
 Destroys a previously created semaphore. More...
 
osa_status_t OSA_SemaphoreWait (osa_semaphore_handle_t semaphoreHandle, uint32_t millisec)
 Pending a semaphore with timeout. More...
 
osa_status_t OSA_SemaphorePost (osa_semaphore_handle_t semaphoreHandle)
 Signals for someone waiting on the semaphore to wake up. More...
 
osa_status_t OSA_MutexCreate (osa_mutex_handle_t mutexHandle)
 Create an unlocked mutex. More...
 
osa_status_t OSA_MutexLock (osa_mutex_handle_t mutexHandle, uint32_t millisec)
 Waits for a mutex and locks it. More...
 
osa_status_t OSA_MutexUnlock (osa_mutex_handle_t mutexHandle)
 Unlocks a previously locked mutex. More...
 
osa_status_t OSA_MutexDestroy (osa_mutex_handle_t mutexHandle)
 Destroys a previously created mutex. More...
 
osa_status_t OSA_EventCreate (osa_event_handle_t eventHandle, uint8_t autoClear)
 Initializes an event object with all flags cleared. More...
 
osa_status_t OSA_EventSet (osa_event_handle_t eventHandle, osa_event_flags_t flagsToSet)
 Sets one or more event flags. More...
 
osa_status_t OSA_EventClear (osa_event_handle_t eventHandle, osa_event_flags_t flagsToClear)
 Clears one or more flags. More...
 
osa_status_t OSA_EventWait (osa_event_handle_t eventHandle, osa_event_flags_t flagsToWait, uint8_t waitAll, uint32_t millisec, osa_event_flags_t *pSetFlags)
 Waits for specified event flags to be set. More...
 
osa_status_t OSA_EventDestroy (osa_event_handle_t eventHandle)
 Destroys a previously created event object. More...
 
osa_status_t OSA_MsgQCreate (osa_msgq_handle_t msgqHandle, uint32_t msgNo, uint32_t msgSize)
 Initializes a message queue. More...
 
osa_status_t OSA_MsgQPut (osa_msgq_handle_t msgqHandle, osa_msg_handle_t pMessage)
 Puts a message at the end of the queue. More...
 
osa_status_t OSA_MsgQGet (osa_msgq_handle_t msgqHandle, osa_msg_handle_t pMessage, uint32_t millisec)
 Reads and remove a message at the head of the queue. More...
 
osa_status_t OSA_MsgQDestroy (osa_msgq_handle_t msgqHandle)
 Destroys a previously created queue. More...
 
void OSA_InterruptEnable (void)
 Enable all interrupts.
 
void OSA_InterruptDisable (void)
 Disable all interrupts.
 
void OSA_EnableIRQGlobal (void)
 Enable all interrupts using PRIMASK.
 
void OSA_DisableIRQGlobal (void)
 Disable all interrupts using PRIMASK.
 
void OSA_TimeDelay (uint32_t millisec)
 Delays execution for a number of milliseconds. More...
 
uint32_t OSA_TimeGetMsec (void)
 This function gets current time in milliseconds. More...
 
void OSA_InstallIntHandler (uint32_t IRQNumber, void(*handler)(void))
 Installs the interrupt handler. More...
 

Data Structure Documentation

struct osa_task_def_t

Data Fields

osa_task_ptr_t pthread
 start address of thread function
 
uint32_t tpriority
 initial thread priority
 
uint32_t instances
 maximum number of instances of that thread function
 
uint32_t stacksize
 stack size requirements in bytes; 0 is default stack size
 
uint32_t * tstack
 stack pointer
 
void * tlink
 link pointer
 
uint8_t * tname
 name pointer
 
uint8_t useFloat
 is use float
 
struct osa_thread_link_t

Data Fields

uint8_t link [12]
 link
 
osa_task_handle_t osThreadId
 thread id
 
osa_task_def_tosThreadDefHandle
 pointer of thread define handle
 
uint32_t * osThreadStackHandle
 pointer of thread stack handle
 
struct osa_time_def_t

Macro Definition Documentation

#define osaWaitForever_c   ((uint32_t)(-1))
#define SEMAPHORE_HANDLE_BUFFER_DEFINE (   name)    uint32_t name[((OSA_SEM_HANDLE_SIZE - 1) >> 2) + 1]

This macro is used to define the semaphore handle buffer for semaphore queue. And then uses the macro SEMAPHORE_HANDLE_BUFFER_GET to get the semaphore handle buffer pointer. The macro should not be used in a suitable position for its user.

This macro is optional, semaphore handle buffer could also be defined by yourself.

This is a example,

* SEMAPHORE_HANDLE_BUFFER_DEFINE(semaphoreHandle);
*
Parameters
nameThe name string of the semaphore handle buffer.
#define SEMAPHORE_HANDLE_BUFFER_GET (   name)    (osa_semaphore_handle_t *)&name[0]

Gets the semaphore buffer pointer \ \ This macro is used to get the semaphore buffer pointer. The macro should \ not be used before the macro SEMAPHORE_HANDLE_BUFFER_DEFINE is used. \ \

Parameters
nameThe memory name string of the buffer. \
#define MUTEX_HANDLE_BUFFER_DEFINE (   name)    uint32_t name[((OSA_MUTEX_HANDLE_SIZE - 1) >> 2) + 1]

This macro is used to define the mutex handle buffer for mutex queue. And then uses the macro MUTEX_HANDLE_BUFFER_GET to get the mutex handle buffer pointer. The macro should not be used in a suitable position for its user.

This macro is optional, mutex handle buffer could also be defined by yourself.

This is a example,

*
Parameters
nameThe name string of the mutex handle buffer.
#define MUTEX_HANDLE_BUFFER_GET (   name)    (osa_mutex_handle_t *)&name[0]

Gets the mutex buffer pointer \ \ This macro is used to get the mutex buffer pointer. The macro should \ not be used before the macro MUTEX_HANDLE_BUFFER_DEFINE is used. \ \

Parameters
nameThe memory name string of the buffer. \
#define EVENT_HANDLE_BUFFER_DEFINE (   name)    uint32_t name[((OSA_EVENT_HANDLE_SIZE - 1) >> 2) + 1]

This macro is used to define the enent handle buffer for enent queue. And then uses the macro EVENT_HANDLE_BUFFER_GET to get the enent handle buffer pointer. The macro should not be used in a suitable position for its user.

This macro is optional, enent handle buffer could also be defined by yourself.

This is a example,

*
Parameters
nameThe name string of the enent handle buffer.
#define EVENT_HANDLE_BUFFER_GET (   name)    (osa_event_handle_t *)&name[0]

Gets the event buffer pointer \ \ This macro is used to get the event buffer pointer. The macro should \ not be used before the macro EVENT_HANDLE_BUFFER_DEFINE is used. \ \

Parameters
nameThe memory name string of the buffer. \
#define MSGQ_HANDLE_BUFFER_DEFINE (   name,
  numberOfMsgs,
  msgSize 
)    uint32_t name[(((OSA_MSGQ_HANDLE_SIZE + numberOfMsgs * msgSize) - 1) >> 2) + 1]

This macro is used to define the message handle buffer for message queue. And then uses the macro MSGQ_HANDLE_BUFFER_GET to get the message handle buffer pointer. The macro should not be used in a suitable position for its user.

This macro is optional, message handle buffer could also be defined by yourself.

This is a example,

* MSGQ_HANDLE_BUFFER_DEFINE(msgqHandle, 3, sizeof(msgStruct));
* MSGQ_HANDLE_BUFFER_DEFINE(msgqHandle, 3, 4);
*
Parameters
nameThe name string of the message handle buffer.
numberOfMsgsThe number Of messages.
msgSizeThe size of a single message structure.
#define MSGQ_HANDLE_BUFFER_GET (   name)    (osa_msgq_handle_t) & name[0]

Gets the message buffer pointer \ \ This macro is used to get the message buffer pointer. The macro should \ not be used before the macro MSGQ_HANDLE_BUFFER_DEFINE is used. \ \

Parameters
nameThe memory name string of the buffer. \
#define TASK_HANDLE_BUFFER_DEFINE (   name)    uint32_t name[((OSA_TASK_HANDLE_SIZE - 1) >> 2) + 1]

This macro is used to define the task handle buffer for task queue. And then uses the macro TASK_HANDLE_BUFFER_GET to get the task handle buffer pointer. The macro should not be used in a suitable position for its user.

This macro is optional, task handle buffer could also be defined by yourself.

This is a example,

*
Parameters
nameThe name string of the task handle buffer.
#define TASK_HANDLE_BUFFER_GET (   name)    (osa_task_handle_t) & name[0]

Gets the task buffer pointer \ \ This macro is used to get the task buffer pointer. The macro should \ not be used before the macro TASK_HANDLE_BUFFER_DEFINE is used. \ \

Parameters
nameThe memory name string of the buffer. \

Typedef Documentation

typedef void(* osa_task_ptr_t)(osa_task_param_t task_param)

Task prototype declaration

typedef uint32_t osa_event_flags_t
typedef void* osa_msg_handle_t
typedef void(* osa_timer_fct_ptr_t)(void const *argument)

Enumeration Type Documentation

Enumerator
KOSA_TimerOnce 

one-shot timer

KOSA_TimerPeriodic 

repeating timer

Enumerator
KOSA_StatusSuccess 

Success.

KOSA_StatusError 

Failed.

KOSA_StatusTimeout 

Timeout occurs while waiting.

KOSA_StatusIdle 

Used for bare metal only, the wait object is not ready and timeout still not occur.

Function Documentation

void* OSA_MemoryAllocate ( uint32_t  length)

The function is used to reserve the requested amount of memory in bytes and initializes it to 0.

Parameters
lengthAmount of bytes to reserve.
Returns
Pointer to the reserved memory. NULL if memory can't be allocated.
void OSA_MemoryFree ( void *  p)

The function is used to free the memory block previously reserved.

Parameters
pPointer to the start of the memory block previously reserved.
void OSA_EnterCritical ( uint32_t *  sr)
Parameters
srStore current status and return to caller.
void OSA_ExitCritical ( uint32_t  sr)
Parameters
srPrevious status to restore.
osa_status_t OSA_TaskCreate ( osa_task_handle_t  taskHandle,
osa_task_def_t thread_def,
osa_task_param_t  task_param 
)

This function is used to create task based on the resources defined by the macro OSA_TASK_DEFINE.

Parameters
taskHandlePointer to a memory space of size #OSA_TASK_HANDLE_SIZE allocated by the caller, task handle. The handle should be 4 byte aligned, because unaligned access does not support on some devices. The macro TASK_HANDLE_BUFFER_GET is used to get the task buffer pointer, and should not be used before the macro TASK_HANDLE_BUFFER_DEFINE is used.
thread_defpointer to theosa_task_def_t structure which defines the task.
task_paramPointer to be passed to the task when it is created.
Return values
KOSA_StatusSuccessThe task is successfully created.
KOSA_StatusErrorThe task can not be created. Example:
* uint32_t taskHandleBuffer[((OSA_TASK_HANDLE_SIZE + sizeof(uint32_t) - 1) / sizeof(uitn32_t))];
* osa_task_handle_t taskHandle = (osa_task_handle_t)&taskHandleBuffer[0];
* OSA_TASK_DEFINE( Job1, OSA_PRIORITY_HIGH, 1, 800, 0);
* OSA_TaskCreate(taskHandle, OSA_TASK(Job1), (osa_task_param_t)NULL);
*
osa_task_handle_t OSA_TaskGetCurrentHandle ( void  )
Returns
Handler to current active task.
osa_status_t OSA_TaskYield ( void  )

When a task calls this function, it gives up the CPU and puts itself to the end of a task ready list.

Return values
KOSA_StatusSuccessThe function is called successfully.
KOSA_StatusErrorError occurs with this function.
osa_task_priority_t OSA_TaskGetPriority ( osa_task_handle_t  taskHandle)
Parameters
taskHandleThe handler of the task whose priority is received. The macro TASK_HANDLE_BUFFER_GET is used to get the task buffer pointer, and should not be used before the macro TASK_HANDLE_BUFFER_DEFINE is used.
Returns
Task's priority.
osa_status_t OSA_TaskSetPriority ( osa_task_handle_t  taskHandle,
osa_task_priority_t  taskPriority 
)
Parameters
taskHandleThe handler of the task whose priority is set. The macro TASK_HANDLE_BUFFER_GET is used to get the task buffer pointer, and should not be used before the macro TASK_HANDLE_BUFFER_DEFINE is used.
taskPriorityThe priority to set.
Return values
KOSA_StatusSuccessTask's priority is set successfully.
KOSA_StatusErrorTask's priority can not be set.
osa_status_t OSA_TaskDestroy ( osa_task_handle_t  taskHandle)
Parameters
taskHandleThe handler of the task to destroy. The macro TASK_HANDLE_BUFFER_GET is used to get the task buffer pointer, and should not be used before the macro TASK_HANDLE_BUFFER_DEFINE is used.
Return values
KOSA_StatusSuccessThe task was successfully destroyed.
KOSA_StatusErrorTask destruction failed or invalid parameter.
osa_status_t OSA_SemaphoreCreate ( osa_semaphore_handle_t  semaphoreHandle,
uint32_t  initValue 
)

This function creates a semaphore and sets the value to the parameter initValue.

Parameters
semaphoreHandlePointer to a memory space of size #OSA_SEM_HANDLE_SIZE allocated by the caller, semaphore handle. The handle should be 4 byte aligned, because unaligned access does not support on some devices. The macro SEMAPHORE_HANDLE_BUFFER_GET is used to get the semaphore buffer pointer, and should not be used before the macro SEMAPHORE_HANDLE_BUFFER_DEFINE is used.
initValueInitial value the semaphore will be set to.
Return values
KOSA_StatusSuccessthe new semaphore if the semaphore is created successfully.
KOSA_StatusErrorif the semaphore can not be created.
osa_status_t OSA_SemaphoreDestroy ( osa_semaphore_handle_t  semaphoreHandle)
Parameters
semaphoreHandleThe semaphore handle. The macro SEMAPHORE_HANDLE_BUFFER_GET is used to get the semaphore buffer pointer, and should not be used before the macro SEMAPHORE_HANDLE_BUFFER_DEFINE is used.
Return values
KOSA_StatusSuccessThe semaphore is successfully destroyed.
KOSA_StatusErrorThe semaphore can not be destroyed.
osa_status_t OSA_SemaphoreWait ( osa_semaphore_handle_t  semaphoreHandle,
uint32_t  millisec 
)

This function checks the semaphore's counting value. If it is positive, decreases it and returns KOSA_StatusSuccess. Otherwise, a timeout is used to wait.

Parameters
semaphoreHandleThe semaphore handle. The macro SEMAPHORE_HANDLE_BUFFER_GET is used to get the semaphore buffer pointer, and should not be used before the macro SEMAPHORE_HANDLE_BUFFER_DEFINE is used.
millisecThe maximum number of milliseconds to wait if semaphore is not positive. Pass osaWaitForever_c to wait indefinitely, pass 0 will return KOSA_StatusTimeout immediately.
Return values
KOSA_StatusSuccessThe semaphore is received.
KOSA_StatusTimeoutThe semaphore is not received within the specified 'timeout'.
KOSA_StatusErrorAn incorrect parameter was passed.
osa_status_t OSA_SemaphorePost ( osa_semaphore_handle_t  semaphoreHandle)

Wakes up one task that is waiting on the semaphore. If no task is waiting, increases the semaphore's counting value.

Parameters
semaphoreHandleThe semaphore handle to signal. The macro SEMAPHORE_HANDLE_BUFFER_GET is used to get the semaphore buffer pointer, and should not be used before the macro SEMAPHORE_HANDLE_BUFFER_DEFINE is used.
Return values
KOSA_StatusSuccessThe semaphore is successfully signaled.
KOSA_StatusErrorThe object can not be signaled or invalid parameter.
osa_status_t OSA_MutexCreate ( osa_mutex_handle_t  mutexHandle)

This function creates a non-recursive mutex and sets it to unlocked status.

Parameters
mutexHandlePointer to a memory space of size #OSA_MUTEX_HANDLE_SIZE allocated by the caller, mutex handle. The handle should be 4 byte aligned, because unaligned access does not support on some devices. The macro MUTEX_HANDLE_BUFFER_GET is used to get the mutex buffer pointer, and should not be used before the macro MUTEX_HANDLE_BUFFER_DEFINE is used.
Return values
KOSA_StatusSuccessthe new mutex if the mutex is created successfully.
KOSA_StatusErrorif the mutex can not be created.
osa_status_t OSA_MutexLock ( osa_mutex_handle_t  mutexHandle,
uint32_t  millisec 
)

This function checks the mutex's status. If it is unlocked, locks it and returns the KOSA_StatusSuccess. Otherwise, waits for a timeout in milliseconds to lock.

Parameters
mutexHandleThe mutex handle. The macro MUTEX_HANDLE_BUFFER_GET is used to get the message mutex pointer, and should not be used before the macro MUTEX_HANDLE_BUFFER_DEFINE is used.
millisecThe maximum number of milliseconds to wait for the mutex. If the mutex is locked, Pass the value osaWaitForever_c will wait indefinitely, pass 0 will return KOSA_StatusTimeout immediately.
Return values
KOSA_StatusSuccessThe mutex is locked successfully.
KOSA_StatusTimeoutTimeout occurred.
KOSA_StatusErrorIncorrect parameter was passed.
Note
This is non-recursive mutex, a task can not try to lock the mutex it has locked.
osa_status_t OSA_MutexUnlock ( osa_mutex_handle_t  mutexHandle)
Parameters
mutexHandleThe mutex handle. The macro MUTEX_HANDLE_BUFFER_GET is used to get the mutex buffer pointer, and should not be used before the macro MUTEX_HANDLE_BUFFER_DEFINE is used.
Return values
KOSA_StatusSuccessThe mutex is successfully unlocked.
KOSA_StatusErrorThe mutex can not be unlocked or invalid parameter.
osa_status_t OSA_MutexDestroy ( osa_mutex_handle_t  mutexHandle)
Parameters
mutexHandleThe mutex handle. The macro MUTEX_HANDLE_BUFFER_GET is used to get the mutex buffer pointer, and should not be used before the macro MUTEX_HANDLE_BUFFER_DEFINE is used.
Return values
KOSA_StatusSuccessThe mutex is successfully destroyed.
KOSA_StatusErrorThe mutex can not be destroyed.
osa_status_t OSA_EventCreate ( osa_event_handle_t  eventHandle,
uint8_t  autoClear 
)

This function creates an event object and set its clear mode. If autoClear is TRUE, when a task gets the event flags, these flags will be cleared automatically. Otherwise these flags must be cleared manually.

Parameters
eventHandlePointer to a memory space of size #OSA_EVENT_HANDLE_SIZE allocated by the caller, Event handle. The handle should be 4 byte aligned, because unaligned access does not support on some devices. The macro EVENT_HANDLE_BUFFER_GET is used to get the event buffer pointer, and should not be used before the macro EVENT_HANDLE_BUFFER_DEFINE is used.
autoClearTRUE The event is auto-clear. FALSE The event manual-clear
Return values
KOSA_StatusSuccessthe new event if the event is created successfully.
KOSA_StatusErrorif the event can not be created.
osa_status_t OSA_EventSet ( osa_event_handle_t  eventHandle,
osa_event_flags_t  flagsToSet 
)

Sets specified flags of an event object.

Parameters
eventHandleThe event handle. The macro EVENT_HANDLE_BUFFER_GET is used to get the event buffer pointer, and should not be used before the macro EVENT_HANDLE_BUFFER_DEFINE is used.
flagsToSetFlags to be set.
Return values
KOSA_StatusSuccessThe flags were successfully set.
KOSA_StatusErrorAn incorrect parameter was passed.
osa_status_t OSA_EventClear ( osa_event_handle_t  eventHandle,
osa_event_flags_t  flagsToClear 
)

Clears specified flags of an event object.

Parameters
eventHandleThe event handle. The macro EVENT_HANDLE_BUFFER_GET is used to get the event buffer pointer, and should not be used before the macro EVENT_HANDLE_BUFFER_DEFINE is used.
flagsToClearFlags to be clear.
Return values
KOSA_StatusSuccessThe flags were successfully cleared.
KOSA_StatusErrorAn incorrect parameter was passed.
osa_status_t OSA_EventWait ( osa_event_handle_t  eventHandle,
osa_event_flags_t  flagsToWait,
uint8_t  waitAll,
uint32_t  millisec,
osa_event_flags_t pSetFlags 
)

This function waits for a combination of flags to be set in an event object. Applications can wait for any/all bits to be set. Also this function could obtain the flags who wakeup the waiting task.

Parameters
eventHandleThe event handle. The macro EVENT_HANDLE_BUFFER_GET is used to get the event buffer pointer, and should not be used before the macro EVENT_HANDLE_BUFFER_DEFINE is used.
flagsToWaitFlags that to wait.
waitAllWait all flags or any flag to be set.
millisecThe maximum number of milliseconds to wait for the event. If the wait condition is not met, pass osaWaitForever_c will wait indefinitely, pass 0 will return KOSA_StatusTimeout immediately.
setFlagsFlags that wakeup the waiting task are obtained by this parameter.
Return values
KOSA_StatusSuccessThe wait condition met and function returns successfully.
KOSA_StatusTimeoutHas not met wait condition within timeout.
KOSA_StatusErrorAn incorrect parameter was passed.
Note
Please pay attention to the flags bit width, FreeRTOS uses the most significant 8 bis as control bits, so do not wait these bits while using FreeRTOS.
osa_status_t OSA_EventDestroy ( osa_event_handle_t  eventHandle)
Parameters
eventHandleThe event handle. The macro EVENT_HANDLE_BUFFER_GET is used to get the event buffer pointer, and should not be used before the macro EVENT_HANDLE_BUFFER_DEFINE is used.
Return values
KOSA_StatusSuccessThe event is successfully destroyed.
KOSA_StatusErrorEvent destruction failed.
osa_status_t OSA_MsgQCreate ( osa_msgq_handle_t  msgqHandle,
uint32_t  msgNo,
uint32_t  msgSize 
)

This function allocates memory for and initializes a message queue. Message queue elements are hardcoded as void*.

Parameters
msgqHandlePointer to a memory space of size #(OSA_MSGQ_HANDLE_SIZE + msgNo*msgSize) on bare-matel and #(OSA_MSGQ_HANDLE_SIZE) on FreeRTOS allocated by the caller, message queue handle. The handle should be 4 byte aligned, because unaligned access does not support on some devices. The macro MSGQ_HANDLE_BUFFER_GET is used to get the message buffer pointer, and should not be used before the macro MSGQ_HANDLE_BUFFER_DEFINE is used.
msgNo:number of messages the message queue should accommodate.
msgSize:size of a single message structure.
Return values
KOSA_StatusSuccessMessage queue successfully Create.
KOSA_StatusErrorMessage queue create failure.
osa_status_t OSA_MsgQPut ( osa_msgq_handle_t  msgqHandle,
osa_msg_handle_t  pMessage 
)

This function puts a message to the end of the message queue. If the queue is full, this function returns the KOSA_StatusError;

Parameters
msgqHandleMessage Queue handler. The macro MSGQ_HANDLE_BUFFER_GET is used to get the message buffer pointer, and should not be used before the macro MSGQ_HANDLE_BUFFER_DEFINE is used.
pMessagePointer to the message to be put into the queue.
Return values
KOSA_StatusSuccessMessage successfully put into the queue.
KOSA_StatusErrorThe queue was full or an invalid parameter was passed.
osa_status_t OSA_MsgQGet ( osa_msgq_handle_t  msgqHandle,
osa_msg_handle_t  pMessage,
uint32_t  millisec 
)

This function gets a message from the head of the message queue. If the queue is empty, timeout is used to wait.

Parameters
msgqHandleMessage Queue handler. The macro MSGQ_HANDLE_BUFFER_GET is used to get the message buffer pointer, and should not be used before the macro MSGQ_HANDLE_BUFFER_DEFINE is used.
pMessagePointer to a memory to save the message.
millisecThe number of milliseconds to wait for a message. If the queue is empty, pass osaWaitForever_c will wait indefinitely, pass 0 will return KOSA_StatusTimeout immediately.
Return values
KOSA_StatusSuccessMessage successfully obtained from the queue.
KOSA_StatusTimeoutThe queue remains empty after timeout.
KOSA_StatusErrorInvalid parameter.
osa_status_t OSA_MsgQDestroy ( osa_msgq_handle_t  msgqHandle)
Parameters
msgqHandleMessage Queue handler. The macro MSGQ_HANDLE_BUFFER_GET is used to get the message buffer pointer, and should not be used before the macro MSGQ_HANDLE_BUFFER_DEFINE is used.
Return values
KOSA_StatusSuccessThe queue was successfully destroyed.
KOSA_StatusErrorMessage queue destruction failed.
void OSA_TimeDelay ( uint32_t  millisec)
Parameters
millisecThe time in milliseconds to wait.
uint32_t OSA_TimeGetMsec ( void  )
Return values
currenttime in milliseconds
void OSA_InstallIntHandler ( uint32_t  IRQNumber,
void(*)(void)  handler 
)
Parameters
IRQNumberIRQ number of the interrupt.
handlerThe interrupt handler to install.