![]() |
WE310F5
39.00.000
|
This section describes the M2MB APIs to perform OS queue operations. More...
This section describes the M2MB APIs to perform OS queue operations.
#define BYTES_FOR_MSG | ( | type | ) | ( 4 * WORD32_FOR_MSG( type ) ) |
Definition at line 60 of file m2mb_os_q.h.
#define M2MB_OS_Q_INVALID 0 |
Definition at line 53 of file m2mb_os_q.h.
#define M2MB_OS_Q_INVALID_ATTR 0 |
Definition at line 54 of file m2mb_os_q.h.
#define m2mb_os_q_setAttrItem_ | ( | h, | |
args, | |||
... | |||
) | m2mb_os_q_setAttrItem( h, CMDS_ARGS( args ) ) |
Definition at line 73 of file m2mb_os_q.h.
#define M2MB_OS_Q_TX_PRIORITIZE 1 |
Definition at line 55 of file m2mb_os_q.h.
#define WORD32_FOR_MSG | ( | type | ) | ( ( sizeof( type ) % 4 ) == 0 ? sizeof( type ) / 4 : sizeof( type ) / 4 + 1 ) |
Definition at line 58 of file m2mb_os_q.h.
typedef struct M2MB_OS_Q_ATTR_HANDLE_TAG* M2MB_OS_Q_ATTR_HANDLE |
Definition at line 109 of file m2mb_os_q.h.
typedef struct M2MB_OS_Q_HANDLE_TAG* M2MB_OS_Q_HANDLE |
Definition at line 108 of file m2mb_os_q.h.
enum M2MB_OS_Q_SEL_CMD_E |
Definition at line 77 of file m2mb_os_q.h.
M2MB_OS_RESULT_E m2mb_os_q_clear | ( | M2MB_OS_Q_HANDLE | qHandle | ) |
Clear all messages from the queue.
This service deletes all messages stored in the specified message queue identified by its handle. If the queue is full, messages of all suspended tasks are discarded. Each suspended task is then resumed with a return status that indicates the message send was successful. If the queue is empty, this service does nothing.
[in] | qHandle | handle of queue to be clear |
Example
M2MB_OS_RESULT_E m2mb_os_q_deinit | ( | M2MB_OS_Q_HANDLE | qHandle | ) |
Message Queue Deinit or Deletion.
This service deletes the specified message queue. All tasks suspended waiting for a message from this queue are resumed with a return value egual to M2MB_OS_DELETED The resources will be released It is the application's responsibility to manage the memory area associated with the queue, which is available after this service completes, if qStart with M2MB_OS_Q_SEL_CMD_QSTART was specified. It is the application's responsibility to prevent use of a deleted queue.
[in] | qHandle | handle of the queue |
Example
M2MB_OS_RESULT_E m2mb_os_q_getItem | ( | M2MB_OS_Q_HANDLE | qHandle, |
M2MB_OS_Q_SEL_CMD_E | selCmd, | ||
MEM_W * | pOut, | ||
void * | pIn | ||
) |
Get specific properties of the queue.
This service retrieve value for specified parameter of the specified queue Selecting cmd, a parameter to be retrieved can be set To be used when queue is already created: its right use is under application responsibility
[in] | qHandle | handle of queue |
[in] | selCmd | Select parameter to be retrieved (see M2MB_OS_Q_SEL_CMD_E) |
[out] | pOut | pointer Output parameter got: its meaning depend on selCmd used See examples as general pointer it is set to UINT32 |
[in] | pIn | pointer to void general Parameter to be specified, if any, to get right output See examples If parameter is not needed, use NULL |
Example
M2MB_OS_RESULT_E m2mb_os_q_hptf | ( | M2MB_OS_Q_HANDLE | queueHandle | ) |
Prioritize queue suspension list Set HPTF: Highest Priority Task First to receive the message from queue (one shot)
This service set the task waiting for this queue which has currently highest priority, on the top of FIFO suspension list
[in] | queueHandle | handle of queue |
Example: Set highest priority task waiting on the queue, at the top of FIFO suspension list
M2MB_OS_RESULT_E m2mb_os_q_init | ( | M2MB_OS_Q_HANDLE * | pQHandle, |
M2MB_OS_Q_ATTR_HANDLE * | pQAttrHandle | ||
) |
Message Queue creation.
This service creates a message queue that is typically used for inter- task communication. The total number of messages is calculated from the specified message size and the total number of bytes in the queue. Specifies the size of each message in the queue. Message sizes range from 1 32-bit word to 16 32-bit words. Valid message size options are numerical values from 1 through 16, inclusive.
[out] | pQHandle | pointer to queue handle |
[in] | pQAttrHandle | pointer to queue attribute handle |
Allowed From Initialization and tasks Preemption Possible No
Example
M2MB_OS_RESULT_E m2mb_os_q_rx | ( | M2MB_OS_Q_HANDLE | qHandle, |
void * | pDest, | ||
UINT32 | timeoutTicks | ||
) |
Receive message from the queue.
This service retrieves a message from the specified message queue identified by its handle. The retrieved message is copied from the queue into the memory area specified by the destination pointer. That message is then removed from the queue.
[in] | qHandle | handle of queue |
[in] | pDest | pointer to destination where to copy the received message |
[in] | timeoutTicks | If timeout is specified and messages are not available on queue, task will be suspended for a maximum time of timeout ticks |
Example
M2MB_OS_RESULT_E m2mb_os_q_setAttrItem | ( | M2MB_OS_Q_ATTR_HANDLE * | pQAttrHandle, |
UINT8 | nCmds, | ||
... | |||
) |
Set specific attribute for queue creation.
This service set the attribute (or create it) to be used for queue creation Selecting cmd, a parameter to be set can be selected
[in] | pQAttrHandle | pointer to event attribute of event |
[in] | nCmds | number of commands to be issued at once |
[in] | ... | variable inputs, N cmds (see M2MB_OS_Q_SEL_CMD_E) followed by N arguments for their respective issued commands. CMDS(...) and CMDS_ARGS(...) macro can be used to better insert cmd and parameters and to better control right insertion |
Example
M2MB_OS_RESULT_E m2mb_os_q_setItem | ( | M2MB_OS_Q_HANDLE | qHandle, |
M2MB_OS_Q_SEL_CMD_E | selCmd, | ||
void * | pIn | ||
) |
Set specific properties of the queue.
This service set value for specified parameter of the specified queue if available Selecting cmd, a parameter to be set can be selected To be used when queue is already created: its right use is under application responsibility
[in] | qHandle | handle of queue |
[in] | selCmd | Select parameter to be set (see M2MB_OS_Q_SEL_CMD_E) |
[in] | pIn | pointer to value to be set. If a simple value, can be easily casted to (void*) e.g. int value -3 has to be passed, use (void*)-3 NULL if no value is needed |
Example
M2MB_OS_RESULT_E m2mb_os_q_tx | ( | M2MB_OS_Q_HANDLE | qHandle, |
void * | pSource, | ||
UINT32 | timeoutTicks, | ||
UINT8 | priority | ||
) |
Send message to the queue.
This service sends a message to the specified message queue identified by its handler. The sent message is copied to the queue from the memory area specified by the pSource pointer. If priority M2MB_OS_Q_TX_PRIORITIZE or a value higher then 0 is selected, the message is placed at the top of the queue, therefore first to be received
[in] | qHandle | handle of queue |
[in] | pSource | pointer of Source message to be sent in queue |
[in] | timeoutTicks | If timeout is specified and there is not room available on queue, task will be suspended for a maximum numbers of timeout ticks |
[in] | priority | with priority > 0 or M2MB_OS_Q_TX_PRIORITIZE the message is copied to the front of the queue from the memory area specified by the pSource pointer |
Example