MCUXpresso SDK API Reference Manual
Rev 2.12.1
NXP Semiconductors
|
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... | |
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_t * | osThreadDefHandle |
pointer of thread define handle | |
uint32_t * | osThreadStackHandle |
pointer of thread stack handle | |
struct osa_time_def_t |
#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,
name | The 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,
name | The 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,
name | The 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,
name | The name string of the message queue handle. |
numberOfMsgs | Number of messages. |
msgSize | Message 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,
name | The name string of the TASK handle. |
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) |
enum osa_timer_t |
enum osa_status_t |
void* OSA_MemoryAllocate | ( | uint32_t | length | ) |
The function is used to reserve the requested amount of memory in bytes and initializes it to 0.
length | Amount of bytes to reserve. |
void OSA_MemoryFree | ( | void * | p | ) |
The function is used to free the memory block previously reserved.
p | Pointer to the start of the memory block previously reserved. |
void OSA_EnterCritical | ( | uint32_t * | sr | ) |
sr | Store current status and return to caller. |
void OSA_ExitCritical | ( | uint32_t | sr | ) |
sr | Previous 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.
Start OSA schedule.
This function is used to start OSA scheduler.
Example below shows how to use this API to start osa schedule.
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.
taskHandle | Pointer 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_def | pointer to theosa_task_def_t structure which defines the task. |
task_param | Pointer to be passed to the task when it is created. |
KOSA_StatusSuccess | The task is successfully created. |
KOSA_StatusError | The task can not be created. |
Gets the handler of 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.
KOSA_StatusSuccess | The function is called successfully. |
KOSA_StatusError | Error occurs with this function. |
Gets the priority of a task.
taskHandle | The handler of the task whose priority is received. |
Sets the priority of a task.
taskHandle | The handler of the task whose priority is set. |
taskPriority | The priority to set. |
KOSA_StatusSuccess | Task's priority is set successfully. |
KOSA_StatusError | Task's priority can not be set. |
Destroys a previously created task.
taskHandle | The handler of the task to destroy. |
KOSA_StatusSuccess | The task was successfully destroyed. |
KOSA_StatusError | Task 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.
semaphoreHandle | Pointer 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))]; |
taskHandler | taskHandler The task handler this event is used by. |
KOSA_StatusSuccess | the 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.
semaphoreHandle | Pointer 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))]; |
initValue | Initial value the semaphore will be set to. |
KOSA_StatusSuccess | the new semaphore if the semaphore is created successfully. |
KOSA_StatusError | if 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.
semaphoreHandle | Pointer 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))]; |
KOSA_StatusSuccess | the new binary semaphore if the binary semaphore is created successfully. |
KOSA_StatusError | if the binary semaphore can not be created. |
osa_status_t OSA_SemaphoreDestroy | ( | osa_semaphore_handle_t | semaphoreHandle | ) |
semaphoreHandle | The 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. |
KOSA_StatusSuccess | The semaphore is successfully destroyed. |
KOSA_StatusError | The 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.
semaphoreHandle | The semaphore handle. |
millisec | The maximum number of milliseconds to wait if semaphore is not positive. Pass osaWaitForever_c to wait indefinitely, pass 0 will return KOSA_StatusTimeout immediately. |
KOSA_StatusSuccess | The semaphore is received. |
KOSA_StatusTimeout | The semaphore is not received within the specified 'timeout'. |
KOSA_StatusError | An 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.
semaphoreHandle | The semaphore handle to signal. |
KOSA_StatusSuccess | The semaphore is successfully signaled. |
KOSA_StatusError | The 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.
mutexHandle | Pointer 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))]; |
KOSA_StatusSuccess | the new mutex if the mutex is created successfully. |
KOSA_StatusError | if 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.
mutexHandle | The mutex handle. |
millisec | The 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. |
KOSA_StatusSuccess | The mutex is locked successfully. |
KOSA_StatusTimeout | Timeout occurred. |
KOSA_StatusError | Incorrect parameter was passed. |
osa_status_t OSA_MutexUnlock | ( | osa_mutex_handle_t | mutexHandle | ) |
mutexHandle | The mutex handle. |
KOSA_StatusSuccess | The mutex is successfully unlocked. |
KOSA_StatusError | The mutex can not be unlocked or invalid parameter. |
osa_status_t OSA_MutexDestroy | ( | osa_mutex_handle_t | mutexHandle | ) |
mutexHandle | The mutex handle. |
KOSA_StatusSuccess | The mutex is successfully destroyed. |
KOSA_StatusError | The 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.
eventHandle | Pointer 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))]; |
taskHandler | The task handler this event is used by. |
KOSA_StatusSuccess | the 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.
eventHandle | Pointer 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))]; |
autoClear | 1 The event is auto-clear. 0 The event manual-clear |
KOSA_StatusSuccess | the new event if the event is created successfully. |
KOSA_StatusError | if 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.
eventHandle | The event handle. |
flagsToSet | Flags to be set. |
KOSA_StatusSuccess | The flags were successfully set. |
KOSA_StatusError | An 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.
eventHandle | The event handle. |
flagsToClear | Flags to be clear. |
KOSA_StatusSuccess | The flags were successfully cleared. |
KOSA_StatusError | An 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.
eventHandle | The 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. |
flagsMask | The flags user want to get are specified by this parameter. |
pFlagsOfEvent | The event flags are obtained by this parameter. |
KOSA_StatusSuccess | The event flags were successfully got. |
KOSA_StatusError | An 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.
eventHandle | The event handle. |
flagsToWait | Flags that to wait. |
waitAll | Wait all flags or any flag to be set. |
millisec | The 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. |
pSetFlags | Flags that wakeup the waiting task are obtained by this parameter. |
KOSA_StatusSuccess | The wait condition met and function returns successfully. |
KOSA_StatusTimeout | Has not met wait condition within timeout. |
KOSA_StatusError | An incorrect parameter was passed. |
osa_status_t OSA_EventDestroy | ( | osa_event_handle_t | eventHandle | ) |
eventHandle | The event handle. |
KOSA_StatusSuccess | The event is successfully destroyed. |
KOSA_StatusError | Event 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.
msgqHandle | Pointer 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. |
KOSA_StatusSuccess | Message queue successfully Create. |
KOSA_StatusError | Message 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;
msgqHandle | Message Queue handler. |
pMessage | Pointer to the message to be put into the queue. |
KOSA_StatusSuccess | Message successfully put into the queue. |
KOSA_StatusError | The 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.
msgqHandle | Message Queue handler. |
pMessage | Pointer to a memory to save the message. |
millisec | The 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. |
KOSA_StatusSuccess | Message successfully obtained from the queue. |
KOSA_StatusTimeout | The queue remains empty after timeout. |
KOSA_StatusError | Invalid parameter. |
int OSA_MsgQAvailableMsgs | ( | osa_msgq_handle_t | msgqHandle | ) |
This function is used to get the available message.
msgqHandle | Message Queue handler. |
osa_status_t OSA_MsgQDestroy | ( | osa_msgq_handle_t | msgqHandle | ) |
msgqHandle | Message Queue handler. |
KOSA_StatusSuccess | The queue was successfully destroyed. |
KOSA_StatusError | Message queue destruction failed. |
void OSA_TimeDelay | ( | uint32_t | millisec | ) |
millisec | The time in milliseconds to wait. |
uint32_t OSA_TimeGetMsec | ( | void | ) |
current | time in milliseconds |
void OSA_InstallIntHandler | ( | uint32_t | IRQNumber, |
void(*)(void) | handler | ||
) |
IRQNumber | IRQ number of the interrupt. |
handler | The interrupt handler to install. |