MCUXpresso SDK API Reference Manual  Rev 2.12.1
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 OSA_PRIORITY_IDLE   (6)
 Priority setting for OSA. More...
 
#define osaWaitNone_c   ((uint32_t)(0))
 Constant to pass as timeout value in order to wait indefinitely. More...
 
#define OSA_SEMAPHORE_HANDLE_DEFINE(name)   uint32_t name[(OSA_SEM_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]
 Defines the semaphore handle. More...
 
#define OSA_MUTEX_HANDLE_DEFINE(name)   uint32_t name[(OSA_MUTEX_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]
 Defines the mutex handle. More...
 
#define OSA_EVENT_HANDLE_DEFINE(name)   uint32_t name[(OSA_EVENT_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]
 Defines the event handle. More...
 
#define OSA_MSGQ_HANDLE_DEFINE(name, numberOfMsgs, msgSize)   uint32_t name[((OSA_MSGQ_HANDLE_SIZE + numberOfMsgs * msgSize) + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]
 Defines the message queue handle. More...
 
#define OSA_TASK_HANDLE_DEFINE(name)   uint32_t name[(OSA_TASK_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]
 Defines the TASK handle. 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_SemaphorePrecreate (osa_semaphore_handle_t semaphoreHandle, osa_task_ptr_t taskHandler)
 Initialize OSA. 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_SemaphoreCreateBinary (osa_semaphore_handle_t semaphoreHandle)
 Creates a binary semaphore. 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_EventPrecreate (osa_event_handle_t eventHandle, osa_task_ptr_t taskHandler)
 Pre-initializes an event object. 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_EventGet (osa_event_handle_t eventHandle, osa_event_flags_t flagsMask, osa_event_flags_t *pFlagsOfEvent)
 Get event's 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...
 
int OSA_MsgQAvailableMsgs (osa_msgq_handle_t msgqHandle)
 Get the available message. 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 OSA_PRIORITY_IDLE   (6)
#define osaWaitNone_c   ((uint32_t)(0))
#define OSA_SEMAPHORE_HANDLE_DEFINE (   name)    uint32_t name[(OSA_SEM_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]

This macro is used to define a 4 byte aligned semaphore handle. Then use "(osa_semaphore_handle_t)name" to get the semaphore handle.

The macro should be global and could be optional. You could also define semaphore handle by yourself.

This is an example,

* OSA_SEMAPHORE_HANDLE_DEFINE(semaphoreHandle);
*
Parameters
nameThe name string of the semaphore handle.
#define OSA_MUTEX_HANDLE_DEFINE (   name)    uint32_t name[(OSA_MUTEX_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]

This macro is used to define a 4 byte aligned mutex handle. Then use "(osa_mutex_handle_t)name" to get the mutex handle.

The macro should be global and could be optional. You could also define mutex handle by yourself.

This is an example,

* OSA_MUTEX_HANDLE_DEFINE(mutexHandle);
*
Parameters
nameThe name string of the mutex handle.
#define OSA_EVENT_HANDLE_DEFINE (   name)    uint32_t name[(OSA_EVENT_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]

This macro is used to define a 4 byte aligned event handle. Then use "(osa_event_handle_t)name" to get the event handle.

The macro should be global and could be optional. You could also define event handle by yourself.

This is an example,

