m2mb API docs  25.20.008
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 #define m2mb_os_q_setAttrItem_( h, args... ) m2mb_os_q_setAttrItem( h, CMDS_ARGS( args ) )
53 
54 /* Global typedefs --------------------------------------------------------------- */
55 
56 typedef enum
57 {
58  M2MB_OS_Q_SEL_CMD_CREATE_ATTR,
59  M2MB_OS_Q_SEL_CMD_DEL_ATTR,
60  /* use as Os name: only available for creation */
61  M2MB_OS_Q_SEL_CMD_NAME,
62  /* if set, usr name could be different from Os used in creation */
63  M2MB_OS_Q_SEL_CMD_USRNAME,
64  /* size of message in 32 bit words: 1 to 16 max */
65  M2MB_OS_Q_SEL_CMD_MSG_SIZE,
66  /* if not specified will be allocated by system: if specified align to MEM_W
67  to avoid possible loosing space for 1 message
68  */
69  M2MB_OS_Q_SEL_CMD_QSTART,
70  /* size in byte */
71  M2MB_OS_Q_SEL_CMD_QSIZE,
72  /* number of task suspended on the queue */
73  M2MB_OS_Q_SEL_CMD_SUSPENDED_COUNT,
74  /* first task (M2MB_OS_TASK_HANDLE) to be served when msg will be enqueued */
75  M2MB_OS_Q_SEL_CMD_1ST_SUSP,
76  /* number of messages enqueued on the queue*/
77  M2MB_OS_Q_SEL_CMD_ENQUEUED,
78  /* number of messages the queue currently has space for */
79  M2MB_OS_Q_SEL_CMD_QROOM,
80 
81  /* ---- */
82  M2MB_OS_Q_SEL_CMD_END,
83  ENUM_TO_INT( M2MB_OS_Q_SEL_CMD_E )
84 } M2MB_OS_Q_SEL_CMD_E;
85 
86 
87 typedef struct M2MB_OS_Q_HANDLE_TAG *M2MB_OS_Q_HANDLE;
88 typedef struct M2MB_OS_Q_ATTR_HANDLE_TAG *M2MB_OS_Q_ATTR_HANDLE;
89 
90 /* Global functions =============================================================================*/
91 
92 /*-----------------------------------------------------------------------------------------------*/
231 /*-----------------------------------------------------------------------------------------------*/
232 M2MB_OS_RESULT_E m2mb_os_q_init( M2MB_OS_Q_HANDLE *pQHandle, M2MB_OS_Q_ATTR_HANDLE *pQAttrHandle );
233 
234 /*-----------------------------------------------------------------------------------------------*/
275 /*-----------------------------------------------------------------------------------------------*/
276 M2MB_OS_RESULT_E m2mb_os_q_deinit( M2MB_OS_Q_HANDLE qHandle );
277 
278 /*-----------------------------------------------------------------------------------------------*/
331 /*-----------------------------------------------------------------------------------------------*/
332 M2MB_OS_RESULT_E m2mb_os_q_rx( M2MB_OS_Q_HANDLE qHandle, void *pDest, UINT32 timeoutTicks );
333 
334 /*-----------------------------------------------------------------------------------------------*/
390 /*-----------------------------------------------------------------------------------------------*/
391 M2MB_OS_RESULT_E m2mb_os_q_tx(
392  M2MB_OS_Q_HANDLE qHandle,
393  void *pSource,
394  UINT32 timeoutTicks,
395  UINT8 priority
396 );
397 
398 /*-----------------------------------------------------------------------------------------------*/
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.