]> git.sur5r.net Git - freertos/commitdiff
Update to latest FreeRTOS+Trace recorder code.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 5 Jun 2013 13:38:56 +0000 (13:38 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 5 Jun 2013 13:38:56 +0000 (13:38 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1905 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

19 files changed:
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Configuration - template/Readme Config.txt [deleted file]
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Configuration - template/trcConfig.h [deleted file]
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Configuration - template/trcPort.h [deleted file]
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ConfigurationTemplate/trcConfig.h [new file with mode: 0644]
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ConfigurationTemplate/trcHardwarePort.h [new file with mode: 0644]
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcBase.h
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcHooks.h
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernel.h
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcTypes.h
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcUser.h
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/debugger trace upload.txt
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/readme.txt
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcBase.c
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcHardwarePort.c [new file with mode: 0644]
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernel.c
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c [new file with mode: 0644]
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.h [new file with mode: 0644]
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcPort.c [deleted file]
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcUser.c

diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Configuration - template/Readme Config.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Configuration - template/Readme Config.txt
deleted file mode 100644 (file)
index 8883a59..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-FreeRTOS+Trace v2.3.0\r
----------------------\r
-\r
-This directory contains the recorder files that the typical FreeRTOS+Trace user needs to be aware of.\r
-\r
-- trcPort.h - contains the hardware ports and the setting of what port to use.\r
-- trcConfig.h - contains the recorder configuration.\r
-\r
-The files in this directory are however not referenced by any of the demo projects. \r
-Copies of these files are instead found in each Demo project directory.\r
-\r
-These copies are included here to make the TraceRecorderSrc directory complete.\r
-\r
-If you use this template, you will need to update the following macro definitions in trcPort.h:\r
-- SELECTED_PORT\r
-- IRQ_PRIORITY_ORDER\r
-- vTraceConsoleMessage (optional, if console prints are desired)\r
-\r
-Always remember to check the settings used in trcConfig.h.\r
-\r
-Percepio AB\r
-www.percepio.com\r
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Configuration - template/trcConfig.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Configuration - template/trcConfig.h
deleted file mode 100644 (file)
index 1ffa3ef..0000000
+++ /dev/null
@@ -1,465 +0,0 @@
-/*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
- * Percepio AB, www.percepio.com\r
- *\r
- * trcConfig.h\r
- *\r
- * Configuration parameters for the trace recorder library. Before using the \r
- * trace recorder library, please check that the default settings are \r
- * appropriate for your system, and if necessary adjust these. Most likely, you \r
- * will need to adjust the NTask, NISR, NQueue, NMutex and NSemaphore values to \r
- * reflect the number of such objects in your system. These may be \r
- * overapproximated, although larger values values implies more RAM usage.\r
- *\r
- * Terms of Use\r
- * This software is copyright Percepio AB. The recorder library is free for\r
- * use together with Percepio products. You may distribute the recorder library\r
- * in its original form, including modifications in trcPort.c and trcPort.h\r
- * given that these modification are clearly marked as your own modifications\r
- * and documented in the initial comment section of these source files. \r
- * This software is the intellectual property of Percepio AB and may not be \r
- * sold or in other ways commercially redistributed without explicit written \r
- * permission by Percepio AB.\r
- *\r
- * Disclaimer \r
- * The trace tool and recorder library is being delivered to you AS IS and \r
- * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
- * not and cannot warrant the performance or results you may obtain by using the \r
- * software or documentation. Percepio AB make no warranties, express or \r
- * implied, as to noninfringement of third party rights, merchantability, or \r
- * fitness for any particular purpose. In no event will Percepio AB, its \r
- * technology partners, or distributors be liable to you for any consequential, \r
- * incidental or special damages, including any lost profits or lost savings, \r
- * even if a representative of Percepio AB has been advised of the possibility \r
- * of such damages, or for any claim by any third party. Some jurisdictions do \r
- * not allow the exclusion or limitation of incidental, consequential or special \r
- * damages, or the exclusion of implied warranties or limitations on how long an \r
- * implied warranty may last, so the above limitations may not apply to you.\r
- *\r
- * FreeRTOS+Trace is available as Free Edition and in two premium editions.\r
- * You may use the premium features during 30 days for evaluation.\r
- * Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/\r
- *\r
- * Copyright Percepio AB, 2012.\r
- * www.percepio.com\r
- ******************************************************************************/\r
-\r
-#ifndef TRCCONFIG_H\r
-#define TRCCONFIG_H\r
-\r
-/*******************************************************************************\r
- * CONFIGURATION RELATED TO CAPACITY AND ALLOCATION \r
- ******************************************************************************/\r
-\r
-/*******************************************************************************\r
- * EVENT_BUFFER_SIZE\r
- *\r
- * Macro which should be defined as an integer value.\r
- *\r
- * This defines the capacity of the event buffer, i.e., the number of records\r
- * it may store. Each registered event typically use one record (4 byte), but\r
- * vTracePrintF may use multiple records depending on the number of data args.\r
- ******************************************************************************/\r
-\r
-#define EVENT_BUFFER_SIZE 1000 /* Adjust wrt. to available RAM */\r
-\r
-\r
-/*******************************************************************************\r
- * USE_LINKER_PRAGMA\r
- *\r
- * Macro which should be defined as an integer value, default is 0.\r
- *\r
- * If this is 1, the header file "recorderdata_linker_pragma.h" is included just\r
- * before the declaration of RecorderData (in trcBase.c), i.e., the trace data \r
- * structure. This allows the user to specify a pragma with linker options. \r
- *\r
- * Example (for IAR Embedded Workbench and NXP LPC17xx):\r
- * #pragma location="AHB_RAM_MEMORY"\r
- * \r
- * This example instructs the IAR linker to place RecorderData in another RAM \r
- * bank, the AHB RAM. This can also be used for other compilers with a similar\r
- * pragmas for linker options.\r
- * \r
- * Note that this only applies if using static allocation, see below.\r
- ******************************************************************************/\r
-\r
-#define USE_LINKER_PRAGMA 0\r
-\r
-\r
-/*******************************************************************************\r
- * SYMBOL_TABLE_SIZE\r
- *\r
- * Macro which should be defined as an integer value.\r
- *\r
- * This defines the capacity of the symbol table, in bytes. This symbol table \r
- * stores User Events labels and names of deleted tasks, queues, or other kernel\r
- * objects. Note that the names of active objects not stored here but in the \r
- * Object Table. Thus, if you don't use User Events or delete any kernel \r
- * objects you set this to zero (0) to minimize RAM usage.\r
- ******************************************************************************/\r
-#define SYMBOL_TABLE_SIZE 1000\r
-\r
-/*******************************************************************************\r
- * NTask, NISR, NQueue, NSemaphore, NMutex\r
- *\r
- * A group of Macros which should be defined as an integer value of zero (0) \r
- * or larger.\r
- *\r
- * This defines the capacity of the Object Property Table - the maximum number\r
- * of objects active at any given point within each object class.\r
- * \r
- * NOTE: In case objects are deleted and created during runtime, this setting\r
- * does not limit the total amount of objects, only the number of concurrently\r
- * active objects. \r
- *\r
- * Using too small values will give an error message through the vTraceError\r
- * routine, which makes the error message appear when opening the trace data\r
- * in FreeRTOS+Trace. If you are using the recorder status monitor task,\r
- * any error messages are displayed in console prints, assuming that the\r
- * print macro has been defined properly (vConsolePrintMessage). \r
- *\r
- * It can be wise to start with very large values for these constants, \r
- * unless you are very confident on these numbers. Then do a recording and\r
- * check the actual usage in FreeRTOS+Trace. This is shown by selecting\r
- * View -> Trace Details -> Resource Usage -> Object Table\r
- * \r
- * NOTE 2: Remember to account for all tasks created by FreeRTOS, such as the \r
- * IDLE task, the FreeRTOS timer task, and any tasks created by other 3rd party \r
- * software components, such as communication stacks. The recorder also has an \r
- * optional monitor task to account for, if this is used.\r
- * Moreover, one task slot is used to indicate "(startup)", i.e., a fictive \r
- * task that represent the time before the FreeRTOS scheduler starts. \r
- * NTask should thus be at least 2-3 slots larger than your application task count.\r
- *\r
- * NOTE 3: The FreeRTOS timer task creates a Queue, that should be accounted \r
- * for in NQueue.\r
- ******************************************************************************/\r
-#define NTask             15\r
-#define NISR              4\r
-#define NQueue            3\r
-#define NSemaphore        4\r
-#define NMutex            2\r
-\r
-/* Maximum object name length for each class (includes zero termination) */\r
-#define NameLenTask       configMAX_TASK_NAME_LEN\r
-#define NameLenISR        10\r
-#define NameLenQueue      15\r
-#define NameLenSemaphore  15\r
-#define NameLenMutex      15\r
-\r
-/******************************************************************************\r
- * TRACE_DESCRIPTION\r
- *\r
- * Macro which should be defined as a string.\r
- *\r
- * This string is stored in the trace and displayed in FreeRTOS+Trace. Can be\r
- * used to store, e.g., system version or build date. This is also used to store\r
- * internal error messages from the recorder, which if occurs overwrites the\r
- * value defined here. This may be maximum 256 chars.\r
- *****************************************************************************/\r
-#define TRACE_DESCRIPTION "FreeRTOS+Trace Demo"\r
-\r
-/******************************************************************************\r
- * TRACE_DESCRIPTION_MAX_LENGTH\r
- *\r
- * The maximum length (including zero termination) for the TRACE_DESCRIPTION\r
- * string. Since this string also is used for internal error messages from the \r
- * recorder do not make it too short, as this may truncate the error messages.\r
- * Default is 80. \r
- * Maximum allowed length is 256 - the trace will fail to load if longer.\r
- *****************************************************************************/\r
-#define TRACE_DESCRIPTION_MAX_LENGTH 80\r
-\r
-\r
-/******************************************************************************\r
- * TRACE_DATA_ALLOCATION\r
- *\r
- * This defines how to allocate the recorder data structure, i.e., using a \r
- * static declaration or using a dynamic allocation in runtime (malloc).\r
- *\r
- * Should be one of these two options:\r
- * - TRACE_DATA_ALLOCATION_STATIC (default)\r
- * - TRACE_DATA_ALLOCATION_DYNAMIC\r
- *\r
- * Using static allocation has the benefits of compile-time errors if the buffer \r
- * is too large (too large constants in trcConfig.h) and no need to call the \r
- * initialization routine (xTraceInitTraceData).\r
- *\r
- * Using dynamic allocation may give more flexibility in some cases.\r
- *****************************************************************************/\r
-\r
-#define TRACE_DATA_ALLOCATION TRACE_DATA_ALLOCATION_STATIC\r
-\r
-\r
-/******************************************************************************\r
- * CONFIGURATION REGARDING WHAT CODE/FEATURES TO INCLUDE\r
- *****************************************************************************/\r
-\r
-/******************************************************************************\r
- * INCLUDE_FLOAT_SUPPORT\r
- *\r
- * Macro which should be defined as either zero (0) or one (1). \r
- * Default is 1.\r
- *\r
- * If this is zero (0), all references to floating point values are removed,\r
- * in case floating point values are not supported by the platform used.\r
- * Floating point values are only used in vTracePrintF and its subroutines, to \r
- * store float (%f) or double (%lf) argments. \r
- *\r
- * Note: vTracePrintF can still be used with integer and string arguments in\r
- * either case.\r
- *****************************************************************************/\r
-#define INCLUDE_FLOAT_SUPPORT 1\r
-\r
-/******************************************************************************\r
- * INCLUDE_USER_EVENTS\r
- *\r
- * Macro which should be defined as either zero (0) or one (1). \r
- * Default is 1.\r
- *\r
- * If this is zero (0) the code for creating User Events is excluded to\r
- * reduce code size. User Events are application-generated events, like \r
- * "printf" but for the trace log instead of console output. User Events are \r
- * much faster than a printf and can therefore be used in timing critical code.\r
- * See vTraceUserEvent() and vTracePrintF() in trcUser.h\r
- * \r
- * Note that FreeRTOS+Trace Standard Edition or Professional Edition is required\r
- * for User Events, they are not displayed in FreeRTOS+Trace Free Edition.\r
- *****************************************************************************/\r
-#define INCLUDE_USER_EVENTS 1\r
-\r
-/*****************************************************************************\r
- * INCLUDE_READY_EVENTS\r
- *\r
- * Macro which should be defined as either zero (0) or one (1). \r
- * Default is 1.\r
- *\r
- * If this is zero (0), the code for recording Ready events is \r
- * excluded. Note, this will make it impossible to calculate the correct\r
- * response times.\r
- *****************************************************************************/\r
-#define INCLUDE_READY_EVENTS 1\r
-\r
-/*****************************************************************************\r
- * INCLUDE_ISR_TRACING\r
- *\r
- * Macro which should be defined as either zero (0) or one (1). \r
- * Default is 1.\r
- *\r
- * If this is zero (0), the code for recording Interrupt Service Routines is \r
- * excluded to reduce code size. Note, recording ISRs require that you insert\r
- * calls to vTraceStoreISRBegin and vTraceStoreISREnd in your interrupt handlers.\r
- * There is no automatic recording of ISRs like for task scheduling, since \r
- * FreeRTOS does not have a central interrupt dispatcher.\r
- *****************************************************************************/\r
-#define INCLUDE_ISR_TRACING 1\r
-\r
-/******************************************************************************\r
- * INCLUDE_OBJECT_DELETE\r
- * \r
- * Macro which should be defined as either zero (0) or one (1). \r
- * Default is 1.\r
- *\r
- * This must be enabled (1) if tasks, queues or other \r
- * traced kernel objects are deleted at runtime, e.g., using vTaskDelete or \r
- * vQueueDelete. If no deletes are made, this can be set to 0 in order to\r
- * exclude the delete-handling code. \r
- *****************************************************************************/\r
-#define INCLUDE_OBJECT_DELETE 1\r
-\r
-/******************************************************************************\r
- * CONFIGURATION RELATED TO BEHAVIOR\r
- *****************************************************************************/\r
-\r
-/******************************************************************************\r
- * RECORDER_STORE_MODE\r
- *\r
- * Macro which should be defined as one of:\r
- * - STORE_MODE_RING_BUFFER\r
- * - STORE_MODE_STOP_WHEN_FULL\r
- * Default is STORE_MODE_RING_BUFFER.\r
- *\r
- * With RECORDER_STORE_MODE set to STORE_MODE_RING_BUFFER, the events are stored\r
- * in a ring buffer, i.e., where the oldest events are overwritten when the\r
- * buffer becomes full. This allows you to get the last events leading up to an\r
- * interesting state, e.g., an error, without having a large trace buffer for\r
- * string the whole run since startup. In this mode, the recorder can run\r
- * "forever" as the buffer never gets full, i.e., in the sense that it always\r
- * has room for more events.\r
- *\r
- * To fetch the trace in mode STORE_MODE_RING_BUFFER, you need to first halt the\r
- * system using your debugger and then do a RAM dump, or to explicitly stop the\r
- * recorder using vTraceStop() and then store/upload the trace data using a\r
- * FreeRTOS task that you need to provide yourself. The trace data is found in\r
- * the struct RecorderData, initialized in trcBase.c.\r
- *\r
- * Note that, if you upload the trace using a RAM dump, i.e., when the system is \r
- * halted on a breakpoint or by a debugger command, there is no need to stop the \r
- * recorder first.\r
- *\r
- * When RECORDER_STORE_MODE is STORE_MODE_STOP_WHEN_FULL, the recording is\r
- * stopped when the buffer becomes full. When the recorder stops itself this way\r
- * vTracePortEnd() is called which allows for custom actions, such as triggering\r
- * a task that stores the trace buffer, i.e., in case taking a RAM dump\r
- * using an on-chip debugger is not possible. In the Windows port, vTracePortEnd\r
- * saves the trace to file directly, but this is not recommended in a real-time\r
- * system since the scheduler is blocked during the processing of vTracePortEnd.\r
- *****************************************************************************/\r
-#ifndef WIN32\r
-#define RECORDER_STORE_MODE STORE_MODE_RING_BUFFER\r
-#else\r
-/* Default in the Win32 demo */\r
-#define RECORDER_STORE_MODE STORE_MODE_STOP_WHEN_FULL\r
-#endif\r
-\r
-/******************************************************************************\r
- * STOP_AFTER_N_EVENTS\r
- *\r
- * Macro which should be defined as an integer value, or not defined.\r
- * Default is -1\r
- *\r
- * STOP_AFTER_N_EVENTS is intended for tests of the ring buffer mode (when\r
- * RECORDER_STORE_MODE is STORE_MODE_RING_BUFFER). It stops the recording when\r
- * the specified number of events has been observed. This value can be larger\r
- * than the buffer size, to allow for test of the "wrapping around" that occurs\r
- * in ring buffer mode . A negative value (or no definition of this macro)\r
- * disables this feature.\r
- *****************************************************************************/\r
-#define STOP_AFTER_N_EVENTS -1\r
-\r
-/******************************************************************************\r
- * USE_IMPLICIT_IFE_RULES\r
- *\r
- * Macro which should be defined as either zero (0) or one (1). \r
- * Default is 1.\r
- *\r
- * ### Instance Finish Events (IFE) ###\r
- *\r
- * For tasks with "infinite" main loops (non-terminating tasks), the concept\r
- * of a task instance has no clear definition, it is an application-specific\r
- * thing. FreeRTOS+Trace allows you to define Instance Finish Events (IFEs),\r
- * which marks the point in a cyclic task when the "task instance" ends.\r
- * The IFE is a blocking kernel call, typically in the main loop of a task\r
- * which typically reads a message queue, waits for a semaphore or performs\r
- * an explicit delay.\r
- *\r
- * If USE_IMPLICIT_IFE_RULES is one (1), the following FreeRTOS kernel calls\r
- * are considered by default to be IFEs (Implicit IFEs):\r
- *  - vTaskDelay\r
- *  - vTaskDelayUntil\r
- *  - vTaskSuspend\r
- *  - xQueueReceive (blocking cases only)\r
- *  - xSemaphoreTake (blocking cases only)\r
- *\r
- * However, Implicit IFEs only applies to blocking kernel calls. If an\r
- * xQueueReceive reads a message without blocking, it does not create a new\r
- * instance since no blocking occurred.\r
- *\r
- * Moreover, the actual IFE might sometimes be another blocking call such as\r
- * xQueueSend or xSemaphoreGive. We therefore allow for user-defined\r
- * Explicit IFEs by calling\r
- *\r
- *     vTraceTaskInstanceIsFinished()\r
- *\r
- * right before the kernel call considered as IFE. This does not create an\r
- * additional event but instead stores the service code and object handle\r
- * of the IFE call as properties of the task.\r
- *\r
- * If using Explicit IFEs and the task also calls an Implicit IFE like\r
- * vTaskDelay, this may result in additional incorrect task instances.\r
- * This is solved by disabling the Implicit IFEs for the task, by adding\r
- * a call to\r
- * \r
- *     vTraceTaskSkipDefaultInstanceFinishedEvents()\r
- * \r
- * in the very beginning of that task. This allows you to combine Explicit IFEs\r
- * for some tasks with Implicit IFEs for the rest of the tasks, if\r
- * USE_IMPLICIT_IFE_RULES is 1.\r
- *\r
- * By setting USE_IMPLICIT_IFE_RULES to zero (0), the implicit IFEs are disabled\r
- * for all tasks. Tasks will then be considered to have a single instance only, \r
- * covering all execution fragments, unless you define an explicit IFE in each\r
- * task by calling vTraceTaskInstanceIsFinished before the blocking call.\r
- *****************************************************************************/\r
-#define USE_IMPLICIT_IFE_RULES 1\r
-\r
-/******************************************************************************\r
- * INCLUDE_SAVE_TO_FILE\r
- *\r
- * Macro which should be defined as either zero (0) or one (1).\r
- * Default is 0.\r
- *\r
- * If enabled (1), the recorder will include code for saving the trace\r
- * to a local file system.\r
- ******************************************************************************/\r
-#ifdef WIN32\r
-    #define INCLUDE_SAVE_TO_FILE 1\r
-#else\r
-    #define INCLUDE_SAVE_TO_FILE 0\r
-#endif\r
-\r
-/******************************************************************************\r
- * TRACE_PROGRESS_MONITOR_TASK_PRIORITY\r
- *\r
- * Macro which sets the priority of the "recorder status monitor" task.\r
- *\r
- * This task, vTraceMonitorTask in trcUser.c, periodically writes\r
- * the recorder status using the vTraceConsoleMessage macro, which is to\r
- * be mapped to your console "printf" routine. The task is named TraceMon but \r
- * is intentionally excluded from the demo trace.\r
- *\r
- * Default is tskIDLE_PRIORITY + 1\r
- * Note that if your system constantly has a high CPU load from high-priority \r
- * tasks, this might not be get a chance to execute.\r
- * \r
- * See vTraceMonitorTask in trcUser.c\r
- *****************************************************************************/\r
-#define TRACE_PROGRESS_MONITOR_TASK_PRIORITY (tskIDLE_PRIORITY + 1)\r
-\r
-/******************************************************************************\r
- * TRACE_PROGRESS_MONITOR_TASK_STACKSIZE\r
- *\r
- * Macro which sets the stack size of the "recorder status monitor" task.\r
- *\r
- * This task, vTraceMonitorTask in trcUser.c, periodically writes\r
- * the recorder status using the vTraceConsoleMessage macro, which is to\r
- * be mapped to your console "printf" routine. The task is intentionally \r
- * excluded from the demo trace.\r
- *\r
- * See vTraceMonitorTask in trcUser.c\r
- *****************************************************************************/\r
-#define TRACE_PROGRESS_MONITOR_TASK_STACKSIZE 500\r
-\r
-/******************************************************************************\r
- * TRACE_PROGRESS_MONITOR_TASK_PERIOD\r
- *\r
- * Macro which sets the period of the "recorder status monitor" task.\r
- *\r
- * This task, vTraceMonitorTask in trcUser.c, periodically writes\r
- * the recorder status using the vTraceConsoleMessage macro, which is to\r
- * be mapped to your console "printf" routine. The task is named TraceMon but \r
- * is intentionally excluded from the demo trace.\r
- *\r
- * Default is 1000 FreeRTOS ticks (typically 1 second). On the Windows port, a \r
- * lower value is suggested since the Windows port runs very slowly, often 20-40\r
- * times slower than the simulated FreeRTOS time.\r
- *\r
- * See vTraceMonitorTask in trcUser.c\r
- *****************************************************************************/\r
-#ifdef WIN32\r
-    #define TRACE_PROGRESS_MONITOR_TASK_PERIOD 100\r
-#else\r
-    #define TRACE_PROGRESS_MONITOR_TASK_PERIOD 1000\r
-#endif\r
-\r
-/******************************************************************************\r
- * TEAM_LICENSE_CODE\r
- *\r
- * Macro which defines a string - the team license code.\r
- * If no team license is available, this should be an empty string "".\r
- * This should be maximum 32 chars, including zero-termination.\r
- *****************************************************************************/\r
-#define TEAM_LICENSE_CODE ""\r
-\r
-#endif\r
-\r
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Configuration - template/trcPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Configuration - template/trcPort.h
deleted file mode 100644 (file)
index a2d4bf1..0000000
+++ /dev/null
@@ -1,490 +0,0 @@
-/******************************************************************************* \r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
- * Percepio AB, www.percepio.com\r
- *\r
- * trcPort.h\r
- *\r
- * Contains together with trcPort.c all portability issues of the trace recorder \r
- * library.\r
- *\r
- * Terms of Use\r
- * This software is copyright Percepio AB. The recorder library is free for\r
- * use together with Percepio products. You may distribute the recorder library\r
- * in its original form, including modifications in trcPort.c and trcPort.h\r
- * given that these modification are clearly marked as your own modifications\r
- * and documented in the initial comment section of these source files. \r
- * This software is the intellectual property of Percepio AB and may not be \r
- * sold or in other ways commercially redistributed without explicit written \r
- * permission by Percepio AB.\r
- *\r
- * Disclaimer \r
- * The trace tool and recorder library is being delivered to you AS IS and \r
- * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
- * not and cannot warrant the performance or results you may obtain by using the \r
- * software or documentation. Percepio AB make no warranties, express or \r
- * implied, as to noninfringement of third party rights, merchantability, or \r
- * fitness for any particular purpose. In no event will Percepio AB, its \r
- * technology partners, or distributors be liable to you for any consequential, \r
- * incidental or special damages, including any lost profits or lost savings, \r
- * even if a representative of Percepio AB has been advised of the possibility \r
- * of such damages, or for any claim by any third party. Some jurisdictions do \r
- * not allow the exclusion or limitation of incidental, consequential or special \r
- * damages, or the exclusion of implied warranties or limitations on how long an \r
- * implied warranty may last, so the above limitations may not apply to you.\r
- *\r
- * FreeRTOS+Trace is available as Free Edition and in two premium editions.\r
- * You may use the premium features during 30 days for evaluation.\r
- * Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/\r
- *\r
- * Copyright Percepio AB, 2012.\r
- * www.percepio.com\r
- ******************************************************************************/\r
-\r
-#ifndef TRCPORT_H\r
-#define TRCPORT_H\r
-\r
-/* If FreeRTOS Win32 port */\r
-#ifdef WIN32\r
-\r
-   #undef _WIN32_WINNT\r
-   #define _WIN32_WINNT 0x0600\r
-\r
-   /* Standard includes. */\r
-   #include <stdio.h>\r
-   #include <windows.h>\r
-   #include <direct.h>\r
-\r
-/*******************************************************************************\r
- * The Win32 port by default saves the trace to file and then kills the\r
- * program when the recorder is stopped, to facilitate quick, simple tests\r
- * of the recorder.\r
- ******************************************************************************/\r
-   #define WIN32_PORT_SAVE_WHEN_STOPPED 1\r
-   #define WIN32_PORT_EXIT_WHEN_STOPPED 1\r
-\r
-#endif\r
-\r
-#define DIRECTION_INCREMENTING 1\r
-#define DIRECTION_DECREMENTING 2\r
-\r
-/******************************************************************************\r
- * Supported ports\r
- * \r
- * PORT_HWIndependent\r
- * A hardware independent fallback option for event timestamping. Provides low \r
- * resolution timestamps based on the OS tick.\r
- * This may be used on the Win32 port, but may also be used on embedded hardware \r
- * platforms. Note that this gives suboptimal display in FreeRTOS+Trace. All \r
- * time durations will be truncated to the OS tick frequency, typically 1 KHz. \r
- * This means that a task or ISR that executes in less than 1 ms get an exection \r
- * time of zero. They are however still visible in FreeRTOS+Trace. \r
- *\r
- * PORT_Win32\r
- * "Accurate" timestamping based on the Windows permance counter. Note that\r
- * this gives the host machine time, not the simulated FreeRTOS time (tick \r
- * count). The timing of the Win32 FreeRTOS build is not real-time, since it \r
- * depends on the scheduling and tick rate of Windows, which is very slow.\r
- *\r
- * Officially supported hardware timer ports:\r
- * - PORT_Atmel_AT91SAM7\r
- * - PORT_Atmel_UC3A0\r
- * - PORT_ARM_CortexM \r
- * - PORT_Renesas_RX600\r
- * - PORT_Microchip_dsPIC_AND_PIC24\r
- *\r
- * We also provide several "unofficial" hardware-specific ports. There have \r
- * been developed by external contributors, and have not yet been verified \r
- * by Percepio AB. Let us know if you have problems getting these to work.\r
- * \r
- * Unoffical hardware specific ports provided are:\r
- * - PORT_TEXAS_INSTRUMENTS_TMS570\r
- * - PORT_TEXAS_INSTRUMENTS_MSP430\r
- * - PORT_MICROCHIP_PIC32\r
- * - PORT_XILINX_PPC405\r
- * - PORT_XILINX_PPC440\r
- * - PORT_XILINX_MICROBLAZE\r
- * - PORT_NXP_LPC210X\r
- *\r
- *****************************************************************************/\r
-\r
-#define PORT_NOT_SET                          -1\r
-\r
-/*** Officially supported hardware timer ports *******************************/\r
-#define PORT_HWIndependent                     0\r
-#define PORT_Win32                             1\r
-#define PORT_Atmel_AT91SAM7                    2\r
-#define PORT_Atmel_UC3A0                       3\r
-#define PORT_ARM_CortexM                       4\r
-#define PORT_Renesas_RX600                     5\r
-#define PORT_Microchip_dsPIC_AND_PIC24         6\r
-\r
-/*** Unofficial ports, provided by external developers, not yet verified *****/\r
-#define PORT_TEXAS_INSTRUMENTS_TMS570          7\r
-#define PORT_TEXAS_INSTRUMENTS_MSP430          8\r
-#define PORT_MICROCHIP_PIC32                   9\r
-#define PORT_XILINX_PPC405                    10\r
-#define PORT_XILINX_PPC440                    11\r
-#define PORT_XILINX_MICROBLAZE                12\r
-#define PORT_NXP_LPC210X                      13\r
-\r
-/*** Select your port here! **************************************************/\r
-#define SELECTED_PORT PORT_NOT_SET\r
-/*****************************************************************************/\r
-\r
-#if (SELECTED_PORT == PORT_NOT_SET) \r
-#error "You need to define SELECTED_PORT here!"\r
-#endif\r
-\r
-/*******************************************************************************\r
- * IRQ_PRIORITY_ORDER\r
- *\r
- * Macro which should be defined as an integer of 0 or 1.\r
- *\r
- * This should be 0 if lower irq priority values implies higher priority \r
- * levels, such as on ARM Cortex M. If the opposite scheme is used, i.e., \r
- * if higher irq priority values means higher priority, this should be 1.\r
- *\r
- * This setting is not critical. It is used only to sort and colorize the \r
- * interrupts in priority order, in case you record interrupts using\r
- * the vTraceStoreISRBegin and vTraceStoreISREnd routines.\r
- *\r
- * We provide this setting for some hardware architectures below:\r
- * - ARM Cortex M:       0 (lower irq priority values are more significant)\r
- * - Atmel AT91SAM7x:    1 (higher irq priority values are more significant)\r
- * - Atmel AVR32:        1 (higher irq priority values are more significant)\r
- * - Renesas RX600:      1 (higher irq priority values are more significant)\r
- * - Microchip PIC24:    0 (lower irq priority values are more significant)\r
- * - Microchip dsPIC:    0 (lower irq priority values are more significant)\r
- * - TI TMS570:          0 (lower irq priority values are more significant)\r
- * - Freescale HCS08:    0 (lower irq priority values are more significant)\r
- * - Freescale HCS12:    0 (lower irq priority values are more significant)\r
- * - PowerPC 405:        0 (lower irq priority values are more significant)\r
- * - PowerPC 440:        0 (lower irq priority values are more significant)\r
- * - Freescale ColdFire: 1 (higher irq priority values are more significant)\r
- * - NXP LPC210x:        0 (lower irq priority values are more significant)\r
- * - MicroBlaze:        0  (lower irq priority values are more significant)\r
- *\r
- * If your chip is not on the above list, and you perhaps know this detail by \r
- * heart, please inform us by e-mail to support@percepio.com.\r
- *\r
- ******************************************************************************\r
- *\r
- * HWTC Macros \r
- *\r
- * These four HWTC macros provides a hardware isolation layer representing a \r
- * generic hardware timer/counter used for driving the operating system tick, \r
- * such as the SysTick feature of ARM Cortex M3/M4, or the PIT of the Atmel \r
- * AT91SAM7X.\r
- *\r
- * HWTC_COUNT: The current value of the counter. This is expected to be reset \r
- * a each tick interrupt. Thus, when the tick handler starts, the counter has \r
- * already wrapped.\r
- *\r
- * HWTC_COUNT_DIRECTION: Should be one of:\r
- * - DIRECTION_INCREMENTING - for hardware timer/counters of incrementing type\r
- *   such as the PIT on Atmel AT91SAM7X.\r
- *   When the counter value reach HWTC_PERIOD, it is reset to zero and the\r
- *   interrupt is signaled.\r
- * - DIRECTION_DECREMENTING - for hardware timer/counters of decrementing type\r
- *   such as the SysTick on ARM Cortex M3/M4 chips.\r
- *   When the counter value reach 0, it is reset to HWTC_PERIOD and the\r
- *   interrupt is signaled.\r
- *\r
- * HWTC_PERIOD: The number of increments or decrements of HWTC_COUNT between\r
- * two tick interrupts. This should preferably be mapped to the reload\r
- * register of the hardware timer, to make it more portable between chips in the \r
- * same family. The macro should in most cases be (reload register + 1).\r
- *\r
- * HWTC_DIVISOR: If the timer frequency is very high, like on the Cortex M chips\r
- * (where the SysTick runs at the core clock frequency), the "differential \r
- * timestamping" used in the recorder will more frequently insert extra XTS \r
- * events to store the timestamps, which increases the event buffer usage. \r
- * In such cases, to reduce the number of XTS events and thereby get longer \r
- * traces, you use HWTC_DIVISOR to scale down the timestamps and frequency.\r
- * Assuming a OS tick rate of 1 KHz, it is suggested to keep the effective timer\r
- * frequency below 65 MHz to avoid an excessive amount of XTS events. Thus, a\r
- * Cortex M chip running at 72 MHZ should use a HWTC_DIVISOR of 2, while a \r
- * faster chip require a higher HWTC_DIVISOR value. \r
- *\r
- * The HWTC macros and uiTracePortGetTimeStamp is the main porting issue\r
- * or the trace recorder library. Typically you should not need to change\r
- * the code of uiTracePortGetTimeStamp if using the HWTC macros.\r
- *\r
- * FREE LICENSE OFFER FROM PERCEPIO\r
- *\r
- * For silicon companies and non-corporate FreeRTOS users (researchers, students,\r
- * hobbyists or early-phase startups) we have the following offer: \r
- * Provide a hardware port for our FreeRTOS recorder and get a FREE single-user\r
- * license for FreeRTOS+Trace Professional Edition. Read more about this offer\r
- * at www.percepio.com or contact us directly at support@percepio.com.\r
- *\r
- ******************************************************************************/\r
-\r
-#if (SELECTED_PORT == PORT_Win32)\r
-    \r
-    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
-    #define HWTC_COUNT (ulGetRunTimeCounterValue())\r
-    #define HWTC_PERIOD 0\r
-    #define HWTC_DIVISOR 1\r
-    \r
-    #define IRQ_PRIORITY_ORDER 1  // Please update according to your hardware...\r
-\r
-#elif (SELECTED_PORT == PORT_HWIndependent)\r
-    \r
-    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
-    #define HWTC_COUNT 0\r
-    #define HWTC_PERIOD 1\r
-    #define HWTC_DIVISOR 1\r
-\r
-    #define IRQ_PRIORITY_ORDER 1  // Please update according to your hardware...\r
-\r
-#elif (SELECTED_PORT == PORT_Atmel_AT91SAM7)\r
-\r
-    /* HWTC_PERIOD is hardcoded for AT91SAM7X256-EK Board (48 MHz)\r
-    A more generic solution is to get the period from pxPIT->PITC_PIMR */\r
-    \r
-    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
-    #define HWTC_COUNT (AT91C_BASE_PITC->PITC_PIIR & 0xFFFFF)\r
-    #define HWTC_PERIOD 2995 \r
-    #define HWTC_DIVISOR 1\r
-\r
-    #define IRQ_PRIORITY_ORDER 1  // higher irq priority values are more significant\r
-\r
-#elif (SELECTED_PORT == PORT_Atmel_UC3A0) \r
-  \r
-    /* For Atmel AVR32 (AT32UC3A) */\r
-  \r
-    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
-    #define HWTC_COUNT sysreg_read(AVR32_COUNT)\r
-    #define HWTC_PERIOD ( configCPU_CLOCK_HZ / configTICK_RATE_HZ )\r
-    #define HWTC_DIVISOR 1    \r
-\r
-    #define IRQ_PRIORITY_ORDER 1  // higher irq priority values are more significant\r
-\r
-#elif (SELECTED_PORT == PORT_ARM_CortexM)\r
-\r
-    /* For all chips using ARM Cortex M cores */\r
-\r
-    #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING\r
-    #define HWTC_COUNT (*((uint32_t*)0xE000E018))\r
-    #define HWTC_PERIOD ((*(uint32_t*)0xE000E014) + 1)\r
-    #define HWTC_DIVISOR 2\r
-    \r
-    #define IRQ_PRIORITY_ORDER 0  // lower irq priority values are more significant\r
-\r
-#elif (SELECTED_PORT == PORT_Renesas_RX600)    \r
-\r
-    #include "iodefine.h"\r
-\r
-    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
-    #define HWTC_COUNT (CMT0.CMCNT)\r
-    #define HWTC_PERIOD ((((configPERIPHERAL_CLOCK_HZ/configTICK_RATE_HZ)-1)/8))\r
-    #define HWTC_DIVISOR 1\r
-\r
-    #define IRQ_PRIORITY_ORDER 1  // higher irq priority values are more significant\r
-\r
-#elif (SELECTED_PORT == PORT_MICROCHIP_dsPIC_AND_PIC24) \r
-\r
-    /* For Microchip PIC24 and dsPIC (16 bit) */\r
-\r
-    /* Note: The trace library was originally designed for 32-bit MCUs, and is slower\r
-       than intended on 16-bit MCUs. Storing an event on a PIC24 takes about 70 Âµs. \r
-       In comparison, 32-bit MCUs are often 10-20 times faster. If recording overhead \r
-       becomes a problem on PIC24, use the filters to exclude less interresting tasks \r
-       or system calls. */\r
-\r
-    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
-    #define HWTC_COUNT (TMR1)\r
-    #define HWTC_PERIOD (PR1+1)\r
-    #define HWTC_DIVISOR 1\r
-\r
-    #define IRQ_PRIORITY_ORDER 0  // lower irq priority values are more significant\r
-\r
-#elif (SELECTED_PORT == PORT_NXP_LPC210X)\r
-    /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
-    \r
-    /* Tested with LPC2106, but should work with most LPC21XX chips.\r
-       Assumption: prescaler is 1:1 (this setting is hardcoded in \r
-       FreeRTOS port for LPC21XX) */\r
-      \r
-    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
-    #define HWTC_COUNT  *((uint32_t *)0xE0004008 )\r
-    #define HWTC_PERIOD ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) \r
-    #define HWTC_DIVISOR 1    \r
-\r
-    #define IRQ_PRIORITY_ORDER 0  // lower irq priority values are more significant\r
-\r
-#elif (SELECTED_PORT == PORT_TEXAS_INSTRUMENTS_TMS570)\r
-    /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
-\r
-    #define RTIFRC0 *((uint32_t *)0xFFFFFC10)\r
-    #define RTICOMP0 *((uint32_t *)0xFFFFFC50)\r
-    #define RTIUDCP0 *((uint32_t *)0xFFFFFC54)\r
-    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
-    #define HWTC_COUNT (RTIFRC0 - (RTICOMP0 - RTIUDCP0))\r
-    #define HWTC_PERIOD (RTIUDCP0)\r
-    #define HWTC_DIVISOR 1\r
-\r
-    #define IRQ_PRIORITY_ORDER 0  // lower irq priority values are more significant\r
-\r
-#elif (SELECTED_PORT == PORT_TEXAS_INSTRUMENTS_MSP430)\r
-    /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
-\r
-    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
-    #define HWTC_COUNT (TA0R)\r
-    #define HWTC_PERIOD configCPU_CLOCKS_PER_TICK      \r
-    #define HWTC_DIVISOR 1\r
-\r
-    #define IRQ_PRIORITY_ORDER 1  // higher irq priority values are more significant\r
-\r
-#elif (SELECTED_PORT == PORT_MICROCHIP_PIC32)\r
-    /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
-\r
-    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
-    #define HWTC_COUNT (ReadTimer1())     /* Should be available in BSP */\r
-    #define HWTC_PERIOD (ReadPeriod1()+1) /* Should be available in BSP */\r
-    #define HWTC_DIVISOR 1\r
-\r
-    #define IRQ_PRIORITY_ORDER 0  // lower irq priority values are more significant\r
-\r
-#elif (SELECTED_PORT == PORT_XILINX_PPC405) \r
-    /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
-\r
-    #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING\r
-    #define HWTC_COUNT  mfspr( 0x3db)\r
-    #define HWTC_PERIOD ( configCPU_CLOCK_HZ / configTICK_RATE_HZ )\r
-    #define HWTC_DIVISOR 1\r
-\r
-    #define IRQ_PRIORITY_ORDER 0  // lower irq priority values are more significant\r
-\r
-#elif (SELECTED_PORT == PORT_XILINX_PPC440) \r
-    /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
-\r
-    /* This should work with most PowerPC chips */\r
-    \r
-    #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING\r
-    #define HWTC_COUNT  mfspr( 0x016 )\r
-    #define HWTC_PERIOD ( configCPU_CLOCK_HZ / configTICK_RATE_HZ )\r
-    #define HWTC_DIVISOR 1    \r
-\r
-    #define IRQ_PRIORITY_ORDER 0  // lower irq priority values are more significant\r
-    \r
-#elif (SELECTED_PORT == PORT_XILINX_MICROBLAZE)\r
-    /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
-\r
-    /* This should work with most Microblaze configurations\r
-     * This port is based on the official FreeRTOS Microlaze port and example application.\r
-     * It uses the AXI Timer 0 - the tick interrupt source.\r
-     * If an AXI Timer 0 peripheral is available on your hardware platform, no modifications are required.\r
-     */\r
-    #include "xtmrctr_l.h"\r
-\r
-    #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING\r
-    #define HWTC_COUNT XTmrCtr_GetTimerCounterReg( XPAR_TMRCTR_0_BASEADDR, 0 )\r
-    #define HWTC_PERIOD ( configCPU_CLOCK_HZ / configTICK_RATE_HZ )\r
-    #define HWTC_DIVISOR 16\r
-\r
-    #define IRQ_PRIORITY_ORDER 0  // lower irq priority values are more significant\r
-\r
-#elif (SELECTED_PORT != PORT_NOT_SET)\r
-\r
-    #error "SELECTED_PORT had unsupported value!"\r
-    #define SELECTED_PORT PORT_NOT_SET\r
-\r
-#endif\r
-\r
-#if (SELECTED_PORT != PORT_NOT_SET)\r
-    \r
-    #ifndef HWTC_COUNT_DIRECTION\r
-    #error "HWTC_COUNT_DIRECTION is not set!"\r
-    #endif \r
-    \r
-    #ifndef HWTC_COUNT\r
-    #error "HWTC_COUNT is not set!"    \r
-    #endif \r
-    \r
-    #ifndef HWTC_PERIOD\r
-    #error "HWTC_PERIOD is not set!"\r
-    #endif \r
-    \r
-    #ifndef HWTC_DIVISOR\r
-    #error "HWTC_DIVISOR is not set!"    \r
-    #endif \r
-    \r
-    #ifndef IRQ_PRIORITY_ORDER\r
-    #error "IRQ_PRIORITY_ORDER is not set!"\r
-    #elif (IRQ_PRIORITY_ORDER != 0) && (IRQ_PRIORITY_ORDER != 1)\r
-    #error "IRQ_PRIORITY_ORDER has bad value!"\r
-    #endif \r
-    \r
-    #if (HWTC_DIVISOR < 1)\r
-    #error "HWTC_DIVISOR must be a non-zero positive value!"\r
-    #endif \r
-\r
-#endif\r
-/*******************************************************************************\r
- * vTraceConsoleMessage\r
- *\r
- * A wrapper for your system-specific console "printf" console output function.\r
- * This needs to be correctly defined to see status reports from the trace \r
- * status monitor task (this is defined in trcUser.c).\r
- ******************************************************************************/         \r
-#if (SELECTED_PORT == PORT_Atmel_AT91SAM7)\r
-/* Port specific includes */\r
-#include "console.h"\r
-#endif\r
-\r
-#define vTraceConsoleMessage(x)\r
-\r
-/*******************************************************************************\r
- * uiTracePortGetTimeStamp\r
- *\r
- * Returns the current time based on the HWTC macros which provide a hardware\r
- * isolation layer towards the hardware timer/counter.\r
- *\r
- * The HWTC macros and uiTracePortGetTimeStamp is the main porting issue\r
- * or the trace recorder library. Typically you should not need to change\r
- * the code of uiTracePortGetTimeStamp if using the HWTC macros.\r
- *\r
- * OFFER FROM PERCEPIO:\r
- * For silicon companies and non-corporate FreeRTOS users (researchers, \r
- * students, hobbyists or early-phase startups) we have an attractive offer: \r
- * Provide a hardware timer port and get a FREE single-user licence for\r
- * FreeRTOS+Trace Professional Edition. Read more about this offer at \r
- * www.percepio.com or contact us directly at support@percepio.com.\r
- ******************************************************************************/\r
-void uiTracePortGetTimeStamp(uint32_t *puiTimestamp);\r
-\r
-/*******************************************************************************\r
- * vTracePortEnd\r
- * \r
- * This function is called when the recorder is stopped due to full buffer.\r
- * Mainly intended to show a message in the console.\r
- * This is used by the Win32 port to store the trace to a file. The file path is\r
- * set using vTracePortSetFileName.\r
- ******************************************************************************/\r
-void vTracePortEnd(void);\r
-\r
-#if (INCLUDE_SAVE_TO_FILE == 1)\r
-\r
-/*******************************************************************************\r
- * vTracePortSetOutFile\r
- *\r
- * Sets the filename/path used in vTracePortSave.\r
- * This is set in a separate function, since the Win32 port calls vTracePortSave\r
- * in vTracePortEnd if WIN32_PORT_SAVE_WHEN_STOPPED is set.\r
- ******************************************************************************/\r
-void vTracePortSetOutFile(char* path);\r
-\r
-/******************************************************************************\r
- * vTracePortSave\r
- *\r
- * Saves the trace to a file on a target-side file system. The path is set in a \r
- * separate function, vTracePortSetOutFile, since the Win32 port may call\r
- * vTracePortSave in vTracePortEnd, if using WIN32_PORT_SAVE_WHEN_STOPPED.\r
- ******************************************************************************/\r
-void vTracePortSave(void);\r
-\r
-#endif\r
-\r
-#endif\r
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ConfigurationTemplate/trcConfig.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ConfigurationTemplate/trcConfig.h
new file mode 100644 (file)
index 0000000..f016dbc
--- /dev/null
@@ -0,0 +1,508 @@
+/*******************************************************************************\r
+ * Tracealyzer v2.4.1 Recorder Library\r
+ * Percepio AB, www.percepio.com\r
+ *\r
+ * trcConfig.h\r
+ *\r
+ * Configuration parameters for the trace recorder library. Before using the \r
+ * trace recorder library, please check that the default settings are \r
+ * appropriate for your system, and if necessary adjust these. Most likely, you \r
+ * will need to adjust the NTask, NISR, NQueue, NMutex and NSemaphore values to \r
+ * reflect the number of such objects in your system. These may be \r
+ * over-approximated, although larger values values implies more RAM usage.\r
+ *\r
+ * Terms of Use\r
+ * This software is copyright Percepio AB. The recorder library is free for\r
+ * use together with Percepio products. You may distribute the recorder library\r
+ * in its original form, including modifications in trcHardwarePort.c/.h\r
+ * given that these modification are clearly marked as your own modifications\r
+ * and documented in the initial comment section of these source files. \r
+ * This software is the intellectual property of Percepio AB and may not be \r
+ * sold or in other ways commercially redistributed without explicit written \r
+ * permission by Percepio AB.\r
+ *\r
+ * Disclaimer \r
+ * The trace tool and recorder library is being delivered to you AS IS and \r
+ * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
+ * not and cannot warrant the performance or results you may obtain by using the \r
+ * software or documentation. Percepio AB make no warranties, express or \r
+ * implied, as to noninfringement of third party rights, merchantability, or \r
+ * fitness for any particular purpose. In no event will Percepio AB, its \r
+ * technology partners, or distributors be liable to you for any consequential, \r
+ * incidental or special damages, including any lost profits or lost savings, \r
+ * even if a representative of Percepio AB has been advised of the possibility \r
+ * of such damages, or for any claim by any third party. Some jurisdictions do \r
+ * not allow the exclusion or limitation of incidental, consequential or special \r
+ * damages, or the exclusion of implied warranties or limitations on how long an \r
+ * implied warranty may last, so the above limitations may not apply to you.\r
+ *\r
+ * Copyright Percepio AB, 2013.\r
+ * www.percepio.com\r
+ ******************************************************************************/\r
+\r
+#ifndef TRCCONFIG_H\r
+#define TRCCONFIG_H\r
+\r
+/*******************************************************************************\r
+ * CONFIGURATION RELATED TO CAPACITY AND ALLOCATION \r
+ ******************************************************************************/\r
+\r
+/*******************************************************************************\r
+ * EVENT_BUFFER_SIZE\r
+ *\r
+ * Macro which should be defined as an integer value.\r
+ *\r
+ * This defines the capacity of the event buffer, i.e., the number of records\r
+ * it may store. Each registered event typically use one record (4 byte), but\r
+ * vTracePrintF may use multiple records depending on the number of data args.\r
+ ******************************************************************************/\r
+\r
+#define EVENT_BUFFER_SIZE 4000 /* Adjust wrt. to available RAM */\r
+\r
+\r
+/*******************************************************************************\r
+ * USE_LINKER_PRAGMA\r
+ *\r
+ * Macro which should be defined as an integer value, default is 0.\r
+ *\r
+ * If this is 1, the header file "recorderdata_linker_pragma.h" is included just\r
+ * before the declaration of RecorderData (in trcBase.c), i.e., the trace data \r
+ * structure. This allows the user to specify a pragma with linker options. \r
+ *\r
+ * Example (for IAR Embedded Workbench and NXP LPC17xx):\r
+ * #pragma location="AHB_RAM_MEMORY"\r
+ * \r
+ * This example instructs the IAR linker to place RecorderData in another RAM \r
+ * bank, the AHB RAM. This can also be used for other compilers with a similar\r
+ * pragmas for linker options.\r
+ * \r
+ * Note that this only applies if using static allocation, see below.\r
+ ******************************************************************************/\r
+\r
+#define USE_LINKER_PRAGMA 0\r
+\r
+\r
+/*******************************************************************************\r
+ * SYMBOL_TABLE_SIZE\r
+ *\r
+ * Macro which should be defined as an integer value.\r
+ *\r
+ * This defines the capacity of the symbol table, in bytes. This symbol table \r
+ * stores User Events labels and names of deleted tasks, queues, or other kernel\r
+ * objects. Note that the names of active objects not stored here but in the \r
+ * Object Table. Thus, if you don't use User Events or delete any kernel \r
+ * objects you set this to zero (0) to minimize RAM usage.\r
+ ******************************************************************************/\r
+#define SYMBOL_TABLE_SIZE 1000\r
+\r
+/*******************************************************************************\r
+ * USE_SEPARATE_USER_EVENT_BUFFER\r
+ *\r
+ * Macro which should be defined as an integer value.\r
+ * Default is zero (0).\r
+ *\r
+ * This enables and disables the use of the separate user event buffer.\r
+ *\r
+ * Note: When using the separate user event buffer, you may get an artificial\r
+ * task instance named "Unknown actor". This is added as a placeholder when the \r
+ * user event history is longer than the task scheduling history.\r
+ ******************************************************************************/\r
+#define USE_SEPARATE_USER_EVENT_BUFFER 0\r
+\r
+/*******************************************************************************\r
+ * USER_EVENT_BUFFER_SIZE\r
+ *\r
+ * Macro which should be defined as an integer value.\r
+ *\r
+ * This defines the capacity of the user event buffer, in number of slots.\r
+ * A single user event can use between 1 and X slots, depending on the data.\r
+ *\r
+ * Only in use if USE_SEPARATE_USER_EVENT_BUFFER is set to 1.\r
+ ******************************************************************************/\r
+#define USER_EVENT_BUFFER_SIZE 500\r
+\r
+/*******************************************************************************\r
+ * USER_EVENT_CHANNELS\r
+ *\r
+ * Macro which should be defined as an integer value.\r
+ *\r
+ * This defines the number of allowed user event channels.\r
+ *\r
+ * Only in use if USE_SEPARATE_USER_EVENT_BUFFER is set to 1.\r
+ ******************************************************************************/\r
+#define CHANNEL_FORMAT_PAIRS 32\r
+\r
+/*******************************************************************************\r
+ * NTask, NISR, NQueue, NSemaphore, NMutex\r
+ *\r
+ * A group of Macros which should be defined as an integer value of zero (0) \r
+ * or larger.\r
+ *\r
+ * This defines the capacity of the Object Property Table - the maximum number\r
+ * of objects active at any given point within each object class.\r
+ * \r
+ * NOTE: In case objects are deleted and created during runtime, this setting\r
+ * does not limit the total amount of objects, only the number of concurrently\r
+ * active objects. \r
+ *\r
+ * Using too small values will give an error message through the vTraceError\r
+ * routine, which makes the error message appear when opening the trace data\r
+ * in Tracealyzer. If you are using the recorder status monitor task,\r
+ * any error messages are displayed in console prints, assuming that the\r
+ * print macro has been defined properly (vConsolePrintMessage). \r
+ *\r
+ * It can be wise to start with very large values for these constants, \r
+ * unless you are very confident on these numbers. Then do a recording and\r
+ * check the actual usage in Tracealyzer. This is shown by selecting\r
+ * View -> Trace Details -> Resource Usage -> Object Table\r
+ * \r
+ * NOTE 2: Remember to account for all tasks created by the kernel, such as the \r
+ * IDLE task, timer task, and any tasks created by other 3rd party \r
+ * software components, such as communication stacks. The recorder also has an \r
+ * optional monitor task to account for, if this is used.\r
+ * Moreover, one task slot is used to indicate "(startup)", i.e., a fictive \r
+ * task that represent the time before the scheduler starts. \r
+ * NTask should thus be at least 2-3 slots larger than your application task count.\r
+ *\r
+ ******************************************************************************/\r
+#define NTask             15\r
+#define NISR              5\r
+#define NQueue            5\r
+#define NSemaphore        5\r
+#define NMutex            5\r
+\r
+/* Maximum object name length for each class (includes zero termination) */\r
+#define NameLenTask       15\r
+#define NameLenISR        15\r
+#define NameLenQueue      15\r
+#define NameLenSemaphore  15\r
+#define NameLenMutex      15\r
+\r
+/******************************************************************************\r
+ * TRACE_DESCRIPTION\r
+ *\r
+ * Macro which should be defined as a string.\r
+ *\r
+ * This string is stored in the trace and displayed in Tracealyzer. Can be\r
+ * used to store, e.g., system version or build date. This is also used to store\r
+ * internal error messages from the recorder, which if occurs overwrites the\r
+ * value defined here. This may be maximum 256 chars.\r
+ *****************************************************************************/\r
+#define TRACE_DESCRIPTION "Tracealyzer Recorder Test Program"\r
+\r
+/******************************************************************************\r
+ * TRACE_DESCRIPTION_MAX_LENGTH\r
+ *\r
+ * The maximum length (including zero termination) for the TRACE_DESCRIPTION\r
+ * string. Since this string also is used for internal error messages from the \r
+ * recorder do not make it too short, as this may truncate the error messages.\r
+ * Default is 80. \r
+ * Maximum allowed length is 256 - the trace will fail to load if longer.\r
+ *****************************************************************************/\r
+#define TRACE_DESCRIPTION_MAX_LENGTH 80\r
+\r
+\r
+/******************************************************************************\r
+ * TRACE_DATA_ALLOCATION\r
+ *\r
+ * This defines how to allocate the recorder data structure, i.e., using a \r
+ * static declaration or using a dynamic allocation in runtime (malloc).\r
+ *\r
+ * Should be one of these two options:\r
+ * - TRACE_DATA_ALLOCATION_STATIC (default)\r
+ * - TRACE_DATA_ALLOCATION_DYNAMIC\r
+ *\r
+ * Using static allocation has the benefits of compile-time errors if the buffer \r
+ * is too large (too large constants in trcConfig.h) and no need to call the \r
+ * initialization routine (xTraceInitTraceData).\r
+ *\r
+ * Using dynamic allocation may give more flexibility in some cases.\r
+ *****************************************************************************/\r
+\r
+#define TRACE_DATA_ALLOCATION TRACE_DATA_ALLOCATION_STATIC\r
+\r
+\r
+/******************************************************************************\r
+ * CONFIGURATION REGARDING WHAT CODE/FEATURES TO INCLUDE\r
+ *****************************************************************************/\r
+\r
+/******************************************************************************\r
+ * USE_TRACE_ASSERT\r
+ *\r
+ * Macro which should be defined as either zero (0) or one (1). \r
+ * Default is 0.\r
+ *\r
+ * If this is one (1), the TRACE_ASSERT macro will verify that a condition is \r
+ * true. If the condition is false, vTraceError() will be called.\r
+ *****************************************************************************/\r
+#define USE_TRACE_ASSERT 0\r
+\r
+/******************************************************************************\r
+ * INCLUDE_FLOAT_SUPPORT\r
+ *\r
+ * Macro which should be defined as either zero (0) or one (1). \r
+ * Default is 1.\r
+ *\r
+ * If this is zero (0), all references to floating point values are removed,\r
+ * in case floating point values are not supported by the platform used.\r
+ * Floating point values are only used in vTracePrintF and its subroutines, to \r
+ * store float (%f) or double (%lf) argments. \r
+ *\r
+ * Note: vTracePrintF can still be used with integer and string arguments in\r
+ * either case.\r
+ *****************************************************************************/\r
+#define INCLUDE_FLOAT_SUPPORT 1\r
+\r
+/******************************************************************************\r
+ * INCLUDE_USER_EVENTS\r
+ *\r
+ * Macro which should be defined as either zero (0) or one (1). \r
+ * Default is 1.\r
+ *\r
+ * If this is zero (0) the code for creating User Events is excluded to\r
+ * reduce code size. User Events are application-generated events, like \r
+ * "printf" but for the trace log instead of console output. User Events are \r
+ * much faster than a printf and can therefore be used in timing critical code.\r
+ * See vTraceUserEvent() and vTracePrintF() in trcUser.h\r
+ * \r
+ * Note that Tracealyzer Standard Edition or Professional Edition is required\r
+ * for User Events, they are not displayed in Tracealyzer Free Edition.\r
+ *****************************************************************************/\r
+#define INCLUDE_USER_EVENTS 1\r
+\r
+/*****************************************************************************\r
+ * INCLUDE_READY_EVENTS\r
+ *\r
+ * Macro which should be defined as either zero (0) or one (1). \r
+ * Default is 1.\r
+ *\r
+ * If this is zero (0), the code for recording Ready events is \r
+ * excluded. Note, this will make it impossible to calculate the correct\r
+ * response times.\r
+ *****************************************************************************/\r
+#define INCLUDE_READY_EVENTS 1\r
+\r
+/*****************************************************************************\r
+ * INCLUDE_NEW_TIME_EVENTS\r
+ *\r
+ * Macro which should be defined as either zero (0) or one (1). \r
+ * Default is 0.\r
+ *\r
+ * If this is zero (1), events will be generated whenever the os clock is\r
+ * increased.\r
+ *****************************************************************************/\r
+#define INCLUDE_NEW_TIME_EVENTS 0\r
+\r
+/*****************************************************************************\r
+ * INCLUDE_ISR_TRACING\r
+ *\r
+ * Macro which should be defined as either zero (0) or one (1). \r
+ * Default is 1.\r
+ *\r
+ * If this is zero (0), the code for recording Interrupt Service Routines is \r
+ * excluded to reduce code size.\r
+ * \r
+ * Note, if the kernel has no central interrupt dispatcher, recording ISRs \r
+ * require that you insert calls to vTraceStoreISRBegin and vTraceStoreISREnd \r
+ * in your interrupt handlers.\r
+ *****************************************************************************/\r
+#define INCLUDE_ISR_TRACING 1\r
+\r
+/******************************************************************************\r
+ * INCLUDE_OBJECT_DELETE\r
+ * \r
+ * Macro which should be defined as either zero (0) or one (1). \r
+ * Default is 1.\r
+ *\r
+ * This must be enabled (1) if tasks, queues or other \r
+ * traced kernel objects are deleted at runtime. If no deletes are made, this \r
+ * can be set to 0 in order to exclude the delete-handling code.\r
+ *****************************************************************************/\r
+#define INCLUDE_OBJECT_DELETE 1\r
+\r
+/******************************************************************************\r
+ * CONFIGURATION RELATED TO BEHAVIOR\r
+ *****************************************************************************/\r
+\r
+/******************************************************************************\r
+ * TRACE_RECORDER_STORE_MODE\r
+ *\r
+ * Macro which should be defined as one of:\r
+ * - TRACE_STORE_MODE_RING_BUFFER\r
+ * - TRACE_STORE_MODE_STOP_WHEN_FULL\r
+ * Default is TRACE_STORE_MODE_RING_BUFFER.\r
+ *\r
+ * With TRACE_RECORDER_STORE_MODE set to TRACE_STORE_MODE_RING_BUFFER, the events are \r
+ * stored in a ring buffer, i.e., where the oldest events are overwritten when \r
+ * the buffer becomes full. This allows you to get the last events leading up \r
+ * to an interesting state, e.g., an error, without having a large trace buffer\r
+ * for string the whole run since startup. In this mode, the recorder can run\r
+ * "forever" as the buffer never gets full, i.e., in the sense that it always\r
+ * has room for more events.\r
+ *\r
+ * To fetch the trace in mode TRACE_STORE_MODE_RING_BUFFER, you need to first halt the\r
+ * system using your debugger and then do a RAM dump, or to explicitly stop the\r
+ * recorder using vTraceStop() and then store/upload the trace data using a\r
+ * task that you need to provide yourself. The trace data is found in the struct\r
+ * RecorderData, initialized in trcBase.c.\r
+ *\r
+ * Note that, if you upload the trace using a RAM dump, i.e., when the system is \r
+ * halted on a breakpoint or by a debugger command, there is no need to stop the \r
+ * recorder first.\r
+ *\r
+ * When TRACE_RECORDER_STORE_MODE is TRACE_STORE_MODE_STOP_WHEN_FULL, the recording is\r
+ * stopped when the buffer becomes full. When the recorder stops itself this way\r
+ * vTracePortEnd() is called which allows for custom actions, such as triggering\r
+ * a task that stores the trace buffer, i.e., in case taking a RAM dump\r
+ * using an on-chip debugger is not possible. In the Windows port, vTracePortEnd\r
+ * saves the trace to file directly, but this is not recommended in a real-time\r
+ * system since the scheduler is blocked during the processing of vTracePortEnd.\r
+ *****************************************************************************/\r
+\r
+#define TRACE_RECORDER_STORE_MODE TRACE_STORE_MODE_RING_BUFFER\r
+\r
+/******************************************************************************\r
+ * STOP_AFTER_N_EVENTS\r
+ *\r
+ * Macro which should be defined as an integer value, or not defined.\r
+ * Default is -1\r
+ *\r
+ * STOP_AFTER_N_EVENTS is intended for tests of the ring buffer mode (when\r
+ * RECORDER_STORE_MODE is STORE_MODE_RING_BUFFER). It stops the recording when\r
+ * the specified number of events has been observed. This value can be larger\r
+ * than the buffer size, to allow for test of the "wrapping around" that occurs\r
+ * in ring buffer mode . A negative value (or no definition of this macro)\r
+ * disables this feature.\r
+ *****************************************************************************/\r
+#define STOP_AFTER_N_EVENTS -1\r
+\r
+/******************************************************************************\r
+ * USE_IMPLICIT_IFE_RULES\r
+ *\r
+ * Macro which should be defined as either zero (0) or one (1). \r
+ * Default is 1.\r
+ *\r
+ * ### Instance Finish Events (IFE) ###\r
+ *\r
+ * For tasks with "infinite" main loops (non-terminating tasks), the concept\r
+ * of a task instance has no clear definition, it is an application-specific\r
+ * thing. Tracealyzer allows you to define Instance Finish Events (IFEs),\r
+ * which marks the point in a cyclic task when the "task instance" ends.\r
+ * The IFE is a blocking kernel call, typically in the main loop of a task\r
+ * which typically reads a message queue, waits for a semaphore or performs\r
+ * an explicit delay.\r
+ *\r
+ * If USE_IMPLICIT_IFE_RULES is one (1), the kernel macros (trcKernelPort.h)\r
+ * will define what kernel calls are considered by default to be IFEs.\r
+ *\r
+ * However, Implicit IFEs only applies to blocking kernel calls. If a\r
+ * service reads a message without blocking, it does not create a new\r
+ * instance since no blocking occurred.\r
+ *\r
+ * Moreover, the actual IFE might sometimes be another blocking call. We \r
+ * therefore allow for user-defined Explicit IFEs by calling\r
+ *\r
+ *     vTraceTaskInstanceIsFinished()\r
+ *\r
+ * right before the kernel call considered as IFE. This does not create an\r
+ * additional event but instead stores the service code and object handle\r
+ * of the IFE call as properties of the task.\r
+ *\r
+ * If using Explicit IFEs and the task also calls an Implicit IFE, this may \r
+ * result in additional incorrect task instances.\r
+ * This is solved by disabling the Implicit IFEs for the task, by adding\r
+ * a call to\r
+ * \r
+ *     vTraceTaskSkipDefaultInstanceFinishedEvents()\r
+ * \r
+ * in the very beginning of that task. This allows you to combine Explicit IFEs\r
+ * for some tasks with Implicit IFEs for the rest of the tasks, if\r
+ * USE_IMPLICIT_IFE_RULES is 1.\r
+ *\r
+ * By setting USE_IMPLICIT_IFE_RULES to zero (0), the implicit IFEs are disabled\r
+ * for all tasks. Tasks will then be considered to have a single instance only, \r
+ * covering all execution fragments, unless you define an explicit IFE in each\r
+ * task by calling vTraceTaskInstanceIsFinished before the blocking call.\r
+ *****************************************************************************/\r
+#define USE_IMPLICIT_IFE_RULES 1\r
+\r
+/******************************************************************************\r
+ * INCLUDE_SAVE_TO_FILE\r
+ *\r
+ * Macro which should be defined as either zero (0) or one (1).\r
+ * Default is 0.\r
+ *\r
+ * If enabled (1), the recorder will include code for saving the trace\r
+ * to a local file system.\r
+ ******************************************************************************/\r
+#ifdef WIN32\r
+    #define INCLUDE_SAVE_TO_FILE 1\r
+#else\r
+    #define INCLUDE_SAVE_TO_FILE 0\r
+#endif\r
+\r
+/******************************************************************************\r
+ * TRACE_PROGRESS_MONITOR_TASK_PRIORITY\r
+ *\r
+ * Macro which sets the priority of the "recorder status monitor" task.\r
+ *\r
+ * This task, vTraceMonitorTask in trcUser.c, periodically writes\r
+ * the recorder status using the vTraceConsoleMessage macro, which is to\r
+ * be mapped to your console "printf" routine. The task is named TraceMon but \r
+ * is intentionally excluded from the demo trace.\r
+ *\r
+ * Default is tskIDLE_PRIORITY + 1\r
+ * Note that if your system constantly has a high CPU load from high-priority \r
+ * tasks, this might not be get a chance to execute.\r
+ * \r
+ * See vTraceMonitorTask in trcUser.c\r
+ *****************************************************************************/\r
+#define TRACE_PROGRESS_MONITOR_TASK_PRIORITY (tskIDLE_PRIORITY + 1)\r
+\r
+/******************************************************************************\r
+ * TRACE_PROGRESS_MONITOR_TASK_STACKSIZE\r
+ *\r
+ * Macro which sets the stack size of the "recorder status monitor" task.\r
+ *\r
+ * This task, vTraceMonitorTask in trcUser.c, periodically writes\r
+ * the recorder status using the vTraceConsoleMessage macro, which is to\r
+ * be mapped to your console "printf" routine. The task is intentionally \r
+ * excluded from the demo trace.\r
+ *\r
+ * See vTraceMonitorTask in trcUser.c\r
+ *****************************************************************************/\r
+#define TRACE_PROGRESS_MONITOR_TASK_STACKSIZE 500\r
+\r
+/******************************************************************************\r
+ * TRACE_PROGRESS_MONITOR_TASK_PERIOD\r
+ *\r
+ * Macro which sets the period of the "recorder status monitor" task.\r
+ *\r
+ * This task, vTraceMonitorTask in trcUser.c, periodically writes\r
+ * the recorder status using the vTraceConsoleMessage macro, which is to\r
+ * be mapped to your console "printf" routine. The task is named TraceMon but \r
+ * is intentionally excluded from the demo trace.\r
+ *\r
+ * Default is 1000 ticks (typically 1 second). On the Windows port, a lower \r
+ * value is suggested since the Windows port runs very slowly, often 20-40\r
+ * times slower than the simulated time.\r
+ *\r
+ * See vTraceMonitorTask in trcUser.c\r
+ *****************************************************************************/\r
+#ifdef WIN32\r
+    #define TRACE_PROGRESS_MONITOR_TASK_PERIOD 100\r
+#else\r
+    #define TRACE_PROGRESS_MONITOR_TASK_PERIOD 1000\r
+#endif\r
+\r
+/******************************************************************************\r
+ * TEAM_LICENSE_CODE\r
+ *\r
+ * Macro which defines a string - the team license code.\r
+ * If no team license is available, this should be an empty string "".\r
+ * This should be maximum 32 chars, including zero-termination.\r
+ *****************************************************************************/\r
+#define TEAM_LICENSE_CODE ""\r
+\r
+#endif\r
+\r
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ConfigurationTemplate/trcHardwarePort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ConfigurationTemplate/trcHardwarePort.h
new file mode 100644 (file)
index 0000000..0e97b8e
--- /dev/null
@@ -0,0 +1,474 @@
+/******************************************************************************* \r
+ * Tracealyzer v2.4.1 Recorder Library\r
+ * Percepio AB, www.percepio.com\r
+ *\r
+ * trcHardwarePort.h\r
+ *\r
+ * Contains together with trcHardwarePort.c all hardware portability issues of \r
+ * the trace recorder library.\r
+ *\r
+ * Terms of Use\r
+ * This software is copyright Percepio AB. The recorder library is free for\r
+ * use together with Percepio products. You may distribute the recorder library\r
+ * in its original form, including modifications in trcPort.c and trcPort.h\r
+ * given that these modification are clearly marked as your own modifications\r
+ * and documented in the initial comment section of these source files. \r
+ * This software is the intellectual property of Percepio AB and may not be \r
+ * sold or in other ways commercially redistributed without explicit written \r
+ * permission by Percepio AB.\r
+ *\r
+ * Disclaimer \r
+ * The trace tool and recorder library is being delivered to you AS IS and \r
+ * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
+ * not and cannot warrant the performance or results you may obtain by using the \r
+ * software or documentation. Percepio AB make no warranties, express or \r
+ * implied, as to noninfringement of third party rights, merchantability, or \r
+ * fitness for any particular purpose. In no event will Percepio AB, its \r
+ * technology partners, or distributors be liable to you for any consequential, \r
+ * incidental or special damages, including any lost profits or lost savings, \r
+ * even if a representative of Percepio AB has been advised of the possibility \r
+ * of such damages, or for any claim by any third party. Some jurisdictions do \r
+ * not allow the exclusion or limitation of incidental, consequential or special \r
+ * damages, or the exclusion of implied warranties or limitations on how long an \r
+ * implied warranty may last, so the above limitations may not apply to you.\r
+ *\r
+ * Copyright Percepio AB, 2013.\r
+ * www.percepio.com\r
+ ******************************************************************************/\r
+\r
+#ifndef TRCPORT_H\r
+#define TRCPORT_H\r
+\r
+#include "trcKernelPort.h"\r
+\r
+/* If Win32 port */\r
+#ifdef WIN32\r
+\r
+   #undef _WIN32_WINNT\r
+   #define _WIN32_WINNT 0x0600\r
+\r
+   /* Standard includes. */\r
+   #include <stdio.h>\r
+   #include <windows.h>\r
+   #include <direct.h>\r
+\r
+/*******************************************************************************\r
+ * The Win32 port by default saves the trace to file and then kills the\r
+ * program when the recorder is stopped, to facilitate quick, simple tests\r
+ * of the recorder.\r
+ ******************************************************************************/\r
+   #define WIN32_PORT_SAVE_WHEN_STOPPED 1\r
+   #define WIN32_PORT_EXIT_WHEN_STOPPED 1\r
+\r
+#endif\r
+\r
+#define DIRECTION_INCREMENTING 1\r
+#define DIRECTION_DECREMENTING 2\r
+\r
+/******************************************************************************\r
+ * Supported ports\r
+ * \r
+ * PORT_HWIndependent\r
+ * A hardware independent fallback option for event timestamping. Provides low \r
+ * resolution timestamps based on the OS tick.\r
+ * This may be used on the Win32 port, but may also be used on embedded hardware \r
+ * platforms. All time durations will be truncated to the OS tick frequency, \r
+ * typically 1 KHz. This means that a task or ISR that executes in less than \r
+ * 1 ms get an execution time of zero.\r
+ *\r
+ * PORT_Win32\r
+ * "Accurate" timestamping based on the Windows performance counter. Note that\r
+ * this gives the host machine time.\r
+ *\r
+ * Officially supported hardware timer ports:\r
+ * - PORT_Atmel_AT91SAM7\r
+ * - PORT_Atmel_UC3A0\r
+ * - PORT_ARM_CortexM \r
+ * - PORT_Renesas_RX600\r
+ * - PORT_Microchip_dsPIC_AND_PIC24\r
+ *\r
+ * We also provide several "unofficial" hardware-specific ports. There have \r
+ * been developed by external contributors, and have not yet been verified \r
+ * by Percepio AB. Let us know if you have problems getting these to work.\r
+ * \r
+ * Unofficial hardware specific ports provided are:\r
+ * - PORT_TEXAS_INSTRUMENTS_TMS570\r
+ * - PORT_TEXAS_INSTRUMENTS_MSP430\r
+ * - PORT_MICROCHIP_PIC32\r
+ * - PORT_XILINX_PPC405\r
+ * - PORT_XILINX_PPC440\r
+ * - PORT_XILINX_MICROBLAZE\r
+ * - PORT_NXP_LPC210X\r
+ *\r
+ *****************************************************************************/\r
+\r
+#define PORT_NOT_SET                          -1\r
+\r
+/*** Officially supported hardware timer ports *******************************/\r
+#define PORT_HWIndependent                     0\r
+#define PORT_Win32                             1\r
+#define PORT_Atmel_AT91SAM7                    2\r
+#define PORT_Atmel_UC3A0                       3\r
+#define PORT_ARM_CortexM                       4\r
+#define PORT_Renesas_RX600                     5\r
+#define PORT_Microchip_dsPIC_AND_PIC24         6\r
+\r
+/*** Unofficial ports, provided by external developers, not yet verified *****/\r
+#define PORT_TEXAS_INSTRUMENTS_TMS570          7\r
+#define PORT_TEXAS_INSTRUMENTS_MSP430          8\r
+#define PORT_MICROCHIP_PIC32                   9\r
+#define PORT_XILINX_PPC405                    10\r
+#define PORT_XILINX_PPC440                    11\r
+#define PORT_XILINX_MICROBLAZE                12\r
+#define PORT_NXP_LPC210X                      13\r
+\r
+/*** Select your port here! **************************************************/\r
+#define SELECTED_PORT PORT_NOT_SET\r
+/*****************************************************************************/\r
+\r
+#if (SELECTED_PORT == PORT_NOT_SET) \r
+#error "You need to define SELECTED_PORT here!"\r
+#endif\r
+\r
+/*******************************************************************************\r
+ * IRQ_PRIORITY_ORDER\r
+ *\r
+ * Macro which should be defined as an integer of 0 or 1.\r
+ *\r
+ * This should be 0 if lower IRQ priority values implies higher priority \r
+ * levels, such as on ARM Cortex M. If the opposite scheme is used, i.e., \r
+ * if higher IRQ priority values means higher priority, this should be 1.\r
+ *\r
+ * This setting is not critical. It is used only to sort and colorize the \r
+ * interrupts in priority order, in case you record interrupts using\r
+ * the vTraceStoreISRBegin and vTraceStoreISREnd routines.\r
+ *\r
+ * We provide this setting for some hardware architectures below:\r
+ * - ARM Cortex M:       0 (lower IRQ priority values are more significant)\r
+ * - Atmel AT91SAM7x:    1 (higher IRQ priority values are more significant)\r
+ * - Atmel AVR32:        1 (higher IRQ priority values are more significant)\r
+ * - Renesas RX600:      1 (higher IRQ priority values are more significant)\r
+ * - Microchip PIC24:    0 (lower IRQ priority values are more significant)\r
+ * - Microchip dsPIC:    0 (lower IRQ priority values are more significant)\r
+ * - TI TMS570:          0 (lower IRQ priority values are more significant)\r
+ * - Freescale HCS08:    0 (lower IRQ priority values are more significant)\r
+ * - Freescale HCS12:    0 (lower IRQ priority values are more significant)\r
+ * - PowerPC 405:        0 (lower IRQ priority values are more significant)\r
+ * - PowerPC 440:        0 (lower IRQ priority values are more significant)\r
+ * - Freescale ColdFire: 1 (higher IRQ priority values are more significant)\r
+ * - NXP LPC210x:        0 (lower IRQ priority values are more significant)\r
+ * - MicroBlaze:        0  (lower IRQ priority values are more significant)\r
+ *\r
+ * If your chip is not on the above list, and you perhaps know this detail by \r
+ * heart, please inform us by e-mail to support@percepio.com.\r
+ *\r
+ ******************************************************************************\r
+ *\r
+ * HWTC Macros \r
+ *\r
+ * These four HWTC macros provides a hardware isolation layer representing a \r
+ * generic hardware timer/counter used for driving the operating system tick, \r
+ * such as the SysTick feature of ARM Cortex M3/M4, or the PIT of the Atmel \r
+ * AT91SAM7X.\r
+ *\r
+ * HWTC_COUNT: The current value of the counter. This is expected to be reset \r
+ * a each tick interrupt. Thus, when the tick handler starts, the counter has \r
+ * already wrapped.\r
+ *\r
+ * HWTC_COUNT_DIRECTION: Should be one of:\r
+ * - DIRECTION_INCREMENTING - for hardware timer/counters of incrementing type\r
+ *   such as the PIT on Atmel AT91SAM7X.\r
+ *   When the counter value reach HWTC_PERIOD, it is reset to zero and the\r
+ *   interrupt is signaled.\r
+ * - DIRECTION_DECREMENTING - for hardware timer/counters of decrementing type\r
+ *   such as the SysTick on ARM Cortex M3/M4 chips.\r
+ *   When the counter value reach 0, it is reset to HWTC_PERIOD and the\r
+ *   interrupt is signaled.\r
+ *\r
+ * HWTC_PERIOD: The number of increments or decrements of HWTC_COUNT between\r
+ * two tick interrupts. This should preferably be mapped to the reload\r
+ * register of the hardware timer, to make it more portable between chips in the \r
+ * same family. The macro should in most cases be (reload register + 1).\r
+ *\r
+ * HWTC_DIVISOR: If the timer frequency is very high, like on the Cortex M chips\r
+ * (where the SysTick runs at the core clock frequency), the "differential \r
+ * timestamping" used in the recorder will more frequently insert extra XTS \r
+ * events to store the timestamps, which increases the event buffer usage. \r
+ * In such cases, to reduce the number of XTS events and thereby get longer \r
+ * traces, you use HWTC_DIVISOR to scale down the timestamps and frequency.\r
+ * Assuming a OS tick rate of 1 KHz, it is suggested to keep the effective timer\r
+ * frequency below 65 MHz to avoid an excessive amount of XTS events. Thus, a\r
+ * Cortex M chip running at 72 MHZ should use a HWTC_DIVISOR of 2, while a \r
+ * faster chip require a higher HWTC_DIVISOR value. \r
+ *\r
+ * The HWTC macros and vTracePortGetTimeStamp is the main porting issue\r
+ * or the trace recorder library. Typically you should not need to change\r
+ * the code of vTracePortGetTimeStamp if using the HWTC macros.\r
+ *\r
+ ******************************************************************************/\r
+\r
+#if (SELECTED_PORT == PORT_Win32)\r
+    \r
+    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+    #define HWTC_COUNT (ulGetRunTimeCounterValue())\r
+    #define HWTC_PERIOD 0\r
+    #define HWTC_DIVISOR 1\r
+    \r
+    #define IRQ_PRIORITY_ORDER 1  // Please update according to your hardware...\r
+\r
+#elif (SELECTED_PORT == PORT_HWIndependent)\r
+    \r
+    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+    #define HWTC_COUNT 0\r
+    #define HWTC_PERIOD 1\r
+    #define HWTC_DIVISOR 1\r
+\r
+    #define IRQ_PRIORITY_ORDER 1  // Please update according to your hardware...\r
+\r
+#elif (SELECTED_PORT == PORT_Atmel_AT91SAM7)\r
+\r
+    /* HWTC_PERIOD is hardcoded for AT91SAM7X256-EK Board (48 MHz)\r
+    A more generic solution is to get the period from pxPIT->PITC_PIMR */\r
+    \r
+    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+    #define HWTC_COUNT (AT91C_BASE_PITC->PITC_PIIR & 0xFFFFF)\r
+    #define HWTC_PERIOD 2995 \r
+    #define HWTC_DIVISOR 1\r
+\r
+    #define IRQ_PRIORITY_ORDER 1  // higher IRQ priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_Atmel_UC3A0) \r
+  \r
+    /* For Atmel AVR32 (AT32UC3A) */\r
+  \r
+    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+    #define HWTC_COUNT sysreg_read(AVR32_COUNT)\r
+    #define HWTC_PERIOD ( TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ )\r
+    #define HWTC_DIVISOR 1    \r
+\r
+    #define IRQ_PRIORITY_ORDER 1  // higher IRQ priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_ARM_CortexM)\r
+\r
+    /* For all chips using ARM Cortex M cores */\r
+\r
+    #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING\r
+    #define HWTC_COUNT (*((uint32_t*)0xE000E018))\r
+    #define HWTC_PERIOD ((*(uint32_t*)0xE000E014) + 1)\r
+    #define HWTC_DIVISOR 2\r
+    \r
+    #define IRQ_PRIORITY_ORDER 0  // lower IRQ priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_Renesas_RX600)    \r
+\r
+    #include "iodefine.h"\r
+\r
+    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+    #define HWTC_COUNT (CMT0.CMCNT)\r
+    #define HWTC_PERIOD ((((TRACE_PERIPHERAL_CLOCK_HZ/TRACE_TICK_RATE_HZ)-1)/8))\r
+    #define HWTC_DIVISOR 1\r
+\r
+    #define IRQ_PRIORITY_ORDER 1  // higher IRQ priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_Microchip_dsPIC_AND_PIC24) \r
+\r
+    /* For Microchip PIC24 and dsPIC (16 bit) */\r
+\r
+    /* Note: The trace library was originally designed for 32-bit MCUs, and is slower\r
+       than intended on 16-bit MCUs. Storing an event on a PIC24 takes about 70 Âµs. \r
+       In comparison, 32-bit MCUs are often 10-20 times faster. If recording overhead \r
+       becomes a problem on PIC24, use the filters to exclude less interesting tasks \r
+       or system calls. */\r
+\r
+    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+    #define HWTC_COUNT (TMR1)\r
+    #define HWTC_PERIOD (PR1+1)\r
+    #define HWTC_DIVISOR 1\r
+\r
+    #define IRQ_PRIORITY_ORDER 0  // lower IRQ priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_NXP_LPC210X)\r
+    /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
+    \r
+    /* Tested with LPC2106, but should work with most LPC21XX chips. */\r
+      \r
+    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+    #define HWTC_COUNT  *((uint32_t *)0xE0004008 )\r
+    #define HWTC_PERIOD ( TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ ) \r
+    #define HWTC_DIVISOR 1    \r
+\r
+    #define IRQ_PRIORITY_ORDER 0  // lower IRQ priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_TEXAS_INSTRUMENTS_TMS570)\r
+    /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
+\r
+    #define RTIFRC0 *((uint32_t *)0xFFFFFC10)\r
+    #define RTICOMP0 *((uint32_t *)0xFFFFFC50)\r
+    #define RTIUDCP0 *((uint32_t *)0xFFFFFC54)\r
+    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+    #define HWTC_COUNT (RTIFRC0 - (RTICOMP0 - RTIUDCP0))\r
+    #define HWTC_PERIOD (RTIUDCP0)\r
+    #define HWTC_DIVISOR 1\r
+\r
+    #define IRQ_PRIORITY_ORDER 0  // lower IRQ priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_TEXAS_INSTRUMENTS_MSP430)\r
+    /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
+\r
+    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+    #define HWTC_COUNT (TA0R)\r
+    #define HWTC_PERIOD TRACE_CPU_CLOCKS_PER_TICK      \r
+    #define HWTC_DIVISOR 1\r
+\r
+    #define IRQ_PRIORITY_ORDER 1  // higher IRQ priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_MICROCHIP_PIC32)\r
+    /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
+\r
+    #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+    #define HWTC_COUNT (ReadTimer1())     /* Should be available in BSP */\r
+    #define HWTC_PERIOD (ReadPeriod1()+1) /* Should be available in BSP */\r
+    #define HWTC_DIVISOR 1\r
+\r
+    #define IRQ_PRIORITY_ORDER 0  // lower IRQ priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_XILINX_PPC405) \r
+    /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
+\r
+    #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING\r
+    #define HWTC_COUNT  mfspr( 0x3db)\r
+    #define HWTC_PERIOD ( TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ )\r
+    #define HWTC_DIVISOR 1\r
+\r
+    #define IRQ_PRIORITY_ORDER 0  // lower IRQ priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_XILINX_PPC440) \r
+    /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
+\r
+    /* This should work with most PowerPC chips */\r
+    \r
+    #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING\r
+    #define HWTC_COUNT  mfspr( 0x016 )\r
+    #define HWTC_PERIOD ( TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ )\r
+    #define HWTC_DIVISOR 1    \r
+\r
+    #define IRQ_PRIORITY_ORDER 0  // lower IRQ priority values are more significant\r
+    \r
+#elif (SELECTED_PORT == PORT_XILINX_MICROBLAZE)\r
+    /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
+\r
+    /* This should work with most Microblaze configurations.\r
+     * It uses the AXI Timer 0 - the tick interrupt source.\r
+     * If an AXI Timer 0 peripheral is available on your hardware platform, no modifications are required.\r
+     */\r
+    #include "xtmrctr_l.h"\r
+\r
+    #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING\r
+    #define HWTC_COUNT XTmrCtr_GetTimerCounterReg( XPAR_TMRCTR_0_BASEADDR, 0 )\r
+    #define HWTC_PERIOD ( TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ )\r
+    #define HWTC_DIVISOR 16\r
+\r
+    #define IRQ_PRIORITY_ORDER 0  // lower IRQ priority values are more significant\r
+\r
+#elif (SELECTED_PORT != PORT_NOT_SET)\r
+\r
+    #error "SELECTED_PORT had unsupported value!"\r
+    #define SELECTED_PORT PORT_NOT_SET\r
+\r
+#endif\r
+\r
+#if (SELECTED_PORT != PORT_NOT_SET)\r
+    \r
+    #ifndef HWTC_COUNT_DIRECTION\r
+    #error "HWTC_COUNT_DIRECTION is not set!"\r
+    #endif \r
+    \r
+    #ifndef HWTC_COUNT\r
+    #error "HWTC_COUNT is not set!"    \r
+    #endif \r
+    \r
+    #ifndef HWTC_PERIOD\r
+    #error "HWTC_PERIOD is not set!"\r
+    #endif \r
+    \r
+    #ifndef HWTC_DIVISOR\r
+    #error "HWTC_DIVISOR is not set!"    \r
+    #endif \r
+    \r
+    #ifndef IRQ_PRIORITY_ORDER\r
+    #error "IRQ_PRIORITY_ORDER is not set!"\r
+    #elif (IRQ_PRIORITY_ORDER != 0) && (IRQ_PRIORITY_ORDER != 1)\r
+    #error "IRQ_PRIORITY_ORDER has bad value!"\r
+    #endif \r
+    \r
+    #if (HWTC_DIVISOR < 1)\r
+    #error "HWTC_DIVISOR must be a non-zero positive value!"\r
+    #endif \r
+\r
+#endif\r
+/*******************************************************************************\r
+ * vTraceConsoleMessage\r
+ *\r
+ * A wrapper for your system-specific console "printf" console output function.\r
+ * This needs to be correctly defined to see status reports from the trace \r
+ * status monitor task (this is defined in trcUser.c).\r
+ ******************************************************************************/         \r
+#if (SELECTED_PORT == PORT_Atmel_AT91SAM7)\r
+/* Port specific includes */\r
+#include "console.h"\r
+#endif\r
+\r
+#define vTraceConsoleMessage(x)\r
+\r
+/*******************************************************************************\r
+ * vTracePortGetTimeStamp\r
+ *\r
+ * Returns the current time based on the HWTC macros which provide a hardware\r
+ * isolation layer towards the hardware timer/counter.\r
+ *\r
+ * The HWTC macros and vTracePortGetTimeStamp is the main porting issue\r
+ * or the trace recorder library. Typically you should not need to change\r
+ * the code of vTracePortGetTimeStamp if using the HWTC macros.\r
+ *\r
+ ******************************************************************************/\r
+void vTracePortGetTimeStamp(uint32_t *puiTimestamp);\r
+\r
+/*******************************************************************************\r
+ * vTracePortEnd\r
+ * \r
+ * This function is called when the recorder is stopped due to full buffer.\r
+ * Mainly intended to show a message in the console.\r
+ * This is used by the Win32 port to store the trace to a file. The file path is\r
+ * set using vTracePortSetFileName.\r
+ ******************************************************************************/\r
+void vTracePortEnd(void);\r
+\r
+#if (INCLUDE_SAVE_TO_FILE == 1)\r
+\r
+/*******************************************************************************\r
+ * vTracePortSetOutFile\r
+ *\r
+ * Sets the filename/path used in vTracePortSave.\r
+ * This is set in a separate function, since the Win32 port calls vTracePortSave\r
+ * in vTracePortEnd if WIN32_PORT_SAVE_WHEN_STOPPED is set.\r
+ ******************************************************************************/\r
+void vTracePortSetOutFile(char* path);\r
+\r
+/******************************************************************************\r
+ * vTracePortSave\r
+ *\r
+ * Saves the trace to a file on a target-side file system. The path is set in a \r
+ * separate function, vTracePortSetOutFile, since the Win32 port may call\r
+ * vTracePortSave in vTracePortEnd, if using WIN32_PORT_SAVE_WHEN_STOPPED.\r
+ ******************************************************************************/\r
+void vTracePortSave(void);\r
+\r
+#else\r
+\r
+#define vTraceConsoleMessage(x)\r
+#define vTracePortSetOutFile(path)\r
+#define vTracePortSave(void)\r
+\r
+#endif\r
+\r
+#endif\r
index 4ffd55c6a84bf19c4e05502b14a7fec40feff125..9196f73d299a807c98598222fdf71e5a5a691b7b 100644 (file)
 /*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
+ * Tracealyzer v2.4.1 Recorder Library\r
  * Percepio AB, www.percepio.com\r
  *\r
  * trcBase.h\r
  *\r
- * Core functionallity of the FreeRTOS+Trace recorder library.\r
+ * Core functionality of the Tracealyzer recorder library.\r
  *\r
  * Terms of Use\r
  * This software is copyright Percepio AB. The recorder library is free for\r
  * use together with Percepio products. You may distribute the recorder library\r
- * in its original form, including modifications in trcPort.c and trcPort.h\r
+ * in its original form, including modifications in trcHardwarePort.c/.h\r
  * given that these modification are clearly marked as your own modifications\r
- * and documented in the initial comment section of these source files. \r
- * This software is the intellectual property of Percepio AB and may not be \r
- * sold or in other ways commercially redistributed without explicit written \r
+ * and documented in the initial comment section of these source files.\r
+ * This software is the intellectual property of Percepio AB and may not be\r
+ * sold or in other ways commercially redistributed without explicit written\r
  * permission by Percepio AB.\r
  *\r
- * Disclaimer \r
- * The trace tool and recorder library is being delivered to you AS IS and \r
- * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
- * not and cannot warrant the performance or results you may obtain by using the \r
- * software or documentation. Percepio AB make no warranties, express or \r
- * implied, as to noninfringement of third party rights, merchantability, or \r
- * fitness for any particular purpose. In no event will Percepio AB, its \r
- * technology partners, or distributors be liable to you for any consequential, \r
- * incidental or special damages, including any lost profits or lost savings, \r
- * even if a representative of Percepio AB has been advised of the possibility \r
- * of such damages, or for any claim by any third party. Some jurisdictions do \r
- * not allow the exclusion or limitation of incidental, consequential or special \r
- * damages, or the exclusion of implied warranties or limitations on how long an \r
+ * Disclaimer\r
+ * The trace tool and recorder library is being delivered to you AS IS and\r
+ * Percepio AB makes no warranty as to its use or performance. Percepio AB does\r
+ * not and cannot warrant the performance or results you may obtain by using the\r
+ * software or documentation. Percepio AB make no warranties, express or\r
+ * implied, as to noninfringement of third party rights, merchantability, or\r
+ * fitness for any particular purpose. In no event will Percepio AB, its\r
+ * technology partners, or distributors be liable to you for any consequential,\r
+ * incidental or special damages, including any lost profits or lost savings,\r
+ * even if a representative of Percepio AB has been advised of the possibility\r
+ * of such damages, or for any claim by any third party. Some jurisdictions do\r
+ * not allow the exclusion or limitation of incidental, consequential or special\r
+ * damages, or the exclusion of implied warranties or limitations on how long an\r
  * implied warranty may last, so the above limitations may not apply to you.\r
- * \r
- * FreeRTOS+Trace is available as Free Edition and in two premium editions.\r
- * You may use the premium features during 30 days for evaluation.\r
- * Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/\r
  *\r
- * Copyright Percepio AB, 2012.\r
+ * Copyright Percepio AB, 2013.\r
  * www.percepio.com\r
  ******************************************************************************/\r
 \r
 #ifndef TRCBASE_H\r
 #define TRCBASE_H\r
 \r
+#define TRACE_MINOR_VERSION 2\r
+#define TRACE_STORE_MODE_STOP_WHEN_FULL 1\r
+#define TRACE_STORE_MODE_RING_BUFFER 2\r
+#define TRACE_DATA_ALLOCATION_STATIC 1\r
+#define TRACE_DATA_ALLOCATION_DYNAMIC 2\r
+#define TRACE_DATA_ALLOCATION_CUSTOM 3\r
+\r
+#include "trcKernelPort.h"\r
+\r
+#if (USE_TRACEALYZER_RECORDER == 1)\r
+\r
 #include <stdio.h>\r
 #include <string.h>\r
 \r
-#include "FreeRTOS.h"\r
-#include "trcConfig.h"\r
-#include "trcTypes.h"\r
-#include "trcPort.h"\r
+#ifndef USE_SEPARATE_USER_EVENT_BUFFER\r
+#define USE_SEPARATE_USER_EVENT_BUFFER 0\r
+#endif\r
 \r
-extern volatile int recorder_busy;\r
+/* Max number of event codes supported */\r
+#define NEventCodes 0x100\r
 \r
-#define trcCRITICAL_SECTION_BEGIN() {taskENTER_CRITICAL(); recorder_busy++;}\r
-#define trcCRITICAL_SECTION_END() {recorder_busy--; taskEXIT_CRITICAL();}\r
+extern volatile int recorder_busy; // This is used to keep track of the recorder's critical sections, to determine if it is busy\r
+// Our local critical sections for the recorder - updates an internal busy flag\r
+#define trcCRITICAL_SECTION_BEGIN() {TRACE_ENTER_CRITICAL_SECTION(); recorder_busy++;}\r
+#define trcCRITICAL_SECTION_END() {recorder_busy--; TRACE_EXIT_CRITICAL_SECTION();}\r
 \r
-#define NCLASSES 5\r
-#define VERSION 0x1AA1\r
-#define MINOR_VERSION 1\r
-#define STORE_MODE_STOP_WHEN_FULL 1\r
-#define STORE_MODE_RING_BUFFER 2\r
-#define TRACE_DATA_ALLOCATION_STATIC 1\r
-#define TRACE_DATA_ALLOCATION_DYNAMIC 2\r
+/* Structure to handle the exclude flags for all objects and tasks. We add some extra objects since index 0 is not used for each object class. */\r
+extern uint8_t excludedObjects[(TRACE_KERNEL_OBJECT_COUNT + TRACE_NCLASSES) / 8 + 1];\r
+\r
+/* Structure to handle the exclude flags for all event codes */\r
+extern uint8_t excludedEventCodes[NEventCodes / 8 + 1];\r
+\r
+/******************************************************************************\r
+ * ObjectHandleStack\r
+ * This data-structure is used to provide a mechanism for 1-byte trace object\r
+ * handles. This way, only 1 byte is necessary instead of 4 bytes (a pointer)\r
+ * when storing a reference to an object. This allows for up to 255 objects of\r
+ * each object class active at any given moment. There can be more "historic"\r
+ * objects, that have been deleted - that number is only limited by the size of\r
+ * the symbol table.\r
+ * Note that handle zero (0) is not used, it is a code for an invalid handle.\r
+ *\r
+ * This data structure keeps track of the FREE handles, not the handles in use.\r
+ * This data structure contains one stack per object class. When a handle is\r
+ * allocated to an object, the next free handle is popped from the stack. When\r
+ * a handle is released (on object delete), it is pushed back on the stack.\r
+ * Note that there is no initialization code that pushed the free handles\r
+ * initially, that is not necessary due to the following optimization:\r
+ *\r
+ * The stack of handles (objectHandles) is initially all zeros. Since zero\r
+ * is not a valid handle, that is a signal of additional handles needed.\r
+ * If a zero is received when popping a new handle, it is replaced by the\r
+ * index of the popped handle instead.\r
+ *\r
+ *****************************************************************************/\r
+typedef struct\r
+{\r
+    /* For each object class, the index of the next handle to allocate */\r
+    int16_t indexOfNextAvailableHandle[ TRACE_NCLASSES ];\r
+\r
+    /* The lowest index of this class (constant) */\r
+    int16_t lowestIndexOfClass[ TRACE_NCLASSES ];\r
+\r
+    /* The highest index of this class (constant) */\r
+    int16_t highestIndexOfClass[ TRACE_NCLASSES ];\r
+\r
+    /* The highest use count for this class (for statistics) */\r
+    int16_t handleCountWaterMarksOfClass[ TRACE_NCLASSES ];\r
+\r
+    /* The free object handles - a set of stacks within this array */\r
+    objectHandleType objectHandles[ TRACE_KERNEL_OBJECT_COUNT ];\r
+\r
+} objectHandleStackType;\r
+\r
+extern objectHandleStackType objectHandleStacks;\r
 \r
 /******************************************************************************\r
  * Object Property Table\r
@@ -69,96 +120,67 @@ extern volatile int recorder_busy;
  * queues, mutexes, etc). The below data structures defines the properties of\r
  * each object class and are used to cast the byte buffer into a cleaner format.\r
  *\r
- * The values in the object table are continously overwritten and always \r
- * represent the current state. If a property is changed during runtime, the OLD \r
- * value should be stored in the trace buffer, not the new value (since the new \r
+ * The values in the object table are continuously overwritten and always\r
+ * represent the current state. If a property is changed during runtime, the OLD\r
+ * value should be stored in the trace buffer, not the new value (since the new\r
  * value is found in the Object Property Table).\r
  * For close events this mechanism is the old names are stored in the symbol\r
  * table), for "priority set" (the old priority is stored in the event data)\r
- * and for "isActive", where the value decides is the taskswitch event type\r
+ * and for "isActive", where the value decides if the task switch event type\r
  * should be "new" or "resume".\r
  ******************************************************************************/\r
 \r
-/* The size of the Object Property Table entries, in bytes, per object */\r
-\r
-/* Queue properties (except name):     current number of message in queue */\r
-#define PropertyTableSizeQueue         (NameLenQueue + 1)      \r
-\r
-/* Semaphore properties (except name): state (signaled = 1, cleared = 0) */\r
-#define PropertyTableSizeSemaphore     (NameLenSemaphore + 1) \r
-\r
-/* Mutex properties (except name):     owner (task handle, 0 = free) */\r
-#define PropertyTableSizeMutex         (NameLenMutex + 1)         \r
-\r
-/* Task properties (except name):      Byte 0: Current priority\r
-                                       Byte 1: state (if already active) \r
-                                       Byte 2: InstanceFinishEvent_ServiceCode\r
-                                       Byte 3: InstanceFinishEvent_ObjHandle */\r
-#define PropertyTableSizeTask         (NameLenTask + 4)\r
-\r
-/* ISR properties:                     Byte 0: priority\r
-                                       Byte 1: state (if already active) */\r
-#define PropertyTableSizeISR          (NameLenISR + 2)\r
-\r
-/* The layout of the byte array representing the Object Property Table */\r
-#define StartIndexQueue            0\r
-#define StartIndexSemaphore        StartIndexQueue     + NQueue * PropertyTableSizeQueue\r
-#define StartIndexMutex            StartIndexSemaphore + NSemaphore * PropertyTableSizeSemaphore\r
-#define StartIndexTask             StartIndexMutex     + NMutex * PropertyTableSizeMutex\r
-#define StartIndexISR              StartIndexTask      + NTask * PropertyTableSizeTask\r
-#define DynObjTableSize            StartIndexISR       + NISR * PropertyTableSizeISR\r
-\r
 typedef struct\r
 {\r
     /* = NCLASSES */\r
     uint32_t NumberOfObjectClasses;\r
-    \r
+\r
     uint32_t ObjectPropertyTableSizeInBytes;\r
-        \r
-    /* This is used to calculate the index in the dynamic object table \r
+\r
+    /* This is used to calculate the index in the dynamic object table\r
     (handle - 1 - nofStaticObjects = index)*/\r
-    uint8_t NumberOfObjectsPerClass[ 4*((NCLASSES+3)/4)];      \r
+    uint8_t NumberOfObjectsPerClass[ 4*((TRACE_NCLASSES+3)/4)];\r
+\r
+    /* Allocation size rounded up to the closest multiple of 4 */\r
+    uint8_t NameLengthPerClass[ 4*((TRACE_NCLASSES+3)/4) ];\r
+\r
+    uint8_t TotalPropertyBytesPerClass[ 4*((TRACE_NCLASSES+3)/4) ];\r
 \r
-    /* Allocation size rounded up to the closest multiple of 4 */    \r
-    uint8_t NameLengthPerClass[ 4*((NCLASSES+3)/4) ];\r
-    \r
-    uint8_t TotalPropertyBytesPerClass[ 4*((NCLASSES+3)/4) ];\r
-    \r
     /* Allocation size rounded up to the closest multiple of 2 */\r
-    uint16_t StartIndexOfClass[ 2*((NCLASSES+1)/2) ];\r
+    uint16_t StartIndexOfClass[ 2*((TRACE_NCLASSES+1)/2) ];\r
 \r
-    /* The actual handles issued, should be Initiated to all zeros */     \r
-    uint8_t objbytes[ 4*((DynObjTableSize+3)/4) ];\r
+    /* The actual handles issued, should be Initiated to all zeros */\r
+    uint8_t objbytes[ 4*((TRACE_OBJECT_TABLE_SIZE+3)/4) ];\r
 } ObjectPropertyTableType;\r
 \r
 /* Symbol table data structure */\r
 typedef struct\r
 {\r
     /* = SYMBOL_HISTORY_TABLE_SIZE_IN_BYTES */\r
-    uint32_t symTableSize;                       \r
-        \r
+    uint32_t symTableSize;\r
+\r
     /* Entry 0 is reserved. Any reference to entry 0 implies NULL*/\r
-    uint32_t nextFreeSymbolIndex;         \r
-        \r
+    uint32_t nextFreeSymbolIndex;\r
+\r
     /* Size rounded up to closest multiple of 4, to avoid alignment issues*/\r
-    uint8_t symbytes[4*((SYMBOL_TABLE_SIZE+3)/4)];           \r
-        \r
-    /* Used for lookups - Up to 64 linked lists within the symbol table \r
-    connecting all entries with the same 6 bit checksum. \r
+    uint8_t symbytes[4*((SYMBOL_TABLE_SIZE+3)/4)];\r
+\r
+    /* Used for lookups - Up to 64 linked lists within the symbol table\r
+    connecting all entries with the same 6 bit checksum.\r
     This field holds the current list heads. Should be initiated to zeros */\r
-    uint16_t latestEntryOfChecksum[64];              \r
+    uint16_t latestEntryOfChecksum[64];\r
 } symbolTableType;\r
 \r
 \r
 /*******************************************************************************\r
- * The data structures of the different events, all 4 bytes long \r
+ * The data structures of the different events, all 4 bytes long\r
  ******************************************************************************/\r
 \r
 typedef struct\r
 {\r
-    uint8_t type;                \r
+    uint8_t type;\r
     objectHandleType objHandle;\r
-    uint16_t dts;    /* differential timestamp - time since last event */            \r
+    uint16_t dts;    /* differential timestamp - time since last event */\r
 } TSEvent, TREvent;\r
 \r
 typedef struct\r
@@ -173,13 +195,13 @@ typedef struct
     uint8_t type;\r
     objectHandleType objHandle;\r
     uint8_t param;\r
-    uint8_t dts;                \r
+    uint8_t dts;\r
 } KernelCallWithParamAndHandle;\r
 \r
 typedef struct\r
 {\r
     uint8_t type;\r
-    uint8_t dts;                \r
+    uint8_t dts;\r
     uint16_t param;\r
 } KernelCallWithParam16;\r
 \r
@@ -193,37 +215,73 @@ typedef struct
 typedef struct\r
 {\r
     uint8_t type;\r
-    uint8_t arg1;            \r
-    uint8_t arg2;        \r
-    uint8_t arg3;        \r
+    uint8_t arg1;\r
+    uint8_t arg2;\r
+    uint8_t arg3;\r
 } ObjClosePropEvent;\r
 \r
 typedef struct\r
 {\r
     uint8_t type;\r
-    uint8_t dts;                \r
+    uint8_t dts;\r
     uint16_t payload;         /* the name of the user event */\r
 } UserEvent;\r
 \r
 typedef struct\r
 {\r
-    uint8_t type;            \r
-    \r
-    /* 8 bits extra for storing DTS, if it does not fit in ordinary event \r
+    uint8_t type;\r
+\r
+    /* 8 bits extra for storing DTS, if it does not fit in ordinary event\r
     (this one is always MSB if used) */\r
-    uint8_t xts_8;            \r
-    \r
+    uint8_t xts_8;\r
+\r
     /* 16 bits extra for storing DTS, if it does not fit in ordinary event. */\r
-    uint16_t xts_16;          \r
+    uint16_t xts_16;\r
 } XTSEvent;\r
 \r
+typedef struct\r
+{\r
+       uint8_t type;\r
+\r
+       uint8_t xps_8;\r
+       uint16_t xps_16;\r
+} XPSEvent;\r
 \r
 /*******************************************************************************\r
- * The main datastructure, read by FreeRTOS+Trace from the RAM dump\r
+ * The separate user event buffer structure. Can be enabled in trcConfig.h.\r
  ******************************************************************************/\r
 \r
+#if (USE_SEPARATE_USER_EVENT_BUFFER == 1)\r
 typedef struct\r
-{    \r
+{\r
+       traceLabel name;\r
+       traceLabel defaultFormat;\r
+} ChannelFormatPair;\r
+\r
+typedef struct\r
+{\r
+       uint16_t bufferID;\r
+       uint16_t version;\r
+       uint32_t wraparoundCounter;\r
+       uint32_t numberOfSlots;\r
+       uint32_t nextSlotToWrite;\r
+       uint8_t numberOfChannels;\r
+       uint8_t padding1;\r
+       uint8_t padding2;\r
+       uint8_t padding3;\r
+       ChannelFormatPair channels[CHANNEL_FORMAT_PAIRS+1];\r
+       uint8_t channelBuffer[(USER_EVENT_BUFFER_SIZE + 3) & 0xFFFFFFFC]; /* 1 byte per slot, with padding for 4 byte alignment */\r
+       uint8_t dataBuffer[USER_EVENT_BUFFER_SIZE * 4]; /* 4 bytes per slot */\r
+\r
+} UserEventBuffer;\r
+#endif\r
+\r
+/*******************************************************************************\r
+ * The main data structure, read by Tracealyzer from the RAM dump\r
+ ******************************************************************************/\r
+\r
+typedef struct\r
+{\r
     uint8_t startmarker0;\r
     uint8_t startmarker1;\r
     uint8_t startmarker2;\r
@@ -237,92 +295,99 @@ typedef struct
     uint8_t startmarker10;\r
     uint8_t startmarker11;\r
 \r
-    /* For FreeRTOS: 0x1AA1 */\r
-    uint16_t version;     \r
-    \r
+    /* Used to determine Kernel and Endianess */\r
+    uint16_t version;\r
+\r
     /* Currently 1 for v2.2.2 (0 earlier)*/\r
     uint8_t minor_version;\r
-    \r
-    /* This should be 0 if lower irq priority values implies higher priority \r
-    levels, such as on ARM Cortex M. If the opposite scheme is used, i.e., \r
-    if higher irq priority values means higher priority, this should be 1. */ \r
+\r
+    /* This should be 0 if lower IRQ priority values implies higher priority\r
+    levels, such as on ARM Cortex M. If the opposite scheme is used, i.e.,\r
+    if higher IRQ priority values means higher priority, this should be 1. */\r
     uint8_t irq_priority_order;\r
-            \r
+\r
     /* sizeof(RecorderDataType) - just for control */\r
     uint32_t filesize;\r
-            \r
+\r
     /* Current number of events recorded */\r
     uint32_t numEvents;\r
 \r
     /* The buffer size, in number of event records */\r
     uint32_t maxEvents;\r
-        \r
+\r
     /* The event buffer index, where to write the next event */\r
     uint32_t nextFreeIndex;\r
-        \r
+\r
     /* 1 if the buffer is full, 0 otherwise */\r
     uint32_t bufferIsFull;\r
 \r
     /* The frequency of the clock/timer/counter used as time base */\r
     uint32_t frequency;\r
 \r
-    /* The absolute timestamp of the last stored event, in the native \r
+    /* The absolute timestamp of the last stored event, in the native\r
     timebase, modulo frequency! */\r
-    uint32_t absTimeLastEvent;    \r
-    \r
+    uint32_t absTimeLastEvent;\r
+\r
     /* The number of seconds in total - lasts for 136 years */\r
-    uint32_t absTimeLastEventSecond;    \r
-    \r
+    uint32_t absTimeLastEventSecond;\r
+\r
     /* 1 if the recorder has been started, 0 if not yet started or stopped.\r
     This is a 32 bit variable due to alignment issues. */\r
-    uint32_t recorderActive;      \r
+    uint32_t recorderActive;\r
 \r
     /* For storing a Team License key */\r
     uint8_t teamLicenceKey[32];\r
 \r
     /* 0xF0F0F0F0 - for control only */\r
-    int32_t debugMarker0;                    \r
+    int32_t debugMarker0;\r
 \r
     /* The Object Property Table holds information about currently active\r
     tasks, queues, and other recorded objects. This is updated on each\r
     create call and includes object name and other properties. */\r
     ObjectPropertyTableType ObjectPropertyTable;\r
 \r
-    /* 0xF1F1F1F1 - for control only */ \r
-    int32_t debugMarker1;                    \r
+    /* 0xF1F1F1F1 - for control only */\r
+    int32_t debugMarker1;\r
 \r
-    /* The Symbol Table stores strings for User Events and is also used to \r
-    store names of deleted objects, which still may be in the trace but no \r
-    longer are available. */        \r
+    /* The Symbol Table stores strings for User Events and is also used to\r
+    store names of deleted objects, which still may be in the trace but no\r
+    longer are available. */\r
     symbolTableType SymbolTable;\r
 \r
-    /* For includsion of float support, and for endian detection of floats. \r
-    The value should be (float)1 or (uint32_t)0 */    \r
+    /* For inclusion of float support, and for endian detection of floats.\r
+    The value should be (float)1 or (uint32_t)0 */\r
 #if (INCLUDE_FLOAT_SUPPORT == 1)\r
-    float exampleFloatEncoding;              \r
+    float exampleFloatEncoding;\r
 #else\r
-    uint32_t exampleFloatEncoding;              \r
+    uint32_t exampleFloatEncoding;\r
 #endif\r
-    /* This is non-zero if an internal error occured in the recorder, e.g., if\r
-    one of the Nxxx constants was too small. The systemInfo string will then \r
-    contain an error message that is displayed when attempting to view the \r
+    /* This is non-zero if an internal error occurred in the recorder, e.g., if\r
+    one of the Nxxx constants was too small. The systemInfo string will then\r
+    contain an error message that is displayed when attempting to view the\r
     trace file. */\r
     uint32_t internalErrorOccured;\r
-    \r
-    /* 0xF2F2F2F2 - for control only */ \r
-    int32_t debugMarker2;                    \r
-      \r
-    /* Generic system information string, presented in the tool. Note that this \r
+\r
+    /* 0xF2F2F2F2 - for control only */\r
+    int32_t debugMarker2;\r
+\r
+    /* Generic system information string, presented in the tool. Note that this\r
     is also used for storing any internal error messages from the recorder, so\r
     do not make TRACE_DESCRIPTION_MAX_LENGTH too small. 80 is recommended. */\r
-    char systemInfo[TRACE_DESCRIPTION_MAX_LENGTH];                   \r
+    char systemInfo[TRACE_DESCRIPTION_MAX_LENGTH];\r
 \r
     /* 0xF3F3F3F3 - for control only */\r
-    int32_t debugMarker3;                    \r
+    int32_t debugMarker3;\r
 \r
     /* The event data, in 4-byte records */\r
     uint8_t eventData[ EVENT_BUFFER_SIZE * 4 ];\r
 \r
+#if (USE_SEPARATE_USER_EVENT_BUFFER == 1)\r
+       UserEventBuffer userEventBuffer;\r
+#endif\r
+\r
+       /* This should always be 0 */\r
+       uint32_t endOfSecondaryBlocks;\r
+\r
     uint8_t endmarker0;\r
     uint8_t endmarker1;\r
     uint8_t endmarker2;\r
@@ -335,103 +400,51 @@ typedef struct
     uint8_t endmarker9;\r
     uint8_t endmarker10;\r
     uint8_t endmarker11;\r
-\r
 } RecorderDataType;\r
 \r
 extern RecorderDataType* RecorderDataPtr;\r
 \r
-/******************************************************************************\r
- * ObjectHandleStack\r
- * This data-structure is used to provide a mechanism for 1-byte trace object\r
- * handles. This way, only 1 byte is necessary instead of 4 bytes (a pointer)\r
- * when storing a reference to an object. This allows for up to 255 objects of\r
- * each object class - Task, ISR, Semaphore, CountingSemaphore, Mutex and Queue,\r
- * active at any given moment. There can be more "historic" objects, that have\r
- * been deleted - that number is only limited by the size of the symbol table.\r
- * Note that handle zero (0) is not used, it is a code for an invalid handle.\r
- *\r
- * This data structure keeps track of the FREE handles, not the handles in use.\r
- * This datastructure contains one stack per object class. When a handle is\r
- * allocated to an object, the next free handle is popped from the stack. When\r
- * a handle is released (on object delete), it is pushed back on the stack.\r
- * Note that there is no initialization code that pushed the free handles\r
- * initially, that is not necessary due to the following optimization:\r
- *\r
- * The stack of handles (objectHandles) is initially all zeros. Since zero\r
- * is not a valid handle, that is a signal of additional handles needed.\r
- * If a zero is received when popping a new handle, it is replaced by the\r
- * index of the popped handle instead.\r
- *\r
- *****************************************************************************/\r
-typedef struct\r
-{\r
-    /* For each object class, the index of the next handle to allocate */\r
-    int16_t indexOfNextAvailableHandle[ NCLASSES ];              \r
-\r
-    /* The lowest index of this class (constant) */        \r
-    int16_t lowestIndexOfClass[ NCLASSES ];                    \r
-        \r
-    /* The highest index of this class (constant) */\r
-    int16_t highestIndexOfClass[ NCLASSES ];    \r
-        \r
-    /* The highest use count for this class (for statistics) */\r
-    int16_t handleCountWaterMarksOfClass[ NCLASSES ];                \r
-        \r
-    /* The free object handles - a set of stacks within this array */\r
-    objectHandleType objectHandles[ NTask+NISR+NSemaphore+NMutex+NQueue ];\r
-\r
-} objectHandleStackType;\r
-\r
-/* Internal data */\r
-\r
-extern objectHandleStackType objectHandleStacks;\r
-\r
-/* Structures to handle the exclude flags for all objects, tasks and event codes */\r
-#define NEventCodes 0x100\r
-extern uint8_t excludedFlags[(NEventCodes+NQueue+NSemaphore+NMutex+NTask) / 8 + 1];\r
-extern uint8_t ifeFlags[NTask / 8 + 1];\r
-\r
 /* Internal functions */\r
 \r
 uint16_t prvTraceGetDTS(uint16_t param_maxDTS);\r
 \r
 void prvTraceGetChecksum(const char *pname, uint8_t* pcrc, uint8_t* plength);\r
 \r
-traceLabel prvTraceCreateSymbolTableEntry(const char* name, \r
-                                          uint8_t crc6, \r
-                                          uint8_t len, \r
+traceLabel prvTraceCreateSymbolTableEntry(const char* name,\r
+                                          uint8_t crc6,\r
+                                          uint8_t len,\r
                                           traceLabel channel);\r
 \r
-traceLabel prvTraceLookupSymbolTableEntry(const char* name, \r
-                                          uint8_t crc6, \r
-                                          uint8_t len, \r
+traceLabel prvTraceLookupSymbolTableEntry(const char* name,\r
+                                          uint8_t crc6,\r
+                                          uint8_t len,\r
                                           traceLabel channel);\r
 \r
 traceLabel prvTraceOpenSymbol(const char* name, traceLabel userEventChannel);\r
 \r
 void prvTraceUpdateCounters(void);\r
 \r
-void prvCheckDataToBeOverwrittenForMultiEntryUserEvents(uint8_t nEntries);\r
+void prvCheckDataToBeOverwrittenForMultiEntryEvents(uint8_t nEntries);\r
 \r
 objectHandleType xTraceGetObjectHandle(traceObjectClass objectclass);\r
 \r
-void vTraceFreeObjectHandle(traceObjectClass objectclass, \r
+void vTraceFreeObjectHandle(traceObjectClass objectclass,\r
                             objectHandleType handle);\r
 \r
-void vTraceSetObjectName(traceObjectClass objectclass, \r
-                         objectHandleType handle, \r
-                         const char* name);\r
+void vTraceSetObjectName(traceObjectClass objectclass,\r
+                           objectHandleType handle,\r
+                           const char* name);\r
 \r
 void* xTraceNextFreeEventBufferSlot(void);\r
 \r
-uint16_t uiIndexOfObject(objectHandleType objecthandle, \r
-    uint8_t objectclass);\r
+uint16_t uiIndexOfObject(objectHandleType objecthandle,\r
+                         uint8_t objectclass);\r
 \r
 \r
 /*******************************************************************************\r
  * vTraceError\r
  *\r
- * Called by various parts in the recorder. Stops the recorder and stores a \r
+ * Called by various parts in the recorder. Stops the recorder and stores a\r
  * pointer to an error message, which is printed by the monitor task.\r
  ******************************************************************************/\r
 void vTraceError(const char* msg);\r
@@ -445,80 +458,48 @@ void vTraceError(const char* msg);
 char* xTraceGetLastError(void);\r
 \r
 /*******************************************************************************\r
- * xTraceInitTraceData\r
+ * prvTraceInitTraceData\r
  *\r
- * Allocates and initializes the recorder datastructure, based on the constants\r
+ * Allocates and initializes the recorder data structure, based on the constants\r
  * in trcConfig.h. This allows for allocating the data on the heap, instead of\r
  * using a static declaration.\r
  ******************************************************************************/\r
-RecorderDataType* xTraceInitTraceData(void);\r
+void prvTraceInitTraceData(void);\r
 \r
 /* Internal macros */\r
 \r
-#define PROPERTY_NAME_GET(objectclass, objecthandle) \\r
+#define TRACE_PROPERTY_NAME_GET(objectclass, objecthandle) \\r
 (const char*)(& RecorderDataPtr->ObjectPropertyTable.objbytes \\r
 [uiIndexOfObject(objecthandle, objectclass)])\r
 \r
-#define PROPERTY_OBJECT_STATE(objectclass, handle) \\r
+#define TRACE_PROPERTY_OBJECT_STATE(objectclass, handle) \\r
 RecorderDataPtr->ObjectPropertyTable.objbytes[uiIndexOfObject(handle, objectclass) \\r
 + RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[objectclass]]\r
 \r
-#define PROPERTY_ACTOR_PRIORITY(objectclass, handle) \\r
+#define TRACE_PROPERTY_ACTOR_PRIORITY(objectclass, handle) \\r
 RecorderDataPtr->ObjectPropertyTable.objbytes[uiIndexOfObject(handle, objectclass) \\r
 + RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[objectclass] + 1]\r
 \r
-#define PROPERTY_TASK_IFE_SERVICECODE(handle) \\r
-RecorderDataPtr->ObjectPropertyTable.objbytes \\r
-[uiIndexOfObject(handle, TRACE_CLASS_TASK) \\r
-+ RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[TRACE_CLASS_TASK]+2]\r
-\r
-#define PROPERTY_TASK_IFE_OBJHANDLE(handle) \\r
-RecorderDataPtr->ObjectPropertyTable.objbytes \\r
-[uiIndexOfObject(handle, TRACE_CLASS_TASK) \\r
-+  RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[TRACE_CLASS_TASK]+3]\r
-\r
-#define SET_FLAG_ISEXCLUDED(bitIndex) excludedFlags[(bitIndex) >> 3] |= (1 << ((bitIndex) & 7))\r
-#define CLEAR_FLAG_ISEXCLUDED(bitIndex) excludedFlags[(bitIndex) >> 3] &= ~(1 << ((bitIndex) & 7))\r
-#define GET_FLAG_ISEXCLUDED(bitIndex) (excludedFlags[(bitIndex) >> 3] & (1 << ((bitIndex) & 7)))\r
-\r
-#define SET_FLAG_MARKIFE(bitIndex) ifeFlags[(bitIndex) >> 3] |= (1 << ((bitIndex) & 7))\r
-#define CLEAR_FLAG_MARKIFE(bitIndex) ifeFlags[(bitIndex) >> 3] &= ~(1 << ((bitIndex) & 7))\r
-#define GET_FLAG_MARKIFE(bitIndex) (ifeFlags[(bitIndex) >> 3] & (1 << ((bitIndex) & 7)))\r
-\r
-#define SET_EVENT_CODE_FLAG_ISEXCLUDED(eventCode) SET_FLAG_ISEXCLUDED(eventCode)\r
-#define CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(eventCode) CLEAR_FLAG_ISEXCLUDED(eventCode)\r
-#define GET_EVENT_CODE_FLAG_ISEXCLUDED(eventCode) GET_FLAG_ISEXCLUDED(eventCode)\r
-\r
-#define SET_QUEUE_FLAG_ISEXCLUDED(queueHandle) SET_FLAG_ISEXCLUDED(NEventCodes+queueHandle-1)\r
-#define CLEAR_QUEUE_FLAG_ISEXCLUDED(queueHandle) CLEAR_FLAG_ISEXCLUDED(NEventCodes+queueHandle-1)\r
-#define GET_QUEUE_FLAG_ISEXCLUDED(queueHandle) GET_FLAG_ISEXCLUDED(NEventCodes+queueHandle-1)\r
-\r
-#define SET_SEMAPHORE_FLAG_ISEXCLUDED(semaphoreHandle) SET_FLAG_ISEXCLUDED(NEventCodes+NQueue+semaphoreHandle-1)\r
-#define CLEAR_SEMAPHORE_FLAG_ISEXCLUDED(semaphoreHandle) CLEAR_FLAG_ISEXCLUDED(NEventCodes+NQueue+semaphoreHandle-1)\r
-#define GET_SEMAPHORE_FLAG_ISEXCLUDED(semaphoreHandle) GET_FLAG_ISEXCLUDED(NEventCodes+NQueue+semaphoreHandle-1)\r
-\r
-#define SET_MUTEX_FLAG_ISEXCLUDED(mutexHandle) SET_FLAG_ISEXCLUDED(NEventCodes+NQueue+NSemaphore+mutexHandle-1)\r
-#define CLEAR_MUTEX_FLAG_ISEXCLUDED(mutexHandle) CLEAR_FLAG_ISEXCLUDED(NEventCodes+NQueue+NSemaphore+mutexHandle-1)\r
-#define GET_MUTEX_FLAG_ISEXCLUDED(mutexHandle) GET_FLAG_ISEXCLUDED(NEventCodes+NQueue+NSemaphore+mutexHandle-1)\r
-\r
-#define SET_TASK_FLAG_ISEXCLUDED(taskHandle) SET_FLAG_ISEXCLUDED(NEventCodes+NQueue+NSemaphore+NMutex+taskHandle-1)\r
-#define CLEAR_TASK_FLAG_ISEXCLUDED(taskHandle) CLEAR_FLAG_ISEXCLUDED(NEventCodes+NQueue+NSemaphore+NMutex+taskHandle-1)\r
-#define GET_TASK_FLAG_ISEXCLUDED(taskHandle) GET_FLAG_ISEXCLUDED(NEventCodes+NQueue+NSemaphore+NMutex+taskHandle-1)\r
-\r
-#define SET_TASK_FLAG_MARKIFE(bitIndex) SET_FLAG_MARKIFE(bitIndex-1)\r
-#define CLEAR_TASK_FLAG_MARKIFE(bitIndex) CLEAR_FLAG_MARKIFE(bitIndex-1)\r
-#define GET_TASK_FLAG_MARKIFE(bitIndex) GET_FLAG_MARKIFE(bitIndex-1)\r
-\r
-/* For debug printouts - the names of the object classes */\r
-extern char OBJECTCLASSNAME[NCLASSES][10];\r
-/*=\r
-{\r
-        "QUEUE"\r
-        "SEMAPHORE",\r
-        "MUTEX",\r
-        "TASK",\r
-        "ISR"\r
-};*/\r
+#define TRACE_SET_FLAG_ISEXCLUDED(flags, bitIndex) flags[(bitIndex) >> 3] |= (1 << ((bitIndex) & 7))\r
+#define TRACE_CLEAR_FLAG_ISEXCLUDED(flags, bitIndex) flags[(bitIndex) >> 3] &= ~(1 << ((bitIndex) & 7))\r
+#define TRACE_GET_FLAG_ISEXCLUDED(flags, bitIndex) (flags[(bitIndex) >> 3] & (1 << ((bitIndex) & 7)))\r
+\r
+#define TRACE_SET_EVENT_CODE_FLAG_ISEXCLUDED(eventCode) TRACE_SET_FLAG_ISEXCLUDED(excludedEventCodes, eventCode)\r
+#define TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(eventCode) TRACE_CLEAR_FLAG_ISEXCLUDED(excludedEventCodes, eventCode)\r
+#define TRACE_GET_EVENT_CODE_FLAG_ISEXCLUDED(eventCode) TRACE_GET_FLAG_ISEXCLUDED(excludedEventCodes, eventCode)\r
+\r
+/* DEBUG ASSERTS */\r
+#if defined USE_TRACE_ASSERT && USE_TRACE_ASSERT != 0\r
+#define TRACE_ASSERT(eval, msg, defRetVal) \\r
+if (!(eval)) \\r
+{ \\r
+       vTraceError("TRACE_ASSERT: " msg); \\r
+       return defRetVal; \\r
+}\r
+#else\r
+#define TRACE_ASSERT(eval, msg, defRetVal)\r
+#endif\r
 \r
 #endif\r
 \r
+#endif
\ No newline at end of file
index c5fc9a4d1eb7a6a9d8280dc3c80baa6a29f1838e..66c38140610cc2f544099c8a4d884819765e45bf 100644 (file)
 /*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
- * Percepio AB, www.percepio.com\r
- *\r
- * trcHooks.h\r
- *\r
- * The kernel integration hooks for FreeRTOS (v7.1.0 or later). This file should\r
- * be included in the end of FreeRTOSConfig.h, together with:\r
- *\r
- * #define configUSE_TRACE_FACILITY 1\r
- *\r
- * NOTE: \r
- * For IAR Embedded Workbench for ARM, you need to have a preprocessor condition\r
- * on the include, to except it from the assembler step which otherwise give\r
- * compile-time errors.\r
- *\r
- * #ifdef __ICCARM__\r
- *       #include "percepio/Include/trcHooks.h"\r
- * #endif\r
- * \r
- * Terms of Use\r
- * This software is copyright Percepio AB. The recorder library is free for\r
- * use together with Percepio products. You may distribute the recorder library\r
- * in its original form, including modifications in trcPort.c and trcPort.h\r
- * given that these modification are clearly marked as your own modifications\r
- * and documented in the initial comment section of these source files. \r
- * This software is the intellectual property of Percepio AB and may not be \r
- * sold or in other ways commercially redistributed without explicit written \r
- * permission by Percepio AB.\r
- *\r
- * Disclaimer \r
- * The trace tool and recorder library is being delivered to you AS IS and \r
- * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
- * not and cannot warrant the performance or results you may obtain by using the \r
- * software or documentation. Percepio AB make no warranties, express or \r
- * implied, as to noninfringement of third party rights, merchantability, or \r
- * fitness for any particular purpose. In no event will Percepio AB, its \r
- * technology partners, or distributors be liable to you for any consequential, \r
- * incidental or special damages, including any lost profits or lost savings, \r
- * even if a representative of Percepio AB has been advised of the possibility \r
- * of such damages, or for any claim by any third party. Some jurisdictions do \r
- * not allow the exclusion or limitation of incidental, consequential or special \r
- * damages, or the exclusion of implied warranties or limitations on how long an \r
- * implied warranty may last, so the above limitations may not apply to you.\r
- *\r
- * FreeRTOS+Trace is available as Free Edition and in two premium editions.\r
- * You may use the premium features during 30 days for evaluation.\r
- * Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/\r
- *\r
- * Copyright Percepio AB, 2012.\r
- * www.percepio.com\r
- ******************************************************************************/\r
+* Tracealyzer v2.4.1 Recorder Library\r
+* Percepio AB, www.percepio.com\r
+*\r
+* trcKernelHooks.h\r
+*\r
+* The kernel integration hooks.\r
+*\r
+* NOTE:\r
+* For IAR Embedded Workbench for ARM, you need to have a preprocessor condition\r
+* on the include, to except it from the assembler step which otherwise give\r
+* compile-time errors.\r
+*\r
+* #ifdef __ICCARM__\r
+*       #include "percepio/Include/trcKernelHooks.h"\r
+* #endif\r
+*\r
+* Terms of Use\r
+* This software is copyright Percepio AB. The recorder library is free for\r
+* use together with Percepio products. You may distribute the recorder library\r
+* in its original form, including modifications in trcPort.c and trcPort.h\r
+* given that these modification are clearly marked as your own modifications\r
+* and documented in the initial comment section of these source files.\r
+* This software is the intellectual property of Percepio AB and may not be\r
+* sold or in other ways commercially redistributed without explicit written\r
+* permission by Percepio AB.\r
+*\r
+* Disclaimer\r
+* The trace tool and recorder library is being delivered to you AS IS and\r
+* Percepio AB makes no warranty as to its use or performance. Percepio AB does\r
+* not and cannot warrant the performance or results you may obtain by using the\r
+* software or documentation. Percepio AB make no warranties, express or\r
+* implied, as to noninfringement of third party rights, merchantability, or\r
+* fitness for any particular purpose. In no event will Percepio AB, its\r
+* technology partners, or distributors be liable to you for any consequential,\r
+* incidental or special damages, including any lost profits or lost savings,\r
+* even if a representative of Percepio AB has been advised of the possibility\r
+* of such damages, or for any claim by any third party. Some jurisdictions do\r
+* not allow the exclusion or limitation of incidental, consequential or special\r
+* damages, or the exclusion of implied warranties or limitations on how long an\r
+* implied warranty may last, so the above limitations may not apply to you.\r
+*\r
+* Copyright Percepio AB, 2013.\r
+* www.percepio.com\r
+******************************************************************************/\r
+\r
+#ifndef TRCKERNELHOOKS_H\r
+#define TRCKERNELHOOKS_H\r
+\r
+#if (USE_TRACEALYZER_RECORDER == 1)\r
+\r
+#undef INCLUDE_xTaskGetSchedulerState\r
+#define INCLUDE_xTaskGetSchedulerState 1\r
+\r
+#undef INCLUDE_xTaskGetCurrentTaskHandle\r
+#define INCLUDE_xTaskGetCurrentTaskHandle 1\r
 \r
-#ifndef TRCHOOKS_H\r
-#define TRCHOOKS_H\r
-\r
-#if (configUSE_TRACE_FACILITY == 1)\r
-\r
-    #include "trcUser.h"\r
-       \r
-    #undef INCLUDE_xTaskGetSchedulerState\r
-    #define INCLUDE_xTaskGetSchedulerState 1\r
-       \r
-    #undef INCLUDE_xTaskGetCurrentTaskHandle\r
-    #define INCLUDE_xTaskGetCurrentTaskHandle 1\r
-       \r
-#if !defined INCLUDE_READY_EVENTS || INCLUDE_READY_EVENTS == 1\r
-    /* Called for each task that becomes ready */\r
-    #undef traceMOVED_TASK_TO_READY_STATE\r
-    #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) \\r
-    vTraceStoreTaskReady((unsigned char)pxTCB->uxTaskNumber);\r
+#ifndef INCLUDE_OBJECT_DELETE\r
+#define INCLUDE_OBJECT_DELETE 0\r
 #endif\r
-       \r
-    /* Called on each OS tick. Will call uiPortGetTimestamp to make sure it is called at least once every OS tick. */\r
-    #undef traceTASK_INCREMENT_TICK\r
-    #define traceTASK_INCREMENT_TICK( xTickCount ) \\r
-      if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxMissedTicks == 0) {extern uint32_t uiTraceTickCount; uiTraceTickCount++; uiTracePortGetTimeStamp(0);}\r
-\r
-    /* Called on each task-switch */\r
-    #undef traceTASK_SWITCHED_IN\r
-    #define traceTASK_SWITCHED_IN() \\r
-      vTraceStoreTaskswitch();\r
 \r
-    /* Called on vTaskSuspend */\r
-    #undef traceTASK_SUSPEND\r
-    #define traceTASK_SUSPEND( pxTaskToSuspend ) \\r
-      vTraceStoreKernelCall(TASK_SUSPEND, TRACE_CLASS_TASK, pxTaskToSuspend->uxTaskNumber); \\r
-      vTraceSetTaskInstanceFinished((uint8_t)pxTaskToSuspend->uxTaskNumber);\r
-\r
-    /* Called on vTaskDelay - note the use of FreeRTOS variable xTicksToDelay */\r
-    #undef traceTASK_DELAY\r
-    #define traceTASK_DELAY() \\r
-      portENTER_CRITICAL(); \\r
-      vTraceStoreKernelCallWithNumericParamOnly(TASK_DELAY, (uint16_t)xTicksToDelay);\\r
-      vTraceSetTaskInstanceFinished((uint8_t)pxCurrentTCB->uxTaskNumber);\\r
-      portEXIT_CRITICAL();\r
-\r
-    /* Called on vTaskDelayUntil - note the use of FreeRTOS variable xTimeToWake */\r
-    #undef traceTASK_DELAY_UNTIL\r
-    #define traceTASK_DELAY_UNTIL() \\r
-      portENTER_CRITICAL(); \\r
-      vTraceStoreKernelCallWithNumericParamOnly(TASK_DELAY_UNTIL, (uint16_t)xTimeToWake); \\r
-      vTraceSetTaskInstanceFinished((uint8_t)pxCurrentTCB->uxTaskNumber); \\r
-      portEXIT_CRITICAL();\r
+#ifndef INCLUDE_READY_EVENTS\r
+#define INCLUDE_READY_EVENTS 1\r
+#endif\r
 \r
-#ifndef INCLUDE_OBJECT_DELETE\r
-#define INCLUDE_OBJECT_DELETE 1\r
+#ifndef INCLUDE_NEW_TIME_EVENTS\r
+#define INCLUDE_NEW_TIME_EVENTS 0\r
 #endif\r
 \r
 #if (INCLUDE_OBJECT_DELETE == 1)\r
-    /* Called on vTaskDelete */\r
-    #undef traceTASK_DELETE\r
-    #define traceTASK_DELETE( pxTaskToDelete ) \\r
-      trcCRITICAL_SECTION_BEGIN(); \\r
-      vTraceStoreKernelCall(EVENTGROUP_DELETE + TRACE_CLASS_TASK, TRACE_CLASS_TASK, pxTaskToDelete->uxTaskNumber); \\r
-      vTraceStoreObjectNameOnCloseEvent((objectHandleType)pxTaskToDelete->uxTaskNumber, TRACE_CLASS_TASK); \\r
-      vTraceStoreObjectPropertiesOnCloseEvent((objectHandleType)pxTaskToDelete->uxTaskNumber, TRACE_CLASS_TASK); \\r
-      vTraceSetPriorityProperty(TRACE_CLASS_TASK, (objectHandleType)pxTaskToDelete->uxTaskNumber, (uint8_t)pxTaskToDelete->uxPriority); \\r
-      vTraceSetObjectState(TRACE_CLASS_TASK, (objectHandleType)pxTaskToDelete->uxTaskNumber, TASK_STATE_INSTANCE_NOT_ACTIVE); \\r
-      vTraceFreeObjectHandle(TRACE_CLASS_TASK, (objectHandleType)pxTaskToDelete->uxTaskNumber); \\r
-      trcCRITICAL_SECTION_END();\r
+/* This macro will remove the task and store it in the event buffer */\r
+#undef trcKERNEL_HOOKS_TASK_DELETE\r
+#define trcKERNEL_HOOKS_TASK_DELETE(SERVICE, pxTCB) \\r
+       vTraceStoreKernelCall(TRACE_GET_TASK_EVENT_CODE(SERVICE, SUCCESS, CLASS, pxTCB), TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); \\r
+       vTraceStoreObjectNameOnCloseEvent(TRACE_GET_TASK_NUMBER(pxTCB), TRACE_CLASS_TASK); \\r
+       vTraceStoreObjectPropertiesOnCloseEvent(TRACE_GET_TASK_NUMBER(pxTCB), TRACE_CLASS_TASK); \\r
+       vTraceSetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_GET_TASK_PRIORITY(pxTCB)); \\r
+       vTraceSetObjectState(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TASK_STATE_INSTANCE_NOT_ACTIVE); \\r
+       vTraceFreeObjectHandle(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB));\r
+#else\r
+#undef trcKERNEL_HOOKS_TASK_DELETE\r
+#define trcKERNEL_HOOKS_TASK_DELETE(SERVICE, pxTCB)\r
 #endif\r
 \r
-    /* Called on vTaskCreate */\r
-    #undef traceTASK_CREATE\r
-    #define traceTASK_CREATE( pxNewTCB ) \\r
-      if (pxNewTCB != NULL){ \\r
-          pxNewTCB->uxTaskNumber = xTraceGetObjectHandle(TRACE_CLASS_TASK); \\r
-          vTraceSetObjectName(TRACE_CLASS_TASK, (objectHandleType)pxNewTCB->uxTaskNumber, (char*)pxNewTCB->pcTaskName); \\r
-          vTraceSetPriorityProperty(TRACE_CLASS_TASK, (objectHandleType)pxNewTCB->uxTaskNumber, (uint8_t)pxNewTCB->uxPriority); \\r
-          vTraceStoreKernelCall(EVENTGROUP_CREATE + TRACE_CLASS_TASK, TRACE_CLASS_TASK, pxNewTCB->uxTaskNumber);\\r
-      }\r
-\r
-    /* Called in vTaskCreate, if it fails (typically if the stack can not be allocated) */\r
-    #undef traceTASK_CREATE_FAILED\r
-    #define traceTASK_CREATE_FAILED() \\r
-      portENTER_CRITICAL();\\r
-      vTraceStoreKernelCall(EVENTGROUP_FAILED_CREATE + TRACE_CLASS_TASK, TRACE_CLASS_TASK, 0); \\r
-      portEXIT_CRITICAL();\r
-\r
-    /* Called in xQueueCreate, and thereby for all other object based on queues, such as semaphores. */\r
-    #undef traceQUEUE_CREATE\r
-    #define traceQUEUE_CREATE( pxNewQueue )\\r
-        portENTER_CRITICAL(); \\r
-        pxNewQueue->ucQueueNumber = xTraceGetObjectHandle(TraceObjectClassTable[pxNewQueue->ucQueueType]);\\r
-        vTraceStoreKernelCall(EVENTGROUP_CREATE + TraceObjectClassTable[pxNewQueue->ucQueueType], TraceObjectClassTable[pxNewQueue->ucQueueType], pxNewQueue->ucQueueNumber); \\r
-        vTraceSetObjectState(TraceObjectClassTable[pxNewQueue->ucQueueType], pxNewQueue->ucQueueNumber, 0); \\r
-        portEXIT_CRITICAL();\r
-\r
-    /* Called in xQueueCreate, if the queue creation fails */\r
-    #undef traceQUEUE_CREATE_FAILED\r
-    #define traceQUEUE_CREATE_FAILED( queueType ) \\r
-        portENTER_CRITICAL();\\r
-        vTraceStoreKernelCall((uint8_t)(EVENTGROUP_FAILED_CREATE + TraceObjectClassTable[queueType]), TraceObjectClassTable[queueType], 0); \\r
-        portEXIT_CRITICAL();\r
-    \r
-    /* Called in xQueueCreateMutex, and thereby also from xSemaphoreCreateMutex and xSemaphoreCreateRecursiveMutex */\r
-    #undef traceCREATE_MUTEX\r
-    #define traceCREATE_MUTEX( pxNewQueue ) \\r
-      portENTER_CRITICAL();\\r
-      pxNewQueue->ucQueueNumber = xTraceGetObjectHandle(TRACE_CLASS_MUTEX); \\r
-      vTraceStoreKernelCall(EVENTGROUP_CREATE + TraceObjectClassTable[pxNewQueue->ucQueueType], TraceObjectClassTable[pxNewQueue->ucQueueType], pxNewQueue->ucQueueNumber); \\r
-      vTraceSetObjectState(TraceObjectClassTable[pxNewQueue->ucQueueType], pxNewQueue->ucQueueNumber, 0); \\r
-      portEXIT_CRITICAL();\r
-\r
-    /* Called in xQueueCreateMutex when the operation fails (when memory allocation fails) */\r
-    #undef traceCREATE_MUTEX_FAILED\r
-    #define traceCREATE_MUTEX_FAILED() \\r
-        portENTER_CRITICAL();\\r
-        vTraceStoreKernelCall(EVENTGROUP_FAILED_CREATE + TRACE_CLASS_MUTEX, TRACE_CLASS_MUTEX, 0);\\r
-        portEXIT_CRITICAL();\r
-\r
-    /* Called when the Mutex can not be given, since not holder */\r
-    #undef traceGIVE_MUTEX_RECURSIVE_FAILED\r
-    #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) \\r
-        portENTER_CRITICAL();\\r
-        vTraceStoreKernelCall(EVENTGROUP_FAILED_SEND + TRACE_CLASS_MUTEX, TRACE_CLASS_MUTEX, pxMutex->ucQueueNumber); \\r
-        portEXIT_CRITICAL();\r
-\r
-    /* Called when a message is sent to a queue */\r
-    #undef traceQUEUE_SEND\r
-    #define traceQUEUE_SEND( pxQueue ) \\r
-      vTraceStoreKernelCall(EVENTGROUP_SEND + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \\r
-      if (TraceObjectClassTable[pxQueue->ucQueueType] == TRACE_CLASS_MUTEX){\\r
-          vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (uint8_t)pxQueue->ucQueueNumber, (uint8_t)0); \\r
-      }else{\\r
-          vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (uint8_t)pxQueue->ucQueueNumber, (uint8_t)(pxQueue->uxMessagesWaiting + 1)); \\r
-      }\r
-\r
-    /* Called when a message failed to be sent to a queue (timeout) */\r
-    #undef traceQUEUE_SEND_FAILED\r
-    #define traceQUEUE_SEND_FAILED( pxQueue ) \\r
-      portENTER_CRITICAL();\\r
-      vTraceStoreKernelCall(EVENTGROUP_FAILED_SEND + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \\r
-      portEXIT_CRITICAL();\r
-\r
-    /* Called when the task is blocked due to a send operation on a full queue */\r
-    #undef traceBLOCKING_ON_QUEUE_SEND\r
-    #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) \\r
-      portENTER_CRITICAL();\\r
-      vTraceStoreKernelCall(EVENTGROUP_BLOCK_ON_SEND + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \\r
-      portEXIT_CRITICAL();\r
-                \r
-    /* Called when a message is received from a queue */\r
-    #undef traceQUEUE_RECEIVE\r
-    #define traceQUEUE_RECEIVE( pxQueue ) \\r
-      vTraceStoreKernelCall(EVENTGROUP_RECEIVE + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \\r
-      if (TraceObjectClassTable[pxQueue->ucQueueType] == TRACE_CLASS_MUTEX){\\r
-          extern volatile void * volatile pxCurrentTCB; \\r
-          vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (objectHandleType)pxQueue->ucQueueNumber, (objectHandleType)uxTaskGetTaskNumber((xTaskHandle)pxCurrentTCB)); /*For mutex, store the new owner rather than queue length */ \\r
-      }else{\\r
-          vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (objectHandleType)pxQueue->ucQueueNumber, (uint8_t)(pxQueue->uxMessagesWaiting - 1)); \\r
-      }\r
-        \r
-    /* Called when the task is blocked due to a receive operation on an empty queue */\r
-    #undef traceBLOCKING_ON_QUEUE_RECEIVE\r
-    #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) \\r
-      portENTER_CRITICAL(); \\r
-      vTraceStoreKernelCall(EVENTGROUP_BLOCK_ON_RECEIVE + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \\r
-      if (TraceObjectClassTable[pxQueue->ucQueueType] != TRACE_CLASS_MUTEX){\\r
-          extern volatile void * volatile pxCurrentTCB; \\r
-          vTraceSetTaskInstanceFinished((objectHandleType)uxTaskGetTaskNumber((xTaskHandle)pxCurrentTCB)); \\r
-      }\\r
-      portEXIT_CRITICAL();\r
-\r
-    /* Called on xQueuePeek */\r
-    #undef traceQUEUE_PEEK\r
-    #define traceQUEUE_PEEK( pxQueue ) \\r
-        vTraceStoreKernelCall(EVENTGROUP_PEEK + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber);\r
-\r
-    /* Called when a receive operation on a queue fails (timeout) */\r
-    #undef traceQUEUE_RECEIVE_FAILED\r
-    #define traceQUEUE_RECEIVE_FAILED( pxQueue ) \\r
-      portENTER_CRITICAL(); \\r
-      vTraceStoreKernelCall(EVENTGROUP_FAILED_RECEIVE + TraceObjectClassTable[pxQueue->ucQueueType],  TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \\r
-      portEXIT_CRITICAL();\r
-        \r
-    /* Called when a message is sent from interrupt context, e.g., using xQueueSendFromISR */\r
-    #undef traceQUEUE_SEND_FROM_ISR\r
-    #define traceQUEUE_SEND_FROM_ISR( pxQueue ) \\r
-      vTraceStoreKernelCall(EVENTGROUP_SEND_FROM_ISR + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \\r
-      vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (objectHandleType)pxQueue->ucQueueNumber, (uint8_t)(pxQueue->uxMessagesWaiting + 1));\r
-\r
-    /* Called when a message send from interrupt context fails (since the queue was full) */\r
-    #undef traceQUEUE_SEND_FROM_ISR_FAILED\r
-    #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) \\r
-      vTraceStoreKernelCall(EVENTGROUP_FAILED_SEND_FROM_ISR + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber);\r
-\r
-    /* Called when a message is received in interrupt context, e.g., using xQueueReceiveFromISR */\r
-    #undef traceQUEUE_RECEIVE_FROM_ISR\r
-    #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) \\r
-      vTraceStoreKernelCall(EVENTGROUP_RECEIVE_FROM_ISR + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \\r
-      vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (objectHandleType)pxQueue->ucQueueNumber, (uint8_t)(pxQueue->uxMessagesWaiting - 1));\r
-    \r
-    /* Called when a message receive from interrupt context fails (since the queue was empty) */\r
-    #undef traceQUEUE_RECEIVE_FROM_ISR_FAILED\r
-    #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) \\r
-      vTraceStoreKernelCall(EVENTGROUP_FAILED_RECEIVE_FROM_ISR + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber);\r
-\r
 #if (INCLUDE_OBJECT_DELETE == 1)\r
-    /* Called on vQueueDelete */\r
-    #undef traceQUEUE_DELETE\r
-    #define traceQUEUE_DELETE( pxQueue ) \\r
-    { \\r
-        portENTER_CRITICAL();\\r
-        vTraceStoreKernelCall(EVENTGROUP_DELETE + TraceObjectClassTable[pxQueue->ucQueueType], TraceObjectClassTable[pxQueue->ucQueueType], pxQueue->ucQueueNumber); \\r
-        vTraceStoreObjectNameOnCloseEvent((objectHandleType)pxQueue->ucQueueNumber, TraceObjectClassTable[pxQueue->ucQueueType]); \\r
-        vTraceStoreObjectPropertiesOnCloseEvent((objectHandleType)pxQueue->ucQueueNumber, TraceObjectClassTable[pxQueue->ucQueueType]); \\r
-        if (TraceObjectClassTable[pxQueue->ucQueueType] == TRACE_CLASS_MUTEX){ \\r
-            vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (objectHandleType)pxQueue->ucQueueNumber, (objectHandleType)uxTaskGetTaskNumber((xTaskHandle)pxQueue->pxMutexHolder)); \\r
-        }else{ \\r
-            vTraceSetObjectState(TraceObjectClassTable[pxQueue->ucQueueType], (objectHandleType)pxQueue->ucQueueNumber, (uint8_t)uxQueueMessagesWaiting(pxQueue)); \\r
-        } \\r
-        vTraceFreeObjectHandle(TraceObjectClassTable[pxQueue->ucQueueType], (objectHandleType)pxQueue->ucQueueNumber); \\r
-        portEXIT_CRITICAL();\\r
-    }\r
+/* This macro will remove the object and store it in the event buffer */\r
+#undef trcKERNEL_HOOKS_OBJECT_DELETE\r
+#define trcKERNEL_HOOKS_OBJECT_DELETE(SERVICE, CLASS, pxObject) \\r
+       vTraceStoreKernelCall(TRACE_GET_OBJECT_EVENT_CODE(SERVICE, SUCCESS, CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject)); \\r
+       vTraceStoreObjectNameOnCloseEvent(TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject)); \\r
+       vTraceStoreObjectPropertiesOnCloseEvent(TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject)); \\r
+       vTraceFreeObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject));\r
+#else\r
+#undef trcKERNEL_HOOKS_OBJECT_DELETE\r
+#define trcKERNEL_HOOKS_OBJECT_DELETE(SERVICE, CLASS, pxObject)\r
 #endif\r
-    \r
-    /* Called in vTaskPrioritySet */\r
-    #undef traceTASK_PRIORITY_SET\r
-    #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) \\r
-      vTraceStoreKernelCallWithParam(TASK_PRIORITY_SET, TRACE_CLASS_TASK, pxTask->uxTaskNumber, uiTraceGetPriorityProperty(TRACE_CLASS_TASK, (uint8_t)pxTask->uxTaskNumber));\\r
-      vTraceSetPriorityProperty( TRACE_CLASS_TASK, (uint8_t)pxTask->uxTaskNumber, (uint8_t)uxNewPriority);\r
-\r
-    /* Called in vTaskPriorityInherit, which is called by Mutex operations */\r
-    #undef traceTASK_PRIORITY_INHERIT\r
-    #define traceTASK_PRIORITY_INHERIT( pxTask, uxNewPriority ) \\r
-      vTraceStoreKernelCallWithParam(TASK_PRIORITY_INHERIT, TRACE_CLASS_TASK, pxTask->uxTaskNumber, uiTraceGetPriorityProperty(TRACE_CLASS_TASK, (uint8_t)pxTask->uxTaskNumber));\\r
-      vTraceSetPriorityProperty( TRACE_CLASS_TASK, (uint8_t)pxTask->uxTaskNumber, (uint8_t)uxNewPriority );\r
 \r
-    /* Called in vTaskPriorityDisinherit, which is called by Mutex operations */\r
-    #undef traceTASK_PRIORITY_DISINHERIT\r
-    #define traceTASK_PRIORITY_DISINHERIT( pxTask, uxNewPriority ) \\r
-      vTraceStoreKernelCallWithParam(TASK_PRIORITY_DISINHERIT, TRACE_CLASS_TASK, pxTask->uxTaskNumber, uiTraceGetPriorityProperty(TRACE_CLASS_TASK, (uint8_t)pxTask->uxTaskNumber));\\r
-      vTraceSetPriorityProperty( TRACE_CLASS_TASK, (uint8_t)pxTask->uxTaskNumber, (uint8_t)uxNewPriority );\r
+/* This macro will create a task in the object table */\r
+#undef trcKERNEL_HOOKS_TASK_CREATE\r
+#define trcKERNEL_HOOKS_TASK_CREATE(SERVICE, pxTCB) \\r
+       TRACE_SET_TASK_NUMBER(pxTCB) \\r
+       vTraceSetObjectName(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_GET_TASK_NAME(pxTCB)); \\r
+       vTraceSetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_GET_TASK_PRIORITY(pxTCB)); \\r
+       vTraceStoreKernelCall(TRACE_GET_TASK_EVENT_CODE(SERVICE, SUCCESS, CLASS, pxTCB), TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB));\r
+\r
+/* This macro will create a failed create call to create a task */\r
+#undef trcKERNEL_HOOKS_TASK_CREATE_FAILED\r
+#define trcKERNEL_HOOKS_TASK_CREATE_FAILED(SERVICE) \\r
+       vTraceStoreKernelCall(TRACE_GET_TASK_EVENT_CODE(SERVICE, FAILED, CLASS, pxTCB), TRACE_CLASS_TASK, 0);\r
+\r
+/* This macro will setup a task in the object table */\r
+#undef trcKERNEL_HOOKS_OBJECT_CREATE\r
+#define trcKERNEL_HOOKS_OBJECT_CREATE(SERVICE, CLASS, pxObject)\\r
+       TRACE_SET_OBJECT_NUMBER(CLASS, pxObject);\\r
+       vTraceStoreKernelCall(TRACE_GET_OBJECT_EVENT_CODE(SERVICE, SUCCESS, CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject)); \\r
+       vTraceSetObjectState(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), 0);\r
+\r
+/* This macro will create a failed create call to create an object */\r
+#undef trcKERNEL_HOOKS_OBJECT_CREATE_FAILED\r
+#define trcKERNEL_HOOKS_OBJECT_CREATE_FAILED(SERVICE, CLASS, kernelClass) \\r
+       vTraceStoreKernelCall(TRACE_GET_CLASS_EVENT_CODE(SERVICE, FAILED, CLASS, kernelClass), TRACE_GET_CLASS_TRACE_CLASS(CLASS, kernelClass), 0);\r
+\r
+/* This macro will create a call to a kernel service with a certain result, with an object as parameter */\r
+#undef trcKERNEL_HOOKS_KERNEL_SERVICE\r
+#define trcKERNEL_HOOKS_KERNEL_SERVICE(SERVICE, RESULT, CLASS, pxObject) \\r
+       vTraceStoreKernelCall(TRACE_GET_OBJECT_EVENT_CODE(SERVICE, RESULT, CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject));\r
+\r
+/* This macro will set the state for an object */\r
+#undef trcKERNEL_HOOKS_SET_OBJECT_STATE\r
+#define trcKERNEL_HOOKS_SET_OBJECT_STATE(CLASS, pxObject, STATE) \\r
+       vTraceSetObjectState(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), STATE);\r
+\r
+/* This macro will flag a certain task as a finished instance */\r
+#undef trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED\r
+#define trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(CLASS, pxObject) \\r
+       vTraceSetTaskInstanceFinished(TRACE_GET_TASK_NUMBER(TRACE_GET_CURRENT_TASK()));\r
+\r
+#if INCLUDE_READY_EVENTS == 1\r
+/* This macro will create an event to indicate that a task became Ready */\r
+#undef trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE\r
+#define trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE(pxTCB) \\r
+       vTraceStoreTaskReady(TRACE_GET_TASK_NUMBER(pxTCB));\r
+#else\r
+#undef trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE\r
+#define trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE(pxTCB)\r
+#endif\r
 \r
-    /* Called in vTaskResume */\r
-    #undef traceTASK_RESUME\r
-    #define traceTASK_RESUME( pxTaskToResume ) \\r
-      vTraceStoreKernelCall(TASK_RESUME, TRACE_CLASS_TASK, pxTaskToResume->uxTaskNumber);\r
+/* This macro will update the internal tick counter and call vTracePortGetTimeStamp(0) to update the internal counters */\r
+#undef trcKERNEL_HOOKS_INCREMENT_TICK\r
+#define trcKERNEL_HOOKS_INCREMENT_TICK() \\r
+       { extern uint32_t uiTraceTickCount; uiTraceTickCount++; vTracePortGetTimeStamp(0); }\r
+\r
+#if INCLUDE_NEW_TIME_EVENTS == 1\r
+/* This macro will create an event indicating that the OS tick count has increased */\r
+#undef trcKERNEL_HOOKS_NEW_TIME\r
+#define trcKERNEL_HOOKS_NEW_TIME(SERVICE, xValue) \\r
+       vTraceStoreKernelCallWithNumericParamOnly(SERVICE, xValue);\r
+#else\r
+#undef trcKERNEL_HOOKS_NEW_TIME\r
+#define trcKERNEL_HOOKS_NEW_TIME(SERVICE, xValue)\r
+#endif\r
 \r
-    /* Called in vTaskResumeFromISR */\r
-    #undef traceTASK_RESUME_FROM_ISR\r
-    #define traceTASK_RESUME_FROM_ISR( pxTaskToResume )\\r
-      vTraceStoreKernelCall(TASK_RESUME_FROM_ISR, TRACE_CLASS_TASK, pxTaskToResume->uxTaskNumber);\r
+/* This macro will create a task switch event to the currently executing task */\r
+#undef trcKERNEL_HOOKS_TASK_SWITCH\r
+#define trcKERNEL_HOOKS_TASK_SWITCH( pxTCB ) \\r
+       vTraceStoreTaskswitch(TRACE_GET_TASK_NUMBER(pxTCB));\r
+\r
+/* This macro will create an event to indicate that the task has been suspended */\r
+#undef trcKERNEL_HOOKS_TASK_SUSPEND\r
+#define trcKERNEL_HOOKS_TASK_SUSPEND(SERVICE, pxTCB) \\r
+       vTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); \\r
+       vTraceSetTaskInstanceFinished((uint8_t)TRACE_GET_TASK_NUMBER(pxTCB));\r
+\r
+/* This macro will create an event to indicate that a task has called a wait/delay function */\r
+#undef trcKERNEL_HOOKS_TASK_DELAY\r
+#define trcKERNEL_HOOKS_TASK_DELAY(SERVICE, pxTCB, xValue) \\r
+       vTraceStoreKernelCallWithNumericParamOnly(SERVICE, xValue); \\r
+       vTraceSetTaskInstanceFinished((uint8_t)TRACE_GET_TASK_NUMBER(pxTCB));\r
+\r
+/* This macro will create an event to indicate that a task has gotten its priority changed */\r
+#undef trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE\r
+#define trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(SERVICE, pxTCB, uxNewPriority) \\r
+       vTraceStoreKernelCallWithParam(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), uiTraceGetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)));\\r
+       vTraceSetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), (uint8_t)uxNewPriority);\r
+\r
+/* This macro will create an event to indicate that the task has been resumed */\r
+#undef trcKERNEL_HOOKS_TASK_RESUME\r
+#define trcKERNEL_HOOKS_TASK_RESUME(SERVICE, pxTCB) \\r
+       vTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB));\r
 \r
 #endif\r
-#endif\r
+\r
+#endif /* TRCKERNELHOOKS_H */\r
index c81db92e14dc9d8a56aeea2706f39870ba8354af..709e128c99d5c3719049ffc069aa9d0519fcd287 100644 (file)
@@ -1,64 +1,61 @@
 /*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
+ * Tracealyzer v2.4.1 Recorder Library\r
  * Percepio AB, www.percepio.com\r
  *\r
  * trcKernel.h\r
  *\r
- * Functions used by trcHooks.h, for the FreeRTOS kernel integration.\r
+ * Functions used by trcKernelHooks.h.\r
  *\r
  * Terms of Use\r
  * This software is copyright Percepio AB. The recorder library is free for\r
  * use together with Percepio products. You may distribute the recorder library\r
- * in its original form, including modifications in trcPort.c and trcPort.h\r
+ * in its original form, including modifications in trcHardwarePort.c/.h\r
  * given that these modification are clearly marked as your own modifications\r
- * and documented in the initial comment section of these source files. \r
- * This software is the intellectual property of Percepio AB and may not be \r
- * sold or in other ways commercially redistributed without explicit written \r
+ * and documented in the initial comment section of these source files.\r
+ * This software is the intellectual property of Percepio AB and may not be\r
+ * sold or in other ways commercially redistributed without explicit written\r
  * permission by Percepio AB.\r
  *\r
- * Disclaimer \r
- * The trace tool and recorder library is being delivered to you AS IS and \r
- * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
- * not and cannot warrant the performance or results you may obtain by using the \r
- * software or documentation. Percepio AB make no warranties, express or \r
- * implied, as to noninfringement of third party rights, merchantability, or \r
- * fitness for any particular purpose. In no event will Percepio AB, its \r
- * technology partners, or distributors be liable to you for any consequential, \r
- * incidental or special damages, including any lost profits or lost savings, \r
- * even if a representative of Percepio AB has been advised of the possibility \r
- * of such damages, or for any claim by any third party. Some jurisdictions do \r
- * not allow the exclusion or limitation of incidental, consequential or special \r
- * damages, or the exclusion of implied warranties or limitations on how long an \r
+ * Disclaimer\r
+ * The trace tool and recorder library is being delivered to you AS IS and\r
+ * Percepio AB makes no warranty as to its use or performance. Percepio AB does\r
+ * not and cannot warrant the performance or results you may obtain by using the\r
+ * software or documentation. Percepio AB make no warranties, express or\r
+ * implied, as to noninfringement of third party rights, merchantability, or\r
+ * fitness for any particular purpose. In no event will Percepio AB, its\r
+ * technology partners, or distributors be liable to you for any consequential,\r
+ * incidental or special damages, including any lost profits or lost savings,\r
+ * even if a representative of Percepio AB has been advised of the possibility\r
+ * of such damages, or for any claim by any third party. Some jurisdictions do\r
+ * not allow the exclusion or limitation of incidental, consequential or special\r
+ * damages, or the exclusion of implied warranties or limitations on how long an\r
  * implied warranty may last, so the above limitations may not apply to you.\r
  *\r
- * FreeRTOS+Trace is available as Free Edition and in two premium editions.\r
- * You may use the premium features during 30 days for evaluation.\r
- * Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/\r
- *\r
- * Copyright Percepio AB, 2012.\r
+ * Copyright Percepio AB, 2013.\r
  * www.percepio.com\r
  ******************************************************************************/\r
 \r
 #ifndef TRCKERNEL_H\r
 #define TRCKERNEL_H\r
 \r
-#include "trcBase.h"\r
+#include "trcKernelPort.h"\r
 \r
-/* Internal functions */\r
+#if (USE_TRACEALYZER_RECORDER == 1)\r
 \r
+/* Internal functions */\r
 \r
 #if !defined INCLUDE_READY_EVENTS || INCLUDE_READY_EVENTS == 1\r
 void vTraceStoreTaskReady(objectHandleType handle);\r
 #endif\r
 \r
-void vTraceStoreTaskswitch(void);\r
+void vTraceStoreTaskswitch(objectHandleType task_handle);\r
 \r
-void vTraceStoreKernelCall(uint32_t eventcode, traceObjectClass objectClass, uint32_t byteParam); \r
+void vTraceStoreKernelCall(uint32_t eventcode, traceObjectClass objectClass, uint32_t byteParam);\r
 \r
-void vTraceStoreKernelCallWithNumericParamOnly(uint32_t evtcode, \r
-                                               uint16_t param);\r
+void vTraceStoreKernelCallWithNumericParamOnly(uint32_t evtcode,\r
+                                               uint32_t param);\r
 \r
-void vTraceStoreKernelCallWithParam(uint32_t evtcode, traceObjectClass objectClass, \r
+void vTraceStoreKernelCallWithParam(uint32_t evtcode, traceObjectClass objectClass,\r
                                     uint32_t objectNumber, uint8_t param);\r
 \r
 void vTraceSetTaskInstanceFinished(objectHandleType handle);\r
@@ -71,12 +68,12 @@ void vTraceSetObjectState(uint8_t objectclass, uint8_t id, uint8_t value);
 \r
 uint8_t uiTraceGetObjectState(uint8_t objectclass, uint8_t id);\r
 \r
-#if (INCLUDE_OBJECT_DELETE == 1)    \r
+#if (INCLUDE_OBJECT_DELETE == 1)\r
 \r
-void vTraceStoreObjectNameOnCloseEvent(objectHandleType handle, \r
+void vTraceStoreObjectNameOnCloseEvent(objectHandleType handle,\r
                                        traceObjectClass objectclass);\r
 \r
-void vTraceStoreObjectPropertiesOnCloseEvent(objectHandleType handle, \r
+void vTraceStoreObjectPropertiesOnCloseEvent(objectHandleType handle,\r
                                              traceObjectClass objectclass);\r
 #endif\r
 \r
@@ -85,190 +82,7 @@ void vTraceStoreObjectPropertiesOnCloseEvent(objectHandleType handle,
 #define TASK_STATE_INSTANCE_ACTIVE 1\r
 #define TASK_STATE_INSTANCE_MARKED_FINISHED 2\r
 \r
-extern objectHandleType handle_of_running_task;\r
-\r
-/* This defines the mapping between FreeRTOS queue types and our internal \r
-class IDs */\r
-extern traceObjectClass TraceObjectClassTable[5];\r
-\r
-/*******************************************************************************\r
- * The event codes - should match the offline config file.\r
- * \r
- * Some sections below are encoded to allow for constructions like:\r
- *\r
- *  vTraceStoreKernelCall(EVENTGROUP_CREATE + objectclass, ...\r
- *\r
- * The object class ID is given by the three LSB bits, in such cases. Since each \r
- * object class has a separate object property table, the class ID is needed to \r
- * know what section in the object table to use for getting an object name from\r
- * an object handle. \r
- ******************************************************************************/\r
-\r
-#define NULL_EVENT                   (0x00)  /* Ignored in the analysis*/\r
-\r
-/*******************************************************************************\r
- * EVENTGROUP_RE\r
- *\r
- * Events that indicate that something is ready to execute.\r
- ******************************************************************************/\r
-#define EVENTGROUP_RE                (NULL_EVENT + 2)                   /*0x02*/\r
-#define TR_TASK_READY                (EVENTGROUP_RE + 0)                /*0x02*/\r
-\r
-/*******************************************************************************\r
- * EVENTGROUP_TS\r
- *\r
- * Events for storing task-switches and interrupts. The RESUME events are \r
- * generated if the task/interrupt is already marked active.\r
- ******************************************************************************/\r
-#define EVENTGROUP_TS                (EVENTGROUP_RE + 2)                /*0x04*/\r
-#define TS_ISR_BEGIN                 (EVENTGROUP_TS + 0)                /*0x04*/\r
-#define TS_ISR_RESUME                (EVENTGROUP_TS + 1)                /*0x05*/\r
-#define TS_TASK_BEGIN                (EVENTGROUP_TS + 2)                /*0x06*/\r
-#define TS_TASK_RESUME               (EVENTGROUP_TS + 3)                /*0x07*/\r
-\r
-/*******************************************************************************\r
- * EVENTGROUP_OBJCLOSE_NAME\r
- * \r
- * About Close Events\r
- * When an object is evicted from the object property table (object close), two \r
- * internal events are stored (EVENTGROUP_OBJCLOSE_NAME and \r
- * EVENTGROUP_OBJCLOSE_PROP), containg the handle-name mapping and object \r
- * properties valid up to this point.\r
- ******************************************************************************/\r
-#define EVENTGROUP_OBJCLOSE_NAME     (EVENTGROUP_TS + 4)                /*0x08*/\r
-\r
-/*******************************************************************************\r
- * EVENTGROUP_OBJCLOSE_PROP\r
- * \r
- * The internal event carrying properties of deleted objects\r
- * The handle and object class of the closed object is not stored in this event, \r
- * but is assumed to be the same as in the preceeding CLOSE event. Thus, these \r
- * two events must be generated from within a critical section. \r
- * When queues are closed, arg1 is the "state" property (i.e., number of \r
- * buffered messages/signals).\r
- * When actors are closed, arg1 is priority, arg2 is handle of the "instance \r
- * finish" event, and arg3 is event code of the "instance finish" event. \r
- * In this case, the lower three bits is the object class of the instance finish \r
- * handle. The lower three bits are not used (always zero) when queues are \r
- * closed since the queue type is given in the previous OBJCLOSE_NAME event.\r
- ******************************************************************************/\r
-#define EVENTGROUP_OBJCLOSE_PROP     (EVENTGROUP_OBJCLOSE_NAME + 8)     /*0x10*/\r
-\r
-/*******************************************************************************\r
- * EVENTGROUP_CREATE\r
- * \r
- * The events in this group are used to log Kernel object creations.\r
- * The lower three bits in the event code gives the object class, i.e., type of\r
- * create operation (task, queue, semaphore, etc).\r
- ******************************************************************************/\r
-#define EVENTGROUP_CREATE    (EVENTGROUP_OBJCLOSE_PROP + 8)             /*0x18*/\r
-\r
-/*******************************************************************************\r
- * EVENTGROUP_SEND\r
- * \r
- * The events in this group are used to log Send/Give events on queues, \r
- * semaphores and mutexeds The lower three bits in the event code gives the \r
- * object class, i.e., what type of object that is operated on (queue, semaphore \r
- * or mutex).\r
- ******************************************************************************/\r
-#define EVENTGROUP_SEND      (EVENTGROUP_CREATE + 8)                    /*0x20*/\r
-\r
-/*******************************************************************************\r
- * EVENTGROUP_RECEIVE\r
- * \r
- * The events in this group are used to log Receive/Take events on queues, \r
- * semaphores and mutexes. The lower three bits in the event code gives the \r
- * object class, i.e., what type of object that is operated on (queue, semaphore\r
- * or mutex).\r
- ******************************************************************************/\r
-#define EVENTGROUP_RECEIVE                       (EVENTGROUP_SEND + 8)  /*0x28*/\r
-\r
-/* Send/Give operations, from ISR */\r
-#define EVENTGROUP_SEND_FROM_ISR              (EVENTGROUP_RECEIVE + 8)  /*0x30*/\r
-\r
-/* Receive/Take operations, from ISR */\r
-#define EVENTGROUP_RECEIVE_FROM_ISR     (EVENTGROUP_SEND_FROM_ISR + 8)  /*0x38*/\r
-\r
-/* "Failed" event type versions of above (timeout, failed allocation, etc) */\r
-#define EVENTGROUP_FAILED_KSE         (EVENTGROUP_RECEIVE_FROM_ISR + 8) /*0x40*/\r
-\r
-/* Failed create calls - memory allocation failed */\r
-#define EVENTGROUP_FAILED_CREATE                (EVENTGROUP_FAILED_KSE) /*0x40*/\r
-\r
-/* Failed send/give - timeout! */\r
-#define EVENTGROUP_FAILED_SEND           (EVENTGROUP_FAILED_CREATE + 8) /*0x48*/\r
-\r
-/* Failed receive/take - timeout! */\r
-#define EVENTGROUP_FAILED_RECEIVE          (EVENTGROUP_FAILED_SEND + 8) /*0x50*/\r
-\r
-/* Failed non-blocking send/give - queue full */\r
-#define EVENTGROUP_FAILED_SEND_FROM_ISR (EVENTGROUP_FAILED_RECEIVE + 8) /*0x58*/\r
-\r
-/* Failed non-blocking receive/take - queue empty */\r
-#define EVENTGROUP_FAILED_RECEIVE_FROM_ISR \\r
-                                  (EVENTGROUP_FAILED_SEND_FROM_ISR + 8) /*0x60*/\r
-\r
-/* Events when blocking on receive/take */\r
-#define EVENTGROUP_BLOCK_ON_RECEIVE \\r
-                               (EVENTGROUP_FAILED_RECEIVE_FROM_ISR + 8) /*0x68*/\r
-\r
-/* Events when blocking on send/give */\r
-#define EVENTGROUP_BLOCK_ON_SEND     (EVENTGROUP_BLOCK_ON_RECEIVE + 8)  /*0x70*/\r
-\r
-/* Events on queue peek (receive) */\r
-#define EVENTGROUP_PEEK              (EVENTGROUP_BLOCK_ON_SEND + 8)     /*0x78*/\r
-\r
-/* Events on object delete (vTaskDelete or vQueueDelete) */\r
-#define EVENTGROUP_DELETE            (EVENTGROUP_PEEK + 8)              /*0x80*/\r
-\r
-/* Other events - object class is implied: TASK */\r
-#define EVENTGROUP_OTHERS            (EVENTGROUP_DELETE + 8)            /*0x88*/\r
-#define TASK_DELAY_UNTIL             (EVENTGROUP_OTHERS + 0)            /*0x88*/\r
-#define TASK_DELAY                   (EVENTGROUP_OTHERS + 1)            /*0x89*/\r
-#define TASK_SUSPEND                 (EVENTGROUP_OTHERS + 2)            /*0x8A*/\r
-#define TASK_RESUME                  (EVENTGROUP_OTHERS + 3)            /*0x8B*/\r
-#define TASK_RESUME_FROM_ISR         (EVENTGROUP_OTHERS + 4)            /*0x8C*/\r
-#define TASK_PRIORITY_SET            (EVENTGROUP_OTHERS + 5)            /*0x8D*/\r
-#define TASK_PRIORITY_INHERIT        (EVENTGROUP_OTHERS + 6)            /*0x8E*/\r
-#define TASK_PRIORITY_DISINHERIT     (EVENTGROUP_OTHERS + 7)            /*0x8F*/\r
-\r
-/* Not yet used */\r
-#define EVENTGROUP_FTRACE_PLACEHOLDER    (EVENTGROUP_OTHERS + 8)        /*0x90*/\r
-\r
-/* User events */\r
-#define EVENTGROUP_USEREVENT (EVENTGROUP_FTRACE_PLACEHOLDER + 8)        /*0x98*/\r
-#define USER_EVENT (EVENTGROUP_USEREVENT + 0)\r
-\r
-/* Allow for 0-15 arguments (the number of args is added to event code) */\r
-#define USER_EVENT_LAST (EVENTGROUP_USEREVENT + 15)                     /*0xA7*/\r
-\r
-/*******************************************************************************\r
- * XTS Event - eXtended TimeStamp events\r
- * The timestamps used in the recorder are "differential timestamps" (DTS), i.e.\r
- * the time since the last stored event. The DTS fields are either 1 or 2 bytes \r
- * in the other events, depending on the bytes available in the event struct. \r
- * If the time since the last event (the DTS) is larger than allowed for by \r
- * the DTS field of the current event, an XTS event is inserted immidiatly \r
- * before the original event. The XTS event contains up to 3 additional bytes \r
- * of the DTS value - the higher bytes of the true DTS value. The lower 1-2 \r
- * bytes are stored in the normal DTS field. \r
- * There are two types of XTS events, XTS8 and XTS16. An XTS8 event is stored \r
- * when there is only room for 1 byte (8 bit) DTS data in the original event, \r
- * which means a limit of 0xFF (255). The XTS16 is used when the original event \r
- * has a 16 bit DTS field and thereby can handle values up to 0xFFFF (65535).\r
- * \r
- * Using a very high frequency time base can result in many XTS events. \r
- * Preferably, the time between two OS ticks should fit in 16 bits, i.e.,\r
- * at most 65535. If your time base has a higher frequency, you can define\r
- * the TRACE\r
- ******************************************************************************/\r
-\r
-#define EVENTGROUP_SYS (EVENTGROUP_USEREVENT + 16)                      /*0xA8*/\r
-#define XTS8 (EVENTGROUP_SYS + 0)                                       /*0xA8*/\r
-#define XTS16 (EVENTGROUP_SYS + 1)                                      /*0xA9*/\r
-\r
-#define EVENT_BEING_WRITTEN (EVENTGROUP_SYS + 2)                        /*0xAA*/\r
-\r
-#define RESERVED_DUMMY_CODE (EVENTGROUP_SYS + 3)                        /*0xAB*/\r
 \r
 #endif\r
+\r
+#endif
\ No newline at end of file
index 7bf438c8be29c6d86c4cf404ecd3dd53355d6c45..a01791216e82bbc2f98127108a90613923a90625 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
+ * Tracealyzer v2.4.1 Recorder Library\r
  * Percepio AB, www.percepio.com\r
  *\r
  * trcTypes.h\r
@@ -9,7 +9,7 @@
  * Terms of Use\r
  * This software is copyright Percepio AB. The recorder library is free for\r
  * use together with Percepio products. You may distribute the recorder library\r
- * in its original form, including modifications in trcPort.c and trcPort.h\r
+ * in its original form, including modifications in trcHardwarePort.c/.h\r
  * given that these modification are clearly marked as your own modifications\r
  * and documented in the initial comment section of these source files. \r
  * This software is the intellectual property of Percepio AB and may not be \r
  * damages, or the exclusion of implied warranties or limitations on how long an \r
  * implied warranty may last, so the above limitations may not apply to you.\r
  *\r
- * FreeRTOS+Trace is available as Free Edition and in two premium editions.\r
- * You may use the premium features during 30 days for evaluation.\r
- * Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/\r
- *\r
- * Copyright Percepio AB, 2012.\r
+ * Copyright Percepio AB, 2013.\r
  * www.percepio.com\r
  ******************************************************************************/\r
 \r
 \r
 typedef uint16_t traceLabel;\r
 \r
+typedef uint8_t UserEventChannel;\r
+\r
 typedef uint8_t objectHandleType;\r
 \r
 typedef uint8_t traceObjectClass;\r
 \r
-#define TRACE_CLASS_QUEUE ((traceObjectClass)0)\r
-#define TRACE_CLASS_SEMAPHORE ((traceObjectClass)1) \r
-#define TRACE_CLASS_MUTEX ((traceObjectClass)2)\r
-#define TRACE_CLASS_TASK ((traceObjectClass)3)\r
-#define TRACE_CLASS_ISR ((traceObjectClass)4)\r
-\r
-typedef uint8_t traceKernelService;\r
-\r
-#define TRACE_KERNEL_SERVICE_TASK_CREATE ((traceKernelService)0)\r
-#define TRACE_KERNEL_SERVICE_TASK_DELETE ((traceKernelService)1)\r
-#define TRACE_KERNEL_SERVICE_TASK_DELAY ((traceKernelService)2)\r
-#define TRACE_KERNEL_SERVICE_PRIORITY_SET ((traceKernelService)3)\r
-#define TRACE_KERNEL_SERVICE_TASK_SUSPEND ((traceKernelService)4)\r
-#define TRACE_KERNEL_SERVICE_TASK_RESUME ((traceKernelService)5)\r
-#define TRACE_KERNEL_SERVICE_QUEUE_CREATE ((traceKernelService)6)\r
-#define TRACE_KERNEL_SERVICE_QUEUE_DELETE ((traceKernelService)7)\r
-#define TRACE_KERNEL_SERVICE_QUEUE_SEND ((traceKernelService)8)\r
-#define TRACE_KERNEL_SERVICE_QUEUE_RECEIVE ((traceKernelService)9)\r
-#define TRACE_KERNEL_SERVICE_QUEUE_PEEK ((traceKernelService)10)\r
-#define TRACE_KERNEL_SERVICE_MUTEX_CREATE ((traceKernelService)11)\r
-#define TRACE_KERNEL_SERVICE_MUTEX_DELETE ((traceKernelService)12)\r
-#define TRACE_KERNEL_SERVICE_MUTEX_GIVE ((traceKernelService)13)\r
-#define TRACE_KERNEL_SERVICE_MUTEX_TAKE ((traceKernelService)14)\r
-#define TRACE_KERNEL_SERVICE_SEMAPHORE_CREATE ((traceKernelService)15)\r
-#define TRACE_KERNEL_SERVICE_SEMAPHORE_DELETE ((traceKernelService)16)\r
-#define TRACE_KERNEL_SERVICE_SEMAPHORE_GIVE ((traceKernelService)17)\r
-#define TRACE_KERNEL_SERVICE_SEMAPHORE_TAKE ((traceKernelService)18)\r
-\r
 #endif\r
index 3e80162fa9dcdbb747996a2cdbfb6ee9c4b0579f..273e870742a5f10b93c05d8ee73c2c80481dc2df 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
+ * Tracealyzer v2.4.1 Recorder Library\r
  * Percepio AB, www.percepio.com\r
  *\r
  * trcUser.h\r
  * Terms of Use\r
  * This software is copyright Percepio AB. The recorder library is free for\r
  * use together with Percepio products. You may distribute the recorder library\r
- * in its original form, including modifications in trcPort.c and trcPort.h\r
+ * in its original form, including modifications in trcHardwarePort.c/.h\r
  * given that these modification are clearly marked as your own modifications\r
- * and documented in the initial comment section of these source files. \r
- * This software is the intellectual property of Percepio AB and may not be \r
- * sold or in other ways commercially redistributed without explicit written \r
+ * and documented in the initial comment section of these source files.\r
+ * This software is the intellectual property of Percepio AB and may not be\r
+ * sold or in other ways commercially redistributed without explicit written\r
  * permission by Percepio AB.\r
  *\r
- * Disclaimer \r
- * The trace tool and recorder library is being delivered to you AS IS and \r
- * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
- * not and cannot warrant the performance or results you may obtain by using the \r
- * software or documentation. Percepio AB make no warranties, express or \r
- * implied, as to noninfringement of third party rights, merchantability, or \r
- * fitness for any particular purpose. In no event will Percepio AB, its \r
- * technology partners, or distributors be liable to you for any consequential, \r
- * incidental or special damages, including any lost profits or lost savings, \r
- * even if a representative of Percepio AB has been advised of the possibility \r
- * of such damages, or for any claim by any third party. Some jurisdictions do \r
- * not allow the exclusion or limitation of incidental, consequential or special \r
- * damages, or the exclusion of implied warranties or limitations on how long an \r
+ * Disclaimer\r
+ * The trace tool and recorder library is being delivered to you AS IS and\r
+ * Percepio AB makes no warranty as to its use or performance. Percepio AB does\r
+ * not and cannot warrant the performance or results you may obtain by using the\r
+ * software or documentation. Percepio AB make no warranties, express or\r
+ * implied, as to noninfringement of third party rights, merchantability, or\r
+ * fitness for any particular purpose. In no event will Percepio AB, its\r
+ * technology partners, or distributors be liable to you for any consequential,\r
+ * incidental or special damages, including any lost profits or lost savings,\r
+ * even if a representative of Percepio AB has been advised of the possibility\r
+ * of such damages, or for any claim by any third party. Some jurisdictions do\r
+ * not allow the exclusion or limitation of incidental, consequential or special\r
+ * damages, or the exclusion of implied warranties or limitations on how long an\r
  * implied warranty may last, so the above limitations may not apply to you.\r
  *\r
- * FreeRTOS+Trace is available as Free Edition and in two premium editions.\r
- * You may use the premium features during 30 days for evaluation.\r
- * Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/\r
- *\r
- * Copyright Percepio AB, 2012.\r
+ * Copyright Percepio AB, 2013.\r
  * www.percepio.com\r
  ******************************************************************************/\r
 \r
 #ifndef TRCUSER_H\r
 #define TRCUSER_H\r
 \r
-#include "FreeRTOS.h"\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+#include "trcKernelPort.h"\r
 \r
-#include "trcKernel.h"\r
+#if (USE_TRACEALYZER_RECORDER == 1)\r
 \r
-#if (configUSE_TRACE_FACILITY == 1)\r
+#ifndef USE_SEPARATE_USER_EVENT_BUFFER\r
+#define USE_SEPARATE_USER_EVENT_BUFFER 0\r
+#endif\r
 \r
-#ifdef __cplusplus\r
-extern "C" {\r
+/*******************************************************************************\r
+ * TRACE_STOP_HOOK - Hook Pointer Data Type\r
+ *\r
+ * Declares a data type for a call back function that will be invoked whenever\r
+ * the recorder is stopped.\r
+ ******************************************************************************/\r
+typedef void (*TRACE_STOP_HOOK)(void);\r
+\r
+/*******************************************************************************\r
+ * vTraceStopHookPtr\r
+ *\r
+ * Points to a call back function that is called from vTraceStop().\r
+ ******************************************************************************/\r
+extern TRACE_STOP_HOOK vTraceStopHookPtr;\r
+\r
+/*******************************************************************************\r
+ * vTraceInitTraceData\r
+ *\r
+ * Allocates, if necessary, and initializes the recorder data structure, based\r
+ * on the constants in trcConfig.h.\r
+ ******************************************************************************/\r
+void vTraceInitTraceData(void);\r
+\r
+/*******************************************************************************\r
+ * vTraceSetRecorderData\r
+ *\r
+ * If custom allocation is used, this function must be called so the recorder\r
+ * library knows where to save the trace data.\r
+ ******************************************************************************/\r
+#if (TRACE_DATA_ALLOCATION == TRACE_DATA_ALLOCATION_CUSTOM)\r
+void vTraceSetRecorderData(void* pRecorderData);\r
 #endif\r
 \r
 /*******************************************************************************\r
  * uiTraceStart\r
  *\r
  * Starts the recorder. The recorder will not be started if an error has been\r
- * indicated using vTraceError, e.g. if any of the Nx constants in trcConfig.h \r
+ * indicated using vTraceError, e.g. if any of the Nx constants in trcConfig.h\r
  * has a too small value (NTASK, NQUEUE, etc).\r
- * \r
+ *\r
  * Returns 1 if the recorder was started successfully.\r
- * Returns 0 if the recorder start was prevented due to a previous internal \r
+ * Returns 0 if the recorder start was prevented due to a previous internal\r
  * error. In that case, check vTraceGetLastError to get the error message.\r
- * Any error message is also presented when opening a trace file in \r
- * FreeRTOS+Trace v2.2.2 or later.\r
+ * Any error message is also presented when opening a trace file.\r
+ *\r
  ******************************************************************************/\r
 uint32_t uiTraceStart(void);\r
 \r
 /*******************************************************************************\r
- * vTraceStart \r
+ * vTraceStart\r
  *\r
  * Starts the recorder. The recorder will not be started if an error has been\r
- * indicated using vTraceError, e.g. if any of the Nx constants in trcConfig.h \r
+ * indicated using vTraceError, e.g. if any of the Nx constants in trcConfig.h\r
  * has a too small value (NTASK, NQUEUE, etc).\r
- * \r
- * This function is obsolete, but has been saved for backwards compatibility. \r
+ *\r
+ * This function is obsolete, but has been saved for backwards compatibility.\r
  * We recommend using uiTraceStart instead.\r
  ******************************************************************************/\r
 void vTraceStart(void);\r
@@ -81,12 +112,12 @@ void vTraceStart(void);
 /*******************************************************************************\r
  * vTraceStartStatusMonitor\r
  *\r
- * This starts a task to monitor the status of the recorder module. \r
- * This task periodically prints a line to the console window, which shows the \r
- * recorder status, the number of events recorded and the latest timestamp. \r
- * This task calls vTracePortEnd (trcPort.c) when it detects that the recorder \r
- * has been stopped. This allows for adding custom actions, e.g., to store the\r
- * trace to a file in case a file system is available on the device.\r
+ * This starts a task to monitor the status of the recorder module.\r
+ * This task periodically prints a line to the console window, which shows the\r
+ * recorder status, the number of events recorded and the latest timestamp.\r
+ * This task calls vTracePortEnd (trcHardwarePort.c) when it detects that the\r
+ * recorder has been stopped. This allows for adding custom actions, e.g., to\r
+ * store the trace to a file in case a file system is available on the device.\r
  ******************************************************************************/\r
 void vTraceStartStatusMonitor(void);\r
 \r
@@ -101,33 +132,19 @@ void vTraceStop(void);
 /*******************************************************************************\r
  * vTraceClear\r
  *\r
- * Resets the recorder. Only necessary if a restart is desired - this is not \r
+ * Resets the recorder. Only necessary if a restart is desired - this is not\r
  * needed in the startup initialization.\r
  ******************************************************************************/\r
 void vTraceClear(void);\r
 \r
-/*******************************************************************************\r
- * vTraceSetQueueName\r
- *\r
- * Assigns a name to a FreeRTOS Queue, Semaphore or Mutex. This function should\r
- * be called right after creation of the queue/mutex/semaphore. If not using \r
- * this function, the queues/mutexes/semaphores will be presented by their\r
- * numeric handle only.\r
- *\r
- * Example:\r
- *     actuatorQ = xQueueCreate(3, sizeof(QueueMessage));\r
- *     vTraceSetQueueName(actuatorQ, "ActuatorQueue");\r
- ******************************************************************************/\r
-void vTraceSetQueueName(void* queue, const char* name);\r
-\r
 #if (INCLUDE_ISR_TRACING == 1)\r
 \r
 /*******************************************************************************\r
  * vTraceSetISRProperties\r
- * \r
+ *\r
  * Registers an Interrupt Service Routine in the recorder library, This must be\r
- * called before using vTraceStoreISRBegin to store ISR events. This is \r
- * typically called in the startup of the system, before the scheduler is \r
+ * called before using vTraceStoreISRBegin to store ISR events. This is\r
+ * typically called in the startup of the system, before the scheduler is\r
  * started.\r
  *\r
  * Example:\r
@@ -151,18 +168,9 @@ void vTraceSetISRProperties(objectHandleType handle, const char* name, char prio
 \r
 /*******************************************************************************\r
  * vTraceStoreISRBegin\r
- * \r
- * Registers the beginning of an Interrupt Service Routine.\r
  *\r
- * Note! This may only be used for interrupts affected by portENTER_CRITICAL.\r
- * In some FreeRTOS ports, such as ARM Cortex M3, this does not disable all\r
- * interrupts. Interrupts above configMAX_SYSCALL_INTERRUPT_PRIORITY are still \r
- * enabled, but may not call the FreeRTOS API. Such may not call the recorder \r
- * API, including this function.\r
- *\r
- * See http://www.freertos.org/a00110.html\r
- * \r
- * If allowing nested ISRs, this must be called with interrupts disabled. \r
+ * Registers the beginning of an Interrupt Service Routine.\r
+ * If allowing nested ISRs, this must be called with interrupts disabled.\r
  *\r
  * Example:\r
  *     #define ID_ISR_TIMER1 1       // lowest valid ID is 1\r
@@ -180,23 +188,16 @@ void vTraceSetISRProperties(objectHandleType handle, const char* name, char prio
  *         vTraceStoreISREnd();\r
  *         portEXIT_CRITICAL();\r
  *     }\r
+ *\r
  ******************************************************************************/\r
 void vTraceStoreISRBegin(objectHandleType id);\r
 \r
 /*******************************************************************************\r
  * vTraceStoreISREnd\r
- * \r
- * Registers the end of an Interrupt Service Routine.\r
  *\r
- * Note! This may only be used for interrupts affected by portENTER_CRITICAL.\r
- * In some FreeRTOS ports, such as ARM Cortex M3, this does not disable all\r
- * interrupts. Interrupts above configMAX_SYSCALL_INTERRUPT_PRIORITY are still \r
- * enabled, but may not call the FreeRTOS API. Such may not call the recorder \r
- * API, including this function.\r
+ * Registers the end of an Interrupt Service Routine.\r
  *\r
- * See http://www.freertos.org/a00110.html\r
- * \r
- * If allowing nested ISRs, this must be called with interrupts disabled. \r
+ * If allowing nested ISRs, this must be called with interrupts disabled.\r
  *\r
  * Example:\r
  *     #define ID_ISR_TIMER1 1       // lowest valid ID is 1\r
@@ -214,6 +215,7 @@ void vTraceStoreISRBegin(objectHandleType id);
  *         vTraceStoreISREnd();\r
  *         portEXIT_CRITICAL();\r
  *     }\r
+ *\r
  ******************************************************************************/\r
 void vTraceStoreISREnd(void);\r
 \r
@@ -233,41 +235,41 @@ void vTraceDecreaseISRActive(void);
 /*******************************************************************************\r
  * vvTraceTaskSkipDefaultInstanceFinishedEvents\r
  *\r
- * This is useful if there are implicit Instance Finish Events, such as \r
- * vTaskDelayUntil or xQueueReceive, in a task where an explicit Instance Finish \r
- * Event has been defined. This function tells the recorder that only the \r
+ * This is useful if there are implicit Instance Finish Events, such as\r
+ * vTaskDelayUntil or xQueueReceive, in a task where an explicit Instance Finish\r
+ * Event has been defined. This function tells the recorder that only the\r
  * explicitly defined functions (using vTraceTaskInstanceIsFinished) should be\r
- * treated as Instance Finish Events for this task. The implicit Instance Finish \r
+ * treated as Instance Finish Events for this task. The implicit Instance Finish\r
  * Events are thus disregarded for this task.\r
  ******************************************************************************/\r
 void vTraceTaskSkipDefaultInstanceFinishedEvents(void);\r
 \r
 /*******************************************************************************\r
  * vTraceTaskInstanceIsFinished\r
- * \r
- * This defines an explicit Instance Finish Event for the current task. It tells \r
- * the recorder that the current instance of this task is finished at the next \r
- * kernel call of the task, e.g., a taskDelay or a queue receive. This function \r
- * should be called right before the api function call considered to be the end \r
+ *\r
+ * This defines an explicit Instance Finish Event for the current task. It tells\r
+ * the recorder that the current instance of this task is finished at the next\r
+ * kernel call of the task, e.g., a taskDelay or a queue receive. This function\r
+ * should be called right before the api function call considered to be the end\r
  * of the task instamce, i.e., the Instance Finish Event.\r
  ******************************************************************************/\r
 void vTraceTaskInstanceIsFinished(void);\r
 \r
 /*******************************************************************************\r
  * vTraceGetTraceBuffer\r
- * \r
- * Returns a pointer to the recorder data structure. Use this together with \r
- * uiTraceGetTraceBufferSize if you wish to implement an own store/upload \r
- * solution, e.g., in case a debugger connection is not available for uploading \r
+ *\r
+ * Returns a pointer to the recorder data structure. Use this together with\r
+ * uiTraceGetTraceBufferSize if you wish to implement an own store/upload\r
+ * solution, e.g., in case a debugger connection is not available for uploading\r
  * the data.\r
  ******************************************************************************/\r
 void* vTraceGetTraceBuffer(void);\r
 \r
 /*******************************************************************************\r
  * uiTraceGetTraceBufferSize\r
- * \r
- * Gets the size of the recorder data structure. For use together with \r
- * vTraceGetTraceBuffer if you wish to implement an own store/upload solution, \r
+ *\r
+ * Gets the size of the recorder data structure. For use together with\r
+ * vTraceGetTraceBuffer if you wish to implement an own store/upload solution,\r
  * e.g., in case a debugger connection is not available for uploading the data.\r
  ******************************************************************************/\r
 uint32_t uiTraceGetTraceBufferSize(void);\r
@@ -276,14 +278,14 @@ uint32_t uiTraceGetTraceBufferSize(void);
 \r
 /*******************************************************************************\r
  * xTraceOpenLabel\r
- * \r
+ *\r
  * Creates user event labels for user event channels or for individual events.\r
  * User events can be used to log application events and data for display in\r
  * the visualization tool. A user event is identified by a label, i.e., a string,\r
  * which is stored in the recorder's symbol table.\r
  * When logging a user event, a numeric handle (reference) to this string is\r
- * used to identify the event. This is obtained by calling \r
- * \r
+ * used to identify the event. This is obtained by calling\r
+ *\r
  *     xTraceOpenLabel()\r
  *\r
  * whihc adds the string to the symbol table (if not already present)\r
@@ -304,7 +306,7 @@ uint32_t uiTraceGetTraceBufferSize(void);
  *     ...\r
  *     vTraceUserEvent(myEventHandle);\r
  *\r
- * The second option is faster since no lookup is required on each event, and \r
+ * The second option is faster since no lookup is required on each event, and\r
  * therefore recommended for user events that are frequently\r
  * executed and/or located in time-critical code. The lookup operation is\r
  * however fairly fast due to the design of the symbol table.\r
@@ -315,40 +317,40 @@ traceLabel xTraceOpenLabel(const char* label);
  * vTraceUserEvent\r
  *\r
  * Basic user event (Standard and Professional Edition only)\r
- * \r
+ *\r
  * Generates a User Event with a text label. The label is created/looked up\r
  * in the symbol table using xTraceOpenLabel.\r
  ******************************************************************************/\r
 void vTraceUserEvent(traceLabel eventLabel);\r
 \r
  /******************************************************************************\r
- * vTracePrintF \r
- * \r
+ * vTracePrintF\r
+ *\r
  * Advanced user events (Professional Edition only)\r
  *\r
  * Generates User Event with formatted text and data, similar to a "printf".\r
- * It is very fast compared to a normal "printf" since this function only \r
+ * It is very fast compared to a normal "printf" since this function only\r
  * stores the arguments. The actual formatting is done\r
- * on the host PC when the trace is displayed in the viewer tool. \r
+ * on the host PC when the trace is displayed in the viewer tool.\r
  *\r
  * User Event labels are created using xTraceOpenLabel.\r
  * Example:\r
  *\r
  *     traceLabel adc_uechannel = xTraceOpenLabel("ADC User Events");\r
  *     ...\r
- *     vTracePrint(adc_uechannel, \r
- *                 "ADC channel %d: %lf volts", \r
+ *     vTracePrint(adc_uechannel,\r
+ *                 "ADC channel %d: %lf volts",\r
  *                 ch, (double)adc_reading/(double)scale);\r
  *\r
  * This can be combined into one line, if desired, but this is slower:\r
  *\r
- *     vTracePrint(xTraceOpenLabel("ADC User Events"), \r
- *                 "ADC channel %d: %lf volts", \r
+ *     vTracePrint(xTraceOpenLabel("ADC User Events"),\r
+ *                 "ADC channel %d: %lf volts",\r
  *                 ch, (double)adc_reading/(double)scale);\r
  *\r
  * Calling xTraceOpenLabel multiple times will not create duplicate entries, but\r
- * it is of course faster to just do it once, and then keep the handle for later \r
- * use. If you don´t have any data arguments, only a text label/string, it is \r
+ * it is of course faster to just do it once, and then keep the handle for later\r
+ * use. If you don´t have any data arguments, only a text label/string, it is\r
  * better to use vTraceUserEvent - it is faster.\r
  *\r
  * Format specifiers supported:\r
@@ -361,84 +363,62 @@ void vTraceUserEvent(traceLabel eventLabel);
  *  %bd - 8 bit signed integer\r
  *  %bu - 8 bit unsigned integer\r
  *  %lf - double-precision float (Note! See below...)\r
- * \r
+ *\r
  * Up to 15 data arguments are allowed, with a total size of maximum 32 byte.\r
  * In case this is exceeded, the user event is changed into an error message.\r
- * \r
- * The data is stored in trace buffer, and is packed to allow storing multiple \r
+ *\r
+ * The data is stored in trace buffer, and is packed to allow storing multiple\r
  * smaller data entries in the same 4-byte record, e.g., four 8-bit values.\r
- * A string requires two bytes, as the symbol table is limited to 64K. Storing \r
- * a double (%lf) uses two records, so this is quite costly. Use float (%f) \r
+ * A string requires two bytes, as the symbol table is limited to 64K. Storing\r
+ * a double (%lf) uses two records, so this is quite costly. Use float (%f)\r
  * unless the higher precision is really necessary.\r
- * \r
- * Note that the double-precision float (%lf) assumes a 64 bit double \r
- * representation. This does not seem to be the case on e.g. PIC24F. \r
- * Before using a %lf argument on a 16-bit MCU, please verify that \r
+ *\r
+ * Note that the double-precision float (%lf) assumes a 64 bit double\r
+ * representation. This does not seem to be the case on e.g. PIC24F.\r
+ * Before using a %lf argument on a 16-bit MCU, please verify that\r
  * "sizeof(double)" actually gives 8 as expected. If not, use %f instead.\r
- ******************************************************************************/ \r
+ ******************************************************************************/\r
 void vTracePrintF(traceLabel eventLabel, const char* formatStr, ...);\r
 \r
+#if (USE_SEPARATE_USER_EVENT_BUFFER == 1)\r
+UserEventChannel xTraceRegisterChannelFormat(traceLabel channel, traceLabel formatStr);\r
+void vTraceChannelPrintF(UserEventChannel channel, ...);\r
+void vTraceChannelUserEvent(UserEventChannel channel);\r
+#endif\r
+\r
 #else\r
 \r
 #define vTracePrintF(eventLabel, formatStr, ...);\r
 #define xTraceOpenLabel(label) 0\r
-#define vTraceUserEvent(eventLabel) \r
-\r
-#endif\r
-\r
-/******************************************************************************\r
- * vTraceExclude______FromTrace\r
- *\r
- * Excludes a task or object from the trace.\r
- * This can be useful if some irrelevant task is very frequent and is "eating\r
- * up the buffer". This should be called after the task has been created, but \r
- * before starting the FreeRTOS scheduler.\r
- *****************************************************************************/\r
-void vTraceExcludeQueueFromTrace(void* handle);\r
-void vTraceExcludeSemaphoreFromTrace(void* handle);\r
-void vTraceExcludeMutexFromTrace(void* handle);\r
-void vTraceExcludeTaskFromTrace(void* handle);\r
-void vTraceExcludeKernelServiceFromTrace(traceKernelService kernelService);\r
-\r
-/******************************************************************************\r
- * vTraceInclude______InTrace\r
- *\r
- * Includes a task, object or kernel service in the trace. This is only\r
- * necessary if the task or object has been previously exluded.\r
- *****************************************************************************/\r
-void vTraceIncludeQueueInTrace(void* handle);\r
-void vTraceIncludeSemaphoreInTrace(void* handle);\r
-void vTraceIncludeMutexInTrace(void* handle);\r
-void vTraceIncludeTaskInTrace(void* handle);\r
-void vTraceIncludeKernelServiceInTrace(traceKernelService kernelService);\r
+#define vTraceUserEvent(eventLabel)\r
 \r
-#ifdef __cplusplus\r
-}\r
 #endif\r
 \r
 #else\r
 \r
-#include "trcPort.h"\r
+/* Empty defines for user functions to avoid compiler errors if trace is not to be used */\r
 \r
-#define vTraceInit()\r
-#define uiTraceStart() (1)\r
+#define vTraceInitTraceData()\r
+#define uiTraceStart() (1) // Fake "success", if used when recorder is excluded from build\r
 #define vTraceStart()\r
 #define vTraceStop()\r
 #define vTraceClear()\r
 #define vTraceStartStatusMonitor()\r
-#define vTracePortSetOutFile(f)\r
 #define vTraceGetTraceBuffer() ((void*)0)\r
 #define uiTraceGetTraceBufferSize() 0\r
 #define xTraceOpenLabel(label) 0\r
 #define vTraceUserEvent(eventLabel)\r
 #define vTracePrintF(eventLabel,formatStr,...)\r
 #define vTraceExcludeTaskFromSchedulingTrace(name)\r
-#define vTraceSetQueueName(queue, name)\r
 \r
 #define vTraceTaskSkipDefaultInstanceFinishedEvents()\r
 #define vTraceSetISRProperties(handle, name, priority)\r
 #define vTraceStoreISRBegin(id)\r
 #define vTraceStoreISREnd()\r
 #endif\r
+\r
+#ifdef __cplusplus\r
+}\r
 #endif\r
 \r
+#endif\r
index 417a54bb7cd7bc1d152d16009feaa6e5529f9cfe..f815e8b21858f9885b47ac740e9b0a1e5aa6d361 100644 (file)
@@ -1,24 +1,28 @@
 \r
-FreeRTOS+Trace - Uploading the trace data\r
+Tracealyzer - Uploading the trace data\r
 -----------------------------------------\r
 Percepio AB, Nov. 8, 2012\r
 \r
 This document decribes how to upload the trace data from the target system to\r
-FreeRTOS+Trace. For information on how to integrate and enable the recorder \r
-library in your FreeRTOS project, see the FreeRTOS+Trace User Manual.\r
+Tracealyzer. \r
 \r
-FreeRTOS+Trace uses your existing debugger to upload the trace data from the \r
+Tracealyzer uses your existing debugger to upload the trace data from the \r
 chip RAM. This is a plain RAM dump, that is done whenever you want to look at \r
 the trace buffer contents. This means it works with essentially with any debug \r
 probe on the market.\r
 \r
-Note that hardware-generated trace is not required (or used by) FreeRTOS+Trace. \r
-We however plan to add support for that in future versions of FreeRTOS+Trace \r
+If the device has a file system and some possibility of accessing this file \r
+system from the development PC, it is also possible to write the recorder data\r
+to a file, using vTraceGetTraceBuffer() and uiTraceGetTraceBufferSize() \r
+found in trcUser.h/.c.\r
+\r
+Note that hardware-generated trace is not required (or used by) Tracealyzer. \r
+We however plan to add support for that in future versions of Tracealyzer \r
 and other Tracealyzer products.\r
 \r
 Built-in support for Segger J-Link/J-Trace and Atmel SAM-ICE\r
 ------------------------------------------------------------\r
-FreeRTOS+Trace v2.3 supports Segger J-Link and J-Link compatible debuggers \r
+Tracealyzer v2.3 supports Segger J-Link and J-Link compatible debuggers \r
 directly, without any debugger IDE involved. Using other debug probes is \r
 also possible, but requires some extra steps, described below.\r
 \r
@@ -36,7 +40,7 @@ can be found can by inspecting the "RecorderData" struct or the
 Typical values are 0x0, 0x10000000 or 0x20000000 as start address\r
 and 0x10000 or 0x20000 as size (64 KB or 128 KB).\r
 \r
-This makes FreeRTOS+Trace reads the chip RAM and locate the trace data. \r
+This makes Tracealyzer reads the chip RAM and locate the trace data. \r
 Note that this option is only available if a compatible debug probe is found.\r
 \r
 J-Link compatible debug probes also include Atmel SAM-ICE and many built-in \r
@@ -46,17 +50,17 @@ connection directly to the board). Look for a Segger J-Link label on the board.
 MemoryLogger extension in Atmel Studio 6\r
 ----------------------------------------\r
 Atmel's new MemoryLogger extension provides a superb integration with\r
-FreeRTOS+Trace. Look for "MemoryLogger" in Atmel Gallery, available in \r
+Tracealyzer. Look for "MemoryLogger" in Atmel Gallery, available in \r
 Atmel Studio and at the Atmel website.\r
 \r
-This extension automatically detects the path to FreeRTOS+Trace, if \r
+This extension automatically detects the path to Tracealyzer, if \r
 installed, and gives you a single-click upload/refresh. You can use it \r
 while debugging and optionally get an automatic refresh eash time the \r
 MCU is halted, e.g., on each breakpoint.\r
 \r
 Using other development environments and debug probes\r
 -----------------------------------------------------\r
-Most debuggers are able to save the RAM contents to a file. FreeRTOS+Trace \r
+Most debuggers are able to save the RAM contents to a file. Tracealyzer \r
 supports the following common formats:\r
 - Binary (.bin), supporting gdb, J-Link and Renesas HEW.\r
 - Intel Hex (.hex), supporting IAR Embedded Workbench and Atmel Studio (atprogram.exe)\r
@@ -66,7 +70,7 @@ When you store the RAM dump, you must also make sure to select the right region,
 i.e., start address and size. The recorder data is stored in a single data \r
 block, identified by the pointer RecorderDataPtr. \r
 It is not necessary to match the begin and end of the recorder data, as long as \r
-it is fully included by the dumped memory region. FreeRTOS+Trace automatically \r
+it is fully included by the dumped memory region. Tracealyzer automatically \r
 finds the trace data in the RAM dump, thanks to special signatures. For chips \r
 with on-chip RAM only, we therefore recommend to dump the entire RAM. This is \r
 usually very fast.\r
@@ -84,7 +88,7 @@ In the debugger view, when stopped on a breakpoint:
        - File format: Intel Extended\r
        - Filename: <name>.hex\r
        - Press "Save" button\r
-You can now open <name>.hex in FreeRTOS+Trace.\r
+You can now open <name>.hex in Tracealyzer.\r
 \r
 To find the right Start and End addresses, check the address of the symbol \r
 "RecorderData". The addresses does not need to match this symbol exactly, as \r
@@ -100,7 +104,7 @@ In the debugger view, when stopped on a breakpoint:
        - Start Address: 00000000 (For RX62N in the demo project)\r
        - End Address: 0000FFFF (For RX62N in the demo project)\r
        - Access size: 1\r
-       - Press "Save" button and open <name>.bin in FreeRTOS+Trace.\r
+       - Press "Save" button and open <name>.bin in Tracealyzer.\r
        \r
 Using Microchip MPLAB v8.86\r
 ------------------------------------------------------\r
@@ -110,7 +114,7 @@ Using Microchip MPLAB v8.86
 - In the dialog ("Export As"), make sure "Single Column Output" is selected (seems to be default).\r
 - Select start address 0x0000 and make sure the end address is beyond the RecorderData structure. \r
   The default values seems to be the whole RAM, so you probably don't need to change this.\r
-- Save as a .mch file and open this file in FreeRTOS+Trace v2.2.4 or later (support for the .mch format was added in v2.2.4).\r
+- Save as a .mch file and open this file in Tracealyzer v2.2.4 or later (support for the .mch format was added in v2.2.4).\r
 \r
 Using STM32 ST-Link\r
 ------------------------------------------------------\r
@@ -118,7 +122,7 @@ Using STM32 ST-Link
 - Connect to the device and view the device memory.\r
 - Set the view to display the entire RAM, or at least the section containing the RecorderData structure.\r
 - Select "Save as" and choose binary (.bin) or Intel Hex (.hex) format.\r
-- Open the resulting file in FreeRTOS+Trace.\r
+- Open the resulting file in Tracealyzer.\r
 \r
 In case you have any question, contact support@percepio.com\r
 \r
index 0553c8bd1862b16793151bbd9a0d74d83befdd30..d8337b1a85babac32ec22d2c157cb182af5659c1 100644 (file)
@@ -1,20 +1,13 @@
 \r
-FreeRTOS+Trace Trace Recorder Library\r
+Tracealyzer Trace Recorder Library\r
 -------------------------------------\r
 Percepio AB\r
 www.percepio.com\r
 \r
-This directory contains the core trace recorder library used by FreeRTOS+Trace v2.3. \r
-\r
-Ready-to-run demonstrations projects are found at www.percepio.com.\r
-\r
-For information on how to integrate the recorder library in your FreeRTOS build, see\r
-the FreeRTOS+Trace User Manual, section 2.\r
+This directory contains the a generic trace recorder library for Tracealyzer v2.4. \r
 \r
 For information on how to upload the trace data from your target system RAM to \r
-FreeRTOS+Trace, see "debugger trace upload.txt"\r
-\r
-NOTE: This trace recorder library requires FreeRTOS v7.3.0 or later.\r
+Tracealyzer, see "debugger trace upload.txt"\r
 \r
 Files included\r
 --------------\r
@@ -22,8 +15,9 @@ Files included
 - trcUser.c / trcUser.h     - The main API towards the application (trcUser.h in the only include necessary).\r
 - trcKernel.c / trcKernel.h - Internal routines for storing kernel events.\r
 - trcBase.c / trcBase.h     - Internal routines for manipulating the data structures and calculating timestamps.\r
-- trcPort.c / trcPort.h     - The port layer, abstracting the hardware (mainly the timer used for timestamping).\r
-- trcHooks.h                           - The interface between FreeRTOS and the recorder, containing trace macro defintions.\r
+- trcHardwarePort.c / trcHardwarePort.h     - The port layer, abstracting the hardware (mainly the timer used for timestamping).\r
+- trcKernelHooks.h                             - The interface between the Kernel and the recorder, containing trace macro defintions.\r
+- trcKernelPort.h                              - Kernel specific implementations of macros and data.\r
 - trcTypes.h                           - Type definitions used.\r
 \r
 Hardware Timer Ports\r
index c80915cc944e4c66d7afdaf9416730a6ded04e59..67f34bc33bda6e3bc1794440f6dd92d77c5d8857 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
+ * Tracealyzer v2.4.1 Recorder Library\r
  * Percepio AB, www.percepio.com\r
  *\r
  * trcBase.c\r
@@ -9,70 +9,75 @@
  * Terms of Use\r
  * This software is copyright Percepio AB. The recorder library is free for\r
  * use together with Percepio products. You may distribute the recorder library\r
- * in its original form, including modifications in trcPort.c and trcPort.h\r
+ * in its original form, including modifications in trcHardwarePort.c/.h\r
  * given that these modification are clearly marked as your own modifications\r
- * and documented in the initial comment section of these source files. \r
- * This software is the intellectual property of Percepio AB and may not be \r
- * sold or in other ways commercially redistributed without explicit written \r
+ * and documented in the initial comment section of these source files.\r
+ * This software is the intellectual property of Percepio AB and may not be\r
+ * sold or in other ways commercially redistributed without explicit written\r
  * permission by Percepio AB.\r
  *\r
- * Disclaimer \r
- * The trace tool and recorder library is being delivered to you AS IS and \r
- * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
- * not and cannot warrant the performance or results you may obtain by using the \r
- * software or documentation. Percepio AB make no warranties, express or \r
- * implied, as to noninfringement of third party rights, merchantability, or \r
- * fitness for any particular purpose. In no event will Percepio AB, its \r
- * technology partners, or distributors be liable to you for any consequential, \r
- * incidental or special damages, including any lost profits or lost savings, \r
- * even if a representative of Percepio AB has been advised of the possibility \r
- * of such damages, or for any claim by any third party. Some jurisdictions do \r
- * not allow the exclusion or limitation of incidental, consequential or special \r
- * damages, or the exclusion of implied warranties or limitations on how long an \r
+ * Disclaimer\r
+ * The trace tool and recorder library is being delivered to you AS IS and\r
+ * Percepio AB makes no warranty as to its use or performance. Percepio AB does\r
+ * not and cannot warrant the performance or results you may obtain by using the\r
+ * software or documentation. Percepio AB make no warranties, express or\r
+ * implied, as to noninfringement of third party rights, merchantability, or\r
+ * fitness for any particular purpose. In no event will Percepio AB, its\r
+ * technology partners, or distributors be liable to you for any consequential,\r
+ * incidental or special damages, including any lost profits or lost savings,\r
+ * even if a representative of Percepio AB has been advised of the possibility\r
+ * of such damages, or for any claim by any third party. Some jurisdictions do\r
+ * not allow the exclusion or limitation of incidental, consequential or special\r
+ * damages, or the exclusion of implied warranties or limitations on how long an\r
  * implied warranty may last, so the above limitations may not apply to you.\r
  *\r
- * FreeRTOS+Trace is available as Free Edition and in two premium editions.\r
- * You may use the premium features during 30 days for evaluation.\r
- * Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/\r
- *\r
- * Copyright Percepio AB, 2012.\r
+ * Copyright Percepio AB, 2013.\r
  * www.percepio.com\r
  ******************************************************************************/\r
 \r
-#include "trcUser.h"\r
-#include "task.h"\r
+#include "trcBase.h"\r
+\r
+#if (USE_TRACEALYZER_RECORDER == 1)\r
 \r
-#if (configUSE_TRACE_FACILITY == 1)\r
+#include <stdint.h>\r
 \r
 /*******************************************************************************\r
  * Static data initializations\r
  ******************************************************************************/\r
 \r
+/* Structure to handle the exclude flags for all objects and tasks. We add some extra objects since index 0 is not used for each object class. */\r
+uint8_t excludedObjects[(TRACE_KERNEL_OBJECT_COUNT + TRACE_NCLASSES) / 8 + 1] = { 0 };\r
+\r
+/* Structure to handle the exclude flags for all event codes */\r
+uint8_t excludedEventCodes[NEventCodes / 8 + 1] = { 0 };\r
+\r
+/* Keeps track of available handles */\r
+objectHandleStackType objectHandleStacks = { { 0 }, { 0 }, { 0 }, { 0 }, { 0 } };\r
 \r
 /*******************************************************************************\r
  * RecorderData\r
  *\r
- * The main data structure. This is the data read by FreeRTOS+Trace, typically\r
+ * The main data structure. This is the data read by Tracealyzer, typically\r
  * through a debugger RAM dump. The recorder access this through the pointer\r
  * RecorderDataPtr, to allow for dynamic memory allocation as well.\r
  *\r
  * On the NXP LPC17xx you may use the secondary RAM bank (AHB RAM) for this\r
- * purpose. For instance, the LPC1766 has 32 KB AHB RAM which allows for \r
+ * purpose. For instance, the LPC1766 has 32 KB AHB RAM which allows for\r
  * allocating a buffer size of at least 7500 events without affecting the main\r
  * RAM. To place RecorderData in this RAM bank, use the below declaration.\r
- * \r
+ *\r
  *     #pragma location="AHB_RAM_MEMORY"\r
  *     RecorderDataType RecorderData = ...\r
- * \r
- * This of course works for other hardware architectures with additional RAM \r
- * banks as well, just replace "AHB_RAM_MEMORY" with the name of the right \r
+ *\r
+ * This of course works for other hardware architectures with additional RAM\r
+ * banks as well, just replace "AHB_RAM_MEMORY" with the name of the right\r
  * address section from the linker file.\r
  *\r
  * However, to keep trcBase.c portable and still have a preconfigured IAR demo\r
- * using AHB RAM, we don't add the pragma directly in trcBase.c but in a header \r
+ * using AHB RAM, we don't add the pragma directly in trcBase.c but in a header\r
  * included where the pragma should go. This is used depending on the setting\r
  * USE_LINKER_PRAGMA, defined in trcConfig.h.\r
- * \r
+ *\r
  * If using GCC, this is instead done by adding a "section" attribute:\r
  *\r
  *     RecorderDataType RecorderData __attribute__ ((section ("name"))) = ...\r
  * Remember to replace "name" with the correct section name.\r
  ******************************************************************************/\r
 \r
+static void vInitStartMarkers(void);\r
+\r
 #if (TRACE_DATA_ALLOCATION == TRACE_DATA_ALLOCATION_STATIC)\r
 #if (USE_LINKER_PRAGMA == 1)\r
 #include "recorderdata_linker_pragma.h"\r
 #endif\r
-RecorderDataType RecorderData =\r
-{\r
-    /* start marker, 12 chars */\r
-    0x01, 0x02, 0x03, 0x04,\r
-    0x71, 0x72, 0x73, 0x74,\r
-    0xF1, 0xF2, 0xF3, 0xF4,\r
-\r
-    /* version code - also used to determine endianness */\r
-    VERSION,\r
-\r
-    /* minor file format version */\r
-    MINOR_VERSION,\r
-    \r
-    /* irq priority order */\r
-    IRQ_PRIORITY_ORDER,\r
-\r
-    /* file size (for control) */\r
-    sizeof(RecorderDataType),\r
-\r
-    /* number of events stored so far */\r
-    0,\r
-\r
-    /* size of events buffer (in event records, each 4 bytes) */\r
-    EVENT_BUFFER_SIZE,\r
-\r
-    /* next free event index (event index, not byte address) */\r
-    0,\r
 \r
-    /* buffer is full */ \r
-    0,\r
+RecorderDataType RecorderData;\r
 \r
-    /* frequency of clock user for timestamps, in Hz - should be 0 here\r
-    as this is used to indicate "not yet initialized" - this is instead\r
-    initialized on the first taskswitch event. */\r
-    0,\r
-\r
-    /* the absolute timestamp of the last stored event, modulo frequency */\r
-    0,\r
-\r
-    /* the number of seconds so far */\r
-    0,\r
+#endif\r
 \r
-    /* is recorder active (yes = 1) - note that "close" events are always \r
-        stored to keep the name-handle mapping updated!*/\r
-    0,\r
+RecorderDataType* RecorderDataPtr = NULL;\r
 \r
-    /* Generated by FreeRTOS+Trace in Team Admin mode. Otherwise this should be "". */\r
-    TEAM_LICENSE_CODE,\r
+/* This version of the function dynamically allocates the trace data */\r
+void prvTraceInitTraceData()\r
+{\r
+#if TRACE_DATA_ALLOCATION == TRACE_DATA_ALLOCATION_STATIC\r
+       RecorderDataPtr = &RecorderData;\r
+#elif TRACE_DATA_ALLOCATION == TRACE_DATA_ALLOCATION_DYNAMIC\r
+       RecorderDataPtr = (RecorderDataType*)TRACE_MALLOC(sizeof(RecorderDataType));\r
+#elif TRACE_DATA_ALLOCATION == TRACE_DATA_ALLOCATION_CUSTOM\r
+       /* DO NOTHING */\r
+#endif\r
 \r
-    /* debug marker 0 */\r
-    0xF0F0F0F0,\r
+       TRACE_ASSERT(RecorderDataPtr != NULL, "prvTraceInitTraceData, RecorderDataPtr == NULL", );\r
 \r
-    /* The Object Property Table - holds info of all active objects */ \r
+    if (! RecorderDataPtr)\r
     {\r
-        /* Number of object classes, also those not used */\r
-        NCLASSES,\r
+        vTraceError("No recorder data structure allocated!");\r
+        return;\r
+    }\r
 \r
-        /* The size in bytes of the object table byte pool */\r
-        DynObjTableSize,\r
+    (void)memset(RecorderDataPtr, 0, sizeof(RecorderDataType));\r
 \r
-        /* The number of slots/handles available for each class */\r
-        {\r
-            NQueue,\r
-            NSemaphore,\r
-            NMutex,\r
-            NTask,\r
-            NISR\r
-        },\r
-\r
-        /* The maximum name length for each object class */\r
-        {\r
-            NameLenQueue,\r
-            NameLenSemaphore,\r
-            NameLenMutex,\r
-            NameLenTask,\r
-            NameLenISR\r
-        },\r
-\r
-        /* The total length a property table entry of the class */\r
-        {\r
-            PropertyTableSizeQueue,\r
-            PropertyTableSizeSemaphore,\r
-            PropertyTableSizeMutex,\r
-            PropertyTableSizeTask,\r
-            PropertyTableSizeISR\r
-        },\r
-\r
-        /* The start index of each class in the object property table */\r
-        {\r
-            StartIndexQueue,\r
-            StartIndexSemaphore,\r
-            StartIndexMutex,\r
-            StartIndexTask,\r
-            StartIndexISR\r
-        },\r
-\r
-        /* the object property table - encoded in a byte array using above \r
-        definitions */\r
-        {0}\r
-    },\r
-\r
-    /* debug marker 1 */\r
-    0xF1F1F1F1,\r
-\r
-    /* The Symbol Table - holds all object names used since system \r
-       startup. Every string is unique, so objects with same name will share \r
-       an entry. Each name entry has four extra bytes: byte 0-1 is a link \r
-       reference in an internal linked list, used for fast lookups, byte 2-3 \r
-       holds a reference to a channel label used for vTracePrintF format \r
-       strings, and byte 4.. holds the object name, followed by a \r
-       zero-termination.*/\r
-    {\r
-        SYMBOL_TABLE_SIZE,\r
+    RecorderDataPtr->startmarker0 = 0x00;\r
+    RecorderDataPtr->startmarker1 = 0x01;\r
+    RecorderDataPtr->startmarker2 = 0x02;\r
+    RecorderDataPtr->startmarker3 = 0x03;\r
+    RecorderDataPtr->startmarker4 = 0x70;\r
+    RecorderDataPtr->startmarker5 = 0x71;\r
+    RecorderDataPtr->startmarker6 = 0x72;\r
+    RecorderDataPtr->startmarker7 = 0x73;\r
+    RecorderDataPtr->startmarker8 = 0xF0;\r
+    RecorderDataPtr->startmarker9 = 0xF1;\r
+    RecorderDataPtr->startmarker10 = 0xF2;\r
+    RecorderDataPtr->startmarker11 = 0xF3;\r
 \r
-        /* next free index (0 is reserved to mean NULL) */\r
-        1,\r
+    RecorderDataPtr->version = TRACE_KERNEL_VERSION;\r
+    RecorderDataPtr->minor_version = TRACE_MINOR_VERSION;\r
+    RecorderDataPtr->irq_priority_order = IRQ_PRIORITY_ORDER;\r
+    RecorderDataPtr->filesize = sizeof(RecorderDataType);\r
 \r
-        /* the symbol table byte pool */\r
-        {0},\r
+    RecorderDataPtr->maxEvents = EVENT_BUFFER_SIZE;\r
 \r
-        /* this is a 64 entry array holding 16-bit references (indexes) \r
-           to the most recent entry of each checksum - i.e., list heads.*/\r
-        {0},\r
+    RecorderDataPtr->debugMarker0 = 0xF0F0F0F0;\r
 \r
-    },\r
+       /* This function is kernel specific */\r
+       vTraceInitObjectPropertyTable();\r
 \r
+    RecorderDataPtr->debugMarker1 = 0xF1F1F1F1;\r
+    RecorderDataPtr->SymbolTable.symTableSize = SYMBOL_TABLE_SIZE;\r
+    RecorderDataPtr->SymbolTable.nextFreeSymbolIndex = 1;\r
 #if (INCLUDE_FLOAT_SUPPORT == 1)\r
-    /* example float, for float endian detection */\r
-    (float)1.0,\r
-#else\r
-    /* This code signals that no float support is included */\r
-    (uint32_t)0, \r
+    RecorderDataPtr->exampleFloatEncoding = (float)1.0; /* otherwise already zero */\r
+#endif\r
+    RecorderDataPtr->debugMarker2 = 0xF2F2F2F2;\r
+    (void)strncpy(RecorderDataPtr->systemInfo, TRACE_DESCRIPTION, TRACE_DESCRIPTION_MAX_LENGTH);\r
+    RecorderDataPtr->debugMarker3 = 0xF3F3F3F3;\r
+    RecorderDataPtr->endmarker0 = 0x0A;\r
+    RecorderDataPtr->endmarker1 = 0x0B;\r
+    RecorderDataPtr->endmarker2 = 0x0C;\r
+    RecorderDataPtr->endmarker3 = 0x0D;\r
+    RecorderDataPtr->endmarker4 = 0x71;\r
+    RecorderDataPtr->endmarker5 = 0x72;\r
+    RecorderDataPtr->endmarker6 = 0x73;\r
+    RecorderDataPtr->endmarker7 = 0x74;\r
+    RecorderDataPtr->endmarker8 = 0xF1;\r
+    RecorderDataPtr->endmarker9 = 0xF2;\r
+    RecorderDataPtr->endmarker10 = 0xF3;\r
+    RecorderDataPtr->endmarker11 = 0xF4;\r
+\r
+#if USE_SEPARATE_USER_EVENT_BUFFER\r
+       RecorderDataPtr->userEventBuffer.bufferID = 1;\r
+       RecorderDataPtr->userEventBuffer.version = 0;\r
+       RecorderDataPtr->userEventBuffer.numberOfSlots = USER_EVENT_BUFFER_SIZE;\r
+       RecorderDataPtr->userEventBuffer.numberOfChannels = CHANNEL_FORMAT_PAIRS + 1;\r
 #endif\r
 \r
-    /* internalErrorOccured */\r
-    0,\r
-    \r
-    /* debug marker 2 */\r
-    0xF2F2F2F2,\r
-    \r
-    /* The trace description string, can hold any information about the system, \r
-        e.g., version, configuration. Error messages from the recorder are\r
-        copied to this buffer. Also used for internal error messages.*/\r
-    TRACE_DESCRIPTION,\r
-        \r
-    /* debug marker 3 */\r
-    0xF3F3F3F3,\r
-\r
-    /* the event data buffer, size EVENT_BUFFER_SIZE*4 */\r
-    {0},\r
-\r
-    /* end markers, used to extract the trace from a RAM dump image */\r
-    0x0A, 0x0B, 0x0C, 0x0D,\r
-    0x71, 0x72, 0x73, 0x74,\r
-    0xF1, 0xF2, 0xF3, 0xF4\r
-};\r
-\r
-RecorderDataType* RecorderDataPtr = &RecorderData;\r
-\r
-/* This version of the function does nothing as the trace data is statically allocated */\r
-RecorderDataType* xTraceInitTraceData(void)\r
-{\r
-    return 0;\r
-}\r
-\r
-#elif (TRACE_DATA_ALLOCATION == TRACE_DATA_ALLOCATION_DYNAMIC)\r
+       /* Kernel specific initialization of the objectHandleStacks variable */\r
+       vTraceInitObjectHandleStack();\r
 \r
-RecorderDataType* RecorderDataPtr = NULL;\r
+       /* Fix the start markers of the trace data structure */\r
+       vInitStartMarkers();\r
+}\r
 \r
-/* This version of the function dynamically allocates the trace data */\r
-RecorderDataType* xTraceInitTraceData(void)\r
+static void vInitStartMarkers()\r
 {\r
-    RecorderDataType* tmp = (RecorderDataType*)pvPortMalloc(sizeof(RecorderDataType));\r
-\r
-    if (! tmp)\r
-    {\r
-        vTraceError("Malloc failed in xTraceInitTraceData! Reduce size constants in trcConfig.h");\r
-        return NULL;\r
-    }\r
-    \r
-    (void)memset(tmp, 0, sizeof(RecorderDataType));\r
-\r
-    tmp->startmarker0 = 0x01;\r
-    tmp->startmarker1 = 0x02;\r
-    tmp->startmarker2 = 0x03;\r
-    tmp->startmarker3 = 0x04;\r
-    tmp->startmarker4 = 0x71;\r
-    tmp->startmarker5 = 0x72;\r
-    tmp->startmarker6 = 0x73;\r
-    tmp->startmarker7 = 0x74;\r
-    tmp->startmarker8 = 0xF1;\r
-    tmp->startmarker9 = 0xF2;\r
-    tmp->startmarker10 = 0xF3;\r
-    tmp->startmarker11 = 0xF4;\r
-    tmp->version = VERSION;\r
-    tmp->minor_version = MINOR_VERSION;\r
-    tmp->irq_priority_order = IRQ_PRIORITY_ORDER;\r
-    tmp->filesize = sizeof(RecorderDataType);\r
-    \r
-    tmp->maxEvents = EVENT_BUFFER_SIZE;\r
-    \r
-    tmp->debugMarker0 = 0xF0F0F0F0;\r
-    tmp->ObjectPropertyTable.NumberOfObjectClasses = NCLASSES;\r
-    tmp->ObjectPropertyTable.ObjectPropertyTableSizeInBytes = DynObjTableSize;\r
-    tmp->ObjectPropertyTable.NumberOfObjectsPerClass[0] = NQueue;\r
-    tmp->ObjectPropertyTable.NumberOfObjectsPerClass[1] = NSemaphore;\r
-    tmp->ObjectPropertyTable.NumberOfObjectsPerClass[2] = NMutex;\r
-    tmp->ObjectPropertyTable.NumberOfObjectsPerClass[3] = NTask;\r
-    tmp->ObjectPropertyTable.NumberOfObjectsPerClass[4] = NISR;\r
-    tmp->ObjectPropertyTable.NameLengthPerClass[0] = NameLenQueue;\r
-    tmp->ObjectPropertyTable.NameLengthPerClass[1] = NameLenSemaphore;\r
-    tmp->ObjectPropertyTable.NameLengthPerClass[2] = NameLenMutex;\r
-    tmp->ObjectPropertyTable.NameLengthPerClass[3] = NameLenTask;\r
-    tmp->ObjectPropertyTable.NameLengthPerClass[4] = NameLenISR;\r
-    tmp->ObjectPropertyTable.TotalPropertyBytesPerClass[0] = PropertyTableSizeQueue;\r
-    tmp->ObjectPropertyTable.TotalPropertyBytesPerClass[1] = PropertyTableSizeSemaphore;\r
-    tmp->ObjectPropertyTable.TotalPropertyBytesPerClass[2] = PropertyTableSizeMutex;\r
-    tmp->ObjectPropertyTable.TotalPropertyBytesPerClass[3] = PropertyTableSizeTask;\r
-    tmp->ObjectPropertyTable.TotalPropertyBytesPerClass[4] = PropertyTableSizeISR;\r
-    tmp->ObjectPropertyTable.StartIndexOfClass[0] = StartIndexQueue;\r
-    tmp->ObjectPropertyTable.StartIndexOfClass[1] = StartIndexSemaphore;\r
-    tmp->ObjectPropertyTable.StartIndexOfClass[2] = StartIndexMutex;\r
-    tmp->ObjectPropertyTable.StartIndexOfClass[3] = StartIndexTask;\r
-    tmp->ObjectPropertyTable.StartIndexOfClass[4] = StartIndexISR;    \r
-    tmp->debugMarker1 = 0xF1F1F1F1;\r
-    tmp->SymbolTable.symTableSize = SYMBOL_TABLE_SIZE;\r
-    tmp->SymbolTable.nextFreeSymbolIndex = 1;\r
-#if (INCLUDE_FLOAT_SUPPORT == 1)\r
-    tmp->exampleFloatEncoding = (float)1.0; /* otherwize already zero */\r
-#endif\r
-    tmp->debugMarker2 = 0xF2F2F2F2;    \r
-    (void)strncpy(tmp->systemInfo, TRACE_DESCRIPTION, TRACE_DESCRIPTION_MAX_LENGTH);\r
-    tmp->debugMarker3 = 0xF3F3F3F3;\r
-    tmp->endmarker0 = 0x0A;\r
-    tmp->endmarker1 = 0x0B;\r
-    tmp->endmarker2 = 0x0C;\r
-    tmp->endmarker3 = 0x0D;\r
-    tmp->endmarker4 = 0x71;\r
-    tmp->endmarker5 = 0x72;\r
-    tmp->endmarker6 = 0x73;\r
-    tmp->endmarker7 = 0x74;\r
-    tmp->endmarker8 = 0xF1;\r
-    tmp->endmarker9 = 0xF2;\r
-    tmp->endmarker10 = 0xF3;\r
-    tmp->endmarker11 = 0xF4;\r
-    \r
-    RecorderDataPtr = tmp;\r
-\r
-    return (RecorderDataType*)RecorderDataPtr;\r
+       uint32_t i;\r
+       uint8_t *ptr = (uint8_t*)&(RecorderDataPtr->startmarker0);\r
+       if ((*ptr) == 0)\r
+       {\r
+               for (i = 0; i < 12; i++)\r
+               {\r
+                       ptr[i] += 1;\r
+               }\r
+       }\r
+       else\r
+       {\r
+               vTraceError("Trace start markers already initialized!");\r
+       }\r
 }\r
 \r
-#endif\r
-\r
 volatile int recorder_busy = 0;\r
 \r
-char sprintfBuffer[150];\r
-\r
-/* For debug printouts - the names of the object classes */\r
-char OBJECTCLASSNAME[NCLASSES][10] =\r
-{\r
-        "QUEUE",\r
-        "SEMAPHORE",\r
-        "MUTEX",\r
-        "TASK",\r
-        "ISR"\r
-};\r
-\r
-/* Initialization of the handle mechanism, see e.g, xTraceGetObjectHandle */\r
-objectHandleStackType objectHandleStacks =\r
-{\r
-        /* indexOfNextAvailableHandle */\r
-        {\r
-                0,\r
-                NQueue,\r
-                NQueue + NSemaphore,\r
-                NQueue + NSemaphore + NMutex,\r
-                NQueue + NSemaphore + NMutex + NTask\r
-        },\r
-\r
-        /* lowestIndexOfClass */\r
-        {\r
-                0,\r
-                NQueue,\r
-                NQueue + NSemaphore,\r
-                NQueue + NSemaphore + NMutex,\r
-                NQueue + NSemaphore + NMutex + NTask\r
-        },\r
-\r
-        /* highestIndexOfClass */\r
-        {\r
-                NQueue - 1,\r
-                NQueue + NSemaphore - 1,\r
-                NQueue + NSemaphore + NMutex - 1,\r
-                NQueue + NSemaphore + NMutex + NTask - 1,\r
-                NQueue + NSemaphore + NMutex + NTask + NISR - 1\r
-        },\r
-        {0},\r
-        {0}\r
-};\r
-\r
-\r
-/* Used for internal state flags of objects */\r
-uint8_t excludedFlags[(NEventCodes+NQueue+NSemaphore+NMutex+NTask) / 8 + 1];\r
-uint8_t ifeFlags[NTask / 8 + 1];\r
-\r
 /* Gives the last error message of the recorder. NULL if no error message. */\r
 char* traceErrorMessage = NULL;\r
 \r
@@ -399,47 +209,46 @@ void* xTraceNextFreeEventBufferSlot(void)
         vTraceError("Attempt to index outside event buffer!");\r
         return NULL;\r
     }\r
-    return (void*)(&RecorderDataPtr->\r
-                   eventData[RecorderDataPtr->nextFreeIndex*4]);\r
+    return (void*)(&RecorderDataPtr->eventData[RecorderDataPtr->nextFreeIndex*4]);\r
 }\r
 \r
 uint16_t uiIndexOfObject(objectHandleType objecthandle, uint8_t objectclass)\r
 {\r
-    if ((objectclass < NCLASSES) && (objecthandle > 0) && (objecthandle <= \r
+       TRACE_ASSERT(objectclass < TRACE_NCLASSES, "uiIndexOfObject: Invalid value for objectclass", 0);\r
+       TRACE_ASSERT(objecthandle > 0 && objecthandle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], "uiIndexOfObject: Invalid value for objecthandle", 0);\r
+\r
+    if ((objectclass < TRACE_NCLASSES) && (objecthandle > 0) && (objecthandle <=\r
     RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass]))\r
     {\r
-        return (uint16_t)(RecorderDataPtr->\r
-            ObjectPropertyTable.StartIndexOfClass[objectclass] + \r
-            (RecorderDataPtr->\r
-            ObjectPropertyTable.TotalPropertyBytesPerClass[objectclass] * \r
-            (objecthandle-1)));\r
+        return (uint16_t)(RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[objectclass] +\r
+                       (RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[objectclass] * (objecthandle-1)));\r
     }\r
-    \r
-    vTraceError("Object table lookup with invalid object handle or object class!");    \r
+\r
+    vTraceError("Object table lookup with invalid object handle or object class!");\r
     return 0;\r
 }\r
 \r
 /*******************************************************************************\r
- * Object handle system \r
+ * Object handle system\r
  * This provides a mechanism to assign each kernel object (tasks, queues, etc)\r
  * with a 1-byte handle, that is used to identify the object in the trace.\r
  * This way, only one byte instead of four is necessary to identify the object.\r
  * This allows for maximum 255 objects, of each object class, active at any\r
  * moment.\r
  * Note that zero is reserved as an error code and is not a valid handle.\r
- * \r
- * In order to allow for fast dynamic allocation and release of object handles, \r
- * the handles of each object class (e.g., TASK) are stored in a stack. When a \r
- * handle is needed, e.g., on task creation, the next free handle is popped from \r
- * the stack. When an object (e.g., task) is deleted, its handle is pushed back \r
+ *\r
+ * In order to allow for fast dynamic allocation and release of object handles,\r
+ * the handles of each object class (e.g., TASK) are stored in a stack. When a\r
+ * handle is needed, e.g., on task creation, the next free handle is popped from\r
+ * the stack. When an object (e.g., task) is deleted, its handle is pushed back\r
  * on the stack and can thereby be reused for other objects.\r
- * \r
- * Since this allows for reuse of object handles, a specific handle (e.g, "8") \r
- * may refer to TASK_X at one point, and later mean "TASK_Y". To resolve this, \r
- * the recorder uses "Close events", which are stored in the main event buffer \r
- * when objects are deleted and their handles are released. The close event \r
+ *\r
+ * Since this allows for reuse of object handles, a specific handle (e.g, "8")\r
+ * may refer to TASK_X at one point, and later mean "TASK_Y". To resolve this,\r
+ * the recorder uses "Close events", which are stored in the main event buffer\r
+ * when objects are deleted and their handles are released. The close event\r
  * contains the mapping between object handle and object name which was valid up\r
- * to this point in time. The object name is stored as a symbol table entry. \r
+ * to this point in time. The object name is stored as a symbol table entry.\r
  ******************************************************************************/\r
 \r
 objectHandleType xTraceGetObjectHandle(traceObjectClass objectclass)\r
@@ -447,61 +256,45 @@ objectHandleType xTraceGetObjectHandle(traceObjectClass objectclass)
     static objectHandleType handle;\r
     static int indexOfHandle;\r
 \r
+       TRACE_ASSERT(objectclass < TRACE_NCLASSES, "xTraceGetObjectHandle: Invalid value for objectclass", (objectHandleType)0);\r
+\r
     indexOfHandle = objectHandleStacks.indexOfNextAvailableHandle[objectclass];\r
     if (objectHandleStacks.objectHandles[indexOfHandle] == 0)\r
     {\r
         /* Zero is used to indicate a never before used handle, i.e.,\r
-           new slots in the handle stack. The handle slot needs to \r
+           new slots in the handle stack. The handle slot needs to\r
            be initialized here (starts at 1). */\r
-        objectHandleStacks.objectHandles[indexOfHandle] = \r
-            (objectHandleType)(1 + indexOfHandle - \r
+        objectHandleStacks.objectHandles[indexOfHandle] =\r
+            (objectHandleType)(1 + indexOfHandle -\r
             objectHandleStacks.lowestIndexOfClass[objectclass]);\r
     }\r
 \r
     handle = objectHandleStacks.objectHandles[indexOfHandle];\r
-    \r
-    if ( objectHandleStacks.indexOfNextAvailableHandle[objectclass] \r
-        > objectHandleStacks.highestIndexOfClass[objectclass] )\r
+\r
+    if (objectHandleStacks.indexOfNextAvailableHandle[objectclass]\r
+        > objectHandleStacks.highestIndexOfClass[objectclass])\r
     {\r
         /* ERROR */\r
-        switch(objectclass)\r
-        {\r
-        case TRACE_CLASS_TASK:\r
-            vTraceError("Not enough TASK handles - increase NTask in trcConfig.h");         \r
-            break;\r
-        case TRACE_CLASS_ISR:\r
-            vTraceError("Not enough ISR handles - increase NISR in trcConfig.h");         \r
-            break;\r
-        case TRACE_CLASS_SEMAPHORE:\r
-            vTraceError("Not enough SEMAPHORE handles - increase NSemaphore in trcConfig.h");         \r
-            break;\r
-        case TRACE_CLASS_MUTEX:\r
-            vTraceError("Not enough MUTEX handles - increase NMutex in trcConfig.h");         \r
-            break;\r
-        case TRACE_CLASS_QUEUE:\r
-            vTraceError("Not enough QUEUE handles - increase NQueue in trcConfig.h");         \r
-            break;\r
-        default:\r
-            vTraceError("Invalid object class.");\r
-            break;\r
-        }\r
-        \r
+               vTraceError(pszTraceGetErrorNotEnoughHandles(objectclass));\r
+\r
         handle = 0; /* an invalid/anonymous handle - but the recorder is stopped now... */\r
     }\r
     else\r
     {\r
         int hndCount;\r
         objectHandleStacks.indexOfNextAvailableHandle[objectclass]++;\r
-        \r
-        hndCount = objectHandleStacks.indexOfNextAvailableHandle[objectclass] - \r
+\r
+        hndCount = objectHandleStacks.indexOfNextAvailableHandle[objectclass] -\r
             objectHandleStacks.lowestIndexOfClass[objectclass];\r
-        \r
-        if (hndCount > \r
+\r
+        if (hndCount >\r
             objectHandleStacks.handleCountWaterMarksOfClass[objectclass])\r
         {\r
-            objectHandleStacks.handleCountWaterMarksOfClass[objectclass] = \r
+            objectHandleStacks.handleCountWaterMarksOfClass[objectclass] =\r
                 (objectHandleType)hndCount;\r
         }\r
+\r
+               TRACE_CLEAR_OBJECT_FLAG_ISEXCLUDED(objectclass, handle);\r
     }\r
 \r
     return handle;\r
@@ -511,9 +304,12 @@ void vTraceFreeObjectHandle(traceObjectClass objectclass, objectHandleType handl
 {\r
     int indexOfHandle;\r
 \r
+    TRACE_ASSERT(objectclass < TRACE_NCLASSES, "vTraceFreeObjectHandle: Invalid value for objectclass", );\r
+    TRACE_ASSERT(handle > 0 && handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], "vTraceFreeObjectHandle: Invalid value for handle", );\r
+\r
     /* Check that there is room to push the handle on the stack */\r
-    if ( (objectHandleStacks.indexOfNextAvailableHandle[objectclass] - 1) < \r
-        objectHandleStacks.lowestIndexOfClass[objectclass] )\r
+    if ((objectHandleStacks.indexOfNextAvailableHandle[objectclass] - 1) <\r
+        objectHandleStacks.lowestIndexOfClass[objectclass])\r
     {\r
         /* Error */\r
         vTraceError("Attempt to free more handles than allocated! (duplicate xTaskDelete or xQueueDelete?)");\r
@@ -528,7 +324,7 @@ void vTraceFreeObjectHandle(traceObjectClass objectclass, objectHandleType handl
 }\r
 \r
 /*******************************************************************************\r
- * Objects Property Table \r
+ * Objects Property Table\r
  *\r
  * This holds the names and properties of the currently active objects, such as\r
  * tasks and queues. This is developed to support "dynamic" objects which might\r
@@ -548,52 +344,30 @@ void vTraceFreeObjectHandle(traceObjectClass objectclass, objectHandleType handl
  * Registers the names of queues, semaphores and other kernel objects in the\r
  * recorder's Object Property Table, at the given handle and object class.\r
  ******************************************************************************/\r
-void vTraceSetObjectName(traceObjectClass objectclass, \r
-                         objectHandleType handle, \r
+void vTraceSetObjectName(traceObjectClass objectclass,\r
+                         objectHandleType handle,\r
                          const char* name)\r
 {\r
     static uint16_t idx;\r
 \r
-    if (handle == 0)\r
+       TRACE_ASSERT(name != NULL, "vTraceSetObjectName: name == NULL", );\r
+\r
+    if (objectclass >= TRACE_NCLASSES)\r
     {\r
-        vTraceError("Illegal handle (0) in vTraceSetObjectName.");   \r
+        vTraceError("Illegal object class in vTraceSetObjectName");\r
         return;\r
     }\r
-    \r
-    switch(objectclass)\r
+\r
+    if (handle == 0)\r
     {\r
-        case TRACE_CLASS_TASK:\r
-        case TRACE_CLASS_ISR:\r
-        case TRACE_CLASS_SEMAPHORE:\r
-        case TRACE_CLASS_MUTEX:\r
-        case TRACE_CLASS_QUEUE:\r
-        break;\r
-    default:\r
-        vTraceError("Illegal object class in vTraceSetObjectName");   \r
-        break;            \r
+        vTraceError("Illegal handle (0) in vTraceSetObjectName.");\r
+        return;\r
     }\r
 \r
-    if (handle > \r
-        RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass])\r
+    if (handle > RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass])\r
     {\r
-        switch(objectclass)\r
-        {\r
-            case TRACE_CLASS_TASK:\r
-            vTraceError("Not enough TASK handles - increase NTask in trcConfig.h");         \r
-            break;\r
-            case TRACE_CLASS_ISR:\r
-            vTraceError("Not enough ISR handles - increase NISR in trcConfig.h");       \r
-            break;\r
-            case TRACE_CLASS_SEMAPHORE:\r
-            vTraceError("Not enough SEMAPHORE handles - increase NSemaphore in trcConfig.h");\r
-            break;\r
-            case TRACE_CLASS_MUTEX:\r
-            vTraceError("Not enough MUTEX handles - increase NMutex in trcConfig.h");\r
-            break;\r
-            case TRACE_CLASS_QUEUE:\r
-            vTraceError("Not enough QUEUE handles - increase NQueue in trcConfig.h");\r
-            break;\r
-        }\r
+           /* ERROR */\r
+           vTraceError(pszTraceGetErrorNotEnoughHandles(objectclass));\r
     }\r
     else\r
     {\r
@@ -603,21 +377,21 @@ void vTraceSetObjectName(traceObjectClass objectclass,
         {\r
             (void)strncpy((char*)&(RecorderDataPtr->ObjectPropertyTable.objbytes[idx]),\r
                     name,\r
-                    RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[ objectclass ] );\r
-#ifdef WIN32\r
-            printf("vTraceSetObjectName(%d, %d, %s)\n", objectclass, handle, name);\r
-#endif\r
+                    RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[ objectclass ]);\r
         }\r
     }\r
 }\r
 \r
 traceLabel prvTraceOpenSymbol(const char* name, traceLabel userEventChannel)\r
 {\r
-    static uint16_t result;\r
-    static uint8_t len;\r
-    static uint8_t crc;\r
+    uint16_t result;\r
+    uint8_t len;\r
+    uint8_t crc;\r
     len = 0;\r
     crc = 0;\r
+\r
+    TRACE_ASSERT(name != NULL, "prvTraceOpenSymbol: name == NULL", (traceLabel)0);\r
+\r
     prvTraceGetChecksum(name, &crc, &len);\r
 \r
     trcCRITICAL_SECTION_BEGIN();\r
@@ -635,38 +409,46 @@ traceLabel prvTraceOpenSymbol(const char* name, traceLabel userEventChannel)
  * Supporting functions\r
  ******************************************************************************/\r
 \r
+extern volatile uint32_t rtest_error_flag;\r
+\r
 /*******************************************************************************\r
  * vTraceError\r
  *\r
- * Called by various parts in the recorder. Stops the recorder and stores a \r
+ * Called by various parts in the recorder. Stops the recorder and stores a\r
  * pointer to an error message, which is printed by the monitor task.\r
- * If you are not using the monitor task, you may use xTraceGetLastError() \r
+ * If you are not using the monitor task, you may use xTraceGetLastError()\r
  * from your application to check if the recorder is OK.\r
  *\r
- * Note: If a recorder error is registered before vTraceStart is called, the \r
- * trace start will be aborted. This can occur if any of the Nxxxx constants \r
+ * Note: If a recorder error is registered before vTraceStart is called, the\r
+ * trace start will be aborted. This can occur if any of the Nxxxx constants\r
  * (e.g., NTask) in trcConfig.h is too small.\r
  ******************************************************************************/\r
 void vTraceError(const char* msg)\r
 {\r
-    vTraceStop();\r
+       TRACE_ASSERT(msg != NULL, "vTraceError: msg == NULL", );\r
+       TRACE_ASSERT(RecorderDataPtr != NULL, "vTraceError: RecorderDataPtr == NULL", );\r
+\r
+       // Stop the recorder. Note: We do not call vTraceStop, since that adds a weird\r
+       // and unnecessary dependency to trcUser.c.\r
+\r
+       RecorderDataPtr->recorderActive = 0;\r
+\r
     if (traceErrorMessage == NULL)\r
     {\r
       traceErrorMessage = (char*)msg;\r
-      (void)strncpy(RecorderDataPtr->systemInfo, \r
-          traceErrorMessage, \r
-          TRACE_DESCRIPTION_MAX_LENGTH);\r
-      RecorderDataPtr->internalErrorOccured = 1;\r
+      (void)strncpy(RecorderDataPtr->systemInfo, traceErrorMessage, TRACE_DESCRIPTION_MAX_LENGTH);\r
+      RecorderDataPtr->internalErrorOccured = 1;                \r
     }\r
+       \r
 }\r
 \r
 /******************************************************************************\r
- * prvCheckDataToBeOverwrittenForMultiEntryUserEvents\r
+ * prvCheckDataToBeOverwrittenForMultiEntryEvents\r
  *\r
- * This checks if the next event to be overwritten is a multi-entry user event, \r
+ * This checks if the next event to be overwritten is a multi-entry user event,\r
  * i.e., a USER_EVENT followed by data entries.\r
  * Such data entries do not have an event code at byte 0, as other events.\r
- * All 4 bytes are user data, so the first byte of such data events must \r
+ * All 4 bytes are user data, so the first byte of such data events must\r
  * not be interpreted as type field. The number of data entries following\r
  * a USER_EVENT is given in the event code of the USER_EVENT.\r
  * Therefore, when overwriting a USER_EVENT (when using in ringbuffer mode)\r
@@ -675,16 +457,18 @@ void vTraceError(const char* msg)
  * This is assumed to execute within a critical section...\r
  *****************************************************************************/\r
 \r
-void prvCheckDataToBeOverwrittenForMultiEntryUserEvents(\r
-    uint8_t nofEntriesToCheck)\r
+void prvCheckDataToBeOverwrittenForMultiEntryEvents(uint8_t nofEntriesToCheck)\r
 {\r
     /* Generic "int" type is desired - should be 16 bit variable on 16 bit HW */\r
-    unsigned int i = 0; \r
+    unsigned int i = 0;\r
     unsigned int e = 0;\r
+\r
+    TRACE_ASSERT(nofEntriesToCheck != 0, "prvCheckDataToBeOverwrittenForMultiEntryEvents: nofEntriesToCheck == 0", );\r
+\r
     while (i < nofEntriesToCheck)\r
-    {        \r
+    {\r
         e = RecorderDataPtr->nextFreeIndex + i;\r
-        if ((RecorderDataPtr->eventData[e*4] > USER_EVENT) && \r
+        if ((RecorderDataPtr->eventData[e*4] > USER_EVENT) &&\r
             (RecorderDataPtr->eventData[e*4] < USER_EVENT + 16))\r
         {\r
             uint8_t nDataEvents = (uint8_t)(RecorderDataPtr->eventData[e*4] - USER_EVENT);\r
@@ -692,6 +476,20 @@ void prvCheckDataToBeOverwrittenForMultiEntryUserEvents(
             {\r
                 (void)memset(& RecorderDataPtr->eventData[e*4], 0, 4 + 4 * nDataEvents);\r
             }\r
+        }\r
+               else if (RecorderDataPtr->eventData[e*4] == DIV_XPS)\r
+        {\r
+            if ((e + 1) < RecorderDataPtr->maxEvents)\r
+            {\r
+                               /* Clear 8 bytes */\r
+                (void)memset(& RecorderDataPtr->eventData[e*4], 0, 4 + 4);\r
+            }\r
+            else\r
+            {\r
+                   /* Clear 8 bytes, 4 first and 4 last */\r
+                   (void)memset(& RecorderDataPtr->eventData[0], 0, 4);\r
+                   (void)memset(& RecorderDataPtr->eventData[e*4], 0, 4);\r
+            }\r
         }\r
         i++;\r
     }\r
@@ -708,14 +506,14 @@ void prvTraceUpdateCounters(void)
     {\r
         return;\r
     }\r
-    \r
+\r
     RecorderDataPtr->numEvents++;\r
 \r
     RecorderDataPtr->nextFreeIndex++;\r
-    \r
+\r
     if (RecorderDataPtr->nextFreeIndex >= EVENT_BUFFER_SIZE)\r
-    {   \r
-#if (RECORDER_STORE_MODE == STORE_MODE_RING_BUFFER)       \r
+    {\r
+#if (TRACE_RECORDER_STORE_MODE == TRACE_STORE_MODE_RING_BUFFER)\r
         RecorderDataPtr->bufferIsFull = 1;\r
         RecorderDataPtr->nextFreeIndex = 0;\r
 #else\r
@@ -723,10 +521,10 @@ void prvTraceUpdateCounters(void)
 #endif\r
     }\r
 \r
-#if (RECORDER_STORE_MODE == STORE_MODE_RING_BUFFER)\r
-    prvCheckDataToBeOverwrittenForMultiEntryUserEvents(1);\r
+#if (TRACE_RECORDER_STORE_MODE == TRACE_STORE_MODE_RING_BUFFER)\r
+    prvCheckDataToBeOverwrittenForMultiEntryEvents(1);\r
 #endif\r
-    \r
+\r
 #ifdef STOP_AFTER_N_EVENTS\r
 #if (STOP_AFTER_N_EVENTS > -1)\r
     if (RecorderDataPtr->numEvents >= STOP_AFTER_N_EVENTS)\r
@@ -736,7 +534,7 @@ void prvTraceUpdateCounters(void)
 #endif\r
 #endif\r
 }\r
-    \r
+\r
 /******************************************************************************\r
  * prvTraceGetDTS\r
  *\r
@@ -754,26 +552,25 @@ uint16_t prvTraceGetDTS(uint16_t param_maxDTS)
     uint32_t dts = 0;\r
     uint32_t timestamp = 0;\r
 \r
+    TRACE_ASSERT(param_maxDTS == 0xFF || param_maxDTS == 0xFFFF, "prvTraceGetDTS: Invalid value for param_maxDTS", 0);\r
+\r
     if (RecorderDataPtr->frequency == 0)\r
     {\r
         /* If HWTC_PERIOD is mapped to the timer reload register,\r
-        such as in the Cortex M port, it is not initialized before\r
-        FreeRTOS has been started. We therefore store the frequency\r
-        of the timer at the first timestamped event after the \r
-        scheduler has started. (Note that this function is called\r
-        also by vTraceStart and uiTraceStart, which might be\r
-        called before the scheduler has been started.) */\r
-\r
-#if (SELECTED_PORT == PORT_Win32)    \r
+        such as in the Cortex M port, it might not be initialized\r
+               before the Kernel scheduler has been started has been\r
+               started. We therefore store the frequency of the timer at\r
+               the first timestamped event after the scheduler has started.\r
+               (Note that this function is called also by vTraceStart and\r
+               uiTraceStart, which might be called before the scheduler\r
+               has been started.) */\r
+\r
+#if (SELECTED_PORT == PORT_Win32)\r
         RecorderDataPtr->frequency = 100000;\r
-#elif (SELECTED_PORT == PORT_HWIndependent)    \r
-        RecorderDataPtr->frequency = configTICK_RATE_HZ;\r
-#else        \r
-        if (xTaskGetSchedulerState() != 0) /* Has the scheduler started? */\r
-        {            \r
-            RecorderDataPtr->frequency = \r
-                 (uint32_t)HWTC_PERIOD * (uint32_t)configTICK_RATE_HZ / (uint32_t)HWTC_DIVISOR; \r
-        }\r
+#elif (SELECTED_PORT == PORT_HWIndependent)\r
+        RecorderDataPtr->frequency = TRACE_TICK_RATE_HZ;\r
+#else\r
+               RecorderDataPtr->frequency = TRACE_CPU_CLOCK_HZ / (uint32_t)HWTC_DIVISOR;\r
 #endif\r
     }\r
 \r
@@ -782,26 +579,16 @@ uint16_t prvTraceGetDTS(uint16_t param_maxDTS)
     * If necessary, whole seconds are extracted using division while the rest\r
     * comes from the modulo operation.\r
     **************************************************************************/\r
-    \r
-    uiTracePortGetTimeStamp(&timestamp);\r
+\r
+    vTracePortGetTimeStamp(&timestamp);\r
 \r
     /***************************************************************************\r
-    * This condition is only for the Win32 port, since it does not use the tick\r
-    * count but instead only HWTC_COUNT (from the performance counter).\r
-    * Without this condition, you sometimes get a negative dts value (converted\r
-    * into a very large unsiged value) when the performance counter wraps \r
-    * around. In other "normal" ports also using the FreeRTOS tick counter, this \r
-    * condition can not occur and therefore has no impact.\r
+    * Since dts is unsigned the result will be correct even if timestamp has\r
+       * wrapped around.\r
     ***************************************************************************/\r
-    if (timestamp < old_timestamp)\r
-    {\r
-        timestamp += RecorderDataPtr->frequency;\r
-    }\r
-\r
-\r
        dts = timestamp - old_timestamp;\r
     old_timestamp = timestamp;\r
-    \r
+\r
     if (RecorderDataPtr->frequency > 0)\r
     {\r
         /* Check if dts > 1 second */\r
@@ -813,8 +600,10 @@ uint16_t prvTraceGetDTS(uint16_t param_maxDTS)
             RecorderDataPtr->absTimeLastEvent += dts % RecorderDataPtr->frequency;\r
         }\r
         else\r
+               {\r
             RecorderDataPtr->absTimeLastEvent += dts;\r
-        \r
+               }\r
+\r
         /* Check if absTimeLastEvent >= 1 second */\r
         if (RecorderDataPtr->absTimeLastEvent >= RecorderDataPtr->frequency)\r
         {\r
@@ -858,7 +647,7 @@ uint16_t prvTraceGetDTS(uint16_t param_maxDTS)
         }\r
     }\r
 \r
-    return (uint16_t)(dts % (param_maxDTS + 1));\r
+    return (uint16_t)dts & param_maxDTS;\r
 }\r
 \r
 /*******************************************************************************\r
@@ -874,13 +663,16 @@ uint16_t prvTraceGetDTS(uint16_t param_maxDTS)
  * byte 4..(4 + length): the string (object name or user event label), with\r
  * zero-termination\r
  ******************************************************************************/\r
-traceLabel prvTraceLookupSymbolTableEntry(const char* name, \r
-                                          uint8_t crc6, \r
-                                          uint8_t len, \r
+traceLabel prvTraceLookupSymbolTableEntry(const char* name,\r
+                                          uint8_t crc6,\r
+                                          uint8_t len,\r
                                           traceLabel chn)\r
 {\r
     uint16_t i = RecorderDataPtr->SymbolTable.latestEntryOfChecksum[ crc6 ];\r
 \r
+       TRACE_ASSERT(name != NULL, "prvTraceLookupSymbolTableEntry: name == NULL", (traceLabel)0);\r
+       TRACE_ASSERT(len != 0, "prvTraceLookupSymbolTableEntry: len == 0", (traceLabel)0);\r
+\r
     while (i != 0)\r
     {\r
         if (RecorderDataPtr->SymbolTable.symbytes[i + 2] == (chn & 0x00FF))\r
@@ -914,54 +706,58 @@ traceLabel prvTraceLookupSymbolTableEntry(const char* name,
  * byte 4..(4 + length): the string (object name or user event label), with\r
  * zero-termination\r
  ******************************************************************************/\r
-uint16_t prvTraceCreateSymbolTableEntry(const char* name, \r
-                                        uint8_t crc6, \r
-                                        uint8_t len, \r
+uint16_t prvTraceCreateSymbolTableEntry(const char* name,\r
+                                        uint8_t crc6,\r
+                                        uint8_t len,\r
                                         traceLabel channel)\r
 {\r
     uint16_t ret = 0;\r
+\r
+       TRACE_ASSERT(name != NULL, "prvTraceCreateSymbolTableEntry: name == NULL", 0);\r
+       TRACE_ASSERT(len != 0, "prvTraceCreateSymbolTableEntry: len == 0", 0);\r
+\r
     if (RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + len + 4 >= SYMBOL_TABLE_SIZE)\r
     {\r
         vTraceError("Symbol table full. Increase SYMBOL_TABLE_SIZE in trcConfig.h");\r
-        ret = 0;        \r
+        ret = 0;\r
     }\r
     else\r
     {\r
 \r
         RecorderDataPtr->SymbolTable.symbytes\r
-            [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex] = \r
+            [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex] =\r
             (uint8_t)(RecorderDataPtr->SymbolTable.latestEntryOfChecksum[ crc6 ] & 0x00FF);\r
 \r
         RecorderDataPtr->SymbolTable.symbytes\r
-            [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 1] = \r
+            [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 1] =\r
             (uint8_t)(RecorderDataPtr->SymbolTable.latestEntryOfChecksum[ crc6 ] / 0x100);\r
 \r
         RecorderDataPtr->SymbolTable.symbytes\r
-            [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 2] = \r
+            [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 2] =\r
             (uint8_t)(channel & 0x00FF);\r
 \r
         RecorderDataPtr->SymbolTable.symbytes\r
-            [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 3] = \r
+            [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 3] =\r
             (uint8_t)(channel / 0x100);\r
 \r
         /* set name (bytes 4...4+len-1) */\r
-        (void)strncpy((char*)&( RecorderDataPtr->SymbolTable.symbytes\r
-            [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 4] ), name, len);\r
+        (void)strncpy((char*)&(RecorderDataPtr->SymbolTable.symbytes\r
+            [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 4]), name, len);\r
 \r
-        /* Set zero termination (at offest 4+len) */\r
+        /* Set zero termination (at offset 4+len) */\r
         RecorderDataPtr->SymbolTable.symbytes\r
             [RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 4 + len] = '\0';\r
 \r
         /* store index of entry (for return value, and as head of LL[crc6]) */\r
         RecorderDataPtr->SymbolTable.latestEntryOfChecksum\r
             [ crc6 ] = (uint16_t)RecorderDataPtr->SymbolTable.nextFreeSymbolIndex;\r
-        \r
+\r
         RecorderDataPtr->SymbolTable.nextFreeSymbolIndex += (len + 5);\r
-        \r
-        ret = (uint16_t)(RecorderDataPtr->SymbolTable.nextFreeSymbolIndex - \r
+\r
+        ret = (uint16_t)(RecorderDataPtr->SymbolTable.nextFreeSymbolIndex -\r
             (len + 5));\r
     }\r
-    \r
+\r
     return ret;\r
 }\r
 \r
@@ -969,7 +765,7 @@ uint16_t prvTraceCreateSymbolTableEntry(const char* name,
 /*******************************************************************************\r
  * prvTraceGetChecksum\r
  *\r
- * Calculates a simple 6-bit checksum from a string, used to index the string \r
+ * Calculates a simple 6-bit checksum from a string, used to index the string\r
  * for fast symbol table lookup.\r
  ******************************************************************************/\r
 void prvTraceGetChecksum(const char *pname, uint8_t* pcrc, uint8_t* plength)\r
@@ -977,16 +773,21 @@ void prvTraceGetChecksum(const char *pname, uint8_t* pcrc, uint8_t* plength)
    unsigned char c;\r
    int length = 0;\r
    int crc = 0;\r
-   if ( pname != (const char *) 0 )\r
+\r
+   TRACE_ASSERT(pname != NULL, "prvTraceGetChecksum: pname == NULL", );\r
+   TRACE_ASSERT(pcrc != NULL, "prvTraceGetChecksum: pcrc == NULL", );\r
+   TRACE_ASSERT(plength != NULL, "prvTraceGetChecksum: plength == NULL", );\r
+\r
+   if (pname != (const char *) 0)\r
    {\r
-      for ( ; (c = *pname++) != '\0'; )\r
+      for (; (c = *pname++) != '\0';)\r
       {\r
          crc += c;\r
          length++;\r
       }\r
    }\r
-   *pcrc = (uint8_t)(crc % 64);\r
+   *pcrc = (uint8_t)(crc & 0x3F);\r
    *plength = (uint8_t)length;\r
 }\r
 \r
-#endif\r
+#endif
\ No newline at end of file
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcHardwarePort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcHardwarePort.c
new file mode 100644 (file)
index 0000000..754b321
--- /dev/null
@@ -0,0 +1,119 @@
+/******************************************************************************* \r
+ * Tracealyzer v2.4.1 Recorder Library\r
+ * Percepio AB, www.percepio.com\r
+ *\r
+ * trcHardwarePort.c\r
+ *\r
+ * Contains together with trcHardwarePort.h all hardware portability issues of \r
+ * the trace recorder library.\r
+ *\r
+ * Terms of Use\r
+ * This software is copyright Percepio AB. The recorder library is free for\r
+ * use together with Percepio products. You may distribute the recorder library\r
+ * in its original form, including modifications in trcPort.c and trcPort.h\r
+ * given that these modification are clearly marked as your own modifications\r
+ * and documented in the initial comment section of these source files. \r
+ * This software is the intellectual property of Percepio AB and may not be \r
+ * sold or in other ways commercially redistributed without explicit written \r
+ * permission by Percepio AB.\r
+ *\r
+ * Disclaimer \r
+ * The trace tool and recorder library is being delivered to you AS IS and \r
+ * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
+ * not and cannot warrant the performance or results you may obtain by using the \r
+ * software or documentation. Percepio AB make no warranties, express or \r
+ * implied, as to noninfringement of third party rights, merchantability, or \r
+ * fitness for any particular purpose. In no event will Percepio AB, its \r
+ * technology partners, or distributors be liable to you for any consequential, \r
+ * incidental or special damages, including any lost profits or lost savings, \r
+ * even if a representative of Percepio AB has been advised of the possibility \r
+ * of such damages, or for any claim by any third party. Some jurisdictions do \r
+ * not allow the exclusion or limitation of incidental, consequential or special \r
+ * damages, or the exclusion of implied warranties or limitations on how long an \r
+ * implied warranty may last, so the above limitations may not apply to you.\r
+ *\r
+ * Copyright Percepio AB, 2013.\r
+ * www.percepio.com\r
+ ******************************************************************************/\r
+\r
+#include "trcHardwarePort.h"\r
+\r
+#if (USE_TRACEALYZER_RECORDER == 1)\r
+\r
+#include <stdint.h>\r
+\r
+\r
+/*******************************************************************************\r
+ * uiTraceTickCount\r
+ *\r
+ * This variable is should be updated by the Kernel tick interrupt. This does \r
+ * not need to be modified when developing a new timer port. It is preferred to \r
+ * keep any timer port changes in the HWTC macro definitions, which typically \r
+ * give sufficient flexibility.\r
+ ******************************************************************************/\r
+uint32_t uiTraceTickCount = 0;\r
+\r
+/******************************************************************************\r
+ * vTracePortGetTimeStamp\r
+ *\r
+ * Returns the current time based on the HWTC macros which provide a hardware\r
+ * isolation layer towards the hardware timer/counter.\r
+ *\r
+ * The HWTC macros and vTracePortGetTimeStamp is the main porting issue\r
+ * or the trace recorder library. Typically you should not need to change\r
+ * the code of vTracePortGetTimeStamp if using the HWTC macros.\r
+ *\r
+ ******************************************************************************/\r
+void vTracePortGetTimeStamp(uint32_t *pTimestamp)\r
+{\r
+       static uint32_t last_traceTickCount = 0;\r
+    static uint32_t last_hwtc_count = 0;\r
+    uint32_t traceTickCount = 0;\r
+    uint32_t hwtc_count = 0;\r
+    \r
+    /* Retrieve HWTC_COUNT only once since the same value should be used all throughout this function. */\r
+#if (HWTC_COUNT_DIRECTION == DIRECTION_INCREMENTING)\r
+    hwtc_count = HWTC_COUNT;\r
+#elif (HWTC_COUNT_DIRECTION == DIRECTION_DECREMENTING)\r
+    hwtc_count = HWTC_PERIOD - HWTC_COUNT;\r
+#else\r
+    Junk text to cause compiler error - HWTC_COUNT_DIRECTION is not set correctly!\r
+    Should be DIRECTION_INCREMENTING or DIRECTION_DECREMENTING\r
+#endif\r
+    \r
+    if (last_traceTickCount - uiTraceTickCount - 1 < 0x80000000)\r
+    {\r
+        /* This means last_traceTickCount is higher than uiTraceTickCount,\r
+        so we have previously compensated for a missed tick.\r
+        Therefore we use the last stored value because that is more accurate. */\r
+        traceTickCount = last_traceTickCount;\r
+    }\r
+    else\r
+    {\r
+        /* Business as usual */\r
+        traceTickCount = uiTraceTickCount;\r
+    }\r
+\r
+    /* Check for overflow. May occur if the update of uiTraceTickCount has been \r
+    delayed due to disabled interrupts. */\r
+    if (traceTickCount == last_traceTickCount && hwtc_count < last_hwtc_count)\r
+    {\r
+        /* A trace tick has occurred but not been executed by the kernel, so we compensate manually. */\r
+        traceTickCount++;\r
+    }\r
+    \r
+    /* Check if the return address is OK, then we perform the calculation. */\r
+    if (pTimestamp)\r
+    {\r
+        /* Get timestamp from trace ticks. Scale down the period to avoid unwanted overflows. */\r
+        *pTimestamp = traceTickCount * (HWTC_PERIOD / HWTC_DIVISOR);\r
+        /* Increase timestamp by (hwtc_count + "lost hardware ticks from scaling down period") / HWTC_DIVISOR. */\r
+        *pTimestamp += (hwtc_count + traceTickCount * (HWTC_PERIOD % HWTC_DIVISOR)) / HWTC_DIVISOR;\r
+    }\r
+    \r
+    /* Store the previous values. */\r
+    last_traceTickCount = traceTickCount;\r
+    last_hwtc_count = hwtc_count;\r
+}\r
+\r
+#endif
\ No newline at end of file
index 98b84a8ea2546018e75207d7a90cd3cb993a72fc..ce9b14a84adc6b8bd7f8c30b18de9cdbc6da31e9 100644 (file)
 /*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
+ * Tracealyzer v2.4.1 Recorder Library\r
  * Percepio AB, www.percepio.com\r
  *\r
  * trcKernel.c\r
  *\r
- * Functions for integration of the trace recorder library in the FreeRTOS \r
- * kernel (requires FreeRTOS v7.1.0 or later).\r
- * \r
+ * Functions used by trcKernelHooks.h.\r
+ *\r
  * Terms of Use\r
  * This software is copyright Percepio AB. The recorder library is free for\r
  * use together with Percepio products. You may distribute the recorder library\r
- * in its original form, including modifications in trcPort.c and trcPort.h\r
+ * in its original form, including modifications in trcHardwarePort.c/.h\r
  * given that these modification are clearly marked as your own modifications\r
- * and documented in the initial comment section of these source files. \r
- * This software is the intellectual property of Percepio AB and may not be \r
- * sold or in other ways commercially redistributed without explicit written \r
+ * and documented in the initial comment section of these source files.\r
+ * This software is the intellectual property of Percepio AB and may not be\r
+ * sold or in other ways commercially redistributed without explicit written\r
  * permission by Percepio AB.\r
  *\r
- * Disclaimer \r
- * The trace tool and recorder library is being delivered to you AS IS and \r
- * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
- * not and cannot warrant the performance or results you may obtain by using the \r
- * software or documentation. Percepio AB make no warranties, express or \r
- * implied, as to noninfringement of third party rights, merchantability, or \r
- * fitness for any particular purpose. In no event will Percepio AB, its \r
- * technology partners, or distributors be liable to you for any consequential, \r
- * incidental or special damages, including any lost profits or lost savings, \r
- * even if a representative of Percepio AB has been advised of the possibility \r
- * of such damages, or for any claim by any third party. Some jurisdictions do \r
- * not allow the exclusion or limitation of incidental, consequential or special \r
- * damages, or the exclusion of implied warranties or limitations on how long an \r
+ * Disclaimer\r
+ * The trace tool and recorder library is being delivered to you AS IS and\r
+ * Percepio AB makes no warranty as to its use or performance. Percepio AB does\r
+ * not and cannot warrant the performance or results you may obtain by using the\r
+ * software or documentation. Percepio AB make no warranties, express or\r
+ * implied, as to noninfringement of third party rights, merchantability, or\r
+ * fitness for any particular purpose. In no event will Percepio AB, its\r
+ * technology partners, or distributors be liable to you for any consequential,\r
+ * incidental or special damages, including any lost profits or lost savings,\r
+ * even if a representative of Percepio AB has been advised of the possibility\r
+ * of such damages, or for any claim by any third party. Some jurisdictions do\r
+ * not allow the exclusion or limitation of incidental, consequential or special\r
+ * damages, or the exclusion of implied warranties or limitations on how long an\r
  * implied warranty may last, so the above limitations may not apply to you.\r
  *\r
- * FreeRTOS+Trace is available as Free Edition and in two premium editions.\r
- * You may use the premium features during 30 days for evaluation.\r
- * Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/\r
- *\r
- * Copyright Percepio AB, 2012.\r
+ * Copyright Percepio AB, 2013.\r
  * www.percepio.com\r
  ******************************************************************************/\r
 \r
-#include "trcUser.h"\r
-#include "task.h"\r
+#include "trcKernel.h"\r
 \r
-#if (configUSE_TRACE_FACILITY == 1)\r
+#if (USE_TRACEALYZER_RECORDER == 1)\r
 \r
-\r
-\r
-/******************************************************************************\r
- * TraceObjectClassTable\r
- * Translates a FreeRTOS QueueType into trace objects classes (TRACE_CLASS_).\r
- * This was added since we want to map both types of Mutex and both types of \r
- * Semaphores on common classes for all Mutexes and all Semaphores respectively. \r
- * \r
- * FreeRTOS Queue types\r
- * #define queueQUEUE_TYPE_BASE                  ( 0U ) => TRACE_CLASS_QUEUE\r
- * #define queueQUEUE_TYPE_MUTEX                 ( 1U ) => TRACE_CLASS_MUTEX\r
- * #define queueQUEUE_TYPE_COUNTING_SEMAPHORE    ( 2U ) => TRACE_CLASS_SEMAPHORE\r
- * #define queueQUEUE_TYPE_BINARY_SEMAPHORE      ( 3U ) => TRACE_CLASS_SEMAPHORE\r
- * #define queueQUEUE_TYPE_RECURSIVE_MUTEX       ( 4U ) => TRACE_CLASS_MUTEX \r
- ******************************************************************************/\r
-traceObjectClass TraceObjectClassTable[5]        =  {TRACE_CLASS_QUEUE,     \r
-                                                     TRACE_CLASS_MUTEX,      \r
-                                                     TRACE_CLASS_SEMAPHORE,  \r
-                                                     TRACE_CLASS_SEMAPHORE,\r
-                                                     TRACE_CLASS_MUTEX };\r
-\r
-/* This is defined in FreeRTOS! */\r
-extern volatile void * volatile pxCurrentTCB; \r
+#include <stdint.h>\r
 \r
 /* Internal variables */\r
 uint8_t nISRactive = 0;\r
 objectHandleType handle_of_last_logged_task = 0;\r
 uint8_t inExcludedTask = 0;\r
 \r
-static uint8_t prvTraceIsObjectExcluded(traceObjectClass, uint32_t);\r
-\r
-/*******************************************************************************\r
- * prvTraceIsObjectExcluded\r
- *\r
- * Private function that accepts an object class and an object number and uses\r
- * that to determine if the object has been flagged as excluded.\r
- ******************************************************************************/\r
-static uint8_t prvTraceIsObjectExcluded(traceObjectClass objectClass, uint32_t objectNumber)\r
-{\r
-    switch(objectClass)\r
-    {\r
-    case TRACE_CLASS_QUEUE:\r
-        return GET_QUEUE_FLAG_ISEXCLUDED(objectNumber);\r
-        break;\r
-    case TRACE_CLASS_SEMAPHORE:\r
-        return GET_SEMAPHORE_FLAG_ISEXCLUDED(objectNumber);\r
-        break;\r
-    case TRACE_CLASS_MUTEX:\r
-        return GET_MUTEX_FLAG_ISEXCLUDED(objectNumber);\r
-        break;\r
-    case TRACE_CLASS_TASK:\r
-        return GET_TASK_FLAG_ISEXCLUDED(objectNumber);\r
-        break;\r
-    }\r
-    return 0;\r
-}\r
+static uint32_t prvTraceGetParam(uint32_t, uint32_t);\r
 \r
 #if !defined INCLUDE_READY_EVENTS || INCLUDE_READY_EVENTS == 1\r
 /*******************************************************************************\r
@@ -112,79 +58,91 @@ void vTraceStoreTaskReady(objectHandleType handle)
 {\r
     uint16_t dts3;\r
     TREvent* tr;\r
+       \r
+       TRACE_ASSERT(handle > 0 && handle <= NTask, "vTraceStoreTaskReady: Invalid value for handle", );\r
 \r
-    if (!GET_TASK_FLAG_ISEXCLUDED(handle))\r
+    if (recorder_busy)\r
     {\r
-        dts3 = (uint16_t)prvTraceGetDTS(0xFFFF);\r
-        if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */\r
-        {\r
-            tr = (TREvent*)xTraceNextFreeEventBufferSlot();\r
-\r
-            if (tr != NULL)\r
-            {\r
-                tr->type = TR_TASK_READY;\r
-                tr->dts = dts3;\r
-                tr->objHandle = handle;\r
-\r
-                prvTraceUpdateCounters();    \r
-            }\r
-        }\r
+      /***********************************************************************\r
+      * This should never occur, as the tick- and kernel call ISR is on lowest\r
+      * interrupt priority and always are disabled during the critical sections\r
+      * of the recorder.\r
+      ***********************************************************************/\r
+\r
+      vTraceError("Recorder busy - high priority ISR using syscall? (1)");\r
+      return;\r
     }\r
+\r
+    if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */\r
+       {\r
+               if (!TRACE_GET_TASK_FLAG_ISEXCLUDED(handle))\r
+               {\r
+                       dts3 = (uint16_t)prvTraceGetDTS(0xFFFF);\r
+                       if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */\r
+                       {\r
+                               tr = (TREvent*)xTraceNextFreeEventBufferSlot();\r
+\r
+                               if (tr != NULL)\r
+                               {\r
+                                       tr->type = DIV_TASK_READY;\r
+                                       tr->dts = dts3;\r
+                                       tr->objHandle = handle;\r
+\r
+                                       prvTraceUpdateCounters();\r
+                               }\r
+                       }\r
+               }\r
+       }\r
 }\r
 #endif\r
 \r
 /*******************************************************************************\r
  * vTraceStoreKernelCall\r
  *\r
- * This is the main integration point for storing FreeRTOS kernel calls, and\r
- * is called by the hooks in FreeRTOS.h (see trcKernel.h for event codes).\r
+ * This is the main integration point for storing kernel calls, and\r
+ * is called by the hooks in trcKernelHooks.h (see trcKernelPort.h for event codes).\r
  ******************************************************************************/\r
 void vTraceStoreKernelCall(uint32_t ecode, traceObjectClass objectClass, uint32_t objectNumber)\r
 {\r
     KernelCall * kse;\r
     uint16_t dts1;\r
+       \r
+    TRACE_ASSERT(ecode < 0xFF, "vTraceStoreKernelCall: ecode >= 0xFF", );\r
+    TRACE_ASSERT(objectClass < TRACE_NCLASSES, "vTraceStoreKernelCall: objectClass >= TRACE_NCLASSES", );\r
+    TRACE_ASSERT(objectNumber <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectClass], "vTraceStoreKernelCall: Invalid value for objectNumber", );\r
+\r
+    if (recorder_busy)\r
+    {\r
+        /*************************************************************************\r
+        * This may occur if a high-priority ISR is illegally using a system call,\r
+        * or creates a user event.\r
+        * Only ISRs that are disabled by TRACE_ENTER_CRITICAL_SECTION may use system calls\r
+        * or user events (see TRACE_MAX_SYSCALL_INTERRUPT_PRIORITY).\r
+        *************************************************************************/\r
+\r
+        vTraceError("Recorder busy - high priority ISR using syscall? (2)");\r
+        return;\r
+    }\r
 \r
     if (handle_of_last_logged_task == 0)\r
     {\r
         return;\r
     }\r
-    \r
+\r
     if (RecorderDataPtr->recorderActive)\r
     {\r
-        \r
+\r
         /* If it is an ISR or NOT an excluded task, this kernel call will be stored in the trace */\r
         if (nISRactive || !inExcludedTask)\r
         {\r
-            /* Make sure ISRs never change the IFE flags of tasks */\r
-            if (!nISRactive)\r
-            {\r
-                /* This checks if this is the first kernel call after a call to\r
-                vTraceTaskInstanceIsFinished. In that case, calls to this kernel service \r
-                with this specific kernel object become the "instance finish event"\r
-                (IFE) of the calling task.*/\r
-                if (GET_TASK_FLAG_MARKIFE(handle_of_last_logged_task))\r
-                {\r
-                    /* Reset the flag - this has been handled now */\r
-                    CLEAR_TASK_FLAG_MARKIFE(handle_of_last_logged_task);\r
-\r
-                    /* Store the kernel service tagged as instance finished event */\r
-                    PROPERTY_TASK_IFE_SERVICECODE(handle_of_last_logged_task) = \r
-                      (uint8_t)ecode;                \r
-\r
-                    /* Store the handle of the specific kernel object */\r
-                    PROPERTY_TASK_IFE_OBJHANDLE(handle_of_last_logged_task) =\r
-                      (objectHandleType)objectNumber;    \r
-                }\r
-            }\r
-            \r
             /* Check if the referenced object or the event code is excluded */\r
-            if (!prvTraceIsObjectExcluded(objectClass, objectNumber) && !GET_EVENT_CODE_FLAG_ISEXCLUDED(ecode))\r
+            if (!uiTraceIsObjectExcluded(objectClass, objectNumber) && !TRACE_GET_EVENT_CODE_FLAG_ISEXCLUDED(ecode))\r
             {\r
                 trcCRITICAL_SECTION_BEGIN();\r
                 dts1 = (uint16_t)prvTraceGetDTS(0xFFFF);\r
 \r
                 if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */\r
-                {           \r
+                {\r
                     kse = (KernelCall*) xTraceNextFreeEventBufferSlot();\r
                     if (kse != NULL)\r
                     {\r
@@ -214,17 +172,34 @@ void vTraceStoreKernelCallWithParam(uint32_t evtcode,
     KernelCallWithParamAndHandle * kse;\r
     uint8_t dts2;\r
 \r
-    if (RecorderDataPtr->recorderActive && handle_of_last_logged_task && \r
+       TRACE_ASSERT(evtcode < 0xFF, "vTraceStoreKernelCall: evtcode >= 0xFF", );\r
+       TRACE_ASSERT(objectClass < TRACE_NCLASSES, "vTraceStoreKernelCallWithParam: objectClass >= TRACE_NCLASSES", );\r
+       TRACE_ASSERT(objectNumber <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectClass], "vTraceStoreKernelCallWithParam: Invalid value for objectNumber", );\r
+\r
+    if (RecorderDataPtr->recorderActive && handle_of_last_logged_task &&\r
         (! inExcludedTask || nISRactive))\r
     {\r
+        if (recorder_busy)\r
+        {\r
+            /*************************************************************************\r
+            * This may occur if a high-priority ISR is illegally using a system call,\r
+            * or creates a user event.\r
+            * Only ISRs that are disabled by TRACE_ENTER_CRITICAL_SECTION may use system calls\r
+               * or user events (see TRACE_MAX_SYSCALL_INTERRUPT_PRIORITY).\r
+            *************************************************************************/\r
+\r
+            vTraceError("Recorder busy - high priority ISR using syscall? (3)");\r
+            return;\r
+        }\r
+\r
         /* Check if the referenced object or the event code is excluded */\r
-        if (!prvTraceIsObjectExcluded(objectClass, objectNumber) && !GET_EVENT_CODE_FLAG_ISEXCLUDED(evtcode))\r
+        if (!uiTraceIsObjectExcluded(objectClass, objectNumber) && !TRACE_GET_EVENT_CODE_FLAG_ISEXCLUDED(evtcode))\r
         {\r
             trcCRITICAL_SECTION_BEGIN();\r
             dts2 = (uint8_t)prvTraceGetDTS(0xFF);\r
 \r
             if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */\r
-            {                \r
+            {\r
                 kse = (KernelCallWithParamAndHandle*) xTraceNextFreeEventBufferSlot();\r
                 if (kse != NULL)\r
                 {\r
@@ -232,7 +207,7 @@ void vTraceStoreKernelCallWithParam(uint32_t evtcode,
                     kse->type = (uint8_t)evtcode;\r
                     kse->objHandle = (uint8_t)objectNumber;\r
                     kse->param = param;\r
-                    prvTraceUpdateCounters();    \r
+                    prvTraceUpdateCounters();\r
                 }\r
             }\r
             trcCRITICAL_SECTION_END();\r
@@ -240,6 +215,35 @@ void vTraceStoreKernelCallWithParam(uint32_t evtcode,
     }\r
 }\r
 \r
+/*******************************************************************************\r
+ * prvTraceGetParam\r
+ *\r
+ * Used for storing extra bytes for kernel calls with numeric parameters.\r
+ ******************************************************************************/\r
+static uint32_t prvTraceGetParam(uint32_t param_max, uint32_t param)\r
+{\r
+       XPSEvent* xps;\r
+       \r
+       TRACE_ASSERT(param_max == 0xFF || param_max == 0xFFFF, "prvTraceGetParam: Invalid value for param_max", param);\r
+       \r
+       if (param <= param_max)\r
+       {\r
+               return param;\r
+       }\r
+       else\r
+       {\r
+               xps = (XPSEvent*) xTraceNextFreeEventBufferSlot();\r
+               if (xps != NULL)\r
+               {\r
+                       xps->type = DIV_XPS;\r
+                       xps->xps_8 = (param & (0xFF00 & ~param_max)) >> 8;\r
+                       xps->xps_16 = (param & (0xFFFF0000 & ~param_max)) >> 16;\r
+                       prvTraceUpdateCounters();\r
+               }\r
+\r
+               return param & param_max;\r
+       }\r
+}\r
 \r
 /*******************************************************************************\r
  * vTraceStoreKernelCallWithNumericParamOnly\r
@@ -247,124 +251,117 @@ void vTraceStoreKernelCallWithParam(uint32_t evtcode,
  * Used for storing kernel calls with numeric parameters only. This is\r
  * only used for traceTASK_DELAY and traceDELAY_UNTIL at the moment.\r
  ******************************************************************************/\r
-void vTraceStoreKernelCallWithNumericParamOnly(uint32_t evtcode, uint16_t param)\r
+void vTraceStoreKernelCallWithNumericParamOnly(uint32_t evtcode, uint32_t param)\r
 {\r
     KernelCallWithParam16 * kse;\r
     uint8_t dts6;\r
+       uint16_t restParam = 0;\r
 \r
-    if (RecorderDataPtr->recorderActive && handle_of_last_logged_task \r
+       TRACE_ASSERT(evtcode < 0xFF, "vTraceStoreKernelCallWithNumericParamOnly: Invalid value for evtcode", );\r
+       \r
+    if (RecorderDataPtr->recorderActive && handle_of_last_logged_task\r
         && (! inExcludedTask || nISRactive))\r
     {\r
         /* Check if the event code is excluded */\r
-        if (!GET_EVENT_CODE_FLAG_ISEXCLUDED(evtcode))\r
+        if (!TRACE_GET_EVENT_CODE_FLAG_ISEXCLUDED(evtcode))\r
         {\r
+            if (recorder_busy)\r
+            {\r
+                /*************************************************************************\r
+                * This may occur if a high-priority ISR is illegally using a system call,\r
+                * or creates a user event.\r
+                * Only ISRs that are disabled by TRACE_ENTER_CRITICAL_SECTION may use system calls\r
+                * or user events (see TRACE_MAX_SYSCALL_INTERRUPT_PRIORITY).\r
+                *************************************************************************/\r
+\r
+                vTraceError("Recorder busy - high priority ISR using syscall? (4)");\r
+                return;\r
+            }\r
+\r
             trcCRITICAL_SECTION_BEGIN();\r
             dts6 = (uint8_t)prvTraceGetDTS(0xFF);\r
 \r
             if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */\r
-            {                \r
-                kse = (KernelCallWithParam16*) xTraceNextFreeEventBufferSlot();\r
-                if (kse != NULL)\r
-                {\r
-                    kse->dts = dts6;\r
-                    kse->type = (uint8_t)evtcode;\r
-                    kse->param = param;\r
-                    prvTraceUpdateCounters();    \r
-                }\r
+            {\r
+                               restParam = (uint16_t)prvTraceGetParam(0xFFFF, param);\r
+\r
+                               if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */\r
+                               {\r
+                                       kse = (KernelCallWithParam16*) xTraceNextFreeEventBufferSlot();\r
+                                       if (kse != NULL)\r
+                                       {\r
+                                               kse->dts = dts6;\r
+                                               kse->type = (uint8_t)evtcode;\r
+                                               kse->param = restParam;\r
+                                               prvTraceUpdateCounters();\r
+                                       }\r
+                               }\r
             }\r
             trcCRITICAL_SECTION_END();\r
         }\r
     }\r
 }\r
 \r
-objectHandleType handle_of_running_task = 0;\r
-\r
 /*******************************************************************************\r
  * vTraceStoreTaskswitch\r
  * Called by the scheduler from the SWITCHED_OUT hook, and by uiTraceStart.\r
  * At this point interrupts are assumed to be disabled!\r
  ******************************************************************************/\r
-void vTraceStoreTaskswitch(void)\r
+void vTraceStoreTaskswitch(objectHandleType task_handle)\r
 {\r
     uint16_t dts3;\r
-    TSEvent* ts;        \r
+    TSEvent* ts;\r
     int8_t skipEvent = 0;\r
-    uint32_t schedulerState = 0;\r
-    \r
-    /*************************************************************************** \r
-    This is used to detect if a high-priority ISRs is illegally using the \r
-    recorder ISR trace functions (vTraceStoreISRBegin and ...End) while the \r
+\r
+       TRACE_ASSERT(task_handle <= NTask, "vTraceStoreTaskswitch: Invalid value for task_handle", );\r
+       \r
+    /***************************************************************************\r
+    This is used to detect if a high-priority ISRs is illegally using the\r
+    recorder ISR trace functions (vTraceStoreISRBegin and ...End) while the\r
     recorder is busy with a task-level event or lower priority ISR event.\r
-    \r
-    If this is detected, it triggers a call to vTraceError with the error \r
+\r
+    If this is detected, it triggers a call to vTraceError with the error\r
     "Illegal call to vTraceStoreISRBegin/End". If you get this error, it means\r
-    that the macro taskENTER_CRITICAL does not disable this ISR, as required.\r
-    You can solve this by adjusting the value of the FreeRTOS constant\r
-    configMAX_SYSCALL_INTERRUPT_PRIORITY, which is defined in FreeRTOSConfig.h\r
+    that the macro trcCRITICAL_SECTION_BEGIN does not disable this ISR, as required.\r
 \r
     Note: Setting recorder_busy is normally handled in our macros\r
-    trcCRITICAL_SECTION_BEGIN and _END, but is needed explicitly in this \r
-    function since critical sections should not be used in the context switch \r
-    event...)    \r
+    trcCRITICAL_SECTION_BEGIN and _END, but is needed explicitly in this\r
+    function since critical sections should not be used in the context switch\r
+    event...)\r
     ***************************************************************************/\r
-    recorder_busy++; \r
-    \r
-    schedulerState = xTaskGetSchedulerState();\r
-\r
-    if (schedulerState == 0)\r
-    {\r
-        /* This occurs on the very first taskswitch event, generated by \r
-        vTraceStart and uiTraceStart if the scheduler is not yet started.\r
-        This creates a dummy "(startup)" task entry internally in the\r
-        recorder */\r
-        if (handle_of_running_task == 0)\r
-        {\r
-            handle_of_running_task = xTraceGetObjectHandle(TRACE_CLASS_TASK);\r
-\r
-            vTraceSetObjectName(TRACE_CLASS_TASK, \r
-                handle_of_running_task,\r
-                "(startup)");\r
+    recorder_busy++;\r
 \r
-            vTraceSetPriorityProperty(TRACE_CLASS_TASK,\r
-                handle_of_running_task,\r
-                0);\r
-        }        \r
-    }\r
-    else\r
-    {    \r
-        handle_of_running_task = \r
-        (objectHandleType)uxTaskGetTaskNumber(xTaskGetCurrentTaskHandle());\r
-    }\r
-    \r
     /* Skip the event if the task has been excluded, using vTraceExcludeTask */\r
-    if (GET_TASK_FLAG_ISEXCLUDED(handle_of_running_task))\r
-    {    \r
+    if (TRACE_GET_TASK_FLAG_ISEXCLUDED(task_handle))\r
+    {\r
         skipEvent = 1;\r
-        inExcludedTask = 1;            \r
+        inExcludedTask = 1;\r
     }\r
     else\r
+       {\r
         inExcludedTask = 0;\r
-        \r
+       }\r
 \r
-    /* Skip the event if the same task is scheduled */\r
-    if (handle_of_running_task == handle_of_last_logged_task)\r
-    {\r
-        skipEvent = 1;\r
-    }\r
-  \r
-    if (! RecorderDataPtr->recorderActive)\r
+       /* Skip the event if the same task is scheduled */\r
+       if (task_handle == handle_of_last_logged_task)\r
+       {\r
+               skipEvent = 1;\r
+       }\r
+\r
+\r
+    if (!RecorderDataPtr->recorderActive)\r
     {\r
         skipEvent = 1;\r
     }\r
 \r
     /* If this event should be logged, log it! */\r
-    if (skipEvent == 0)    \r
-    {    \r
+    if (skipEvent == 0)\r
+    {\r
         dts3 = (uint16_t)prvTraceGetDTS(0xFFFF);\r
-        \r
+\r
         if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */\r
         {\r
-            handle_of_last_logged_task = handle_of_running_task;            \r
+            handle_of_last_logged_task = task_handle;\r
             ts = (TSEvent*)xTraceNextFreeEventBufferSlot();\r
 \r
             if (ts != NULL)\r
@@ -382,17 +379,17 @@ void vTraceStoreTaskswitch(void)
                 ts->dts = dts3;\r
                 ts->objHandle = handle_of_last_logged_task;\r
 \r
-                vTraceSetObjectState(TRACE_CLASS_TASK, \r
-                                     handle_of_last_logged_task, \r
+                vTraceSetObjectState(TRACE_CLASS_TASK,\r
+                                     handle_of_last_logged_task,\r
                                      TASK_STATE_INSTANCE_ACTIVE);\r
 \r
-                prvTraceUpdateCounters();    \r
+                prvTraceUpdateCounters();\r
             }\r
         }\r
-    }    \r
+    }\r
 \r
     /* See comment on recorder_busy++ above. */\r
-    recorder_busy--; \r
+    recorder_busy--;\r
 }\r
 \r
 /*******************************************************************************\r
@@ -404,88 +401,102 @@ void vTraceStoreTaskswitch(void)
  * "old" one, valid up until this point.\r
  ******************************************************************************/\r
 #if (INCLUDE_OBJECT_DELETE == 1)\r
-void vTraceStoreObjectNameOnCloseEvent(objectHandleType handle, \r
+void vTraceStoreObjectNameOnCloseEvent(objectHandleType handle,\r
                                        traceObjectClass objectclass)\r
-{    \r
+{\r
     ObjCloseNameEvent * ce;\r
     const char * name;\r
     traceLabel idx;\r
 \r
-    name = PROPERTY_NAME_GET(objectclass, handle);\r
+       TRACE_ASSERT(objectclass < TRACE_NCLASSES, "vTraceStoreObjectNameOnCloseEvent: objectclass >= TRACE_NCLASSES", );\r
+       TRACE_ASSERT(handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], "vTraceStoreObjectNameOnCloseEvent: Invalid value for handle", );\r
 \r
-    idx = prvTraceOpenSymbol(name, 0);\r
-    \r
-    // Interrupt disable not necessary, already done in trcHooks.h macro\r
-    ce = (ObjCloseNameEvent*) xTraceNextFreeEventBufferSlot(); \r
-    if (ce != NULL)\r
-    {\r
-        ce->type = EVENTGROUP_OBJCLOSE_NAME + objectclass;\r
-        ce->objHandle = handle;\r
-        ce->symbolIndex = idx;\r
-        prvTraceUpdateCounters();\r
-    }\r
-    \r
+    if (RecorderDataPtr->recorderActive)\r
+       {\r
+               name = TRACE_PROPERTY_NAME_GET(objectclass, handle);\r
+\r
+               idx = prvTraceOpenSymbol(name, 0);\r
+\r
+               // Interrupt disable not necessary, already done in trcHooks.h macro\r
+               ce = (ObjCloseNameEvent*) xTraceNextFreeEventBufferSlot();\r
+               if (ce != NULL)\r
+               {\r
+                       ce->type = EVENTGROUP_OBJCLOSE_NAME + objectclass;\r
+                       ce->objHandle = handle;\r
+                       ce->symbolIndex = idx;\r
+                       prvTraceUpdateCounters();\r
+               }\r
+       }\r
 }\r
 \r
-void vTraceStoreObjectPropertiesOnCloseEvent(objectHandleType handle, \r
+void vTraceStoreObjectPropertiesOnCloseEvent(objectHandleType handle,\r
                                              traceObjectClass objectclass)\r
 {\r
     ObjClosePropEvent * pe;\r
+       \r
+    TRACE_ASSERT(objectclass < TRACE_NCLASSES, "vTraceStoreObjectPropertiesOnCloseEvent: objectclass >= TRACE_NCLASSES", );\r
+    TRACE_ASSERT(handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], "vTraceStoreObjectPropertiesOnCloseEvent: Invalid value for handle", );\r
 \r
-    if (objectclass == TRACE_CLASS_ISR)\r
-    {        \r
-        /* ISR handles should not be closed - never called for ISR */\r
-        return;\r
-    }\r
-\r
-    // Interrupt disable not necessary, already done in trcHooks.h macro\r
-    pe = (ObjClosePropEvent*) xTraceNextFreeEventBufferSlot();\r
-    if (pe != NULL)\r
-    {\r
-        if (objectclass == TRACE_CLASS_TASK)\r
-        {\r
-            pe->arg1 = PROPERTY_ACTOR_PRIORITY(objectclass, handle);\r
-            pe->arg2 = PROPERTY_TASK_IFE_SERVICECODE(handle);\r
-            pe->arg3 = PROPERTY_TASK_IFE_OBJHANDLE(handle);\r
-            PROPERTY_TASK_IFE_SERVICECODE(handle) = 0;\r
-            PROPERTY_TASK_IFE_OBJHANDLE(handle) = 0;\r
-        }else{\r
-            pe->arg1 = PROPERTY_OBJECT_STATE(objectclass, handle);\r
-        }\r
-        pe->type = EVENTGROUP_OBJCLOSE_PROP + objectclass;    \r
-        prvTraceUpdateCounters();\r
-    }\r
+    if (RecorderDataPtr->recorderActive)\r
+       {\r
+               // Interrupt disable not necessary, already done in trcHooks.h macro\r
+               pe = (ObjClosePropEvent*) xTraceNextFreeEventBufferSlot();\r
+               if (pe != NULL)\r
+               {\r
+                       if (objectclass == TRACE_CLASS_TASK)\r
+                       {\r
+                               pe->arg1 = TRACE_PROPERTY_ACTOR_PRIORITY(objectclass, handle);\r
+                               pe->arg2 = 0; // Legacy - IFE info removed.\r
+                               pe->arg3 = 0; // Legacy - IFE info removed.\r
+                       }else{\r
+                               pe->arg1 = TRACE_PROPERTY_OBJECT_STATE(objectclass, handle);\r
+                       }\r
+                       pe->type = EVENTGROUP_OBJCLOSE_PROP + objectclass;\r
+                       prvTraceUpdateCounters();\r
+               }\r
+       }\r
 }\r
 #endif\r
 \r
 void vTraceSetPriorityProperty(uint8_t objectclass, uint8_t id, uint8_t value)\r
 {\r
-    PROPERTY_ACTOR_PRIORITY(objectclass, id) = value;\r
+       TRACE_ASSERT(objectclass < TRACE_NCLASSES, "vTraceSetPriorityProperty: objectclass >= TRACE_NCLASSES", );\r
+       TRACE_ASSERT(id <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], "vTraceSetPriorityProperty: Invalid value for id", );\r
+\r
+    TRACE_PROPERTY_ACTOR_PRIORITY(objectclass, id) = value;\r
 }\r
 \r
 uint8_t uiTraceGetPriorityProperty(uint8_t objectclass, uint8_t id)\r
 {\r
-    return PROPERTY_ACTOR_PRIORITY(objectclass, id);\r
+       TRACE_ASSERT(objectclass < TRACE_NCLASSES, "uiTraceGetPriorityProperty: objectclass >= TRACE_NCLASSES", 0);\r
+       TRACE_ASSERT(id <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], "uiTraceGetPriorityProperty: Invalid value for id", 0);\r
+\r
+    return TRACE_PROPERTY_ACTOR_PRIORITY(objectclass, id);\r
 }\r
 \r
 void vTraceSetObjectState(uint8_t objectclass, uint8_t id, uint8_t value)\r
 {\r
-    PROPERTY_OBJECT_STATE(objectclass, id) = value;\r
+       TRACE_ASSERT(objectclass < TRACE_NCLASSES, "vTraceSetObjectState: objectclass >= TRACE_NCLASSES", );\r
+       TRACE_ASSERT(id <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], "vTraceSetObjectState: Invalid value for id", );\r
+       \r
+    TRACE_PROPERTY_OBJECT_STATE(objectclass, id) = value;\r
 }\r
 \r
-void vTraceSetTaskInstanceFinished(objectHandleType handle)\r
+uint8_t uiTraceGetObjectState(uint8_t objectclass, uint8_t id)\r
 {\r
-#if (USE_IMPLICIT_IFE_RULES == 1)\r
-    if (PROPERTY_TASK_IFE_SERVICECODE(handle) == 0)\r
-    {\r
-        PROPERTY_OBJECT_STATE(TRACE_CLASS_TASK, handle) = 0;\r
-    }\r
-#endif\r
+       TRACE_ASSERT(objectclass < TRACE_NCLASSES, "uiTraceGetObjectState: objectclass >= TRACE_NCLASSES", 0);\r
+       TRACE_ASSERT(id <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], "uiTraceGetObjectState: Invalid value for id", 0);\r
+       \r
+    return TRACE_PROPERTY_OBJECT_STATE(objectclass, id);\r
 }\r
 \r
-uint8_t uiTraceGetObjectState(uint8_t objectclass, uint8_t id)\r
+void vTraceSetTaskInstanceFinished(objectHandleType handle)\r
 {\r
-    return PROPERTY_OBJECT_STATE(objectclass, id);\r
+       TRACE_ASSERT(handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[TRACE_CLASS_TASK], "vTraceSetTaskInstanceFinished: Invalid value for handle", );\r
+       \r
+#if (USE_IMPLICIT_IFE_RULES == 1)\r
+    TRACE_PROPERTY_OBJECT_STATE(TRACE_CLASS_TASK, handle) = 0;    \r
+#endif\r
 }\r
 \r
-#endif\r
+#endif
\ No newline at end of file
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c
new file mode 100644 (file)
index 0000000..427d770
--- /dev/null
@@ -0,0 +1,191 @@
+/*******************************************************************************\r
+ * Tracealyzer v2.4.1 Recorder Library\r
+ * Percepio AB, www.percepio.com\r
+ *\r
+ * trcKernelPort.c\r
+ *\r
+ * Kernel-specific functionality for FreeRTOS, used by the recorder library.\r
+ * \r
+ * Terms of Use\r
+ * This software is copyright Percepio AB. The recorder library is free for\r
+ * use together with Percepio products. You may distribute the recorder library\r
+ * in its original form, including modifications in trcHardwarePort.c/.h\r
+ * given that these modification are clearly marked as your own modifications\r
+ * and documented in the initial comment section of these source files. \r
+ * This software is the intellectual property of Percepio AB and may not be \r
+ * sold or in other ways commercially redistributed without explicit written \r
+ * permission by Percepio AB.\r
+ *\r
+ * Disclaimer \r
+ * The trace tool and recorder library is being delivered to you AS IS and \r
+ * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
+ * not and cannot warrant the performance or results you may obtain by using the \r
+ * software or documentation. Percepio AB make no warranties, express or \r
+ * implied, as to noninfringement of third party rights, merchantability, or \r
+ * fitness for any particular purpose. In no event will Percepio AB, its \r
+ * technology partners, or distributors be liable to you for any consequential, \r
+ * incidental or special damages, including any lost profits or lost savings, \r
+ * even if a representative of Percepio AB has been advised of the possibility \r
+ * of such damages, or for any claim by any third party. Some jurisdictions do \r
+ * not allow the exclusion or limitation of incidental, consequential or special \r
+ * damages, or the exclusion of implied warranties or limitations on how long an \r
+ * implied warranty may last, so the above limitations may not apply to you.\r
+ *\r
+ * Copyright Percepio AB, 2013.\r
+ * www.percepio.com\r
+ ******************************************************************************/\r
+\r
+#include "trcKernelPort.h"\r
+\r
+#if (USE_TRACEALYZER_RECORDER == 1)\r
+\r
+#include <stdint.h>\r
+\r
+#include "task.h"\r
+\r
+traceObjectClass TraceObjectClassTable[5] = {\r
+       TRACE_CLASS_QUEUE,\r
+       TRACE_CLASS_MUTEX,\r
+       TRACE_CLASS_SEMAPHORE,\r
+       TRACE_CLASS_SEMAPHORE,\r
+       TRACE_CLASS_MUTEX\r
+};\r
+\r
+extern unsigned char ucQueueGetQueueType(void*);\r
+extern unsigned char ucQueueGetQueueNumber(void*);\r
+\r
+objectHandleType prvTraceGetObjectNumber(void* handle)\r
+{\r
+       return ucQueueGetQueueNumber(handle);   \r
+}\r
+\r
+unsigned char prvTraceGetObjectType(void* handle)\r
+{\r
+       return ucQueueGetQueueType(handle);\r
+}\r
+\r
+objectHandleType prvTraceGetTaskNumber(void* handle)\r
+{\r
+       return (objectHandleType)uxTaskGetTaskNumber(handle);\r
+}\r
+\r
+void prvTraceEnterCritical()\r
+{\r
+       taskENTER_CRITICAL();\r
+}\r
+\r
+void prvTraceExitCritical()\r
+{\r
+       taskEXIT_CRITICAL();\r
+}\r
+\r
+unsigned char prvTraceIsSchedulerActive()\r
+{\r
+       return xTaskGetSchedulerState() == taskSCHEDULER_RUNNING;\r
+}\r
+\r
+unsigned char prvTraceIsSchedulerSuspended()\r
+{\r
+       return xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED;\r
+}\r
+\r
+unsigned char prvTraceIsSchedulerStarted()\r
+{\r
+       return xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED;\r
+}\r
+\r
+void* prvTraceGetCurrentTaskHandle()\r
+{\r
+       return xTaskGetCurrentTaskHandle();\r
+}\r
+\r
+/* Initialization of the object property table */\r
+void vTraceInitObjectPropertyTable()\r
+{\r
+       RecorderDataPtr->ObjectPropertyTable.NumberOfObjectClasses = TRACE_NCLASSES;\r
+       RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[0] = NQueue;\r
+       RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[1] = NSemaphore;\r
+       RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[2] = NMutex;\r
+       RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[3] = NTask;\r
+       RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[4] = NISR;\r
+       RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[0] = NameLenQueue;\r
+       RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[1] = NameLenSemaphore;\r
+       RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[2] = NameLenMutex;\r
+       RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[3] = NameLenTask;\r
+       RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[4] = NameLenISR;\r
+       RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[0] = PropertyTableSizeQueue;\r
+       RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[1] = PropertyTableSizeSemaphore;\r
+       RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[2] = PropertyTableSizeMutex;\r
+       RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[3] = PropertyTableSizeTask;\r
+       RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[4] = PropertyTableSizeISR;\r
+       RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[0] = StartIndexQueue;\r
+       RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[1] = StartIndexSemaphore;\r
+       RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[2] = StartIndexMutex;\r
+       RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[3] = StartIndexTask;\r
+       RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[4] = StartIndexISR;\r
+       RecorderDataPtr->ObjectPropertyTable.ObjectPropertyTableSizeInBytes = TRACE_OBJECT_TABLE_SIZE;\r
+}\r
+\r
+/* Initialization of the handle mechanism, see e.g, xTraceGetObjectHandle */\r
+void vTraceInitObjectHandleStack()\r
+{\r
+       objectHandleStacks.indexOfNextAvailableHandle[0] = 0;\r
+       objectHandleStacks.indexOfNextAvailableHandle[1] = NQueue;\r
+       objectHandleStacks.indexOfNextAvailableHandle[2] = NQueue + NSemaphore;\r
+       objectHandleStacks.indexOfNextAvailableHandle[3] = NQueue + NSemaphore + NMutex;\r
+       objectHandleStacks.indexOfNextAvailableHandle[4] = NQueue + NSemaphore + NMutex + NTask;\r
+       objectHandleStacks.lowestIndexOfClass[0] = 0;\r
+       objectHandleStacks.lowestIndexOfClass[1] = NQueue;\r
+       objectHandleStacks.lowestIndexOfClass[2] = NQueue + NSemaphore;\r
+       objectHandleStacks.lowestIndexOfClass[3] = NQueue + NSemaphore + NMutex;\r
+       objectHandleStacks.lowestIndexOfClass[4] = NQueue + NSemaphore + NMutex + NTask;\r
+    objectHandleStacks.highestIndexOfClass[0] = NQueue - 1;\r
+       objectHandleStacks.highestIndexOfClass[1] = NQueue + NSemaphore - 1;\r
+       objectHandleStacks.highestIndexOfClass[2] = NQueue + NSemaphore + NMutex - 1;\r
+       objectHandleStacks.highestIndexOfClass[3] = NQueue + NSemaphore + NMutex + NTask - 1;\r
+       objectHandleStacks.highestIndexOfClass[4] = NQueue + NSemaphore + NMutex + NTask + NISR - 1;\r
+}\r
+       \r
+/* Returns the "Not enough handles" error message for this object class */\r
+const char* pszTraceGetErrorNotEnoughHandles(traceObjectClass objectclass)\r
+{\r
+       switch(objectclass)\r
+       {\r
+       case TRACE_CLASS_TASK:\r
+               return "Not enough TASK handles - increase NTask in trcConfig.h";\r
+       case TRACE_CLASS_ISR:\r
+               return "Not enough ISR handles - increase NISR in trcConfig.h";\r
+       case TRACE_CLASS_SEMAPHORE:\r
+               return "Not enough SEMAPHORE handles - increase NSemaphore in trcConfig.h";\r
+       case TRACE_CLASS_MUTEX:\r
+               return "Not enough MUTEX handles - increase NMutex in trcConfig.h";\r
+       case TRACE_CLASS_QUEUE:\r
+               return "Not enough QUEUE handles - increase NQueue in trcConfig.h";\r
+       default:\r
+               return "pszTraceGetErrorHandles: Invalid objectclass!";\r
+       }\r
+}\r
+\r
+/* Returns the exclude state of the object */\r
+uint8_t uiTraceIsObjectExcluded(traceObjectClass objectclass, objectHandleType handle)\r
+{\r
+       TRACE_ASSERT(objectclass < TRACE_NCLASSES, "prvTraceIsObjectExcluded: objectclass >= TRACE_NCLASSES", 1);\r
+       TRACE_ASSERT(handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], "uiTraceIsObjectExcluded: Invalid value for handle", 1);\r
+       \r
+       switch(objectclass)\r
+       {\r
+       case TRACE_CLASS_TASK:\r
+               return TRACE_GET_TASK_FLAG_ISEXCLUDED(handle);\r
+       case TRACE_CLASS_SEMAPHORE:\r
+               return TRACE_GET_SEMAPHORE_FLAG_ISEXCLUDED(handle);\r
+       case TRACE_CLASS_MUTEX:\r
+               return TRACE_GET_MUTEX_FLAG_ISEXCLUDED(handle);\r
+       case TRACE_CLASS_QUEUE:\r
+               return TRACE_GET_QUEUE_FLAG_ISEXCLUDED(handle);\r
+       }\r
+       \r
+       /* Must never reach */\r
+       return 1;\r
+}\r
+\r
+#endif
\ No newline at end of file
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.h
new file mode 100644 (file)
index 0000000..25de1e7
--- /dev/null
@@ -0,0 +1,749 @@
+/*******************************************************************************\r
+ * Tracealyzer v2.4.1 Recorder Library\r
+ * Percepio AB, www.percepio.com\r
+ *\r
+ * trcKernelPort.h\r
+ *\r
+ * Kernel-specific functionality for FreeRTOS, used by the recorder library.\r
+ * \r
+ * Terms of Use\r
+ * This software is copyright Percepio AB. The recorder library is free for\r
+ * use together with Percepio products. You may distribute the recorder library\r
+ * in its original form, including modifications in trcHardwarePort.c/.h\r
+ * given that these modification are clearly marked as your own modifications\r
+ * and documented in the initial comment section of these source files. \r
+ * This software is the intellectual property of Percepio AB and may not be \r
+ * sold or in other ways commercially redistributed without explicit written \r
+ * permission by Percepio AB.\r
+ *\r
+ * Disclaimer \r
+ * The trace tool and recorder library is being delivered to you AS IS and \r
+ * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
+ * not and cannot warrant the performance or results you may obtain by using the \r
+ * software or documentation. Percepio AB make no warranties, express or \r
+ * implied, as to noninfringement of third party rights, merchantability, or \r
+ * fitness for any particular purpose. In no event will Percepio AB, its \r
+ * technology partners, or distributors be liable to you for any consequential, \r
+ * incidental or special damages, including any lost profits or lost savings, \r
+ * even if a representative of Percepio AB has been advised of the possibility \r
+ * of such damages, or for any claim by any third party. Some jurisdictions do \r
+ * not allow the exclusion or limitation of incidental, consequential or special \r
+ * damages, or the exclusion of implied warranties or limitations on how long an \r
+ * implied warranty may last, so the above limitations may not apply to you.\r
+ *\r
+ * Copyright Percepio AB, 2013.\r
+ * www.percepio.com\r
+ ******************************************************************************/\r
+\r
+\r
+#ifndef TRCKERNELPORT_H_\r
+#define TRCKERNELPORT_H_\r
+\r
+#include "FreeRTOS.h"  // Defines configUSE_TRACE_FACILITY\r
+\r
+#define USE_TRACEALYZER_RECORDER configUSE_TRACE_FACILITY\r
+\r
+#if (USE_TRACEALYZER_RECORDER == 1)\r
+\r
+/* Defines that must be set for the recorder to work properly */\r
+#define TRACE_KERNEL_VERSION 0x1AA1\r
+#define TRACE_CPU_CLOCK_HZ configCPU_CLOCK_HZ /* Defined in "FreeRTOS.h" */\r
+#define TRACE_PERIPHERAL_CLOCK_HZ configPERIPHERAL_CLOCK_HZ /* Defined in "FreeRTOS.h" */\r
+#define TRACE_TICK_RATE_HZ configTICK_RATE_HZ /* Defined in "FreeRTOS.h" */\r
+#define TRACE_CPU_CLOCKS_PER_TICK configCPU_CLOCKS_PER_TICK /* Defined in "FreeRTOS.h" */\r
+\r
+/************************************************************************/\r
+/* KERNEL SPECIFIC OBJECT CONFIGURATION                                 */\r
+/************************************************************************/\r
+#define TRACE_NCLASSES 5\r
+#define TRACE_CLASS_QUEUE ((traceObjectClass)0)\r
+#define TRACE_CLASS_SEMAPHORE ((traceObjectClass)1)\r
+#define TRACE_CLASS_MUTEX ((traceObjectClass)2)\r
+#define TRACE_CLASS_TASK ((traceObjectClass)3)\r
+#define TRACE_CLASS_ISR ((traceObjectClass)4)\r
+\r
+#define TRACE_KERNEL_OBJECT_COUNT (NQueue + NSemaphore + NMutex + NTask + NISR)\r
+\r
+/* The size of the Object Property Table entries, in bytes, per object */\r
+\r
+/* Queue properties (except name):     current number of message in queue */\r
+#define PropertyTableSizeQueue         (NameLenQueue + 1)      \r
+\r
+/* Semaphore properties (except name): state (signaled = 1, cleared = 0) */\r
+#define PropertyTableSizeSemaphore     (NameLenSemaphore + 1) \r
+\r
+/* Mutex properties (except name):     owner (task handle, 0 = free) */\r
+#define PropertyTableSizeMutex         (NameLenMutex + 1)         \r
+\r
+/* Task properties (except name):      Byte 0: Current priority\r
+                                       Byte 1: state (if already active) \r
+                                       Byte 2: legacy, not used\r
+                                       Byte 3: legacy, not used */\r
+#define PropertyTableSizeTask         (NameLenTask + 4)\r
+\r
+/* ISR properties:                     Byte 0: priority\r
+                                       Byte 1: state (if already active) */\r
+#define PropertyTableSizeISR          (NameLenISR + 2)\r
+\r
+/* The layout of the byte array representing the Object Property Table */\r
+#define StartIndexQueue            0\r
+#define StartIndexSemaphore        StartIndexQueue     + NQueue * PropertyTableSizeQueue\r
+#define StartIndexMutex            StartIndexSemaphore + NSemaphore * PropertyTableSizeSemaphore\r
+#define StartIndexTask             StartIndexMutex     + NMutex * PropertyTableSizeMutex\r
+#define StartIndexISR              StartIndexTask      + NTask * PropertyTableSizeTask\r
+\r
+/* Number of bytes used by the object table */\r
+#define TRACE_OBJECT_TABLE_SIZE    StartIndexISR       + NISR * PropertyTableSizeISR\r
+\r
+\r
+/* Includes */\r
+#include "trcTypes.h"\r
+#include "trcConfig.h"\r
+#include "trcKernelHooks.h"\r
+#include "trcHardwarePort.h"\r
+#include "trcBase.h"\r
+#include "trcKernel.h"\r
+#include "trcUser.h"\r
+\r
+/* Initialization of the object property table */\r
+void vTraceInitObjectPropertyTable(void);\r
+\r
+/* Initialization of the handle mechanism, see e.g, xTraceGetObjectHandle */\r
+void vTraceInitObjectHandleStack(void);\r
+\r
+/* Returns the "Not enough handles" error message for the specified object class */\r
+const char* pszTraceGetErrorNotEnoughHandles(traceObjectClass objectclass);\r
+\r
+/*******************************************************************************\r
+ * The event codes - should match the offline config file.\r
+ * \r
+ * Some sections below are encoded to allow for constructions like:\r
+ *\r
+ *  vTraceStoreKernelCall(EVENTGROUP_CREATE + objectclass, ...\r
+ *\r
+ * The object class ID is given by the three LSB bits, in such cases. Since each \r
+ * object class has a separate object property table, the class ID is needed to \r
+ * know what section in the object table to use for getting an object name from\r
+ * an object handle. \r
+ ******************************************************************************/\r
+\r
+#define NULL_EVENT                   (0x00)  /* Ignored in the analysis*/\r
+\r
+/*******************************************************************************\r
+ * EVENTGROUP_DIV\r
+ *\r
+ * Miscellaneous events.\r
+ ******************************************************************************/\r
+#define EVENTGROUP_DIV               (NULL_EVENT + 1)                   /*0x01*/\r
+#define DIV_XPS                      (EVENTGROUP_DIV + 0)               /*0x01*/\r
+#define DIV_TASK_READY               (EVENTGROUP_DIV + 1)               /*0x02*/\r
+#define DIV_NEW_TIME                 (EVENTGROUP_DIV + 2)               /*0x03*/\r
+\r
+/*******************************************************************************\r
+ * EVENTGROUP_TS\r
+ *\r
+ * Events for storing task-switches and interrupts. The RESUME events are \r
+ * generated if the task/interrupt is already marked active.\r
+ ******************************************************************************/\r
+#define EVENTGROUP_TS                (EVENTGROUP_DIV + 3)               /*0x04*/\r
+#define TS_ISR_BEGIN                 (EVENTGROUP_TS + 0)                /*0x04*/\r
+#define TS_ISR_RESUME                (EVENTGROUP_TS + 1)                /*0x05*/\r
+#define TS_TASK_BEGIN                (EVENTGROUP_TS + 2)                /*0x06*/\r
+#define TS_TASK_RESUME               (EVENTGROUP_TS + 3)                /*0x07*/\r
+\r
+/*******************************************************************************\r
+ * EVENTGROUP_OBJCLOSE_NAME\r
+ * \r
+ * About Close Events\r
+ * When an object is evicted from the object property table (object close), two \r
+ * internal events are stored (EVENTGROUP_OBJCLOSE_NAME and \r
+ * EVENTGROUP_OBJCLOSE_PROP), containing the handle-name mapping and object \r
+ * properties valid up to this point.\r
+ ******************************************************************************/\r
+#define EVENTGROUP_OBJCLOSE_NAME     (EVENTGROUP_TS + 4)                /*0x08*/\r
+\r
+/*******************************************************************************\r
+ * EVENTGROUP_OBJCLOSE_PROP\r
+ * \r
+ * The internal event carrying properties of deleted objects\r
+ * The handle and object class of the closed object is not stored in this event, \r
+ * but is assumed to be the same as in the preceding CLOSE event. Thus, these \r
+ * two events must be generated from within a critical section. \r
+ * When queues are closed, arg1 is the "state" property (i.e., number of \r
+ * buffered messages/signals).\r
+ * When actors are closed, arg1 is priority, arg2 is handle of the "instance \r
+ * finish" event, and arg3 is event code of the "instance finish" event. \r
+ * In this case, the lower three bits is the object class of the instance finish \r
+ * handle. The lower three bits are not used (always zero) when queues are \r
+ * closed since the queue type is given in the previous OBJCLOSE_NAME event.\r
+ ******************************************************************************/\r
+#define EVENTGROUP_OBJCLOSE_PROP     (EVENTGROUP_OBJCLOSE_NAME + 8)     /*0x10*/\r
+\r
+/*******************************************************************************\r
+ * EVENTGROUP_CREATE\r
+ * \r
+ * The events in this group are used to log Kernel object creations.\r
+ * The lower three bits in the event code gives the object class, i.e., type of\r
+ * create operation (task, queue, semaphore, etc).\r
+ ******************************************************************************/\r
+#define EVENTGROUP_CREATE_SUCCESS    (EVENTGROUP_OBJCLOSE_PROP + 8)             /*0x18*/\r
+\r
+/*******************************************************************************\r
+ * EVENTGROUP_SEND\r
+ * \r
+ * The events in this group are used to log Send/Give events on queues, \r
+ * semaphores and mutexes The lower three bits in the event code gives the \r
+ * object class, i.e., what type of object that is operated on (queue, semaphore \r
+ * or mutex).\r
+ ******************************************************************************/\r
+#define EVENTGROUP_SEND_SUCCESS      (EVENTGROUP_CREATE_SUCCESS + 8)                    /*0x20*/\r
+\r
+/*******************************************************************************\r
+ * EVENTGROUP_RECEIVE\r
+ * \r
+ * The events in this group are used to log Receive/Take events on queues, \r
+ * semaphores and mutexes. The lower three bits in the event code gives the \r
+ * object class, i.e., what type of object that is operated on (queue, semaphore\r
+ * or mutex).\r
+ ******************************************************************************/\r
+#define EVENTGROUP_RECEIVE_SUCCESS                       (EVENTGROUP_SEND_SUCCESS + 8)  /*0x28*/\r
+\r
+/* Send/Give operations, from ISR */\r
+#define EVENTGROUP_SEND_FROM_ISR_SUCCESS              (EVENTGROUP_RECEIVE_SUCCESS + 8)  /*0x30*/\r
+\r
+/* Receive/Take operations, from ISR */\r
+#define EVENTGROUP_RECEIVE_FROM_ISR_SUCCESS     (EVENTGROUP_SEND_FROM_ISR_SUCCESS + 8)  /*0x38*/\r
+\r
+/* "Failed" event type versions of above (timeout, failed allocation, etc) */\r
+#define EVENTGROUP_KSE_FAILED         (EVENTGROUP_RECEIVE_FROM_ISR_SUCCESS + 8) /*0x40*/\r
+\r
+/* Failed create calls - memory allocation failed */\r
+#define EVENTGROUP_CREATE_FAILED                (EVENTGROUP_KSE_FAILED) /*0x40*/\r
+\r
+/* Failed send/give - timeout! */\r
+#define EVENTGROUP_SEND_FAILED           (EVENTGROUP_CREATE_FAILED + 8) /*0x48*/\r
+\r
+/* Failed receive/take - timeout! */\r
+#define EVENTGROUP_RECEIVE_FAILED          (EVENTGROUP_SEND_FAILED + 8) /*0x50*/\r
+\r
+/* Failed non-blocking send/give - queue full */\r
+#define EVENTGROUP_SEND_FROM_ISR_FAILED (EVENTGROUP_RECEIVE_FAILED + 8) /*0x58*/\r
+\r
+/* Failed non-blocking receive/take - queue empty */\r
+#define EVENTGROUP_RECEIVE_FROM_ISR_FAILED \\r
+                                  (EVENTGROUP_SEND_FROM_ISR_FAILED + 8) /*0x60*/\r
+\r
+/* Events when blocking on receive/take */\r
+#define EVENTGROUP_RECEIVE_BLOCK \\r
+                               (EVENTGROUP_RECEIVE_FROM_ISR_FAILED + 8) /*0x68*/\r
+\r
+/* Events when blocking on send/give */\r
+#define EVENTGROUP_SEND_BLOCK     (EVENTGROUP_RECEIVE_BLOCK + 8)  /*0x70*/\r
+\r
+/* Events on queue peek (receive) */\r
+#define EVENTGROUP_PEEK_SUCCESS              (EVENTGROUP_SEND_BLOCK + 8)     /*0x78*/\r
+\r
+/* Events on object delete (vTaskDelete or vQueueDelete) */\r
+#define EVENTGROUP_DELETE_SUCCESS            (EVENTGROUP_PEEK_SUCCESS + 8)              /*0x80*/\r
+\r
+/* Other events - object class is implied: TASK */\r
+#define EVENTGROUP_OTHERS            (EVENTGROUP_DELETE_SUCCESS + 8)            /*0x88*/\r
+#define TASK_DELAY_UNTIL             (EVENTGROUP_OTHERS + 0)            /*0x88*/\r
+#define TASK_DELAY                   (EVENTGROUP_OTHERS + 1)            /*0x89*/\r
+#define TASK_SUSPEND                 (EVENTGROUP_OTHERS + 2)            /*0x8A*/\r
+#define TASK_RESUME                  (EVENTGROUP_OTHERS + 3)            /*0x8B*/\r
+#define TASK_RESUME_FROM_ISR         (EVENTGROUP_OTHERS + 4)            /*0x8C*/\r
+#define TASK_PRIORITY_SET            (EVENTGROUP_OTHERS + 5)            /*0x8D*/\r
+#define TASK_PRIORITY_INHERIT        (EVENTGROUP_OTHERS + 6)            /*0x8E*/\r
+#define TASK_PRIORITY_DISINHERIT     (EVENTGROUP_OTHERS + 7)            /*0x8F*/\r
+\r
+/* Not yet used */\r
+#define EVENTGROUP_FTRACE_PLACEHOLDER    (EVENTGROUP_OTHERS + 8)        /*0x90*/\r
+\r
+/* User events */\r
+#define EVENTGROUP_USEREVENT (EVENTGROUP_FTRACE_PLACEHOLDER + 8)        /*0x98*/\r
+#define USER_EVENT (EVENTGROUP_USEREVENT + 0)\r
+\r
+/* Allow for 0-15 arguments (the number of args is added to event code) */\r
+#define USER_EVENT_LAST (EVENTGROUP_USEREVENT + 15)                     /*0xA7*/\r
+\r
+/*******************************************************************************\r
+ * XTS Event - eXtended TimeStamp events\r
+ * The timestamps used in the recorder are "differential timestamps" (DTS), i.e.\r
+ * the time since the last stored event. The DTS fields are either 1 or 2 bytes \r
+ * in the other events, depending on the bytes available in the event struct. \r
+ * If the time since the last event (the DTS) is larger than allowed for by \r
+ * the DTS field of the current event, an XTS event is inserted immediately \r
+ * before the original event. The XTS event contains up to 3 additional bytes \r
+ * of the DTS value - the higher bytes of the true DTS value. The lower 1-2 \r
+ * bytes are stored in the normal DTS field. \r
+ * There are two types of XTS events, XTS8 and XTS16. An XTS8 event is stored \r
+ * when there is only room for 1 byte (8 bit) DTS data in the original event, \r
+ * which means a limit of 0xFF (255). The XTS16 is used when the original event \r
+ * has a 16 bit DTS field and thereby can handle values up to 0xFFFF (65535).\r
+ * \r
+ * Using a very high frequency time base can result in many XTS events. \r
+ * Preferably, the time between two OS ticks should fit in 16 bits, i.e.,\r
+ * at most 65535. If your time base has a higher frequency, you can define\r
+ * the TRACE\r
+ ******************************************************************************/\r
+\r
+#define EVENTGROUP_SYS (EVENTGROUP_USEREVENT + 16)                      /*0xA8*/\r
+#define XTS8 (EVENTGROUP_SYS + 0)                                       /*0xA8*/\r
+#define XTS16 (EVENTGROUP_SYS + 1)                                      /*0xA9*/\r
+\r
+#define EVENT_BEING_WRITTEN (EVENTGROUP_SYS + 2)                        /*0xAA*/\r
+\r
+#define RESERVED_DUMMY_CODE (EVENTGROUP_SYS + 3)                        /*0xAB*/\r
+\r
+\r
+\r
+/************************************************************************/\r
+/* KERNEL SPECIFIC DATA AND FUNCTIONS NEEDED TO PROVIDE THE             */\r
+/* FUNCTIONALITY REQUESTED BY THE TRACE RECORDER                        */\r
+/************************************************************************/\r
+\r
+/******************************************************************************\r
+ * TraceObjectClassTable\r
+ * Translates a FreeRTOS QueueType into trace objects classes (TRACE_CLASS_).\r
+ * This was added since we want to map both types of Mutex and both types of \r
+ * Semaphores on common classes for all Mutexes and all Semaphores respectively. \r
+ * \r
+ * FreeRTOS Queue types\r
+ * #define queueQUEUE_TYPE_BASE                  (0U) => TRACE_CLASS_QUEUE\r
+ * #define queueQUEUE_TYPE_MUTEX                 (1U) => TRACE_CLASS_MUTEX\r
+ * #define queueQUEUE_TYPE_COUNTING_SEMAPHORE    (2U) => TRACE_CLASS_SEMAPHORE\r
+ * #define queueQUEUE_TYPE_BINARY_SEMAPHORE      (3U) => TRACE_CLASS_SEMAPHORE\r
+ * #define queueQUEUE_TYPE_RECURSIVE_MUTEX       (4U) => TRACE_CLASS_MUTEX \r
+ ******************************************************************************/\r
+\r
+extern traceObjectClass TraceObjectClassTable[5];\r
+\r
+/* These functions are implemented in the .c file since certain header files must not be included in this one */\r
+objectHandleType prvTraceGetObjectNumber(void* handle);\r
+unsigned char prvTraceGetObjectType(void* handle);\r
+objectHandleType prvTraceGetTaskNumber(void* handle);\r
+unsigned char prvTraceIsSchedulerActive(void);\r
+unsigned char prvTraceIsSchedulerSuspended(void);\r
+unsigned char prvTraceIsSchedulerStarted(void);\r
+void prvTraceEnterCritical(void);\r
+void prvTraceExitCritical(void);\r
+void* prvTraceGetCurrentTaskHandle(void);\r
+\r
+\r
+/************************************************************************/\r
+/* KERNEL SPECIFIC MACROS USED BY THE TRACE RECORDER                    */\r
+/************************************************************************/\r
+\r
+#define TRACE_MALLOC(size) pvPortMalloc(size)\r
+\r
+#define TRACE_ENTER_CRITICAL_SECTION() prvTraceEnterCritical();\r
+#define TRACE_EXIT_CRITICAL_SECTION() prvTraceExitCritical();\r
+\r
+#define TRACE_IS_SCHEDULER_ACTIVE() prvTraceIsSchedulerActive()\r
+#define TRACE_IS_SCHEDULER_STARTED() prvTraceIsSchedulerStarted()\r
+#define TRACE_IS_SCHEDULER_SUSPENDED() prvTraceIsSchedulerSuspended()\r
+#define TRACE_GET_CURRENT_TASK() prvTraceGetCurrentTaskHandle()\r
+\r
+#define TRACE_GET_TASK_PRIORITY(pxTCB) ((uint8_t)pxTCB->uxPriority)\r
+#define TRACE_GET_TASK_NAME(pxTCB) ((char*)pxTCB->pcTaskName)\r
+#define TRACE_GET_TASK_NUMBER(pxTCB) (prvTraceGetTaskNumber(pxTCB))\r
+#define TRACE_SET_TASK_NUMBER(pxTCB) pxTCB->uxTaskNumber = xTraceGetObjectHandle(TRACE_CLASS_TASK);\r
+\r
+#define TRACE_GET_CLASS_TRACE_CLASS(CLASS, kernelClass) TraceObjectClassTable[kernelClass]\r
+#define TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject) TRACE_GET_CLASS_TRACE_CLASS(CLASS, prvTraceGetObjectType(pxObject))\r
+\r
+#define TRACE_GET_OBJECT_NUMBER(CLASS, pxObject) (prvTraceGetObjectNumber(pxObject))\r
+#define TRACE_SET_OBJECT_NUMBER(CLASS, pxObject) pxObject->ucQueueNumber = xTraceGetObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject));\r
+\r
+#define TRACE_GET_CLASS_EVENT_CODE(SERVICE, RESULT, CLASS, kernelClass) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_GET_CLASS_TRACE_CLASS(CLASS, kernelClass))\r
+#define TRACE_GET_OBJECT_EVENT_CODE(SERVICE, RESULT, CLASS, pxObject) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject))\r
+#define TRACE_GET_TASK_EVENT_CODE(SERVICE, RESULT, CLASS, pxTCB) (EVENTGROUP_##SERVICE##_##RESULT + TRACE_CLASS_TASK)\r
+\r
+\r
+\r
+/************************************************************************/\r
+/* KERNEL SPECIFIC WRAPPERS THAT SHOULD BE CALLED BY THE KERNEL         */\r
+/************************************************************************/\r
+\r
+/* Called for each task that becomes ready */\r
+#undef traceMOVED_TASK_TO_READY_STATE\r
+#define traceMOVED_TASK_TO_READY_STATE( pxTCB ) \\r
+       trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE(pxTCB);\r
+\r
+/* Called on each OS tick. Will call uiPortGetTimestamp to make sure it is called at least once every OS tick. */\r
+#undef traceTASK_INCREMENT_TICK\r
+#define traceTASK_INCREMENT_TICK( xTickCount ) \\r
+    if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxMissedTicks == 0) { trcKERNEL_HOOKS_INCREMENT_TICK(); } \\r
+       if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE) { trcKERNEL_HOOKS_NEW_TIME(DIV_NEW_TIME, xTickCount + 1); }\r
+\r
+/* Called on each task-switch */\r
+#undef traceTASK_SWITCHED_IN\r
+#define traceTASK_SWITCHED_IN() \\r
+       trcKERNEL_HOOKS_TASK_SWITCH(TRACE_GET_CURRENT_TASK());\r
+\r
+/* Called on vTaskSuspend */\r
+#undef traceTASK_SUSPEND\r
+#define traceTASK_SUSPEND( pxTaskToSuspend ) \\r
+       trcKERNEL_HOOKS_TASK_SUSPEND(TASK_SUSPEND, pxTaskToSuspend);\r
+\r
+/* Called on vTaskDelay - note the use of FreeRTOS variable xTicksToDelay */\r
+#undef traceTASK_DELAY\r
+#define traceTASK_DELAY() \\r
+       TRACE_ENTER_CRITICAL_SECTION(); \\r
+       trcKERNEL_HOOKS_TASK_DELAY(TASK_DELAY, pxCurrentTCB, xTicksToDelay); \\r
+       trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(UNUSED,pxCurrentTCB); \\r
+       TRACE_EXIT_CRITICAL_SECTION();\r
+\r
+/* Called on vTaskDelayUntil - note the use of FreeRTOS variable xTimeToWake */\r
+#undef traceTASK_DELAY_UNTIL\r
+#define traceTASK_DELAY_UNTIL() \\r
+       TRACE_ENTER_CRITICAL_SECTION(); \\r
+       trcKERNEL_HOOKS_TASK_DELAY(TASK_DELAY_UNTIL, pxCurrentTCB, xTimeToWake); \\r
+       trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(UNUSED,pxCurrentTCB); \\r
+       TRACE_EXIT_CRITICAL_SECTION();\r
+\r
+#if (INCLUDE_OBJECT_DELETE == 1)\r
+/* Called on vTaskDelete */\r
+#undef traceTASK_DELETE\r
+#define traceTASK_DELETE( pxTaskToDelete ) \\r
+       trcKERNEL_HOOKS_TASK_DELETE(DELETE, pxTaskToDelete);\r
+#endif\r
+\r
+#if (INCLUDE_OBJECT_DELETE == 1)\r
+/* Called on vQueueDelete */\r
+#undef traceQUEUE_DELETE\r
+#define traceQUEUE_DELETE( pxQueue ) \\r
+       TRACE_ENTER_CRITICAL_SECTION(); \\r
+       trcKERNEL_HOOKS_OBJECT_DELETE(DELETE, UNUSED, pxQueue); \\r
+       TRACE_EXIT_CRITICAL_SECTION();\r
+#endif\r
+\r
+/* Called on vTaskCreate */\r
+#undef traceTASK_CREATE\r
+#define traceTASK_CREATE(pxNewTCB) \\r
+       if (pxNewTCB != NULL) \\r
+       { \\r
+               trcKERNEL_HOOKS_TASK_CREATE(CREATE, pxNewTCB); \\r
+       }\r
+\r
+/* Called in vTaskCreate, if it fails (typically if the stack can not be allocated) */\r
+#undef traceTASK_CREATE_FAILED\r
+#define traceTASK_CREATE_FAILED() \\r
+       TRACE_ENTER_CRITICAL_SECTION(); \\r
+       trcKERNEL_HOOKS_TASK_CREATE_FAILED(CREATE); \\r
+       TRACE_EXIT_CRITICAL_SECTION();\r
+\r
+/* Called in xQueueCreate, and thereby for all other object based on queues, such as semaphores. */\r
+#undef traceQUEUE_CREATE\r
+#define traceQUEUE_CREATE( pxNewQueue )\\r
+       TRACE_ENTER_CRITICAL_SECTION(); \\r
+       trcKERNEL_HOOKS_OBJECT_CREATE(CREATE, UNUSED, pxNewQueue); \\r
+       TRACE_EXIT_CRITICAL_SECTION();\r
+\r
+/* Called in xQueueCreate, if the queue creation fails */\r
+#undef traceQUEUE_CREATE_FAILED\r
+#define traceQUEUE_CREATE_FAILED( queueType ) \\r
+       TRACE_ENTER_CRITICAL_SECTION(); \\r
+       trcKERNEL_HOOKS_OBJECT_CREATE_FAILED(CREATE, UNUSED, queueType); \\r
+       TRACE_EXIT_CRITICAL_SECTION();\r
+\r
+/* Called in xQueueCreateMutex, and thereby also from xSemaphoreCreateMutex and xSemaphoreCreateRecursiveMutex */\r
+#undef traceCREATE_MUTEX\r
+#define traceCREATE_MUTEX( pxNewQueue ) \\r
+       TRACE_ENTER_CRITICAL_SECTION(); \\r
+       trcKERNEL_HOOKS_OBJECT_CREATE(CREATE, UNUSED, pxNewQueue); \\r
+       TRACE_EXIT_CRITICAL_SECTION();\r
+\r
+/* Called in xQueueCreateMutex when the operation fails (when memory allocation fails) */\r
+#undef traceCREATE_MUTEX_FAILED\r
+#define traceCREATE_MUTEX_FAILED() \\r
+       TRACE_ENTER_CRITICAL_SECTION(); \\r
+       trcKERNEL_HOOKS_OBJECT_CREATE_FAILED(CREATE, UNUSED, queueQUEUE_TYPE_MUTEX); \\r
+       TRACE_EXIT_CRITICAL_SECTION();\r
+\r
+/* Called when the Mutex can not be given, since not holder */\r
+#undef traceGIVE_MUTEX_RECURSIVE_FAILED\r
+#define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) \\r
+       TRACE_ENTER_CRITICAL_SECTION(); \\r
+       trcKERNEL_HOOKS_KERNEL_SERVICE(SEND, FAILED, UNUSED, pxMutex); \\r
+       TRACE_EXIT_CRITICAL_SECTION();\r
+\r
+/* Called when a message is sent to a queue */\r
+#undef traceQUEUE_SEND\r
+#define traceQUEUE_SEND( pxQueue ) \\r
+       trcKERNEL_HOOKS_KERNEL_SERVICE(SEND, SUCCESS, UNUSED, pxQueue); \\r
+       trcKERNEL_HOOKS_SET_OBJECT_STATE(UNUSED, pxQueue, TRACE_GET_OBJECT_TRACE_CLASS(UNUSED, pxQueue) == TRACE_CLASS_MUTEX ? (uint8_t)0 : (uint8_t)(pxQueue->uxMessagesWaiting + 1)); /*For mutex, store the new owner rather than queue length */\r
+\r
+/* Called when a message failed to be sent to a queue (timeout) */\r
+#undef traceQUEUE_SEND_FAILED\r
+#define traceQUEUE_SEND_FAILED( pxQueue ) \\r
+    TRACE_ENTER_CRITICAL_SECTION();\\r
+    trcKERNEL_HOOKS_KERNEL_SERVICE(SEND, FAILED, UNUSED, pxQueue); \\r
+    TRACE_EXIT_CRITICAL_SECTION();\r
+\r
+/* Called when the task is blocked due to a send operation on a full queue */\r
+#undef traceBLOCKING_ON_QUEUE_SEND\r
+#define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) \\r
+       TRACE_ENTER_CRITICAL_SECTION();\\r
+       trcKERNEL_HOOKS_KERNEL_SERVICE(SEND, BLOCK, UNUSED, pxQueue); \\r
+       TRACE_EXIT_CRITICAL_SECTION();\r
+\r
+/* Called when a message is received from a queue */\r
+#undef traceQUEUE_RECEIVE\r
+#define traceQUEUE_RECEIVE( pxQueue ) \\r
+       trcKERNEL_HOOKS_KERNEL_SERVICE(RECEIVE, SUCCESS, UNUSED, pxQueue); \\r
+       trcKERNEL_HOOKS_SET_OBJECT_STATE(UNUSED, pxQueue, TRACE_GET_OBJECT_TRACE_CLASS(UNUSED, pxQueue) == TRACE_CLASS_MUTEX ? TRACE_GET_TASK_NUMBER(TRACE_GET_CURRENT_TASK()) : (uint8_t)(pxQueue->uxMessagesWaiting - 1)); /*For mutex, store the new owner rather than queue length */\r
+\r
+/* Called when a receive operation on a queue fails (timeout) */\r
+#undef traceQUEUE_RECEIVE_FAILED\r
+#define traceQUEUE_RECEIVE_FAILED( pxQueue ) \\r
+       TRACE_ENTER_CRITICAL_SECTION(); \\r
+       trcKERNEL_HOOKS_KERNEL_SERVICE(RECEIVE, FAILED, UNUSED, pxQueue); \\r
+       TRACE_EXIT_CRITICAL_SECTION();\r
+\r
+/* Called when the task is blocked due to a receive operation on an empty queue */\r
+#undef traceBLOCKING_ON_QUEUE_RECEIVE\r
+#define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) \\r
+       TRACE_ENTER_CRITICAL_SECTION(); \\r
+       trcKERNEL_HOOKS_KERNEL_SERVICE(RECEIVE, BLOCK, UNUSED, pxQueue); \\r
+       if (TRACE_GET_OBJECT_TRACE_CLASS(UNUSED, pxQueue) != TRACE_CLASS_MUTEX) \\r
+       { \\r
+               trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED(UNUSED, pxQueue); \\r
+       } \\r
+       TRACE_EXIT_CRITICAL_SECTION();\r
+\r
+/* Called on xQueuePeek */\r
+#undef traceQUEUE_PEEK\r
+#define traceQUEUE_PEEK( pxQueue ) \\r
+       trcKERNEL_HOOKS_KERNEL_SERVICE(PEEK, SUCCESS, UNUSED, pxQueue);\r
+\r
+/* Called when a message is sent from interrupt context, e.g., using xQueueSendFromISR */\r
+#undef traceQUEUE_SEND_FROM_ISR\r
+#define traceQUEUE_SEND_FROM_ISR( pxQueue ) \\r
+       trcKERNEL_HOOKS_KERNEL_SERVICE(SEND_FROM_ISR, SUCCESS, UNUSED, pxQueue); \\r
+       trcKERNEL_HOOKS_SET_OBJECT_STATE(UNUSED, pxQueue, (uint8_t)(pxQueue->uxMessagesWaiting + 1));\r
+\r
+/* Called when a message send from interrupt context fails (since the queue was full) */\r
+#undef traceQUEUE_SEND_FROM_ISR_FAILED\r
+#define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) \\r
+       trcKERNEL_HOOKS_KERNEL_SERVICE(SEND_FROM_ISR, FAILED, UNUSED, pxQueue);\r
+\r
+/* Called when a message is received in interrupt context, e.g., using xQueueReceiveFromISR */\r
+#undef traceQUEUE_RECEIVE_FROM_ISR\r
+#define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) \\r
+       trcKERNEL_HOOKS_KERNEL_SERVICE(RECEIVE_FROM_ISR, SUCCESS, UNUSED, pxQueue); \\r
+       trcKERNEL_HOOKS_SET_OBJECT_STATE(UNUSED, pxQueue, (uint8_t)(pxQueue->uxMessagesWaiting - 1));\r
+\r
+/* Called when a message receive from interrupt context fails (since the queue was empty) */\r
+#undef traceQUEUE_RECEIVE_FROM_ISR_FAILED\r
+#define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) \\r
+       trcKERNEL_HOOKS_KERNEL_SERVICE(RECEIVE_FROM_ISR, FAILED, UNUSED, pxQueue);\r
+\r
+/* Called in vTaskPrioritySet */\r
+#undef traceTASK_PRIORITY_SET\r
+#define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) \\r
+       trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(TASK_PRIORITY_SET, pxTask, uxNewPriority);\r
+\r
+/* Called in vTaskPriorityInherit, which is called by Mutex operations */\r
+#undef traceTASK_PRIORITY_INHERIT\r
+#define traceTASK_PRIORITY_INHERIT( pxTask, uxNewPriority ) \\r
+       trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(TASK_PRIORITY_INHERIT, pxTask, uxNewPriority);\r
+\r
+/* Called in vTaskPriorityDisinherit, which is called by Mutex operations */\r
+#undef traceTASK_PRIORITY_DISINHERIT\r
+#define traceTASK_PRIORITY_DISINHERIT( pxTask, uxNewPriority ) \\r
+       trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(TASK_PRIORITY_DISINHERIT, pxTask, uxNewPriority);\r
+\r
+/* Called in vTaskResume */\r
+#undef traceTASK_RESUME\r
+#define traceTASK_RESUME( pxTaskToResume ) \\r
+       trcKERNEL_HOOKS_TASK_RESUME(TASK_RESUME, pxTaskToResume);\r
+\r
+/* Called in vTaskResumeFromISR */\r
+#undef traceTASK_RESUME_FROM_ISR\r
+#define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) \\r
+       trcKERNEL_HOOKS_TASK_RESUME(TASK_RESUME_FROM_ISR, pxTaskToResume);\r
+\r
+\r
+/************************************************************************/\r
+/* KERNEL SPECIFIC MACROS TO EXCLUDE OR INCLUDE THINGS IN TRACE         */\r
+/************************************************************************/\r
+\r
+/* Returns the exclude state of the object */\r
+uint8_t uiTraceIsObjectExcluded(traceObjectClass objectclass, objectHandleType handle);\r
+\r
+#define TRACE_SET_QUEUE_FLAG_ISEXCLUDED(queueIndex) TRACE_SET_FLAG_ISEXCLUDED(excludedObjects, queueIndex)\r
+#define TRACE_CLEAR_QUEUE_FLAG_ISEXCLUDED(queueIndex) TRACE_CLEAR_FLAG_ISEXCLUDED(excludedObjects, queueIndex)\r
+#define TRACE_GET_QUEUE_FLAG_ISEXCLUDED(queueIndex) TRACE_GET_FLAG_ISEXCLUDED(excludedObjects, queueIndex)\r
+\r
+#define TRACE_SET_SEMAPHORE_FLAG_ISEXCLUDED(semaphoreIndex) TRACE_SET_FLAG_ISEXCLUDED(excludedObjects, NQueue+1+semaphoreIndex)\r
+#define TRACE_CLEAR_SEMAPHORE_FLAG_ISEXCLUDED(semaphoreIndex) TRACE_CLEAR_FLAG_ISEXCLUDED(excludedObjects, NQueue+1+semaphoreIndex)\r
+#define TRACE_GET_SEMAPHORE_FLAG_ISEXCLUDED(semaphoreIndex) TRACE_GET_FLAG_ISEXCLUDED(excludedObjects, NQueue+1+semaphoreIndex)\r
+\r
+#define TRACE_SET_MUTEX_FLAG_ISEXCLUDED(mutexIndex) TRACE_SET_FLAG_ISEXCLUDED(excludedObjects, NQueue+1+NSemaphore+1+mutexIndex)\r
+#define TRACE_CLEAR_MUTEX_FLAG_ISEXCLUDED(mutexIndex) TRACE_CLEAR_FLAG_ISEXCLUDED(excludedObjects, NQueue+1+NSemaphore+1+mutexIndex)\r
+#define TRACE_GET_MUTEX_FLAG_ISEXCLUDED(mutexIndex) TRACE_GET_FLAG_ISEXCLUDED(excludedObjects, NQueue+1+NSemaphore+1+mutexIndex)\r
+\r
+#define TRACE_SET_TASK_FLAG_ISEXCLUDED(taskIndex) TRACE_SET_FLAG_ISEXCLUDED(excludedObjects, NQueue+1+NSemaphore+1+NMutex+1+taskIndex)\r
+#define TRACE_CLEAR_TASK_FLAG_ISEXCLUDED(taskIndex) TRACE_CLEAR_FLAG_ISEXCLUDED(excludedObjects, NQueue+1+NSemaphore+1+NMutex+1+taskIndex)\r
+#define TRACE_GET_TASK_FLAG_ISEXCLUDED(taskIndex) TRACE_GET_FLAG_ISEXCLUDED(excludedObjects, NQueue+1+NSemaphore+1+NMutex+1+taskIndex)\r
+\r
+#define TRACE_CLEAR_OBJECT_FLAG_ISEXCLUDED(objectclass, handle) \\r
+switch (objectclass) \\r
+{ \\r
+case TRACE_CLASS_QUEUE: \\r
+       TRACE_CLEAR_QUEUE_FLAG_ISEXCLUDED(handle); \\r
+       break; \\r
+case TRACE_CLASS_SEMAPHORE: \\r
+       TRACE_CLEAR_SEMAPHORE_FLAG_ISEXCLUDED(handle); \\r
+       break; \\r
+case TRACE_CLASS_MUTEX: \\r
+       TRACE_CLEAR_MUTEX_FLAG_ISEXCLUDED(handle); \\r
+       break; \\r
+case TRACE_CLASS_TASK: \\r
+       TRACE_CLEAR_TASK_FLAG_ISEXCLUDED(handle); \\r
+       break; \\r
+}\r
+\r
+#define TRACE_SET_OBJECT_FLAG_ISEXCLUDED(objectclass, handle) \\r
+switch (objectclass) \\r
+{ \\r
+case TRACE_CLASS_QUEUE: \\r
+       TRACE_SET_QUEUE_FLAG_ISEXCLUDED(handle); \\r
+       break; \\r
+case TRACE_CLASS_SEMAPHORE: \\r
+       TRACE_SET_SEMAPHORE_FLAG_ISEXCLUDED(handle); \\r
+       break; \\r
+case TRACE_CLASS_MUTEX: \\r
+       TRACE_SET_MUTEX_FLAG_ISEXCLUDED(handle); \\r
+       break; \\r
+case TRACE_CLASS_TASK: \\r
+       TRACE_SET_TASK_FLAG_ISEXCLUDED(handle); \\r
+       break; \\r
+}\r
+\r
+/* Task */\r
+#define vTraceExcludeTaskFromTrace(handle) \\r
+TRACE_SET_TASK_FLAG_ISEXCLUDED(TRACE_GET_TASK_NUMBER(handle));\r
+\r
+#define vTraceIncludeTaskInTrace(handle) \\r
+TRACE_CLEAR_TASK_FLAG_ISEXCLUDED(TRACE_GET_TASK_NUMBER(handle));\r
+\r
+\r
+/* Queue */\r
+#define vTraceExcludeQueueFromTrace(handle) \\r
+TRACE_SET_QUEUE_FLAG_ISEXCLUDED(TRACE_GET_OBJECT_NUMBER(UNUSED, handle));\r
+\r
+#define vTraceIncludeQueueInTrace(handle) \\r
+TRACE_CLEAR_QUEUE_FLAG_ISEXCLUDED(TRACE_GET_OBJECT_NUMBER(UNUSED, handle));\r
+\r
+\r
+/* Semaphore */\r
+#define vTraceExcludeSemaphoreFromTrace(handle) \\r
+TRACE_SET_SEMAPHORE_FLAG_ISEXCLUDED(TRACE_GET_OBJECT_NUMBER(UNUSED, handle));\r
+\r
+#define vTraceIncludeSemaphoreInTrace(handle) \\r
+TRACE_CLEAR_QUEUE_FLAG_ISEXCLUDED(TRACE_GET_OBJECT_NUMBER(UNUSED, handle));\r
+\r
+\r
+/* Mutex */\r
+#define vTraceExcludeMutexFromTrace(handle) \\r
+TRACE_SET_MUTEX_FLAG_ISEXCLUDED(TRACE_GET_OBJECT_NUMBER(UNUSED, handle));\r
+\r
+#define vTraceIncludeMutexInTrace(handle) \\r
+TRACE_CLEAR_QUEUE_FLAG_ISEXCLUDED(TRACE_GET_OBJECT_NUMBER(UNUSED, handle));\r
+\r
+\r
+/* Kernel Services */\r
+#define vTraceExcludeKernelServiceDelayFromTrace() \\r
+TRACE_SET_EVENT_CODE_FLAG_ISEXCLUDED(TASK_DELAY); \\r
+TRACE_SET_EVENT_CODE_FLAG_ISEXCLUDED(TASK_DELAY_UNTIL);\r
+\r
+#define vTraceIncludeKernelServiceDelayInTrace() \\r
+TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(TASK_DELAY); \\r
+TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(TASK_DELAY_UNTIL);\r
+\r
+/* HELPER MACROS FOR KERNEL SERVICES FOR OBJECTS */\r
+#define vTraceExcludeKernelServiceSendFromTrace_HELPER(class) \\r
+TRACE_SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_SUCCESS + class); \\r
+TRACE_SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_BLOCK + class); \\r
+TRACE_SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_FAILED + class); \\r
+TRACE_SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_FROM_ISR_SUCCESS + class); \\r
+TRACE_SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_FROM_ISR_FAILED + class);\r
+\r
+#define vTraceIncludeKernelServiceSendInTrace_HELPER(class) \\r
+TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_SUCCESS + class); \\r
+TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_BLOCK + class); \\r
+TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_FAILED + class); \\r
+TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_FROM_ISR_SUCCESS + class); \\r
+TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_FROM_ISR_FAILED + class);\r
+\r
+#define vTraceExcludeKernelServiceReceiveFromTrace_HELPER(class) \\r
+TRACE_SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_SUCCESS + class); \\r
+TRACE_SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_BLOCK + class); \\r
+TRACE_SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_FAILED + class); \\r
+TRACE_SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_FROM_ISR_SUCCESS + class); \\r
+TRACE_SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_FROM_ISR_FAILED + class);\r
+\r
+#define vTraceIncludeKernelServiceReceiveInTrace_HELPER(class) \\r
+TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_SUCCESS + class); \\r
+TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_BLOCK + class); \\r
+TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_FAILED + class); \\r
+TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_FROM_ISR_SUCCESS + class); \\r
+TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_FROM_ISR_FAILED + class);\r
+\r
+/* EXCLUDE AND INCLUDE FOR QUEUE */\r
+#define vTraceExcludeKernelServiceQueueSendFromTrace() \\r
+vTraceExcludeKernelServiceSendFromTrace_HELPER(TRACE_CLASS_QUEUE);\r
+\r
+#define vTraceIncludeKernelServiceQueueSendInTrace() \\r
+vTraceIncludeKernelServiceSendInTrace_HELPER(TRACE_CLASS_QUEUE);\r
+\r
+#define vTraceExcludeKernelServiceQueueReceiveFromTrace() \\r
+vTraceExcludeKernelServiceReceiveFromTrace_HELPER(TRACE_CLASS_QUEUE);\r
+\r
+#define vTraceIncludeKernelServiceQueueReceiveInTrace() \\r
+vTraceIncludeKernelServiceReceiveInTrace_HELPER(TRACE_CLASS_QUEUE);\r
+\r
+/* EXCLUDE AND INCLUDE FOR SEMAPHORE */\r
+#define vTraceExcludeKernelServiceSemaphoreSendFromTrace() \\r
+vTraceExcludeKernelServiceSendFromTrace_HELPER(TRACE_CLASS_SEMAPHORE);\r
+\r
+#define vTraceIncludeKernelServicSemaphoreSendInTrace() \\r
+vTraceIncludeKernelServiceSendInTrace_HELPER(TRACE_CLASS_SEMAPHORE);\r
+\r
+#define vTraceExcludeKernelServiceSemaphoreReceiveFromTrace() \\r
+vTraceExcludeKernelServiceReceiveFromTrace_HELPER(TRACE_CLASS_SEMAPHORE);\r
+\r
+#define vTraceIncludeKernelServiceSemaphoreReceiveInTrace() \\r
+vTraceIncludeKernelServiceReceiveInTrace_HELPER(TRACE_CLASS_SEMAPHORE);\r
+\r
+/* EXCLUDE AND INCLUDE FOR MUTEX */\r
+#define vTraceExcludeKernelServiceMutexSendFromTrace() \\r
+vTraceExcludeKernelServiceSendFromTrace_HELPER(TRACE_CLASS_MUTEX);\r
+\r
+#define vTraceIncludeKernelServiceMutexSendInTrace() \\r
+vTraceIncludeKernelServiceSendInTrace_HELPER(TRACE_CLASS_MUTEX);\r
+\r
+#define vTraceExcludeKernelServiceMutexReceiveFromTrace() \\r
+vTraceExcludeKernelServiceReceiveFromTrace_HELPER(TRACE_CLASS_MUTEX);\r
+\r
+#define vTraceIncludeKernelServiceMutexReceiveInTrace() \\r
+vTraceIncludeKernelServiceReceiveInTrace_HELPER(TRACE_CLASS_MUTEX);\r
+\r
+/************************************************************************/\r
+/* KERNEL SPECIFIC MACROS TO NAME OBJECTS, IF NECESSARY                 */\r
+/************************************************************************/\r
+#define vTraceSetQueueName(object, name) \\r
+vTraceSetObjectName(TRACE_GET_OBJECT_TRACE_CLASS(UNUSED, object), TRACE_GET_OBJECT_NUMBER(UNUSED, object), name);\r
+\r
+#define vTraceSetSemaphoreName(object, name) \\r
+vTraceSetObjectName(TRACE_GET_OBJECT_TRACE_CLASS(UNUSED, object), TRACE_GET_OBJECT_NUMBER(UNUSED, object), name);\r
+\r
+#define vTraceSetMutexName(object, name) \\r
+vTraceSetObjectName(TRACE_GET_OBJECT_TRACE_CLASS(UNUSED, object), TRACE_GET_OBJECT_NUMBER(UNUSED, object), name);\r
+\r
+#endif\r
+\r
+#endif /* TRCKERNELPORT_H_ */
\ No newline at end of file
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcPort.c
deleted file mode 100644 (file)
index e98dd57..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
- * Percepio AB, www.percepio.com\r
- *\r
- * trcPort.c\r
- *\r
- * Contains all portability issues of the trace recorder library. \r
- * See also trcPort.h, where port-specific macros are defined.\r
- *\r
- * Terms of Use\r
- * This software is copyright Percepio AB. The recorder library is free for\r
- * use together with Percepio products. You may distribute the recorder library\r
- * in its original form, including modifications in trcPort.c and trcPort.h\r
- * given that these modification are clearly marked as your own modifications\r
- * and documented in the initial comment section of these source files. \r
- * This software is the intellectual property of Percepio AB and may not be \r
- * sold or in other ways commercially redistributed without explicit written \r
- * permission by Percepio AB.\r
- *\r
- * Disclaimer \r
- * The trace tool and recorder library is being delivered to you AS IS and \r
- * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
- * not and cannot warrant the performance or results you may obtain by using the \r
- * software or documentation. Percepio AB make no warranties, express or \r
- * implied, as to noninfringement of third party rights, merchantability, or \r
- * fitness for any particular purpose. In no event will Percepio AB, its \r
- * technology partners, or distributors be liable to you for any consequential, \r
- * incidental or special damages, including any lost profits or lost savings, \r
- * even if a representative of Percepio AB has been advised of the possibility \r
- * of such damages, or for any claim by any third party. Some jurisdictions do \r
- * not allow the exclusion or limitation of incidental, consequential or special \r
- * damages, or the exclusion of implied warranties or limitations on how long an \r
- * implied warranty may last, so the above limitations may not apply to you.\r
- *\r
- * OFFER FROM PERCEPIO:\r
- * For silicon companies and non-corporate FreeRTOS users (researchers, students\r
- * , hobbyists or early-phase startups) we have an attractive offer: \r
- * Provide a hardware timer port and get a FREE single-user licence for\r
- * FreeRTOS+Trace Professional Edition. Read more about this offer at \r
- * www.percepio.com or contact us directly at support@percepio.com.\r
- *\r
- * FreeRTOS+Trace is available as Free Edition and in two premium editions.\r
- * You may use the premium features during 30 days for evaluation.\r
- * Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/\r
- *\r
- * Copyright Percepio AB, 2012.\r
- * www.percepio.com\r
- ******************************************************************************/\r
-\r
-#include "trcUser.h"\r
-\r
-#if (configUSE_TRACE_FACILITY == 1)\r
-\r
-#if (INCLUDE_SAVE_TO_FILE == 1)\r
-static char* prvFileName = NULL;\r
-#endif\r
-\r
-\r
-/*******************************************************************************\r
- * uiTraceTickCount\r
- *\r
- * This variable is updated by the traceTASK_INCREMENT_TICK macro in the \r
- * FreeRTOS tick handler. This does not need to be modified when developing a \r
- * new timer port. It is prefered to keep any timer port changes in the HWTC \r
- * macro definitions, which typically give sufficient flexibility.\r
- ******************************************************************************/\r
-uint32_t uiTraceTickCount = 0;\r
-\r
-/******************************************************************************\r
- * uiTracePortGetTimeStamp\r
- *\r
- * Returns the current time based on the HWTC macros which provide a hardware\r
- * isolation layer towards the hardware timer/counter.\r
- *\r
- * The HWTC macros and uiTracePortGetTimeStamp is the main porting issue\r
- * or the trace recorder library. Typically you should not need to change\r
- * the code of uiTracePortGetTimeStamp if using the HWTC macros.\r
- *\r
- * OFFER FROM PERCEPIO:\r
- * For silicon companies and non-corporate FreeRTOS users (researchers, students\r
- * , hobbyists or early-phase startups) we have an attractive offer: \r
- * Provide a hardware timer port and get a FREE single-user license for\r
- * FreeRTOS+Trace Professional Edition. Read more about this offer at \r
- * www.percepio.com or contact us directly at support@percepio.com.\r
- ******************************************************************************/\r
-void uiTracePortGetTimeStamp(uint32_t *pTimestamp)\r
-{\r
-    static uint32_t last_traceTickCount = 0;\r
-    static uint32_t last_hwtc_count = 0;\r
-    uint32_t traceTickCount = 0;\r
-    uint32_t hwtc_count = 0;\r
-    \r
-    /* Retrieve HWTC_COUNT only once since the same value should be used all throughout this function. */\r
-#if (HWTC_COUNT_DIRECTION == DIRECTION_INCREMENTING)\r
-    hwtc_count = HWTC_COUNT;\r
-#elif (HWTC_COUNT_DIRECTION == DIRECTION_DECREMENTING)\r
-    hwtc_count = HWTC_PERIOD - HWTC_COUNT;\r
-#else\r
-    Junk text to cause compiler error - HWTC_COUNT_DIRECTION is not set correctly!\r
-    Should be DIRECTION_INCREMENTING or DIRECTION_DECREMENTING\r
-#endif\r
-    \r
-    if (last_traceTickCount - uiTraceTickCount - 1 < 0x80000000)\r
-    {\r
-        /* This means last_traceTickCount is higher than uiTraceTickCount,\r
-        so we have previously compensated for a missed tick.\r
-        Therefore we use the last stored value because that is more accurate. */\r
-        traceTickCount = last_traceTickCount;\r
-    }\r
-    else\r
-    {\r
-        /* Business as usual */\r
-        traceTickCount = uiTraceTickCount;\r
-    }\r
-\r
-    /* Check for overflow. May occur if the update of uiTraceTickCount has been \r
-    delayed due to disabled interrupts. */\r
-    if (traceTickCount == last_traceTickCount && hwtc_count < last_hwtc_count)\r
-    {\r
-        /* A trace tick has occurred but not been executed by the kernel, so we compensate manually. */\r
-        traceTickCount++;\r
-    }\r
-    \r
-    /* Check if the return address is OK, then we perform the calculation. */\r
-    if (pTimestamp)\r
-    {\r
-        /* Get timestamp from trace ticks. Scale down the period to avoid unwanted overflows. */\r
-        *pTimestamp = traceTickCount * (HWTC_PERIOD / HWTC_DIVISOR);\r
-        /* Increase timestamp by (hwtc_count + "lost hardware ticks from scaling down period") / HWTC_DIVISOR. */\r
-        *pTimestamp += (hwtc_count + traceTickCount * (HWTC_PERIOD % HWTC_DIVISOR)) / HWTC_DIVISOR;\r
-    }\r
-    \r
-    /* Store the previous values. */\r
-    last_traceTickCount = traceTickCount;\r
-    last_hwtc_count = hwtc_count;\r
-}\r
-\r
-/*******************************************************************************\r
- * vTracePortEnd\r
- * \r
- * This function is called by the monitor when a recorder stop is detected.\r
- * This is used by the Win32 port to store the trace to a file. The file path is\r
- * set using vTracePortSetOutFile.\r
- ******************************************************************************/\r
-void vTracePortEnd()\r
-{\r
-    vTraceConsoleMessage("\n\r[FreeRTOS+Trace] Running vTracePortEnd.\n\r");\r
-\r
-    #if (WIN32_PORT_SAVE_WHEN_STOPPED == 1)\r
-    vTracePortSave();\r
-    #endif\r
-\r
-    #if (WIN32_PORT_EXIT_WHEN_STOPPED == 1)\r
-    /* In the FreeRTOS/Win32 demo, this allows for killing the application \r
-    when the recorder is stopped (e.g., when the buffer is full) */\r
-    system("pause");\r
-    exit(0);\r
-    #endif\r
-}\r
-\r
-#if (INCLUDE_SAVE_TO_FILE == 1)\r
-/*******************************************************************************\r
- * vTracePortSetOutFile\r
- *\r
- * Sets the filename/path used in vTracePortSave.\r
- * This is set in a separate function, since the Win32 port calls vTracePortSave\r
- * in vTracePortEnd if WIN32_PORT_SAVE_WHEN_STOPPED is set.\r
- ******************************************************************************/\r
-void vTracePortSetOutFile(char* path)\r
-{\r
-    prvFileName = path;\r
-}\r
-\r
-/*******************************************************************************\r
- * vTracePortSave\r
- *\r
- * Saves the trace to a file on a local file system. The path is set in a \r
- * separate function, vTracePortSetOutFile, since the Win32 port calls \r
- * vTracePortSave in vTracePortEnd if WIN32_PORT_SAVE_WHEN_STOPPED is set.\r
- ******************************************************************************/\r
-void vTracePortSave()\r
-{\r
-    char buf[180];\r
-    FILE* f;\r
-\r
-    if (prvFileName == NULL)\r
-    {\r
-        prvFileName = "FreeRTOSPlusTrace.dump";\r
-        sprintf(buf, "No filename specified, using default \"%s\".", prvFileName);\r
-        vTraceConsoleMessage(buf);\r
-    }\r
-\r
-    fopen_s(&f, prvFileName, "wb");\r
-    if (f)\r
-    {\r
-        fwrite(RecorderDataPtr, sizeof(RecorderDataType), 1, f);\r
-        fclose(f);\r
-        sprintf(buf, "\n\r[FreeRTOS+Trace] Saved in: %s\n\r", prvFileName);\r
-        vTraceConsoleMessage(buf);\r
-    }\r
-    else\r
-    {\r
-        sprintf(buf, "\n\r[FreeRTOS+Trace] Failed to write to output file!\n\r");\r
-        vTraceConsoleMessage(buf);\r
-    }\r
-}\r
-#endif\r
-#endif
\ No newline at end of file
index 2e4bc1aac9565056c1843d760ac55f0bb8b3de74..3f33cc00476d70caa34854167ba0649edb2a7e13 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
+ * Tracealyzer v2.4.1 Recorder Library\r
  * Percepio AB, www.percepio.com\r
  *\r
  * trcUser.c\r
@@ -9,44 +9,41 @@
  * Terms of Use\r
  * This software is copyright Percepio AB. The recorder library is free for\r
  * use together with Percepio products. You may distribute the recorder library\r
- * in its original form, including modifications in trcPort.c and trcPort.h\r
+ * in its original form, including modifications in trcHardwarePort.c/.h\r
  * given that these modification are clearly marked as your own modifications\r
- * and documented in the initial comment section of these source files. \r
- * This software is the intellectual property of Percepio AB and may not be \r
- * sold or in other ways commercially redistributed without explicit written \r
+ * and documented in the initial comment section of these source files.\r
+ * This software is the intellectual property of Percepio AB and may not be\r
+ * sold or in other ways commercially redistributed without explicit written\r
  * permission by Percepio AB.\r
  *\r
- * Disclaimer \r
- * The trace tool and recorder library is being delivered to you AS IS and \r
- * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
- * not and cannot warrant the performance or results you may obtain by using the \r
- * software or documentation. Percepio AB make no warranties, express or \r
- * implied, as to noninfringement of third party rights, merchantability, or \r
- * fitness for any particular purpose. In no event will Percepio AB, its \r
- * technology partners, or distributors be liable to you for any consequential, \r
- * incidental or special damages, including any lost profits or lost savings, \r
- * even if a representative of Percepio AB has been advised of the possibility \r
- * of such damages, or for any claim by any third party. Some jurisdictions do \r
- * not allow the exclusion or limitation of incidental, consequential or special \r
- * damages, or the exclusion of implied warranties or limitations on how long an \r
+ * Disclaimer\r
+ * The trace tool and recorder library is being delivered to you AS IS and\r
+ * Percepio AB makes no warranty as to its use or performance. Percepio AB does\r
+ * not and cannot warrant the performance or results you may obtain by using the\r
+ * software or documentation. Percepio AB make no warranties, express or\r
+ * implied, as to noninfringement of third party rights, merchantability, or\r
+ * fitness for any particular purpose. In no event will Percepio AB, its\r
+ * technology partners, or distributors be liable to you for any consequential,\r
+ * incidental or special damages, including any lost profits or lost savings,\r
+ * even if a representative of Percepio AB has been advised of the possibility\r
+ * of such damages, or for any claim by any third party. Some jurisdictions do\r
+ * not allow the exclusion or limitation of incidental, consequential or special\r
+ * damages, or the exclusion of implied warranties or limitations on how long an\r
  * implied warranty may last, so the above limitations may not apply to you.\r
  *\r
- * FreeRTOS+Trace is available as Free Edition and in two premium editions.\r
- * You may use the premium features during 30 days for evaluation.\r
- * Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/\r
- *\r
- * Copyright Percepio AB, 2012.\r
+ * Copyright Percepio AB, 2013.\r
  * www.percepio.com\r
  ******************************************************************************/\r
 \r
+#include "trcUser.h"\r
+\r
+#if (USE_TRACEALYZER_RECORDER == 1)\r
+\r
 #include <string.h>\r
 #include <stdarg.h>\r
+#include <stdint.h>\r
 \r
-#include "trcUser.h"\r
-#include "task.h"\r
-#include "semphr.h"\r
-\r
-#if (configUSE_TRACE_FACILITY == 1)\r
+TRACE_STOP_HOOK vTraceStopHookPtr = (TRACE_STOP_HOOK)0;\r
 \r
 extern uint8_t inExcludedTask;\r
 extern uint8_t nISRactive;\r
@@ -55,145 +52,104 @@ extern uint32_t dts_min;
 extern uint32_t hwtc_count_max_after_tick;\r
 extern uint32_t hwtc_count_sum_after_tick;\r
 extern uint32_t hwtc_count_sum_after_tick_counter;\r
-extern unsigned char ucQueueGetQueueType(void*);\r
-extern unsigned char ucQueueGetQueueNumber(void*);\r
 extern char* traceErrorMessage;\r
-static void vTraceMonitorTask(void);\r
-static void prvTraceExcludeOrIncludeKernelServiceFromTrace(traceKernelService, uint8_t);\r
-    \r
+\r
+/*** private functions *******************************************************/\r
+void vTracePrintF_Helper(traceLabel eventLabel, const char* formatStr, va_list vl);\r
+\r
+#if (USE_SEPARATE_USER_EVENT_BUFFER == 1)\r
+void vTraceChannelPrintF_Helper(UserEventChannel channelPair, va_list vl);\r
+static void prvTraceUserEventHelper1(UserEventChannel channel, traceLabel eventLabel, traceLabel formatLabel, va_list vl);\r
+static void prvTraceUserEventHelper2(UserEventChannel channel, uint32_t* data, uint32_t noOfSlots);\r
+#endif\r
+/*****************************************************************************/\r
+\r
+\r
+\r
 /*******************************************************************************\r
- * vTraceMonitorTask\r
+ * vTraceInitTraceData\r
  *\r
- * A task which periodically reports the recorder status to the console.\r
- * This is included depending on USE_TRACE_PROGRESS_MONITOR_TASK.\r
+ * Allocates, if necessary, and initializes the recorder data structure, based\r
+ * on the constants in trcConfig.h.\r
  ******************************************************************************/\r
-static void vTraceMonitorTask(void)\r
-{    \r
-    portTickType xNextWakeTime;\r
-    char localsprintbuffer[90];\r
-    char* err = NULL;    \r
-    char* lastErr = NULL;      \r
-    #define STATE_INIT 0\r
-    #define STATE_STARTED 1\r
-    #define STATE_STOPPED 2    \r
-    int state = STATE_INIT;\r
-    \r
-    vTraceConsoleMessage("\n\r[FreeRTOS+Trace] Monitor task started...\n\r");\r
-\r
-    /* Initialise xNextWakeTime - this only needs to be done once. */\r
-    xNextWakeTime = xTaskGetTickCount();\r
-\r
-    for (;;)\r
-    {\r
-        lastErr = err;        \r
-        err = xTraceGetLastError();\r
-        if (err != lastErr)\r
-        {\r
-            sprintf(localsprintbuffer, "\n\r[FreeRTOS+Trace] Error: %s\n\r", err);\r
-            vTraceConsoleMessage(localsprintbuffer); \r
-        }\r
-        \r
-        if (state == STATE_STOPPED || state == STATE_INIT) \r
-        {\r
-            if (RecorderDataPtr->recorderActive == 1)\r
-            {\r
-                state = STATE_STARTED;\r
-                vTraceConsoleMessage("\n\r[FreeRTOS+Trace] Recorder started.\n\r");                                       \r
-            }\r
-            else\r
-            {\r
-                if (state == STATE_INIT)\r
-                {\r
-                    \r
-                    vTraceConsoleMessage("\n\r[FreeRTOS+Trace] Recorder not started.\n\r");\r
-                    state = STATE_STOPPED;\r
-                }\r
-            }\r
-        }\r
-        \r
-        if (state == STATE_STARTED)\r
-        {\r
-            if (RecorderDataPtr->frequency > 0)\r
-            {\r
-                sprintf(localsprintbuffer, \r
-                    "\n\r[FreeRTOS+Trace] Event count: %d, Duration: %d ms. [%d ticks]\n\r", \r
-                    (int)RecorderDataPtr->numEvents, \r
-                    (int)(RecorderDataPtr->absTimeLastEventSecond*1000 + (RecorderDataPtr->absTimeLastEvent*1000)/ RecorderDataPtr->frequency), (int)xTaskGetTickCount());\r
-                vTraceConsoleMessage(localsprintbuffer);\r
-            }\r
-\r
-            if (RecorderDataPtr->recorderActive == 0)\r
-            {\r
-                state = STATE_STOPPED;\r
-                vTraceConsoleMessage("\n\r[FreeRTOS+Trace] Recorder stopped.\n\r");                                       \r
-                vTracePortEnd();\r
-            }\r
-                \r
-\r
-        }\r
+void vTraceInitTraceData(void)\r
+{\r
+       prvTraceInitTraceData();\r
+}\r
 \r
-    /* Place this task in the blocked state until it is time to run again. */\r
-        vTaskDelayUntil( &xNextWakeTime, TRACE_PROGRESS_MONITOR_TASK_PERIOD);\r
-        \r
-    }\r
+/*******************************************************************************\r
+ * vTraceSetRecorderData\r
+ *\r
+ * If custom allocation is used, this function must be called so the recorder\r
+ * library knows where to save the trace data.\r
+ ******************************************************************************/\r
+#if TRACE_DATA_ALLOCATION == TRACE_DATA_ALLOCATION_CUSTOM\r
+void vTraceSetRecorderData(void* pRecorderData)\r
+{\r
+       TRACE_ASSERT(pRecorderData != NULL, "vTraceSetTraceData, pRecorderData == NULL", );\r
+       RecorderDataPtr = pRecorderData;\r
 }\r
+#endif\r
 \r
 /*******************************************************************************\r
  * vTraceClear\r
  *\r
- * Resets the recorder. Only necessary if a restart is desired - this is not \r
+ * Resets the recorder. Only necessary if a restart is desired - this is not\r
  * needed in the startup initialization.\r
  ******************************************************************************/\r
 void vTraceClear(void)\r
 {\r
     trcCRITICAL_SECTION_BEGIN();\r
-    \r
+\r
     RecorderDataPtr->absTimeLastEvent = 0;\r
     RecorderDataPtr->nextFreeIndex = 0;\r
     RecorderDataPtr->numEvents = 0;\r
     RecorderDataPtr->bufferIsFull = 0;\r
 \r
     trcCRITICAL_SECTION_END();\r
-    \r
-}\r
 \r
-/*******************************************************************************\r
- * vTraceStartStatusMonitor\r
- *\r
- * This starts a task to monitor the state of½ the recorder. \r
- * This task periodically prints a line to the console window, which shows the \r
- * number of events recorded and the latest timestamp. This task\r
- * calls vTracePortEnd when the recorder has been stopped, where custom\r
- * actions can be added, e.g., to store the trace to a file\r
- * if a file system is available on the device.\r
- ******************************************************************************/\r
-void vTraceStartStatusMonitor(void)\r
-{    \r
-    vTraceConsoleMessage("\n\r[FreeRTOS+Trace] Starting Trace Status Monitor...\n\r");\r
-    (void)xTaskCreate( (pdTASK_CODE)vTraceMonitorTask, (const signed char*)"TraceMon", TRACE_PROGRESS_MONITOR_TASK_STACKSIZE, NULL, TRACE_PROGRESS_MONITOR_TASK_PRIORITY, NULL );\r
 }\r
 \r
 /*******************************************************************************\r
  * uiTraceStart\r
  *\r
  * Starts the recorder. The recorder will not be started if an error has been\r
- * indicated using vTraceError, e.g. if any of the Nx constants in trcConfig.h \r
+ * indicated using vTraceError, e.g. if any of the Nx constants in trcConfig.h\r
  * has a too small value (NTASK, NQUEUE, etc).\r
- * \r
+ *\r
  * Returns 1 if the recorder was started successfully.\r
- * Returns 0 if the recorder start was prevented due to a previous internal \r
+ * Returns 0 if the recorder start was prevented due to a previous internal\r
  * error. In that case, check vTraceGetLastError to get the error message.\r
- * Any error message is also presented when opening a trace file in \r
- * FreeRTOS+Trace v2.2.2 or later.\r
+ * Any error message is also presented when opening a trace file.\r
  ******************************************************************************/\r
 \r
 uint32_t uiTraceStart(void)\r
-{        \r
+{\r
+       objectHandleType handle = 0;\r
+\r
+       if (RecorderDataPtr == NULL)\r
+       {\r
+               vTraceError("RecorderDataPtr is NULL. Call vTraceInitTraceData() before starting trace.");\r
+               return 0;\r
+       }\r
     if (traceErrorMessage == NULL)\r
     {\r
         trcCRITICAL_SECTION_BEGIN();\r
         RecorderDataPtr->recorderActive = 1;\r
-        vTraceStoreTaskswitch(); /* Register the currently running task */\r
+\r
+               handle = TRACE_GET_TASK_NUMBER(TRACE_GET_CURRENT_TASK());\r
+               if (handle == 0)\r
+               {\r
+                       /* This occurs if the scheduler is not yet started.\r
+                       This creates a dummy "(startup)" task entry internally in the\r
+                       recorder */\r
+                       handle = xTraceGetObjectHandle(TRACE_CLASS_TASK);\r
+                       vTraceSetObjectName(TRACE_CLASS_TASK, handle, "(startup)");\r
+\r
+                       vTraceSetPriorityProperty(TRACE_CLASS_TASK, handle, 0);\r
+               }\r
+\r
+        vTraceStoreTaskswitch(handle); /* Register the currently running task */\r
         trcCRITICAL_SECTION_END();\r
     }\r
 \r
@@ -201,17 +157,17 @@ uint32_t uiTraceStart(void)
 }\r
 \r
 /*******************************************************************************\r
- * vTraceStart \r
+ * vTraceStart\r
  *\r
  * Starts the recorder. The recorder will not be started if an error has been\r
- * indicated using vTraceError, e.g. if any of the Nx constants in trcConfig.h \r
+ * indicated using vTraceError, e.g. if any of the Nx constants in trcConfig.h\r
  * has a too small value (NTASK, NQUEUE, etc).\r
- * \r
- * This function is obsolete, but has been saved for backwards compatibility. \r
+ *\r
+ * This function is obsolete, but has been saved for backwards compatibility.\r
  * We recommend using uiTraceStart instead.\r
  ******************************************************************************/\r
 void vTraceStart(void)\r
-{        \r
+{\r
     (void)uiTraceStart();\r
 }\r
 \r
@@ -219,11 +175,16 @@ void vTraceStart(void)
  * vTraceStop\r
  *\r
  * Stops the recorder. The recording can be resumed by calling vTraceStart.\r
- * This does not reset the recorder. Use vTraceClear is that is desired.\r
+ * This does not reset the recorder. Use vTraceClear if that is desired.\r
  ******************************************************************************/\r
 void vTraceStop(void)\r
 {\r
     RecorderDataPtr->recorderActive = 0;\r
+       \r
+       if (vTraceStopHookPtr != (TRACE_STOP_HOOK)0)\r
+       {\r
+               (*vTraceStopHookPtr)();                      /* Call an application level call back function. */\r
+       }\r
 }\r
 \r
 /*******************************************************************************\r
@@ -231,20 +192,19 @@ void vTraceStop(void)
  *\r
  * Gives the last error message, if any. NULL if no error message is stored.\r
  * The message is cleared on read.\r
- * Any error message is also presented when opening a trace file in \r
- * FreeRTOS+Trace v2.2.2 or later.\r
+ * Any error message is also presented when opening a trace file.\r
  ******************************************************************************/\r
 char* xTraceGetLastError(void)\r
-{   \r
-    return traceErrorMessage;\r
+{\r
+       return traceErrorMessage;\r
 }\r
 \r
 /*******************************************************************************\r
  * vTraceGetTraceBuffer\r
- * \r
- * Returns a pointer to the recorder data structure. Use this together with \r
- * uiTraceGetTraceBufferSize if you wish to implement an own store/upload \r
- * solution, e.g., in case a debugger connection is not available for uploading \r
+ *\r
+ * Returns a pointer to the recorder data structure. Use this together with\r
+ * uiTraceGetTraceBufferSize if you wish to implement an own store/upload\r
+ * solution, e.g., in case a debugger connection is not available for uploading\r
  * the data.\r
  ******************************************************************************/\r
 void* vTraceGetTraceBuffer(void)\r
@@ -254,9 +214,9 @@ void* vTraceGetTraceBuffer(void)
 \r
 /*******************************************************************************\r
  * uiTraceGetTraceBufferSize\r
- * \r
- * Gets the size of the recorder data structure. For use together with \r
- * vTraceGetTraceBuffer if you wish to implement an own store/upload solution, \r
+ *\r
+ * Gets the size of the recorder data structure. For use together with\r
+ * vTraceGetTraceBuffer if you wish to implement an own store/upload solution,\r
  * e.g., in case a debugger connection is not available for uploading the data.\r
  ******************************************************************************/\r
 uint32_t uiTraceGetTraceBufferSize(void)\r
@@ -264,396 +224,24 @@ uint32_t uiTraceGetTraceBufferSize(void)
     return sizeof(RecorderDataType);\r
 }\r
 \r
-/*******************************************************************************\r
- * prvTraceExcludeOrIncludeKernelServiceFromTrace\r
- * \r
- * Includes or excludes all events that is related to the kernel service.\r
- ******************************************************************************/\r
-static void prvTraceExcludeOrIncludeKernelServiceFromTrace(traceKernelService kernelService, uint8_t flag)\r
-{\r
-    switch(kernelService)\r
-    {\r
-    case TRACE_KERNEL_SERVICE_TASK_CREATE:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_CREATE + TRACE_CLASS_TASK);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_CREATE + TRACE_CLASS_TASK);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_CREATE + TRACE_CLASS_TASK);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_CREATE + TRACE_CLASS_TASK);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_TASK_DELETE:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_DELETE + TRACE_CLASS_TASK);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_DELETE + TRACE_CLASS_TASK);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_TASK_DELAY:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(TASK_DELAY);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(TASK_DELAY_UNTIL);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(TASK_DELAY);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(TASK_DELAY_UNTIL);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_PRIORITY_SET:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(TASK_PRIORITY_SET);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(TASK_PRIORITY_SET);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_TASK_SUSPEND:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(TASK_SUSPEND);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(TASK_SUSPEND);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_TASK_RESUME:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(TASK_RESUME);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(TASK_RESUME_FROM_ISR);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(TASK_RESUME);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(TASK_RESUME_FROM_ISR);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_QUEUE_CREATE:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_CREATE + TRACE_CLASS_QUEUE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_CREATE + TRACE_CLASS_QUEUE);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_CREATE + TRACE_CLASS_QUEUE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_CREATE + TRACE_CLASS_QUEUE);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_QUEUE_DELETE:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_DELETE + TRACE_CLASS_QUEUE);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_DELETE + TRACE_CLASS_QUEUE);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_QUEUE_SEND:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND + TRACE_CLASS_QUEUE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_SEND + TRACE_CLASS_QUEUE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_BLOCK_ON_SEND + TRACE_CLASS_QUEUE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_FROM_ISR + TRACE_CLASS_QUEUE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_SEND_FROM_ISR + TRACE_CLASS_QUEUE);\r
-            \r
-            \r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND + TRACE_CLASS_QUEUE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_SEND + TRACE_CLASS_QUEUE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_BLOCK_ON_SEND + TRACE_CLASS_QUEUE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_FROM_ISR + TRACE_CLASS_QUEUE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_SEND_FROM_ISR + TRACE_CLASS_QUEUE);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_QUEUE_RECEIVE:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE + TRACE_CLASS_QUEUE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_RECEIVE + TRACE_CLASS_QUEUE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_BLOCK_ON_RECEIVE + TRACE_CLASS_QUEUE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_FROM_ISR + TRACE_CLASS_QUEUE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_RECEIVE_FROM_ISR + TRACE_CLASS_QUEUE);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE + TRACE_CLASS_QUEUE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_RECEIVE + TRACE_CLASS_QUEUE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_BLOCK_ON_RECEIVE + TRACE_CLASS_QUEUE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_FROM_ISR + TRACE_CLASS_QUEUE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_RECEIVE_FROM_ISR + TRACE_CLASS_QUEUE);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_QUEUE_PEEK:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_PEEK + TRACE_CLASS_QUEUE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_PEEK + TRACE_CLASS_SEMAPHORE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_PEEK + TRACE_CLASS_MUTEX);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_PEEK + TRACE_CLASS_QUEUE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_PEEK + TRACE_CLASS_SEMAPHORE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_PEEK + TRACE_CLASS_MUTEX);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_MUTEX_CREATE:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_CREATE + TRACE_CLASS_MUTEX);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_CREATE + TRACE_CLASS_MUTEX);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_CREATE + TRACE_CLASS_MUTEX);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_CREATE + TRACE_CLASS_MUTEX);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_MUTEX_DELETE:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_DELETE + TRACE_CLASS_MUTEX);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_DELETE + TRACE_CLASS_MUTEX);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_MUTEX_GIVE:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND + TRACE_CLASS_MUTEX);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_SEND + TRACE_CLASS_MUTEX);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_BLOCK_ON_SEND + TRACE_CLASS_MUTEX);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_FROM_ISR + TRACE_CLASS_MUTEX);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_SEND_FROM_ISR + TRACE_CLASS_MUTEX);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND + TRACE_CLASS_MUTEX);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_SEND + TRACE_CLASS_MUTEX);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_BLOCK_ON_SEND + TRACE_CLASS_MUTEX);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_FROM_ISR + TRACE_CLASS_MUTEX);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_SEND_FROM_ISR + TRACE_CLASS_MUTEX);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_MUTEX_TAKE:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE + TRACE_CLASS_MUTEX);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_RECEIVE + TRACE_CLASS_MUTEX);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_BLOCK_ON_RECEIVE + TRACE_CLASS_MUTEX);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_FROM_ISR + TRACE_CLASS_MUTEX);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_RECEIVE_FROM_ISR + TRACE_CLASS_MUTEX);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE + TRACE_CLASS_MUTEX);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_RECEIVE + TRACE_CLASS_MUTEX);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_BLOCK_ON_RECEIVE + TRACE_CLASS_MUTEX);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_FROM_ISR + TRACE_CLASS_MUTEX);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_RECEIVE_FROM_ISR + TRACE_CLASS_MUTEX);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_SEMAPHORE_CREATE:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_CREATE + TRACE_CLASS_SEMAPHORE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_CREATE + TRACE_CLASS_SEMAPHORE);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_CREATE + TRACE_CLASS_SEMAPHORE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_CREATE + TRACE_CLASS_SEMAPHORE);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_SEMAPHORE_DELETE:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_DELETE + TRACE_CLASS_SEMAPHORE);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_DELETE + TRACE_CLASS_SEMAPHORE);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_SEMAPHORE_GIVE:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND + TRACE_CLASS_SEMAPHORE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_SEND + TRACE_CLASS_SEMAPHORE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_BLOCK_ON_SEND + TRACE_CLASS_SEMAPHORE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_FROM_ISR + TRACE_CLASS_SEMAPHORE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_SEND_FROM_ISR + TRACE_CLASS_SEMAPHORE);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND + TRACE_CLASS_SEMAPHORE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_SEND + TRACE_CLASS_SEMAPHORE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_BLOCK_ON_SEND + TRACE_CLASS_SEMAPHORE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_SEND_FROM_ISR + TRACE_CLASS_SEMAPHORE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_SEND_FROM_ISR + TRACE_CLASS_SEMAPHORE);\r
-        }\r
-        break;\r
-    case TRACE_KERNEL_SERVICE_SEMAPHORE_TAKE:\r
-        if (flag)\r
-        {\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE + TRACE_CLASS_SEMAPHORE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_RECEIVE + TRACE_CLASS_SEMAPHORE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_BLOCK_ON_RECEIVE + TRACE_CLASS_SEMAPHORE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_FROM_ISR + TRACE_CLASS_SEMAPHORE);\r
-            SET_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_RECEIVE_FROM_ISR + TRACE_CLASS_SEMAPHORE);\r
-        }\r
-        else\r
-        {\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE + TRACE_CLASS_SEMAPHORE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_RECEIVE + TRACE_CLASS_SEMAPHORE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_BLOCK_ON_RECEIVE + TRACE_CLASS_SEMAPHORE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_RECEIVE_FROM_ISR + TRACE_CLASS_SEMAPHORE);\r
-            CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(EVENTGROUP_FAILED_RECEIVE_FROM_ISR + TRACE_CLASS_SEMAPHORE);\r
-        }\r
-        break;\r
-    }\r
-}\r
-\r
-/******************************************************************************\r
- * vTraceExclude______FromTrace\r
- *\r
- * Excludes a task or object from the trace.\r
- * This can be useful if some irrelevant task is very frequent and is "eating\r
- * up the buffer". This should be called after the task has been created, but \r
- * before starting the FreeRTOS scheduler.\r
- *****************************************************************************/\r
-void vTraceExcludeQueueFromTrace(void* handle)\r
-{\r
-    SET_QUEUE_FLAG_ISEXCLUDED(ucQueueGetQueueNumber(handle));\r
-}\r
-\r
-void vTraceExcludeSemaphoreFromTrace(void* handle)\r
-{\r
-    SET_SEMAPHORE_FLAG_ISEXCLUDED(ucQueueGetQueueNumber(handle));\r
-}\r
-\r
-void vTraceExcludeMutexFromTrace(void* handle)\r
-{\r
-    SET_MUTEX_FLAG_ISEXCLUDED(ucQueueGetQueueNumber(handle));\r
-}\r
-\r
-void vTraceExcludeTaskFromTrace(void* handle)\r
-{\r
-    SET_TASK_FLAG_ISEXCLUDED(uxTaskGetTaskNumber(handle));\r
-}\r
-\r
-void vTraceExcludeKernelServiceFromTrace(traceKernelService kernelService)\r
-{\r
-    prvTraceExcludeOrIncludeKernelServiceFromTrace(kernelService, 1);\r
-}\r
-\r
-/******************************************************************************\r
- * vTraceInclude______InTrace\r
- *\r
- * Includes a task, object or kernel service in the trace. This is only\r
- * necessary if the task or object has been previously exluded.\r
- *****************************************************************************/\r
-void vTraceIncludeQueueInTrace(void* handle)\r
-{\r
-    CLEAR_QUEUE_FLAG_ISEXCLUDED(ucQueueGetQueueNumber(handle));\r
-}\r
-\r
-void vTraceIncludeSemaphoreInTrace(void* handle)\r
-{\r
-    CLEAR_SEMAPHORE_FLAG_ISEXCLUDED(ucQueueGetQueueNumber(handle));\r
-}\r
-\r
-void vTraceIncludeMutexInTrace(void* handle)\r
-{\r
-    CLEAR_MUTEX_FLAG_ISEXCLUDED(ucQueueGetQueueNumber(handle));\r
-}\r
-\r
-void vTraceIncludeTaskInTrace(void* handle)\r
-{\r
-    CLEAR_TASK_FLAG_ISEXCLUDED(uxTaskGetTaskNumber(handle));\r
-}\r
-\r
-void vTraceIncludeKernelServiceInTrace(traceKernelService kernelService)\r
-{\r
-    prvTraceExcludeOrIncludeKernelServiceFromTrace(kernelService, 0);\r
-}\r
-\r
-/*******************************************************************************\r
- * vTraceSetQueueName\r
- *\r
- * Assigns a name to a FreeRTOS Queue, Semaphore or Mutex. This function should\r
- * be called right after creation of the queue/mutex/semaphore. If not using \r
- * this function, the queues/mutexes/semaphores will be presented by their\r
- * numeric handle only.\r
- *\r
- * Example:\r
- *     actuatorQ = xQueueCreate(3, sizeof(QueueMessage));\r
- *     vTraceSetQueueName(actuatorQ, "ActuatorQueue");\r
- ******************************************************************************/\r
-void vTraceSetQueueName(void* queue, const char* name)\r
-{\r
-    int t = ucQueueGetQueueType(queue);    \r
-    vTraceSetObjectName(TraceObjectClassTable[t], \r
-                        (objectHandleType)ucQueueGetQueueNumber(queue), name);\r
-}\r
-\r
-\r
 /******************************************************************************\r
  * vTraceTaskInstanceIsFinished\r
- * \r
- * This defines an explicit Instance Finish Event for the current task. It tells \r
- * the recorder that the current instance of this task is finished at the next \r
- * kernel call of the task, e.g., a taskDelay or a queue receive. This function \r
- * should be called right before the api function call considered to be the end \r
- * of the current task instance, i.e., the Instance Finish Event.\r
+ *\r
+ * This defines an explicit Instance Finish Event for the current task. It tells\r
+ * the recorder that the current instance of this task is finished at the \r
+ * context-switch. This function should be called right before the API function \r
+ * call considered to be the Instance Finish Event.\r
  *****************************************************************************/\r
 void vTraceTaskInstanceIsFinished()\r
 {\r
     if (handle_of_last_logged_task)\r
     {\r
-        SET_TASK_FLAG_MARKIFE(handle_of_last_logged_task);    \r
-    }\r
-}\r
-\r
-/*******************************************************************************\r
- * vvTraceTaskSkipDefaultInstanceFinishedEvents\r
- *\r
- * This is useful if there are implicit Instance Finish Events, such as \r
- * vTaskDelayUntil or xQueueReceive, in a task where an explicit Instance Finish \r
- * Event has been defined. This function tells the recorder that only the \r
- * explicitly defined functions, using vTraceTaskInstanceIsFinished, should be\r
- * treated as Instance Finish Events for this task. The implicit Instance Finish \r
- * Events are thus disregarded for the calling task.\r
- ******************************************************************************/\r
-void vTraceTaskSkipDefaultInstanceFinishedEvents()\r
-{    \r
-    if (handle_of_last_logged_task)\r
-    {\r
-        PROPERTY_TASK_IFE_SERVICECODE(handle_of_last_logged_task) = \r
-          RESERVED_DUMMY_CODE;\r
+               TRACE_PROPERTY_OBJECT_STATE(TRACE_CLASS_TASK, handle_of_last_logged_task) = 0;\r
     }\r
 }\r
 \r
 /*******************************************************************************\r
- * Interrupt recording functions \r
+ * Interrupt recording functions\r
  ******************************************************************************/\r
 \r
 #if (INCLUDE_ISR_TRACING == 1)\r
@@ -663,10 +251,10 @@ static uint8_t isrstack[MAX_ISR_NESTING];
 \r
 /*******************************************************************************\r
  * vTraceSetISRProperties\r
- * \r
+ *\r
  * Registers an Interrupt Service Routine in the recorder library, This must be\r
- * called before using vTraceStoreISRBegin to store ISR events. This is \r
- * typically called in the startup of the system, before the scheduler is \r
+ * called before using vTraceStoreISRBegin to store ISR events. This is\r
+ * typically called in the startup of the system, before the scheduler is\r
  * started.\r
  *\r
  * Example:\r
@@ -682,23 +270,25 @@ static uint8_t isrstack[MAX_ISR_NESTING];
  *         vTraceStoreISREnd();\r
  *     }\r
  *\r
- * NOTE: To safely record ISRs, you need to make sure that all traced \r
- * interrupts actually are disabled by trcCRITICAL_SECTION_BEGIN(), which \r
- * typically is mapped to portENTER_CRITICAL(), which uses the macro \r
- * portDISABLE_INTERRUPTS. However, in some ports of FreeRTOS and depending on \r
- * FreeRTOS configuration, this does not disable high priority interrupts!\r
+ * NOTE: To safely record ISRs, you need to make sure that all traced\r
+ * interrupts actually are disabled by trcCRITICAL_SECTION_BEGIN(). However,\r
+ * in some ports this does not disable high priority interrupts!\r
  * If an ISR calls vTraceStoreISRBegin while the recorder is busy, it will\r
  * stop the recording and give an error message.\r
  ******************************************************************************/\r
 void vTraceSetISRProperties(objectHandleType handle, const char* name, char priority)\r
 {\r
+       TRACE_ASSERT(handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[TRACE_CLASS_ISR], "vTraceSetISRProperties: Invalid value for handle", );\r
+       TRACE_ASSERT(name != NULL, "vTraceSetISRProperties: name == NULL", );\r
+       TRACE_ASSERT(priority >= 0, "vTraceSetISRProperties: Invalid value for priority", );\r
+\r
     vTraceSetObjectName(TRACE_CLASS_ISR, handle, name);\r
     vTraceSetPriorityProperty(TRACE_CLASS_ISR, handle, priority);\r
 }\r
 \r
 /*******************************************************************************\r
  * vTraceStoreISRBegin\r
- * \r
+ *\r
  * Registers the beginning of an Interrupt Service Routine.\r
  *\r
  * Example:\r
@@ -714,13 +304,10 @@ void vTraceSetISRProperties(objectHandleType handle, const char* name, char prio
  *         vTraceStoreISREnd();\r
  *     }\r
  *\r
- * NOTE: You need to make sure that any traced interrupts actually are \r
- * disabled by trcCRITICAL_SECTION_BEGIN(), i.e., taskENTER_CRITICAL() which\r
- * uses portDISABLE_INTERRUPTS(). \r
- * In some ports of FreeRTOS, this does not disable high-priority interrupts,\r
- * i.e., with priorities above configMAX_SYSCALL_INTERRUPT_PRIORITY.\r
+ * NOTE: You need to make sure that any traced interrupts actually are\r
+ * disabled by trcCRITICAL_SECTION_BEGIN().\r
  * If an invalid call to vTraceStoreISRBegin is detected (i.e., that preempted\r
- * a critical section of the recorder) this will generate a recorder error \r
+ * a critical section of the recorder) this will generate a recorder error\r
  * using vTraceError.\r
  ******************************************************************************/\r
 void vTraceStoreISRBegin(objectHandleType handle)\r
@@ -728,55 +315,57 @@ void vTraceStoreISRBegin(objectHandleType handle)
     uint16_t dts4;\r
     TSEvent* ts = NULL;\r
 \r
+    TRACE_ASSERT(handle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[TRACE_CLASS_ISR], "vTraceStoreISRBegin: Invalid value for handle", );\r
+\r
     if (recorder_busy)\r
     {\r
-      vTraceError("Illegal call to vTraceStoreISRBegin/End");\r
+      vTraceError("Illegal call to vTraceStoreISRBegin, recorder busy!");\r
       return;\r
     }\r
     if (RecorderDataPtr->recorderActive && handle_of_last_logged_task)\r
-    {    \r
+    {\r
         trcCRITICAL_SECTION_BEGIN();\r
         dts4 = (uint16_t)prvTraceGetDTS(0xFFFF);\r
 \r
-        if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */    \r
-        {    \r
+        if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */\r
+        {\r
 \r
             if (nISRactive < MAX_ISR_NESTING)\r
-            {    \r
+            {\r
                 isrstack[nISRactive] = handle;\r
-                nISRactive++;            \r
+                nISRactive++;\r
                 ts = (TSEvent*)xTraceNextFreeEventBufferSlot();\r
                 if (ts != NULL)\r
                 {\r
                     ts->type = TS_ISR_BEGIN;\r
                     ts->dts = dts4;\r
                     ts->objHandle = handle;\r
-                    prvTraceUpdateCounters();                \r
+                    prvTraceUpdateCounters();\r
                 }\r
             }\r
             else\r
-            {            \r
-                /* This should not occur unless something is very wrong */            \r
+            {\r
+                /* This should not occur unless something is very wrong */\r
                 vTraceError("Too many nested interrupts!");\r
-            }        \r
+            }\r
         }\r
-        trcCRITICAL_SECTION_END();        \r
+        trcCRITICAL_SECTION_END();\r
     }\r
 }\r
 \r
 \r
 #if (SELECTED_PORT == PORT_ARM_CortexM)\r
 \r
-int tailchain_irq_pending(void);\r
+static int tailchain_irq_pending(void);\r
 \r
 /*******************************************************************************\r
  * tailchain_irq_pending\r
  *\r
- * For Cortex-M chips only. Returns 1 if an interrupt is pending, by checking \r
- * the 8 NVIC IRQ pend registers at 0xE000E200 to 0xE000E21C. Returns 0 if no \r
+ * For Cortex-M chips only. Returns 1 if an interrupt is pending, by checking\r
+ * the 8 NVIC IRQ pend registers at 0xE000E200 to 0xE000E21C. Returns 0 if no\r
  * interrupt is pending. This is used to predict tailchaining of ISRs.\r
  ******************************************************************************/\r
-int tailchain_irq_pending(void)\r
+static int tailchain_irq_pending(void)\r
 {\r
   uint32_t* pend_reg = ((uint32_t*)0xE000E200);\r
   int i;\r
@@ -788,15 +377,15 @@ int tailchain_irq_pending(void)
       return 1;\r
     }\r
   }\r
-  return 0;  \r
+  return 0;\r
 }\r
 \r
 #endif\r
 \r
 /*******************************************************************************\r
  * vTraceStoreISREnd\r
- * \r
- * Registers the end of an Interrupt Service Routine. \r
+ *\r
+ * Registers the end of an Interrupt Service Routine.\r
  *\r
  * Example:\r
  *     #define ID_ISR_TIMER1 1       // lowest valid ID is 1\r
@@ -811,13 +400,10 @@ int tailchain_irq_pending(void)
  *         vTraceStoreISREnd();\r
  *     }\r
  *\r
- * NOTE: You need to make sure that any traced interrupts actually are \r
- * disabled by trcCRITICAL_SECTION_BEGIN(), i.e., taskENTER_CRITICAL() which\r
- * uses portDISABLE_INTERRUPTS(). \r
- * In some ports of FreeRTOS, this does not disable high-priority interrupts,\r
- * i.e., with priorities above configMAX_SYSCALL_INTERRUPT_PRIORITY.\r
+ * NOTE: You need to make sure that any traced interrupts actually are\r
+ * disabled by trcCRITICAL_SECTION_BEGIN().\r
  * If an invalid call to vTraceStoreISREnd is detected (i.e., that preempted\r
- * a critical section of the recorder) this will generate a recorder error \r
+ * a critical section of the recorder) this will generate a recorder error\r
  * using vTraceError.\r
  ******************************************************************************/\r
 void vTraceStoreISREnd(void)\r
@@ -827,28 +413,28 @@ void vTraceStoreISREnd(void)
 \r
     if (recorder_busy)\r
     {\r
-      vTraceError("Illegal call to vTraceStoreISRBegin/End");\r
+      vTraceError("Illegal call to vTraceStoreISREnd, recorder busy!");\r
       return;\r
     }\r
-    \r
+\r
     if (RecorderDataPtr->recorderActive && handle_of_last_logged_task)\r
     {\r
         #if (SELECTED_PORT == PORT_ARM_CortexM)\r
         if (tailchain_irq_pending() > 0)\r
         {\r
-            nISRactive--; /* If an IRQ strikes exactly here, the resulting \r
-            ISR tailchaining is not detected. The trace instead shows a very \r
+            nISRactive--; /* If an IRQ strikes exactly here, the resulting\r
+            ISR tailchaining is not detected. The trace instead shows a very\r
             short fragment of the earlier preempted task/ISR, and then the new\r
             ISR begins. */\r
             return;\r
         }\r
         #endif\r
-      \r
+\r
         trcCRITICAL_SECTION_BEGIN();\r
         dts5 = (uint16_t)prvTraceGetDTS(0xFFFF);\r
 \r
-        if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */    \r
-        {    \r
+        if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */\r
+        {\r
             ts = (TSEvent*)xTraceNextFreeEventBufferSlot();\r
             if (ts != NULL)\r
             {\r
@@ -869,7 +455,7 @@ void vTraceStoreISREnd(void)
                 prvTraceUpdateCounters();\r
             }\r
         }\r
-        trcCRITICAL_SECTION_END();        \r
+        trcCRITICAL_SECTION_END();\r
     }\r
 }\r
 \r
@@ -882,7 +468,7 @@ void vTraceIncreaseISRActive(void)
         nISRactive++;\r
 }\r
 \r
-void vTraceDecreaseISRActive(objectHandleType handle)\r
+void vTraceDecreaseISRActive(void)\r
 {\r
     if (RecorderDataPtr->recorderActive && handle_of_last_logged_task)\r
         nISRactive--;\r
@@ -896,59 +482,12 @@ void vTraceDecreaseISRActive(objectHandleType handle)
 \r
 #if (INCLUDE_USER_EVENTS == 1)\r
 \r
- /******************************************************************************\r
- * vTraceUserEvent\r
- *\r
- * Basic user event (Standard and Professional Edition only)\r
- * \r
- * Generates a User Event with a text label. The label is created/looked up\r
- * in the symbol table using xTraceOpenLabel.\r
- ******************************************************************************/\r
-void vTraceUserEvent(traceLabel eventLabel)\r
-{\r
-    UserEvent* ue;\r
-    uint8_t dts1;\r
-\r
-    if (RecorderDataPtr->recorderActive && (! inExcludedTask || nISRactive ) && handle_of_last_logged_task)\r
-    {\r
-        trcCRITICAL_SECTION_BEGIN();\r
-\r
-        dts1 = (uint8_t)prvTraceGetDTS(0xFF);\r
-\r
-        if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */    \r
-        {       \r
-            ue = (UserEvent*) xTraceNextFreeEventBufferSlot();\r
-            if (ue != NULL)\r
-            {\r
-                ue->dts = dts1;\r
-                ue->type = USER_EVENT;\r
-                ue->payload = eventLabel;\r
-                prvTraceUpdateCounters();\r
-            }\r
-        }\r
-        trcCRITICAL_SECTION_END();        \r
-    }\r
-}\r
-\r
-/*** Locally used in vTracePrintF ***/\r
-\r
-/* one word (32 bit) is required for the USER_EVENT entry, 8 words \r
-(8*32 bit = 32 byte) available for argument data */\r
-#define MAX_ARG_SIZE (4+32)    \r
-\r
-static uint8_t writeInt8(void * buffer, uint8_t i, uint8_t value);\r
-static uint8_t writeInt16(void * buffer, uint8_t i, uint16_t value);\r
-static uint8_t writeInt32(void * buffer, uint8_t i, uint32_t value);\r
-\r
-#if (INCLUDE_FLOAT_SUPPORT)\r
-static uint8_t writeFloat(void * buffer, uint8_t i, float value);\r
-static uint8_t writeDouble(void * buffer, uint8_t i, double value);\r
-#endif\r
-\r
+#define MAX_ARG_SIZE (4+32)\r
 /*** Locally used in vTracePrintF ***/\r
 static uint8_t writeInt8(void * buffer, uint8_t i, uint8_t value)\r
-{    \r
-    \r
+{\r
+       TRACE_ASSERT(buffer != NULL, "writeInt8: buffer == NULL", 0);\r
+\r
     if (i >= MAX_ARG_SIZE)\r
     {\r
         return 255;\r
@@ -966,7 +505,9 @@ static uint8_t writeInt8(void * buffer, uint8_t i, uint8_t value)
 \r
 /*** Locally used in vTracePrintF ***/\r
 static uint8_t writeInt16(void * buffer, uint8_t i, uint16_t value)\r
-{      \r
+{\r
+       TRACE_ASSERT(buffer != NULL, "writeInt16: buffer == NULL", 0);\r
+\r
     /* Align to multiple of 2 */\r
     while ((i % 2) != 0)\r
     {\r
@@ -974,11 +515,11 @@ static uint8_t writeInt16(void * buffer, uint8_t i, uint16_t value)
                {\r
                        return 255;\r
                }\r
-                       \r
+\r
         ((uint8_t*)buffer)[i] = 0;\r
-        i++;        \r
+        i++;\r
     }\r
-    \r
+\r
     if (i + 2 > MAX_ARG_SIZE)\r
     {\r
         return 255;\r
@@ -992,7 +533,8 @@ static uint8_t writeInt16(void * buffer, uint8_t i, uint16_t value)
 /*** Locally used in vTracePrintF ***/\r
 static uint8_t writeInt32(void * buffer, uint8_t i, uint32_t value)\r
 {\r
-    \r
+       TRACE_ASSERT(buffer != NULL, "writeInt32: buffer == NULL", 0);\r
+\r
     /* A 32 bit value should begin at an even 4-byte address */\r
     while ((i % 4) != 0)\r
     {\r
@@ -1000,15 +542,15 @@ static uint8_t writeInt32(void * buffer, uint8_t i, uint32_t value)
                {\r
                        return 255;\r
                }\r
-               \r
+\r
         ((uint8_t*)buffer)[i] = 0;\r
         i++;\r
     }\r
-    \r
+\r
     if (i + 4 > MAX_ARG_SIZE)\r
     {\r
         return 255;\r
-    }        \r
+    }\r
 \r
     ((uint32_t*)buffer)[i/4] = value;\r
 \r
@@ -1020,6 +562,8 @@ static uint8_t writeInt32(void * buffer, uint8_t i, uint32_t value)
 /*** Locally used in vTracePrintF ***/\r
 static uint8_t writeFloat(void * buffer, uint8_t i, float value)\r
 {\r
+       TRACE_ASSERT(buffer != NULL, "writeFloat: buffer == NULL", 0);\r
+\r
     /* A 32 bit value should begin at an even 4-byte address */\r
     while ((i % 4) != 0)\r
     {\r
@@ -1035,19 +579,21 @@ static uint8_t writeFloat(void * buffer, uint8_t i, float value)
     if (i + 4 > MAX_ARG_SIZE)\r
     {\r
         return 255;\r
-    }        \r
+    }\r
 \r
     ((float*)buffer)[i/4] = value;\r
-    \r
+\r
     return i + 4;\r
 }\r
 \r
 /*** Locally used in vTracePrintF ***/\r
 static uint8_t writeDouble(void * buffer, uint8_t i, double value)\r
 {\r
+       TRACE_ASSERT(buffer != NULL, "writeDouble: buffer == NULL", 0);\r
+\r
     uint32_t * dest = buffer;\r
     uint32_t * src = (void*)&value;\r
-    /* The double is written as two 32 bit values, and should begin at an even \r
+    /* The double is written as two 32 bit values, and should begin at an even\r
     4-byte address (to avoid having to align with 8 byte) */\r
     while (i % 4 != 0)\r
     {\r
@@ -1057,50 +603,400 @@ static uint8_t writeDouble(void * buffer, uint8_t i, double value)
                }\r
 \r
         ((uint8_t*)buffer)[i] = 0;\r
-        i++;        \r
+        i++;\r
     }\r
-    \r
+\r
     if (i + 8 > MAX_ARG_SIZE)\r
     {\r
         return 255;\r
-    }       \r
-    \r
+    }\r
+\r
     dest[i/4+0] = src[0];\r
     dest[i/4+1] = src[1];\r
-    \r
+\r
     return i + 8;\r
 }\r
 \r
 #endif\r
 \r
+/*******************************************************************************\r
+ * prvTraceUserEventFormat\r
+ *\r
+ * Parses the format string and stores the arguments in the buffer.\r
+ ******************************************************************************/\r
+static uint8_t prvTraceUserEventFormat(const char* formatStr, va_list vl, uint8_t* buffer, uint8_t byteOffset)\r
+{\r
+       uint16_t formatStrIndex = 0;\r
+       uint8_t argCounter = 0;\r
+       uint8_t i = byteOffset;\r
+\r
+       while (formatStr[formatStrIndex] != '\0')\r
+    {\r
+        if (formatStr[formatStrIndex] == '%')\r
+        {\r
+            argCounter++;\r
+\r
+            if (argCounter > 15)\r
+            {\r
+                vTraceError("vTracePrintF - Too many arguments, max 15 allowed!");\r
+                return 0;\r
+            }\r
+\r
+/*******************************************************************************\r
+* These below code writes raw data (primitive datatypes) in the event buffer,\r
+* instead of the normal event structs (where byte 0 is event type).\r
+* These data entries must never be interpreted as real event data, as the type\r
+* field would be misleading since used for payload data.\r
+*\r
+* The correctness of this encoding depends on two mechanisms:\r
+*\r
+* 1. An initial USER_EVENT, which type code tells the number of 32-bit data\r
+* entires that follows. (code - USER_EVENT = number of data entries).\r
+* Note that a data entry corresponds to the slots that normally corresponds to\r
+* one (1) event, i.e., 32 bits. vTracePrintF may encode several pieces of data\r
+* in one data entry, e.g., two 16-bit values or four 8-bit values, one 16-bit\r
+* value followed by two 8-bit values, etc.\r
+*\r
+* 2. A two-phase commit procedure, where the USER_EVENT and data entries are\r
+* written to a local buffer at first, and when all checks are OK then copied to\r
+* the main event buffer using a fast memcpy. The event code is finalized as the\r
+* very last step. Before that step, the event code indicates an unfinished\r
+* event, which causes it to be ignored and stop the loading of the file (since\r
+* an unfinished event is the last event in the trace).\r
+*******************************************************************************/\r
+            formatStrIndex++;\r
+\r
+                       while ((formatStr[formatStrIndex] >= '0' && formatStr[formatStrIndex] <= '9') || formatStr[formatStrIndex] == '#' || formatStr[formatStrIndex] == '.')\r
+                               formatStrIndex++;\r
+\r
+                       if (formatStr[formatStrIndex] != '\0')\r
+                       {\r
+                               switch (formatStr[formatStrIndex])\r
+                               {\r
+                               case 'd':    i = writeInt32(buffer,\r
+                                                                                               i,\r
+                                                                                               (uint32_t)va_arg(vl, uint32_t));\r
+                                                               break;\r
+                               case 'x':\r
+                               case 'X':\r
+                               case 'u':    i = writeInt32(buffer,\r
+                                                                                               i,\r
+                                                                                               (uint32_t)va_arg(vl, uint32_t));\r
+                                                               break;\r
+                               case 's':    i = writeInt16(buffer,\r
+                                                                                               i,\r
+                                                                                               (uint16_t)xTraceOpenLabel((char*)va_arg(vl, char*)));\r
+                                                               break;\r
+\r
+#if (INCLUDE_FLOAT_SUPPORT)\r
+                                                               /* Yes, "double" as type also in the float\r
+                                                               case. This since "float" is promoted into "double"\r
+                                                               by the va_arg stuff. */\r
+                               case 'f':    i = writeFloat(buffer,\r
+                                                                                               i,\r
+                                                                                               (float)va_arg(vl, double));\r
+                                                               break;\r
+#else\r
+       /* No support for floats, but attempt to store a float user event\r
+       avoid a possible crash due to float reference. Instead store the\r
+       data on uint_32 format (will not be displayed anyway). This is just\r
+       to keep va_arg and i consistent. */\r
+\r
+                               case 'f':    i = writeInt32(buffer,\r
+                                                                                               i,\r
+                                                                                               (uint32_t)va_arg(vl, double));\r
+                                                               break;\r
+#endif\r
+                               case 'l':\r
+                                       formatStrIndex++;\r
+                                       switch (formatStr[formatStrIndex])\r
+                                       {\r
+#if (INCLUDE_FLOAT_SUPPORT)\r
+                                       case 'f':     i = writeDouble(buffer,\r
+                                                                                                               i,\r
+                                                                                                               (double)va_arg(vl, double));\r
+                                                               break;\r
+#else\r
+       /* No support for floats, but attempt to store a float user event\r
+       avoid a possible crash due to float reference. Instead store the\r
+       data on uint_32 format (will not be displayed anyway). This is just\r
+       to keep va_arg and i consistent. */\r
+                                       case 'f':    i = writeInt32(buffer, /* In this case, the value will not be shown anyway */\r
+                                                                                                       i,\r
+                                                                                                       (uint32_t)va_arg(vl, double));\r
+                                                                       i = writeInt32(buffer, /* Do it twice, to write in total 8 bytes */\r
+                                                                                                       i,\r
+                                                                                                       (uint32_t)va_arg(vl, double));\r
+                                                               break;\r
+#endif\r
+\r
+                                       }\r
+                                       break;\r
+                               case 'h':\r
+                                       formatStrIndex++;\r
+                                       switch (formatStr[formatStrIndex])\r
+                                       {\r
+                                       case 'd':    i = writeInt16(buffer,\r
+                                                                                                       i,\r
+                                                                                                       (uint16_t)va_arg(vl, uint32_t));\r
+                                                                       break;\r
+                                       case 'u':    i = writeInt16(buffer,\r
+                                                                                                       i,\r
+                                                                                                       (uint16_t)va_arg(vl, uint32_t));\r
+                                                                       break;\r
+                                       }\r
+                                       break;\r
+                               case 'b':\r
+                                       formatStrIndex++;\r
+                                       switch (formatStr[formatStrIndex])\r
+                                       {\r
+                                       case 'd':    i = writeInt8(buffer,\r
+                                                                                                       i,\r
+                                                                                                       (uint8_t)va_arg(vl, uint32_t));\r
+                                                                       break;\r
+                                       case 'u':    i = writeInt8(buffer,\r
+                                                                                                       i,\r
+                                                                                                       (uint8_t)va_arg(vl, uint32_t));\r
+                                                                       break;\r
+                                       }\r
+                                       break;\r
+                               }\r
+                       }\r
+                       else\r
+                               break;\r
+        }\r
+        formatStrIndex++;\r
+        if (i == 255)\r
+        {\r
+            vTraceError("vTracePrintF - Too large arguments, max 32 byte allowed!");\r
+            return 0;\r
+        }\r
+    }\r
+       return (i+3)/4;\r
+}\r
+\r
+#if (USE_SEPARATE_USER_EVENT_BUFFER == 1)\r
+\r
+/*******************************************************************************\r
+ * prvTraceClearChannelBuffer\r
+ *\r
+ * Clears a number of items in the channel buffer, starting from nextSlotToWrite.\r
+ ******************************************************************************/\r
+static void prvTraceClearChannelBuffer(uint32_t count)\r
+{\r
+       uint32_t slots;\r
+\r
+       TRACE_ASSERT(USER_EVENT_BUFFER_SIZE >= count, "prvTraceClearChannelBuffer: USER_EVENT_BUFFER_SIZE is too small to handle this event.", );\r
+\r
+       /* Check if we're close to the end of the buffer */\r
+       if (RecorderDataPtr->userEventBuffer.nextSlotToWrite + count > USER_EVENT_BUFFER_SIZE)\r
+       {\r
+               slots = USER_EVENT_BUFFER_SIZE - RecorderDataPtr->userEventBuffer.nextSlotToWrite; /* Number of slots before end of buffer */\r
+               (void)memset(&RecorderDataPtr->userEventBuffer.channelBuffer[RecorderDataPtr->userEventBuffer.nextSlotToWrite], 0, slots);\r
+               (void)memset(&RecorderDataPtr->userEventBuffer.channelBuffer[0], 0, (count - slots));\r
+       }\r
+       else\r
+               (void)memset(&RecorderDataPtr->userEventBuffer.channelBuffer[RecorderDataPtr->userEventBuffer.nextSlotToWrite], 0, count);\r
+}\r
+\r
+/*******************************************************************************\r
+ * prvTraceCopyToDataBuffer\r
+ *\r
+ * Copies a number of items to the data buffer, starting from nextSlotToWrite.\r
+ ******************************************************************************/\r
+static void prvTraceCopyToDataBuffer(uint32_t* data, uint32_t count)\r
+{\r
+       TRACE_ASSERT(data != NULL, "prvTraceCopyToDataBuffer: data == NULL.", );\r
+       TRACE_ASSERT(count <= USER_EVENT_BUFFER_SIZE, "prvTraceCopyToDataBuffer: USER_EVENT_BUFFER_SIZE is too small to handle this event.", );\r
+\r
+       uint32_t slots;\r
+       /* Check if we're close to the end of the buffer */\r
+       if (RecorderDataPtr->userEventBuffer.nextSlotToWrite + count > USER_EVENT_BUFFER_SIZE)\r
+       {\r
+               slots = USER_EVENT_BUFFER_SIZE - RecorderDataPtr->userEventBuffer.nextSlotToWrite; /* Number of slots before end of buffer */\r
+               (void)memcpy(&RecorderDataPtr->userEventBuffer.dataBuffer[RecorderDataPtr->userEventBuffer.nextSlotToWrite * 4], data, slots * 4);\r
+               (void)memcpy(&RecorderDataPtr->userEventBuffer.dataBuffer[0], data + slots, (count - slots) * 4);\r
+       }\r
+       else\r
+       {\r
+               (void)memcpy(&RecorderDataPtr->userEventBuffer.dataBuffer[RecorderDataPtr->userEventBuffer.nextSlotToWrite * 4], data, count * 4);\r
+       }\r
+}\r
+\r
+/*******************************************************************************\r
+ * prvTraceUserEventHelper1\r
+ *\r
+ * Calls on prvTraceUserEventFormat() to do the actual formatting, then goes on to the next helper function.\r
+ ******************************************************************************/\r
+static void prvTraceUserEventHelper1(UserEventChannel channel, traceLabel eventLabel, traceLabel formatLabel, va_list vl)\r
+{\r
+       uint32_t data[(3 + MAX_ARG_SIZE) / 4];\r
+       uint8_t byteOffset = 4; /* Need room for timestamp */\r
+       uint8_t noOfSlots;\r
+\r
+       if (channel == 0)\r
+       {\r
+               /* We are dealing with an unknown channel format pair */\r
+               byteOffset += 4; /* Also need room for channel and format */\r
+               ((uint16_t*)data)[2] = eventLabel;\r
+               ((uint16_t*)data)[3] = formatLabel;\r
+       }\r
+\r
+       noOfSlots = prvTraceUserEventFormat((char*)&(RecorderDataPtr->SymbolTable.symbytes[formatLabel+4]), vl, (uint8_t*)data, byteOffset);\r
+\r
+       prvTraceUserEventHelper2(channel, data, noOfSlots);\r
+}\r
+\r
+/*******************************************************************************\r
+ * prvTraceUserEventHelper2\r
+ *\r
+ * This function simply copies the data buffer to the actual user event buffer.\r
+ ******************************************************************************/\r
+static void prvTraceUserEventHelper2(UserEventChannel channel, uint32_t* data, uint32_t noOfSlots)\r
+{\r
+       static uint32_t old_timestamp = 0;\r
+       uint32_t old_nextSlotToWrite = 0;\r
+\r
+       TRACE_ASSERT(USER_EVENT_BUFFER_SIZE >= noOfSlots, "vTracePrintF: USER_EVENT_BUFFER_SIZE is too small to handle this event.", );\r
+\r
+       trcCRITICAL_SECTION_BEGIN();\r
+       /* Store the timestamp */\r
+       vTracePortGetTimeStamp(data);\r
+\r
+       if (*data < old_timestamp)\r
+               RecorderDataPtr->userEventBuffer.wraparoundCounter++;\r
+       old_timestamp = *data;\r
+\r
+       /* Start by erasing any information in the channel buffer */\r
+       prvTraceClearChannelBuffer(noOfSlots);\r
+\r
+       prvTraceCopyToDataBuffer(data, noOfSlots); /* Will wrap around the data if necessary */\r
+\r
+       old_nextSlotToWrite = RecorderDataPtr->userEventBuffer.nextSlotToWrite; /* Save the index that we want to write the channel data at when we're done */\r
+       RecorderDataPtr->userEventBuffer.nextSlotToWrite = (RecorderDataPtr->userEventBuffer.nextSlotToWrite + noOfSlots) % USER_EVENT_BUFFER_SIZE; /* Make sure we never end up outside the buffer */\r
+\r
+       /* Write to the channel buffer to indicate that this user event is ready to be used */\r
+       if (channel != 0)\r
+               RecorderDataPtr->userEventBuffer.channelBuffer[old_nextSlotToWrite] = channel;\r
+       else\r
+               RecorderDataPtr->userEventBuffer.channelBuffer[old_nextSlotToWrite] = (UserEventChannel)0xFF;   /* 0xFF indicates that this is not a normal channel id */\r
+       trcCRITICAL_SECTION_END();\r
+}\r
+\r
+/*******************************************************************************\r
+ * xTraceRegisterChannelFormat\r
+ *\r
+ * Attempts to create a pair of the channel and format string.\r
+ *\r
+ * Note: This is only available if USE_SEPARATE_USER_EVENT_BUFFER is enabled in \r
+ * trcConfig.h\r
+ ******************************************************************************/\r
+UserEventChannel xTraceRegisterChannelFormat(traceLabel channel, traceLabel formatStr)\r
+{\r
+       uint8_t i;\r
+       UserEventChannel retVal = 0;\r
+\r
+       TRACE_ASSERT(formatStr != 0, "vTraceRegisterChannelFormat: formatStr == 0", (UserEventChannel)0);\r
+\r
+       trcCRITICAL_SECTION_BEGIN();\r
+       for (i = 1; i <= CHANNEL_FORMAT_PAIRS; i++) /* Size of the channels buffer is CHANNEL_FORMAT_PAIRS + 1. Index 0 is unused. */\r
+       {\r
+               if(RecorderDataPtr->userEventBuffer.channels[i].name == 0 && RecorderDataPtr->userEventBuffer.channels[i].defaultFormat == 0)\r
+               {\r
+                       /* Found empty slot */\r
+                       RecorderDataPtr->userEventBuffer.channels[i].name = channel;\r
+                       RecorderDataPtr->userEventBuffer.channels[i].defaultFormat = formatStr;\r
+                       retVal = (UserEventChannel)i;\r
+                       break;\r
+               }\r
+\r
+               if (RecorderDataPtr->userEventBuffer.channels[i].name == channel && RecorderDataPtr->userEventBuffer.channels[i].defaultFormat == formatStr)\r
+               {\r
+                       /* Found a match */\r
+                       retVal = (UserEventChannel)i;\r
+                       break;\r
+               }\r
+       }\r
+       trcCRITICAL_SECTION_END();\r
+       return retVal;\r
+}\r
+\r
+/******************************************************************************\r
+ * vTraceChannelPrintF\r
+ *\r
+ * Slightly faster version of vTracePrintF() due to no lookups.\r
+ *\r
+ * Note: This is only available if USE_SEPARATE_USER_EVENT_BUFFER is enabled in\r
+ * trcConfig.h\r
+ *\r
+ ******************************************************************************/\r
+void vTraceChannelPrintF(UserEventChannel channelPair, ...)\r
+{\r
+       va_list vl;\r
+\r
+       va_start(vl, channelPair);\r
+       vTraceChannelPrintF_Helper(channelPair, vl);\r
+       va_end(vl);\r
+}\r
+\r
+void vTraceChannelPrintF_Helper(UserEventChannel channelPair, va_list vl)\r
+{\r
+       traceLabel channel;\r
+       traceLabel formatStr;\r
+\r
+       TRACE_ASSERT(channelPair != 0, "vTraceChannelPrintF: channelPair == 0", );\r
+       TRACE_ASSERT(channelPair <= CHANNEL_FORMAT_PAIRS, "vTraceChannelPrintF: ", );\r
+\r
+       channel = RecorderDataPtr->userEventBuffer.channels[channelPair].name;\r
+       formatStr = RecorderDataPtr->userEventBuffer.channels[channelPair].defaultFormat;\r
+\r
+       prvTraceUserEventHelper1(channelPair, channel, formatStr, vl);\r
+}\r
+\r
+/******************************************************************************\r
+ * vTraceChannelUserEvent\r
+ *\r
+ * Slightly faster version of vTraceUserEvent() due to no lookups.\r
+ ******************************************************************************/\r
+void vTraceChannelUserEvent(UserEventChannel channelPair)\r
+{\r
+       uint32_t data[(3 + MAX_ARG_SIZE) / 4];\r
+\r
+       TRACE_ASSERT(channelPair != 0, "vTraceChannelPrintF: channelPair == 0", );\r
+       TRACE_ASSERT(channelPair <= CHANNEL_FORMAT_PAIRS, "vTraceChannelPrintF: ", );\r
+\r
+       prvTraceUserEventHelper2(channelPair, data, 1); /* Only need one slot for timestamp */\r
+}\r
+#endif /* USE_SEPARATE_USER_EVENT_BUFFER == 1 */\r
+\r
  /******************************************************************************\r
- * vTracePrintF \r
- * \r
+ * vTracePrintF\r
+ *\r
  * Advanced user events (Professional Edition only)\r
  *\r
  * Generates User Event with formatted text and data, similar to a "printf".\r
- * It is very fast compared to a normal "printf" since this function only \r
+ * It is very fast compared to a normal "printf" since this function only\r
  * stores the arguments. The actual formatting is done\r
- * on the host PC when the trace is displayed in the viewer tool. \r
+ * on the host PC when the trace is displayed in the viewer tool.\r
  *\r
  * User Event labels are created using xTraceOpenLabel.\r
  * Example:\r
  *\r
  *     traceLabel adc_uechannel = xTraceOpenLabel("ADC User Events");\r
  *     ...\r
- *     vTracePrint(adc_uechannel, \r
- *                 "ADC channel %d: %lf volts", \r
+ *     vTracePrint(adc_uechannel,\r
+ *                 "ADC channel %d: %lf volts",\r
  *                 ch, (double)adc_reading/(double)scale);\r
  *\r
  * This can be combined into one line, if desired, but this is slower:\r
  *\r
- *     vTracePrint(xTraceOpenLabel("ADC User Events"), \r
- *                 "ADC channel %d: %lf volts", \r
+ *     vTracePrint(xTraceOpenLabel("ADC User Events"),\r
+ *                 "ADC channel %d: %lf volts",\r
  *                 ch, (double)adc_reading/(double)scale);\r
  *\r
  * Calling xTraceOpenLabel multiple times will not create duplicate entries, but\r
- * it is of course faster to just do it once, and then keep the handle for later \r
- * use. If you don´t have any data arguments, only a text label/string, it is \r
+ * it is of course faster to just do it once, and then keep the handle for later\r
+ * use. If you don´t have any data arguments, only a text label/string, it is\r
  * better to use vTraceUserEvent - it is faster.\r
  *\r
  * Format specifiers supported:\r
@@ -1113,217 +1009,79 @@ static uint8_t writeDouble(void * buffer, uint8_t i, double value)
  *  %bd - 8 bit signed integer\r
  *  %bu - 8 bit unsigned integer\r
  *  %lf - double-precision float\r
- * \r
+ *\r
  * Up to 15 data arguments are allowed, with a total size of maximum 32 byte.\r
  * In case this is exceeded, the user event is changed into an error message.\r
- * \r
- * The data is stored in trace buffer, and is packed to allow storing multiple \r
+ *\r
+ * The data is stored in trace buffer, and is packed to allow storing multiple\r
  * smaller data entries in the same 4-byte record, e.g., four 8-bit values.\r
- * A string requires two bytes, as the symbol table is limited to 64K. Storing a \r
+ * A string requires two bytes, as the symbol table is limited to 64K. Storing a\r
  * double (%lf) uses two records, so this is quite costly. Use float (%f) unless\r
  * the higher precision is really necessary.\r
  ******************************************************************************/\r
+\r
 void vTracePrintF(traceLabel eventLabel, const char* formatStr, ...)\r
 {\r
+       va_list vl;\r
+\r
+       va_start(vl, formatStr);\r
+       vTracePrintF_Helper(eventLabel, formatStr, vl);\r
+       va_end(vl);\r
+}\r
+\r
+void vTracePrintF_Helper(traceLabel eventLabel, const char* formatStr, va_list vl)\r
+{\r
+#if (USE_SEPARATE_USER_EVENT_BUFFER == 0)\r
+       uint32_t noOfSlots;\r
     UserEvent* ue1;\r
-    va_list vl;\r
-    uint8_t argCounter = 0;\r
-    uint8_t i = 0;\r
-    uint8_t nofEventEntries = 0;\r
-    uint16_t formatStrIndex = 0;    \r
+    uint32_t tempDataBuffer[(3 + MAX_ARG_SIZE) / 4];\r
 \r
     /**************************************************************************\r
-    * The array tempDataBuffer is a local buffer used in a two-phase commit of \r
-    * the event data, since a vTracePrintF may span over multiple slots in the \r
+    * The array tempDataBuffer is a local buffer used in a two-phase commit of\r
+    * the event data, since a vTracePrintF may span over multiple slots in the\r
     * buffer.\r
-    * This buffer can be made larger, of course, but remember the risk for \r
-    * stack overflow. Note: This should be a LOCAL buffer, must not be made \r
+    * This buffer can be made larger, of course, but remember the risk for\r
+    * stack overflow. Note: This should be a LOCAL buffer, must not be made\r
     * global. That would cause data corruption when two calls to vTracePrintF\r
-    * from different tasks overlaps (interrupts are only disabled in a small \r
+    * from different tasks overlaps (interrupts are only disabled in a small\r
     * part of this function, otherwise enabled)\r
     ***************************************************************************/\r
-               \r
-    uint32_t tempDataBuffer[(3 + MAX_ARG_SIZE) / 4];   \r
-       \r
-       \r
-    if ((inExcludedTask == 0) &&\r
-        (nISRactive == 0) &&\r
-        (RecorderDataPtr->recorderActive == 1) &&\r
-        (handle_of_last_logged_task > 0))\r
-    {        \r
-        /* First, write the "primary" user event entry in the local buffer, but \r
-        let the event type be "EVENT_BEING_WRITTEN" for now...*/\r
 \r
-        ue1 = (UserEvent*)(&tempDataBuffer[0]);         \r
-        ue1->type = EVENT_BEING_WRITTEN;      /* Update this as the last step */\r
-        \r
-        i = 4;\r
-        formatStrIndex = 0;\r
-        va_start(vl, formatStr);          /* Begin reading the arguments list */\r
+       TRACE_ASSERT(formatStr != NULL, "vTracePrintF: formatStr == NULL", );\r
 \r
-        while (formatStr[formatStrIndex] != '\0')\r
-        {\r
-            if (formatStr[formatStrIndex] == '%')\r
-            {\r
-                argCounter++;\r
-\r
-                if (argCounter > 15)\r
-                {\r
-                    vTraceError("vTracePrintF - Too many arguments, max 15 allowed!");\r
-                    va_end(vl);                    \r
-                    formatStr = "[vTracePrintF error] Too many arguments, max 15 allowed!";\r
-                    i = 4;\r
-                    break;            \r
-                }\r
-\r
-/*******************************************************************************\r
- * These below code writes raw data (primitive datatypes) in the event buffer, \r
- * instead of the normal event structs (where byte 0 is event type).\r
- * These data entries must never be interpreted as real event data, as the type\r
- * field would be misleading since used for payload data. \r
- * \r
- * The correctness of this encoding depends on two mechanisms:\r
- * \r
- * 1. An initial USER_EVENT, which type code tells the number of 32-bit data \r
- * entires that follows. (code - USER_EVENT = number of data entries). \r
- * Note that a data entry corresponds to the slots that normally corresponds to \r
- * one (1) event, i.e., 32 bits. vTracePrintF may encode several pieces of data \r
- * in one data entry, e.g., two 16-bit values or four 8-bit values, one 16-bit\r
- * value followes by two 8-bit values, etc.\r
- *\r
- * 2. A two-phase commit procedure, where the USER_EVENT and data entries are \r
- * written to a local buffer at first, and when all checks are OK then copied to\r
- * the main event buffer using a fast memcpy. The event code is finalized as the\r
- * very last step. Before that that step, the event code indicates an unfinished\r
- * event, which causes it to be ignored and stop the loading of the file (since \r
- * an unfinished event is the last event in the trace).\r
-*******************************************************************************/\r
-                formatStrIndex++;\r
-                switch (formatStr[formatStrIndex])\r
-                {\r
-                case 'd':    i = writeInt32((uint8_t*)tempDataBuffer, \r
-                                                i, \r
-                                                (uint32_t)va_arg(vl, uint32_t)); \r
-                             break;\r
-                case 'u':    i = writeInt32((uint8_t*)tempDataBuffer, \r
-                                                i, \r
-                                                (uint32_t)va_arg(vl, uint32_t)); \r
-                             break;\r
-                case 's':    i = writeInt16((uint8_t*)tempDataBuffer, \r
-                                                i, \r
-                                                (uint16_t)xTraceOpenLabel((char*)va_arg(vl, char*))); \r
-                             break;\r
+    if (RecorderDataPtr->recorderActive && (! inExcludedTask || nISRactive) && handle_of_last_logged_task)\r
+    {\r
+        /* First, write the "primary" user event entry in the local buffer, but\r
+        let the event type be "EVENT_BEING_WRITTEN" for now...*/\r
 \r
-#if (INCLUDE_FLOAT_SUPPORT)\r
-                             /* Yes, "double" as type also in the float \r
-                             case. This since "float" is promoted into "double" \r
-                             by the va_arg stuff. */\r
-                case 'f':    i = writeFloat((uint8_t*)tempDataBuffer, \r
-                                                i, \r
-                                                (float)va_arg(vl, double)); \r
-                             break;    \r
-#else\r
-/* No support for floats, but attempt to store a float user event\r
-avoid a possible crash due to float reference. Instead store the \r
-data on uint_32 format (will not be displayed anyway). This is just\r
-to keep va_arg and i consistent. */\r
-\r
-                case 'f':    i = writeInt32((uint8_t*)tempDataBuffer,\r
-                                                i, \r
-                                                (uint32_t)va_arg(vl, double)); \r
-#endif\r
-                case 'l':\r
-                    formatStrIndex++;\r
-                    switch (formatStr[formatStrIndex])\r
-                    {\r
-#if (INCLUDE_FLOAT_SUPPORT)\r
-                    case 'f':     i = writeDouble((uint8_t*)tempDataBuffer, \r
-                                                      i, \r
-                                                      (double)va_arg(vl, double)); \r
-                                  break;\r
-#else\r
-/* No support for floats, but attempt to store a float user event\r
-avoid a possible crash due to float reference. Instead store the \r
-data on uint_32 format (will not be displayed anyway). This is just\r
-to keep va_arg and i consistent. */\r
-                    case 'f':    i = writeInt32((uint8_t*)tempDataBuffer, /* In this case, the value will not be shown anyway */\r
-                                                    i, \r
-                                                    (uint32_t)va_arg(vl, double)); \r
-                                 i = writeInt32((uint8_t*)tempDataBuffer, /* Do it twice, to write in total 8 bytes */\r
-                                                    i, \r
-                                                    (uint32_t)va_arg(vl, double)); \r
-#endif\r
+        ue1 = (UserEvent*)(&tempDataBuffer[0]);\r
+        ue1->type = EVENT_BEING_WRITTEN;      /* Update this as the last step */\r
 \r
-                    }\r
-                    break;\r
-                case 'h':\r
-                    formatStrIndex++;\r
-                    switch (formatStr[formatStrIndex])\r
-                    {\r
-                    case 'd':    i = writeInt16((uint8_t*)tempDataBuffer, \r
-                                                    i, \r
-                                                    (uint16_t)va_arg(vl, uint32_t)); \r
-                                 break;\r
-                    case 'u':    i = writeInt16((uint8_t*)tempDataBuffer, \r
-                                                    i, \r
-                                                    (uint16_t)va_arg(vl, uint32_t)); \r
-                                 break;\r
-                    }\r
-                    break;\r
-                case 'b':\r
-                    formatStrIndex++;\r
-                    switch (formatStr[formatStrIndex])\r
-                    {\r
-                    case 'd':    i = writeInt8((uint8_t*)tempDataBuffer, \r
-                                                   i, \r
-                                                   (uint8_t)va_arg(vl, uint32_t)); \r
-                                 break;\r
-                    case 'u':    i = writeInt8((uint8_t*)tempDataBuffer, \r
-                                                   i, \r
-                                                   (uint8_t)va_arg(vl, uint32_t)); \r
-                                 break;\r
-                    }\r
-                    break;\r
-                }\r
-            }                                    \r
-            formatStrIndex++;    \r
-            if (i == 255)\r
-            {\r
-                va_end(vl);\r
-                //vTraceError("vTracePrintF - Too large arguments, max 32 byte allowed!");\r
-                formatStr = "[vTracePrintF error] Too large arguments, max 32 byte allowed!";\r
-                i = 4;\r
-                break;\r
-            }\r
-        }\r
+        noOfSlots = prvTraceUserEventFormat(formatStr, vl, (uint8_t*)tempDataBuffer, 4);\r
 \r
-        va_end(vl);\r
-               \r
         /* Store the format string, with a reference to the channel symbol */\r
-        ue1->payload = prvTraceOpenSymbol(formatStr, eventLabel);     \r
+        ue1->payload = prvTraceOpenSymbol(formatStr, eventLabel);\r
 \r
-        trcCRITICAL_SECTION_BEGIN();  \r
+        trcCRITICAL_SECTION_BEGIN();\r
 \r
         ue1->dts = (uint8_t)prvTraceGetDTS(0xFF);\r
         if (! RecorderDataPtr->recorderActive)\r
         {\r
 \r
-            /* Abort, since an XTS event (created by prvTraceGetDTS) filled the \r
+            /* Abort, since an XTS event (created by prvTraceGetDTS) filled the\r
             buffer, and the recorder stopped since not circular buffer. */\r
             trcCRITICAL_SECTION_END();\r
-        \r
+\r
             return;\r
         }\r
-            \r
-        nofEventEntries = (i+3)/4;\r
 \r
-        /* If the data does not fit in the remaining main buffer, wrap around to \r
+        /* If the data does not fit in the remaining main buffer, wrap around to\r
         0 if allowed, otherwise stop the recorder and quit). */\r
-        if (RecorderDataPtr->nextFreeIndex + nofEventEntries > RecorderDataPtr->maxEvents)\r
+        if (RecorderDataPtr->nextFreeIndex + noOfSlots > RecorderDataPtr->maxEvents)\r
         {\r
-#if (RECORDER_STORE_MODE == STORE_MODE_RING_BUFFER)\r
-            (void)memset(& RecorderDataPtr->eventData[RecorderDataPtr->nextFreeIndex * 4], \r
-                   0, \r
+#if (TRACE_RECORDER_STORE_MODE == TRACE_STORE_MODE_RING_BUFFER)\r
+            (void)memset(& RecorderDataPtr->eventData[RecorderDataPtr->nextFreeIndex * 4],\r
+                   0,\r
                    (RecorderDataPtr->maxEvents - RecorderDataPtr->nextFreeIndex)*4);\r
             RecorderDataPtr->nextFreeIndex = 0;\r
             RecorderDataPtr->bufferIsFull = 1;\r
@@ -1333,60 +1091,150 @@ to keep va_arg and i consistent. */
             trcCRITICAL_SECTION_END();\r
             vTraceStop();\r
 \r
-            \r
+\r
             return;\r
 #endif\r
         }\r
-    \r
-#if (RECORDER_STORE_MODE == STORE_MODE_RING_BUFFER)\r
-        /* Check that the buffer to be overwritten does not contain any user \r
+\r
+#if (TRACE_RECORDER_STORE_MODE == TRACE_STORE_MODE_RING_BUFFER)\r
+        /* Check that the buffer to be overwritten does not contain any user\r
         events that would be partially overwritten. If so, they must be "killed"\r
-        by replacing the user event and following data with NULL events (i.e., \r
+        by replacing the user event and following data with NULL events (i.e.,\r
         using a memset to zero).*/\r
-        prvCheckDataToBeOverwrittenForMultiEntryUserEvents(nofEventEntries);\r
+        prvCheckDataToBeOverwrittenForMultiEntryEvents(noOfSlots);\r
 #endif\r
         /* Copy the local buffer to the main buffer */\r
-        (void)memcpy(& RecorderDataPtr->eventData[RecorderDataPtr->nextFreeIndex * 4], \r
-               tempDataBuffer, \r
-               i);\r
+        (void)memcpy(& RecorderDataPtr->eventData[RecorderDataPtr->nextFreeIndex * 4],\r
+               tempDataBuffer,\r
+               noOfSlots * 4);\r
 \r
-        /* Update the event type, i.e., number of data entries following the \r
-        main USER_EVENT entry (Note: important that this is after the memcpy, \r
+        /* Update the event type, i.e., number of data entries following the\r
+        main USER_EVENT entry (Note: important that this is after the memcpy,\r
         but within the critical section!)*/\r
-        RecorderDataPtr->eventData[RecorderDataPtr->nextFreeIndex * 4] = \r
-          (uint8_t) USER_EVENT + nofEventEntries - 1;    \r
-        \r
-        /* Update the main buffer event index (already checked that it fits in \r
+        RecorderDataPtr->eventData[RecorderDataPtr->nextFreeIndex * 4] =\r
+          (uint8_t) USER_EVENT + noOfSlots - 1;\r
+\r
+        /* Update the main buffer event index (already checked that it fits in\r
         the buffer, so no need to check for wrapping)*/\r
-        \r
-        RecorderDataPtr->nextFreeIndex += nofEventEntries;\r
-        RecorderDataPtr->numEvents += nofEventEntries;\r
-        \r
-        if (RecorderDataPtr->nextFreeIndex >= EVENT_BUFFER_SIZE)\r
-        {\r
-        \r
-#if (RECORDER_STORE_MODE == STORE_MODE_RING_BUFFER)\r
-            RecorderDataPtr->nextFreeIndex = 0;\r
-            RecorderDataPtr->bufferIsFull = 1;\r
+\r
+        RecorderDataPtr->nextFreeIndex += noOfSlots;\r
+        RecorderDataPtr->numEvents += noOfSlots;\r
+\r
+\r
+\r
+               if (RecorderDataPtr->nextFreeIndex >= EVENT_BUFFER_SIZE)\r
+               {\r
+#if (TRACE_RECORDER_STORE_MODE == TRACE_STORE_MODE_RING_BUFFER)\r
+                       /* We have reached the end, but this is a ring buffer. Start from the beginning again. */\r
+                       RecorderDataPtr->bufferIsFull = 1;\r
+                       RecorderDataPtr->nextFreeIndex = 0;\r
 #else\r
-            vTraceStop();\r
+                       /* We have reached the end so we stop. */\r
+                       vTraceStop();\r
 #endif\r
-        }\r
+               }\r
 \r
+#if (TRACE_RECORDER_STORE_MODE == TRACE_STORE_MODE_RING_BUFFER)\r
+               /* Make sure the next entry is cleared correctly */\r
+               prvCheckDataToBeOverwrittenForMultiEntryEvents(1);\r
+#endif\r
+\r
+#ifdef STOP_AFTER_N_EVENTS\r
+#if (STOP_AFTER_N_EVENTS > -1)\r
+               /* Check if we have reached the desired number of events */\r
+               if (RecorderDataPtr->numEvents >= STOP_AFTER_N_EVENTS)\r
+               {\r
+                       vTraceStop();\r
+               }\r
+#endif\r
+#endif\r
+\r
+        trcCRITICAL_SECTION_END();\r
+    }\r
+\r
+#elif (USE_SEPARATE_USER_EVENT_BUFFER == 1)\r
+       /* Use the separate user event buffer */\r
+       traceLabel formatLabel;\r
+       UserEventChannel channel;\r
+\r
+       if (RecorderDataPtr->recorderActive && (! inExcludedTask || nISRactive) && handle_of_last_logged_task)\r
+    {\r
+           formatLabel = xTraceOpenLabel(formatStr);\r
+\r
+           channel = xTraceRegisterChannelFormat(eventLabel, formatLabel);\r
+\r
+               prvTraceUserEventHelper1(channel, eventLabel, formatLabel, vl);\r
+       }\r
+#endif\r
+}\r
+\r
+/******************************************************************************\r
+ * vTraceUserEvent\r
+ *\r
+ * Basic user event (Standard and Professional Edition only)\r
+ *\r
+ * Generates a User Event with a text label. The label is created/looked up\r
+ * in the symbol table using xTraceOpenLabel.\r
+ ******************************************************************************/\r
+void vTraceUserEvent(traceLabel eventLabel)\r
+{\r
+#if (USE_SEPARATE_USER_EVENT_BUFFER == 0)\r
+    UserEvent* ue;\r
+    uint8_t dts1;\r
+\r
+       TRACE_ASSERT(eventLabel > 0, "vTraceUserEvent: Invalid value for eventLabel", );\r
+\r
+    if (RecorderDataPtr->recorderActive && (! inExcludedTask || nISRactive) && handle_of_last_logged_task)\r
+    {\r
+        trcCRITICAL_SECTION_BEGIN();\r
+\r
+        dts1 = (uint8_t)prvTraceGetDTS(0xFF);\r
+\r
+        if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */\r
+        {\r
+            ue = (UserEvent*) xTraceNextFreeEventBufferSlot();\r
+            if (ue != NULL)\r
+            {\r
+                ue->dts = dts1;\r
+                ue->type = USER_EVENT;\r
+                ue->payload = eventLabel;\r
+                prvTraceUpdateCounters();\r
+            }\r
+        }\r
         trcCRITICAL_SECTION_END();\r
-    }    \r
+    }\r
+#elif (USE_SEPARATE_USER_EVENT_BUFFER == 1)\r
+       UserEventChannel channel;\r
+       uint32_t noOfSlots = 1;\r
+       uint32_t tempDataBuffer[(3 + MAX_ARG_SIZE) / 4];\r
+\r
+       if (RecorderDataPtr->recorderActive && (! inExcludedTask || nISRactive) && handle_of_last_logged_task)\r
+       {\r
+               channel = xTraceRegisterChannelFormat(0, eventLabel);\r
+\r
+               if (channel == 0)\r
+               {\r
+                       /* We are dealing with an unknown channel format pair */\r
+                       noOfSlots++; /* Also need room for channel and format */\r
+                       ((uint16_t*)tempDataBuffer)[2] = 0;\r
+                       ((uint16_t*)tempDataBuffer)[3] = eventLabel;\r
+               }\r
+\r
+               prvTraceUserEventHelper2(channel, tempDataBuffer, noOfSlots);\r
+       }\r
+#endif\r
 }\r
-    \r
+\r
 /*******************************************************************************\r
  * xTraceOpenLabel\r
- * \r
+ *\r
  * Creates user event labels for user event channels or for individual events.\r
  * User events can be used to log application events and data for display in\r
  * the visualization tool. A user event is identified by a label, i.e., a string,\r
  * which is stored in the recorder's symbol table.\r
  * When logging a user event, a numeric handle (reference) to this string is\r
- * used to identify the event. This is obtained by calling \r
- * \r
+ * used to identify the event. This is obtained by calling\r
+ *\r
  *     xTraceOpenLabel()\r
  *\r
  * which adds the string to the symbol table (if not already present)\r
@@ -1407,15 +1255,18 @@ to keep va_arg and i consistent. */
  *     ...\r
  *     vTraceUserEvent(myEventHandle);\r
  *\r
- * The second option is faster since no lookup is required on each event, and \r
+ * The second option is faster since no lookup is required on each event, and\r
  * therefore recommended for user events that are frequently\r
  * executed and/or located in time-critical code. The lookup operation is\r
  * however fairly fast due to the design of the symbol table.\r
  ******************************************************************************/\r
 traceLabel xTraceOpenLabel(const char* label)\r
 {\r
+       TRACE_ASSERT(label != NULL, "xTraceOpenLabel: label == NULL", (traceLabel)0);\r
+\r
     return prvTraceOpenSymbol(label, 0);\r
 }\r
-#endif\r
+\r
 #endif\r
 \r
+#endif
\ No newline at end of file