m2mb API docs  25.30.004.0
m2mb API sets documentation
m2mb_os_q.h
Go to the documentation of this file.
1 /* $version: 252203 */
2 /*===============================================================================================*/
3 /* >>> Copyright (C) Telit Communications S.p.A. Italy All Rights Reserved. <<< */
27 #ifndef M2MB_OS_Q_H
28 #define M2MB_OS_Q_H
29 
30 
31 
32 /* Global declarations ==========================================================================*/
33 #define M2MB_OS_Q_INVALID 0
34 #define M2MB_OS_Q_INVALID_ATTR 0
35 #define M2MB_OS_Q_TX_PRIORITIZE 1
36 
37 /* used to get how many word32 are needed for specified "type" struct : see M2MB_OS_Q_SEL_CMD_MSG_SIZE */
38 #define WORD32_FOR_MSG( type ) ( ( sizeof( type ) % 4 ) == 0 ? sizeof( type ) / 4 : sizeof( type ) / 4 + 1 )
39 /* then for decide how many bytes to reserve for any message in the queue : see M2MB_OS_Q_SEL_CMD_QSIZE */
40 #define BYTES_FOR_MSG( type ) ( 4 * WORD32_FOR_MSG( type ) )
41 
42 /*-----------------------------------------------------------------------------------------------
43 
44  can be called directly without specify CMDS_ARGS
45  osRes = m2mb_os_q_setAttrItem_( &qAttrHandle,
46  M2MB_OS_Q_SEL_CMD_CREATE_ATTR, NULL,
47  M2MB_OS_Q_SEL_CMD_NAME, "Myqueue_T",
48  M2MB_OS_Q_SEL_CMD_QSTART, &QueueArea,
49  M2MB_OS_Q_SEL_CMD_MSG_SIZE, WORD32_FOR_MSG( MY_MSG_T ),
50  M2MB_OS_Q_SEL_CMD_QSIZE, sizeof(QueueArea)
51  );
52  -----------------------------------------------------------------------------------------------*/
53 #ifdef _WIN32
54 #define m2mb_os_q_setAttrItem_( h, ... ) m2mb_os_q_setAttrItem( h, CMDS_ARGS( __VA_ARGS__ ) )
55 #else
56 #define m2mb_os_q_setAttrItem_( h, args... ) m2mb_os_q_setAttrItem( h, CMDS_ARGS( args ) )
57 #endif
58 
59 /* Global typedefs --------------------------------------------------------------- */
60 
61 typedef enum
62 {
63  M2MB_OS_Q_SEL_CMD_CREATE_ATTR,
64  M2MB_OS_Q_SEL_CMD_DEL_ATTR,
65  /* use as Os name: only available for creation */
66  M2MB_OS_Q_SEL_CMD_NAME,
67  /* if set, usr name could be different from Os used in creation */
68  M2MB_OS_Q_SEL_CMD_USRNAME,
69  /* size of message in 32 bit words: 1 to 16 max */
70  M2MB_OS_Q_SEL_CMD_MSG_SIZE,
71  /* if not specified will be allocated by system: if specified align to MEM_W
72  to avoid possible loosing space for 1 message
73  */
74  M2MB_OS_Q_SEL_CMD_QSTART,
75  /* size in byte */
76  M2MB_OS_Q_SEL_CMD_QSIZE,
77  /* number of task suspended on the queue */
78  M2MB_OS_Q_SEL_CMD_SUSPENDED_COUNT,
79  /* first task (M2MB_OS_TASK_HANDLE) to be served when msg will be enqueued */
80  M2MB_OS_Q_SEL_CMD_1ST_SUSP,
81  /* number of messages enqueued on the queue*/
82  M2MB_OS_Q_SEL_CMD_ENQUEUED,
83  /* number of messages the queue currently has space for */
84  M2MB_OS_Q_SEL_CMD_QROOM,
85 
86  /* ---- */
87  M2MB_OS_Q_SEL_CMD_END,
88  ENUM_TO_INT( M2MB_OS_Q_SEL_CMD_E )
89 } M2MB_OS_Q_SEL_CMD_E;
90 
91 
92 typedef struct M2MB_OS_Q_HANDLE_TAG *M2MB_OS_Q_HANDLE;
93 typedef struct M2MB_OS_Q_ATTR_HANDLE_TAG *M2MB_OS_Q_ATTR_HANDLE;
94 
95 /* Global functions =============================================================================*/
96 
97 /*-----------------------------------------------------------------------------------------------*/
236 /*-----------------------------------------------------------------------------------------------*/
237 M2MB_OS_RESULT_E m2mb_os_q_init( M2MB_OS_Q_HANDLE *pQHandle, M2MB_OS_Q_ATTR_HANDLE *pQAttrHandle );
238 
239 /*-----------------------------------------------------------------------------------------------*/
280 /*-----------------------------------------------------------------------------------------------*/
281 M2MB_OS_RESULT_E m2mb_os_q_deinit( M2MB_OS_Q_HANDLE qHandle );
282 
283 /*-----------------------------------------------------------------------------------------------*/
336 /*-----------------------------------------------------------------------------------------------*/
337 M2MB_OS_RESULT_E m2mb_os_q_rx( M2MB_OS_Q_HANDLE qHandle, void *pDest, UINT32 timeoutTicks );
338 
339 /*-----------------------------------------------------------------------------------------------*/
395 /*-----------------------------------------------------------------------------------------------*/
396 M2MB_OS_RESULT_E m2mb_os_q_tx(
397  M2MB_OS_Q_HANDLE qHandle,
398  void *pSource,
399  UINT32 timeoutTicks,
400  UINT8 priority
401 );
402 
403 /*-----------------------------------------------------------------------------------------------*/
444 /*-----------------------------------------------------------------------------------------------*/
445 M2MB_OS_RESULT_E m2mb_os_q_hptf( M2MB_OS_Q_HANDLE queueHandle );
446 
447 /*-----------------------------------------------------------------------------------------------*/
482 /*-----------------------------------------------------------------------------------------------*/
483 M2MB_OS_RESULT_E m2mb_os_q_clear( M2MB_OS_Q_HANDLE qHandle );
484 
485 /*-----------------------------------------------------------------------------------------------*/
561 /*-----------------------------------------------------------------------------------------------*/
562 M2MB_OS_RESULT_E m2mb_os_q_setAttrItem( M2MB_OS_Q_ATTR_HANDLE *pQAttrHandle, UINT8 nCmds, ... );
563 
564 /*-----------------------------------------------------------------------------------------------*/
626 /*-----------------------------------------------------------------------------------------------*/
627 M2MB_OS_RESULT_E m2mb_os_q_getItem(
628  M2MB_OS_Q_HANDLE qHandle,
629  M2MB_OS_Q_SEL_CMD_E selCmd,
630  MEM_W *pOut,
631  void *pIn
632 );
633 
634 /*-----------------------------------------------------------------------------------------------*/
676 /*-----------------------------------------------------------------------------------------------*/
677 M2MB_OS_RESULT_E m2mb_os_q_setItem(
678  M2MB_OS_Q_HANDLE qHandle,
679  M2MB_OS_Q_SEL_CMD_E selCmd,
680  void *pIn
681 );
682 
683 
684 
685 #endif /* M2MB_OS_H */
686 
m2mb_os_q_deinit
M2MB_OS_RESULT_E m2mb_os_q_deinit(M2MB_OS_Q_HANDLE qHandle)
Message Queue Deinit or Deletion.
m2mb_os_q_setItem
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.
m2mb_os_q_hptf
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 qu...
m2mb_os_q_tx
M2MB_OS_RESULT_E m2mb_os_q_tx(M2MB_OS_Q_HANDLE qHandle, void *pSource, UINT32 timeoutTicks, UINT8 priority)
Send message to the queue.
m2mb_os_q_rx
M2MB_OS_RESULT_E m2mb_os_q_rx(M2MB_OS_Q_HANDLE qHandle, void *pDest, UINT32 timeoutTicks)
Receive message from the queue.
m2mb_os_q_clear
M2MB_OS_RESULT_E m2mb_os_q_clear(M2MB_OS_Q_HANDLE qHandle)
Clear all messages from the queue.
m2mb_os_q_setAttrItem
M2MB_OS_RESULT_E m2mb_os_q_setAttrItem(M2MB_OS_Q_ATTR_HANDLE *pQAttrHandle, UINT8 nCmds,...)
Set specific attribute for queue creation.
m2mb_os_q_getItem
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.
m2mb_os_q_init
M2MB_OS_RESULT_E m2mb_os_q_init(M2MB_OS_Q_HANDLE *pQHandle, M2MB_OS_Q_ATTR_HANDLE *pQAttrHandle)
Message Queue creation.