SEGGER_SYSVIEW_FreeRTOS.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. /*********************************************************************
  2. * SEGGER Microcontroller GmbH *
  3. * The Embedded Experts *
  4. **********************************************************************
  5. * *
  6. * (c) 1995 - 2021 SEGGER Microcontroller GmbH *
  7. * *
  8. * www.segger.com Support: support@segger.com *
  9. * *
  10. **********************************************************************
  11. * *
  12. * SEGGER SystemView * Real-time application analysis *
  13. * *
  14. **********************************************************************
  15. * *
  16. * All rights reserved. *
  17. * *
  18. * SEGGER strongly recommends to not make any changes *
  19. * to or modify the source code of this software in order to stay *
  20. * compatible with the SystemView and RTT protocol, and J-Link. *
  21. * *
  22. * Redistribution and use in source and binary forms, with or *
  23. * without modification, are permitted provided that the following *
  24. * condition is met: *
  25. * *
  26. * o Redistributions of source code must retain the above copyright *
  27. * notice, this condition and the following disclaimer. *
  28. * *
  29. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
  30. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
  31. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
  32. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
  33. * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
  34. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
  35. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
  36. * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
  37. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
  38. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
  39. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
  40. * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
  41. * DAMAGE. *
  42. * *
  43. **********************************************************************
  44. * *
  45. * SystemView version: 3.32 *
  46. * *
  47. **********************************************************************
  48. -------------------------- END-OF-HEADER -----------------------------
  49. File : SEGGER_SYSVIEW_FreeRTOS.h
  50. Purpose : Interface between FreeRTOS and SystemView.
  51. Tested with FreeRTOS V10.4.3
  52. Revision: $Rev: 7745 $
  53. Notes:
  54. (1) Include this file at the end of FreeRTOSConfig.h
  55. */
  56. #ifndef SYSVIEW_FREERTOS_H
  57. #define SYSVIEW_FREERTOS_H
  58. #include "SEGGER_SYSVIEW.h"
  59. /*********************************************************************
  60. *
  61. * Defines, configurable
  62. *
  63. **********************************************************************
  64. */
  65. #ifndef portSTACK_GROWTH
  66. #define portSTACK_GROWTH ( -1 )
  67. #endif
  68. #define SYSVIEW_FREERTOS_MAX_NOF_TASKS 8
  69. /*********************************************************************
  70. *
  71. * Defines, fixed
  72. *
  73. **********************************************************************
  74. */
  75. #define apiID_OFFSET (32u)
  76. #define apiID_VTASKALLOCATEMPUREGIONS (1u)
  77. #define apiID_VTASKDELETE (2u)
  78. #define apiID_VTASKDELAY (3u)
  79. #define apiID_VTASKDELAYUNTIL (4u)
  80. #define apiID_UXTASKPRIORITYGET (5u)
  81. #define apiID_UXTASKPRIORITYGETFROMISR (6u)
  82. #define apiID_ETASKGETSTATE (7u)
  83. #define apiID_VTASKPRIORITYSET (8u)
  84. #define apiID_VTASKSUSPEND (9u)
  85. #define apiID_VTASKRESUME (10u)
  86. #define apiID_XTASKRESUMEFROMISR (11u)
  87. #define apiID_VTASKSTARTSCHEDULER (12u)
  88. #define apiID_VTASKENDSCHEDULER (13u)
  89. #define apiID_VTASKSUSPENDALL (14u)
  90. #define apiID_XTASKRESUMEALL (15u)
  91. #define apiID_XTASKGETTICKCOUNT (16u)
  92. #define apiID_XTASKGETTICKCOUNTFROMISR (17u)
  93. #define apiID_UXTASKGETNUMBEROFTASKS (18u)
  94. #define apiID_PCTASKGETTASKNAME (19u)
  95. #define apiID_UXTASKGETSTACKHIGHWATERMARK (20u)
  96. #define apiID_VTASKSETAPPLICATIONTASKTAG (21u)
  97. #define apiID_XTASKGETAPPLICATIONTASKTAG (22u)
  98. #define apiID_VTASKSETTHREADLOCALSTORAGEPOINTER (23u)
  99. #define apiID_PVTASKGETTHREADLOCALSTORAGEPOINTER (24u)
  100. #define apiID_XTASKCALLAPPLICATIONTASKHOOK (25u)
  101. #define apiID_XTASKGETIDLETASKHANDLE (26u)
  102. #define apiID_UXTASKGETSYSTEMSTATE (27u)
  103. #define apiID_VTASKLIST (28u)
  104. #define apiID_VTASKGETRUNTIMESTATS (29u)
  105. #define apiID_XTASKGENERICNOTIFY (30u)
  106. #define apiID_XTASKGENERICNOTIFYFROMISR (31u)
  107. #define apiID_XTASKNOTIFYWAIT (32u)
  108. #define apiID_VTASKNOTIFYGIVEFROMISR (33u)
  109. #define apiID_ULTASKNOTIFYTAKE (34u)
  110. #define apiID_XTASKNOTIFYSTATECLEAR (35u)
  111. #define apiID_XTASKGETCURRENTTASKHANDLE (36u)
  112. #define apiID_VTASKSETTIMEOUTSTATE (37u)
  113. #define apiID_XTASKCHECKFORTIMEOUT (38u)
  114. #define apiID_VTASKMISSEDYIELD (39u)
  115. #define apiID_XTASKGETSCHEDULERSTATE (40u)
  116. #define apiID_VTASKPRIORITYINHERIT (41u)
  117. #define apiID_XTASKPRIORITYDISINHERIT (42u)
  118. #define apiID_XTASKGENERICCREATE (43u)
  119. #define apiID_UXTASKGETTASKNUMBER (44u)
  120. #define apiID_VTASKSETTASKNUMBER (45u)
  121. #define apiID_VTASKSTEPTICK (46u)
  122. #define apiID_ETASKCONFIRMSLEEPMODESTATUS (47u)
  123. #define apiID_XTIMERCREATE (48u)
  124. #define apiID_PVTIMERGETTIMERID (49u)
  125. #define apiID_VTIMERSETTIMERID (50u)
  126. #define apiID_XTIMERISTIMERACTIVE (51u)
  127. #define apiID_XTIMERGETTIMERDAEMONTASKHANDLE (52u)
  128. #define apiID_XTIMERPENDFUNCTIONCALLFROMISR (53u)
  129. #define apiID_XTIMERPENDFUNCTIONCALL (54u)
  130. #define apiID_PCTIMERGETTIMERNAME (55u)
  131. #define apiID_XTIMERCREATETIMERTASK (56u)
  132. #define apiID_XTIMERGENERICCOMMAND (57u)
  133. #define apiID_XQUEUEGENERICSEND (58u)
  134. #define apiID_XQUEUEPEEKFROMISR (59u)
  135. #define apiID_XQUEUEGENERICRECEIVE (60u)
  136. #define apiID_UXQUEUEMESSAGESWAITING (61u)
  137. #define apiID_UXQUEUESPACESAVAILABLE (62u)
  138. #define apiID_VQUEUEDELETE (63u)
  139. #define apiID_XQUEUEGENERICSENDFROMISR (64u)
  140. #define apiID_XQUEUEGIVEFROMISR (65u)
  141. #define apiID_XQUEUERECEIVEFROMISR (66u)
  142. #define apiID_XQUEUEISQUEUEEMPTYFROMISR (67u)
  143. #define apiID_XQUEUEISQUEUEFULLFROMISR (68u)
  144. #define apiID_UXQUEUEMESSAGESWAITINGFROMISR (69u)
  145. #define apiID_XQUEUEALTGENERICSEND (70u)
  146. #define apiID_XQUEUEALTGENERICRECEIVE (71u)
  147. #define apiID_XQUEUECRSENDFROMISR (72u)
  148. #define apiID_XQUEUECRRECEIVEFROMISR (73u)
  149. #define apiID_XQUEUECRSEND (74u)
  150. #define apiID_XQUEUECRRECEIVE (75u)
  151. #define apiID_XQUEUECREATEMUTEX (76u)
  152. #define apiID_XQUEUECREATECOUNTINGSEMAPHORE (77u)
  153. #define apiID_XQUEUEGETMUTEXHOLDER (78u)
  154. #define apiID_XQUEUETAKEMUTEXRECURSIVE (79u)
  155. #define apiID_XQUEUEGIVEMUTEXRECURSIVE (80u)
  156. #define apiID_VQUEUEADDTOREGISTRY (81u)
  157. #define apiID_VQUEUEUNREGISTERQUEUE (82u)
  158. #define apiID_XQUEUEGENERICCREATE (83u)
  159. #define apiID_XQUEUECREATESET (84u)
  160. #define apiID_XQUEUEADDTOSET (85u)
  161. #define apiID_XQUEUEREMOVEFROMSET (86u)
  162. #define apiID_XQUEUESELECTFROMSET (87u)
  163. #define apiID_XQUEUESELECTFROMSETFROMISR (88u)
  164. #define apiID_XQUEUEGENERICRESET (89u)
  165. #define apiID_VLISTINITIALISE (90u)
  166. #define apiID_VLISTINITIALISEITEM (91u)
  167. #define apiID_VLISTINSERT (92u)
  168. #define apiID_VLISTINSERTEND (93u)
  169. #define apiID_UXLISTREMOVE (94u)
  170. #define apiID_XEVENTGROUPCREATE (95u)
  171. #define apiID_XEVENTGROUPWAITBITS (96u)
  172. #define apiID_XEVENTGROUPCLEARBITS (97u)
  173. #define apiID_XEVENTGROUPCLEARBITSFROMISR (98u)
  174. #define apiID_XEVENTGROUPSETBITS (99u)
  175. #define apiID_XEVENTGROUPSETBITSFROMISR (100u)
  176. #define apiID_XEVENTGROUPSYNC (101u)
  177. #define apiID_XEVENTGROUPGETBITSFROMISR (102u)
  178. #define apiID_VEVENTGROUPDELETE (103u)
  179. #define apiID_UXEVENTGROUPGETNUMBER (104u)
  180. #define apiID_XSTREAMBUFFERCREATE (105u)
  181. #define apiID_VSTREAMBUFFERDELETE (106u)
  182. #define apiID_XSTREAMBUFFERRESET (107u)
  183. #define apiID_XSTREAMBUFFERSEND (108u)
  184. #define apiID_XSTREAMBUFFERSENDFROMISR (109u)
  185. #define apiID_XSTREAMBUFFERRECEIVE (110u)
  186. #define apiID_XSTREAMBUFFERRECEIVEFROMISR (111u)
  187. #define traceSTART() SEGGER_SYSVIEW_Conf()
  188. #define traceTASK_NOTIFY_TAKE(uxIndexToWait) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_ULTASKNOTIFYTAKE, xClearCountOnExit, xTicksToWait)
  189. #define traceTASK_DELAY() SEGGER_SYSVIEW_RecordU32 (apiID_OFFSET + apiID_VTASKDELAY, xTicksToDelay)
  190. #define traceTASK_DELAY_UNTIL(xTimeToWake) SEGGER_SYSVIEW_RecordVoid (apiID_OFFSET + apiID_VTASKDELAYUNTIL)
  191. #define traceTASK_NOTIFY_GIVE_FROM_ISR(uxIndexToNotify) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_VTASKNOTIFYGIVEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB), (U32)pxHigherPriorityTaskWoken)
  192. #define traceTASK_PRIORITY_INHERIT( pxTCB, uxPriority ) SEGGER_SYSVIEW_RecordU32 (apiID_OFFSET + apiID_VTASKPRIORITYINHERIT, (U32)pxMutexHolder)
  193. #define traceTASK_RESUME( pxTCB ) SEGGER_SYSVIEW_RecordU32 (apiID_OFFSET + apiID_VTASKRESUME, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB))
  194. #define traceINCREASE_TICK_COUNT( xTicksToJump ) SEGGER_SYSVIEW_RecordU32 (apiID_OFFSET + apiID_VTASKSTEPTICK, xTicksToJump)
  195. #define traceTASK_SUSPEND( pxTCB ) SEGGER_SYSVIEW_RecordU32 (apiID_OFFSET + apiID_VTASKSUSPEND, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB))
  196. #define traceTASK_PRIORITY_DISINHERIT( pxTCB, uxBasePriority ) SEGGER_SYSVIEW_RecordU32 (apiID_OFFSET + apiID_XTASKPRIORITYDISINHERIT, (U32)pxMutexHolder)
  197. #define traceTASK_RESUME_FROM_ISR( pxTCB ) SEGGER_SYSVIEW_RecordU32 (apiID_OFFSET + apiID_XTASKRESUMEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB))
  198. #define traceTASK_NOTIFY(uxIndexToNotify) SEGGER_SYSVIEW_RecordU32x4(apiID_OFFSET + apiID_XTASKGENERICNOTIFY, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB), ulValue, eAction, (U32)pulPreviousNotificationValue)
  199. #define traceTASK_NOTIFY_FROM_ISR(uxIndexToWait) SEGGER_SYSVIEW_RecordU32x5(apiID_OFFSET + apiID_XTASKGENERICNOTIFYFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB), ulValue, eAction, (U32)pulPreviousNotificationValue, (U32)pxHigherPriorityTaskWoken)
  200. #define traceTASK_NOTIFY_WAIT(uxIndexToWait) SEGGER_SYSVIEW_RecordU32x4(apiID_OFFSET + apiID_XTASKNOTIFYWAIT, ulBitsToClearOnEntry, ulBitsToClearOnExit, (U32)pulNotificationValue, xTicksToWait)
  201. #define traceQUEUE_CREATE( pxNewQueue ) SEGGER_SYSVIEW_RecordU32x3(apiID_OFFSET + apiID_XQUEUEGENERICCREATE, uxQueueLength, uxItemSize, ucQueueType)
  202. #define traceQUEUE_DELETE( pxQueue ) SEGGER_SYSVIEW_RecordU32 (apiID_OFFSET + apiID_VQUEUEDELETE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue))
  203. #define traceQUEUE_PEEK( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiID_OFFSET + apiID_XQUEUEGENERICRECEIVE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer), xTicksToWait, 1)
  204. #define traceQUEUE_PEEK_FROM_ISR( pxQueue ) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_XQUEUEPEEKFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer))
  205. #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue ) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_XQUEUEPEEKFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer))
  206. #define traceQUEUE_RECEIVE( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiID_OFFSET + apiID_XQUEUEGENERICRECEIVE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)0), xTicksToWait, 1)
  207. #define traceQUEUE_RECEIVE_FAILED( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiID_OFFSET + apiID_XQUEUEGENERICRECEIVE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)0), xTicksToWait, 1)
  208. #define traceQUEUE_SEMAPHORE_RECEIVE( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiID_OFFSET + apiID_XQUEUEGENERICRECEIVE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)0), xTicksToWait, 0)
  209. #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) SEGGER_SYSVIEW_RecordU32x3(apiID_OFFSET + apiID_XQUEUERECEIVEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer), (U32)pxHigherPriorityTaskWoken)
  210. #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) SEGGER_SYSVIEW_RecordU32x3(apiID_OFFSET + apiID_XQUEUERECEIVEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer), (U32)pxHigherPriorityTaskWoken)
  211. #define traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName ) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_VQUEUEADDTOREGISTRY, SEGGER_SYSVIEW_ShrinkId((U32)xQueue), (U32)pcQueueName)
  212. #if ( configUSE_QUEUE_SETS != 1 )
  213. #define traceQUEUE_SEND( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiID_OFFSET + apiID_XQUEUEGENERICSEND, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pvItemToQueue, xTicksToWait, xCopyPosition)
  214. #else
  215. #define traceQUEUE_SEND( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiID_OFFSET + apiID_XQUEUEGENERICSEND, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), 0u, 0u, xCopyPosition)
  216. #endif
  217. #define traceQUEUE_SEND_FAILED( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiID_OFFSET + apiID_XQUEUEGENERICSEND, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pvItemToQueue, xTicksToWait, xCopyPosition)
  218. #define traceQUEUE_SEND_FROM_ISR( pxQueue ) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_XQUEUEGENERICSENDFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pxHigherPriorityTaskWoken)
  219. #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_XQUEUEGENERICSENDFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pxHigherPriorityTaskWoken)
  220. #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_XSTREAMBUFFERCREATE, (U32)xIsMessageBuffer, (U32)pxStreamBuffer)
  221. #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_XSTREAMBUFFERCREATE, (U32)xIsMessageBuffer, 0u)
  222. #define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) SEGGER_SYSVIEW_RecordU32 (apiID_OFFSET + apiID_VSTREAMBUFFERDELETE, (U32)xStreamBuffer)
  223. #define traceSTREAM_BUFFER_RESET( xStreamBuffer ) SEGGER_SYSVIEW_RecordU32 (apiID_OFFSET + apiID_XSTREAMBUFFERRESET, (U32)xStreamBuffer)
  224. #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xBytesSent ) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_XSTREAMBUFFERSEND, (U32)xStreamBuffer, (U32)xBytesSent)
  225. #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_XSTREAMBUFFERSEND, (U32)xStreamBuffer, 0u)
  226. #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xBytesSent ) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_XSTREAMBUFFERSENDFROMISR, (U32)xStreamBuffer, (U32)xBytesSent)
  227. #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_XSTREAMBUFFERRECEIVE, (U32)xStreamBuffer, (U32)xReceivedLength)
  228. #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_XSTREAMBUFFERRECEIVE, (U32)xStreamBuffer, 0u)
  229. #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET + apiID_XSTREAMBUFFERRECEIVEFROMISR, (U32)xStreamBuffer, (U32)xReceivedLength)
  230. #define traceTASK_DELETE( pxTCB ) { \
  231. SEGGER_SYSVIEW_RecordU32(apiID_OFFSET + apiID_VTASKDELETE, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB)); \
  232. SYSVIEW_DeleteTask((U32)pxTCB); \
  233. }
  234. #if( portSTACK_GROWTH < 0 )
  235. #define traceTASK_CREATE(pxNewTCB) if (pxNewTCB != NULL) { \
  236. SEGGER_SYSVIEW_OnTaskCreate((U32)pxNewTCB); \
  237. SYSVIEW_AddTask((U32)pxNewTCB, \
  238. &(pxNewTCB->pcTaskName[0]), \
  239. pxNewTCB->uxPriority, \
  240. (U32)pxNewTCB->pxStack, \
  241. ((U32)pxNewTCB->pxTopOfStack - (U32)pxNewTCB->pxStack) \
  242. ); \
  243. }
  244. #else
  245. #define traceTASK_CREATE(pxNewTCB) if (pxNewTCB != NULL) { \
  246. SEGGER_SYSVIEW_OnTaskCreate((U32)pxNewTCB); \
  247. SYSVIEW_AddTask((U32)pxNewTCB, \
  248. &(pxNewTCB->pcTaskName[0]), \
  249. pxNewTCB->uxPriority, \
  250. (U32)pxNewTCB->pxStack, \
  251. (U32)(pxNewTCB->pxStack-pxNewTCB->pxTopOfStack) \
  252. ); \
  253. }
  254. #endif
  255. #define traceTASK_PRIORITY_SET(pxTask, uxNewPriority) { \
  256. SEGGER_SYSVIEW_RecordU32x2(apiID_OFFSET+apiID_VTASKPRIORITYSET, \
  257. SEGGER_SYSVIEW_ShrinkId((U32)pxTCB), \
  258. uxNewPriority \
  259. ); \
  260. SYSVIEW_UpdateTask((U32)pxTask, \
  261. &(pxTask->pcTaskName[0]), \
  262. uxNewPriority, \
  263. (U32)pxTask->pxStack, \
  264. 0 \
  265. ); \
  266. }
  267. //
  268. // Define INCLUDE_xTaskGetIdleTaskHandle as 1 in FreeRTOSConfig.h to allow identification of Idle state.
  269. //
  270. #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
  271. #define traceTASK_SWITCHED_IN() if(prvGetTCBFromHandle(NULL) == xIdleTaskHandle) { \
  272. SEGGER_SYSVIEW_OnIdle(); \
  273. } else { \
  274. SEGGER_SYSVIEW_OnTaskStartExec((U32)pxCurrentTCB); \
  275. }
  276. #else
  277. #define traceTASK_SWITCHED_IN() { \
  278. if (memcmp(pxCurrentTCB->pcTaskName, "IDLE", 5) != 0) { \
  279. SEGGER_SYSVIEW_OnTaskStartExec((U32)pxCurrentTCB); \
  280. } else { \
  281. SEGGER_SYSVIEW_OnIdle(); \
  282. } \
  283. }
  284. #endif
  285. #define traceMOVED_TASK_TO_READY_STATE(pxTCB) SEGGER_SYSVIEW_OnTaskStartReady((U32)pxTCB)
  286. #define traceREADDED_TASK_TO_READY_STATE(pxTCB)
  287. #define traceMOVED_TASK_TO_DELAYED_LIST() SEGGER_SYSVIEW_OnTaskStopReady((U32)pxCurrentTCB, (1u << 2))
  288. #define traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST() SEGGER_SYSVIEW_OnTaskStopReady((U32)pxCurrentTCB, (1u << 2))
  289. #define traceMOVED_TASK_TO_SUSPENDED_LIST(pxTCB) SEGGER_SYSVIEW_OnTaskStopReady((U32)pxTCB, ((3u << 3) | 3))
  290. #define traceISR_EXIT_TO_SCHEDULER() SEGGER_SYSVIEW_RecordExitISRToScheduler()
  291. #define traceISR_EXIT() SEGGER_SYSVIEW_RecordExitISR()
  292. #define traceISR_ENTER() SEGGER_SYSVIEW_RecordEnterISR()
  293. /*********************************************************************
  294. *
  295. * API functions
  296. *
  297. **********************************************************************
  298. */
  299. #ifdef __cplusplus
  300. extern "C" {
  301. #endif
  302. void SYSVIEW_AddTask (U32 xHandle, const char* pcTaskName, unsigned uxCurrentPriority, U32 pxStack, unsigned uStackHighWaterMark);
  303. void SYSVIEW_UpdateTask (U32 xHandle, const char* pcTaskName, unsigned uxCurrentPriority, U32 pxStack, unsigned uStackHighWaterMark);
  304. void SYSVIEW_DeleteTask (U32 xHandle);
  305. void SYSVIEW_SendTaskInfo (U32 TaskID, const char* sName, unsigned Prio, U32 StackBase, unsigned StackSize);
  306. #ifdef __cplusplus
  307. }
  308. #endif
  309. #endif
  310. /*************************** End of file ****************************/