+++ /dev/null
-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
+++ /dev/null
-/*******************************************************************************\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
+++ /dev/null
-/******************************************************************************* \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
+++ /dev/null
-/*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
- * Percepio AB, www.percepio.com\r
- *\r
- * trcBase.h\r
- *\r
- * Core functionallity of the FreeRTOS+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
- * 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 TRCBASE_H\r
-#define TRCBASE_H\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
-\r
-extern volatile int recorder_busy;\r
-\r
-#define trcCRITICAL_SECTION_BEGIN() {taskENTER_CRITICAL(); recorder_busy++;}\r
-#define trcCRITICAL_SECTION_END() {recorder_busy--; taskEXIT_CRITICAL();}\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
-\r
-/******************************************************************************\r
- * Object Property Table\r
- * The Object Table contains name and other properties of the objects (tasks,\r
- * 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
- * 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
- * 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
- uint32_t ObjectPropertyTableSizeInBytes;\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
-\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
-\r
- /* The actual handles issued, should be Initiated to all zeros */ \r
- uint8_t objbytes[ 4*((DynObjTableSize+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
- /* Entry 0 is reserved. Any reference to entry 0 implies NULL*/\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
- This field holds the current list heads. Should be initiated to zeros */\r
- uint16_t latestEntryOfChecksum[64]; \r
-} symbolTableType;\r
-\r
-\r
-/*******************************************************************************\r
- * The data structures of the different events, all 4 bytes long \r
- ******************************************************************************/\r
-\r
-typedef struct\r
-{\r
- uint8_t type; \r
- objectHandleType objHandle;\r
- uint16_t dts; /* differential timestamp - time since last event */ \r
-} TSEvent, TREvent;\r
-\r
-typedef struct\r
-{\r
- uint8_t type;\r
- uint8_t objHandle;\r
- uint16_t dts;\r
-} KernelCall;\r
-\r
-typedef struct\r
-{\r
- uint8_t type;\r
- objectHandleType objHandle;\r
- uint8_t param;\r
- uint8_t dts; \r
-} KernelCallWithParamAndHandle;\r
-\r
-typedef struct\r
-{\r
- uint8_t type;\r
- uint8_t dts; \r
- uint16_t param;\r
-} KernelCallWithParam16;\r
-\r
-typedef struct\r
-{\r
- uint8_t type;\r
- objectHandleType objHandle; /* the handle of the closed object */\r
- uint16_t symbolIndex; /* the name of the closed object */\r
-} ObjCloseNameEvent;\r
-\r
-typedef struct\r
-{\r
- uint8_t type;\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
- 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
- (this one is always MSB if used) */\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
-} XTSEvent;\r
-\r
-\r
-/*******************************************************************************\r
- * The main datastructure, read by FreeRTOS+Trace from the RAM dump\r
- ******************************************************************************/\r
-\r
-typedef struct\r
-{ \r
- uint8_t startmarker0;\r
- uint8_t startmarker1;\r
- uint8_t startmarker2;\r
- uint8_t startmarker3;\r
- uint8_t startmarker4;\r
- uint8_t startmarker5;\r
- uint8_t startmarker6;\r
- uint8_t startmarker7;\r
- uint8_t startmarker8;\r
- uint8_t startmarker9;\r
- uint8_t startmarker10;\r
- uint8_t startmarker11;\r
-\r
- /* For FreeRTOS: 0x1AA1 */\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
- uint8_t irq_priority_order;\r
- \r
- /* sizeof(RecorderDataType) - just for control */\r
- uint32_t filesize;\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
- /* The event buffer index, where to write the next event */\r
- uint32_t nextFreeIndex;\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
- timebase, modulo frequency! */\r
- uint32_t absTimeLastEvent; \r
- \r
- /* The number of seconds in total - lasts for 136 years */\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
-\r
- /* For storing a Team License key */\r
- uint8_t teamLicenceKey[32];\r
-\r
- /* 0xF0F0F0F0 - for control only */\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
-\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
-#if (INCLUDE_FLOAT_SUPPORT == 1)\r
- float exampleFloatEncoding; \r
-#else\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
- 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
- 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
-\r
- /* 0xF3F3F3F3 - for control only */\r
- int32_t debugMarker3; \r
-\r
- /* The event data, in 4-byte records */\r
- uint8_t eventData[ EVENT_BUFFER_SIZE * 4 ];\r
-\r
- uint8_t endmarker0;\r
- uint8_t endmarker1;\r
- uint8_t endmarker2;\r
- uint8_t endmarker3;\r
- uint8_t endmarker4;\r
- uint8_t endmarker5;\r
- uint8_t endmarker6;\r
- uint8_t endmarker7;\r
- uint8_t endmarker8;\r
- 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 channel);\r
-\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
-\r
-objectHandleType xTraceGetObjectHandle(traceObjectClass objectclass);\r
-\r
-void vTraceFreeObjectHandle(traceObjectClass objectclass, \r
- objectHandleType handle);\r
-\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
-\r
-\r
-/*******************************************************************************\r
- * vTraceError\r
- *\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
-\r
-/*******************************************************************************\r
- * xTraceGetLastError\r
- *\r
- * Gives the last error message, if any. NULL if no error message is stored.\r
- * The message is cleared on read.\r
- ******************************************************************************/\r
-char* xTraceGetLastError(void);\r
-\r
-/*******************************************************************************\r
- * xTraceInitTraceData\r
- *\r
- * Allocates and initializes the recorder datastructure, 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
-\r
-/* Internal macros */\r
-\r
-#define PROPERTY_NAME_GET(objectclass, objecthandle) \\r
-(const char*)(& RecorderDataPtr->ObjectPropertyTable.objbytes \\r
-[uiIndexOfObject(objecthandle, objectclass)])\r
-\r
-#define 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
-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
-\r
-#endif\r
-\r
+++ /dev/null
-/*******************************************************************************\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
-\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
-#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
-\r
-#ifndef INCLUDE_OBJECT_DELETE\r
-#define INCLUDE_OBJECT_DELETE 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
-#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
-#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
-\r
- /* Called in vTaskResume */\r
- #undef traceTASK_RESUME\r
- #define traceTASK_RESUME( pxTaskToResume ) \\r
- vTraceStoreKernelCall(TASK_RESUME, TRACE_CLASS_TASK, pxTaskToResume->uxTaskNumber);\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
-\r
-#endif\r
-#endif\r
+++ /dev/null
-/*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 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
- *\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 TRCKERNEL_H\r
-#define TRCKERNEL_H\r
-\r
-#include "trcBase.h"\r
-\r
-/* Internal functions */\r
-\r
-\r
-#if !defined INCLUDE_READY_EVENTS || INCLUDE_READY_EVENTS == 1\r
-void vTraceStoreTaskReady(objectHandleType handle);\r
-#endif\r
-\r
-void vTraceStoreTaskswitch(void);\r
-\r
-void vTraceStoreKernelCall(uint32_t eventcode, traceObjectClass objectClass, uint32_t byteParam); \r
-\r
-void vTraceStoreKernelCallWithNumericParamOnly(uint32_t evtcode, \r
- uint16_t param);\r
-\r
-void vTraceStoreKernelCallWithParam(uint32_t evtcode, traceObjectClass objectClass, \r
- uint32_t objectNumber, uint8_t param);\r
-\r
-void vTraceSetTaskInstanceFinished(objectHandleType handle);\r
-\r
-void vTraceSetPriorityProperty(uint8_t objectclass, uint8_t id, uint8_t value);\r
-\r
-uint8_t uiTraceGetPriorityProperty(uint8_t objectclass, uint8_t id);\r
-\r
-void vTraceSetObjectState(uint8_t objectclass, uint8_t id, uint8_t value);\r
-\r
-uint8_t uiTraceGetObjectState(uint8_t objectclass, uint8_t id);\r
-\r
-#if (INCLUDE_OBJECT_DELETE == 1) \r
-\r
-void vTraceStoreObjectNameOnCloseEvent(objectHandleType handle, \r
- traceObjectClass objectclass);\r
-\r
-void vTraceStoreObjectPropertiesOnCloseEvent(objectHandleType handle, \r
- traceObjectClass objectclass);\r
-#endif\r
-\r
-/* Internal constants for task state */\r
-#define TASK_STATE_INSTANCE_NOT_ACTIVE 0\r
-#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
+++ /dev/null
-/******************************************************************************* \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
-#else\r
- #define WIN32_PORT_SAVE_WHEN_STOPPED 0\r
- #define WIN32_PORT_EXIT_WHEN_STOPPED 0\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_ARM_CortexM\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
+++ /dev/null
-/*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
- * Percepio AB, www.percepio.com\r
- *\r
- * trcTypes.h\r
- *\r
- * Data types used by 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
- * 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 TRCTYPES_H\r
-#define TRCTYPES_H\r
-\r
-#include <stdint.h>\r
-\r
-typedef uint16_t traceLabel;\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
+++ /dev/null
-/*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
- * Percepio AB, www.percepio.com\r
- *\r
- * trcUser.h\r
- * The public API of 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
- * 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 TRCUSER_H\r
-#define TRCUSER_H\r
-\r
-#include "FreeRTOS.h"\r
-\r
-#include "trcKernel.h"\r
-\r
-#if (configUSE_TRACE_FACILITY == 1)\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\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
- * has a too small value (NTASK, NQUEUE, etc).\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
- * 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
- ******************************************************************************/\r
-uint32_t uiTraceStart(void);\r
-\r
-/*******************************************************************************\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
- * has a too small value (NTASK, NQUEUE, etc).\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
- * 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
- ******************************************************************************/\r
-void vTraceStartStatusMonitor(void);\r
-\r
-/*******************************************************************************\r
- * 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
- ******************************************************************************/\r
-void vTraceStop(void);\r
-\r
-/*******************************************************************************\r
- * vTraceClear\r
- *\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
- * 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
- * started.\r
- *\r
- * Example:\r
- * #define ID_ISR_TIMER1 1 // lowest valid ID is 1\r
- * #define PRIO_OF_ISR_TIMER1 3 // the hardware priority of the interrupt\r
- * ...\r
- * vTraceSetISRProperties(ID_ISR_TIMER1, "ISRTimer1", PRIO_OF_ISR_TIMER1);\r
- * ...\r
- * void ISR_handler()\r
- * {\r
- * portENTER_CRITICAL(); // Required if nested ISRs are allowed\r
- * vTraceStoreISRBegin(ID_OF_ISR_TIMER1);\r
- * portEXIT_CRITICAL();\r
- * ...\r
- * portENTER_CRITICAL(); // Required if nested ISRs are allowed\r
- * vTraceStoreISREnd();\r
- * portEXIT_CRITICAL();\r
- * }\r
- ******************************************************************************/\r
-void vTraceSetISRProperties(objectHandleType handle, const char* name, char priority);\r
-\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
- *\r
- * Example:\r
- * #define ID_ISR_TIMER1 1 // lowest valid ID is 1\r
- * #define PRIO_OF_ISR_TIMER1 3 // the hardware priority of the interrupt\r
- * ...\r
- * vTraceSetISRProperties(ID_ISR_TIMER1, "ISRTimer1", PRIO_OF_ISR_TIMER1);\r
- * ...\r
- * void ISR_handler()\r
- * {\r
- * portENTER_CRITICAL(); // Required if nested ISRs are allowed\r
- * vTraceStoreISRBegin(ID_OF_ISR_TIMER1);\r
- * portEXIT_CRITICAL();\r
- * ...\r
- * portENTER_CRITICAL(); // Required if nested ISRs are allowed\r
- * vTraceStoreISREnd();\r
- * portEXIT_CRITICAL();\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
- *\r
- * See http://www.freertos.org/a00110.html\r
- * \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
- * #define PRIO_OF_ISR_TIMER1 3 // the hardware priority of the interrupt\r
- * ...\r
- * vTraceSetISRProperties(ID_ISR_TIMER1, "ISRTimer1", PRIO_OF_ISR_TIMER1);\r
- * ...\r
- * void ISR_handler()\r
- * {\r
- * portENTER_CRITICAL(); // Required if nested ISRs are allowed\r
- * vTraceStoreISRBegin(ID_OF_ISR_TIMER1);\r
- * portEXIT_CRITICAL();\r
- * ...\r
- * portENTER_CRITICAL(); // Required if nested ISRs are allowed\r
- * vTraceStoreISREnd();\r
- * portEXIT_CRITICAL();\r
- * }\r
- ******************************************************************************/\r
-void vTraceStoreISREnd(void);\r
-\r
-#else\r
- /* If not including the ISR recording */\r
-\r
-void vTraceIncreaseISRActive(void);\r
-\r
-void vTraceDecreaseISRActive(void);\r
-\r
-#define vTraceSetISRProperties(handle, name, priority)\r
-#define vTraceStoreISRBegin(id) vTraceIncreaseISRActive()\r
-#define vTraceStoreISREnd() vTraceDecreaseISRActive()\r
-\r
-#endif\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 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
- * 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
- * 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
- * e.g., in case a debugger connection is not available for uploading the data.\r
- ******************************************************************************/\r
-uint32_t uiTraceGetTraceBufferSize(void);\r
-\r
-#if (INCLUDE_USER_EVENTS == 1)\r
-\r
-/*******************************************************************************\r
- * xTraceOpenLabel\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
- * xTraceOpenLabel()\r
- *\r
- * whihc adds the string to the symbol table (if not already present)\r
- * and returns the corresponding handle.\r
- *\r
- * This can be used in two ways:\r
- *\r
- * 1. The handle is looked up every time, when storing the user event.\r
- *\r
- * Example:\r
- * vTraceUserEvent(xTraceOpenLabel("MyUserEvent"));\r
- *\r
- * 2. The label is registered just once, with the handle stored in an\r
- * application variable - much like using a file handle.\r
- *\r
- * Example:\r
- * myEventHandle = xTraceOpenLabel("MyUserEvent");\r
- * ...\r
- * vTraceUserEvent(myEventHandle);\r
- *\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
- /******************************************************************************\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
- /******************************************************************************\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
- * stores the arguments. The actual formatting is done\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
- * 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
- * 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
- * better to use vTraceUserEvent - it is faster.\r
- *\r
- * Format specifiers supported:\r
- * %d - 32 bit signed integer\r
- * %u - 32 bit unsigned integer\r
- * %f - 32 bit float\r
- * %s - string (is copied to the recorder symbol table)\r
- * %hd - 16 bit signed integer\r
- * %hu - 16 bit unsigned integer\r
- * %bd - 8 bit signed integer\r
- * %bu - 8 bit unsigned integer\r
- * %lf - double-precision float (Note! See below...)\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
- * 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
- * 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
- * "sizeof(double)" actually gives 8 as expected. If not, use %f instead.\r
- ******************************************************************************/ \r
-void vTracePrintF(traceLabel eventLabel, const char* formatStr, ...);\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
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#else\r
-\r
-#include "trcPort.h"\r
-\r
-#define vTraceInit()\r
-#define uiTraceStart() (1)\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
-#endif\r
-\r
+++ /dev/null
-\r
-FreeRTOS+Trace - 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
-\r
-FreeRTOS+Trace 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
-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
-directly, without any debugger IDE involved. Using other debug probes is \r
-also possible, but requires some extra steps, described below.\r
-\r
-If you have a Segger J-Link/J-Trace debug probe or another J-Link compatible \r
-debug probe, just select \r
-\r
- "File" menu -> "Upload from <debug probe name>". \r
-\r
-This opens a dialog where you get to enter the memory region where\r
-the recorder data structure is located. Normally you select the entire \r
-internal RAM according to the datasheet of your MCU, but the exact address\r
-can be found can by inspecting the "RecorderData" struct or the \r
-"RecorderDataPtr" pointer with your debugger.\r
-\r
-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
-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
-debug interfaces on demonstration/evaluation boards (where there is a USB \r
-connection directly to the board). Look for a Segger J-Link label on the board.\r
-\r
-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
-Atmel Studio and at the Atmel website.\r
-\r
-This extension automatically detects the path to FreeRTOS+Trace, 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
-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
-- MCH (.mch), supporting Microchip MPLAB.\r
-\r
-When you store the RAM dump, you must also make sure to select the right region, \r
-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
-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
-For chips with larger amounts of (external) RAM, it is typically possible to \r
-dump a limited region where the data is typically found.\r
-\r
-Using IAR Embedded Workbench for ARM, version 6.3\r
--------------------------------------------------\r
-In the debugger view, when stopped on a breakpoint:\r
-- Select "Debug" menu, "Memory" submenu, "Save..." (keyboard shortcut: ALT,d,y,s)\r
-- In the Save dialog\r
- - Zone: Memory\r
- - Start Adress: 10000000 (for NXP LPC1766 in the demo project)\r
- - End Adress: 1000FFFF (for NXP LPC1766 in the demo project)\r
- - File format: Intel Extended\r
- - Filename: <name>.hex\r
- - Press "Save" button\r
-You can now open <name>.hex in FreeRTOS+Trace.\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
-long as the whole data is included.\r
-\r
-Using Renesas High-performance Embedded Workshop v4.09\r
-------------------------------------------------------\r
-In the debugger view, when stopped on a breakpoint:\r
-- Select "Debug" menu, "Save Memory..." (keyboard shortcut: ALT,d,a)\r
-- In the Save dialog\r
- - Format: Binary\r
- - Filename: <name>.bin\r
- - 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
- \r
-Using Microchip MPLAB v8.86\r
-------------------------------------------------------\r
-- Select "View" -> "File Registers". This shows you the memory contents.\r
-- Make sure "Hex" is selected in the bottom left (instead of "Symbolic"). Hex mode seems to be default.\r
-- Right click in the view and select "Export Table...".\r
-- 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
-\r
-Using STM32 ST-Link\r
-------------------------------------------------------\r
-- Start "ST-Link Utility"\r
-- 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
-\r
-In case you have any question, contact support@percepio.com\r
-\r
-Percepio AB\r
-www.percepio.com\r
+++ /dev/null
-\r
-FreeRTOS+Trace 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
-\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
-\r
-Files included\r
---------------\r
-- trcConfig.h - The recorder's configuration file, check this!\r
-- 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
-- trcTypes.h - Type definitions used.\r
-\r
-Hardware Timer Ports\r
---------------------\r
-This release contains hardware timer ports for the following hardware architectures:\r
-\r
-- ARM Cortex M3/M4 (all brands, such as Atmel SAM3/SAM4, NXP 17xx, 18xx, 43xx, STM32, Freescale Kinetis, ...)\r
-- Atmel AT91SAM7x\r
-- Atmel AT32UC3 (AVR32)\r
-- Renesas RX600 (e.g., RX62N)\r
-- Microchip dsPIC/PIC24\r
-\r
-These are defined in trcPort.h. This also contains several "unofficial" ports, provided by external contributors.\r
-By unofficial, it means that they are not yet verified by Percepio AB. Please refer to trcPort.h for detailed information. \r
-If you use an unofficial port and beleive it is incorrect, please let us know!\r
-\r
-In case your MCU is not yet supported directly, developing a new port is quite easy, just a matter of defining a few macros\r
-according to your specific MCU. See trcPort.h for further information.\r
-\r
-In case you have any questions, do not hesitate to contact support@percepio.com\r
-\r
-Percepio AB\r
-Kƶpmangatan 1A\r
-72215 VƤsterƄs\r
-Sweden\r
-\r
-www.percepio.com
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
- * Percepio AB, www.percepio.com\r
- *\r
- * trcBase.c\r
- *\r
- * Core functionality of 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
- * 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
-#include "task.h"\r
-\r
-#if (configUSE_TRACE_FACILITY == 1)\r
-\r
-/*******************************************************************************\r
- * Static data initializations\r
- ******************************************************************************/\r
-\r
-\r
-/*******************************************************************************\r
- * RecorderData\r
- *\r
- * The main data structure. This is the data read by FreeRTOS+Trace, 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
- * 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
- * #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
- * 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
- * included where the pragma should go. This is used depending on the setting\r
- * USE_LINKER_PRAGMA, defined in trcConfig.h.\r
- * \r
- * If using GCC, this is instead done by adding a "section" attribute:\r
- *\r
- * RecorderDataType RecorderData __attribute__ ((section ("name"))) = ...\r
- *\r
- * Remember to replace "name" with the correct section name.\r
- ******************************************************************************/\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
-\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
-\r
- /* is recorder active (yes = 1) - note that "close" events are always \r
- stored to keep the name-handle mapping updated!*/\r
- 0,\r
-\r
- /* Generated by FreeRTOS+Trace in Team Admin mode. Otherwise this should be "". */\r
- TEAM_LICENSE_CODE,\r
-\r
- /* debug marker 0 */\r
- 0xF0F0F0F0,\r
-\r
- /* The Object Property Table - holds info of all active objects */ \r
- {\r
- /* Number of object classes, also those not used */\r
- NCLASSES,\r
-\r
- /* The size in bytes of the object table byte pool */\r
- DynObjTableSize,\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
-\r
- /* next free index (0 is reserved to mean NULL) */\r
- 1,\r
-\r
- /* the symbol table byte pool */\r
- {0},\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
-\r
- },\r
-\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
-#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
-\r
-RecorderDataType* RecorderDataPtr = NULL;\r
-\r
-/* This version of the function dynamically allocates the trace data */\r
-RecorderDataType* xTraceInitTraceData(void)\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
-}\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
-void* xTraceNextFreeEventBufferSlot(void)\r
-{\r
- if (RecorderDataPtr->nextFreeIndex >= EVENT_BUFFER_SIZE)\r
- {\r
- vTraceError("Attempt to index outside event buffer!");\r
- return NULL;\r
- }\r
- return (void*)(&RecorderDataPtr->\r
- eventData[RecorderDataPtr->nextFreeIndex*4]);\r
-}\r
-\r
-uint16_t uiIndexOfObject(objectHandleType objecthandle, uint8_t objectclass)\r
-{\r
- if ((objectclass < 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
- }\r
- \r
- vTraceError("Object table lookup with invalid object handle or object class!"); \r
- return 0;\r
-}\r
-\r
-/*******************************************************************************\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
- * 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
- * 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
- ******************************************************************************/\r
-\r
-objectHandleType xTraceGetObjectHandle(traceObjectClass objectclass)\r
-{\r
- static objectHandleType handle;\r
- static int indexOfHandle;\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
- be initialized here (starts at 1). */\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
- /* 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
- 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
- objectHandleStacks.lowestIndexOfClass[objectclass];\r
- \r
- if (hndCount > \r
- objectHandleStacks.handleCountWaterMarksOfClass[objectclass])\r
- {\r
- objectHandleStacks.handleCountWaterMarksOfClass[objectclass] = \r
- (objectHandleType)hndCount;\r
- }\r
- }\r
-\r
- return handle;\r
-}\r
-\r
-void vTraceFreeObjectHandle(traceObjectClass objectclass, objectHandleType handle)\r
-{\r
- int indexOfHandle;\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
- {\r
- /* Error */\r
- vTraceError("Attempt to free more handles than allocated! (duplicate xTaskDelete or xQueueDelete?)");\r
- }\r
- else\r
- {\r
- objectHandleStacks.indexOfNextAvailableHandle[objectclass]--;\r
- indexOfHandle = objectHandleStacks.indexOfNextAvailableHandle[objectclass];\r
- objectHandleStacks.objectHandles[indexOfHandle] = handle;\r
- }\r
-\r
-}\r
-\r
-/*******************************************************************************\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
- * be deleted during runtime. Their handles are only valid during their\r
- * lifetime, i.e., from create to delete, as they might be reused on later\r
- * create operations. When an object is deleted from the OPT, its data is moved\r
- * to the trace buffer and/or the symbol table.\r
- * When an object (task, queue, etc.) is created, it receives a handle, which\r
- * together with the object class specifies its location in the OPT. Thus,\r
- * objects of different types may share the same name and/or handle, but still\r
- * be independent objects.\r
- ******************************************************************************/\r
-\r
-/*******************************************************************************\r
- * vTraceSetObjectName\r
- *\r
- * 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
- const char* name)\r
-{\r
- static uint16_t idx;\r
-\r
- if (handle == 0)\r
- {\r
- vTraceError("Illegal handle (0) in vTraceSetObjectName."); \r
- return;\r
- }\r
- \r
- switch(objectclass)\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
- }\r
-\r
- if (handle > \r
- 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
- }\r
- else\r
- {\r
- idx = uiIndexOfObject(handle, objectclass);\r
-\r
- if (traceErrorMessage == NULL)\r
- {\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
- }\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
- len = 0;\r
- crc = 0;\r
- prvTraceGetChecksum(name, &crc, &len);\r
-\r
- trcCRITICAL_SECTION_BEGIN();\r
- result = prvTraceLookupSymbolTableEntry(name, crc, len, userEventChannel);\r
- if (!result)\r
- {\r
- result = prvTraceCreateSymbolTableEntry(name, crc, len, userEventChannel);\r
- }\r
- trcCRITICAL_SECTION_END();\r
-\r
- return result;\r
-}\r
-\r
-/*******************************************************************************\r
- * Supporting functions\r
- ******************************************************************************/\r
-\r
-/*******************************************************************************\r
- * vTraceError\r
- *\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
- * 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
- * (e.g., NTask) in trcConfig.h is too small.\r
- ******************************************************************************/\r
-void vTraceError(const char* msg)\r
-{\r
- vTraceStop();\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
- }\r
-}\r
-\r
-/******************************************************************************\r
- * prvCheckDataToBeOverwrittenForMultiEntryUserEvents\r
- *\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
- * 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
- * any data entries following must be replaced with NULL events (code 0).\r
- *\r
- * This is assumed to execute within a critical section...\r
- *****************************************************************************/\r
-\r
-void prvCheckDataToBeOverwrittenForMultiEntryUserEvents(\r
- 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 e = 0;\r
- while (i < nofEntriesToCheck)\r
- { \r
- e = RecorderDataPtr->nextFreeIndex + i;\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
- if ((e + nDataEvents) < RecorderDataPtr->maxEvents)\r
- {\r
- (void)memset(& RecorderDataPtr->eventData[e*4], 0, 4 + 4 * nDataEvents);\r
- }\r
- }\r
- i++;\r
- }\r
-}\r
-\r
-/*******************************************************************************\r
- * prvTraceUpdateCounters\r
- *\r
- * Updates the index of the event buffer.\r
- ******************************************************************************/\r
-void prvTraceUpdateCounters(void)\r
-{\r
- if (RecorderDataPtr->recorderActive == 0)\r
- {\r
- return;\r
- }\r
- \r
- RecorderDataPtr->numEvents++;\r
-\r
- RecorderDataPtr->nextFreeIndex++;\r
- \r
- if (RecorderDataPtr->nextFreeIndex >= EVENT_BUFFER_SIZE)\r
- { \r
-#if (RECORDER_STORE_MODE == STORE_MODE_RING_BUFFER) \r
- RecorderDataPtr->bufferIsFull = 1;\r
- RecorderDataPtr->nextFreeIndex = 0;\r
-#else\r
- vTraceStop();\r
-#endif\r
- }\r
-\r
-#if (RECORDER_STORE_MODE == STORE_MODE_RING_BUFFER)\r
- prvCheckDataToBeOverwrittenForMultiEntryUserEvents(1);\r
-#endif\r
- \r
-#ifdef STOP_AFTER_N_EVENTS\r
-#if (STOP_AFTER_N_EVENTS > -1)\r
- if (RecorderDataPtr->numEvents >= STOP_AFTER_N_EVENTS)\r
- {\r
- vTraceStop();\r
- }\r
-#endif\r
-#endif\r
-}\r
- \r
-/******************************************************************************\r
- * prvTraceGetDTS\r
- *\r
- * Returns a differential timestamp (DTS), i.e., the time since\r
- * last event, and creates an XTS event if the DTS does not fit in the\r
- * number of bits given. The XTS event holds the MSB bytes of the DTS.\r
- *\r
- * The parameter param_maxDTS should be 0xFF for 8-bit dts or 0xFFFF for\r
- * events with 16-bit dts fields.\r
- *****************************************************************************/\r
-uint16_t prvTraceGetDTS(uint16_t param_maxDTS)\r
-{\r
- static uint32_t old_timestamp = 0;\r
- XTSEvent* xts = 0;\r
- uint32_t dts = 0;\r
- uint32_t timestamp = 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
- 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
-#endif\r
- }\r
-\r
- /**************************************************************************\r
- * The below statements read the timestamp from the timer port module.\r
- * If necessary, whole seconds are extracted using division while the rest\r
- * comes from the modulo operation.\r
- **************************************************************************/\r
- \r
- uiTracePortGetTimeStamp(×tamp);\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
- ***************************************************************************/\r
- if (timestamp < old_timestamp)\r
- {\r
- timestamp += RecorderDataPtr->frequency;\r
- }\r
-\r
-\r
- dts = timestamp - old_timestamp;\r
- old_timestamp = timestamp;\r
- \r
- if (RecorderDataPtr->frequency > 0)\r
- {\r
- /* Check if dts > 1 second */\r
- if (dts > RecorderDataPtr->frequency)\r
- {\r
- /* More than 1 second has passed */\r
- RecorderDataPtr->absTimeLastEventSecond += dts / RecorderDataPtr->frequency;\r
- /* The part that is not an entire second is added to absTimeLastEvent */\r
- RecorderDataPtr->absTimeLastEvent += dts % RecorderDataPtr->frequency;\r
- }\r
- else\r
- RecorderDataPtr->absTimeLastEvent += dts;\r
- \r
- /* Check if absTimeLastEvent >= 1 second */\r
- if (RecorderDataPtr->absTimeLastEvent >= RecorderDataPtr->frequency)\r
- {\r
- /* RecorderDataPtr->absTimeLastEvent is more than or equal to 1 second, but always less than 2 seconds */\r
- RecorderDataPtr->absTimeLastEventSecond++;\r
- RecorderDataPtr->absTimeLastEvent -= RecorderDataPtr->frequency;\r
- /* RecorderDataPtr->absTimeLastEvent is now less than 1 second */\r
- }\r
- }\r
- else\r
- {\r
- /* Special case if the recorder has not yet started (frequency may be uninitialized, i.e., zero) */\r
- RecorderDataPtr->absTimeLastEvent = timestamp;\r
- }\r
-\r
- /* If the dts (time since last event) does not fit in event->dts (only 8 or 16 bits) */\r
- if (dts > param_maxDTS)\r
- {\r
- /* Create an XTS event (eXtended TimeStamp) containing the higher dts bits*/\r
- xts = (XTSEvent*) xTraceNextFreeEventBufferSlot();\r
-\r
- if (xts != NULL)\r
- {\r
- if (param_maxDTS == 0xFFFF)\r
- {\r
- xts->type = XTS16;\r
- xts->xts_16 = (uint16_t)((dts / 0x10000) & 0xFFFF);\r
- xts->xts_8 = 0;\r
- }\r
- else if (param_maxDTS == 0xFF)\r
- {\r
- xts->type = XTS8;\r
- xts->xts_16 = (uint16_t)((dts / 0x100) & 0xFFFF);\r
- xts->xts_8 = (uint8_t)((dts / 0x1000000) & 0xFF);\r
- }\r
- else\r
- {\r
- vTraceError("Bad param_maxDTS in prvTraceGetDTS");\r
- }\r
- prvTraceUpdateCounters();\r
- }\r
- }\r
-\r
- return (uint16_t)(dts % (param_maxDTS + 1));\r
-}\r
-\r
-/*******************************************************************************\r
- * prvTraceLookupSymbolTableEntry\r
- *\r
- * Find an entry in the symbol table, return 0 if not present.\r
- *\r
- * The strings are stored in a byte pool, with four bytes of "meta-data" for\r
- * every string.\r
- * byte 0-1: index of next entry with same checksum (for fast lookup).\r
- * byte 2-3: reference to a symbol table entry, a label for vTracePrintF\r
- * format strings only (the handle of the destination channel).\r
- * 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 chn)\r
-{\r
- uint16_t i = RecorderDataPtr->SymbolTable.latestEntryOfChecksum[ crc6 ];\r
-\r
- while (i != 0)\r
- {\r
- if (RecorderDataPtr->SymbolTable.symbytes[i + 2] == (chn & 0x00FF))\r
- {\r
- if (RecorderDataPtr->SymbolTable.symbytes[i + 3] == (chn / 0x100))\r
- {\r
- if (RecorderDataPtr->SymbolTable.symbytes[i + 4 + len] == '\0')\r
- {\r
- if (strncmp((char*)(& RecorderDataPtr->SymbolTable.symbytes[i + 4]), name, len) == 0)\r
- {\r
- break; /* found */\r
- }\r
- }\r
- }\r
- }\r
- i = (uint16_t)(RecorderDataPtr->SymbolTable.symbytes[i] + (RecorderDataPtr->SymbolTable.symbytes[i + 1] * 0x100));\r
- }\r
- return i;\r
-}\r
-\r
-/*******************************************************************************\r
- * prvTraceCreateSymbolTableEntry\r
- *\r
- * Creates an entry in the symbol table, independent if it exists already.\r
- *\r
- * The strings are stored in a byte pool, with four bytes of "meta-data" for\r
- * every string.\r
- * byte 0-1: index of next entry with same checksum (for fast lookup).\r
- * byte 2-3: reference to a symbol table entry, a label for vTracePrintF\r
- * format strings only (the handle of the destination channel).\r
- * 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
- traceLabel channel)\r
-{\r
- uint16_t ret = 0;\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
- }\r
- else\r
- {\r
-\r
- RecorderDataPtr->SymbolTable.symbytes\r
- [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex] = \r
- (uint8_t)(RecorderDataPtr->SymbolTable.latestEntryOfChecksum[ crc6 ] & 0x00FF);\r
-\r
- RecorderDataPtr->SymbolTable.symbytes\r
- [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 1] = \r
- (uint8_t)(RecorderDataPtr->SymbolTable.latestEntryOfChecksum[ crc6 ] / 0x100);\r
-\r
- RecorderDataPtr->SymbolTable.symbytes\r
- [ RecorderDataPtr->SymbolTable.nextFreeSymbolIndex + 2] = \r
- (uint8_t)(channel & 0x00FF);\r
-\r
- RecorderDataPtr->SymbolTable.symbytes\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
-\r
- /* Set zero termination (at offest 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
- RecorderDataPtr->SymbolTable.nextFreeSymbolIndex += (len + 5);\r
- \r
- ret = (uint16_t)(RecorderDataPtr->SymbolTable.nextFreeSymbolIndex - \r
- (len + 5));\r
- }\r
- \r
- return ret;\r
-}\r
-\r
-\r
-/*******************************************************************************\r
- * prvTraceGetChecksum\r
- *\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
-{\r
- unsigned char c;\r
- int length = 0;\r
- int crc = 0;\r
- if ( pname != (const char *) 0 )\r
- {\r
- for ( ; (c = *pname++) != '\0'; )\r
- {\r
- crc += c;\r
- length++;\r
- }\r
- }\r
- *pcrc = (uint8_t)(crc % 64);\r
- *plength = (uint8_t)length;\r
-}\r
-\r
-#endif\r
+++ /dev/null
-/*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 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
- * 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
-#include "trcUser.h"\r
-#include "task.h"\r
-\r
-#if (configUSE_TRACE_FACILITY == 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
-\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
-\r
-#if !defined INCLUDE_READY_EVENTS || INCLUDE_READY_EVENTS == 1\r
-/*******************************************************************************\r
- * vTraceStoreTaskReady\r
- *\r
- * This function stores a ready state for the task handle sent in as parameter.\r
- ******************************************************************************/\r
-void vTraceStoreTaskReady(objectHandleType handle)\r
-{\r
- uint16_t dts3;\r
- TREvent* tr;\r
-\r
- if (!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 = TR_TASK_READY;\r
- tr->dts = dts3;\r
- tr->objHandle = handle;\r
-\r
- prvTraceUpdateCounters(); \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
- ******************************************************************************/\r
-void vTraceStoreKernelCall(uint32_t ecode, traceObjectClass objectClass, uint32_t objectNumber)\r
-{\r
- KernelCall * kse;\r
- uint16_t dts1;\r
-\r
- if (handle_of_last_logged_task == 0)\r
- {\r
- return;\r
- }\r
- \r
- if (RecorderDataPtr->recorderActive)\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
- {\r
- trcCRITICAL_SECTION_BEGIN();\r
- dts1 = (uint16_t)prvTraceGetDTS(0xFFFF);\r
-\r
- if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */\r
- { \r
- kse = (KernelCall*) xTraceNextFreeEventBufferSlot();\r
- if (kse != NULL)\r
- {\r
- kse->dts = dts1;\r
- kse->type = (uint8_t)ecode;\r
- kse->objHandle = (uint8_t)objectNumber;\r
- prvTraceUpdateCounters();\r
- }\r
- }\r
- trcCRITICAL_SECTION_END();\r
- }\r
- }\r
- }\r
-}\r
-\r
-/*******************************************************************************\r
- * vTraceStoreKernelCallWithParam\r
- *\r
- * Used for storing kernel calls with a handle and a numeric parameter. This is\r
- * only used for traceTASK_PRIORITY_SET at the moment.\r
- ******************************************************************************/\r
-void vTraceStoreKernelCallWithParam(uint32_t evtcode,\r
- traceObjectClass objectClass,\r
- uint32_t objectNumber,\r
- uint8_t param)\r
-{\r
- KernelCallWithParamAndHandle * kse;\r
- uint8_t dts2;\r
-\r
- if (RecorderDataPtr->recorderActive && handle_of_last_logged_task && \r
- (! inExcludedTask || nISRactive))\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
- {\r
- trcCRITICAL_SECTION_BEGIN();\r
- dts2 = (uint8_t)prvTraceGetDTS(0xFF);\r
-\r
- if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */\r
- { \r
- kse = (KernelCallWithParamAndHandle*) xTraceNextFreeEventBufferSlot();\r
- if (kse != NULL)\r
- {\r
- kse->dts = dts2;\r
- kse->type = (uint8_t)evtcode;\r
- kse->objHandle = (uint8_t)objectNumber;\r
- kse->param = param;\r
- prvTraceUpdateCounters(); \r
- }\r
- }\r
- trcCRITICAL_SECTION_END();\r
- }\r
- }\r
-}\r
-\r
-\r
-/*******************************************************************************\r
- * vTraceStoreKernelCallWithNumericParamOnly\r
- *\r
- * 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
-{\r
- KernelCallWithParam16 * kse;\r
- uint8_t dts6;\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
- {\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
- 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
-{\r
- uint16_t dts3;\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
- 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
- "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
-\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
- ***************************************************************************/\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
-\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
- skipEvent = 1;\r
- inExcludedTask = 1; \r
- }\r
- else\r
- inExcludedTask = 0;\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
- {\r
- skipEvent = 1;\r
- }\r
-\r
- /* If this event should be logged, log it! */\r
- if (skipEvent == 0) \r
- { \r
- dts3 = (uint16_t)prvTraceGetDTS(0xFFFF);\r
- \r
- if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */\r
- {\r
- handle_of_last_logged_task = handle_of_running_task; \r
- ts = (TSEvent*)xTraceNextFreeEventBufferSlot();\r
-\r
- if (ts != NULL)\r
- {\r
- if (uiTraceGetObjectState(TRACE_CLASS_TASK,\r
- handle_of_last_logged_task) == TASK_STATE_INSTANCE_ACTIVE)\r
- {\r
- ts->type = TS_TASK_RESUME;\r
- }\r
- else\r
- {\r
- ts->type = TS_TASK_BEGIN;\r
- }\r
-\r
- ts->dts = dts3;\r
- ts->objHandle = handle_of_last_logged_task;\r
-\r
- vTraceSetObjectState(TRACE_CLASS_TASK, \r
- handle_of_last_logged_task, \r
- TASK_STATE_INSTANCE_ACTIVE);\r
-\r
- prvTraceUpdateCounters(); \r
- }\r
- }\r
- } \r
-\r
- /* See comment on recorder_busy++ above. */\r
- recorder_busy--; \r
-}\r
-\r
-/*******************************************************************************\r
- * vTraceStoreNameCloseEvent\r
- *\r
- * Updates the symbol table with the name of this object from the dynamic\r
- * objects table and stores a "close" event, holding the mapping between handle\r
- * and name (a symbol table handle). The stored name-handle mapping is thus the\r
- * "old" one, valid up until this point.\r
- ******************************************************************************/\r
-#if (INCLUDE_OBJECT_DELETE == 1)\r
-void vTraceStoreObjectNameOnCloseEvent(objectHandleType handle, \r
- traceObjectClass objectclass)\r
-{ \r
- ObjCloseNameEvent * ce;\r
- const char * name;\r
- traceLabel idx;\r
-\r
- name = 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
- traceObjectClass objectclass)\r
-{\r
- ObjClosePropEvent * pe;\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
-}\r
-#endif\r
-\r
-void vTraceSetPriorityProperty(uint8_t objectclass, uint8_t id, uint8_t value)\r
-{\r
- 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
-}\r
-\r
-void vTraceSetObjectState(uint8_t objectclass, uint8_t id, uint8_t value)\r
-{\r
- PROPERTY_OBJECT_STATE(objectclass, id) = value;\r
-}\r
-\r
-void vTraceSetTaskInstanceFinished(objectHandleType handle)\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
-}\r
-\r
-uint8_t uiTraceGetObjectState(uint8_t objectclass, uint8_t id)\r
-{\r
- return PROPERTY_OBJECT_STATE(objectclass, id);\r
-}\r
-\r
-#endif\r
+++ /dev/null
-/*******************************************************************************\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
+++ /dev/null
-/*******************************************************************************\r
- * FreeRTOS+Trace v2.3.0 Recorder Library\r
- * Percepio AB, www.percepio.com\r
- *\r
- * trcUser.c\r
- *\r
- * The public API of 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
- * 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 <string.h>\r
-#include <stdarg.h>\r
-\r
-#include "trcUser.h"\r
-#include "task.h"\r
-#include "semphr.h"\r
-\r
-#if (configUSE_TRACE_FACILITY == 1)\r
-\r
-extern uint8_t inExcludedTask;\r
-extern uint8_t nISRactive;\r
-extern uint8_t handle_of_last_logged_task;\r
-extern uint32_t dts_min;\r
-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
- * vTraceMonitorTask\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
- ******************************************************************************/\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
-\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
-\r
-/*******************************************************************************\r
- * vTraceClear\r
- *\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
- 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
- * has a too small value (NTASK, NQUEUE, etc).\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
- * 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
- ******************************************************************************/\r
-\r
-uint32_t uiTraceStart(void)\r
-{ \r
- if (traceErrorMessage == NULL)\r
- {\r
- trcCRITICAL_SECTION_BEGIN();\r
- RecorderDataPtr->recorderActive = 1;\r
- vTraceStoreTaskswitch(); /* Register the currently running task */\r
- trcCRITICAL_SECTION_END();\r
- }\r
-\r
- return RecorderDataPtr->recorderActive;\r
-}\r
-\r
-/*******************************************************************************\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
- * has a too small value (NTASK, NQUEUE, etc).\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
- (void)uiTraceStart();\r
-}\r
-\r
-/*******************************************************************************\r
- * 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
- ******************************************************************************/\r
-void vTraceStop(void)\r
-{\r
- RecorderDataPtr->recorderActive = 0;\r
-}\r
-\r
-/*******************************************************************************\r
- * xTraceGetLastError\r
- *\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
- ******************************************************************************/\r
-char* xTraceGetLastError(void)\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
- * the data.\r
- ******************************************************************************/\r
-void* vTraceGetTraceBuffer(void)\r
-{\r
- return RecorderDataPtr;\r
-}\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
- * e.g., in case a debugger connection is not available for uploading the data.\r
- ******************************************************************************/\r
-uint32_t uiTraceGetTraceBufferSize(void)\r
-{\r
- 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
-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
- }\r
-}\r
-\r
-/*******************************************************************************\r
- * Interrupt recording functions \r
- ******************************************************************************/\r
-\r
-#if (INCLUDE_ISR_TRACING == 1)\r
-\r
-#define MAX_ISR_NESTING 16\r
-static uint8_t isrstack[MAX_ISR_NESTING];\r
-\r
-/*******************************************************************************\r
- * vTraceSetISRProperties\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
- * started.\r
- *\r
- * Example:\r
- * #define ID_ISR_TIMER1 1 // lowest valid ID is 1\r
- * #define PRIO_OF_ISR_TIMER1 3 // the hardware priority of the interrupt\r
- * ...\r
- * vTraceSetISRProperties(ID_ISR_TIMER1, "ISRTimer1", PRIO_OF_ISR_TIMER1);\r
- * ...\r
- * void ISR_handler()\r
- * {\r
- * vTraceStoreISRBegin(ID_OF_ISR_TIMER1);\r
- * ...\r
- * 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
- * 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
- vTraceSetObjectName(TRACE_CLASS_ISR, handle, name);\r
- vTraceSetPriorityProperty(TRACE_CLASS_ISR, handle, priority);\r
-}\r
-\r
-/*******************************************************************************\r
- * vTraceStoreISRBegin\r
- * \r
- * Registers the beginning of an Interrupt Service Routine.\r
- *\r
- * Example:\r
- * #define ID_ISR_TIMER1 1 // lowest valid ID is 1\r
- * #define PRIO_OF_ISR_TIMER1 3 // the hardware priority of the interrupt\r
- * ...\r
- * vTraceSetISRProperties(ID_ISR_TIMER1, "ISRTimer1", PRIO_OF_ISR_TIMER1);\r
- * ...\r
- * void ISR_handler()\r
- * {\r
- * vTraceStoreISRBegin(ID_OF_ISR_TIMER1);\r
- * ...\r
- * 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
- * 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
- * using vTraceError.\r
- ******************************************************************************/\r
-void vTraceStoreISRBegin(objectHandleType handle)\r
-{\r
- uint16_t dts4;\r
- TSEvent* ts = NULL;\r
-\r
- if (recorder_busy)\r
- {\r
- vTraceError("Illegal call to vTraceStoreISRBegin/End");\r
- return;\r
- }\r
- if (RecorderDataPtr->recorderActive && handle_of_last_logged_task)\r
- { \r
- trcCRITICAL_SECTION_BEGIN();\r
- dts4 = (uint16_t)prvTraceGetDTS(0xFFFF);\r
-\r
- if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */ \r
- { \r
-\r
- if (nISRactive < MAX_ISR_NESTING)\r
- { \r
- isrstack[nISRactive] = handle;\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
- }\r
- }\r
- else\r
- { \r
- /* This should not occur unless something is very wrong */ \r
- vTraceError("Too many nested interrupts!");\r
- } \r
- }\r
- trcCRITICAL_SECTION_END(); \r
- }\r
-}\r
-\r
-\r
-#if (SELECTED_PORT == PORT_ARM_CortexM)\r
-\r
-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
- * interrupt is pending. This is used to predict tailchaining of ISRs.\r
- ******************************************************************************/\r
-int tailchain_irq_pending(void)\r
-{\r
- uint32_t* pend_reg = ((uint32_t*)0xE000E200);\r
- int i;\r
-\r
- for (i=0; i<8; i++)\r
- {\r
- if (pend_reg[i] != 0)\r
- {\r
- return 1;\r
- }\r
- }\r
- return 0; \r
-}\r
-\r
-#endif\r
-\r
-/*******************************************************************************\r
- * vTraceStoreISREnd\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
- * #define PRIO_OF_ISR_TIMER1 3 // the hardware priority of the interrupt\r
- * ...\r
- * vTraceSetISRProperties(ID_ISR_TIMER1, "ISRTimer1", PRIO_OF_ISR_TIMER1);\r
- * ...\r
- * void ISR_handler()\r
- * {\r
- * vTraceStoreISRBegin(ID_OF_ISR_TIMER1);\r
- * ...\r
- * 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
- * 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
- * using vTraceError.\r
- ******************************************************************************/\r
-void vTraceStoreISREnd(void)\r
-{\r
- TSEvent* ts;\r
- uint16_t dts5;\r
-\r
- if (recorder_busy)\r
- {\r
- vTraceError("Illegal call to vTraceStoreISRBegin/End");\r
- return;\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
- short fragment of the earlier preempted task/ISR, and then the new\r
- ISR begins. */\r
- return;\r
- }\r
- #endif\r
- \r
- trcCRITICAL_SECTION_BEGIN();\r
- dts5 = (uint16_t)prvTraceGetDTS(0xFFFF);\r
-\r
- if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */ \r
- { \r
- ts = (TSEvent*)xTraceNextFreeEventBufferSlot();\r
- if (ts != NULL)\r
- {\r
- if (nISRactive > 1)\r
- {\r
- /* return to another isr */\r
- ts->type = TS_ISR_RESUME;\r
- ts->objHandle = isrstack[nISRactive];\r
- }\r
- else\r
- {\r
- /* return to task */\r
- ts->type = TS_TASK_RESUME;\r
- ts->objHandle = handle_of_last_logged_task;\r
- }\r
- ts->dts = dts5;\r
- nISRactive--;\r
- prvTraceUpdateCounters();\r
- }\r
- }\r
- trcCRITICAL_SECTION_END(); \r
- }\r
-}\r
-\r
-#else\r
-\r
-/* ISR tracing is turned off */\r
-void vTraceIncreaseISRActive(void)\r
-{\r
- if (RecorderDataPtr->recorderActive && handle_of_last_logged_task)\r
- nISRactive++;\r
-}\r
-\r
-void vTraceDecreaseISRActive(objectHandleType handle)\r
-{\r
- if (RecorderDataPtr->recorderActive && handle_of_last_logged_task)\r
- nISRactive--;\r
-}\r
-#endif\r
-\r
-\r
-/*******************************************************************************\r
- * User Event functions\r
- ******************************************************************************/\r
-\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
-/*** Locally used in vTracePrintF ***/\r
-static uint8_t writeInt8(void * buffer, uint8_t i, uint8_t value)\r
-{ \r
- \r
- if (i >= MAX_ARG_SIZE)\r
- {\r
- return 255;\r
- }\r
-\r
- ((uint8_t*)buffer)[i] = value;\r
-\r
- if (i + 1 > MAX_ARG_SIZE)\r
- {\r
- return 255;\r
- }\r
-\r
- return i + 1;\r
-}\r
-\r
-/*** Locally used in vTracePrintF ***/\r
-static uint8_t writeInt16(void * buffer, uint8_t i, uint16_t value)\r
-{ \r
- /* Align to multiple of 2 */\r
- while ((i % 2) != 0)\r
- {\r
- if (i >= MAX_ARG_SIZE)\r
- {\r
- return 255;\r
- }\r
- \r
- ((uint8_t*)buffer)[i] = 0;\r
- i++; \r
- }\r
- \r
- if (i + 2 > MAX_ARG_SIZE)\r
- {\r
- return 255;\r
- }\r
-\r
- ((uint16_t*)buffer)[i/2] = value;\r
-\r
- return i + 2;\r
-}\r
-\r
-/*** Locally used in vTracePrintF ***/\r
-static uint8_t writeInt32(void * buffer, uint8_t i, uint32_t value)\r
-{\r
- \r
- /* A 32 bit value should begin at an even 4-byte address */\r
- while ((i % 4) != 0)\r
- {\r
- if (i >= MAX_ARG_SIZE)\r
- {\r
- return 255;\r
- }\r
- \r
- ((uint8_t*)buffer)[i] = 0;\r
- i++;\r
- }\r
- \r
- if (i + 4 > MAX_ARG_SIZE)\r
- {\r
- return 255;\r
- } \r
-\r
- ((uint32_t*)buffer)[i/4] = value;\r
-\r
- return i + 4;\r
-}\r
-\r
-#if (INCLUDE_FLOAT_SUPPORT)\r
-\r
-/*** Locally used in vTracePrintF ***/\r
-static uint8_t writeFloat(void * buffer, uint8_t i, float value)\r
-{\r
- /* A 32 bit value should begin at an even 4-byte address */\r
- while ((i % 4) != 0)\r
- {\r
- if (i >= MAX_ARG_SIZE)\r
- {\r
- return 255;\r
- }\r
-\r
- ((uint8_t*)buffer)[i] = 0;\r
- i++;\r
- }\r
-\r
- if (i + 4 > MAX_ARG_SIZE)\r
- {\r
- return 255;\r
- } \r
-\r
- ((float*)buffer)[i/4] = value;\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
- 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
- 4-byte address (to avoid having to align with 8 byte) */\r
- while (i % 4 != 0)\r
- {\r
- if (i >= MAX_ARG_SIZE)\r
- {\r
- return 255;\r
- }\r
-\r
- ((uint8_t*)buffer)[i] = 0;\r
- i++; \r
- }\r
- \r
- if (i + 8 > MAX_ARG_SIZE)\r
- {\r
- return 255;\r
- } \r
- \r
- dest[i/4+0] = src[0];\r
- dest[i/4+1] = src[1];\r
- \r
- return i + 8;\r
-}\r
-\r
-#endif\r
-\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
- * stores the arguments. The actual formatting is done\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
- * 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
- * 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
- * better to use vTraceUserEvent - it is faster.\r
- *\r
- * Format specifiers supported:\r
- * %d - 32 bit signed integer\r
- * %u - 32 bit unsigned integer\r
- * %f - 32 bit float\r
- * %s - string (is copied to the recorder symbol table)\r
- * %hd - 16 bit signed integer\r
- * %hu - 16 bit unsigned integer\r
- * %bd - 8 bit signed integer\r
- * %bu - 8 bit unsigned integer\r
- * %lf - double-precision float\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
- * 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
- * double (%lf) uses two records, so this is quite costly. Use float (%f) unless\r
- * the higher precision is really necessary.\r
- ******************************************************************************/\r
-void vTracePrintF(traceLabel eventLabel, const char* formatStr, ...)\r
-{\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
-\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
- * 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
- * global. That would cause data corruption when two calls to vTracePrintF\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
-\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
-\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
-\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
-\r
- va_end(vl);\r
- \r
- /* Store the format string, with a reference to the channel symbol */\r
- ue1->payload = prvTraceOpenSymbol(formatStr, eventLabel); \r
-\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
- buffer, and the recorder stopped since not circular buffer. */\r
- trcCRITICAL_SECTION_END();\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
- 0 if allowed, otherwise stop the recorder and quit). */\r
- if (RecorderDataPtr->nextFreeIndex + nofEventEntries > RecorderDataPtr->maxEvents)\r
- {\r
-#if (RECORDER_STORE_MODE == 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
-#else\r
- /* Abort and stop recorder, since the event data will not fit in the\r
- buffer and not circular buffer in this case... */\r
- trcCRITICAL_SECTION_END();\r
- vTraceStop();\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
- 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
- using a memset to zero).*/\r
- prvCheckDataToBeOverwrittenForMultiEntryUserEvents(nofEventEntries);\r
-#endif\r
- /* Copy the local buffer to the main buffer */\r
- (void)memcpy(& RecorderDataPtr->eventData[RecorderDataPtr->nextFreeIndex * 4], \r
- tempDataBuffer, \r
- i);\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
- 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
- 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
-#else\r
- vTraceStop();\r
-#endif\r
- }\r
-\r
- trcCRITICAL_SECTION_END();\r
- } \r
-}\r
- \r
-/*******************************************************************************\r
- * xTraceOpenLabel\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
- * xTraceOpenLabel()\r
- *\r
- * which adds the string to the symbol table (if not already present)\r
- * and returns the corresponding handle.\r
- *\r
- * This can be used in two ways:\r
- *\r
- * 1. The handle is looked up every time, when storing the user event.\r
- *\r
- * Example:\r
- * vTraceUserEvent(xTraceOpenLabel("MyUserEvent"));\r
- *\r
- * 2. The label is registered just once, with the handle stored in an\r
- * application variable - much like using a file handle.\r
- *\r
- * Example:\r
- * myEventHandle = xTraceOpenLabel("MyUserEvent");\r
- * ...\r
- * vTraceUserEvent(myEventHandle);\r
- *\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
- return prvTraceOpenSymbol(label, 0);\r
-}\r
-#endif\r
-#endif\r
-\r