qs_pkg.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. /*$file${include::qs_pkg.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
  2. /*
  3. * Model: qpc.qm
  4. * File: ${include::qs_pkg.h}
  5. *
  6. * This code has been generated by QM 5.2.5 <www.state-machine.com/qm>.
  7. * DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
  8. *
  9. * This code is covered by the following QP license:
  10. * License # : LicenseRef-QL-dual
  11. * Issued to : Any user of the QP/C real-time embedded framework
  12. * Framework(s) : qpc
  13. * Support ends : 2023-12-31
  14. * License scope:
  15. *
  16. * Copyright (C) 2005 Quantum Leaps, LLC <state-machine.com>.
  17. *
  18. * SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
  19. *
  20. * This software is dual-licensed under the terms of the open source GNU
  21. * General Public License version 3 (or any later version), or alternatively,
  22. * under the terms of one of the closed source Quantum Leaps commercial
  23. * licenses.
  24. *
  25. * The terms of the open source GNU General Public License version 3
  26. * can be found at: <www.gnu.org/licenses/gpl-3.0>
  27. *
  28. * The terms of the closed source Quantum Leaps commercial licenses
  29. * can be found at: <www.state-machine.com/licensing>
  30. *
  31. * Redistributions in source code must retain this top-level comment block.
  32. * Plagiarizing this software to sidestep the license obligations is illegal.
  33. *
  34. * Contact information:
  35. * <www.state-machine.com/licensing>
  36. * <info@state-machine.com>
  37. */
  38. /*$endhead${include::qs_pkg.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  39. /*! @file
  40. * @brief Internal (package scope) QS/C interface.
  41. */
  42. #ifndef QS_PKG_H_
  43. #define QS_PKG_H_
  44. /*==========================================================================*/
  45. /*! QS received record types (RX channel)
  46. * @details
  47. * This enumeration specifies the record types for the QS receive channel
  48. */
  49. enum QSpyRxRecords {
  50. QS_RX_INFO, /*!< query Target info (ver, config, tstamp) */
  51. QS_RX_COMMAND, /*!< execute a user-defined command in the Target */
  52. QS_RX_RESET, /*!< reset the Target */
  53. QS_RX_TICK, /*!< call QTIMEEVT_TICK_X() in the Target */
  54. QS_RX_PEEK, /*!< peek Target memory */
  55. QS_RX_POKE, /*!< poke Target memory */
  56. QS_RX_FILL, /*!< fill Target memory */
  57. QS_RX_TEST_SETUP, /*!< test setup */
  58. QS_RX_TEST_TEARDOWN, /*!< test teardown */
  59. QS_RX_TEST_PROBE, /*!< set a Test-Probe in the Target */
  60. QS_RX_GLB_FILTER, /*!< set global filters in the Target */
  61. QS_RX_LOC_FILTER, /*!< set local filters in the Target */
  62. QS_RX_AO_FILTER, /*!< set local AO filter in the Target */
  63. QS_RX_CURR_OBJ, /*!< set the "current-object" in the Target */
  64. QS_RX_TEST_CONTINUE, /*!< continue a test after QS_TEST_PAUSE() */
  65. QS_RX_QUERY_CURR, /*!< query the "current object" in the Target */
  66. QS_RX_EVENT /*!< inject an event to the Target */
  67. };
  68. /*==========================================================================*/
  69. /*! Frame character of the QS output protocol */
  70. #define QS_FRAME (0x7EU)
  71. /*! Escape character of the QS output protocol */
  72. #define QS_ESC (0x7DU)
  73. /*! The expected checksum value over a correct QS record */
  74. #define QS_GOOD_CHKSUM (0xFFU)
  75. /*! Escape modifier of the QS output protocol */
  76. /**
  77. * @details
  78. * The escaped byte is XOR-ed with the escape modifier before it is inserted
  79. * into the QS buffer.
  80. */
  81. #define QS_ESC_XOR (0x20U)
  82. /*==========================================================================*/
  83. /*! Internal QS macro to begin a predefined QS record with
  84. * entering critical section.
  85. *
  86. * @note This macro is intended to use only inside QP components and NOT
  87. * at the application level.
  88. * @sa QS_BEGIN_ID()
  89. */
  90. #define QS_BEGIN_PRE_(rec_, qs_id_) \
  91. if (QS_GLB_CHECK_(rec_) && QS_LOC_CHECK_(qs_id_)) { \
  92. QS_CRIT_E_(); \
  93. QS_beginRec_((uint_fast8_t)(rec_));
  94. /*! Internal QS macro to end a predefined QS record with
  95. * exiting critical section.
  96. *
  97. * @note This macro is intended to use only inside QP components and NOT
  98. * at the application level.
  99. * @sa QS_END()
  100. */
  101. #define QS_END_PRE_() \
  102. QS_endRec_(); \
  103. QS_CRIT_X_(); \
  104. }
  105. /*! Internal macro to begin a predefined QS record without
  106. * entering critical section.
  107. *
  108. * @note This macro is intended to use only inside QP components and NOT
  109. * at the application level.
  110. * @sa QS_BEGIN_NOCRIT()
  111. */
  112. #define QS_BEGIN_NOCRIT_PRE_(rec_, qs_id_) \
  113. if (QS_GLB_CHECK_(rec_) && QS_LOC_CHECK_(qs_id_)) { \
  114. QS_beginRec_((uint_fast8_t)(rec_));
  115. /*! Internal QS macro to end a predefined QS record without
  116. * exiting critical section
  117. *
  118. * @note This macro is intended to use only inside QP components and NOT
  119. * at the application level. @sa #QS_END_NOCRIT
  120. */
  121. #define QS_END_NOCRIT_PRE_() QS_endRec_(); }
  122. /*! Internal QS macro to output a predefined uint8_t data element */
  123. #define QS_U8_PRE_(data_) (QS_u8_raw_((uint8_t)(data_)))
  124. /*! Internal QS macro to output 2 predefined uint8_t data elements */
  125. #define QS_2U8_PRE_(data1_, data2_) \
  126. (QS_2u8_raw_((uint8_t)(data1_), (uint8_t)(data2_)))
  127. /*! Internal QS macro to output an predefined uint16_t data element */
  128. #define QS_U16_PRE_(data_) (QS_u16_raw_((uint16_t)(data_)))
  129. /*! Internal QS macro to output a predefined uint32_t data element */
  130. #define QS_U32_PRE_(data_) (QS_u32_raw_((uint32_t)(data_)))
  131. /*! Internal QS macro to output a predefined zero-terminated string element */
  132. #define QS_STR_PRE_(msg_) (QS_str_raw_((msg_)))
  133. #if (!defined Q_SIGNAL_SIZE || (Q_SIGNAL_SIZE == 1U))
  134. /*! Internal macro to output an unformatted event signal data element */
  135. /**
  136. * @note the size of the pointer depends on the macro #Q_SIGNAL_SIZE.
  137. */
  138. #define QS_SIG_PRE_(sig_) (QS_u8_raw_((uint8_t)sig_))
  139. #elif (Q_SIGNAL_SIZE == 2U)
  140. #define QS_SIG_PRE_(sig_) (QS_u16_raw_((uint16_t)sig_))
  141. #elif (Q_SIGNAL_SIZE == 4U)
  142. #define QS_SIG_PRE_(sig_) (QS_u32_raw_((uint32_t)sig_))
  143. #endif
  144. #define QS_OBJ_PRE_(obj_) (QS_obj_raw_(obj_))
  145. #if (!defined QS_FUN_PTR_SIZE || (QS_FUN_PTR_SIZE == 1U))
  146. #define QS_FUN_PRE_(fun_) (QS_u8_raw_((uint8_t)(fun_)))
  147. #elif (QS_FUN_PTR_SIZE == 2U)
  148. #define QS_FUN_PRE_(fun_) (QS_u16_raw_((uint16_t)(fun_)))
  149. #elif (QS_FUN_PTR_SIZE == 4U)
  150. #define QS_FUN_PRE_(fun_) (QS_u32_raw_((uint32_t)(fun_)))
  151. #elif (QS_FUN_PTR_SIZE == 8U)
  152. #define QS_FUN_PRE_(fun_) (QS_u64_raw_((uint64_t)(fun_)))
  153. #else
  154. /*! Internal macro to output an unformatted function pointer */
  155. /** @note the size of the pointer depends on the macro #QS_FUN_PTR_SIZE.
  156. * If the size is not defined the size of pointer is assumed 4-bytes.
  157. */
  158. #define QS_FUN_PRE_(fun_) (QS_u32_raw_((uint32_t)(fun_)))
  159. #endif
  160. /*==========================================================================*/
  161. #if (!defined QF_EQUEUE_CTR_SIZE || (QF_EQUEUE_CTR_SIZE == 1U))
  162. /*! Internal QS macro to output an unformatted event queue counter
  163. * data element. */
  164. /**
  165. * @note the counter size depends on the macro #QF_EQUEUE_CTR_SIZE.
  166. */
  167. #define QS_EQC_PRE_(ctr_) QS_u8_raw_((uint8_t)(ctr_))
  168. #elif (QF_EQUEUE_CTR_SIZE == 2U)
  169. #define QS_EQC_PRE_(ctr_) QS_u16_raw_((uint16_t)(ctr_))
  170. #elif (QF_EQUEUE_CTR_SIZE == 4U)
  171. #define QS_EQC_PRE_(ctr_) QS_u32_raw_((uint32_t)(ctr_))
  172. #endif
  173. #if (!defined QF_EVENT_SIZ_SIZE || (QF_EVENT_SIZ_SIZE == 1U))
  174. /*! Internal QS macro to output an unformatted event size
  175. * data element. */
  176. /**
  177. * @note the event size depends on the macro #QF_EVENT_SIZ_SIZE.
  178. */
  179. #define QS_EVS_PRE_(size_) QS_u8_raw_((uint8_t)(size_))
  180. #elif (QF_EVENT_SIZ_SIZE == 2U)
  181. #define QS_EVS_PRE_(size_) QS_u16_raw_((uint16_t)(size_))
  182. #elif (QF_EVENT_SIZ_SIZE == 4U)
  183. #define QS_EVS_PRE_(size_) QS_u32_raw_((uint32_t)(size_))
  184. #endif
  185. #if (!defined QF_MPOOL_SIZ_SIZE || (QF_MPOOL_SIZ_SIZE == 1U))
  186. /*! Internal QS macro to output an unformatted memory pool
  187. * block-size data element */
  188. /**
  189. * @note the block-size depends on the macro #QF_MPOOL_SIZ_SIZE.
  190. */
  191. #define QS_MPS_PRE_(size_) QS_u8_raw_((uint8_t)(size_))
  192. #elif (QF_MPOOL_SIZ_SIZE == 2U)
  193. #define QS_MPS_PRE_(size_) QS_u16_raw_((uint16_t)(size_))
  194. #elif (QF_MPOOL_SIZ_SIZE == 4U)
  195. #define QS_MPS_PRE_(size_) QS_u32_raw_((uint32_t)(size_))
  196. #endif
  197. #if (!defined QF_MPOOL_CTR_SIZE || (QF_MPOOL_CTR_SIZE == 1U))
  198. /*! Internal QS macro to output an unformatted memory pool
  199. * block-counter data element. */
  200. /**
  201. * @note the counter size depends on the macro #QF_MPOOL_CTR_SIZE.
  202. */
  203. #define QS_MPC_PRE_(ctr_) QS_u8_raw_((uint8_t)(ctr_))
  204. #elif (QF_MPOOL_CTR_SIZE == 2U)
  205. #define QS_MPC_PRE_(ctr_) QS_u16_raw_((uint16_t)(ctr_))
  206. #elif (QF_MPOOL_CTR_SIZE == 4U)
  207. #define QS_MPC_PRE_(ctr_) QS_u32_raw_((uint16_t)(ctr_))
  208. #endif
  209. #if (!defined QF_TIMEEVT_CTR_SIZE || (QF_TIMEEVT_CTR_SIZE == 1U))
  210. /*! Internal QS macro to output an unformatted time event
  211. * tick-counter data element */
  212. /**
  213. * @note the counter size depends on the macro #QF_TIMEEVT_CTR_SIZE.
  214. */
  215. #define QS_TEC_PRE_(ctr_) QS_u8_raw_((uint8_t)(ctr_))
  216. #elif (QF_TIMEEVT_CTR_SIZE == 2U)
  217. #define QS_TEC_PRE_(ctr_) QS_u16_raw_((uint16_t)(ctr_))
  218. #elif (QF_TIMEEVT_CTR_SIZE == 4U)
  219. #define QS_TEC_PRE_(ctr_) QS_u32_raw_((uint32_t)(ctr_))
  220. #endif
  221. /*==========================================================================*/
  222. /*! Internal QS macro to insert an un-escaped byte into the QS buffer */
  223. #define QS_INSERT_BYTE_(b_) \
  224. buf[head] = (b_); \
  225. ++head; \
  226. if (head == end) { \
  227. head = 0U; \
  228. }
  229. /*! Internal QS macro to insert an escaped byte into the QS buffer */
  230. #define QS_INSERT_ESC_BYTE_(b_) \
  231. chksum = (uint8_t)(chksum + (b_)); \
  232. if (((b_) != QS_FRAME) && ((b_) != QS_ESC)) { \
  233. QS_INSERT_BYTE_(b_) \
  234. } \
  235. else { \
  236. QS_INSERT_BYTE_(QS_ESC) \
  237. QS_INSERT_BYTE_((uint8_t)((b_) ^ QS_ESC_XOR))\
  238. ++QS_priv_.used; \
  239. }
  240. #endif /* QS_PKG_H_ */