1 /*********************************************************************
2 *                SEGGER Microcontroller GmbH & Co. KG                *
3 *                        The Embedded Experts                        *
4 **********************************************************************
5 *                                                                    *
6 *       (c) 2015 - 2017  SEGGER Microcontroller GmbH & Co. KG        *
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 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 * conditions are met:                                                *
25 *                                                                    *
26 * o Redistributions of source code must retain the above copyright   *
27 *   notice, this list of conditions and the following disclaimer.    *
28 *                                                                    *
29 * o Redistributions in binary form must reproduce the above          *
30 *   copyright notice, this list of conditions and the following      *
31 *   disclaimer in the documentation and/or other materials provided  *
32 *   with the distribution.                                           *
33 *                                                                    *
34 * o Neither the name of SEGGER Microcontroller GmbH & Co. KG         *
35 *   nor the names of its contributors may be used to endorse or      *
36 *   promote products derived from this software without specific     *
37 *   prior written permission.                                        *
38 *                                                                    *
39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND             *
40 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,        *
41 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF           *
42 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE           *
43 * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
44 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR           *
45 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  *
46 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;    *
47 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF      *
48 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT          *
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE  *
50 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH   *
51 * DAMAGE.                                                            *
52 *                                                                    *
53 **********************************************************************
54 *                                                                    *
55 *       SystemView version: V2.42                                    *
56 *                                                                    *
57 **********************************************************************
58 -------------------------- END-OF-HEADER -----------------------------
59 
60 File    : SEGGER_SYSVIEW_FreeRTOS.h
61 Purpose : Interface between FreeRTOS and SystemView.
62 Revision: $Rev: 3734 $
63 
64 Notes:
65   (1) Include this file at the end of FreeRTOSConfig.h
66 */
67 
68 #ifndef SYSVIEW_FREERTOS_H
69 #define SYSVIEW_FREERTOS_H
70 
71 #include "SEGGER_SYSVIEW.h"
72 
73 /*********************************************************************
74 *
75 *       Defines, configurable
76 *
77 **********************************************************************
78 */
79 
80 #define SYSVIEW_FREERTOS_MAX_NOF_TASKS  CONFIG_APPTRACE_SV_MAX_TASKS
81 
82 /*********************************************************************
83 *
84 *       Defines, fixed
85 *
86 **********************************************************************
87 */
88 
89 // for dual-core targets we use event ID to keep core ID bit (0 or 1)
90 // use the highest - 1 bit of event ID to indicate core ID
91 // the highest bit can not be used due to event ID encoding method
92 // this reduces supported ID range to [0..63] (for 1 byte IDs) plus [128..16383] (for 2 bytes IDs)
93 // so original continuous event IDs range is split into two sub-ranges for 1-bytes IDs and 2-bytes ones
94 
95 // events which use apiFastID_OFFSET will have 1 byte ID,
96 // so for the sake of bandwidth economy events which are generated more frequently should use this ID offset
97 // currently all used events fall into this range
98 #define apiFastID_OFFSET                          (32u)
99 
100 #define apiID_VTASKDELETE                         (1u)
101 #define apiID_VTASKDELAY                          (2u)
102 #define apiID_VTASKDELAYUNTIL                     (3u)
103 #define apiID_VTASKSUSPEND                        (4u)
104 #define apiID_ULTASKNOTIFYTAKE                    (5u)
105 #define apiID_VTASKNOTIFYGIVEFROMISR              (6u)
106 #define apiID_VTASKPRIORITYINHERIT                (7u)
107 #define apiID_VTASKRESUME                         (8u)
108 #define apiID_VTASKSTEPTICK                       (9u)
109 #define apiID_XTASKPRIORITYDISINHERIT             (10u)
110 #define apiID_XTASKRESUMEFROMISR                  (11u)
111 #define apiID_XTASKGENERICNOTIFY                  (12u)
112 #define apiID_XTASKGENERICNOTIFYFROMISR           (13u)
113 #define apiID_XTASKNOTIFYWAIT                     (14u)
114 #define apiID_XQUEUEGENERICCREATE                 (15u)
115 #define apiID_VQUEUEDELETE                        (16u)
116 #define apiID_XQUEUEGENERICRECEIVE                (17u)
117 #define apiID_XQUEUEPEEKFROMISR                   (18u)
118 #define apiID_XQUEUERECEIVEFROMISR                (19u)
119 #define apiID_VQUEUEADDTOREGISTRY                 (20u)
120 #define apiID_XQUEUEGENERICSEND                   (21u)
121 #define apiID_XQUEUEGENERICSENDFROMISR            (22u)
122 #define apiID_VTASKPRIORITYSET                    (23u)
123 #define apiID_UXTASKPRIORITYGETFROMISR            (24u)
124 #define apiID_XTASKGETTICKCOUNTFROMISR            (25u)
125 #define apiID_XEVENTGROUPCLEARBITSFROMISR         (26u)
126 #define apiID_XEVENTGROUPSETBITSFROMISR           (27u)
127 #define apiID_XEVENTGROUPGETBITSFROMISR           (28u)
128 #define apiID_XQUEUEGIVEFROMISR                   (29u)
129 #define apiID_XQUEUEISQUEUEEMPTYFROMISR           (30u)
130 #define apiID_XQUEUEISQUEUEFULLFROMISR            (31u) // the maximum allowed apiID for the first ID range
131 
132 // events which use apiSlowID_OFFSET will have 2-bytes ID
133 #define apiSlowID_OFFSET                          (127u)
134 
135 #define apiID_VTASKALLOCATEMPUREGIONS             (1u)
136 #define apiID_UXTASKPRIORITYGET                   (2u)
137 #define apiID_ETASKGETSTATE                       (3u)
138 #define apiID_VTASKSTARTSCHEDULER                 (4u)
139 #define apiID_VTASKENDSCHEDULER                   (5u)
140 #define apiID_VTASKSUSPENDALL                     (6u)
141 #define apiID_XTASKRESUMEALL                      (7u)
142 #define apiID_XTASKGETTICKCOUNT                   (8u)
143 #define apiID_UXTASKGETNUMBEROFTASKS              (9u)
144 #define apiID_PCTASKGETTASKNAME                   (10u)
145 #define apiID_UXTASKGETSTACKHIGHWATERMARK         (11u)
146 #define apiID_VTASKSETAPPLICATIONTASKTAG          (12u)
147 #define apiID_XTASKGETAPPLICATIONTASKTAG          (13u)
148 #define apiID_VTASKSETTHREADLOCALSTORAGEPOINTER   (14u)
149 #define apiID_PVTASKGETTHREADLOCALSTORAGEPOINTER  (15u)
150 #define apiID_XTASKCALLAPPLICATIONTASKHOOK        (16u)
151 #define apiID_XTASKGETIDLETASKHANDLE              (17u)
152 #define apiID_UXTASKGETSYSTEMSTATE                (18u)
153 #define apiID_VTASKLIST                           (19u)
154 #define apiID_VTASKGETRUNTIMESTATS                (20u)
155 #define apiID_XTASKNOTIFYSTATECLEAR               (21u)
156 #define apiID_XTASKGETCURRENTTASKHANDLE           (22u)
157 #define apiID_VTASKSETTIMEOUTSTATE                (23u)
158 #define apiID_XTASKCHECKFORTIMEOUT                (24u)
159 #define apiID_VTASKMISSEDYIELD                    (25u)
160 #define apiID_XTASKGETSCHEDULERSTATE              (26u)
161 #define apiID_XTASKGENERICCREATE                  (27u)
162 #define apiID_UXTASKGETTASKNUMBER                 (28u)
163 #define apiID_VTASKSETTASKNUMBER                  (29u)
164 #define apiID_ETASKCONFIRMSLEEPMODESTATUS         (30u)
165 #define apiID_XTIMERCREATE                        (31u)
166 #define apiID_PVTIMERGETTIMERID                   (32u)
167 #define apiID_VTIMERSETTIMERID                    (33u)
168 #define apiID_XTIMERISTIMERACTIVE                 (34u)
169 #define apiID_XTIMERGETTIMERDAEMONTASKHANDLE      (35u)
170 #define apiID_XTIMERPENDFUNCTIONCALLFROMISR       (36u)
171 #define apiID_XTIMERPENDFUNCTIONCALL              (37u)
172 #define apiID_PCTIMERGETTIMERNAME                 (38u)
173 #define apiID_XTIMERCREATETIMERTASK               (39u)
174 #define apiID_XTIMERGENERICCOMMAND                (40u)
175 #define apiID_UXQUEUEMESSAGESWAITING              (41u)
176 #define apiID_UXQUEUESPACESAVAILABLE              (42u)
177 #define apiID_UXQUEUEMESSAGESWAITINGFROMISR       (43u)
178 #define apiID_XQUEUEALTGENERICSEND                (44u)
179 #define apiID_XQUEUEALTGENERICRECEIVE             (45u)
180 #define apiID_XQUEUECRSENDFROMISR                 (46u)
181 #define apiID_XQUEUECRRECEIVEFROMISR              (47u)
182 #define apiID_XQUEUECRSEND                        (48u)
183 #define apiID_XQUEUECRRECEIVE                     (49u)
184 #define apiID_XQUEUECREATEMUTEX                   (50u)
185 #define apiID_XQUEUECREATECOUNTINGSEMAPHORE       (51u)
186 #define apiID_XQUEUEGETMUTEXHOLDER                (52u)
187 #define apiID_XQUEUETAKEMUTEXRECURSIVE            (53u)
188 #define apiID_XQUEUEGIVEMUTEXRECURSIVE            (54u)
189 #define apiID_VQUEUEUNREGISTERQUEUE               (55u)
190 #define apiID_XQUEUECREATESET                     (56u)
191 #define apiID_XQUEUEADDTOSET                      (57u)
192 #define apiID_XQUEUEREMOVEFROMSET                 (58u)
193 #define apiID_XQUEUESELECTFROMSET                 (59u)
194 #define apiID_XQUEUESELECTFROMSETFROMISR          (60u)
195 #define apiID_XQUEUEGENERICRESET                  (61u)
196 #define apiID_VLISTINITIALISE                     (62u)
197 #define apiID_VLISTINITIALISEITEM                 (63u)
198 #define apiID_VLISTINSERT                         (64u)
199 #define apiID_VLISTINSERTEND                      (65u)
200 #define apiID_UXLISTREMOVE                        (66u)
201 #define apiID_XEVENTGROUPCREATE                   (67u)
202 #define apiID_XEVENTGROUPWAITBITS                 (68u)
203 #define apiID_XEVENTGROUPCLEARBITS                (69u)
204 #define apiID_XEVENTGROUPSETBITS                  (70u)
205 #define apiID_XEVENTGROUPSYNC                     (71u)
206 #define apiID_VEVENTGROUPDELETE                   (72u)
207 #define apiID_UXEVENTGROUPGETNUMBER               (73u)
208 
209 #define traceTASK_NOTIFY_TAKE( uxIndexToWait )                        SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET + apiID_ULTASKNOTIFYTAKE, xClearCountOnExit, xTicksToWait)
210 #define traceTASK_DELAY()                                             SEGGER_SYSVIEW_RecordU32(apiFastID_OFFSET + apiID_VTASKDELAY, xTicksToDelay)
211 #define traceTASK_DELAY_UNTIL()                                       SEGGER_SYSVIEW_RecordVoid(apiFastID_OFFSET + apiID_VTASKDELAYUNTIL)
212 #define traceTASK_DELETE( pxTCB )                                     if (pxTCB != NULL) {                                              \
213 						                                                SEGGER_SYSVIEW_RecordU32(apiFastID_OFFSET + apiID_VTASKDELETE,  \
214 						                                                                      SEGGER_SYSVIEW_ShrinkId((U32)pxTCB)); 	\
215 					                                                    SYSVIEW_DeleteTask((U32)pxTCB);                                 \
216 					                                                  }
217 #define traceTASK_NOTIFY_GIVE_FROM_ISR( uxIndexToNotify )             SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET + apiID_VTASKNOTIFYGIVEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB), (U32)pxHigherPriorityTaskWoken)
218 #define traceTASK_PRIORITY_INHERIT( pxTCB, uxPriority )               SEGGER_SYSVIEW_RecordU32(apiFastID_OFFSET + apiID_VTASKPRIORITYINHERIT, (U32)pxMutexHolder)
219 #define traceTASK_RESUME( pxTCB )                                     SEGGER_SYSVIEW_RecordU32(apiFastID_OFFSET + apiID_VTASKRESUME, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB))
220 #define traceINCREASE_TICK_COUNT( xTicksToJump )                      SEGGER_SYSVIEW_RecordU32(apiFastID_OFFSET + apiID_VTASKSTEPTICK, xTicksToJump)
221 #define traceTASK_SUSPEND( pxTCB )                                    SEGGER_SYSVIEW_RecordU32(apiFastID_OFFSET + apiID_VTASKSUSPEND, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB))
222 #define traceTASK_PRIORITY_DISINHERIT( pxTCB, uxBasePriority )        SEGGER_SYSVIEW_RecordU32(apiFastID_OFFSET + apiID_XTASKPRIORITYDISINHERIT, (U32)pxMutexHolder)
223 #define traceTASK_RESUME_FROM_ISR( pxTCB )                            SEGGER_SYSVIEW_RecordU32(apiFastID_OFFSET + apiID_XTASKRESUMEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB))
224 #define traceTASK_NOTIFY( uxIndexToNotify )                           SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XTASKGENERICNOTIFY, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB), ulValue, eAction, (U32)pulPreviousNotificationValue)
225 #define traceTASK_NOTIFY_FROM_ISR( uxIndexToNotify )                  SYSVIEW_RecordU32x5(apiFastID_OFFSET + apiID_XTASKGENERICNOTIFYFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB), ulValue, eAction, (U32)pulPreviousNotificationValue, (U32)pxHigherPriorityTaskWoken)
226 #define traceTASK_NOTIFY_WAIT( uxIndexToWait )                        SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XTASKNOTIFYWAIT, ulBitsToClearOnEntry, ulBitsToClearOnExit, (U32)pulNotificationValue, xTicksToWait)
227 
228 #define traceQUEUE_CREATE( pxNewQueue )                               SEGGER_SYSVIEW_RecordU32x3(apiFastID_OFFSET + apiID_XQUEUEGENERICCREATE, uxQueueLength, uxItemSize, ucQueueType)
229 #define traceQUEUE_DELETE( pxQueue )                                  SEGGER_SYSVIEW_RecordU32(apiFastID_OFFSET + apiID_VQUEUEDELETE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue))
230 #define traceQUEUE_PEEK( pxQueue )                                    SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICRECEIVE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer), xTicksToWait, 0)
231 #define traceQUEUE_PEEK_FROM_ISR( pxQueue )                           SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET + apiID_XQUEUEPEEKFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer))
232 #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue )                    SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET + apiID_XQUEUEPEEKFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer))
233 #define traceQUEUE_RECEIVE( pxQueue )                                 SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICRECEIVE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)0), xTicksToWait, 1)
234 #define traceQUEUE_RECEIVE_FAILED( pxQueue )                          SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICRECEIVE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)0), xTicksToWait, 1)
235 #define traceQUEUE_SEMAPHORE_RECEIVE( pxQueue )                       SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICRECEIVE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)0), xTicksToWait, 0)
236 #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue )                        SEGGER_SYSVIEW_RecordU32x3(apiFastID_OFFSET + apiID_XQUEUERECEIVEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer), (U32)pxHigherPriorityTaskWoken)
237 #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue )                 SEGGER_SYSVIEW_RecordU32x3(apiFastID_OFFSET + apiID_XQUEUERECEIVEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer), (U32)pxHigherPriorityTaskWoken)
238 #define traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName )                SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET + apiID_VQUEUEADDTOREGISTRY, SEGGER_SYSVIEW_ShrinkId((U32)xQueue), (U32)pcQueueName)
239 #if ( configUSE_QUEUE_SETS != 1 )
240   #define traceQUEUE_SEND( pxQueue )                                    SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICSEND, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pvItemToQueue, xTicksToWait, xCopyPosition)
241 #else
242   #define traceQUEUE_SEND( pxQueue )                                    SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICSEND, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), 0, 0, xCopyPosition)
243 #endif
244 #define traceQUEUE_SEND_FAILED( pxQueue )                             SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICSEND, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pvItemToQueue, xTicksToWait, xCopyPosition)
245 #define traceQUEUE_SEND_FROM_ISR( pxQueue )                           SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICSENDFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pvItemToQueue, (U32)pxHigherPriorityTaskWoken, xCopyPosition)
246 #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue )                    SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICSENDFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pvItemToQueue, (U32)pxHigherPriorityTaskWoken, xCopyPosition)
247 #define traceQUEUE_GIVE_FROM_ISR( pxQueue )                           SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET + apiID_XQUEUEGIVEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pxHigherPriorityTaskWoken)
248 #define traceQUEUE_GIVE_FROM_ISR_FAILED( pxQueue )                    SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET + apiID_XQUEUEGIVEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pxHigherPriorityTaskWoken)
249 
250 #if( portSTACK_GROWTH < 0 )
251 #define traceTASK_CREATE(pxNewTCB)                  if (pxNewTCB != NULL) {                                             \
252                                                       SEGGER_SYSVIEW_OnTaskCreate((U32)pxNewTCB);                       \
253                                                       SYSVIEW_AddTask((U32)pxNewTCB,                                    \
254                                                                       &(pxNewTCB->pcTaskName[0]),                       \
255                                                                       pxNewTCB->uxPriority,                             \
256                                                                       (U32)pxNewTCB->pxStack,                           \
257                                                                       ((U32)pxNewTCB->pxTopOfStack - (U32)pxNewTCB->pxStack) \
258                                                                       );                                                \
259                                                     }
260 #else
261 #define traceTASK_CREATE(pxNewTCB)                  if (pxNewTCB != NULL) {                                             \
262                                                       SEGGER_SYSVIEW_OnTaskCreate((U32)pxNewTCB);                       \
263                                                       SYSVIEW_AddTask((U32)pxNewTCB,                                    \
264                                                                       &(pxNewTCB->pcTaskName[0]),                       \
265                                                                       pxNewTCB->uxPriority,                             \
266                                                                       (U32)pxNewTCB->pxStack,                           \
267                                                                       (U32)(pxNewTCB->pxStack-pxNewTCB->pxTopOfStack)   \
268                                                                       );                                                \
269                                                     }
270 #endif
271 #define traceTASK_PRIORITY_SET(pxTask, uxNewPriority) {                                                                 \
272                                                         SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET+apiID_VTASKPRIORITYSET, \
273                                                                                    SEGGER_SYSVIEW_ShrinkId((U32)pxTCB), \
274                                                                                    uxNewPriority                        \
275                                                                                   );                                    \
276                                                         SYSVIEW_UpdateTask((U32)pxTask,                                 \
277                                                                            &(pxTask->pcTaskName[0]),                    \
278                                                                            uxNewPriority,                               \
279                                                                            (U32)pxTask->pxStack,                        \
280                                                                            0                                            \
281                                                                           );                                            \
282                                                       }
283 //
284 // Define INCLUDE_xTaskGetIdleTaskHandle as 1 in FreeRTOSConfig.h to allow identification of Idle state.
285 //
286 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
287   #define traceTASK_SWITCHED_IN()                   if(prvGetTCBFromHandle(NULL) == xTaskGetIdleTaskHandle()) {           \
288                                                       SEGGER_SYSVIEW_OnIdle();                                          \
289                                                     } else {                                                            \
290                                                       SEGGER_SYSVIEW_OnTaskStartExec((U32)pxCurrentTCB[cpu_hal_get_core_id()]); \
291                                                     }
292 #else
293   #define traceTASK_SWITCHED_IN()                   {                                                                   \
294                                                       if (memcmp(pxCurrentTCB[cpu_hal_get_core_id()]->pcTaskName, "IDLE", 5) != 0) { \
295                                                         SEGGER_SYSVIEW_OnTaskStartExec((U32)pxCurrentTCB[cpu_hal_get_core_id()]);    \
296                                                       } else {                                                          \
297                                                         SEGGER_SYSVIEW_OnIdle();                                        \
298                                                       }                                                                 \
299                                                     }
300 #endif
301 
302 #define traceMOVED_TASK_TO_READY_STATE(pxTCB)       SEGGER_SYSVIEW_OnTaskStartReady((U32)pxTCB)
303 #define traceREADDED_TASK_TO_READY_STATE(pxTCB)
304 
305 #define traceMOVED_TASK_TO_DELAYED_LIST()           SEGGER_SYSVIEW_OnTaskStopReady((U32)pxCurrentTCB[cpu_hal_get_core_id()],  (1u << 2))
306 #define traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST()  SEGGER_SYSVIEW_OnTaskStopReady((U32)pxCurrentTCB[cpu_hal_get_core_id()],  (1u << 2))
307 #define traceMOVED_TASK_TO_SUSPENDED_LIST(pxTCB)    SEGGER_SYSVIEW_OnTaskStopReady((U32)pxTCB,         ((3u << 3) | 3))
308 
309 #define traceISR_EXIT_TO_SCHEDULER()                SEGGER_SYSVIEW_RecordExitISRToScheduler()
310 #define traceISR_EXIT()                             SEGGER_SYSVIEW_RecordExitISR()
311 #define traceISR_ENTER(_n_)                         SEGGER_SYSVIEW_RecordEnterISR(_n_)
312 
313 
314 /*********************************************************************
315 *
316 *       API functions
317 *
318 **********************************************************************
319 */
320 #ifdef __cplusplus
321 extern "C" {
322 #endif
323 void SYSVIEW_AddTask      (U32 xHandle, const char* pcTaskName, unsigned uxCurrentPriority, U32  pxStack, unsigned uStackHighWaterMark);
324 void SYSVIEW_UpdateTask   (U32 xHandle, const char* pcTaskName, unsigned uxCurrentPriority, U32 pxStack, unsigned uStackHighWaterMark);
325 void SYSVIEW_DeleteTask   (U32 xHandle);
326 void SYSVIEW_SendTaskInfo (U32 TaskID, const char* sName, unsigned Prio, U32 StackBase, unsigned StackSize);
327 void SYSVIEW_RecordU32x4  (unsigned Id, U32 Para0, U32 Para1, U32 Para2, U32 Para3);
328 void SYSVIEW_RecordU32x5  (unsigned Id, U32 Para0, U32 Para1, U32 Para2, U32 Para3, U32 Para4);
329 
330 #ifdef __cplusplus
331 }
332 #endif
333 
334 #endif
335 
336 /*************************** End of file ****************************/
337