]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/FreeRTOS-Plus-Trace/Configuration - template/trcConfig.h
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS-Plus / FreeRTOS-Plus-Trace / Configuration - template / trcConfig.h
1 /*******************************************************************************\r
2  * FreeRTOS+Trace v2.2.3 Recorder Library\r
3  * Percepio AB, www.percepio.se\r
4  *\r
5  * trcConfig.h\r
6  *\r
7  * Configuration parameters for the trace recorder library. Before using the \r
8  * trace recorder library, please check that the default settings are \r
9  * appropriate for your system, and if necessary adjust these. Most likely, you \r
10  * will need to adjust the NTask, NISR, NQueue, NMutex and NSemaphore values to \r
11  * reflect the number of such objects in your system. These may be \r
12  * overapproximated, although larger values values implies more RAM usage.\r
13  *\r
14  * Terms of Use\r
15  * This software is copyright Percepio AB. The recorder library is free for\r
16  * use together with Percepio products. You may distribute the recorder library\r
17  * in its original form, including modifications in trcPort.c and trcPort.h\r
18  * given that these modification are clearly marked as your own modifications\r
19  * and documented in the initial comment section of these source files. \r
20  * This software is the intellectual property of Percepio AB and may not be \r
21  * sold or in other ways commercially redistributed without explicit written \r
22  * permission by Percepio AB.\r
23  *\r
24  * Disclaimer \r
25  * The trace tool and recorder library is being delivered to you AS IS and \r
26  * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
27  * not and cannot warrant the performance or results you may obtain by using the \r
28  * software or documentation. Percepio AB make no warranties, express or \r
29  * implied, as to noninfringement of third party rights, merchantability, or \r
30  * fitness for any particular purpose. In no event will Percepio AB, its \r
31  * technology partners, or distributors be liable to you for any consequential, \r
32  * incidental or special damages, including any lost profits or lost savings, \r
33  * even if a representative of Percepio AB has been advised of the possibility \r
34  * of such damages, or for any claim by any third party. Some jurisdictions do \r
35  * not allow the exclusion or limitation of incidental, consequential or special \r
36  * damages, or the exclusion of implied warranties or limitations on how long an \r
37  * implied warranty may last, so the above limitations may not apply to you.\r
38  *\r
39  * FreeRTOS+Trace is available as Free Edition and in two premium editions.\r
40  * You may use the premium features during 30 days for evaluation.\r
41  * Download FreeRTOS+Trace at http://www.percepio.se/index.php?page=downloads\r
42  *\r
43  * Copyright Percepio AB, 2012.\r
44  * www.percepio.se\r
45  ******************************************************************************/\r
46 \r
47 #ifndef TRCCONFIG_H\r
48 #define TRCCONFIG_H\r
49 \r
50 /*******************************************************************************\r
51  * CONFIGURATION RELATED TO CAPACITY AND ALLOCATION \r
52  ******************************************************************************/\r
53 \r
54 /*******************************************************************************\r
55  * EVENT_BUFFER_SIZE\r
56  *\r
57  * Macro which should be defined as an integer value.\r
58  *\r
59  * This defines the capacity of the event buffer, i.e., the number of records\r
60  * it may store. Each registered event typically use one record (4 byte), but\r
61  * vTracePrintF may use multiple records depending on the number of data args.\r
62  ******************************************************************************/\r
63 \r
64 #ifdef WIN32\r
65     #define EVENT_BUFFER_SIZE 3000\r
66 #else\r
67     #define EVENT_BUFFER_SIZE 1000 /* Adjust wrt. to available RAM */\r
68 #endif\r
69 \r
70 /*******************************************************************************\r
71  * SYMBOL_TABLE_SIZE\r
72  *\r
73  * Macro which should be defined as an integer value.\r
74  *\r
75  * This defines the capacity of the symbol table, in bytes. This symbol table \r
76  * stores User Events labels and names of deleted tasks, queues, or other kernel\r
77  * objects. Note that the names of active objects not stored here but in the \r
78  * Object Table. Thus, if you don't use User Events or delete any kernel \r
79  * objects you set this to zero (0) to minimize RAM usage.\r
80  ******************************************************************************/\r
81 #define SYMBOL_TABLE_SIZE 1000\r
82 \r
83 /*******************************************************************************\r
84  * NTask, NISR, NQueue, NSemaphore, NMutex\r
85  *\r
86  * A group of Macros which should be defined as an integer value of zero (0) \r
87  * or larger.\r
88  *\r
89  * This defines the capacity of the Object Property Table - the maximum number\r
90  * of objects active at any given point within each object class.\r
91  * \r
92  * NOTE: In case objects are deleted and created during runtime, this setting\r
93  * does not limit the total amount of objects, only the number of concurrently\r
94  * active objects. \r
95  *\r
96  * Using too small values will give an error message through the vTraceError\r
97  * routine, which makes the error message appear when opening the trace data\r
98  * in FreeRTOS+Trace. If you are using the recorder status monitor task,\r
99  * any error messages are displayed in console prints, assuming that the\r
100  * print macro has been defined properly (vConsolePrintMessage).\r
101  * \r
102  * NOTE 2: If you include the monitor task (USE_TRACE_PROGRESS_MONITOR_TASK)\r
103  * make sure to dimension NTask with this task accounted for.\r
104  *\r
105  * Also remember to account for all tasks created by FreeRTOS, such as the \r
106  * IDLE task, the FreeRTOS timer task, and any tasks created by other 3rd party \r
107  * software components, such as communication stacks.\r
108  * Moreover, one task slot is used to indicate "(startup)", i.e., a "task" that \r
109  * represent the time before the first task starts. NTask should thus be at \r
110  * least 2-3 slots larger than your application task count.\r
111  *\r
112  * NOTE 3: The FreeRTOS timer task creates a Queue, that should be accounted \r
113  * for in NQueue.\r
114  ******************************************************************************/\r
115 #define NTask             15\r
116 #define NISR              4\r
117 #define NQueue            3\r
118 #define NSemaphore        4\r
119 #define NMutex            2\r
120 \r
121 /* Maximum object name length for each class (includes zero termination) */\r
122 #define NameLenTask       configMAX_TASK_NAME_LEN\r
123 #define NameLenISR        10\r
124 #define NameLenQueue      15\r
125 #define NameLenSemaphore  15\r
126 #define NameLenMutex      15\r
127 \r
128 /******************************************************************************\r
129  * TRACE_DESCRIPTION\r
130  *\r
131  * Macro which should be defined as a string.\r
132  *\r
133  * This string is stored in the trace and displayed in FreeRTOS+Trace. Can be\r
134  * used to store, e.g., system version or build date. This is also used to store\r
135  * internal error messages from the recorder, which if occurs overwrites the\r
136  * value defined here. This may be maximum 256 chars.\r
137  *****************************************************************************/\r
138 #define TRACE_DESCRIPTION "FreeRTOS+Trace Demo"\r
139 \r
140 /******************************************************************************\r
141  * TRACE_DESCRIPTION_MAX_LENGTH\r
142  *\r
143  * The maximum length (including zero termination) for the TRACE_DESCRIPTION\r
144  * string. Since this string also is used for internal error messages from the \r
145  * recorder do not make it too short, as this may truncate the error messages.\r
146  * Default is 80. \r
147  * Maximum allowed length is 256 - the trace will fail to load if longer.\r
148  *****************************************************************************/\r
149 #define TRACE_DESCRIPTION_MAX_LENGTH 80\r
150 \r
151 \r
152 /******************************************************************************\r
153  * TRACE_DATA_ALLOCATION\r
154  *\r
155  * This defines how to allocate the recorder data structure, i.e., using a \r
156  * static declaration or using a dynamic allocation in runtime (malloc).\r
157  *\r
158  * Should be one of these two options:\r
159  * - TRACE_DATA_ALLOCATION_STATIC (default)\r
160  * - TRACE_DATA_ALLOCATION_DYNAMIC\r
161  *\r
162  * Using static allocation has the benefits of compile-time errors if the buffer \r
163  * is too large (too large constants in trcConfig.h) and no need to call the \r
164  * initialization routine (xTraceInitTraceData).\r
165  *\r
166  * Using dynamic allocation may give more flexibility in some cases.\r
167  *****************************************************************************/\r
168 \r
169 #define TRACE_DATA_ALLOCATION TRACE_DATA_ALLOCATION_STATIC\r
170 \r
171 \r
172 /******************************************************************************\r
173  * CONFIGURATION REGARDING WHAT CODE/FEATURES TO INCLUDE\r
174  *****************************************************************************/\r
175 \r
176 /******************************************************************************\r
177  * INCLUDE_FLOAT_SUPPORT\r
178  *\r
179  * Macro which should be defined as either zero (0) or one (1). \r
180  * Default is 1.\r
181  *\r
182  * If this is zero (0), all references to floating point values are removed,\r
183  * in case floating point values are not supported by the platform used.\r
184  * Floating point values are only used in vTracePrintF and its subroutines, to \r
185  * store float (%f) or double (%lf) argments. \r
186  *\r
187  * Note: vTracePrintF can still be used with integer and string arguments in\r
188  * either case.\r
189  *****************************************************************************/\r
190 #define INCLUDE_FLOAT_SUPPORT 1\r
191 \r
192 /******************************************************************************\r
193  * INCLUDE_USER_EVENTS\r
194  *\r
195  * Macro which should be defined as either zero (0) or one (1). \r
196  * Default is 1.\r
197  *\r
198  * If this is zero (0) the code for creating User Events is excluded to\r
199  * reduce code size. User Events are application-generated events, like \r
200  * "printf" but for the trace log instead of console output. User Events are \r
201  * much faster than a printf and can therefore be used in timing critical code.\r
202  * See vTraceUserEvent() and vTracePrintF() in trcUser.h\r
203  * \r
204  * Note that FreeRTOS+Trace Standard Edition or Professional Edition is required\r
205  * for User Events, they are not displayed in FreeRTOS+Trace Free Edition.\r
206  *****************************************************************************/\r
207 #define INCLUDE_USER_EVENTS 1\r
208 \r
209 /*****************************************************************************\r
210  * INCLUDE_ISR_TRACING\r
211  *\r
212  * Macro which should be defined as either zero (0) or one (1). \r
213  * Default is 1.\r
214  *\r
215  * If this is zero (0), the code for recording Interrupt Service Routines is \r
216  * excluded to reduce code size. Note, recording ISRs require that you insert\r
217  * calls to vTraceStoreISRBegin and vTraceStoreISREnd in your interrupt handlers.\r
218  * There is no automatic recording of ISRs like for task scheduling, since \r
219  * FreeRTOS does not have a central interrupt dispatcher.\r
220  *****************************************************************************/\r
221 #define INCLUDE_ISR_TRACING 1\r
222 \r
223 /******************************************************************************\r
224  * INCLUDE_OBJECT_DELETE\r
225  * \r
226  * Macro which should be defined as either zero (0) or one (1). \r
227  * Default is 1.\r
228  *\r
229  * This must be enabled (1) if tasks, queues or other \r
230  * traced kernel objects are deleted at runtime, e.g., using vTaskDelete or \r
231  * vQueueDelete. If no deletes are made, this can be set to 0 in order to\r
232  * exclude the delete-handling code. \r
233  *****************************************************************************/\r
234 #define INCLUDE_OBJECT_DELETE 1\r
235 \r
236 /******************************************************************************\r
237  * CONFIGURATION RELATED TO BEHAVIOR\r
238  *****************************************************************************/\r
239 \r
240 /******************************************************************************\r
241  * RECORDER_STORE_MODE\r
242  *\r
243  * Macro which should be defined as one of:\r
244  * - STORE_MODE_RING_BUFFER\r
245  * - STORE_MODE_STOP_WHEN_FULL\r
246  * Default is STORE_MODE_RING_BUFFER.\r
247  *\r
248  * With RECORDER_STORE_MODE set to STORE_MODE_RING_BUFFER, the events are stored\r
249  * in a ring buffer, i.e., where the oldest events are overwritten when the\r
250  * buffer becomes full. This allows you to get the last events leading up to an\r
251  * interesting state, e.g., an error, without having a large trace buffer for\r
252  * string the whole run since startup. In this mode, the recorder can run\r
253  * "forever" as the buffer never gets full, i.e., in the sense that it always\r
254  * has room for more events.\r
255  *\r
256  * To fetch the trace in mode STORE_MODE_RING_BUFFER, you need to first halt the\r
257  * system using your debugger and then do a RAM dump, or to explicitly stop the\r
258  * recorder using vTraceStop() and then store/upload the trace data using a\r
259  * FreeRTOS task that you need to provide yourself. The trace data is found in\r
260  * the struct RecorderData, initialized in trcBase.c.\r
261  *\r
262  * Note that, if you upload the trace using a RAM dump, i.e., when the system is \r
263  * halted on a breakpoint or by a debugger command, there is no need to stop the \r
264  * recorder first.\r
265  *\r
266  * When RECORDER_STORE_MODE is STORE_MODE_STOP_WHEN_FULL, the recording is\r
267  * stopped when the buffer becomes full. When the recorder stops itself this way\r
268  * vTracePortEnd() is called which allows for custom actions, such as triggering\r
269  * a task that stores the trace buffer, i.e., in case taking a RAM dump\r
270  * using an on-chip debugger is not possible. In the Windows port, vTracePortEnd\r
271  * saves the trace to file directly, but this is not recommended in a real-time\r
272  * system since the scheduler is blocked during the processing of vTracePortEnd.\r
273  *****************************************************************************/\r
274 #ifndef WIN32\r
275 #define RECORDER_STORE_MODE STORE_MODE_RING_BUFFER\r
276 #else\r
277 /* Default in the Win32 demo */\r
278 #define RECORDER_STORE_MODE STORE_MODE_STOP_WHEN_FULL\r
279 #endif\r
280 \r
281 /******************************************************************************\r
282  * STOP_AFTER_N_EVENTS\r
283  *\r
284  * Macro which should be defined as an integer value, or not defined.\r
285  * Default is -1\r
286  *\r
287  * STOP_AFTER_N_EVENTS is intended for tests of the ring buffer mode (when\r
288  * RECORDER_STORE_MODE is STORE_MODE_RING_BUFFER). It stops the recording when\r
289  * the specified number of events has been observed. This value can be larger\r
290  * than the buffer size, to allow for test of the "wrapping around" that occurs\r
291  * in ring buffer mode . A negative value (or no definition of this macro)\r
292  * disables this feature.\r
293  *****************************************************************************/\r
294 #define STOP_AFTER_N_EVENTS -1\r
295 \r
296 /******************************************************************************\r
297  * USE_IMPLICIT_IFE_RULES\r
298  *\r
299  * Macro which should be defined as either zero (0) or one (1). \r
300  * Default is 1.\r
301  *\r
302  * ### Instance Finish Events (IFE) ###\r
303  *\r
304  * For tasks with "infinite" main loops (non-terminating tasks), the concept\r
305  * of a task instance has no clear definition, it is an application-specific\r
306  * thing. FreeRTOS+Trace allows you to define Instance Finish Events (IFEs),\r
307  * which marks the point in a cyclic task when the "task instance" ends.\r
308  * The IFE is a blocking kernel call, typically in the main loop of a task\r
309  * which typically reads a message queue, waits for a semaphore or performs\r
310  * an explicit delay.\r
311  *\r
312  * If USE_IMPLICIT_IFE_RULES is one (1), the following FreeRTOS kernel calls\r
313  * are considered by default to be IFEs (Implicit IFEs):\r
314  *  - vTaskDelay\r
315  *  - vTaskDelayUntil\r
316  *  - vTaskSuspend\r
317  *  - xQueueReceive (blocking cases only)\r
318  *  - xSemaphoreTake (blocking cases only)\r
319  *\r
320  * However, Implicit IFEs only applies to blocking kernel calls. If an\r
321  * xQueueReceive reads a message without blocking, it does not create a new\r
322  * instance since no blocking occurred.\r
323  *\r
324  * Moreover, the actual IFE might sometimes be another blocking call such as\r
325  * xQueueSend or xSemaphoreGive. We therefore allow for user-defined\r
326  * Explicit IFEs by calling\r
327  *\r
328  *     vTraceTaskInstanceIsFinished()\r
329  *\r
330  * right before the kernel call considered as IFE. This does not create an\r
331  * additional event but instead stores the service code and object handle\r
332  * of the IFE call as properties of the task.\r
333  *\r
334  * If using Explicit IFEs and the task also calls an Implicit IFE like\r
335  * vTaskDelay, this may result in additional incorrect task instances.\r
336  * This is solved by disabling the Implicit IFEs for the task, by adding\r
337  * a call to\r
338  * \r
339  *     vTraceTaskSkipDefaultInstanceFinishedEvents()\r
340  * \r
341  * in the very beginning of that task. This allows you to combine Explicit IFEs\r
342  * for some tasks with Implicit IFEs for the rest of the tasks, if\r
343  * USE_IMPLICIT_IFE_RULES is 1.\r
344  *\r
345  * By setting USE_IMPLICIT_IFE_RULES to zero (0), the implicit IFEs are disabled\r
346  * for all tasks. Tasks will then be considered to have a single instance only, \r
347  * covering all execution fragments, unless you define an explicit IFE in each\r
348  * task by calling vTraceTaskInstanceIsFinished before the blocking call.\r
349  *****************************************************************************/\r
350 #define USE_IMPLICIT_IFE_RULES 1\r
351 \r
352 /******************************************************************************\r
353  * INCLUDE_SAVE_TO_FILE\r
354  *\r
355  * Macro which should be defined as either zero (0) or one (1).\r
356  * Default is 0.\r
357  *\r
358  * If enabled (1), the recorder will include code for saving the trace\r
359  * to a local file system.\r
360  ******************************************************************************/\r
361 #ifdef WIN32\r
362     #define INCLUDE_SAVE_TO_FILE 1\r
363 #else\r
364     #define INCLUDE_SAVE_TO_FILE 0\r
365 #endif\r
366 \r
367 /******************************************************************************\r
368  * TRACE_PROGRESS_MONITOR_TASK_PRIORITY\r
369  *\r
370  * Macro which sets the priority of the "recorder status monitor" task.\r
371  *\r
372  * This task, vTraceMonitorTask in trcUser.c, periodically writes\r
373  * the recorder status using the vTraceConsoleMessage macro, which is to\r
374  * be mapped to your console "printf" routine. The task is named TraceMon but \r
375  * is intentionally excluded from the demo trace.\r
376  *\r
377  * Default is tskIDLE_PRIORITY + 1\r
378  * Note that if your system constantly has a high CPU load from high-priority \r
379  * tasks, this might not be get a chance to execute.\r
380  * \r
381  * See vTraceMonitorTask in trcUser.c\r
382  *****************************************************************************/\r
383 #define TRACE_PROGRESS_MONITOR_TASK_PRIORITY (tskIDLE_PRIORITY + 1)\r
384 \r
385 /******************************************************************************\r
386  * TRACE_PROGRESS_MONITOR_TASK_STACKSIZE\r
387  *\r
388  * Macro which sets the stack size of the "recorder status monitor" task.\r
389  *\r
390  * This task, vTraceMonitorTask in trcUser.c, periodically writes\r
391  * the recorder status using the vTraceConsoleMessage macro, which is to\r
392  * be mapped to your console "printf" routine. The task is intentionally \r
393  * excluded from the demo trace.\r
394  *\r
395  * See vTraceMonitorTask in trcUser.c\r
396  *****************************************************************************/\r
397 #define TRACE_PROGRESS_MONITOR_TASK_STACKSIZE 500\r
398 \r
399 /******************************************************************************\r
400  * TRACE_PROGRESS_MONITOR_TASK_PERIOD\r
401  *\r
402  * Macro which sets the period of the "recorder status monitor" task.\r
403  *\r
404  * This task, vTraceMonitorTask in trcUser.c, periodically writes\r
405  * the recorder status using the vTraceConsoleMessage macro, which is to\r
406  * be mapped to your console "printf" routine. The task is named TraceMon but \r
407  * is intentionally excluded from the demo trace.\r
408  *\r
409  * Default is 1000 FreeRTOS ticks (typically 1 second). On the Windows port, a \r
410  * lower value is suggested since the Windows port runs very slowly, often 20-40\r
411  * times slower than the simulated FreeRTOS time.\r
412  *\r
413  * See vTraceMonitorTask in trcUser.c\r
414  *****************************************************************************/\r
415 #ifdef WIN32\r
416     #define TRACE_PROGRESS_MONITOR_TASK_PERIOD 100\r
417 #else\r
418     #define TRACE_PROGRESS_MONITOR_TASK_PERIOD 1000\r
419 #endif\r
420 \r
421 /******************************************************************************\r
422  * TEAM_LICENSE_CODE\r
423  *\r
424  * Macro which defines a string - the team license code.\r
425  * If no team license is available, this should be an empty string "".\r
426  * This should be maximum 32 chars, including zero-termination.\r
427  *****************************************************************************/\r
428 #define TEAM_LICENSE_CODE ""\r
429 \r
430 #endif\r
431 \r