* OSA_EVENT_HANDLE_DEFINE(eventHandle);
*
Parameters
nameThe name string of the event handle.
#define OSA_MSGQ_HANDLE_DEFINE (   name,
  numberOfMsgs,
  msgSize 
)    uint32_t name[((OSA_MSGQ_HANDLE_SIZE + numberOfMsgs * msgSize) + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]

This macro is used to define a 4 byte aligned message queue handle. Then use "(osa_msgq_handle_t)name" to get the message queue handle.

The macro should be global and could be optional. You could also define message queue handle by yourself.

This is an example,

* OSA_MSGQ_HANDLE_DEFINE(msgqHandle, 3, sizeof(msgStruct));
*
Parameters
nameThe name string of the message queue handle.
numberOfMsgsNumber of messages.
msgSizeMessage size.
#define OSA_TASK_HANDLE_DEFINE (   name)    uint32_t name[(OSA_TASK_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]

This macro is used to define a 4 byte aligned TASK handle. Then use "(osa_task_handle_t)name" to get the TASK handle.

The macro should be global and could be optional. You could also define TASK handle by yourself.

This is an example,

* OSA_TASK_HANDLE_DEFINE(taskHandle);
*
Parameters
nameThe name string of the TASK handle.

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_SemaphorePrecreate ( osa_semaphore_handle_t  semaphoreHandle,
osa_task_ptr_t  taskHandler 
)

This function is used to setup the basic services.

Example below shows how to use this API to create the task handle.

* OSA_Init();
*

Start OSA schedule.

This function is used to start OSA scheduler.

Example below shows how to use this API to start osa schedule.

* OSA_Start();
*

Creates a task.

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

Example below shows how to use this API to create the task handle.

* OSA_TASK_HANDLE_DEFINE(taskHandle);
* OSA_TASK_DEFINE( Job1, OSA_PRIORITY_HIGH, 1, 800, 0);
* OSA_TaskCreate((osa_task_handle_t)taskHandle, OSA_TASK(Job1), (osa_task_param_t)NULL);
*
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 doesn't be supported on some devices. You can define the handle in the following two ways: OSA_TASK_HANDLE_DEFINE(taskHandle); or uint32_t taskHandle[((OSA_TASK_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))];
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.

Gets the handler of active task.

Returns
Handler to current active task.

Puts the active task to the end of scheduler's queue.

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.

Gets the priority of a task.

Parameters
taskHandleThe handler of the task whose priority is received.
Returns
Task's priority.

Sets the priority of a task.

Parameters
taskHandleThe handler of the task whose priority is set.
taskPriorityThe priority to set.
Return values
KOSA_StatusSuccessTask's priority is set successfully.
KOSA_StatusErrorTask's priority can not be set.

Destroys a previously created task.

Parameters
taskHandleThe handler of the task to destroy.
Return values
KOSA_StatusSuccessThe task was successfully destroyed.
KOSA_StatusErrorTask destruction failed or invalid parameter.

Pre-creates a semaphore.

This function pre-creates a semaphore with the task handler.

Example below shows how to use this API to create the semaphore handle.

* OSA_SEMAPHORE_HANDLE_DEFINE(semaphoreHandle);
* OSA_SemaphoreCreate((osa_semaphore_handle_t)semaphoreHandle, (osa_task_ptr_t)taskHandler);
*
Parameters
semaphoreHandlePointer to a memory space of size OSA_SEM_HANDLE_SIZE allocated by the caller. The handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. You can define the handle in the following two ways: OSA_SEMAPHORE_HANDLE_DEFINE(semaphoreHandle); or uint32_t semaphoreHandle[((OSA_SEM_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))];
taskHandlertaskHandler The task handler this event is used by.
Return values
KOSA_StatusSuccessthe new semaphore if the semaphore is created successfully.
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.

Example below shows how to use this API to create the semaphore handle.

* OSA_SEMAPHORE_HANDLE_DEFINE(semaphoreHandle);
* OSA_SemaphoreCreate((osa_semaphore_handle_t)semaphoreHandle, 0xff);
*
Parameters
semaphoreHandlePointer to a memory space of size OSA_SEM_HANDLE_SIZE allocated by the caller. The handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. You can define the handle in the following two ways: OSA_SEMAPHORE_HANDLE_DEFINE(semaphoreHandle); or uint32_t semaphoreHandle[((OSA_SEM_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))];
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_SemaphoreCreateBinary ( osa_semaphore_handle_t  semaphoreHandle)

This function creates a binary semaphore

Example below shows how to use this API to create the semaphore handle.

Parameters
semaphoreHandlePointer to a memory space of size OSA_SEM_HANDLE_SIZE allocated by the caller. The handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. You can define the handle in the following two ways: OSA_SEMAPHORE_HANDLE_DEFINE(semaphoreHandle); or uint32_t semaphoreHandle[((OSA_SEM_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))];
Return values
KOSA_StatusSuccessthe new binary semaphore if the binary semaphore is created successfully.
KOSA_StatusErrorif the binary 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.
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.
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.

Example below shows how to use this API to create the mutex handle.

* OSA_MUTEX_HANDLE_DEFINE(mutexHandle);
*
Parameters
mutexHandlePointer to a memory space of size OSA_MUTEX_HANDLE_SIZE allocated by the caller. The handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. You can define the handle in the following two ways: OSA_MUTEX_HANDLE_DEFINE(mutexHandle); or uint32_t mutexHandle[((OSA_MUTEX_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))];
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.
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.
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.
Return values
KOSA_StatusSuccessThe mutex is successfully destroyed.
KOSA_StatusErrorThe mutex can not be destroyed.
osa_status_t OSA_EventPrecreate ( osa_event_handle_t  eventHandle,
osa_task_ptr_t  taskHandler 
)

This function pre-creates an event object and indicates which task this event is used by.

Example below shows how to use this API to create the event handle.

* OSA_EVENT_HANDLE_DEFINE(eventHandle);
*
Parameters
eventHandlePointer to a memory space of size OSA_EVENT_HANDLE_SIZE allocated by the caller. The handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. You can define the handle in the following two ways: OSA_EVENT_HANDLE_DEFINE(eventHandle); or uint32 eventHandle[((OSA_EVENT_HANDLE_SIZE + sizeof(uint32) - 1U) / sizeof(uint32))];
taskHandlerThe task handler this event is used by.
Return values
KOSA_StatusSuccessthe new event if the event is pre-created successfully.
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 1, when a task gets the event flags, these flags will be cleared automatically. Otherwise these flags must be cleared manually.

Example below shows how to use this API to create the event handle.

* OSA_EVENT_HANDLE_DEFINE(eventHandle);
*
Parameters
eventHandlePointer to a memory space of size OSA_EVENT_HANDLE_SIZE allocated by the caller. The handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. You can define the handle in the following two ways: OSA_EVENT_HANDLE_DEFINE(eventHandle); or uint32_t eventHandle[((OSA_EVENT_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))];
autoClear1 The event is auto-clear. 0 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.
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.
flagsToClearFlags to be clear.
Return values
KOSA_StatusSuccessThe flags were successfully cleared.
KOSA_StatusErrorAn incorrect parameter was passed.
osa_status_t OSA_EventGet ( osa_event_handle_t  eventHandle,
osa_event_flags_t  flagsMask,
osa_event_flags_t pFlagsOfEvent 
)

Get 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.
flagsMaskThe flags user want to get are specified by this parameter.
pFlagsOfEventThe event flags are obtained by this parameter.
Return values
KOSA_StatusSuccessThe event flags were successfully got.
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.
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.
pSetFlagsFlags 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.
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*.

Example below shows how to use this API to create the massage queue handle.

* OSA_MSGQ_HANDLE_DEFINE(msgqHandle);
* OSA_MsgQCreate((osa_msgq_handle_t)msgqHandle, 5U, sizeof(msg));
*
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 doesn't be supported on some devices. You can define the handle in the following two ways: OSA_MSGQ_HANDLE_DEFINE(msgqHandle); or For bm: uint32_t msgqHandle[((OSA_MSGQ_HANDLE_SIZE + msgNo*msgSize + sizeof(uint32_t) - 1U) / sizeof(uint32_t))]; For freertos: uint32_t msgqHandle[((OSA_MSGQ_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))];
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.
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.
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.
int OSA_MsgQAvailableMsgs ( osa_msgq_handle_t  msgqHandle)

This function is used to get the available message.

Parameters
msgqHandleMessage Queue handler.
Returns
Available message count
osa_status_t OSA_MsgQDestroy ( osa_msgq_handle_t  msgqHandle)
Parameters
msgqHandleMessage Queue handler.
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.