Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

triceDefaultConfig.h 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. /*!
  2. * \file triceDefaultConfig.h
  3. \author Thomas.Hoehenleitner [at] seerose.net
  4. * *****************************************************************************
  5. */
  6. #ifndef TRICE_DEFAULT_CONFIG_H_
  7. #define TRICE_DEFAULT_CONFIG_H_
  8. #ifdef __cplusplus
  9. extern "C"
  10. {
  11. #endif
  12. #ifndef TRICE_CLEAN
  13. // TRICE_CLEAN, when found in triceConfig.h is set to 0 with command "trice insert".
  14. // and set to 1 with command "trice clean" to get rid of
  15. // potential editor warnings in the trice clean state.
  16. #define TRICE_CLEAN 0
  17. #endif
  18. #ifndef TRICE_OFF
  19. // TRICE_OFF, when defined to 1 earlier than including trice.h disables trice code for the file.
  20. // When defined in the project settings, it influences the whole trice code generation.
  21. #define TRICE_OFF 0
  22. #endif
  23. #ifndef TRICE_UARTA_MIN_ID
  24. #define TRICE_UARTA_MIN_ID 0 //!< TRICE_UARTA_MIN_ID, if > 0, is the smalles ID routed to UARTA.
  25. #endif
  26. #ifndef TRICE_UARTA_MAX_ID
  27. #define TRICE_UARTA_MAX_ID 0 //!< TRICE_UARTA_MAX_ID, if > 0, is the largest ID routed to UARTA.
  28. #endif
  29. #ifndef TRICE_UARTB_MIN_ID
  30. #define TRICE_UARTB_MIN_ID 0 //!< TRICE_UARTB_MIN_ID, if > 0, is the smalles ID routed to UARTB.
  31. #endif
  32. #ifndef TRICE_UARTB_MAX_ID
  33. #define TRICE_UARTB_MAX_ID 0 //!< TRICE_UARTB_MAX_ID, if > 0, is the largest ID routed to UARTA.
  34. #endif
  35. #ifndef TRICE_DEFERRED_UARTA
  36. #define TRICE_DEFERRED_UARTA 0 //!< TRICE_DEFERRED_UARTA enables a user defined deferred trice write over TRICE_UARTA.
  37. #endif
  38. #ifndef TRICE_DEFERRED_UARTB
  39. #define TRICE_DEFERRED_UARTB 0 //!< TRICE_DEFERRED_UARTB enables a user defined deferred trice write over TRICE_UARTB.
  40. #endif
  41. #ifndef TRICE_DIRECT_AUXILIARY8
  42. #define TRICE_DIRECT_AUXILIARY8 0 //!< TRICE_DIRECT_AUXILIARY8 enables a user defined direct trice write.
  43. #endif
  44. #ifndef TRICE_DEFERRED_AUXILIARY8
  45. #define TRICE_DEFERRED_AUXILIARY8 0 //!< TRICE_DEFERRED_AUXILIARY8 enables a user defined deferred trice write.
  46. #endif
  47. #ifndef TRICE_DIRECT_AUXILIARY32
  48. #define TRICE_DIRECT_AUXILIARY32 0 //!< TRICE_DIRECT_AUXILIARY32 enables a user defineddirect trice write.
  49. #endif
  50. #ifndef TRICE_DEFERRED_AUXILIARY32
  51. #define TRICE_DEFERRED_AUXILIARY32 0 //!< TRICE_DEFERRED_AUXILIARY32 enables a user defined deferred trice write.
  52. #endif
  53. #ifndef TRICE_DIRECT_OUTPUT_IS_WITH_ROUTING
  54. //! TRICE_DIRECT_OUTPUT_IS_WITH_ROUTING allows to send an ID range of trices directly to an output.
  55. //! The called output function usually is executed inside an interrupt and should therefore be non-blocking and fast.
  56. #define TRICE_DIRECT_OUTPUT_IS_WITH_ROUTING 0
  57. #endif
  58. #ifndef TRICE_DEFERRED_OUTPUT_IS_WITH_ROUTING
  59. //! TRICE_DEFERRED_OUTPUT_IS_WITH_ROUTING allows to send an ID range of trices directly to an output.
  60. //! The called output function should be non-blocking.
  61. #define TRICE_DEFERRED_OUTPUT_IS_WITH_ROUTING 0
  62. #endif
  63. #ifndef TRICE_B
  64. //! TRICE_B is a shortcut for TRICE8_B, TRICE16_B, TRICE32_B or TRICE64_B usable in your project.
  65. #define TRICE_B TRICE8_B
  66. #endif
  67. #ifndef TRICE_F
  68. //! TRICE_F is a shortcut for TRICE8_F, TRICE16_F, TRICE32_F or TRICE64_F usable in your project.
  69. #define TRICE_F TRICE8_F
  70. #endif
  71. #ifndef TRICE_COMMAND_SIZE_MAX
  72. //! TRICE_COMMAND_SIZE_MAX is the length limit for command strings to target.
  73. #define TRICE_COMMAND_SIZE_MAX 8
  74. #endif
  75. #ifndef TRICE_DEFAULT_PARAMETER_BIT_WIDTH
  76. //! TRICE_DEFAULT_PARAMETER_BIT_WIDTH is the default parameter bit width for Trice macros not specifying the parameter bit width: 8, 16, 32 or 64.
  77. //! If for example the majority of your values is 16 bit, it makes sense to set this value to 16 to use Trice for them and to use Trice32 explicitely for 32-bit values.
  78. //! The trice tool CLI switch "-defaultTRICEBitwidth" needs to be set to the same bit width, default is 32.
  79. #define TRICE_DEFAULT_PARAMETER_BIT_WIDTH 32
  80. #endif
  81. #ifndef TRICE_CONFIG_WARNINGS
  82. #define TRICE_CONFIG_WARNINGS 1 //!< TRICE_CONFIG_WARNINGS == 0 can suppress some unwanted configuration warnings. Set to 0 only if you know what you are doing.
  83. #endif
  84. #ifndef TriceStamp16
  85. //! TriceStamp16 returns a 16-bit value to stamp `Id` TRICE and `Trice` macros. Usually it is a timestamp, but could also be a destination address or a counter for example.
  86. //! The user has to provide this value. Defining a macro here, instead of providing a function has significant speed impact.
  87. #define TriceStamp16 0xbe16
  88. #endif
  89. #ifndef TriceStamp32
  90. //! TriceStamp32 returns a 32-bit value to stamp `ID` TRICE and `TRice` macros. Usually it is a timestamp, but could also be a destination address or a counter for example.
  91. //! The user has to provide this value. Defining a macro here, instead of providing a function has significant speed impact.
  92. #define TriceStamp32 0xfeed3322
  93. #endif
  94. #ifndef TRICE_PROTECT
  95. //! The TRICE_PROTECT switch is only relevant for the deferred trice modes TRICE_DOUBLE_BUFFER and TRICE_RING_BUFFER.
  96. //! The trice library works well, when less data are produced in the average than transmittable and when in the double buffer case the TriceTransfer
  97. //! function is called, before too much data in a half buffer according to a good configuration. If that is guarantied you do not need to enable TRICE_PROTECT.
  98. //! If because of an potential error this is not guarantied, you should enable TRICE_PROTECT. This slows down the Trice macros a bit, but makes buffer overflows impossible.
  99. //! A ring buffer cannot overflow in a first assumption, because old, not yet transmitted, trices are overwritten by newer ones.
  100. //! But that can happen only to parts of trices. The ring buffer read out function relies on consistent data. If it gets data garbage, wrong values
  101. //! for the trice lengths are possible and buffer overruns not avoidable. When enabling TRICE_PROTECT, new trices are only written into the deferred buffer,
  102. //! if there is enough space. That guaranties data consistency. Because a suppressed trice cannot cause a cycle error, there is TriceOverflowCount as diagnostic value.
  103. //! Long story short: If you sure, not to produce too much data, than set TRICE_PROTECT to 0 and get a bit more speed.
  104. #define TRICE_PROTECT 1
  105. #endif
  106. #if !defined(TRICE_BUFFER) && !TRICE_OFF
  107. //! TRICE_BUFFER selects, where the Trice macros accumulate the trice data during a single Trice execution. Selectable options:
  108. //! - TRICE_STACK_BUFFER: No additional buffer is needed, what makes sense for single task systems with direct output only.
  109. //! - TRICE_STATIC_BUFFER: A single trice is stored in a separate static buffer, what makes sense for multi-tasking systems with direct output only.
  110. //! - TRICE_DOUBLE_BUFFER: Trice macros write direct into a double buffer without any additional management action.
  111. //! This is the fastest execution option for Trice macros but needs more RAM. Used for deferred output and optional additional direct output.
  112. //! - TRICE_RING_BUFFER: Trice macros write direct into a ring buffer without any additional management action.
  113. //! This is a fast but not the fastest execution option for Trice macros and needs less RAM. Used for deferred output and optional additional direct output.
  114. #error TRICE_BUFFER type not specified in triceConfig.h, please add "#define TRICE_BUFFER TRICE_RING_BUFFER" for example.
  115. #endif
  116. #ifndef TRICE_DEFERRED_TRANSFER_MODE
  117. //! TRICE_DEFERRED_TRANSFER_MODE is the selected deferred trice transfer method. Options:
  118. //! - TRICE_SINGLE_PACK_MODE packs each Trice message separately and adds a 0-delimiter byte. This increases the transmit byte count slightly. In case of a lost package only one Trice can get lost.
  119. //! - TRICE_MULTI_PACK_MODE packs several trice messages before adding a 0-delimiter byte. This reduces the transmit byte count. In case of a lost package several Trices can get lost.
  120. //! - When using encryption, the TRICE_MULTI_PACK_MODE can significantly reduce the transmit byte count, because in TRICE_SINGLE_PACK_MODE each Trice message gets extended
  121. //! with 1 to 7 padding bytes before encryption. TRICE_MULTI_PACK_MODE is not possible for TRICE_STACK_BUFFER and TRICE_STATIC_BUFFER (direct mode).
  122. #define TRICE_DEFERRED_TRANSFER_MODE TRICE_MULTI_PACK_MODE
  123. #endif
  124. #ifndef TRICE_RING_BUFFER_OVERFLOW_WATCH
  125. //! TRICE_RING_BUFFER_OVERFLOW_WATCH is used to investigate, if the ring buffer margins are really not touched.
  126. //! This value usually can stay 0.
  127. #define TRICE_RING_BUFFER_OVERFLOW_WATCH 0
  128. #endif
  129. #ifndef TRICE_DIRECT_OUTPUT
  130. //! TRICE_DIRECT_OUTPUT == 0: only deferred output, usually UART output only
  131. //! TRICE_DIRECT_OUTPUT == 1: with direct output, SEGGER_RTT output and/or TRICE_DIRECT_AUXILIARY8 output
  132. //! Setting TRICE_BUFFER to TRICE_STACK_BUFFER or TRICE_STATIC_BUFFER demands TRICE_DIRECT_OUTPUT == 1, no deferred output at all.
  133. //! When TRICE_BUFFER == TRICE_RING_BUFFER or TRICE_BUFFER == TRICE_DOUBLE_BUFFER for deferred output, additional direct output can be switched on here.
  134. //! For example it is possible to have direct 32-bit wise RTT TRICE_FRAMING_NONE output and deferred UART TRICE_FRAMING_TCOBS output.
  135. #define TRICE_DIRECT_OUTPUT 0
  136. #endif
  137. #ifndef TRICE_DEFERRED_OUTPUT
  138. //! TRICE_DEFERRED_OUTPUT == 0: no deferred output
  139. //! TRICE_DEFERRED_OUTPUT == 1: with deferred output, usually UART output and/or auxiliary output
  140. //! Setting TRICE_BUFFER to TRICE_RING_BUFFER or TRICE_DOUBLE_BUFFER demands TRICE_DEFERRED_OUTPUT == 1.
  141. //! TRICE_BUFFER == TRICE_STACK_BUFFER or TRICE_BUFFER == TRICE_STATIC_BUFFER needs TRICE_DEFERRED_OUTPUT == 0.
  142. //! When TRICE_BUFFER == TRICE_RING_BUFFER or TRICE_BUFFER == TRICE_DOUBLE_BUFFER for deferred output, additional direct output can be on.
  143. #define TRICE_DEFERRED_OUTPUT 0
  144. #endif
  145. #ifndef TRICE_DIRECT_OUTPUT_IS_WITH_ROUTING
  146. //! TRICE_DIRECT_OUTPUT_IS_WITH_ROUTING == 1 makes only sense, when TRICE_DIRECT_OUTPUT is 1.
  147. //! Enable this only, if you want only a specific ID range for direct Trice output.
  148. //! If you use different direct output channels, you can change this only for all together.
  149. #define TRICE_DIRECT_OUTPUT_IS_WITH_ROUTING 0 // (experimental)
  150. #endif
  151. #ifndef TRICE_DEFERRED_OUTPUT_IS_WITH_ROUTING
  152. //! TRICE_DEFERRED_OUTPUT_IS_WITH_ROUTING == 1 makes only sense, when TRICE_DEFERRED_OUTPUT is 1.
  153. //! Enable this only, if you want only a specific ID range for direct Trice output.
  154. //! If you use different direct output channels, you can change this only for all together.
  155. #define TRICE_DEFERRED_OUTPUT_IS_WITH_ROUTING 0 // (experimental)
  156. #endif
  157. #ifndef TRICE_DATA_OFFSET
  158. //! TRICE_DATA_OFFSET is the space in front of single trice data for in-buffer (T)COBS encoding.
  159. //! - When using real big buffers, 16 may be not enough.
  160. //! - When having only short trices but lots of trice bursts, it may make sense to reduce this value to 4.
  161. //! - Without encoding/framing this value can be 0.
  162. //! - When using XTEA, this value should incorporate additional 4 bytes, because of the 64-bit encryption units.
  163. //! With TRICE_BUFFER == TRICE_RING_BUFFER, this amount of space is allocated in front of the ring buffer.
  164. //! With TRICE_BUFFER == TRICE_DOUBLE_BUFFER, this amount of space is allocated once in front of each half buffer.
  165. //! Must be a multiple of 4. 64 is a _very_ safe value. In most cases you can reduce this to 16 or less.
  166. #define TRICE_DATA_OFFSET 64
  167. #endif
  168. #ifndef TRICE_SINGLE_MAX_SIZE
  169. //! TRICE_SINGLE_MAX_SIZE is used to truncate long runtime generated strings, to detect the need of a ring buffer wrap or to protect against overflow.
  170. //! It must be a multiple of 4 and ist max valid value is 32764.
  171. //! \li Be careful with this value: When using 12 64-bit values with a 32-bit stamp the trice size is 2(id) + 4(stamp) + 2(count) + 12*8(values) = 104 bytes.
  172. //! \li In direct mode, and also when you enabled TRICE_DEFERRED_SEGGER_RTT_8BIT_WRITE, this plus TRICE_DATA_OFFSET plus 4 is the max allocation size on the target
  173. //! stack with TRICE_BUFFER == TRICE_STACK_BUFFER.
  174. //! \li When short of memory and, for example, max 2 32-bit values with a 32-bit stamp are used, the max trice size is 2 + 4 + 2 + 2*4 = 16 bytes.
  175. //! \li When not using target timestamps and not more than one 32-bit or two 16-bit or four 8-bit values or using target timestamp without carried values, the TRICE_SINGLE_MAX_SIZE should be 8 bytes only.
  176. //! \li With a value < 104 automatically all then forbidden trices are disabled to avoid mistakes. This also reduces the needed flash size and compile time depending on the used compiler.
  177. //! \li Example: TRrice( "%d %d %d", 1, 2, 3)` would cause a compiler error with `#define TRICE_SINGLE_MAX_SIZE 16` then.
  178. //! \li When NOT using dynamic string or buffer transfer, bigger values than 104 make no sense here and just spoiling RAM.
  179. //! \li When USING dynamic string (or buffer) transfer, this value limits the max length of a trice. 2^15-4=32764 is the max possible value if you have enough RAM.
  180. //! According to TRICE_SINGLE_MAX_SIZE the Trice functions are enabled/disabled automatically.
  181. //! To force that manually, the user can for example `#define ENABLE_trice32fn_12 0` or `#define ENABLE_trice32fn_12 1` for all variations. See trice8.c trice16.c, ... .
  182. #define TRICE_SINGLE_MAX_SIZE 104
  183. #endif
  184. #if TRICE_SINGLE_MAX_SIZE & 3
  185. #error "TRICE_SINGLE_MAX_SIZE is not a multiple of 4"
  186. #endif
  187. #if TRICE_SINGLE_MAX_SIZE > 32764
  188. #error "TRICE_SINGLE_MAX_SIZE is too big"
  189. #endif
  190. #ifndef TRICE_DEFERRED_BUFFER_SIZE
  191. //! TRICE_DEFERRED_BUFFER_SIZE needs to be capable to hold trice bursts until they are transmitted and must be a multiple of 4.
  192. //! \li When TRICE_BUFFER == TRICE_STACK_BUFFER this value is not used.
  193. //! \li When TRICE_BUFFER == TRICE_STATIC_BUFFER this value is not used.
  194. //! \li When TRICE_BUFFER == TRICE_DOUBLE_BUFFER, this is the sum of both half buffers.
  195. //! \li When TRICE_BUFFER == TRICE_RING_BUFFER, this is the whole buffer.
  196. #define TRICE_DEFERRED_BUFFER_SIZE 1024
  197. #endif
  198. #ifndef TRICE_RING_BUFFER_SIZE
  199. //! TRICE_RING_BUFFER_SIZE is the ring buffer net size. Together with TRICE_DATA_OFFSET it is the TRICE_DEFERRED_BUFFER_SIZE.
  200. #define TRICE_RING_BUFFER_SIZE (TRICE_DEFERRED_BUFFER_SIZE - TRICE_DATA_OFFSET)
  201. #endif
  202. #ifndef TRICE_TRANSFER_ORDER_IS_BIG_ENDIAN
  203. //! Long story short: Whith big endian target MCUs simply apply the `-triceEndianness bigEndian` CLI switch when using the `trice log` command.
  204. //! Long story long:
  205. //! TRICE_TRANSFER_ORDER_IS_BIG_ENDIAN should have the same value as TRICE_MCU_IS_BIG_ENDIAN to avoid additional byte swapping code.
  206. //! It can be defined to 1 on little endian MCUs if the trice data are needed in network order for some reason.
  207. //! But that adds byte swapping code. This switch is mainly intended to be used for automated tests.
  208. //! The default transfer order is little endian as most targets are little endian machines.
  209. //! On big endian MCUs this value should be set to 1 to avoid additional byte swapping code, which increases the trice storage time and the needed code amount.
  210. //! For TRICE_TRANSFER_ORDER_IS_BIG_ENDIAN == 1, you need to apply the `-triceEndianness bigEndian` CLI switch when using the `trice log` command then.
  211. //! Please consider also the TRICE_MCU_IS_BIG_ENDIAN compiler switch in this context.
  212. #define TRICE_TRANSFER_ORDER_IS_BIG_ENDIAN TRICE_MCU_IS_BIG_ENDIAN
  213. #endif
  214. #ifndef TRICE_DIRECT_OUT_FRAMING
  215. //! TRICE_DIRECT_OUT_FRAMING defines the framing method of the binary trice data stream for direct output. Options:
  216. //! - TRICE_FRAMING_TCOBS: Recommended for internal transfer and trice tool visualization.
  217. //! - TRICE_FRAMING_COBS: The trice tool needs switch `-pf COBS`. Useful with XTEA or to decode the binary trice data with a user tool.
  218. //! - TRICE_FRAMING_NONE: The trice tool needs switch `-pf none`. TRICE_FRAMING_NONE is recommended for fast RTT (32-bit access).
  219. #define TRICE_DIRECT_OUT_FRAMING TRICE_FRAMING_NONE
  220. #endif
  221. #ifndef TRICE_DEFERRED_OUT_FRAMING
  222. //! TRICE_DEFERRED_OUT_FRAMING defines the framing method of the binary trice data stream for deferred output. Options:
  223. //! - TRICE_FRAMING_TCOBS: Recommended for UART transfer and trice tool visualization.
  224. //! - TRICE_FRAMING_COBS: The trice tool needs switch `-pf COBS`. Useful with XTEA or to decode the binary trice date with Python or an other language.
  225. //! - TRICE_FRAMING_NONE: The trice tool needs switch `-pf none`. This mode may be helpful if you write your own trice viewer without a decoder.
  226. #define TRICE_DEFERRED_OUT_FRAMING TRICE_FRAMING_TCOBS
  227. #endif
  228. #ifndef XTEA_ENCRYPT_KEY
  229. //! XTEA_ENCRYPT_KEY allows XTEA TriceEncryption with the key.
  230. //! To get your private XTEA_KEY, call just once "trice log -port ... -password YourSecret -showKey".
  231. //! The byte sequence you see then, copy and use it in your trice.Config.h file.
  232. //! YOu can user `-password MySecret` as Trice tool CLI switch with the default key.
  233. #define XTEA_ENCRYPT_KEY XTEA_KEY(ea, bb, ec, 6f, 31, 80, 4e, b9, 68, e2, fa, ea, ae, f1, 50, 54);
  234. #endif
  235. #ifndef XTEA_DECRYPT
  236. //! XTEA_DECRYPT, when defined, enables device local decryption. Usable for checks or if you use a trice reception capable node to read XTEA encrypted messages.
  237. //! One possible application is, receiving trices, decoding them, finding an ID match in a (from triceF generated) function pointer list and executing the dedicated function.
  238. //! This allows kind of RPC (without immediate return) also with encryption.
  239. #define XTEA_DECRYPT 0
  240. #endif
  241. #ifndef TRICE_DIRECT_XTEA_ENCRYPT
  242. //! TRICE_DIRECT_XTEA_ENCRYPT enables encryption for direct output. Encrypting direct output costs significant computing time in the time critical path!
  243. #define TRICE_DIRECT_XTEA_ENCRYPT 0
  244. #endif
  245. #ifndef TRICE_DEFERRED_XTEA_ENCRYPT
  246. //! TRICE_DEFERRED_XTEA_ENCRYPT enables encryption for deferred output.
  247. #define TRICE_DEFERRED_XTEA_ENCRYPT 0
  248. #endif
  249. #ifndef TRICE_DIAGNOSTICS
  250. //! With TRICE_DIAGNOSTICS == 0, additional trice diagnostics code is removed.
  251. //! During development TRICE_DIAGNOSTICS == 1 helps to optimize the trice buffer sizes.
  252. #define TRICE_DIAGNOSTICS 1
  253. #endif
  254. #ifndef TRICE_DIRECT_SEGGER_RTT_8BIT_WRITE
  255. //! TRICE_DIRECT_SEGGER_RTT_8BIT_WRITE==1 uses standard RTT transfer by using function SEGGER_RTT_WriteNoLock and needs ((TRICE_DIRECT_OUTPUT == 1).
  256. //! - This setting results in unframed RTT trice packages and requires the `-packageFraming none` switch for the appropriate trice tool instance.
  257. //! - Not that fast as with TRICE_SEGGER_RTT_32BIT_WRITE == 1 but still fast and uses pure SEGGER functionality only.
  258. #define TRICE_DIRECT_SEGGER_RTT_8BIT_WRITE 0
  259. #endif
  260. #ifndef TRICE_DIRECT_SEGGER_RTT_32BIT_WRITE
  261. //! TRICE_DIRECT_SEGGER_RTT_32BIT_WRITE == 1 speeds up RTT transfer by using function SEGGER_Write_RTT0_NoCheck32.
  262. //! - This setting results in unframed RTT trice packages and requires the `-packageFraming none` switch for the appropriate trice tool instance.
  263. //! This squeezes the whole Trice macro into about 100 processor clocks leaving the data already inside the SEGGER _acUpBuffer.
  264. //! - If you do not wish RTT, or wish RTT with framing, simply set this value to 0.
  265. //! - The trice tool CLI switch -d16 is needed too, because for alignment reasons the 16bit ID field is doubled for 16bit timestamp trice messages.
  266. #define TRICE_DIRECT_SEGGER_RTT_32BIT_WRITE 0
  267. #endif
  268. #ifndef TRICE_DEFERRED_SEGGER_RTT_8BIT_WRITE
  269. //! TRICE_DEFERRED_SEGGER_RTT_8BIT_WRITE == 1 enables channel number 0 for SeggerRTT usage. Only channel 0 works right now for some reason.
  270. //! Than the RTT trice packages can be framed according to the set TRICE_DIRECT_OUT_FRAMING.
  271. //! Not useable together with TRICE_DIRECT_SEGGER_RTT_32BIT_WRITE or TRICE_DIRECT_SEGGER_RTT_8BIT_WRITE
  272. //! Switch this on, if you wish deferred Segger RTT output. Usually RTT is used for direct mode only.
  273. #define TRICE_DEFERRED_SEGGER_RTT_8BIT_WRITE 0
  274. #endif
  275. #ifndef TRICE_DIRECT_AUXILIARY8
  276. //! TRICE_DIRECT_AUXILIARY8 enables a user defined direct trice 8bit char write.
  277. #define TRICE_DIRECT_AUXILIARY8 0
  278. #endif
  279. #ifndef TRICE_DIRECT_AUXILIARY32
  280. //! TRICE_DIRECT_AUXILIARY32 enables a user defined direct trice 32bit word write.
  281. #define TRICE_DIRECT_AUXILIARY32 0
  282. #endif
  283. #ifndef TRICE_DEFERRED_AUXILIARY8
  284. //! TRICE_DEFERRED_AUXILIARY8 enables a user defined deferred trice 8bit char write.
  285. #define TRICE_DEFERRED_AUXILIARY8 0
  286. #endif
  287. #ifndef TRICE_DEFERRED_AUXILIARY32
  288. //! TRICE_DEFERRED_AUXILIARY32 enables a user defined deferred trice 32bit word write.
  289. #define TRICE_DEFERRED_AUXILIARY32 0
  290. #endif
  291. #ifndef TRICE_CGO
  292. //! CGO interface for testing the target code with Go only, do not enable normally. Usage examples can be found in the trice/_test folder.
  293. #define TRICE_CGO 0
  294. #endif
  295. #ifndef TRICE_CYCLE_COUNTER
  296. //! TRICE_CYCLE_COUNTER adds a cycle counter to each trice message.
  297. //! If 0, do not add cycle counter. The Trice macros are a bit faster. Lost TRICEs are not detectable by the trice tool. The cycle counter byte ist statically 0xC0.
  298. //! If 1, add an 8-bit cycle counter. The Trice macros are a bit slower. Lost TRICEs are detectable by the trice tool. The cycle counter byte changes (recommended).
  299. #define TRICE_CYCLE_COUNTER 1
  300. #endif
  301. // Compiler Adaption:
  302. #ifndef USE_SEGGER_RTT_LOCK_UNLOCK_MACROS
  303. //! USE_SEGGER_RTT_LOCK_UNLOCK_MACROS == 1 includes SEGGER_RTT header files even SEGGER_RTT is not used. THis allows SEGGER code for critical sections.
  304. #define USE_SEGGER_RTT_LOCK_UNLOCK_MACROS 0
  305. #endif
  306. #ifndef TRICE_ENTER_CRITICAL_SECTION
  307. //! TRICE_ENTER_CRITICAL_SECTION saves interrupt state and disables Interrupts.
  308. //! If trices are used only outside critical sections or interrupts, you can leave this macro empty for more speed. Use only '{' in that case.
  309. //! Examples:
  310. //! \li #define TRICE_ENTER_CRITICAL_SECTION { SEGGER_RTT_LOCK() { - does the job for many compilers.
  311. //! \li #define TRICE_ENTER_CRITICAL_SECTION {
  312. //! \li #define TRICE_ENTER_CRITICAL_SECTION { uint32_t old_mask = cm_mask_interrupts(1); { // copied from test/OpenCM3_STM32F411_Nucleo/triceConfig.h
  313. //! \li #define TRICE_ENTER_CRITICAL_SECTION { uint32_t primaskstate = __get_PRIMASK(); __disable_irq(); {
  314. #define TRICE_ENTER_CRITICAL_SECTION {
  315. #endif
  316. #ifndef TRICE_LEAVE_CRITICAL_SECTION
  317. //! TRICE_LEAVE_CRITICAL_SECTION restores interrupt state.
  318. //! If trices are used only outside critical sections or interrupts, you can leave this macro empty for more speed. Use only '}' in that case.
  319. //! Examples:
  320. //! \li #define TRICE_LEAVE_CRITICAL_SECTION } SEGGER_RTT_UNLOCK() } - does the job for many compilers.
  321. //! \li #define TRICE_LEAVE_CRITICAL_SECTION }
  322. //! \li #define TRICE_LEAVE_CRITICAL_SECTION } cm_mask_interrupts(old_mask); } // copied from test/OpenCM3_STM32F411_Nucleo/triceConfig.h
  323. //! \li #define TRICE_LEAVE_CRITICAL_SECTION } __set_PRIMASK(primaskstate); }
  324. #define TRICE_LEAVE_CRITICAL_SECTION }
  325. #endif
  326. #ifndef TRICE_INLINE
  327. //! TRICE_INLINE is used for inlining trice code to be usable with any compiler. Define this value according to your compiler syntax.
  328. #define TRICE_INLINE static inline
  329. #endif
  330. // code space optimization
  331. #ifndef TRICE_8_BIT_SUPPORT
  332. //! TRICE_8_BIT_SUPPORT enables/disables all 8-bit Trice macros.
  333. #define TRICE_8_BIT_SUPPORT 1
  334. #endif
  335. #ifndef TRICE_16_BIT_SUPPORT
  336. //! TRICE_16_BIT_SUPPORT enables/disables all 16-bit Trice macros.
  337. #define TRICE_16_BIT_SUPPORT 1
  338. #endif
  339. #ifndef TRICE_32_BIT_SUPPORT
  340. //! TRICE_32_BIT_SUPPORT enables/disables all 32-bit Trice macros.
  341. #define TRICE_32_BIT_SUPPORT 1
  342. #endif
  343. #ifndef TRICE_64_BIT_SUPPORT
  344. //! TRICE_32_BIT_SUPPORT enables/disables all 64-bit Trice macros.
  345. #define TRICE_64_BIT_SUPPORT 1
  346. #endif
  347. ///////////////////////////////////////////////////////////////////////////////
  348. // Trice time measurement
  349. // The SYSTICKVAL is not needed by the Trice code. It is only used inside triceCheck.c as example value.
  350. // If your MCU is a not ARM Cortex-M one, simply define this value according your MCU, if you wish to use SYSTICKVAL.
  351. #ifndef SYSTICKVAL
  352. #if defined(__arm__) /* Defined by GNU C and RealView */ \
  353. || defined(__thumb__) /* Defined by GNU C and RealView in Thumb mode */ \
  354. || defined(_ARM) /* Defined by ImageCraft C */ \
  355. || defined(_M_ARM) /* Defined by Visual Studio */ \
  356. || defined(_M_ARMT) /* Defined by Visual Studio in Thumb mode */ \
  357. || defined(__arm) /* Defined by Diab */ \
  358. || defined(__ICCARM__) /* IAR */ \
  359. || defined(__CC_ARM) /* ARM's (RealView) compiler */ \
  360. || defined(__ARM__) /* TASKING VX ARM toolset C compiler */ \
  361. || defined(__CARM__) /* TASKING VX ARM toolset C compiler */ \
  362. || defined(__CPARM__) /* TASKING VX ARM toolset C++ compiler */
  363. //! ARM Cortex-M MCUs have this register.
  364. //! \li See https://developer.arm.com/documentation/dui0552/a/cortex-m3-peripherals/system-timer--systick
  365. //! This is only 16- or 24-bit wide and usually resetted each ms. Consider using DWT_CYCCNT if your MCU supports this.
  366. //! When using a 24-bit SYSTICKVAL as 16-bit target timestamp, be aware, that, for example, with a 100 MHz system clock, the
  367. //! SYSTICKVAL runs from 99 999 999 to 0 and you see just the lower 16 bit as time stamp, what may be confusing. With a
  368. //! 64 MHz clock, everything is fine, because 63999 is still a 16-bit value. When using DWT_CYCCNT on MCU clocks > 65 MHz,
  369. //! displaying only the lower 2 bytes is ok, because this 32-bit counter runs circular without being resetted.
  370. #define SYSTICKVAL (*(volatile uint32_t*)0xE000E018UL)
  371. #else
  372. #define SYSTICKVAL 0
  373. #endif
  374. #endif // #ifndef SYSTICKVAL
  375. //
  376. ///////////////////////////////////////////////////////////////////////////////
  377. ///////////////////////////////////////////////////////////////////////////////
  378. // These settings are overwriting the Trice relevant defaults in SEGGER_RTT_Conf.h.
  379. // To change, you should define them in your project specific triceConfig.h.
  380. // No separate copy of SEGGER_RTT_Conf.h is needed this way.
  381. // The BUFFER_SIZE_UP value is de-facto a TRICE_DIRECT_BUFFER_SIZE, if no direct auxilary output is used.
  382. #ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS
  383. #define SEGGER_RTT_MAX_NUM_UP_BUFFERS (1) // Max. number of up-buffers (T->H) available on this target
  384. #endif
  385. #ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS
  386. #define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (0) // Max. number of down-buffers (H->T) available on this target
  387. #endif
  388. #ifndef BUFFER_SIZE_UP
  389. #define BUFFER_SIZE_UP (1024) // "TRICE_DIRECT_BUFFER_SIZE"
  390. #endif
  391. #ifndef BUFFER_SIZE_DOWN
  392. #define BUFFER_SIZE_DOWN (0) // Size of the buffer for terminal input to target from host
  393. #endif
  394. #ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE
  395. #define SEGGER_RTT_PRINTF_BUFFER_SIZE (0u) // Size of buffer for RTT printf to bulk-send chars via RTT
  396. #endif
  397. //
  398. ///////////////////////////////////////////////////////////////////////////////
  399. #ifdef __cplusplus
  400. }
  401. #endif
  402. #endif /* TRICE_DEFAULT_CONFIG_H_ */