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