From: rtel Date: Thu, 1 Jun 2017 14:16:16 +0000 (+0000) Subject: Update trace recorder source to fix some compile time warnings. X-Git-Tag: V10.0.0~4 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=edc2fd6b0666957574ad5e1fda384b73f2464ee5;p=freertos Update trace recorder source to fix some compile time warnings. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2515 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/Demo.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/Demo.c deleted file mode 100644 index 39f7ff88d..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/Demo.c +++ /dev/null @@ -1,566 +0,0 @@ -/******************************************************************************* - * Tracealyzer v3.0.0 Demo Application - * Percepio AB, www.percepio.com - * - * traceDemoApp.c - * - * Demo application for Tracealyzer demo project. - * - * Terms of Use - * This software is copyright Percepio AB. The recorder library is free for - * use together with Percepio products. You may distribute the recorder library - * in its original form, including modifications in trcHardwarePort.c/.h - * given that these modification are clearly marked as your own modifications - * and documented in the initial comment section of these source files. - * This software is the intellectual property of Percepio AB and may not be - * sold or in other ways commercially redistributed without explicit written - * permission by Percepio AB. - * - * Disclaimer - * The trace tool and recorder library is being delivered to you AS IS and - * Percepio AB makes no warranty as to its use or performance. Percepio AB does - * not and cannot warrant the performance or results you may obtain by using the - * software or documentation. Percepio AB make no warranties, express or - * implied, as to noninfringement of third party rights, merchantability, or - * fitness for any particular purpose. In no event will Percepio AB, its - * technology partners, or distributors be liable to you for any consequential, - * incidental or special damages, including any lost profits or lost savings, - * even if a representative of Percepio AB has been advised of the possibility - * of such damages, or for any claim by any third party. Some jurisdictions do - * not allow the exclusion or limitation of incidental, consequential or special - * damages, or the exclusion of implied warranties or limitations on how long an - * implied warranty may last, so the above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2014. - * www.percepio.com - ******************************************************************************/ - - -/* Standard includes. */ -#include -#include - -/* Kernel includes. */ -#include -#include "task.h" -#include "queue.h" -#include "semphr.h" - -#if (configUSE_TIMERS == 1) - #include "timers.h" -#endif - -#include "trcRecorder.h" - -#define ISR3_PERIOD 18 -#define ISR2_PERIOD 24 -#define ISR1_PERIOD 30 - -#define EXECTIME_CONTROLLER 1 -#define EXECTIME_SUPERV 2 -#define EXECTIME_SENSOR 1 - -typedef struct -{ - int32_t code; - int32_t value; - char data[512]; // Makes the Memory Heap Utilization graph more interresting! -} QueueMessage; - -#define MSGCODE_SENSOR_VALUE 1 -#define MSGCODE_CONTROL_VALUE 10 -#define MSGCODE_CONTROL_DEFAULT_VALUE 99 - -static portTASK_FUNCTION_PROTO( trcDemoTaskSensor, pvParameters ); -static portTASK_FUNCTION_PROTO( trcDemoTaskActuator, pvParameters ); -static portTASK_FUNCTION_PROTO( trcDemoTaskController, pvParameters ); -static portTASK_FUNCTION( trcDemoTaskSuperv, pvParameters ); -static portTASK_FUNCTION( trcDemoISR, pvParameters ); - -#if (configUSE_TIMERS == 1) -xTimerHandle timer; -void myTimerHandler(xTimerHandle tmr); -#endif - -xQueueHandle sensorQ, actuatorQ; -xSemaphoreHandle Sem1, Sem2, Sem3; - -void doSomeWork(uint32_t n); - -int readSensor(int i); - -/****************************************************************************** -* doSomeWork -* -* Performs a busy wait for X milliseconds. Used to generate suitable execution -* times in the demo application, in a portable way. -******************************************************************************/ -void doSomeWork(uint32_t ms) -{ - portTickType old = xTaskGetTickCount(); - portTickType new = 0; - while (ms > 0) - { - new = xTaskGetTickCount(); - if (old < new) - { - /* If uiTraceTickCount has changed, we only reduce 1ms of the wait - time. This way we do not count time that this task has waited - for other tasks. This will result in somewhat correct execution - times. */ - old = new; - ms--; - } - } -} - -/****************************************************************************** -* readSensor -* -* Simulates a set of sensors/inputs, using a simple physics simulation. -* The values are intentionally ints (rather than floats) to avoid very slow -* execution times on chips without hardware floating point support. -******************************************************************************/ -int readSensor(int i) -{ - static int pos[3] = {40, 80, 120}; - static int speed[3] = {0, 0, -3}; - static int acc[3] = {0, 0, 0}; - - i--; - - acc[i] = (-pos[i] >> 3); - speed[i] += acc[i]; - pos[i] += speed[i]; - - return (int)pos[i]; -} - -/****************************************************************************** -* trcDemoTaskSensor -* -* The "Sensor" tasks (three instances of this code). Reads data using -* "readSensor" when trigged by the timer interrupt through a semaphore. -******************************************************************************/ -static portTASK_FUNCTION( trcDemoTaskSensor, pvParameters ) -{ - char name[30] = "SensorX\0"; - QueueMessage sensorReading; - unsigned char idx = (unsigned char)(*(int*)pvParameters); - xSemaphoreHandle mySem = NULL; - - /* Change 'X' to the index */ - name[6] = '0' + idx; - - switch (idx) - { - case 1: mySem = Sem1; break; - case 2: mySem = Sem2; break; - case 3: mySem = Sem3; break; - } - - vTraceStoreUserEventChannelName(name); - - /* Initialize xNextWakeTime - this only needs to be done once. */ - - sensorReading.value = 0; - sensorReading.code = 0; - - for( ;; ) - { - - xSemaphoreTake(mySem, 0xFFFFFFFF); - - sensorReading.code = idx; - sensorReading.value = readSensor(idx); - - doSomeWork(EXECTIME_SENSOR); - - vTracePrintF(name , "Sending msg %d", sensorReading.value); - - if (xQueueSend(sensorQ, &sensorReading, 1) != pdTRUE) - { - vTracePrint(name, "Sensor queue full. Sample dropped!"); - } - vTraceInstanceFinishedNow(); - } -} - - - -/****************************************************************************** -* trcDemoTaskSuperv -* -* The "Supervisor" task. Performs no action in the simulation, apart from -* preempting other tasks in the scheduling. -******************************************************************************/ -static portTASK_FUNCTION( trcDemoTaskSuperv, pvParameters ) -{ - int counter = 0; - - #if (configUSE_TIMERS == 1) - static int timerState = 0; - #endif - - portTickType xNextWakeTime; - (void)pvParameters; - - xNextWakeTime = xTaskGetTickCount(); - - #if (configUSE_TIMERS == 1) - timer = xTimerCreate("Tmr5", 5, 1, (void*)42, myTimerHandler); - xTimerChangePeriod(timer, 10, 0); - #endif - - for( ;; ) - { - vTaskDelayUntil( &xNextWakeTime, 40); - - counter = (counter + 1) % 16; - - if (counter == 8) vTaskPrioritySet(NULL, 2); - - if (counter == 0) vTaskPrioritySet(NULL, 3); - - doSomeWork(EXECTIME_SUPERV); - - #if (configUSE_TIMERS == 1) - if (timerState == 0) - { - xTimerStart(timer, 0); - timerState = 1; - } - else if (timerState == 1) - { - xTimerStop(timer, 0); - timerState = 0; - } - #endif - } -} - -/****************************************************************************** -* trcDemoTaskController -* -* The "Controller" task. Periodically reads all accumulated messages in SensorQ -* (i.e., those produced by the Sensor tasks since the last execution of -* the Controller task). Calculates their mean value and send this to Actuator. -******************************************************************************/ -static portTASK_FUNCTION( trcDemoTaskController, pvParameters ) -{ - portTickType xNextWakeTime; - QueueMessage* sensorReading; - QueueMessage actuatorMessage; - int32_t sum[4]; - int32_t count[4]; - - (void)pvParameters; - - vTraceStoreUserEventChannelName("UE TEST"); - - /* Initialize xNextWakeTime - this only needs to be done once. */ - xNextWakeTime = xTaskGetTickCount(); - for(;;) - { - sum[1] = 0; - sum[2] = 0; - sum[3] = 0; - count[1] = 0; - count[2] = 0; - count[3] = 0; - - vTaskDelayUntil(&xNextWakeTime, 60); - - for(;;) - { - // To demostrate malloc/free tracing - sensorReading = ( QueueMessage * ) pvPortMalloc( sizeof( QueueMessage ) ); - - if (xQueueReceive(sensorQ, sensorReading, 0) != pdTRUE) - { - vPortFree(sensorReading); - break; - } - else - { - if (sensorReading->code >= 1 && sensorReading->code <= 3) - { - sum[sensorReading->code] += sensorReading->value; - count[sensorReading->code]++; - } - } - doSomeWork(EXECTIME_CONTROLLER); - - //vTracePrintF(0, "0x%4x", 111); - //vTracePrintF(0, "0x%04x", 111); - //vTracePrintF(0, "0x%4X", 111); - //vTracePrintF(0, "0x%04X", 111); - // - //vTracePrint(0, "123456789012345678901234567890123456789012345678901234567890"); - //vTracePrint("UE TEST", "1234567890123456789012345678901234567890123456789012345"); - //vTracePrint("UE TEST", "12345678901234567890123456789012345678901234567890123456"); - //vTracePrint("UE TEST", "123456789012345678901234567890123456789012345678901234567"); - //vTracePrint("UE TEST", "12345678901234567890123456789012345678901234567890"); - // - //vTracePrintF("UE TEST", "%5d", 42); - //vTracePrintF("UE TEST", "%05d", 42); - //vTracePrintF("UE TEST", "%5d", -42); - //vTracePrintF("UE TEST", "%05d", -42); - //vTracePrintF("UE TEST", "%05d", -1042); - //vTracePrintF("UE TEST", "%05d", -11042); - // - //vTracePrintF("UE TEST", "%5u", -1); - //vTracePrintF("UE TEST", "%05u", -1); - //vTracePrintF("UE TEST", "%5u", 10); - //vTracePrintF("UE TEST", "%05u", 10); - // - //vTracePrintF("UE TEST", "%5u", 11042); - //vTracePrintF("UE TEST", "%05u", 11042); - // - //vTracePrintF("UE TEST", "%5u", 111042); - //vTracePrintF("UE TEST", "%05u", 111042); - // - //vTracePrintF("UE TEST", "%15d", 111042); - //vTracePrintF("UE TEST", "%015d", 111042); - - vPortFree(sensorReading); - vTraceInstanceFinishedNow(); - - } - - actuatorMessage.code = MSGCODE_CONTROL_VALUE; - actuatorMessage.value = 0; - - if (count[1] > 0) - actuatorMessage.value += (int32_t)(0.5 * sum[1]/count[1]); - if (count[2] > 0) - actuatorMessage.value += (int32_t)(0.25 * sum[2]/count[2]); - if (count[3] > 0) - actuatorMessage.value += (int32_t)(0.25 * sum[3]/count[3]); - - xQueueSend(actuatorQ, &actuatorMessage, 10000); - } -} - -/****************************************************************************** -* trcDemoISR -* -* The "FakeISR" task, that simulates the ISRTimer interrupts, which triggers -* the Sensor tasks. -******************************************************************************/ -static portTASK_FUNCTION( trcDemoISR, pvParameters ) -{ - portTickType xNextWakeTime; - portBASE_TYPE dummy; - int i = 0; - - (void)pvParameters; - - /* Initialize xNextWakeTime - this only needs to be done once. */ - xNextWakeTime = xTaskGetTickCount(); - vTraceSetISRProperties("ISRTimer1", 3); - vTraceSetISRProperties("ISRTimer2", 2); - vTraceSetISRProperties("ISRTimer3", 1); - vTaskDelayUntil( &xNextWakeTime, 1); - - for( ;; ) - { - i++; - - if (i % ISR3_PERIOD == 0) - { - portENTER_CRITICAL(); - vTraceStoreISRBegin((void*)"ISRTimer3"); - xSemaphoreGiveFromISR(Sem3, &dummy); - vTraceStoreISREndManual(dummy); - portEXIT_CRITICAL(); - } - - if (i % ISR2_PERIOD == 0) - { - portENTER_CRITICAL(); - vTraceStoreISRBegin((void*)"ISRTimer2"); - xSemaphoreGiveFromISR(Sem2, &dummy); - vTraceStoreISREndManual(dummy); - portEXIT_CRITICAL(); - } - - if (i % ISR1_PERIOD == 0) - { - portENTER_CRITICAL(); - vTraceStoreISRBegin((void*)"ISRTimer1"); - xSemaphoreGiveFromISR(Sem1, &dummy); - vTraceStoreISREndManual(dummy); - portEXIT_CRITICAL(); - - - } - - vTaskDelayUntil( &xNextWakeTime, 1); - } -} - -/****************************************************************************** -* trcDemoTaskActuator -* -* The "Actuator" task, just reads the data from Controller and logs it in a -* User Event (i.e., the "vTracePrintF" calls). -******************************************************************************/ -static portTASK_FUNCTION( trcDemoTaskActuator, pvParameters ) -{ - QueueMessage inMessage; - (void)pvParameters; - vTraceStoreUserEventChannelName("Actuator Out Signal"); - - for( ;; ) - { - vTraceInstanceFinishedNow(); - /* Place this task in blocked state until it is time to run again. */ - if (xQueueReceive(actuatorQ, &inMessage, 35) != pdTRUE) - { - vTracePrintF("Actuator Out Signal", "No data..."); - } - else - { - if (inMessage.code == MSGCODE_CONTROL_VALUE) - { - vTracePrintF("Actuator Out Signal", "Out: %d", - inMessage.value); - } - } - } -} - -#if (configUSE_TIMERS == 1) -void myTimerHandler(xTimerHandle tmr) -{ - (void) tmr; - vTracePrintF("Timer", "Timer handler!"); -} -#endif - -int sensorTaskID1 = 1; -int sensorTaskID2 = 2; -int sensorTaskID3 = 3; - -#define vTaskCreateNotTraced( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority ) \ - { void* this_pxCreatedTask; \ - vTraceSetReadyEventsEnabled(0); \ - xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( &this_pxCreatedTask ), ( NULL ), ( NULL ) ); \ - vTraceSetReadyEventsEnabled(1); \ - if (this_pxCreatedTask != NULL){ vTraceExcludeTaskFromTrace(this_pxCreatedTask); }else{ return -42;} } - -/****************************************************************************** -* trcDemoTaskActuator -* -* The "Actuator" task, just reads the data from Controller and logs it in a -* User Event (i.e., the "vTracePrintF" calls). -******************************************************************************/ -int vStartDemoApplication(void) -{ - void* objectHandle = NULL; - - vTraceStoreUserEventChannelName("Messages"); - - vTracePrint("Messages", "Demo starting..."); - vTracePrint("Messages", "vTraceUserEvent creates basic User Events."); - vTracePrint("Messages", "vTracePrintF creates advanced user events, like printf"); - //vTracePrintF("Messages", "A float: %f (should be 1)", (float)1.0); - //vTracePrintF("Messages", "A double: %lf (should be 1)", (double)1.0); - //vTracePrintF("Messages", "A signed 8-bit value: %bd (should be -1)", -1); - - vTraceStoreUserEventChannelName("Timer"); - - sensorQ = xQueueCreate(15, sizeof(QueueMessage) ); - if( sensorQ == 0 ) - { - vTracePrint("Messages", "Could not create SensorQ!\n"); - return -1; - } - vTraceSetQueueName(sensorQ, "SensorQueue"); - - actuatorQ = xQueueCreate(3, sizeof(QueueMessage) ); - if( actuatorQ == 0 ) - { - vTracePrint("Messages", "Could not create ActuatorQ!\n"); - return -2; - } - vTraceSetQueueName(actuatorQ, "ActuatorQueue"); - - vSemaphoreCreateBinary(Sem1); - if( Sem1 == NULL ) - { - vTracePrint("Messages", "Could not create Sem1!\n"); - return -3; - } - vTraceSetSemaphoreName(Sem1, "SemaphSenX"); - - vSemaphoreCreateBinary(Sem2); - if( Sem2 == NULL ) - { - vTracePrint("Messages", "Could not create Sem2!\n"); - return -4; - } - vTraceSetSemaphoreName(Sem2, "SemaphSenY"); - - vSemaphoreCreateBinary(Sem3); - if( Sem3 == NULL ) - { - vTracePrint("Messages", "Could not create Sem3!\n"); - return -5; - } - vTraceSetSemaphoreName(Sem3, "SemaphSenZ"); - - xTaskCreate( trcDemoTaskSensor, "SensorX", - configMINIMAL_STACK_SIZE*2, &sensorTaskID1, 8, &objectHandle ); - if (objectHandle == NULL) - { - return -6; - } - - xTaskCreate( trcDemoTaskSensor, "SensorY", - configMINIMAL_STACK_SIZE*2, &sensorTaskID2, 7, &objectHandle ); - if (objectHandle == NULL) - { - return -7; - } - - xTaskCreate( trcDemoTaskSensor, "SensorZ", - configMINIMAL_STACK_SIZE*2, &sensorTaskID3, 6, &objectHandle ); - if (objectHandle == NULL) - { - return -8; - } - - xTaskCreate( trcDemoTaskController, "Control", - configMINIMAL_STACK_SIZE*2, NULL, 4, &objectHandle ); - if (objectHandle == NULL) - { - return -9; - } - - xTaskCreate( trcDemoTaskActuator, "Actuator", - configMINIMAL_STACK_SIZE*2, NULL, 5, &objectHandle ); - if (objectHandle == NULL) - { - return -10; - } - - xTaskCreate( trcDemoTaskSuperv, "Superv", - configMINIMAL_STACK_SIZE*2, NULL, 3, &objectHandle ); - if (objectHandle == NULL) - { - return -11; - } - - xTaskCreate( trcDemoISR, "(Hide)FakeISR", - configMINIMAL_STACK_SIZE*2, NULL, configMAX_PRIORITIES-1, &objectHandle); - if (objectHandle == NULL) - { - return -12; - } - - return 0; -} diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/Release notes.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/Release notes.txt deleted file mode 100644 index dae3b94d8..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/Release notes.txt +++ /dev/null @@ -1,45 +0,0 @@ -Release notes, Trace Recorder Library for Tracealyzer v3.0.2 -September 29, 2015. Percepio AB. - -Changes: -v3.0.2 -- Fixed bug in tracing of nested interrupts. -- Made locally used variables and functions static. -v3.0.1 -- Added vTraceOnTraceBegin()/vTraceOnTraceEnd() in trcKernelPort.c to allow custom cleanup via macros TRC_STREAM_PORT_ON_TRACE_BEGIN()/TRC_STREAM_PORT_ON_TRACE_END(). -v3.0.0 -- Modified trcTCPIP functions to take bytes written/read as parameters and instead return potential errors. -- Added vTraceOnTraceBegin()/vTraceOnTraceEnd() in trcKernelPort that in turn uses macros from trcStreamPort.h to allow transfer method defined (as well as user defined) actions where appropriate. Currently only used by TCP/IP to re-initialize the paged event buffer so no old data is sent on trace start. -v2.8.6 -- Changed void* to uint32_t to ensure 32bit for vTraceStoreEvent1(), vTraceStoreEvent2() and vTraceStoreEvent3(). -- Added prefix TRC to most macros to avoid conflicts. -- Moved all trace stream macros to trcStreamPort.h. -- Now allows users to define their own trace stream macros. First specify TRC_RECORDER_TRANSFER_METHOD_CUSTOM and then modify the TRC_STREAM_CUSTOM_XXXXXXXXX macros. -- Added trcPagedEventBuffer that can be used to avoid endless recursion for trace stream methods that use kernel objects (semaphores, mutexes) when sending data. -- Added trcTCPIP/trcTCPIPConfig for easy trace stream integration with custom TCP/IP stacks. -v2.8.5 -- Added internal OS tick counter that can be used by certain kernel ports to keep track of the actual OS tick, in case it can be delayed. -- Updated generic macro names. -- Removed usage of strlen(). - -- Added support for width and padding formats for %d, %u, %x and %X. -- Reduced RAM usage for certain cases by redefining unused buffers. -- Fixed traceTAKE_MUTEX_RECURSIVE_FAILED being called traceTAKE_MUTEX_RECURSIVE resulting in duplicate defines. -- Implemented fix for missing parameter "xCopyPosition" when using "xSemaphoreGiveFromISR()" in FreeRTOS v8. -- Added prefix to internal defines to avoid conflicts. -- Fixed possible memory alignment issue which could cause hard fault. -- Made sure TzCtrl runs every 100ms instead of every 100 OS ticks. -- Moved project specific includes to trcConfig.h. -- Added a few backwards compatibility macros. -v2.8.2 -- Improved vTracePrintF() parsing. -- Added vTracePrint() that performs no formatting. -- Removed need for passing parameter to vTraceStoreISREnd() on embOS port. This parameter is detected automatically. -- Added vTraceStoreISREndManual(param) that can be used on kernel ports that doesn't automatically detect pending task switches after interrupts. -v2.8.1 -- New J-Link drivers fixes the RTT Buffer Index != 0 issue. -- trcRecorder.c hotfixed to handle missing defines in embOS that haven't made it to release yet. -v2.8.0 -- Initial release. Only RTT Buffer Index 0 works in this version. - -For questions, contact support@percepio.com or sales@percepio.com diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/SEGGER_RTT.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/SEGGER_RTT.c deleted file mode 100644 index 74ce1443a..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/SEGGER_RTT.c +++ /dev/null @@ -1,591 +0,0 @@ -/********************************************************************* -* SEGGER MICROCONTROLLER GmbH & Co. KG * -* Solutions for real time microcontroller applications * -********************************************************************** -* * -* (c) 2014-2014 SEGGER Microcontroller GmbH & Co. KG * -* * -* Internet: www.segger.com Support: support@segger.com * -* * -********************************************************************** ----------------------------------------------------------------------- -File : SEGGER_RTT.c -Date : 17 Dec 2014 -Purpose : Implementation of SEGGER real-time terminal (RTT) which allows - real-time terminal communication on targets which support - debugger memory accesses while the CPU is running. - - Type "int" is assumed to be 32-bits in size - H->T Host to target communication - T->H Target to host communication - - RTT channel 0 is always present and reserved for Terminal usage. - Name is fixed to "Terminal" - ----------------------------END-OF-HEADER------------------------------ -*/ - -#include "SEGGER_RTT_Conf.h" -#include "SEGGER_RTT.h" - -#include // for memcpy - -/********************************************************************* -* -* Defines, configurable -* -********************************************************************** -*/ - -#ifndef BUFFER_SIZE_UP - #define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host -#endif - -#ifndef BUFFER_SIZE_DOWN - #define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) -#endif - -#ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS - #define SEGGER_RTT_MAX_NUM_UP_BUFFERS (1) // Number of up-buffers (T->H) available on this target -#endif - -#ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS - #define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (1) // Number of down-buffers (H->T) available on this target -#endif - -#ifndef SEGGER_RTT_LOCK - #define SEGGER_RTT_LOCK() -#endif - -#ifndef SEGGER_RTT_UNLOCK - #define SEGGER_RTT_UNLOCK() -#endif - -#ifndef SEGGER_RTT_IN_RAM - #define SEGGER_RTT_IN_RAM (0) -#endif - -/********************************************************************* -* -* Defines, fixed -* -********************************************************************** -*/ - -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) - -#define MEMCPY(a, b, c) memcpy((a),(b),(c)) - -// -// For some environments, NULL may not be defined until certain headers are included -// -#ifndef NULL - #define NULL 0 -#endif - -/********************************************************************* -* -* Types -* -********************************************************************** -*/ - -// -// Description for a circular buffer (also called "ring buffer") -// which is used as up- (T->H) or down-buffer (H->T) -// -typedef struct { - const char* sName; // Optional name. Standard names so far are: "Terminal", "VCom" - char* pBuffer; // Pointer to start of buffer - int SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty. - volatile int WrOff; // Position of next item to be written by either host (down-buffer) or target (up-buffer). Must be volatile since it may be modified by host (down-buffer) - volatile int RdOff; // Position of next item to be read by target (down-buffer) or host (up-buffer). Must be volatile since it may be modified by host (up-buffer) - int Flags; // Contains configuration flags -} RING_BUFFER; - -// -// RTT control block which describes the number of buffers available -// as well as the configuration for each buffer -// -// -typedef struct { - char acID[16]; // Initialized to "SEGGER RTT" - int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2) - int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2) - RING_BUFFER aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host - RING_BUFFER aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target -} SEGGER_RTT_CB; - -/********************************************************************* -* -* Static data -* -********************************************************************** -*/ -// -// Allocate buffers for channel 0 -// -static char _acUpBuffer [BUFFER_SIZE_UP]; -static char _acDownBuffer[BUFFER_SIZE_DOWN]; -// -// Initialize SEGGER Real-time-Terminal control block (CB) -// -static SEGGER_RTT_CB _SEGGER_RTT = { -#if SEGGER_RTT_IN_RAM - "SEGGER RTTI", -#else - "SEGGER RTT", -#endif - SEGGER_RTT_MAX_NUM_UP_BUFFERS, - SEGGER_RTT_MAX_NUM_DOWN_BUFFERS, - {{ "Terminal", &_acUpBuffer[0], sizeof(_acUpBuffer), 0, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP }}, - {{ "Terminal", &_acDownBuffer[0], sizeof(_acDownBuffer), 0, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP }}, -}; - -static char _ActiveTerminal; - -/********************************************************************* -* -* Static code -* -********************************************************************** -*/ - -/********************************************************************* -* -* _strlen -* -* Function description -* ANSI compatible function to determine the length of a string -* -* Return value -* Length of string in bytes. -* -* Parameters -* s Pointer to \0 terminated string. -* -* Notes -* (1) s needs to point to an \0 terminated string. Otherwise proper functionality of this function is not guaranteed. -*/ -static int _strlen(const char* s) { - int Len; - - Len = 0; - if (s == NULL) { - return 0; - } - do { - if (*s == 0) { - break; - } - Len++; - s++; - } while (1); - return Len; -} - -/********************************************************************* -* -* _Init -* -* Function description -* In case SEGGER_RTT_IN_RAM is defined, -* _Init() modifies the ID of the RTT CB to allow identifying the -* RTT Control Block Structure in the data segment. -*/ -static void _Init(void) { -#if SEGGER_RTT_IN_RAM - if (_SEGGER_RTT.acID[10] == 'I') { - _SEGGER_RTT.acID[10] = '\0'; - } -#endif -} - -/********************************************************************* -* -* Public code -* -********************************************************************** -*/ -/********************************************************************* -* -* SEGGER_RTT_Read -* -* Function description -* Reads characters from SEGGER real-time-terminal control block -* which have been previously stored by the host. -* -* Parameters -* BufferIndex Index of Down-buffer to be used. (e.g. 0 for "Terminal") -* pBuffer Pointer to buffer provided by target application, to copy characters from RTT-down-buffer to. -* BufferSize Size of the target application buffer -* -* Return values -* Number of bytes that have been read -*/ -int SEGGER_RTT_Read(unsigned BufferIndex, char* pBuffer, unsigned BufferSize) { - int NumBytesRem; - unsigned NumBytesRead; - int RdOff; - int WrOff; - - SEGGER_RTT_LOCK(); - _Init(); - RdOff = _SEGGER_RTT.aDown[BufferIndex].RdOff; - WrOff = _SEGGER_RTT.aDown[BufferIndex].WrOff; - NumBytesRead = 0; - // - // Read from current read position to wrap-around of buffer, first - // - if (RdOff > WrOff) { - NumBytesRem = _SEGGER_RTT.aDown[BufferIndex].SizeOfBuffer - RdOff; - NumBytesRem = MIN(NumBytesRem, (int)BufferSize); - MEMCPY(pBuffer, _SEGGER_RTT.aDown[BufferIndex].pBuffer + RdOff, NumBytesRem); - NumBytesRead += NumBytesRem; - pBuffer += NumBytesRem; - BufferSize -= NumBytesRem; - RdOff += NumBytesRem; - // - // Handle wrap-around of buffer - // - if (RdOff == _SEGGER_RTT.aDown[BufferIndex].SizeOfBuffer) { - RdOff = 0; - } - } - // - // Read remaining items of buffer - // - NumBytesRem = WrOff - RdOff; - NumBytesRem = MIN(NumBytesRem, (int)BufferSize); - if (NumBytesRem > 0) { - MEMCPY(pBuffer, _SEGGER_RTT.aDown[BufferIndex].pBuffer + RdOff, NumBytesRem); - NumBytesRead += NumBytesRem; - pBuffer += NumBytesRem; - BufferSize -= NumBytesRem; - RdOff += NumBytesRem; - } - if (NumBytesRead) { - _SEGGER_RTT.aDown[BufferIndex].RdOff = RdOff; - } - SEGGER_RTT_UNLOCK(); - return NumBytesRead; -} - -/********************************************************************* -* -* SEGGER_RTT_Write -* -* Function description -* Stores a specified number of characters in SEGGER RTT -* control block which is then read by the host. -* -* Parameters -* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal") -* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. -* NumBytes Number of bytes to be stored in the SEGGER RTT control block. -* -* Return values -* Number of bytes which have been stored in the "Up"-buffer. -* -* Notes -* (1) If there is not enough space in the "Up"-buffer, remaining characters of pBuffer are dropped. -*/ -int SEGGER_RTT_Write(unsigned BufferIndex, const char* pBuffer, unsigned NumBytes) { - int NumBytesToWrite; - unsigned NumBytesWritten; - int RdOff; - // - // Target is not allowed to perform other RTT operations while string still has not been stored completely. - // Otherwise we would probably end up with a mixed string in the buffer. - // - SEGGER_RTT_LOCK(); - _Init(); - // - // In case we are not in blocking mode, - // we need to calculate, how many bytes we can put into the buffer at all. - // - if ((_SEGGER_RTT.aUp[BufferIndex].Flags & SEGGER_RTT_MODE_MASK) != SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL) { - RdOff = _SEGGER_RTT.aUp[BufferIndex].RdOff; - NumBytesToWrite = RdOff - _SEGGER_RTT.aUp[BufferIndex].WrOff - 1; - if (NumBytesToWrite < 0) { - NumBytesToWrite += _SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer; - } - // - // If the complete data does not fit in the buffer, check if we have to skip it completely or trim the data - // - if ((int)NumBytes > NumBytesToWrite) { - if ((_SEGGER_RTT.aUp[BufferIndex].Flags & SEGGER_RTT_MODE_MASK) == SEGGER_RTT_MODE_NO_BLOCK_SKIP) { - SEGGER_RTT_UNLOCK(); - return 0; - } else { - NumBytes = NumBytesToWrite; - } - } - } - // - // Early out if nothing is to do - // - if (NumBytes == 0) { - SEGGER_RTT_UNLOCK(); - return 0; - } - // - // Write data to buffer and handle wrap-around if necessary - // - NumBytesWritten = 0; - do { - RdOff = _SEGGER_RTT.aUp[BufferIndex].RdOff; // May be changed by host (debug probe) in the meantime - NumBytesToWrite = RdOff - _SEGGER_RTT.aUp[BufferIndex].WrOff - 1; - if (NumBytesToWrite < 0) { - NumBytesToWrite += _SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer; - } - NumBytesToWrite = MIN(NumBytesToWrite, (_SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer - _SEGGER_RTT.aUp[BufferIndex].WrOff)); // Number of bytes that can be written until buffer wrap-around - NumBytesToWrite = MIN(NumBytesToWrite, (int)NumBytes); - MEMCPY(_SEGGER_RTT.aUp[BufferIndex].pBuffer + _SEGGER_RTT.aUp[BufferIndex].WrOff, pBuffer, NumBytesToWrite); - NumBytesWritten += NumBytesToWrite; - pBuffer += NumBytesToWrite; - NumBytes -= NumBytesToWrite; - _SEGGER_RTT.aUp[BufferIndex].WrOff += NumBytesToWrite; - if (_SEGGER_RTT.aUp[BufferIndex].WrOff == _SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer) { - _SEGGER_RTT.aUp[BufferIndex].WrOff = 0; - } - } while (NumBytes); - SEGGER_RTT_UNLOCK(); - return NumBytesWritten; -} - -/********************************************************************* -* -* SEGGER_RTT_WriteString -* -* Function description -* Stores string in SEGGER RTT control block. -* This data is read by the host. -* -* Parameters -* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal") -* s Pointer to string. -* -* Return values -* Number of bytes which have been stored in the "Up"-buffer. -* -* Notes -* (1) If there is not enough space in the "Up"-buffer, depending on configuration, -* remaining characters may be dropped or RTT module waits until there is more space in the buffer. -* (2) String passed to this function has to be \0 terminated -* (3) \0 termination character is *not* stored in RTT buffer -*/ -int SEGGER_RTT_WriteString(unsigned BufferIndex, const char* s) { - int Len; - - Len = _strlen(s); - return SEGGER_RTT_Write(BufferIndex, s, Len); -} - -/********************************************************************* -* -* SEGGER_RTT_GetKey -* -* Function description -* Reads one character from the SEGGER RTT buffer. -* Host has previously stored data there. -* -* Return values -* < 0 No character available (buffer empty). -* >= 0 Character which has been read. (Possible values: 0 - 255) -* -* Notes -* (1) This function is only specified for accesses to RTT buffer 0. -*/ -int SEGGER_RTT_GetKey(void) { - char c; - int r; - - r = SEGGER_RTT_Read(0, &c, 1); - if (r == 1) { - return (int)(unsigned char)c; - } - return -1; -} - -/********************************************************************* -* -* SEGGER_RTT_WaitKey -* -* Function description -* Waits until at least one character is avaible in the SEGGER RTT buffer. -* Once a character is available, it is read and this function returns. -* -* Return values -* >=0 Character which has been read. -* -* Notes -* (1) This function is only specified for accesses to RTT buffer 0 -* (2) This function is blocking if no character is present in RTT buffer -*/ -int SEGGER_RTT_WaitKey(void) { - int r; - - do { - r = SEGGER_RTT_GetKey(); - } while (r < 0); - return r; -} - -/********************************************************************* -* -* SEGGER_RTT_HasKey -* -* Function description -* Checks if at least one character for reading is available in the SEGGER RTT buffer. -* -* Return values -* 0 No characters are available to read. -* 1 At least one character is available. -* -* Notes -* (1) This function is only specified for accesses to RTT buffer 0 -*/ -int SEGGER_RTT_HasKey(void) { - int RdOff; - - _Init(); - RdOff = _SEGGER_RTT.aDown[0].RdOff; - if (RdOff != _SEGGER_RTT.aDown[0].WrOff) { - return 1; - } - return 0; -} - -/********************************************************************* -* -* SEGGER_RTT_ConfigUpBuffer -* -* Function description -* Run-time configuration of a specific up-buffer (T->H). -* Buffer to be configured is specified by index. -* This includes: Buffer address, size, name, flags, ... -* -* Return value -* >= 0 O.K. -* < 0 Error -*/ -int SEGGER_RTT_ConfigUpBuffer(unsigned BufferIndex, const char* sName, char* pBuffer, int BufferSize, int Flags) { - _Init(); - if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumUpBuffers) { - SEGGER_RTT_LOCK(); - if (BufferIndex > 0) { - _SEGGER_RTT.aUp[BufferIndex].sName = sName; - _SEGGER_RTT.aUp[BufferIndex].pBuffer = pBuffer; - _SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer = BufferSize; - _SEGGER_RTT.aUp[BufferIndex].RdOff = 0; - _SEGGER_RTT.aUp[BufferIndex].WrOff = 0; - } - _SEGGER_RTT.aUp[BufferIndex].Flags = Flags; - SEGGER_RTT_UNLOCK(); - return 0; - } - return -1; -} - -/********************************************************************* -* -* SEGGER_RTT_ConfigDownBuffer -* -* Function description -* Run-time configuration of a specific down-buffer (H->T). -* Buffer to be configured is specified by index. -* This includes: Buffer address, size, name, flags, ... -* -* Return value -* >= 0 O.K. -* < 0 Error -*/ -int SEGGER_RTT_ConfigDownBuffer(unsigned BufferIndex, const char* sName, char* pBuffer, int BufferSize, int Flags) { - _Init(); - if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumDownBuffers) { - SEGGER_RTT_LOCK(); - if (BufferIndex > 0) { - _SEGGER_RTT.aDown[BufferIndex].sName = sName; - _SEGGER_RTT.aDown[BufferIndex].pBuffer = pBuffer; - _SEGGER_RTT.aDown[BufferIndex].SizeOfBuffer = BufferSize; - _SEGGER_RTT.aDown[BufferIndex].RdOff = 0; - _SEGGER_RTT.aDown[BufferIndex].WrOff = 0; - } - _SEGGER_RTT.aDown[BufferIndex].Flags = Flags; - SEGGER_RTT_UNLOCK(); - return 0; - } - return -1; -} - -/********************************************************************* -* -* SEGGER_RTT_Init -* -* Function description -* Initializes the RTT Control Block. -* Should be used in RAM targets, at start of the application. -* -*/ -void SEGGER_RTT_Init (void) { - _Init(); -} - -/********************************************************************* -* -* SEGGER_RTT_SetTerminal -* -* Function description -* Sets the terminal to be used for output on channel 0. -* -*/ -void SEGGER_RTT_SetTerminal (char TerminalId) { - char ac[2]; - - ac[0] = 0xFF; - if (TerminalId < 10) { - ac[1] = '0' + TerminalId; - } else if (TerminalId < 16) { - ac[1] = 'A' + (TerminalId - 0x0A); - } else { - return; // RTT only supports up to 16 virtual terminals. - } - _ActiveTerminal = TerminalId; - SEGGER_RTT_Write(0, ac, 2); -} - -/********************************************************************* -* -* SEGGER_RTT_TerminalOut -* -* Function description -* Writes a string to the given terminal -* without changing the terminal for channel 0. -* -*/ -int SEGGER_RTT_TerminalOut (char TerminalId, const char* s) { - char ac[2]; - int r; - - ac[0] = 0xFF; - if (TerminalId < 10) { - ac[1] = '0' + TerminalId; - } else if (TerminalId < 16) { - ac[1] = 'A' + (TerminalId - 0x0A); - } else { - return -1; // RTT only supports up to 16 virtual terminals. - } - SEGGER_RTT_Write(0, ac, 2); - r = SEGGER_RTT_WriteString(0, s); - if (TerminalId < 10) { - ac[1] = '0' + _ActiveTerminal; - } else if (TerminalId < 16) { - ac[1] = 'A' + (_ActiveTerminal - 0x0A); - } - SEGGER_RTT_Write(0, ac, 2); - return r; -} - -/*************************** End of file ****************************/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/SEGGER_RTT.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/SEGGER_RTT.h deleted file mode 100644 index 987354ed9..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/SEGGER_RTT.h +++ /dev/null @@ -1,110 +0,0 @@ -/********************************************************************* -* SEGGER MICROCONTROLLER SYSTEME GmbH * -* Solutions for real time microcontroller applications * -********************************************************************** -* * -* (c) 1996-2014 SEGGER Microcontroller Systeme GmbH * -* * -* Internet: www.segger.com Support: support@segger.com * -* * -********************************************************************** ----------------------------------------------------------------------- -File : SEGGER_RTT.h -Date : 17 Dec 2014 -Purpose : Implementation of SEGGER real-time terminal which allows - real-time terminal communication on targets which support - debugger memory accesses while the CPU is running. ----------------------------END-OF-HEADER------------------------------ -*/ - -/********************************************************************* -* -* Defines -* -********************************************************************** -*/ -#define SEGGER_RTT_MODE_MASK (3 << 0) - -#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0) -#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1 << 0) -#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (1 << 1) - -#define RTT_CTRL_RESET "" - -#define RTT_CTRL_CLEAR "" - -#define RTT_CTRL_TEXT_BLACK "" -#define RTT_CTRL_TEXT_RED "" -#define RTT_CTRL_TEXT_GREEN "" -#define RTT_CTRL_TEXT_YELLOW "" -#define RTT_CTRL_TEXT_BLUE "" -#define RTT_CTRL_TEXT_MAGENTA "" -#define RTT_CTRL_TEXT_CYAN "" -#define RTT_CTRL_TEXT_WHITE "" - -#define RTT_CTRL_TEXT_BRIGHT_BLACK "" -#define RTT_CTRL_TEXT_BRIGHT_RED "" -#define RTT_CTRL_TEXT_BRIGHT_GREEN "" -#define RTT_CTRL_TEXT_BRIGHT_YELLOW "" -#define RTT_CTRL_TEXT_BRIGHT_BLUE "" -#define RTT_CTRL_TEXT_BRIGHT_MAGENTA "" -#define RTT_CTRL_TEXT_BRIGHT_CYAN "" -#define RTT_CTRL_TEXT_BRIGHT_WHITE "" - -#define RTT_CTRL_BG_BLACK "" -#define RTT_CTRL_BG_RED "" -#define RTT_CTRL_BG_GREEN "" -#define RTT_CTRL_BG_YELLOW "" -#define RTT_CTRL_BG_BLUE "" -#define RTT_CTRL_BG_MAGENTA "" -#define RTT_CTRL_BG_CYAN "" -#define RTT_CTRL_BG_WHITE "" - -#define RTT_CTRL_BG_BRIGHT_BLACK "" -#define RTT_CTRL_BG_BRIGHT_RED "" -#define RTT_CTRL_BG_BRIGHT_GREEN "" -#define RTT_CTRL_BG_BRIGHT_YELLOW "" -#define RTT_CTRL_BG_BRIGHT_BLUE "" -#define RTT_CTRL_BG_BRIGHT_MAGENTA "" -#define RTT_CTRL_BG_BRIGHT_CYAN "" -#define RTT_CTRL_BG_BRIGHT_WHITE "" - - -/********************************************************************* -* -* RTT API functions -* -********************************************************************** -*/ - -int SEGGER_RTT_Read (unsigned BufferIndex, char* pBuffer, unsigned BufferSize); -int SEGGER_RTT_Write (unsigned BufferIndex, const char* pBuffer, unsigned NumBytes); -int SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s); - -int SEGGER_RTT_GetKey (void); -int SEGGER_RTT_WaitKey (void); -int SEGGER_RTT_HasKey (void); - -int SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName, char* pBuffer, int BufferSize, int Flags); -int SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName, char* pBuffer, int BufferSize, int Flags); - -void SEGGER_RTT_Init (void); - -/********************************************************************* -* -* RTT "Terminal" API functions -* -********************************************************************** -*/ -void SEGGER_RTT_SetTerminal (char TerminalId); -int SEGGER_RTT_TerminalOut (char TerminalId, const char* s); - -/********************************************************************* -* -* RTT printf functions (require SEGGER_RTT_printf.c) -* -********************************************************************** -*/ -int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...); - -/*************************** End of file ****************************/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/SEGGER_RTT_Conf.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/SEGGER_RTT_Conf.h deleted file mode 100644 index c9845c6f7..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/SEGGER_RTT_Conf.h +++ /dev/null @@ -1,57 +0,0 @@ -/********************************************************************* -* SEGGER MICROCONTROLLER SYSTEME GmbH * -* Solutions for real time microcontroller applications * -********************************************************************** -* * -* (c) 1996-2014 SEGGER Microcontroller Systeme GmbH * -* * -* Internet: www.segger.com Support: support@segger.com * -* * -********************************************************************** ----------------------------------------------------------------------- -File : SEGGER_RTT_Conf.h -Date : 17 Dec 2014 -Purpose : Implementation of SEGGER real-time terminal which allows - real-time terminal communication on targets which support - debugger memory accesses while the CPU is running. ----------------------------END-OF-HEADER------------------------------ -*/ - -/********************************************************************* -* -* Defines, configurable -* -********************************************************************** -*/ - -#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (2) // Max. number of up-buffers (T->H) available on this target (Default: 2) -#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (2) // Max. number of down-buffers (H->T) available on this target (Default: 2) - -#define BUFFER_SIZE_UP (10 * 1024) // Size of the buffer for terminal output of target, up to host (Default: 1k) -#define BUFFER_SIZE_DOWN (32) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16) - -#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64) - -// -// Target is not allowed to perform other RTT operations while string still has not been stored completely. -// Otherwise we would probably end up with a mixed string in the buffer. -// If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here. -// -#define SEGGER_RTT_LOCK() -#define SEGGER_RTT_UNLOCK() - -// -// Define SEGGER_RTT_IN_RAM as 1 -// when using RTT in RAM targets (init and data section both in RAM). -// This prevents the host to falsly identify the RTT Callback Structure -// in the init segment as the used Callback Structure. -// -// When defined as 1, -// the first call to an RTT function will modify the ID of the RTT Callback Structure. -// To speed up identifying on the host, -// especially when RTT functions are not called at the beginning of execution, -// SEGGER_RTT_Init() should be called at the start of the application. -// -#define SEGGER_RTT_IN_RAM (0) - -/*************************** End of file ****************************/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/SEGGER_RTT_Printf.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/SEGGER_RTT_Printf.c deleted file mode 100644 index f68c105c4..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/SEGGER_RTT_Printf.c +++ /dev/null @@ -1,443 +0,0 @@ -/********************************************************************* -* SEGGER MICROCONTROLLER GmbH & Co. KG * -* Solutions for real time microcontroller applications * -********************************************************************** -* * -* (c) 2014-2014 SEGGER Microcontroller GmbH & Co. KG * -* * -* Internet: www.segger.com Support: support@segger.com * -* * -********************************************************************** ----------------------------------------------------------------------- -File : SEGGER_RTT_printf.c -Date : 17 Dec 2014 -Purpose : Replacement for printf to write formatted data via RTT ----------------------------END-OF-HEADER------------------------------ -*/ -#include "SEGGER_RTT.h" -#include "SEGGER_RTT_Conf.h" - -/********************************************************************* -* -* Defines, configurable -* -********************************************************************** -*/ - -#ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE - #define SEGGER_RTT_PRINTF_BUFFER_SIZE (64) -#endif - -#include -#include - - -#define FORMAT_FLAG_LEFT_JUSTIFY (1 << 0) -#define FORMAT_FLAG_PAD_ZERO (1 << 1) -#define FORMAT_FLAG_PRINT_SIGN (1 << 2) -#define FORMAT_FLAG_ALTERNATE (1 << 3) - -/********************************************************************* -* -* Types -* -********************************************************************** -*/ - -typedef struct { - char* pBuffer; - int BufferSize; - int Cnt; - - int ReturnValue; - - unsigned RTTBufferIndex; -} SEGGER_RTT_PRINTF_DESC; - -/********************************************************************* -* -* Function prototypes -* -********************************************************************** -*/ -int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList); - -/********************************************************************* -* -* Static code -* -********************************************************************** -*/ -/********************************************************************* -* -* _StoreChar -*/ -static void _StoreChar(SEGGER_RTT_PRINTF_DESC * p, char c) { - int Cnt; - - Cnt = p->Cnt; - if ((Cnt + 1) <= p->BufferSize) { - *(p->pBuffer + Cnt) = c; - p->Cnt = Cnt + 1; - p->ReturnValue++; - } - // - // Write part of string, when the buffer is full - // - if (p->Cnt == p->BufferSize) { - if (SEGGER_RTT_Write(p->RTTBufferIndex, p->pBuffer, p->Cnt) != p->Cnt) { - p->ReturnValue = -1; - } else { - p->Cnt = 0; - } - } -} - -/********************************************************************* -* -* _PrintUnsigned -*/ -static void _PrintUnsigned(SEGGER_RTT_PRINTF_DESC * pBufferDesc, unsigned v, unsigned Base, int NumDigits, unsigned FieldWidth, unsigned FormatFlags) { - static const char _aV2C[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - unsigned Div; - unsigned Digit = 1; - unsigned Number; - unsigned Width; - char c; - - Number = v; - - // - // Get actual field width - // - Width = 1; - while (Number >= Base) { - Number = (Number / Base); - Width++; - } - if ((unsigned)NumDigits > Width) { - Width = NumDigits; - } - // - // Print leading chars if necessary - // - if ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0) { - if (FieldWidth != 0) { - if (((FormatFlags & FORMAT_FLAG_PAD_ZERO) == FORMAT_FLAG_PAD_ZERO) && (NumDigits == 0)) { - c = '0'; - } else { - c = ' '; - } - while ((FieldWidth != 0) && (Width < FieldWidth--)) { - _StoreChar(pBufferDesc, c); - if (pBufferDesc->ReturnValue < 0) { - return; - } - } - } - } - // - // Count how many digits are required by precision - // - while (((v / Digit) >= Base) | (NumDigits-- > 1)) { - Digit *= Base; - } - // - // Output digits - // - do { - Div = v / Digit; - v -= Div * Digit; - _StoreChar(pBufferDesc, _aV2C[Div]); - if (pBufferDesc->ReturnValue < 0) { - break; - } - Digit /= Base; - } while (Digit); - // - // Print trailing spaces if necessary - // - if ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == FORMAT_FLAG_LEFT_JUSTIFY) { - if (FieldWidth != 0) { - while ((FieldWidth != 0) && (Width < FieldWidth--)) { - _StoreChar(pBufferDesc, ' '); - if (pBufferDesc->ReturnValue < 0) { - return; - } - } - } - } -} - -/********************************************************************* -* -* _PrintInt -*/ -static void _PrintInt(SEGGER_RTT_PRINTF_DESC * pBufferDesc, int v, unsigned Base, unsigned NumDigits, unsigned FieldWidth, unsigned FormatFlags) { - unsigned Width; - unsigned Number; - - Number = (v < 0) ? -v : v; - - // - // Get actual field width - // - Width = 1; - while (Number >= Base) { - Number = (Number / Base); - Width++; - } - if (NumDigits > Width) { - Width = NumDigits; - } - if ((FieldWidth > 0) && ((v < 0) || ((FormatFlags & FORMAT_FLAG_PRINT_SIGN) == FORMAT_FLAG_PRINT_SIGN))) { - FieldWidth--; - } - - // - // Print leading spaces if necessary - // - if ((((FormatFlags & FORMAT_FLAG_PAD_ZERO) == 0) || (NumDigits != 0)) && ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0)) { - if (FieldWidth != 0) { - while ((FieldWidth != 0) && (Width < FieldWidth--)) { - _StoreChar(pBufferDesc, ' '); - if (pBufferDesc->ReturnValue < 0) { - return; - } - } - } - } - // - // Print sign if necessary - // - if (v < 0) { - v = -v; - _StoreChar(pBufferDesc, '-'); - if (pBufferDesc->ReturnValue < 0) { - return; - } - } else if ((FormatFlags & FORMAT_FLAG_PRINT_SIGN) == FORMAT_FLAG_PRINT_SIGN) { - _StoreChar(pBufferDesc, '+'); - if (pBufferDesc->ReturnValue < 0) { - return; - } - } - // - // Print leading zeros if necessary - // - if (((FormatFlags & FORMAT_FLAG_PAD_ZERO) == FORMAT_FLAG_PAD_ZERO) && ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0) && (NumDigits == 0)) { - if (FieldWidth != 0) { - while ((FieldWidth != 0) && (Width < FieldWidth--)) { - _StoreChar(pBufferDesc, '0'); - if (pBufferDesc->ReturnValue < 0) { - return; - } - } - } - } - - // - // Print number without sign - // - _PrintUnsigned(pBufferDesc, v, Base, NumDigits, FieldWidth, FormatFlags); -} - -/********************************************************************* -* -* Public code -* -********************************************************************** -*/ -/********************************************************************* -* -* SEGGER_RTT_vprintf -* -* Function description -* Stores a formatted string in SEGGER RTT control block. -* This data is read by the host. -* -* Parameters -* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal") -* sFormat Pointer to format string -* pParamList Pointer to the list of arguments for the format string -* -* Return values -* >= 0: Number of bytes which have been stored in the "Up"-buffer. -* < 0: Error -*/ -int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList) { - char c; - SEGGER_RTT_PRINTF_DESC BufferDesc; - int v; - unsigned NumDigits; - unsigned FormatFlags; - unsigned FieldWidth; - char acBuffer[SEGGER_RTT_PRINTF_BUFFER_SIZE]; - - BufferDesc.pBuffer = acBuffer; - BufferDesc.BufferSize = SEGGER_RTT_PRINTF_BUFFER_SIZE; - BufferDesc.Cnt = 0; - BufferDesc.RTTBufferIndex = BufferIndex; - BufferDesc.ReturnValue = 0; - - do { - c = *sFormat++; - if (c == 0) { - break; - } - if (c == '%') { - // - // Filter out flags - // - FormatFlags = 0; - do { - c = *sFormat; - switch (c) { - case '-': FormatFlags |= FORMAT_FLAG_LEFT_JUSTIFY; sFormat++; break; - case '0': FormatFlags |= FORMAT_FLAG_PAD_ZERO; sFormat++; break; - case '+': FormatFlags |= FORMAT_FLAG_PRINT_SIGN; sFormat++; break; - case '#': FormatFlags |= FORMAT_FLAG_ALTERNATE; sFormat++; break; - default: goto FilterFieldWidth; break; - } - } while (1); - // - // filter out field with - // -FilterFieldWidth: - FieldWidth = 0; - do { - c = *sFormat; - if (c < '0' || c > '9') { - break; - } - sFormat++; - FieldWidth = FieldWidth * 10 + (c - '0'); - } while (1); - - // - // Filter out precision (number of digits to display) - // - NumDigits = 0; - c = *sFormat; - if (c == '.') { - sFormat++; - do { - c = *sFormat; - if (c < '0' || c > '9') { - break; - } - sFormat++; - NumDigits = NumDigits * 10 + (c - '0'); - } while (1); - } - // - // Filter out length modifier - // - c = *sFormat; - do { - if (c == 'l' || c == 'h') { - c = *sFormat++; - continue; - } - break; - } while (1); - // - // Handle specifiers - // - switch (c) { - case 'c': { - char c0; - v = va_arg(*pParamList, int); - c0 = (char)v; - _StoreChar(&BufferDesc, c0); - break; - } - case 'd': - v = va_arg(*pParamList, int); - _PrintInt(&BufferDesc, v, 10, NumDigits, FieldWidth, FormatFlags); - break; - case 'u': - v = va_arg(*pParamList, int); - _PrintUnsigned(&BufferDesc, v, 10, NumDigits, FieldWidth, FormatFlags); - break; - case 'x': - case 'X': - v = va_arg(*pParamList, int); - _PrintUnsigned(&BufferDesc, v, 16, NumDigits, FieldWidth, FormatFlags); - break; - case 's': - { - const char * s = va_arg(*pParamList, const char *); - do { - c = *s++; - if (c == 0) { - break; - } - _StoreChar(&BufferDesc, c); - } while (BufferDesc.ReturnValue >= 0); - } - break; - case 'p': - v = va_arg(*pParamList, int); - _PrintUnsigned(&BufferDesc, v, 16, 8, 8, 0); - break; - case '%': - _StoreChar(&BufferDesc, '%'); - break; - } - sFormat++; - } else { - _StoreChar(&BufferDesc, c); - } - } while (BufferDesc.ReturnValue >= 0); - - if (BufferDesc.ReturnValue > 0) { - // - // Write remaining data, if any - // - if (BufferDesc.Cnt != 0) { - SEGGER_RTT_Write(BufferIndex, acBuffer, BufferDesc.Cnt); - } - BufferDesc.ReturnValue += BufferDesc.Cnt; - } - return BufferDesc.ReturnValue; -} - -/********************************************************************* -* -* SEGGER_RTT_printf -* -* Function description -* Stores a formatted string in SEGGER RTT control block. -* This data is read by the host. -* -* Parameters -* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal") -* sFormat Pointer to format string, followed by the arguments for conversion -* -* Return values -* >= 0: Number of bytes which have been stored in the "Up"-buffer. -* < 0: Error -* -* Notes -* (1) Conversion specifications have following syntax: -* %[flags][FieldWidth][.Precision]ConversionSpecifier -* (2) Supported flags: -* -: Left justify within the field width -* +: Always print sign extension for signed conversions -* 0: Pad with 0 instead of spaces. Ignored when using '-'-flag or precision -* Supported conversion specifiers: -* c: Print the argument as one char -* d: Print the argument as a signed integer -* u: Print the argument as an unsigned integer -* x: Print the argument as an hexadecimal integer -* s: Print the string pointed to by the argument -* p: Print the argument as an 8-digit hexadecimal integer. (Argument shall be a pointer to void.) -*/ -int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...) { - va_list ParamList; - - va_start(ParamList, sFormat); - return SEGGER_RTT_vprintf(BufferIndex, sFormat, &ParamList); -} -/*************************** End of file ****************************/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcConfig.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcConfig.h deleted file mode 100644 index 3ada261bf..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcConfig.h +++ /dev/null @@ -1,326 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v3.0.2 - * Percepio AB, www.percepio.com - * - * trcConfig.h - * - * Configuration parameters for the streaming version trace recorder library. - * Before using the trace recorder library, please check that the default - * settings are appropriate for your system, and if necessary adjust these. - * - * Terms of Use - * This software (the "Tracealyzer Recorder Library") is the intellectual - * property of Percepio AB and may not be sold or in other ways commercially - * redistributed without explicit written permission by Percepio AB. - * - * Separate conditions applies for the SEGGER branded source code included. - * - * The recorder library is free for use together with Percepio products. - * You may distribute the recorder library in its original form, but public - * distribution of modified versions require approval by Percepio AB. - * - * Disclaimer - * The trace tool and recorder library is being delivered to you AS IS and - * Percepio AB makes no warranty as to its use or performance. Percepio AB does - * not and cannot warrant the performance or results you may obtain by using the - * software or documentation. Percepio AB make no warranties, express or - * implied, as to noninfringement of third party rights, merchantability, or - * fitness for any particular purpose. In no event will Percepio AB, its - * technology partners, or distributors be liable to you for any consequential, - * incidental or special damages, including any lost profits or lost savings, - * even if a representative of Percepio AB has been advised of the possibility - * of such damages, or for any claim by any third party. Some jurisdictions do - * not allow the exclusion or limitation of incidental, consequential or special - * damages, or the exclusion of implied warranties or limitations on how long an - * implied warranty may last, so the above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2015. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_CONFIG_H -#define TRC_CONFIG_H - -#ifdef __cplusplus -extern “C” { -#endif - -/******************************************************************************* - * Configuration Macro: TRC_RECORDER_HARDWARE_PORT - * - * Specify what hardware is used. - * - * See trcHardwarePort.h for available ports, or to define your own. - ******************************************************************************/ -#define TRC_RECORDER_HARDWARE_PORT TRC_PORT_ARM_Cortex_M - -/****************************************************************************** - * BSP and other project specific includes - * - * Include the necessary header files. - *****************************************************************************/ -#include "board.h" - -/****************************************************************************** - * TRC_FREERTOS_VERSION - * - * Specify what version of FreeRTOS that is used. This is necessary compensate - * for renamed symbols in the FreeRTOS kernel (does not build if incorrect). - * - * TRC_FREERTOS_VERSION_7_3_OR_7_4 (= 1) If using FreeRTOS v7.3.0 - v7.4.2 - * TRC_FREERTOS_VERSION_7_5_OR_7_6 (= 2) If using FreeRTOS v7.5.0 - v7.6.0 - * TRC_FREERTOS_VERSION_8_0_OR_LATER (= 3) If using FreeRTOS v8.0.0 or later - *****************************************************************************/ -#define TRC_FREERTOS_VERSION_NOT_SET 0 -#define TRC_FREERTOS_VERSION_7_3_OR_7_4 1 -#define TRC_FREERTOS_VERSION_7_5_OR_7_6 2 -#define TRC_FREERTOS_VERSION_8_0_OR_LATER 3 - -#define TRC_FREERTOS_VERSION TRC_FREERTOS_VERSION_8_0_OR_LATER - -/******************************************************************************* - * Configuration Macro: TRC_SYMBOL_TABLE_SLOTS - * - * The maximum number of symbols names that can be stored. This includes: - * - Task names - * - Named ISRs (vTraceSetISRProperties) - * - Named kernel objects (vTraceStoreKernelObjectName) - * - User event channels (vTraceStoreUserEventChannelName) - * - * If this value is too small, not all symbol names will be stored and the - * trace display will be affected. In that case, there will be warnings - * (as User Events) from TzCtrl task, that monitors this. - ******************************************************************************/ -#define TRC_SYMBOL_TABLE_SLOTS 30 - -/******************************************************************************* - * Configuration Macro: TRC_SYMBOL_MAX_LENGTH - * - * The maximum length of symbol names, including: - * - Task names - * - Named ISRs (vTraceSetISRProperties) - * - Named kernel objects (vTraceStoreKernelObjectName) - * - User event channel names (vTraceStoreUserEventChannelName) - * - * If longer symbol names are used, they will be truncated by the recorder, - * which will affect the trace display. In that case, there will be warnings - * (as User Events) from TzCtrl task, that monitors this. - ******************************************************************************/ -#define TRC_SYMBOL_MAX_LENGTH 25 - -/******************************************************************************* - * Configuration Macro: TRC_OBJECT_DATA_SLOTS - * - * The maximum number of object data entries (used for task priorities) that can - * be stored at the same time. Must be sufficient for all tasks, otherwise there - * will be warnings (as User Events) from TzCtrl task, that monitors this. - ******************************************************************************/ -#define TRC_OBJECT_DATA_SLOTS 20 - -/******************************************************************************* - * Configuration Macro: TRC_RTT_UP_BUFFER_INDEX - * - * Defines the RTT buffer to use for writing the trace data. Make sure that - * the PC application has the same setting (File->Settings). - * - ******************************************************************************/ -#define TRC_RTT_UP_BUFFER_INDEX 0 - -/******************************************************************************* - * Configuration Macro: TRC_RTT_DOWN_BUFFER_INDEX - * - * Defines the RTT buffer to use for reading the trace data. Make sure that - * the PC application has the same setting (File->Settings). - * - ******************************************************************************/ -#define TRC_RTT_DOWN_BUFFER_INDEX 0 - -/******************************************************************************* - * Configuration Macro: TRC_CTRL_TASK_STACK_SIZE - * - * The stack size of the TzCtrl task, that receive commands. - * We are aiming to remove this extra task in future versions. - ******************************************************************************/ -#define TRC_CTRL_TASK_STACK_SIZE (configMINIMAL_STACK_SIZE * 2) - -/******************************************************************************* - * Configuration Macro: TRC_CTRL_TASK_PRIORITY - * - * The priority of the TzCtrl task, that receive commands from. - * We are aiming to remove this extra task in future versions. - ******************************************************************************/ -#define TRC_CTRL_TASK_PRIORITY 1 - -/******************************************************************************* - * Configuration Macro: TRC_CTRL_TASK_DELAY - * - * The delay between every loop of the TzCtrl task. A high delay will reduce the - * CPU load, but may cause missed events if the TzCtrl task is performing the - * trace transfer. - ******************************************************************************/ -#define TRC_CTRL_TASK_DELAY ((10 * configTICK_RATE_HZ) / 1000) - -/******************************************************************************* - * Configuration Macro: TRC_MEASURE_BLOCKING_TIME - * - * If using SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL, this activates detection and - * warnings in case of blocking in SEGGER_RTT_Write (if too small buffer). - * - * If enabling this option (set to 1) warnings are given as User Events if - * blocking occurs, including the longest blocking time. These warnings are - * given on the channel "Blocking on trace buffer". - * - * Note: If you get such warnings, you can study the blocking time in the User - * Event Signal Plot to get an overview of the magnitude of the blocking and - * decide if acceptable. - * - * To eliminate or at least reduce occurrences of blocking: - * - * - Verify the J-Link Speed in the Settings dialog of the PC application. - * Default is 4 MHz, but can be increased a lot depending on your J-Link. - * - * Note: If you set the speed higher than your J-Link can manage, the J-Link - * driver will instead use the fastest supported speed. The actual speed used - * is shown in the title of the trace receiver window. - * - * - Increase the buffer size (BUFFER_SIZE_UP in SEGGER_RTT_Conf.h). - * - * - Reduce the amount of data produced, e.g., by removing frequent User Events. - ******************************************************************************/ -#define TRC_MEASURE_BLOCKING_TIME 0 - -/******************************************************************************* - * Configuration Macro: TRC_BLOCKING_MIN_CYCLES - * - * Threshold value for deciding if SEGGER_RTT_Write has blocked. Most events - * take 200-300 cycles on ARM Cortex-M MCUs, so anything above 500 cycles should - * be due to blocking on a full buffer (i.e., waiting for the debugger to read - * the RTT buffer data and make room for more...). - ******************************************************************************/ -#define TRC_BLOCKING_MIN_CYCLES 500 - -/******************************************************************************* - * Configuration Macro: TRC_RECORDER_BUFFER_ALLOCATION - * - * Specifies how the recorder buffer is allocated. - * - * Values: - * TRC_RECORDER_BUFFER_ALLOCATION_STATIC - * TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC - ******************************************************************************/ -#define TRC_RECORDER_BUFFER_ALLOCATION TRC_RECORDER_BUFFER_ALLOCATION_STATIC - -/******************************************************************************* - * Configuration Macro: TRC_RECORDER_TRANSFER_METHOD - * - * Specifies what type of transfer method is used. - * - * Values: - * TRC_RECORDER_TRANSFER_METHOD_JLINK_RTT_BLOCK - * TRC_RECORDER_TRANSFER_METHOD_JLINK_RTT_NOBLOCK - * TRC_RECORDER_TRANSFER_METHOD_TCPIP - * TRC_RECORDER_TRANSFER_METHOD_CUSTOM - ******************************************************************************/ -#define TRC_RECORDER_TRANSFER_METHOD TRC_RECORDER_TRANSFER_METHOD_JLINK_RTT_BLOCK - -/******************************************************************************* - * Configuration Macro: TRC_STREAM_CUSTOM_BLOCKING_TRANSFER - * - * Note: Only active if TRC_RECORDER_TRANSFER_METHOD_CUSTOM is used. - * - * Specifies how the custom transfer method handles full buffers. - * - * Values: - * 0 - The custom transfer method skips sending the data if the buffer is full. - * 1 - The custom transfer method blocks on send if the buffer is full. - ******************************************************************************/ - #define TRC_STREAM_CUSTOM_BLOCKING_TRANSFER - -/******************************************************************************* - * Configuration Macro: TRC_STREAM_CUSTOM_ALLOCATE_FIELDS - * - * Note: Only active if TRC_RECORDER_TRANSFER_METHOD_CUSTOM is used. - * - * Macro that should allocate any buffers needed for the transfer method. - * See trcStreamPort.h for examples. - ******************************************************************************/ -#define TRC_STREAM_CUSTOM_ALLOCATE_FIELDS() - -/******************************************************************************* - * Configuration Macro: TRC_STREAM_CUSTOM_INIT - * - * Note: Only active if TRC_RECORDER_TRANSFER_METHOD_CUSTOM is used. - * - * Used to initialize and set up the transfer method. - * See trcStreamPort.h for examples. - ******************************************************************************/ -#define TRC_STREAM_CUSTOM_INIT() - -/******************************************************************************* - * Configuration Macro: TRC_STREAM_CUSTOM_ALLOCATE_EVENT - * - * Note: Only active if TRC_RECORDER_TRANSFER_METHOD_CUSTOM is used. - * - * Specifies how the trace events that should be sent using the transfer method - * are allocated first. - * See trcStreamPort.h for examples. - ******************************************************************************/ -#define TRC_STREAM_CUSTOM_ALLOCATE_EVENT(_type, _ptr, _size) - -/******************************************************************************* - * Configuration Macro: TRC_STREAM_CUSTOM_COMMIT_EVENT - * - * Note: Only active if TRC_RECORDER_TRANSFER_METHOD_CUSTOM is used. - * - * Specifies how trace events are sent/written. - * See trcStreamPort.h for examples. - ******************************************************************************/ -#define TRC_STREAM_CUSTOM_COMMIT_EVENT(_ptr, _size) - -/******************************************************************************* - * Configuration Macro: TRC_STREAM_CUSTOM_READ_DATA - * - * Note: Only active if TRC_RECORDER_TRANSFER_METHOD_CUSTOM is used. - * - * Specifies how data is read using the transfer method. - * See trcStreamPort.h for examples. - ******************************************************************************/ -#define TRC_STREAM_CUSTOM_READ_DATA(_ptrData, _size, _ptrBytesRead) - -/******************************************************************************* - * Configuration Macro: TRC_STREAM_CUSTOM_PERIODIC_SEND_DATA - * - * Note: Only active if TRC_RECORDER_TRANSFER_METHOD_CUSTOM is used. - * - * Specifies how data is sent periodically. Used by certain transfer methods. - * See trcStreamPort.h for examples. - ******************************************************************************/ -#define TRC_STREAM_CUSTOM_PERIODIC_SEND_DATA(_ptrBytesSent) - -/******************************************************************************* - * Configuration Macro: TRC_STREAM_CUSTOM_ON_TRACE_BEGIN - * - * Note: Only active if TRC_RECORDER_TRANSFER_METHOD_CUSTOM is used. - * - * Called on tracing is started. Use this to perform any necessary steps to - * properly start the trace, such as clearing buffers. - ******************************************************************************/ -#define TRC_STREAM_CUSTOM_ON_TRACE_BEGIN() - -/******************************************************************************* - * Configuration Macro: TRC_STREAM_CUSTOM_ON_TRACE_END - * - * Note: Only active if TRC_RECORDER_TRANSFER_METHOD_CUSTOM is used. - * - * Called when tracing is disabled. Use this to perform any necessary steps to - * properly shut down the tracing, such as clearing buffers. - ******************************************************************************/ -#define TRC_STREAM_CUSTOM_ON_TRACE_END() - -#ifdef __cplusplus -} -#endif - -#endif /* TRC_CONFIG_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcHardwarePort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcHardwarePort.h deleted file mode 100644 index 113394449..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcHardwarePort.h +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v3.0.2 - * Percepio AB, www.percepio.com - * - * trcHardwarePort.h - * - * The hardware abstraction layer for the trace recorder library. - * - * Terms of Use - * This software (the "Tracealyzer Recorder Library") is the intellectual - * property of Percepio AB and may not be sold or in other ways commercially - * redistributed without explicit written permission by Percepio AB. - * - * Separate conditions applies for the SEGGER branded source code included. - * - * The recorder library is free for use together with Percepio products. - * You may distribute the recorder library in its original form, but public - * distribution of modified versions require approval by Percepio AB. - * - * Disclaimer - * The trace tool and recorder library is being delivered to you AS IS and - * Percepio AB makes no warranty as to its use or performance. Percepio AB does - * not and cannot warrant the performance or results you may obtain by using the - * software or documentation. Percepio AB make no warranties, express or - * implied, as to noninfringement of third party rights, merchantability, or - * fitness for any particular purpose. In no event will Percepio AB, its - * technology partners, or distributors be liable to you for any consequential, - * incidental or special damages, including any lost profits or lost savings, - * even if a representative of Percepio AB has been advised of the possibility - * of such damages, or for any claim by any third party. Some jurisdictions do - * not allow the exclusion or limitation of incidental, consequential or special - * damages, or the exclusion of implied warranties or limitations on how long an - * implied warranty may last, so the above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2015. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_HARDWARE_PORT_H -#define TRC_HARDWARE_PORT_H - -#ifdef __cplusplus -extern “C” { -#endif - -#include - -/****************************************************************************** - * Hardware ports - * To get accurate timestamping, a hardware timer is necessary. Below are the - * available ports. Some of these are "unofficial", meaning that - * they have not yet been verified by Percepio but have been contributed by - * external developers. They should work, otherwise let us know by emailing - * support@percepio.com. Some work on any OS platform, while other are specific - * to a certain operating system. - *****************************************************************************/ - - -/****** Port Name ***************************** Code */ -#define TRC_PORT_APPLICATION_DEFINED -1 -#define TRC_PORT_NOT_SET 0 -#define TRC_PORT_ARM_Cortex_M 1 -#define TRC_PORT_ARM_CORTEX_A9 2 -#define TRC_PORT_Renesas_RX600 3 -#define TRC_PORT_TEXAS_INSTRUMENTS_TMS570_RM48 4 -#define TRC_PORT_MICROCHIP_PIC32_MX_MZ 5 - -/******************************************************************************* - * - * HWTC Macros - Hardware Timer/Counter Isolation Layer - * - * These two HWTC macros provides a hardware isolation layer representing a - * generic hardware timer/counter used for the timestamping. - * - * HWTC_COUNT: The current value of the counter. This is expected to be reset - * a each tick interrupt. Thus, when the tick handler starts, the counter has - * already wrapped. - * - * HWTC_TYPE: Defines the type of timer/counter used for HWTC_COUNT: - * - * - FREE_RUNNING_32BIT_INCR: - * Free-running 32-bit timer, counting upwards from 0 - > 0xFFFFFFFF - * - * - FREE_RUNNING_32BIT_DECR - * Free-running 32-bit counter, counting downwards from 0xFFFFFFFF -> 0 - * - * - OS_TIMER_INCR - * Interrupt timer, counts upwards from 0 until HWTC_PERIOD-1 - * - * - OS_TIMER_DECR - * Interrupt timer, counts downwards from HWTC_PERIOD-1 until 0 - * - ******************************************************************************* - * - * IRQ_PRIORITY_ORDER - * - * Macro which should be defined as an integer of 0 or 1. - * - * It is only used only to sort and colorize the interrupts in priority order, - * in case you record interrupts using the vTraceStoreISRBegin and - * vTraceStoreISREnd routines. 1 indicates higher value is more important. - * - ******************************************************************************/ - -#define TRC_FREE_RUNNING_32BIT_INCR 1 -#define TRC_FREE_RUNNING_32BIT_DECR 2 -#define TRC_OS_TIMER_INCR 3 -#define TRC_OS_TIMER_DECR 4 - -#if (TRC_RECORDER_HARDWARE_PORT == TRC_PORT_ARM_Cortex_M) - - #define HWTC_TYPE TRC_OS_TIMER_DECR - #define HWTC_COUNT (*((uint32_t*)0xE000E018)) /* SysTick counter */ - #define IRQ_PRIORITY_ORDER 0 - -#elif (TRC_RECORDER_HARDWARE_PORT == TRC_PORT_Renesas_RX600) - - #include "iodefine.h" - - #define HWTC_TYPE TRC_OS_TIMER_INCR - #define HWTC_COUNT (CMT0.CMCNT) - #define IRQ_PRIORITY_ORDER 1 - -#elif (TRC_RECORDER_HARDWARE_PORT == TRC_PORT_MICROCHIP_PIC32_MX_MZ) - - #define HWTC_TYPE TRC_OS_TIMER_INCR - #define HWTC_COUNT (TMR1) - #define IRQ_PRIORITY_ORDER 0 - -#elif (TRC_RECORDER_HARDWARE_PORT == TRC_PORT_TEXAS_INSTRUMENTS_TMS570_RM48) - - #define RTIFRC0 *((uint32_t *)0xFFFFFC10) - #define RTICOMP0 *((uint32_t *)0xFFFFFC50) - #define RTIUDCP0 *((uint32_t *)0xFFFFFC54) - - #define HWTC_TYPE TRC_OS_TIMER_INCR - #define HWTC_COUNT (RTIFRC0 - (RTICOMP0 - RTIUDCP0)) - #define IRQ_PRIORITY_ORDER 0 - -#elif (TRC_RECORDER_HARDWARE_PORT == TRC_PORT_ARM_CORTEX_A9) - /* INPUT YOUR PERIPHERAL BASE ADDRESS HERE */ - #define CA9_MPCORE_PERIPHERAL_BASE_ADDRESS 0xSOMETHING - - #define CA9_MPCORE_PRIVATE_MEMORY_OFFSET 0x0600 - #define CA9_MPCORE_PRIVCTR_PERIOD_REG (*(volatile uint32_t*)(CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x00)) - #define CA9_MPCORE_PRIVCTR_COUNTER_REG (*(volatile uint32_t*)(CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x04)) - #define CA9_MPCORE_PRIVCTR_CONTROL_REG (*(volatile uint32_t*)(CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x08)) - - #define CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_MASK 0x0000FF00 - #define CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_SHIFT 8 - #define CA9_MPCORE_PRIVCTR_PRESCALER (((CA9_MPCORE_PRIVCTR_CONTROL_REG & CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_MASK) >> CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_SHIFT) + 1) - - #define HWTC_TYPE TRC_OS_TIMER_DECR - #define HWTC_COUNT CA9_MPCORE_PRIVCTR_COUNTER_REG - #define IRQ_PRIORITY_ORDER 0 - -#elif (TRC_RECORDER_HARDWARE_PORT == TRC_PORT_APPLICATION_DEFINED) - - #if !( defined (HWTC_TYPE) && defined (HWTC_COUNT) && defined (IRQ_PRIORITY_ORDER)) - #error RECORDER_HARDWARE_PORT is PORT_APPLICATION_DEFINED but not all of the necessary constants have been defined. - #endif - -#elif (TRC_RECORDER_HARDWARE_PORT != TRC_PORT_NOT_SET) - - #error "RECORDER_HARDWARE_PORT had unsupported value!" - #define TRC_RECORDER_HARDWARE_PORT PORT_NOT_SET - -#endif - -#if (TRC_RECORDER_HARDWARE_PORT != TRC_PORT_NOT_SET) - - #ifndef HWTC_COUNT - #error "HWTC_COUNT is not set!" - #endif - - #ifndef HWTC_TYPE - #error "HWTC_TYPE is not set!" - #endif - - #ifndef IRQ_PRIORITY_ORDER - #error "IRQ_PRIORITY_ORDER is not set!" - #elif (IRQ_PRIORITY_ORDER != 0) && (IRQ_PRIORITY_ORDER != 1) - #error "IRQ_PRIORITY_ORDER has bad value!" - #endif - -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* TRC_HARDWARE_PORT_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcKernelPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcKernelPort.c deleted file mode 100644 index e3a9c46aa..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcKernelPort.c +++ /dev/null @@ -1,267 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v3.0.2 - * Percepio AB, www.percepio.com - * - * trcKernelPort.c - * - * The kernel-specific code for integration with FreeRTOS. - * - * Terms of Use - * This software (the "Tracealyzer Recorder Library") is the intellectual - * property of Percepio AB and may not be sold or in other ways commercially - * redistributed without explicit written permission by Percepio AB. - * - * Separate conditions applies for the SEGGER branded source code included. - * - * The recorder library is free for use together with Percepio products. - * You may distribute the recorder library in its original form, but public - * distribution of modified versions require approval by Percepio AB. - * - * Disclaimer - * The trace tool and recorder library is being delivered to you AS IS and - * Percepio AB makes no warranty as to its use or performance. Percepio AB does - * not and cannot warrant the performance or results you may obtain by using the - * software or documentation. Percepio AB make no warranties, express or - * implied, as to noninfringement of third party rights, merchantability, or - * fitness for any particular purpose. In no event will Percepio AB, its - * technology partners, or distributors be liable to you for any consequential, - * incidental or special damages, including any lost profits or lost savings, - * even if a representative of Percepio AB has been advised of the possibility - * of such damages, or for any claim by any third party. Some jurisdictions do - * not allow the exclusion or limitation of incidental, consequential or special - * damages, or the exclusion of implied warranties or limitations on how long an - * implied warranty may last, so the above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2015. - * www.percepio.com - ******************************************************************************/ - -#include "trcKernelPort.h" - -#if (USE_TRACEALYZER_RECORDER == 1) - -#include -#include "trcRecorder.h" -#include "trcStreamPort.h" -#include "task.h" - -/* TzCtrl task TCB */ -static xTaskHandle HandleTzCtrl; - -/* Called by TzCtrl task periodically (every 100 ms) */ -static void CheckRecorderStatus(void); - -/* The TzCtrl task - receives commands from Tracealyzer (start/stop) */ -static portTASK_FUNCTION( TzCtrl, pvParameters ); - -/* Monitored by TzCtrl task, that give warnings as User Events */ -extern volatile uint32_t NoRoomForSymbol; -extern volatile uint32_t NoRoomForObjectData; -extern volatile uint32_t LongestSymbolName; -extern volatile uint32_t MaxBytesTruncated; - -#define TRC_PORT_MALLOC(size) pvPortMalloc(size) -#if ((TRC_STREAM_PORT_BLOCKING_TRANSFER == 1) && (TRC_MEASURE_BLOCKING_TIME == 1)) - -/*** Used in blocking transfer mode, if enabled TRC_MEASURE_BLOCKING_TIME **************/ - -/* The highest number of cycles used by SEGGER_RTT_Write. */ -static volatile int32_t blockingCyclesMax; - -/* The number of times SEGGER_RTT_Write has blocked due to a full buffer. */ -static volatile uint32_t blockingCount; - -/* User Event Channel for giving warnings regarding blocking */ -static char* trcDiagnosticsChannel; - -#endif /*((TRC_STREAM_PORT_BLOCKING_TRANSFER==1) && (TRC_MEASURE_BLOCKING_TIME))*/ - -TRC_STREAM_PORT_ALLOCATE_FIELDS() - -/* User Event Channel for giving warnings regarding NoRoomForSymbol etc. */ -char* trcWarningChannel; - -/* Keeps track of previous values, to only react on changes. */ -static uint32_t NoRoomForSymbol_last = 0; -static uint32_t NoRoomForObjectData_last = 0; -static uint32_t LongestSymbolName_last = 0; -static uint32_t MaxBytesTruncated_last = 0; - -/******************************************************************************* - * prvTraceGetCurrentTaskHandle - * - * Function that returns the handle to the currently executing task. - * - ******************************************************************************/ -void* prvTraceGetCurrentTaskHandle(void) -{ - return xTaskGetCurrentTaskHandle(); -} - -/******************************************************************************* - * prvIsNewTCB - * - * Function that returns the handle to the currently executing task. - * - ******************************************************************************/ -static void* pCurrentTCB = NULL; -uint32_t prvIsNewTCB(void* pNewTCB) -{ - if (pCurrentTCB != pNewTCB) - { - pCurrentTCB = pNewTCB; - return 1; - } - return 0; -} -/******************************************************************************* - * CheckRecorderStatus - * - * Called by TzCtrl task periodically (every 100 ms - seems reasonable). - * Checks a number of diagnostic variables and give warnings as user events, - * in most cases including a suggested solution. - ******************************************************************************/ -static void CheckRecorderStatus(void) -{ - if (NoRoomForSymbol > NoRoomForSymbol_last) - { - vTracePrintF(trcWarningChannel, "TRC_SYMBOL_TABLE_SLOTS too small. Add %d slots.", - NoRoomForSymbol); - - NoRoomForSymbol_last = NoRoomForSymbol; - } - - if (NoRoomForObjectData > NoRoomForObjectData_last) - { - vTracePrintF(trcWarningChannel, "TRC_OBJECT_DATA_SLOTS too small. Add %d slots.", - NoRoomForObjectData); - - NoRoomForObjectData_last = NoRoomForObjectData; - } - - if (LongestSymbolName > LongestSymbolName_last) - { - if (LongestSymbolName > TRC_SYMBOL_MAX_LENGTH) - { - vTracePrintF(trcWarningChannel, "TRC_SYMBOL_MAX_LENGTH too small. Add %d chars.", - LongestSymbolName); - } - LongestSymbolName_last = LongestSymbolName; - } - - if (MaxBytesTruncated > MaxBytesTruncated_last) - { - /* Some string event generated a too long string that was truncated. - This may happen for the following functions: - - vTracePrintF - - vTracePrintF - - vTraceStoreKernelObjectName - - vTraceStoreUserEventChannelName - - vTraceSetISRProperties - - A PSF event may store maximum 60 bytes payload, including data arguments - and string characters. For User Events, also the User Event Channel ptr - must be squeezed in, if a channel is specified. */ - - vTracePrintF(trcWarningChannel, "String event too long, up to %d bytes truncated.", - MaxBytesTruncated); - - MaxBytesTruncated_last = MaxBytesTruncated; - } - -#if ((TRC_STREAM_PORT_BLOCKING_TRANSFER==1) && (TRC_MEASURE_BLOCKING_TIME)) - if (blockingCount > 0) - { - /* At least one case of blocking since the last check and this is - the longest case. */ - vTracePrintF(trcDiagnosticsChannel, "Longest since last: %d us", - (uint32_t)blockingCyclesMax/(TRACE_CPU_CLOCK_HZ/1000000)); - - blockingCyclesMax = 0; - } -#endif -} - -/******************************************************************************* - * vTraceOnTraceBegin - * - * Called on trace begin. - ******************************************************************************/ -void vTraceOnTraceBegin(void) -{ - TRC_STREAM_PORT_ON_TRACE_BEGIN(); -} - -/******************************************************************************* - * vTraceOnTraceEnd - * - * Called on trace end. - ******************************************************************************/ -void vTraceOnTraceEnd(void) -{ - TRC_STREAM_PORT_ON_TRACE_END(); -} - -/******************************************************************************* - * TzCtrl - * - * Task for receiving commands from Tracealyzer and for recorder diagnostics. - * - ******************************************************************************/ -static portTASK_FUNCTION( TzCtrl, pvParameters ) -{ - TracealyzerCommandType msg; - int bytes = 0; - - while (1) - { - bytes = 0; - TRC_STREAM_PORT_READ_DATA(&msg, sizeof(TracealyzerCommandType), &bytes); - if (bytes != 0) - { - if (bytes == sizeof(TracealyzerCommandType)) - { - if (isValidCommand(&msg)) - { - processCommand(&msg); /* Start or Stop currently... */ - } - } - } - - do - { - bytes = 0; - TRC_STREAM_PORT_PERIODIC_SEND_DATA(&bytes); - } - while (bytes != 0); - - CheckRecorderStatus(); - vTaskDelay(TRC_CTRL_TASK_DELAY); /* 10ms */ - } -} - -/******************************************************************************* - * Trace_Init - * - * The main initialization routine for the trace recorder. Configures the stream - * and activates the TzCtrl task. - * Also sets up the diagnostic User Event channels used by TzCtrl task. - * - ******************************************************************************/ -void Trace_Init(void) -{ - TRC_STREAM_PORT_INIT(); - - trcWarningChannel = vTraceStoreUserEventChannelName("Warnings from Recorder"); - -#if ((TRC_STREAM_PORT_BLOCKING_TRANSFER==1) && (TRC_MEASURE_BLOCKING_TIME)) - trcDiagnosticsChannel = vTraceStoreUserEventChannelName("Blocking on trace buffer"); -#endif - - /* Creates the TzCtrl task - receives trace commands (start, stop, ...) */ - xTaskCreate( TzCtrl, "TzCtrl", configMINIMAL_STACK_SIZE, NULL, TRC_CTRL_TASK_PRIORITY, &HandleTzCtrl ); -} - -#endif diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcKernelPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcKernelPort.h deleted file mode 100644 index 554cabcd0..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcKernelPort.h +++ /dev/null @@ -1,929 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v3.0.2 - * Percepio AB, www.percepio.com - * - * trcKernelPort.h - * - * The kernel-specific definitions for FreeRTOS. - * - * Terms of Use - * This software (the "Tracealyzer Recorder Library") is the intellectual - * property of Percepio AB and may not be sold or in other ways commercially - * redistributed without explicit written permission by Percepio AB. - * - * Separate conditions applies for the SEGGER branded source code included. - * - * The recorder library is free for use together with Percepio products. - * You may distribute the recorder library in its original form, but public - * distribution of modified versions require approval by Percepio AB. - * - * Disclaimer - * The trace tool and recorder library is being delivered to you AS IS and - * Percepio AB makes no warranty as to its use or performance. Percepio AB does - * not and cannot warrant the performance or results you may obtain by using the - * software or documentation. Percepio AB make no warranties, express or - * implied, as to noninfringement of third party rights, merchantability, or - * fitness for any particular purpose. In no event will Percepio AB, its - * technology partners, or distributors be liable to you for any consequential, - * incidental or special damages, including any lost profits or lost savings, - * even if a representative of Percepio AB has been advised of the possibility - * of such damages, or for any claim by any third party. Some jurisdictions do - * not allow the exclusion or limitation of incidental, consequential or special - * damages, or the exclusion of implied warranties or limitations on how long an - * implied warranty may last, so the above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2015. - * www.percepio.com - ******************************************************************************/ - - -#ifndef TRC_KERNEL_PORT_H -#define TRC_KERNEL_PORT_H - -#ifdef __cplusplus -extern “C” { -#endif - -#include "FreeRTOS.h" /* Defines configUSE_TRACE_FACILITY */ -#include "trcConfig.h" -#include "trcHardwarePort.h" - -extern int uiInEventGroupSetBitsFromISR; - -#define USE_TRACEALYZER_RECORDER configUSE_TRACE_FACILITY - -#if (USE_TRACEALYZER_RECORDER == 1) - -/******************************************************************************* - * Trace_Init - * - * The main initalization routine for the embOS-Trace recorder. Configures RTT, - * activates the PTRACE instrumentation in embOS and the TzCtrl task. - * Also sets up the diagnostic User Event channels used by TzCtrl task. - * - * Settings used by the trace recorder are found in these header files: - * - SEGGER_RTT_Conf.h: settings for SEGGER Real-Time Terminal (RTT) which is - * used for the trace streaming. - * - trcKernelPort.h: RTT related settings for the trace streaming. - * - trcRecorder.h - settings for allocation of internal recorder tables. - * - trcHardwarePort.h - hardware-specific configuration (timestamping). - ******************************************************************************/ -void Trace_Init(void); - -/******************************************************************************* - * vTraceOnTraceBegin - * - * Called on trace begin. - ******************************************************************************/ -void vTraceOnTraceBegin(void); - -/******************************************************************************* - * vTraceOnTraceEnd - * - * Called on trace end. - ******************************************************************************/ -void vTraceOnTraceEnd(void); - -#include "trcRecorder.h" - -/* Defines that must be set for the recorder to work properly */ -#define KERNEL_ID 0x1AA1 -#define TRACE_TICK_RATE_HZ configTICK_RATE_HZ /* Defined in "FreeRTOS.h" */ -#define TRACE_CPU_CLOCK_HZ configCPU_CLOCK_HZ /* Defined in "FreeRTOSConfig.h" */ - -#if (TRC_RECORDER_HARDWARE_PORT == TRC_PORT_ARM_Cortex_M) - - /* Uses CMSIS API. Must be #included in trcConfig.h. */ - #define TRACE_ALLOC_CRITICAL_SECTION() int __irq_status; - #define TRACE_ENTER_CRITICAL_SECTION() {__irq_status = __get_PRIMASK(); __set_PRIMASK(1);} - #define TRACE_EXIT_CRITICAL_SECTION() {__set_PRIMASK(__irq_status);} - -#endif - -#if ((TRC_RECORDER_HARDWARE_PORT == TRC_PORT_ARM_CORTEX_A9) || (TRC_RECORDER_HARDWARE_PORT == TRC_PORT_Renesas_RX600)) - #define TRACE_ALLOC_CRITICAL_SECTION() int __irq_status; - #define TRACE_ENTER_CRITICAL_SECTION() {__irq_status = portSET_INTERRUPT_MASK_FROM_ISR();} - #define TRACE_EXIT_CRITICAL_SECTION() {portCLEAR_INTERRUPT_MASK_FROM_ISR(__irq_status);} -#endif - -#ifndef TRACE_ENTER_CRITICAL_SECTION - #error "This port has no valid definition for critical sections! See http://percepio.com/2014/10/27/how-to-define-critical-sections-for-the-recorder/" -#endif - -void* prvTraceGetCurrentTaskHandle(void); -uint32_t prvIsNewTCB(void* pNewTCB); - -#define OS_IS_SWITCH_FROM_INT_REQUIRED() 0 -#define TRACE_GET_CURRENT_TASK() prvTraceGetCurrentTaskHandle() - -/*************************************************************************/ -/* KERNEL SPECIFIC OBJECT CONFIGURATION */ -/*************************************************************************/ - -/******************************************************************************* - * The event codes - should match the offline config file. - * - * Some sections below are encoded to allow for constructions like: - * - * vTraceStoreKernelCall(EVENTGROUP_CREATE + objectclass, ... - * - * The object class ID is given by the three LSB bits, in such cases. Since each - * object class has a separate object property table, the class ID is needed to - * know what section in the object table to use for getting an object name from - * an object handle. - ******************************************************************************/ - -#define PSF_EVENT_NULL_EVENT 0x00 - -/* PSF event codes */ -#define PSF_EVENT_TRACE_START 0x01 -#define PSF_EVENT_TS_CONFIG 0x02 -#define PSF_EVENT_OBJ_NAME 0x03 -#define PSF_EVENT_TASK_PRIORITY 0x04 -#define PSF_EVENT_TASK_PRIO_INHERIT 0x05 -#define PSF_EVENT_TASK_PRIO_DISINHERIT 0x06 -#define PSF_EVENT_DEFINE_ISR 0x07 - -#define PSF_EVENT_TASK_CREATE 0x10 -#define PSF_EVENT_QUEUE_CREATE 0x11 -#define PSF_EVENT_SEMAPHORE_BINARY_CREATE 0x12 -#define PSF_EVENT_MUTEX_CREATE 0x13 -#define PSF_EVENT_TIMER_CREATE 0x14 -#define PSF_EVENT_EVENTGROUP_CREATE 0x15 -#define PSF_EVENT_SEMAPHORE_COUNTING_CREATE 0x16 -#define PSF_EVENT_MUTEX_RECURSIVE_CREATE 0x17 - -#define PSF_EVENT_TASK_DELETE 0x20 -#define PSF_EVENT_QUEUE_DELETE 0x21 -#define PSF_EVENT_SEMAPHORE_DELETE 0x22 -#define PSF_EVENT_MUTEX_DELETE 0x23 -#define PSF_EVENT_TIMER_DELETE 0x24 -#define PSF_EVENT_EVENTGROUP_DELETE 0x25 - -#define PSF_EVENT_TASK_READY 0x30 -#define PSF_EVENT_NEW_TIME 0x31 -#define PSF_EVENT_NEW_TIME_SCHEDULER_SUSPENDED 0x32 -#define PSF_EVENT_ISR_BEGIN 0x33 -#define PSF_EVENT_ISR_RESUME 0x34 -#define PSF_EVENT_TS_BEGIN 0x35 -#define PSF_EVENT_TS_RESUME 0x36 -#define PSF_EVENT_TASK_ACTIVATE 0x37 - -#define PSF_EVENT_MALLOC 0x38 -#define PSF_EVENT_FREE 0x39 - -#define PSF_EVENT_LOWPOWER_BEGIN 0x3A -#define PSF_EVENT_LOWPOWER_END 0x3B - -#define PSF_EVENT_IFE_NEXT 0x3C -#define PSF_EVENT_IFE_DIRECT 0x3D - -#define PSF_EVENT_TASK_CREATE_FAILED 0x40 -#define PSF_EVENT_QUEUE_CREATE_FAILED 0x41 -#define PSF_EVENT_SEMAPHORE_BINARY_CREATE_FAILED 0x42 -#define PSF_EVENT_MUTEX_CREATE_FAILED 0x43 -#define PSF_EVENT_TIMER_CREATE_FAILED 0x44 -#define PSF_EVENT_EVENTGROUP_CREATE_FAILED 0x45 -#define PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED 0x46 -#define PSF_EVENT_MUTEX_RECURSIVE_CREATE_FAILED 0x47 - -#define PSF_EVENT_TIMER_DELETE_FAILED 0x48 - -#define PSF_EVENT_QUEUE_SEND 0x50 -#define PSF_EVENT_SEMAPHORE_GIVE 0x51 -#define PSF_EVENT_MUTEX_GIVE 0x52 - -#define PSF_EVENT_QUEUE_SEND_FAILED 0x53 -#define PSF_EVENT_SEMAPHORE_GIVE_FAILED 0x54 -#define PSF_EVENT_MUTEX_GIVE_FAILED 0x55 - -#define PSF_EVENT_QUEUE_SEND_BLOCK 0x56 -#define PSF_EVENT_SEMAPHORE_GIVE_BLOCK 0x57 -#define PSF_EVENT_MUTEX_GIVE_BLOCK 0x58 - -#define PSF_EVENT_QUEUE_SEND_FROMISR 0x59 -#define PSF_EVENT_SEMAPHORE_GIVE_FROMISR 0x5A - -#define PSF_EVENT_QUEUE_SEND_FROMISR_FAILED 0x5C -#define PSF_EVENT_SEMAPHORE_GIVE_FROMISR_FAILED 0x5D - -#define PSF_EVENT_QUEUE_RECEIVE 0x60 -#define PSF_EVENT_SEMAPHORE_TAKE 0x61 -#define PSF_EVENT_MUTEX_TAKE 0x62 - -#define PSF_EVENT_QUEUE_RECEIVE_FAILED 0x63 -#define PSF_EVENT_SEMAPHORE_TAKE_FAILED 0x64 -#define PSF_EVENT_MUTEX_TAKE_FAILED 0x65 - -#define PSF_EVENT_QUEUE_RECEIVE_BLOCK 0x66 -#define PSF_EVENT_SEMAPHORE_TAKE_BLOCK 0x67 -#define PSF_EVENT_MUTEX_TAKE_BLOCK 0x68 - -#define PSF_EVENT_QUEUE_RECEIVE_FROMISR 0x69 -#define PSF_EVENT_SEMAPHORE_TAKE_FROMISR 0x6A - -#define PSF_EVENT_QUEUE_RECEIVE_FROMISR_FAILED 0x6C -#define PSF_EVENT_SEMAPHORE_TAKE_FROMISR_FAILED 0x6D - -#define PSF_EVENT_QUEUE_PEEK 0x70 -#define PSF_EVENT_SEMAPHORE_PEEK 0x71 /* Will never be used */ -#define PSF_EVENT_MUTEX_PEEK 0x72 /* Will never be used */ - -#define PSF_EVENT_QUEUE_PEEK_FAILED 0x73 -#define PSF_EVENT_SEMAPHORE_PEEK_FAILED 0x74 /* Will never be used */ -#define PSF_EVENT_MUTEX_PEEK_FAILED 0x75 /* Will never be used */ - -#define PSF_EVENT_QUEUE_PEEK_BLOCK 0x76 -#define PSF_EVENT_SEMAPHORE_PEEK_BLOCK 0x77 /* Will never be used */ -#define PSF_EVENT_MUTEX_PEEK_BLOCK 0x78 /* Will never be used */ - -#define PSF_EVENT_TASK_DELAY_UNTIL 0x79 -#define PSF_EVENT_TASK_DELAY 0x7A -#define PSF_EVENT_TASK_SUSPEND 0x7B -#define PSF_EVENT_TASK_RESUME 0x7C -#define PSF_EVENT_TASK_RESUME_FROMISR 0x7D - -#define PSF_EVENT_TIMER_PENDFUNCCALL 0x80 -#define PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR 0x81 -#define PSF_EVENT_TIMER_PENDFUNCCALL_FAILED 0x82 -#define PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR_FAILED 0x83 - -#define PSF_EVENT_USER_EVENT 0x90 - -#define PSF_EVENT_TIMER_START 0xA0 -#define PSF_EVENT_TIMER_RESET 0xA1 -#define PSF_EVENT_TIMER_STOP 0xA2 -#define PSF_EVENT_TIMER_CHANGEPERIOD 0xA3 -#define PSF_EVENT_TIMER_START_FROMISR 0xA4 -#define PSF_EVENT_TIMER_RESET_FROMISR 0xA5 -#define PSF_EVENT_TIMER_STOP_FROMISR 0xA6 -#define PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR 0xA7 -#define PSF_EVENT_TIMER_START_FAILED 0xA8 -#define PSF_EVENT_TIMER_RESET_FAILED 0xA9 -#define PSF_EVENT_TIMER_STOP_FAILED 0xAA -#define PSF_EVENT_TIMER_CHANGEPERIOD_FAILED 0xAB -#define PSF_EVENT_TIMER_START_FROMISR_FAILED 0xAC -#define PSF_EVENT_TIMER_RESET_FROMISR_FAILED 0xAD -#define PSF_EVENT_TIMER_STOP_FROMISR_FAILED 0xAE -#define PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR_FAILED 0xAF - -#define PSF_EVENT_EVENTGROUP_SYNC 0xB0 -#define PSF_EVENT_EVENTGROUP_WAITBITS 0xB1 -#define PSF_EVENT_EVENTGROUP_CLEARBITS 0xB2 -#define PSF_EVENT_EVENTGROUP_CLEARBITS_FROMISR 0xB3 -#define PSF_EVENT_EVENTGROUP_SETBITS 0xB4 -#define PSF_EVENT_EVENTGROUP_SETBITS_FROMISR 0xB5 -#define PSF_EVENT_EVENTGROUP_SYNC_BLOCK 0xB6 -#define PSF_EVENT_EVENTGROUP_WAITBITS_BLOCK 0xB7 -#define PSF_EVENT_EVENTGROUP_SYNC_FAILED 0xB8 -#define PSF_EVENT_EVENTGROUP_WAITBITS_FAILED 0xB9 - -#define PSF_EVENT_QUEUE_SEND_FRONT 0xC0 -#define PSF_EVENT_QUEUE_SEND_FRONT_FAILED 0xC1 -#define PSF_EVENT_QUEUE_SEND_FRONT_BLOCK 0xC2 -#define PSF_EVENT_QUEUE_SEND_FRONT_FROMISR 0xC3 -#define PSF_EVENT_QUEUE_SEND_FRONT_FROMISR_FAILED 0xC4 -#define PSF_EVENT_MUTEX_GIVE_RECURSIVE 0xC5 -#define PSF_EVENT_MUTEX_GIVE_RECURSIVE_FAILED 0xC6 -#define PSF_EVENT_MUTEX_TAKE_RECURSIVE 0xC7 -#define PSF_EVENT_MUTEX_TAKE_RECURSIVE_FAILED 0xC8 - -#define PSF_EVENT_TASK_NOTIFY 0xC9 -#define PSF_EVENT_TASK_NOTIFY_TAKE 0xCA -#define PSF_EVENT_TASK_NOTIFY_TAKE_BLOCK 0xCB -#define PSF_EVENT_TASK_NOTIFY_TAKE_FAILED 0xCC -#define PSF_EVENT_TASK_NOTIFY_WAIT 0xCD -#define PSF_EVENT_TASK_NOTIFY_WAIT_BLOCK 0xCE -#define PSF_EVENT_TASK_NOTIFY_WAIT_FAILED 0xCF -#define PSF_EVENT_TASK_NOTIFY_FROM_ISR 0xD0 -#define PSF_EVENT_TASK_NOTIFY_GIVE_FROM_ISR 0xD1 - -#define TRACE_GET_OS_TICKS() (uiTraceTickCount) - -/************************************************************************/ -/* KERNEL SPECIFIC DATA AND FUNCTIONS NEEDED TO PROVIDE THE */ -/* FUNCTIONALITY REQUESTED BY THE TRACE RECORDER */ -/************************************************************************/ - -#if (configUSE_TIMERS == 1) -#undef INCLUDE_xTimerGetTimerDaemonTaskHandle -#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1 -#endif - -/************************************************************************/ -/* KERNEL SPECIFIC MACROS USED BY THE TRACE RECORDER */ -/************************************************************************/ - -#define TRACE_MALLOC(size) pvPortMalloc(size) - -/************************************************************************/ -/* KERNEL SPECIFIC WRAPPERS THAT SHOULD BE CALLED BY THE KERNEL */ -/************************************************************************/ - -#if (configUSE_TICKLESS_IDLE != 0) - -#undef traceLOW_POWER_IDLE_BEGIN -#define traceLOW_POWER_IDLE_BEGIN() \ - { \ - vTraceStoreEvent0(PSF_EVENT_LOWPOWER_BEGIN); \ - } - -#undef traceLOW_POWER_IDLE_END -#define traceLOW_POWER_IDLE_END() \ - { \ - vTraceStoreEvent0(PSF_EVENT_LOWPOWER_END); \ - } - -#endif - -/* A macro that will update the tick count when returning from tickless idle */ -#undef traceINCREASE_TICK_COUNT -/* Note: This can handle time adjustments of max 2^32 ticks, i.e., 35 seconds at 120 MHz. Thus, tick-less idle periods longer than 2^32 ticks will appear "compressed" on the time line.*/ -#define traceINCREASE_TICK_COUNT( xCount ) - -/* Called for each task that becomes ready */ -#undef traceMOVED_TASK_TO_READY_STATE -#define traceMOVED_TASK_TO_READY_STATE( pxTCB ) \ - vTraceStoreEvent1(PSF_EVENT_TASK_READY, (uint32_t)pxTCB); - -/* Called on each OS tick. Will call uiPortGetTimestamp to make sure it is called at least once every OS tick. */ -#undef traceTASK_INCREMENT_TICK -#if (TRC_FREERTOS_VERSION == TRC_FREERTOS_VERSION_7_3_OR_7_4) - -#define traceTASK_INCREMENT_TICK( xTickCount ) \ - if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxMissedTicks == 0) { extern uint32_t uiTraceTickCount; uiTraceTickCount++; } \ - if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE) { vTraceStoreEvent1(PSF_EVENT_NEW_TIME, (xTickCount + 1)); } - -#else - -#define traceTASK_INCREMENT_TICK( xTickCount ) \ - if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdTRUE || uxPendedTicks == 0) { extern uint32_t uiTraceTickCount; uiTraceTickCount++; } \ - if (uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE) { vTraceStoreEvent1(PSF_EVENT_NEW_TIME, (xTickCount + 1)); } - -#endif - -/* Called on each task-switch */ -#undef traceTASK_SWITCHED_IN -#define traceTASK_SWITCHED_IN() \ - if (prvIsNewTCB(pxCurrentTCB)) \ - { \ - vTraceStoreEvent2(PSF_EVENT_TASK_ACTIVATE, (uint32_t)pxCurrentTCB, pxCurrentTCB->uxPriority); \ - } - -/* Called on vTaskSuspend */ -#undef traceTASK_SUSPEND -#define traceTASK_SUSPEND( pxTaskToSuspend ) \ - vTraceStoreEvent1(PSF_EVENT_TASK_SUSPEND, (uint32_t)pxTaskToSuspend); - -/* Called on vTaskDelay - note the use of FreeRTOS variable xTicksToDelay */ -#undef traceTASK_DELAY -#define traceTASK_DELAY() \ - vTraceStoreEvent1(PSF_EVENT_TASK_DELAY, xTicksToDelay); - -/* Called on vTaskDelayUntil - note the use of FreeRTOS variable xTimeToWake */ -#undef traceTASK_DELAY_UNTIL -#define traceTASK_DELAY_UNTIL() \ - vTraceStoreEvent1(PSF_EVENT_TASK_DELAY_UNTIL, xTimeToWake); - -/* Called on vTaskDelete */ -#undef traceTASK_DELETE -#define traceTASK_DELETE( pxTaskToDelete ) \ - vTraceStoreEvent2(PSF_EVENT_TASK_DELETE, (uint32_t)pxTaskToDelete, (pxTaskToDelete != NULL) ? (pxTaskToDelete->uxPriority) : 0); - -/* Called on vQueueDelete */ -#undef traceQUEUE_DELETE -#define traceQUEUE_DELETE( pxQueue ) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - vTraceStoreEvent2(PSF_EVENT_QUEUE_DELETE, (uint32_t)pxQueue, (pxQueue != NULL) ? (pxQueue->uxMessagesWaiting) : 0); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - vTraceStoreEvent2(PSF_EVENT_MUTEX_DELETE, (uint32_t)pxQueue, (pxQueue != NULL) ? (pxQueue->uxMessagesWaiting) : 0); \ - break; \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - vTraceStoreEvent2(PSF_EVENT_SEMAPHORE_DELETE, (uint32_t)pxQueue, (pxQueue != NULL) ? (pxQueue->uxMessagesWaiting) : 0); \ - break; \ - } - -/* Called on vTaskCreate */ -#undef traceTASK_CREATE -#define traceTASK_CREATE(pxNewTCB) \ - if (pxNewTCB != NULL) \ - { \ - vTraceSaveSymbol(pxNewTCB, (const char*)pcName); \ - vTraceSaveObjectData(pxNewTCB, uxPriority); \ - vTraceStoreStringEvent(1, PSF_EVENT_OBJ_NAME, pcName, pxNewTCB); \ - vTraceStoreEvent2(PSF_EVENT_TASK_CREATE, (uint32_t)pxNewTCB, uxPriority); \ - } - -/* Called in vTaskCreate, if it fails (typically if the stack can not be allocated) */ -#undef traceTASK_CREATE_FAILED -#define traceTASK_CREATE_FAILED() \ - vTraceStoreEvent0(PSF_EVENT_TASK_CREATE_FAILED); - -/* Called in xQueueCreate, and thereby for all other object based on queues, such as semaphores. */ -#undef traceQUEUE_CREATE -#define traceQUEUE_CREATE( pxNewQueue )\ - switch (pxNewQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - vTraceStoreEvent2(PSF_EVENT_QUEUE_CREATE, (uint32_t)pxNewQueue, pxNewQueue->uxLength); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - vTraceStoreEvent1(PSF_EVENT_SEMAPHORE_BINARY_CREATE, (uint32_t)pxNewQueue); \ - break; \ - } - -/* Called in xQueueCreate, if the queue creation fails */ -#undef traceQUEUE_CREATE_FAILED -#define traceQUEUE_CREATE_FAILED( queueType ) \ - switch (queueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - vTraceStoreEvent0(PSF_EVENT_QUEUE_CREATE_FAILED); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - vTraceStoreEvent0(PSF_EVENT_SEMAPHORE_BINARY_CREATE_FAILED); \ - break; \ - } - -/* Called in xQueueCreateCountingSemaphore, if the queue creation fails */ -#undef traceCREATE_COUNTING_SEMAPHORE -#if TRC_FREERTOS_VERSION == TRC_FREERTOS_VERSION_8_0_OR_LATER -#define traceCREATE_COUNTING_SEMAPHORE() \ - vTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE, (uint32_t)xHandle, ((Queue_t *) xHandle)->uxMessagesWaiting); -#else -#define traceCREATE_COUNTING_SEMAPHORE() \ - vTraceStoreEvent2(PSF_EVENT_SEMAPHORE_COUNTING_CREATE, (uint32_t)pxHandle, pxHandle->uxMessagesWaiting); -#endif - -#undef traceCREATE_COUNTING_SEMAPHORE_FAILED -#define traceCREATE_COUNTING_SEMAPHORE_FAILED() \ - vTraceStoreEvent0(PSF_EVENT_SEMAPHORE_COUNTING_CREATE_FAILED); - -/* Called in xQueueCreateMutex, and thereby also from xSemaphoreCreateMutex and xSemaphoreCreateRecursiveMutex */ -#undef traceCREATE_MUTEX -#define traceCREATE_MUTEX( pxNewQueue ) \ - switch (ucQueueType) \ - { \ - case queueQUEUE_TYPE_MUTEX: \ - vTraceStoreEvent1(PSF_EVENT_MUTEX_CREATE, (uint32_t)pxNewQueue); \ - break; \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - vTraceStoreEvent1(PSF_EVENT_MUTEX_RECURSIVE_CREATE, (uint32_t)pxNewQueue); \ - break; \ - } - -/* Called in xQueueCreateMutex when the operation fails (when memory allocation fails) */ -#undef traceCREATE_MUTEX_FAILED -#define traceCREATE_MUTEX_FAILED() \ - switch (ucQueueType) \ - { \ - case queueQUEUE_TYPE_MUTEX: \ - vTraceStoreEvent0(PSF_EVENT_MUTEX_CREATE_FAILED); \ - break; \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - vTraceStoreEvent0(PSF_EVENT_MUTEX_CREATE_FAILED); \ - break; \ - } - -/* Called when a message is sent to a queue */ /* CS IS NEW ! */ -#undef traceQUEUE_SEND -#define traceQUEUE_SEND( pxQueue ) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - vTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND : PSF_EVENT_QUEUE_SEND_FRONT, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting + 1); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - vTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting + 1); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - vTraceStoreEvent1(PSF_EVENT_MUTEX_GIVE, (uint32_t)pxQueue); \ - break; \ - } - -/* Called when a message failed to be sent to a queue (timeout) */ -#undef traceQUEUE_SEND_FAILED -#define traceQUEUE_SEND_FAILED( pxQueue ) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - vTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_FAILED : PSF_EVENT_QUEUE_SEND_FRONT_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - vTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - vTraceStoreEvent1(PSF_EVENT_MUTEX_GIVE_FAILED, (uint32_t)pxQueue); \ - break; \ - } - - /*trcKERNEL_HOOKS_KERNEL_SERVICE(SEND, FAILED, UNUSED, pxQueue);*/ - -/* Called when the task is blocked due to a send operation on a full queue */ -#undef traceBLOCKING_ON_QUEUE_SEND -#define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - vTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_BLOCK : PSF_EVENT_QUEUE_SEND_FRONT_BLOCK, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - vTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE_BLOCK, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - vTraceStoreEvent1(PSF_EVENT_MUTEX_GIVE_BLOCK, (uint32_t)pxQueue); \ - break; \ - } - -/* Called for Recursive Mutex */ -#undef traceGIVE_MUTEX_RECURSIVE -#define traceGIVE_MUTEX_RECURSIVE( pxMutex ) \ - vTraceStoreEvent1(PSF_EVENT_MUTEX_GIVE_RECURSIVE, (uint32_t)pxMutex); - -/* Called for Recursive Mutex */ -#undef traceGIVE_MUTEX_RECURSIVE_FAILED -#define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) \ - vTraceStoreEvent1(PSF_EVENT_MUTEX_GIVE_RECURSIVE_FAILED, (uint32_t)pxMutex); - -/**************************************************************************/ -/* Hack to make sure xQueueGiveFromISR also has a xCopyPosition parameter */ -/**************************************************************************/ -/* Helpers needed to correctly expand names */ -#define TZ__CAT2(a,b) a ## b -#define TZ__CAT(a,b) TZ__CAT2(a, b) - -/* Expands name if this header is included... uxQueueType must be a macro that only exists in queue.c or whatever, and it must expand to nothing or to something that's valid in identifiers */ -#define xQueueGiveFromISR(a,b) TZ__CAT(xQueueGiveFromISR__, uxQueueType) (a,b) - -/* If in queue.c, the "uxQueueType" macro expands to "pcHead". queueSEND_TO_BACK is the value we need to send in */ -#define xQueueGiveFromISR__pcHead(__a, __b) MyWrapper(__a, __b, const BaseType_t xCopyPosition); \ -BaseType_t xQueueGiveFromISR(__a, __b) { return MyWrapper(xQueue, pxHigherPriorityTaskWoken, queueSEND_TO_BACK); } \ -BaseType_t MyWrapper(__a, __b, const BaseType_t xCopyPosition) - -/* If not in queue.c, "uxQueueType" isn't expanded */ -#define xQueueGiveFromISR__uxQueueType(__a, __b) xQueueGiveFromISR(__a,__b) - -/**************************************************************************/ -/* End of xQueueGiveFromISR hack */ -/**************************************************************************/ - -/* Called when a message is sent from interrupt context, e.g., using xQueueSendFromISR */ -#undef traceQUEUE_SEND_FROM_ISR -#define traceQUEUE_SEND_FROM_ISR( pxQueue ) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - vTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_FROMISR : PSF_EVENT_QUEUE_SEND_FRONT_FROMISR, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting + 1); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - vTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE_FROMISR, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting + 1); \ - break; \ - } - -/* Called when a message send from interrupt context fails (since the queue was full) */ -#undef traceQUEUE_SEND_FROM_ISR_FAILED -#define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - vTraceStoreEvent2(xCopyPosition == queueSEND_TO_BACK ? PSF_EVENT_QUEUE_SEND_FROMISR_FAILED : PSF_EVENT_QUEUE_SEND_FRONT_FROMISR_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - vTraceStoreEvent2(PSF_EVENT_SEMAPHORE_GIVE_FROMISR_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - } - -/* Called when a message is received from a queue */ -#undef traceQUEUE_RECEIVE -#define traceQUEUE_RECEIVE( pxQueue ) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - vTraceStoreEvent3(PSF_EVENT_QUEUE_RECEIVE, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting - 1); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - vTraceStoreEvent3(PSF_EVENT_SEMAPHORE_TAKE, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting - 1); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - vTraceStoreEvent2(PSF_EVENT_MUTEX_TAKE, (uint32_t)pxQueue, xTicksToWait); \ - break; \ - } - -/* Called when a receive operation on a queue fails (timeout) */ -#undef traceQUEUE_RECEIVE_FAILED -#define traceQUEUE_RECEIVE_FAILED( pxQueue ) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - vTraceStoreEvent3(xJustPeeking == pdFALSE ? PSF_EVENT_QUEUE_RECEIVE_FAILED : PSF_EVENT_QUEUE_PEEK_FAILED, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - vTraceStoreEvent3(xJustPeeking == pdFALSE ? PSF_EVENT_SEMAPHORE_TAKE_FAILED : PSF_EVENT_SEMAPHORE_PEEK_FAILED, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - vTraceStoreEvent2(xJustPeeking == pdFALSE ? PSF_EVENT_MUTEX_TAKE_FAILED : PSF_EVENT_MUTEX_PEEK_FAILED, (uint32_t)pxQueue, xTicksToWait); \ - break; \ - } - -/* Called when the task is blocked due to a receive operation on an empty queue */ -#undef traceBLOCKING_ON_QUEUE_RECEIVE -#define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - vTraceStoreEvent3(xJustPeeking == pdFALSE ? PSF_EVENT_QUEUE_RECEIVE_BLOCK : PSF_EVENT_QUEUE_PEEK_BLOCK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - vTraceStoreEvent3(xJustPeeking == pdFALSE ? PSF_EVENT_SEMAPHORE_TAKE_BLOCK : PSF_EVENT_SEMAPHORE_PEEK_BLOCK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - vTraceStoreEvent2(xJustPeeking == pdFALSE ? PSF_EVENT_MUTEX_TAKE_BLOCK : PSF_EVENT_MUTEX_PEEK_BLOCK, (uint32_t)pxQueue, xTicksToWait); \ - break; \ - } - -#undef traceTAKE_MUTEX_RECURSIVE -#if TRC_FREERTOS_VERSION == TRC_FREERTOS_VERSION_8_0_OR_LATER -#define traceTAKE_MUTEX_RECURSIVE( pxQueue ) \ - vTraceStoreEvent2(PSF_EVENT_MUTEX_TAKE_RECURSIVE, (uint32_t)pxQueue, xTicksToWait); -#else -#define traceTAKE_MUTEX_RECURSIVE( pxQueue ) \ - vTraceStoreEvent2(PSF_EVENT_MUTEX_TAKE_RECURSIVE, (uint32_t)pxQueue, xBlockTime); -#endif - -#undef traceTAKE_MUTEX_RECURSIVE_FAILED -#if TRC_FREERTOS_VERSION == TRC_FREERTOS_VERSION_8_0_OR_LATER -#define traceTAKE_MUTEX_RECURSIVE_FAILED( pxQueue ) \ -vTraceStoreEvent2(PSF_EVENT_MUTEX_TAKE_RECURSIVE_FAILED, (uint32_t)pxQueue, xTicksToWait); -#else -#define traceTAKE_MUTEX_RECURSIVE_FAILED( pxQueue ) \ -vTraceStoreEvent2(PSF_EVENT_MUTEX_TAKE_RECURSIVE_FAILED, (uint32_t)pxQueue, xBlockTime); -#endif - -/* Called when a message is received in interrupt context, e.g., using xQueueReceiveFromISR */ -#undef traceQUEUE_RECEIVE_FROM_ISR -#define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) \ -switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - vTraceStoreEvent2(PSF_EVENT_QUEUE_RECEIVE_FROMISR, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting - 1); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - vTraceStoreEvent2(PSF_EVENT_SEMAPHORE_TAKE_FROMISR, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting - 1); \ - break; \ - } - -/* Called when a message receive from interrupt context fails (since the queue was empty) */ -#undef traceQUEUE_RECEIVE_FROM_ISR_FAILED -#define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - vTraceStoreEvent2(PSF_EVENT_QUEUE_RECEIVE_FROMISR_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - vTraceStoreEvent2(PSF_EVENT_SEMAPHORE_TAKE_FROMISR_FAILED, (uint32_t)pxQueue, pxQueue->uxMessagesWaiting); \ - break; \ - } - -/* Called on xQueuePeek */ -#undef traceQUEUE_PEEK -#define traceQUEUE_PEEK( pxQueue ) \ - switch (pxQueue->ucQueueType) \ - { \ - case queueQUEUE_TYPE_BASE: \ - vTraceStoreEvent3(PSF_EVENT_QUEUE_PEEK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_BINARY_SEMAPHORE: \ - case queueQUEUE_TYPE_COUNTING_SEMAPHORE: \ - vTraceStoreEvent3(PSF_EVENT_SEMAPHORE_PEEK, (uint32_t)pxQueue, xTicksToWait, pxQueue->uxMessagesWaiting); \ - break; \ - case queueQUEUE_TYPE_MUTEX: \ - case queueQUEUE_TYPE_RECURSIVE_MUTEX: \ - vTraceStoreEvent1(PSF_EVENT_MUTEX_PEEK, (uint32_t)pxQueue); \ - break; \ - } - -/* Called in vTaskPrioritySet */ -#undef traceTASK_PRIORITY_SET -#define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) \ - vTraceStoreEvent2(PSF_EVENT_TASK_PRIORITY, (uint32_t)pxTask, uxNewPriority); - -/* Called in vTaskPriorityInherit, which is called by Mutex operations */ -#undef traceTASK_PRIORITY_INHERIT -#define traceTASK_PRIORITY_INHERIT( pxTask, uxNewPriority ) \ - vTraceStoreEvent2(PSF_EVENT_TASK_PRIO_INHERIT, (uint32_t)pxTask, uxNewPriority); - -/* Called in vTaskPriorityDisinherit, which is called by Mutex operations */ -#undef traceTASK_PRIORITY_DISINHERIT -#define traceTASK_PRIORITY_DISINHERIT( pxTask, uxNewPriority ) \ - vTraceStoreEvent2(PSF_EVENT_TASK_PRIO_DISINHERIT, (uint32_t)pxTask, uxNewPriority); - -/* Called in vTaskResume */ -#undef traceTASK_RESUME -#define traceTASK_RESUME( pxTaskToResume ) \ - vTraceStoreEvent1(PSF_EVENT_TASK_RESUME, (uint32_t)pxTaskToResume); - -/* Called in vTaskResumeFromISR */ -#undef traceTASK_RESUME_FROM_ISR -#define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) \ - vTraceStoreEvent1(PSF_EVENT_TASK_RESUME_FROMISR, (uint32_t)pxTaskToResume); - -#undef traceMALLOC -#define traceMALLOC( pvAddress, uiSize ) \ - vTraceStoreEvent2(PSF_EVENT_MALLOC, (uint32_t)pvAddress, (int32_t)uiSize); - -#undef traceFREE -#define traceFREE( pvAddress, uiSize ) \ - vTraceStoreEvent2(PSF_EVENT_FREE, (uint32_t)pvAddress, (int32_t)(-uiSize)); - -/* Called in timer.c - xTimerCreate */ -#undef traceTIMER_CREATE -#define traceTIMER_CREATE(tmr) \ - vTraceStoreEvent2(PSF_EVENT_TIMER_CREATE, (uint32_t)tmr, tmr->xTimerPeriodInTicks); - -#undef traceTIMER_CREATE_FAILED -#define traceTIMER_CREATE_FAILED() \ - vTraceStoreEvent0(PSF_EVENT_TIMER_CREATE_FAILED); - -#if TRC_FREERTOS_VERSION == TRC_FREERTOS_VERSION_8_0_OR_LATER -#define traceTIMER_COMMAND_SEND_8_0_CASES(tmr) \ - case tmrCOMMAND_RESET: \ - vTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_RESET : PSF_EVENT_TIMER_RESET_FAILED, (uint32_t)tmr, xOptionalValue); \ - break; \ - case tmrCOMMAND_START_FROM_ISR: \ - vTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_START_FROMISR : PSF_EVENT_TIMER_START_FROMISR_FAILED, (uint32_t)tmr, xOptionalValue); \ - break; \ - case tmrCOMMAND_RESET_FROM_ISR: \ - vTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_RESET_FROMISR : PSF_EVENT_TIMER_RESET_FROMISR_FAILED, (uint32_t)tmr, xOptionalValue); \ - break; \ - case tmrCOMMAND_STOP_FROM_ISR: \ - vTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_STOP_FROMISR : PSF_EVENT_TIMER_STOP_FROMISR_FAILED, (uint32_t)tmr, xOptionalValue); \ - break; \ - case tmrCOMMAND_CHANGE_PERIOD_FROM_ISR: \ - vTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR : PSF_EVENT_TIMER_CHANGEPERIOD_FROMISR_FAILED, (uint32_t)tmr, xOptionalValue); \ - break; -#else -#define traceTIMER_COMMAND_SEND_8_0_CASES(tmr) -#endif - -/* Note that xCommandID can never be tmrCOMMAND_EXECUTE_CALLBACK (-1) since the trace macro is not called in that case */ -#undef traceTIMER_COMMAND_SEND -#define traceTIMER_COMMAND_SEND(tmr, xCommandID, xOptionalValue, xReturn) \ - switch(xCommandID) \ - { \ - case tmrCOMMAND_START: \ - break; \ - case tmrCOMMAND_STOP: \ - break; \ - case tmrCOMMAND_CHANGE_PERIOD: \ - vTraceStoreEvent2((xReturn == pdPASS) ? PSF_EVENT_TIMER_CHANGEPERIOD : PSF_EVENT_TIMER_CHANGEPERIOD_FAILED, (uint32_t)tmr, xOptionalValue); \ - break; \ - case tmrCOMMAND_DELETE: \ - vTraceStoreEvent1((xReturn == pdPASS) ? PSF_EVENT_TIMER_DELETE : PSF_EVENT_TIMER_DELETE_FAILED, (uint32_t)tmr); \ - break; \ - traceTIMER_COMMAND_SEND_8_0_CASES(tmr) \ - } - -#undef tracePEND_FUNC_CALL -#define tracePEND_FUNC_CALL(func, arg1, arg2, ret) \ - vTraceStoreEvent1((ret == pdPASS) ? PSF_EVENT_TIMER_PENDFUNCCALL : PSF_EVENT_TIMER_PENDFUNCCALL_FAILED, (uint32_t)func); - -#undef tracePEND_FUNC_CALL_FROM_ISR -#define tracePEND_FUNC_CALL_FROM_ISR(func, arg1, arg2, ret) \ - vTraceStoreEvent1((ret == pdPASS) ? PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR : PSF_EVENT_TIMER_PENDFUNCCALL_FROMISR_FAILED, (uint32_t)func); - -#undef traceEVENT_GROUP_CREATE -#define traceEVENT_GROUP_CREATE(eg) \ - vTraceStoreEvent1(PSF_EVENT_EVENTGROUP_CREATE, (uint32_t)eg); - -#undef traceEVENT_GROUP_DELETE -#define traceEVENT_GROUP_DELETE(eg) \ - vTraceStoreEvent1(PSF_EVENT_EVENTGROUP_DELETE, (uint32_t)eg); - -#undef traceEVENT_GROUP_CREATE_FAILED -#define traceEVENT_GROUP_CREATE_FAILED() \ - vTraceStoreEvent0(PSF_EVENT_EVENTGROUP_CREATE_FAILED); - -#undef traceEVENT_GROUP_SYNC_BLOCK -#define traceEVENT_GROUP_SYNC_BLOCK(eg, bitsToSet, bitsToWaitFor) \ - vTraceStoreEvent2(PSF_EVENT_EVENTGROUP_SYNC_BLOCK, (uint32_t)eg, bitsToWaitFor); - -#undef traceEVENT_GROUP_SYNC_END -#define traceEVENT_GROUP_SYNC_END(eg, bitsToSet, bitsToWaitFor, wasTimeout) \ - vTraceStoreEvent2((wasTimeout != pdTRUE) ? PSF_EVENT_EVENTGROUP_SYNC : PSF_EVENT_EVENTGROUP_SYNC_FAILED, (uint32_t)eg, bitsToWaitFor); - -#undef traceEVENT_GROUP_WAIT_BITS_BLOCK -#define traceEVENT_GROUP_WAIT_BITS_BLOCK(eg, bitsToWaitFor) \ - vTraceStoreEvent2(PSF_EVENT_EVENTGROUP_WAITBITS_BLOCK, (uint32_t)eg, bitsToWaitFor); - -#undef traceEVENT_GROUP_WAIT_BITS_END -#define traceEVENT_GROUP_WAIT_BITS_END(eg, bitsToWaitFor, wasTimeout) \ - vTraceStoreEvent2((wasTimeout != pdTRUE) ? PSF_EVENT_EVENTGROUP_WAITBITS : PSF_EVENT_EVENTGROUP_WAITBITS_FAILED, (uint32_t)eg, bitsToWaitFor); - -#undef traceEVENT_GROUP_CLEAR_BITS -#define traceEVENT_GROUP_CLEAR_BITS(eg, bitsToClear) \ - vTraceStoreEvent2(PSF_EVENT_EVENTGROUP_CLEARBITS, (uint32_t)eg, bitsToClear); - -#undef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR -#define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR(eg, bitsToClear) \ - vTraceStoreEvent2(PSF_EVENT_EVENTGROUP_CLEARBITS_FROMISR, (uint32_t)eg, bitsToClear); - -#undef traceEVENT_GROUP_SET_BITS -#define traceEVENT_GROUP_SET_BITS(eg, bitsToSet) \ - vTraceStoreEvent2(PSF_EVENT_EVENTGROUP_SETBITS, (uint32_t)eg, bitsToSet); - -#undef traceEVENT_GROUP_SET_BITS_FROM_ISR -#define traceEVENT_GROUP_SET_BITS_FROM_ISR(eg, bitsToSet) \ - vTraceStoreEvent2(PSF_EVENT_EVENTGROUP_SETBITS_FROMISR, (uint32_t)eg, bitsToSet); - -#undef traceTASK_NOTIFY_TAKE -#define traceTASK_NOTIFY_TAKE() \ - if (pxCurrentTCB->eNotifyState == eNotified) \ - vTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_TAKE, (uint32_t)pxCurrentTCB, xTicksToWait); \ - else \ - vTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_TAKE_FAILED, (uint32_t)pxCurrentTCB, xTicksToWait); - -#undef traceTASK_NOTIFY_TAKE_BLOCK -#define traceTASK_NOTIFY_TAKE_BLOCK() \ - vTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_TAKE_BLOCK, (uint32_t)pxCurrentTCB, xTicksToWait); - -#undef traceTASK_NOTIFY_WAIT -#define traceTASK_NOTIFY_WAIT() \ - if (pxCurrentTCB->eNotifyState == eNotified) \ - vTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_WAIT, (uint32_t)pxCurrentTCB, xTicksToWait); \ - else \ - vTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_WAIT_FAILED, (uint32_t)pxCurrentTCB, xTicksToWait); - -#undef traceTASK_NOTIFY_WAIT_BLOCK -#define traceTASK_NOTIFY_WAIT_BLOCK() \ - vTraceStoreEvent2(PSF_EVENT_TASK_NOTIFY_WAIT_BLOCK, (uint32_t)pxCurrentTCB, xTicksToWait); - -#undef traceTASK_NOTIFY -#define traceTASK_NOTIFY() \ - vTraceStoreEvent1(PSF_EVENT_TASK_NOTIFY, (uint32_t)xTaskToNotify); - -#undef traceTASK_NOTIFY_FROM_ISR -#define traceTASK_NOTIFY_FROM_ISR() \ - vTraceStoreEvent1(PSF_EVENT_TASK_NOTIFY_FROM_ISR, (uint32_t)xTaskToNotify); - -#undef traceTASK_NOTIFY_GIVE_FROM_ISR -#define traceTASK_NOTIFY_GIVE_FROM_ISR() \ - vTraceStoreEvent1(PSF_EVENT_TASK_NOTIFY_GIVE_FROM_ISR, (uint32_t)xTaskToNotify); - -/************************************************************************/ -/* KERNEL SPECIFIC MACROS TO NAME OBJECTS, IF NECESSARY */ -/************************************************************************/ -#define vTraceSetQueueName(object, name) \ -vTraceStoreKernelObjectName(object, name); - -#define vTraceSetSemaphoreName(object, name) \ -vTraceStoreKernelObjectName(object, name); - -#define vTraceSetMutexName(object, name) \ -vTraceStoreKernelObjectName(object, name); - -#define vTraceSetEventGroupName(object, name) \ -vTraceStoreKernelObjectName(object, name); - -#else /*(USE_TRACEALYZER_RECORDER == 1)*/ - -#define vTraceSetQueueName(object, name) - -#define vTraceSetSemaphoreName(object, name) - -#define vTraceSetMutexName(object, name) - -#define vTraceSetEventGroupName(object, name) - -#define Trace_Init() - -#endif /*(USE_TRACEALYZER_RECORDER == 1)*/ - -#ifdef __cplusplus -} -#endif - -#endif /* TRC_KERNEL_PORT_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcPagedEventBuffer.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcPagedEventBuffer.c deleted file mode 100644 index c15dee411..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcPagedEventBuffer.c +++ /dev/null @@ -1,302 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v3.0.2 - * Percepio AB, www.percepio.com - * - * trcPagedEventBuffer.c - * - * Implements a paged buffer that can be used by TCP/IP or custom transfer - * methods. - * - * Terms of Use - * This software (the "Tracealyzer Recorder Library") is the intellectual - * property of Percepio AB and may not be sold or in other ways commercially - * redistributed without explicit written permission by Percepio AB. - * - * Separate conditions applies for the SEGGER branded source code included. - * - * The recorder library is free for use together with Percepio products. - * You may distribute the recorder library in its original form, but public - * distribution of modified versions require approval by Percepio AB. - * - * Disclaimer - * The trace tool and recorder library is being delivered to you AS IS and - * Percepio AB makes no warranty as to its use or performance. Percepio AB does - * not and cannot warrant the performance or results you may obtain by using the - * software or documentation. Percepio AB make no warranties, express or - * implied, as to noninfringement of third party rights, merchantability, or - * fitness for any particular purpose. In no event will Percepio AB, its - * technology partners, or distributors be liable to you for any consequential, - * incidental or special damages, including any lost profits or lost savings, - * even if a representative of Percepio AB has been advised of the possibility - * of such damages, or for any claim by any third party. Some jurisdictions do - * not allow the exclusion or limitation of incidental, consequential or special - * damages, or the exclusion of implied warranties or limitations on how long an - * implied warranty may last, so the above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2015. - * www.percepio.com - ******************************************************************************/ - -#include -#include -#include - -#include "trcConfig.h" -#include "trcPagedEventBuffer.h" -#include "trcPagedEventBufferConfig.h" -#include "trcKernelPort.h" - -uint32_t DroppedEventCounter = 0; // Total number of dropped events (failed allocations) -uint32_t TotalBytesRemaining_LowWaterMark = TRC_PAGED_EVENT_BUFFER_PAGE_COUNT * TRC_PAGED_EVENT_BUFFER_PAGE_SIZE; - -#if (USE_TRACEALYZER_RECORDER == 1) - -#define PAGE_STATUS_FREE 0 -#define PAGE_STATUS_WRITE 1 -#define PAGE_STATUS_READ 2 - -uint32_t TotalBytesRemaining = TRC_PAGED_EVENT_BUFFER_PAGE_COUNT * TRC_PAGED_EVENT_BUFFER_PAGE_SIZE; - -typedef struct{ - uint8_t Status; - uint16_t BytesRemaining; - char* WritePointer; -} PageType; - -PageType PageInfo[TRC_PAGED_EVENT_BUFFER_PAGE_COUNT]; - -char* EventBuffer = NULL; - -static void prvPageReadComplete(int pageIndex); -static int prvAllocateBufferPage(int prevPage); - -static int prvAllocateBufferPage(int prevPage) -{ - int index; - int count = 0; - - index = (prevPage + 1) % TRC_PAGED_EVENT_BUFFER_PAGE_COUNT; - - while((PageInfo[index].Status != PAGE_STATUS_FREE) && (count ++ < TRC_PAGED_EVENT_BUFFER_PAGE_COUNT)) - { - index = (index + 1) % TRC_PAGED_EVENT_BUFFER_PAGE_COUNT; - } - - if (PageInfo[index].Status == PAGE_STATUS_FREE) - { - return index; - } - - return -1; -} - -static void prvPageReadComplete(int pageIndex) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - PageInfo[pageIndex].BytesRemaining = TRC_PAGED_EVENT_BUFFER_PAGE_SIZE; - PageInfo[pageIndex].WritePointer = &EventBuffer[pageIndex * TRC_PAGED_EVENT_BUFFER_PAGE_SIZE]; - PageInfo[pageIndex].Status = PAGE_STATUS_FREE; - - TotalBytesRemaining += TRC_PAGED_EVENT_BUFFER_PAGE_SIZE; - - TRACE_EXIT_CRITICAL_SECTION(); -} - -static int prvGetBufferPage(int32_t* bytesUsed) -{ - static int8_t lastPage = -1; - int count = 0; - int8_t index = (lastPage + 1) % TRC_PAGED_EVENT_BUFFER_PAGE_COUNT; - - while((PageInfo[index].Status != PAGE_STATUS_READ) && (count++ < TRC_PAGED_EVENT_BUFFER_PAGE_COUNT)) - { - index = (index + 1) % TRC_PAGED_EVENT_BUFFER_PAGE_COUNT; - } - - if (PageInfo[index].Status == PAGE_STATUS_READ) - { - *bytesUsed = TRC_PAGED_EVENT_BUFFER_PAGE_SIZE - PageInfo[index].BytesRemaining; - lastPage = index; - return index; - } - - *bytesUsed = 0; - - return -1; -} - -/******************************************************************************* - -int32_t vPagedEventBufferTransfer(int32_t (*writeFunc)(void* data, - uint32_t size), - int32_t* nofBytes) - -Transfers one block of trace data, if available for reading. Returns the number -of bytes transfered, or a negative error code. If data was transferred (return -value > 0), it can be good to call this function again until all data available -has been transfered. - -This function is intended to be called by a periodic task with a suitable -delay (e.g. 10-100 ms). - -Example: - - TickType_t lastWakeTime = xTaskGetTickCount(); - - while(1) - { - - do{ - // Transfer all available data - status = vPagedEventBufferTransfer(MyWrite, ptrBytes); - }while(status > 0); - - if (status < 0) - { - // A negative return value is an error code... - } - - vTraceDelayUntil(lastWakeTime, 50); // 50 ms -> 20 times/sec - } - -Return value: returnvalue of writeFunc (0 == OK) - -Parameters: - -- writeFunc -Function pointer (example: int32_t write(void* data, uint32_t size)) -The function passed as writeFunc should write "size" bytes from "data" to the -socket/file/channel, and return a status code where 0 means OK, -and any other non-zero value means an error. - -- int32_t* nofBytes -Pointer to an integer assigned the number of bytes that was transfered. - -*******************************************************************************/ - -int32_t vPagedEventBufferTransfer(int32_t (*writeFunc)(void* data, uint32_t size, int32_t* ptrBytesWritten), int32_t* nofBytes) -{ - static int firstTime = 1; - int8_t pageToTransfer = -1; - - pageToTransfer = prvGetBufferPage(nofBytes); - - if (firstTime) - { - firstTime = 0; - } - - if (pageToTransfer > -1) - { - if (writeFunc(&EventBuffer[pageToTransfer * TRC_PAGED_EVENT_BUFFER_PAGE_SIZE], *nofBytes, nofBytes) == 0) - { - prvPageReadComplete(pageToTransfer); - - return 0; - } - else - { - return 1; - } - } - return 0; -} - -/******************************************************************************* - -void* vPagedEventBufferGetWritePointer(int sizeOfEvent) - -Returns a pointer to an available location in the buffer able to store the -requested size. - -Return value: The pointer. - -Parameters: - -- sizeOfEvent -The size of the event that is to be placed in the buffer. - -*******************************************************************************/ -void* vPagedEventBufferGetWritePointer(int sizeOfEvent) -{ - void* ret; - static int currentWritePage = -1; - - if (currentWritePage == -1) - { - currentWritePage = prvAllocateBufferPage(currentWritePage); - if (currentWritePage == -1) - { - DroppedEventCounter++; - return NULL; - } - } - - if (PageInfo[currentWritePage].BytesRemaining - sizeOfEvent < 0) - { - PageInfo[currentWritePage].Status = PAGE_STATUS_READ; - - TotalBytesRemaining -= PageInfo[currentWritePage].BytesRemaining; // Last trailing bytes - - if (TotalBytesRemaining < TotalBytesRemaining_LowWaterMark) - TotalBytesRemaining_LowWaterMark = TotalBytesRemaining; - - currentWritePage = prvAllocateBufferPage(currentWritePage); - if (currentWritePage == -1) - { - DroppedEventCounter++; - return NULL; - } - } - ret = PageInfo[currentWritePage].WritePointer; - PageInfo[currentWritePage].WritePointer += sizeOfEvent; - PageInfo[currentWritePage].BytesRemaining -= sizeOfEvent; - - TotalBytesRemaining -= sizeOfEvent; - - if (TotalBytesRemaining < TotalBytesRemaining_LowWaterMark) - TotalBytesRemaining_LowWaterMark = TotalBytesRemaining; - - return ret; -} - -/******************************************************************************* - -void vPagedEventBufferInit(char* buffer) - -Assigns the buffer to use and initializes the PageInfo structure. - -Return value: void - -Parameters: - -- buffer -Pointer to the buffer location that is dynamically or statically allocated by -the caller. - -*******************************************************************************/ -void vPagedEventBufferInit(char* buffer) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - int i; - - EventBuffer = buffer; - - TRACE_ENTER_CRITICAL_SECTION(); - for (i = 0; i < TRC_PAGED_EVENT_BUFFER_PAGE_COUNT; i++) - { - PageInfo[i].BytesRemaining = TRC_PAGED_EVENT_BUFFER_PAGE_SIZE; - PageInfo[i].WritePointer = &EventBuffer[i * TRC_PAGED_EVENT_BUFFER_PAGE_SIZE]; - PageInfo[i].Status = PAGE_STATUS_FREE; - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -#endif - - - diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcPagedEventBuffer.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcPagedEventBuffer.h deleted file mode 100644 index be4a754e4..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcPagedEventBuffer.h +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v3.0.2 - * Percepio AB, www.percepio.com - * - * trcPagedEventBuffer.h - * - * Implements a paged buffer that can be used by TCP/IP or custom transfer - * methods. - * - * Terms of Use - * This software (the "Tracealyzer Recorder Library") is the intellectual - * property of Percepio AB and may not be sold or in other ways commercially - * redistributed without explicit written permission by Percepio AB. - * - * Separate conditions applies for the SEGGER branded source code included. - * - * The recorder library is free for use together with Percepio products. - * You may distribute the recorder library in its original form, but public - * distribution of modified versions require approval by Percepio AB. - * - * Disclaimer - * The trace tool and recorder library is being delivered to you AS IS and - * Percepio AB makes no warranty as to its use or performance. Percepio AB does - * not and cannot warrant the performance or results you may obtain by using the - * software or documentation. Percepio AB make no warranties, express or - * implied, as to noninfringement of third party rights, merchantability, or - * fitness for any particular purpose. In no event will Percepio AB, its - * technology partners, or distributors be liable to you for any consequential, - * incidental or special damages, including any lost profits or lost savings, - * even if a representative of Percepio AB has been advised of the possibility - * of such damages, or for any claim by any third party. Some jurisdictions do - * not allow the exclusion or limitation of incidental, consequential or special - * damages, or the exclusion of implied warranties or limitations on how long an - * implied warranty may last, so the above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2015. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_PAGED_EVENT_BUFFER_H -#define TRC_PAGED_EVENT_BUFFER_H - -#ifdef __cplusplus -extern “C” { -#endif - -void vPagedEventBufferInit(char* buffer); - -void* vPagedEventBufferGetWritePointer(int sizeOfEvent); - -int32_t vPagedEventBufferTransfer(int32_t (*writeFunc)(void* data, uint32_t size, int32_t* ptrBytesWritten), int32_t* nofBytes); - -void vPagedEventBufferReset(void); - -#ifdef __cplusplus -} -#endif - -#endif /*TRC_PAGED_EVENT_BUFFER_H*/ \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcPagedEventBufferConfig.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcPagedEventBufferConfig.h deleted file mode 100644 index f50652acb..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcPagedEventBufferConfig.h +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v3.0.2 - * Percepio AB, www.percepio.com - * - * trcPagedEventBuffer.h - * - * Configuration for the paged event buffer that can be used by TCP/IP or - * custom transfer methods. - * - * Terms of Use - * This software (the "Tracealyzer Recorder Library") is the intellectual - * property of Percepio AB and may not be sold or in other ways commercially - * redistributed without explicit written permission by Percepio AB. - * - * Separate conditions applies for the SEGGER branded source code included. - * - * The recorder library is free for use together with Percepio products. - * You may distribute the recorder library in its original form, but public - * distribution of modified versions require approval by Percepio AB. - * - * Disclaimer - * The trace tool and recorder library is being delivered to you AS IS and - * Percepio AB makes no warranty as to its use or performance. Percepio AB does - * not and cannot warrant the performance or results you may obtain by using the - * software or documentation. Percepio AB make no warranties, express or - * implied, as to noninfringement of third party rights, merchantability, or - * fitness for any particular purpose. In no event will Percepio AB, its - * technology partners, or distributors be liable to you for any consequential, - * incidental or special damages, including any lost profits or lost savings, - * even if a representative of Percepio AB has been advised of the possibility - * of such damages, or for any claim by any third party. Some jurisdictions do - * not allow the exclusion or limitation of incidental, consequential or special - * damages, or the exclusion of implied warranties or limitations on how long an - * implied warranty may last, so the above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2015. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_PAGED_EVENT_BUFFER_CONFIG_H -#define TRC_PAGED_EVENT_BUFFER_CONFIG_H - -#ifdef __cplusplus -extern “C” { -#endif - -#define TRC_PAGED_EVENT_BUFFER_PAGE_COUNT 5 -#define TRC_PAGED_EVENT_BUFFER_PAGE_SIZE 1440 - -#ifdef __cplusplus -} -#endif - -#endif /*TRC_PAGED_EVENT_BUFFER_CONFIG_H*/ \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcRecorder.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcRecorder.c deleted file mode 100644 index 4768176f8..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcRecorder.c +++ /dev/null @@ -1,1126 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v3.0.2 - * Percepio AB, www.percepio.com - * - * trcRecorder.c - * - * The trace recorder core functions (portable). - * - * Terms of Use - * This software (the "Tracealyzer Recorder Library") is the intellectual - * property of Percepio AB and may not be sold or in other ways commercially - * redistributed without explicit written permission by Percepio AB. - * - * Separate conditions applies for the SEGGER branded source code included. - * - * The recorder library is free for use together with Percepio products. - * You may distribute the recorder library in its original form, but public - * distribution of modified versions require approval by Percepio AB. - * - * Disclaimer - * The trace tool and recorder library is being delivered to you AS IS and - * Percepio AB makes no warranty as to its use or performance. Percepio AB does - * not and cannot warrant the performance or results you may obtain by using the - * software or documentation. Percepio AB make no warranties, express or - * implied, as to noninfringement of third party rights, merchantability, or - * fitness for any particular purpose. In no event will Percepio AB, its - * technology partners, or distributors be liable to you for any consequential, - * incidental or special damages, including any lost profits or lost savings, - * even if a representative of Percepio AB has been advised of the possibility - * of such damages, or for any claim by any third party. Some jurisdictions do - * not allow the exclusion or limitation of incidental, consequential or special - * damages, or the exclusion of implied warranties or limitations on how long an - * implied warranty may last, so the above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2015. - * www.percepio.com - ******************************************************************************/ - -#include -#include - -#include "trcRecorder.h" -#include "trcStreamPort.h" - -#if (USE_TRACEALYZER_RECORDER == 1) - -uint32_t uiTraceTickCount = 0; - -typedef struct{ - int16_t EventID; - uint16_t EventCount; - uint32_t TS; -} BaseEvent; - -typedef struct{ - BaseEvent base; - uint32_t param1; -} EventWithParam_1; - -typedef struct{ - BaseEvent base; - uint32_t param1; - uint32_t param2; -} EventWithParam_2; - -typedef struct{ - BaseEvent base; - uint32_t param1; - uint32_t param2; - uint32_t param3; -} EventWithParam_3; - -/* Used in event functions with variable number of parameters. */ -typedef struct -{ - BaseEvent base; - char data[60]; /* maximum payload size */ -} largestEventType; - -typedef struct{ - uint32_t psf; - uint16_t version; - uint16_t platform; - uint32_t options; - uint16_t symbolSize; - uint16_t symbolCount; - uint16_t objectDataSize; - uint16_t objectDataCount; -} PSFHeaderInfo; - -/* The size of each slot in the Symbol Table */ -#define SYMBOL_TABLE_SLOT_SIZE (sizeof(uint32_t) + (((TRC_SYMBOL_MAX_LENGTH)+(sizeof(uint32_t)-1))/sizeof(uint32_t))*sizeof(uint32_t)) - -#define OBJECT_DATA_SLOT_SIZE (sizeof(uint32_t) + sizeof(uint32_t)) - -/* The total size of the Symbol Table */ -#define SYMBOL_TABLE_BUFFER_SIZE (TRC_SYMBOL_TABLE_SLOTS * SYMBOL_TABLE_SLOT_SIZE) - -/* The total size of the Object Data Table */ -#define OBJECT_DATA_TABLE_BUFFER_SIZE (TRC_OBJECT_DATA_SLOTS * OBJECT_DATA_SLOT_SIZE) - -/* The Symbol Table type - just a byte array */ -typedef struct{ - uint8_t pSymbolTableBuffer[SYMBOL_TABLE_BUFFER_SIZE]; -} SymbolTable; - -/* The Object Data Table type - just a byte array */ -typedef struct{ - uint8_t pObjectDataTableBuffer[OBJECT_DATA_TABLE_BUFFER_SIZE]; -} ObjectDataTable; - -/* The Symbol Table instance - keeps names of tasks and other named objects. */ -static SymbolTable symbolTable = { { 0 } }; - -/* The Object Data Table instance - keeps initial priorities of tasks. */ -static ObjectDataTable objectDataTable = { { 0 } }; - -/* Code used for "task address" when no task has started. (NULL = idle task) */ -#define HANDLE_NO_TASK 2 - -/* The maximum number of nested ISRs */ -#define MAX_ISR_NESTING 8 - -/* Keeps track of ISR nesting */ -static uint32_t ISR_stack[MAX_ISR_NESTING]; - -/* Keeps track of ISR nesting */ -static int8_t ISR_stack_index = -1; - -/* Any error that occured in the recorder (also creates User Event) */ -static int errorCode = 0; - -/* The user event channel for recorder warnings, defined in trcKernelPort.c */ -extern char* trcWarningChannel; - -/* Performs timestamping using definitions in trcHardwarePort.h */ -static uint32_t prvGetTimestamp32(void); - -/* Counts the number of trace sessions (not yet used) */ -static uint32_t SessionCounter = 0; - -/* Master switch for recording (0 => Disabled, 1 => Enabled) */ -static uint32_t RecorderEnabled = 0; - -/* Used to determine endian of data (big/little) */ -static uint32_t PSFEndianessIdentifier = 0x50534600; - -/* Used to interpret the data format */ -static uint16_t FormatVersion = 0x0002; - -/* The number of events stored. Used as event sequence number. */ -static uint32_t eventCounter = 0; - -/* Keeps track of if the current ISR chain has triggered a context switch that will be performed once all ISRs have returned. */ -int32_t isPendingContextSwitch = 0; - -/******************************************************************************* - * NoRoomForSymbol - * - * Incremented on vTraceSaveSymbol if no room for saving the symbol name. This - * is used for storing the names of: - * - Tasks - * - Named ISRs (vTraceSetISRProperties) - * - Named kernel objects (vTraceStoreKernelObjectName) - * - User event channels (vTraceStoreUserEventChannelName) - * - * This variable should be zero. If not, it shows the number of missing slots so - * far. In that case, increment SYMBOL_TABLE_SLOTS with (at least) this value. - ******************************************************************************/ -volatile uint32_t NoRoomForSymbol = 0; - -/******************************************************************************* - * NoRoomForObjectData - * - * Incremented on vTraceSaveObjectData if no room for saving the object data, - * i.e., the base priorities of tasks. There must be one slot for each task. - * If not, this variable will show the difference. - * - * This variable should be zero. If not, it shows the number of missing slots so - * far. In that case, increment OBJECT_DATA_SLOTS with (at least) this value. - ******************************************************************************/ -volatile uint32_t NoRoomForObjectData = 0; - -/******************************************************************************* - * LongestSymbolName - * - * Updated in vTraceSaveSymbol. Should not exceed SYMBOL_MAX_LENGTH, otherwise - * symbol names will be truncated. In that case, set SYMBOL_MAX_LENGTH to (at - * least) this value. - ******************************************************************************/ -volatile uint32_t LongestSymbolName = 0; - -/******************************************************************************* - * MaxBytesTruncated - * - * Set in prvTraceStoreStringEvent if the total data payload exceeds 60 bytes, - * including data arguments and the string. For user events, that is 52 bytes - * for string and data arguments. In that is exceeded, the event is truncated - * (usually only the string, unless more than 15 parameters) and this variable - * holds the maximum number of truncated bytes, from any event. - ******************************************************************************/ -volatile uint32_t MaxBytesTruncated = 0; - -/* Internal common function for storing string events */ -static void prvTraceStoreStringEvent( int nArgs, - uint16_t eventID, - const char* userEvtChannel, - const char* str, - va_list vl); - -/* Stores the header information on Start */ -static void vTraceStoreHeader(void); - -/* Stores the symbol table on Start */ -static void vTraceStoreSymbolTable(void); - -/* Stores the object table on Start */ -static void vTraceStoreObjectDataTable(void); - -/* Store the Timestamp Config on Start */ -static void vTraceStoreTSConfig(void); - -/* Internal function for starting/stopping the recorder. */ -static void intSetRecorderEnabled(int isEnabled); - -/* Command codes for TzCtrl task (sent on Start/Stop). */ -#define CMD_SET_ACTIVE 1 - -/* The final command code, used to validate commands. Only one command yet. */ -#define CMD_LAST_COMMAND 1 - -/* Part of the PSF format - encodes the number of 32-bit params in an event */ -#define PARAM_COUNT(n) ((n & 0xF) << 12) - -/* Temporary fix since embOS sources aren't yet updated to contain them */ -#ifndef OS_TRACE_ID_IFE -#define OS_TRACE_ID_IFE (4000u) -#endif - -#ifndef OS_TRACE_ID_IFE_NEXT -#define OS_TRACE_ID_IFE_NEXT (4001u) -#endif - -/****************************************************************************** - * vTraceInstanceFinishNow - * - * Creates an event that ends the current task instance at this very instant. - * This makes the viewer to splits the current fragment at this point and begin - * a new actor instance, even if no task-switch has occurred. - *****************************************************************************/ -void vTraceInstanceFinishedNow(void) -{ - vTraceStoreEvent0(PSF_EVENT_IFE_DIRECT); -} - -/****************************************************************************** - * vTraceInstanceFinishedNext - * - * Marks the current "task instance" as finished on the next kernel call. - * - * If that kernel call is blocking, the instance ends after the blocking event - * and the corresponding return event is then the start of the next instance. - * If the kernel call is not blocking, the viewer instead splits the current - * fragment right before the kernel call, which makes this call the first event - * of the next instance. - *****************************************************************************/ -void vTraceInstanceFinishedNext(void) -{ - vTraceStoreEvent0(PSF_EVENT_IFE_NEXT); -} - -/******************************************************************************* - * vTraceStoreUserEventChannelName - * - * Stores a name for a user event channel, returns the handle (just a pointer - * to the const char*. - * The returned channel handle - ******************************************************************************/ -char* vTraceStoreUserEventChannelName(const char* name) -{ - vTraceSaveSymbol((void*)name, name); - - /* Always save in symbol table, if the recording has not yet started */ - vTraceStoreStringEvent(1, PSF_EVENT_OBJ_NAME, name, (uint32_t)name); - - return (char*)name; -} - -/******************************************************************************* - * vTraceStoreKernelObjectName - * - * Stores a name for kernel objects (Semaphore, Mailbox, etc.). - ******************************************************************************/ -void vTraceStoreKernelObjectName(void* object, const char* name) -{ - vTraceSaveSymbol(object, name); - - /* Always save in symbol table, if the recording has not yet started */ - vTraceStoreStringEvent(1, PSF_EVENT_OBJ_NAME, name, (uint32_t)object); -} - -/****************************************************************************** - * vTracePrint - * - * Generates "User Events", with unformatted text. - * - * User Events can be used for very efficient application logging, and are shown - * as yellow labels in the main trace view. - * - * You may group User Events into User Event Channels. The yellow User Event - * labels shows the logged string, preceeded by the channel name within - * brackets. For example: - * - * "[MyChannel] Hello World!" - * - * The User Event Channels are shown in the View Filter, which makes it easy to - * select what User Events you wish to display. User Event Channels are created - * using vTraceStoreUserEventChannelName(). - * - * Example: - * - * char* error_uechannel = vTraceStoreUserEventChannelName("Errors"); - * ... - * vTracePrint(error_uechannel, "Shouldn't reach this code!"); - * - ******************************************************************************/ -void vTracePrint(const char* chn, const char* str) -{ - va_list vl = { 0 }; - - if (chn != NULL) - { - prvTraceStoreStringEvent(0, PSF_EVENT_USER_EVENT + 1, chn, str, vl); - } - else - { - prvTraceStoreStringEvent(0, PSF_EVENT_USER_EVENT, chn, str, vl); - } -} - -/****************************************************************************** - * vTracePrintF - * - * Generates "User Events", with formatted text and data, similar to a "printf". - * It is very fast since the actual formatting is done on the host side when the - * trace is displayed. - * - * User Events can be used for very efficient application logging, and are shown - * as yellow labels in the main trace view. - * An advantage of User Events is that data can be plotted in the "User Event - * Signal Plot" view, visualizing any data you log as User Events, discrete - * states or control system signals (e.g. system inputs or outputs). - * - * You may group User Events into User Event Channels. The yellow User Event - * labels show the logged string, preceeded by the channel name within brackets. - * - * Example: - * - * "[MyChannel] Hello World!" - * - * The User Event Channels are shown in the View Filter, which makes it easy to - * select what User Events you wish to display. User Event Channels are created - * using vTraceStoreUserEventChannelName(). - * - * Example: - * - * char* adc_uechannel = vTraceStoreUserEventChannelName("ADC User Events"); - * ... - * vTracePrint(adc_uechannel, - * "ADC channel %d: %lf volts", - * ch, (double)adc_reading/(double)scale); - * - * All data arguments are assumed to be 32 bt wide. The following formats are - * supported in v2.8: - * %d - signed integer. The following width and padding format is supported: "%05d" -> "-0042" and "%5d" -> " -42" - * %u - unsigned integer. The following width and padding format is supported: "%05u" -> "00042" and "%5u" -> " 42" - * %X - hexadecimal (uppercase). The following width and padding format is supported: "%04X" -> "002A" and "%4X" -> " 2A" - * %x - hexadecimal (lowercase). The following width and padding format is supported: "%04x" -> "002a" and "%4x" -> " 2a" - * %s - string (currently, this must be an earlier stored symbol name) - * - * Up to 15 data arguments are allowed, with a total size of maximum 60 byte - * including 8 byte for the base event fields and the format string. So with - * one data argument, the maximum string length is 48 chars. If this is exceeded - * the string is truncated (4 bytes at a time). - * - ******************************************************************************/ -void vTracePrintF(const char* chn, const char* fmt, ...) -{ - int i = 0; - va_list vl; - - int nArgs = 0; - - int len = 0; - for (len = 0; fmt[len] != 0; len++) - { - // Empty - } - if (len > 52) - len = 52; - - while (i < len) - { - if (fmt[i] == '%') - { - if (fmt[i+1] != '%') - nArgs++; /* Found an argument */ - - i++; /* Move past format specifier or non-argument '%' */ - } - - i++; - } - - va_start(vl, fmt); - if (chn != NULL) - { - prvTraceStoreStringEvent(nArgs, PSF_EVENT_USER_EVENT + nArgs + 1, chn, fmt, vl); - } - else - { - prvTraceStoreStringEvent(nArgs, PSF_EVENT_USER_EVENT + nArgs, chn, fmt, vl); - } - va_end(vl); -} - -/******************************************************************************* - * vTraceSetISRProperties - * - * Stores a name and priority level for an Interrupt Service Routine, to allow - * for better visualization. The string address is used as a unique handle. - * - * Example: - * #define PRIO_ISR_TIMER1 3 // the hardware priority of the interrupt - * ... - * vTraceSetISRProperties("ISRTimer1", PRIO_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin("ISRTimer1"); - * ... - * vTraceStoreISREnd(0); - * } - * - ******************************************************************************/ -void vTraceSetISRProperties(const char* name, char priority) -{ - /* Save object data in object data table */ - vTraceSaveObjectData((void*)name, priority); - - /* Note: "name" is used both as a string argument, and the address as ID */ - vTraceStoreStringEvent(2, PSF_EVENT_DEFINE_ISR, name, name, priority); - - /* Always save in symbol table, if the recording has not yet started */ - vTraceSaveSymbol((void*)name, name); -} - -/******************************************************************************* - * vTraceStoreISRBegin - * - * Registers the beginning of an Interrupt Service Routine. - * - * Example: - * #define PRIO_ISR_TIMER1 3 // the hardware priority of the interrupt - * ... - * vTraceSetISRProperties("ISRTimer1", PRIO_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin("ISRTimer1"); - * ... - * vTraceStoreISREnd(0); - * } - * - ******************************************************************************/ -void vTraceStoreISRBegin(void* handle) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (ISR_stack_index == -1) - isPendingContextSwitch = 0; /* We are at the start of a possible ISR chain. No context switches should have been triggered now. */ - - if (ISR_stack_index < MAX_ISR_NESTING - 1) - { - ISR_stack_index++; - ISR_stack[ISR_stack_index] = (uint32_t)handle; - vTraceStoreEvent1(PSF_EVENT_ISR_BEGIN, (uint32_t)handle); - TRACE_EXIT_CRITICAL_SECTION(); - } - else - { - TRACE_EXIT_CRITICAL_SECTION(); - psfError(PSF_ERROR_ISR_NESTING_OVERFLOW); - } -} - -/******************************************************************************* - * vTraceStoreISREnd - * - * Registers the end of an Interrupt Service Routine. - * - * This function will automatically detect if a task switch will take place - * when interrupt ends. If this is possible depends on the kernel port. - * - * Example: - * #define PRIO_ISR_TIMER1 3 // the hardware priority of the interrupt - * ... - * vTraceSetISRProperties("ISRTimer1", PRIO_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin("ISRTimer1"); - * ... - * vTraceStoreISREnd(); - * } - * - ******************************************************************************/ -void vTraceStoreISREnd() -{ - vTraceStoreISREndManual(OS_IS_SWITCH_FROM_INT_REQUIRED()); -} - -/******************************************************************************* - * vTraceStoreISREndManual - * - * Registers the end of an Interrupt Service Routine. - * - * The parameter taskSwitchRequested indicates if the interrupt has requested a - * task-switch (= 1) or if the interrupt returns to the earlier context (= 0) - * - * Example: - * #define PRIO_ISR_TIMER1 3 // the hardware priority of the interrupt - * ... - * vTraceSetISRProperties("ISRTimer1", PRIO_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin("ISRTimer1"); - * ... - * vTraceStoreISREndManual(0); - * } - * - ******************************************************************************/ -void vTraceStoreISREndManual(int isTaskSwitchRequired) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - - isPendingContextSwitch |= isTaskSwitchRequired; /* Is there a pending context switch right now? */ - if (ISR_stack_index > 0) - { - ISR_stack_index--; - - /* Store return to interrupted ISR (if nested ISRs)*/ - vTraceStoreEvent1(PSF_EVENT_ISR_RESUME, (uint32_t)ISR_stack[ISR_stack_index]); - } - else - { - ISR_stack_index--; - - /* Store return to interrupted task, if a task switch has not been triggered by any interrupt */ - if (isPendingContextSwitch == 0) - { - vTraceStoreEvent1(PSF_EVENT_TS_RESUME, (uint32_t)TRACE_GET_CURRENT_TASK()); - } - } - - TRACE_EXIT_CRITICAL_SECTION(); -} - - -/******************************************************************************/ -/*** INTERNAL FUNCTIONS *******************************************************/ -/******************************************************************************/ - -/* Internal function for starting/stopping the recorder. */ -static void intSetRecorderEnabled(int isEnabled) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - void* currentTask = TRACE_GET_CURRENT_TASK(); - - TRACE_ENTER_CRITICAL_SECTION(); - - RecorderEnabled = isEnabled; - - if (currentTask == NULL) - { - currentTask = (void*)HANDLE_NO_TASK; - } - - if (RecorderEnabled) - { - vTraceOnTraceBegin(); - - eventCounter = 0; - ISR_stack_index = -1; - vTraceStoreHeader(); - vTraceStoreSymbolTable(); - vTraceStoreObjectDataTable(); - vTraceStoreEvent3( PSF_EVENT_TRACE_START, - (uint32_t)TRACE_GET_OS_TICKS(), - (uint32_t)currentTask, - SessionCounter++); - vTraceStoreTSConfig(); - } - else - { - vTraceOnTraceEnd(); - } - - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Stores the symbol table on Start */ -static void vTraceStoreSymbolTable() -{ - uint32_t i = 0; - uint32_t j = 0; - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - for (i = 0; i < sizeof(SymbolTable); i += SYMBOL_TABLE_SLOT_SIZE) - { - TRC_STREAM_PORT_ALLOCATE_EVENT(uint8_t, data, SYMBOL_TABLE_SLOT_SIZE); - for (j = 0; j < SYMBOL_TABLE_SLOT_SIZE; j++) - { - data[j] = symbolTable.pSymbolTableBuffer[i+j]; - } - TRC_STREAM_PORT_COMMIT_EVENT(data, SYMBOL_TABLE_SLOT_SIZE); - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Stores the object table on Start */ -static void vTraceStoreObjectDataTable() -{ - uint32_t i = 0; - uint32_t j = 0; - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - for (i = 0; i < sizeof(ObjectDataTable); i += OBJECT_DATA_SLOT_SIZE) - { - TRC_STREAM_PORT_ALLOCATE_EVENT(uint8_t, data, OBJECT_DATA_SLOT_SIZE); - for (j = 0; j < OBJECT_DATA_SLOT_SIZE; j++) - { - data[j] = objectDataTable.pObjectDataTableBuffer[i+j]; - } - TRC_STREAM_PORT_COMMIT_EVENT(data, OBJECT_DATA_SLOT_SIZE); - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Stores the header information on Start */ -static void vTraceStoreHeader() -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - TRC_STREAM_PORT_ALLOCATE_EVENT(PSFHeaderInfo, header, sizeof(PSFHeaderInfo)); - if (header != NULL) - { - header->psf = PSFEndianessIdentifier; - header->version = FormatVersion; - header->platform = KERNEL_ID; - header->options = 0; - /* Lowest bit used for IRQ_PRIORITY_ORDER */ - header->options = header->options | (IRQ_PRIORITY_ORDER << 0); - header->symbolSize = SYMBOL_TABLE_SLOT_SIZE; - header->symbolCount = TRC_SYMBOL_TABLE_SLOTS; - header->objectDataSize = 8; - header->objectDataCount = TRC_OBJECT_DATA_SLOTS; - TRC_STREAM_PORT_COMMIT_EVENT(header, sizeof(PSFHeaderInfo)); - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Store an event with zero parameters (event ID only) */ -void vTraceStoreEvent0(uint16_t eventID) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - PSF_ASSERT(eventID < 4096, PSF_ERROR_EVENT_CODE_TOO_LARGE); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - eventCounter++; - - TRC_STREAM_PORT_ALLOCATE_EVENT(BaseEvent, event, sizeof(BaseEvent)); - if (event != NULL) - { - event->EventID = eventID | PARAM_COUNT(0); - event->EventCount = eventCounter; - event->TS = prvGetTimestamp32(); - TRC_STREAM_PORT_COMMIT_EVENT(event, sizeof(BaseEvent)); - } - - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Store an event with one 32-bit parameter (pointer address or an int) */ -void vTraceStoreEvent1(uint16_t eventID, uint32_t param1) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - PSF_ASSERT(eventID < 4096, PSF_ERROR_EVENT_CODE_TOO_LARGE); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - eventCounter++; - TRC_STREAM_PORT_ALLOCATE_EVENT(EventWithParam_1, event, sizeof(EventWithParam_1)); - if (event != NULL) - { - event->base.EventID = eventID | PARAM_COUNT(1); - event->base.EventCount = eventCounter; - event->base.TS = prvGetTimestamp32(); - event->param1 = (uint32_t)param1; - TRC_STREAM_PORT_COMMIT_EVENT(event, sizeof(EventWithParam_1)); - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Store an event with two 32-bit parameters */ -void vTraceStoreEvent2(uint16_t eventID, uint32_t param1, uint32_t param2) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - PSF_ASSERT(eventID < 4096, PSF_ERROR_EVENT_CODE_TOO_LARGE); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - eventCounter++; - - TRC_STREAM_PORT_ALLOCATE_EVENT(EventWithParam_2, event, sizeof(EventWithParam_2)); - if (event != NULL) - { - event->base.EventID = eventID | PARAM_COUNT(2); - event->base.EventCount = eventCounter; - event->base.TS = prvGetTimestamp32(); - event->param1 = (uint32_t)param1; - event->param2 = param2; - TRC_STREAM_PORT_COMMIT_EVENT(event, sizeof(EventWithParam_2)); - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Store an event with three 32-bit parameters */ -void vTraceStoreEvent3( uint16_t eventID, - uint32_t param1, - uint32_t param2, - uint32_t param3) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - - PSF_ASSERT(eventID < 4096, PSF_ERROR_EVENT_CODE_TOO_LARGE); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - eventCounter++; - - TRC_STREAM_PORT_ALLOCATE_EVENT(EventWithParam_3, event, sizeof(EventWithParam_3)); - if (event != NULL) - { - event->base.EventID = eventID | PARAM_COUNT(3); - event->base.EventCount = eventCounter; - event->base.TS = prvGetTimestamp32(); - event->param1 = (uint32_t)param1; - event->param2 = param2; - event->param3 = param3; - TRC_STREAM_PORT_COMMIT_EVENT(event, sizeof(EventWithParam_3)); - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Stores an event with 32-bit integer parameters */ -void vTraceStoreEvent(int nParam, uint16_t eventID, ...) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - va_list vl; - int i; - - PSF_ASSERT(eventID < 4096, PSF_ERROR_EVENT_CODE_TOO_LARGE); - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - int eventSize = sizeof(BaseEvent) + nParam * sizeof(uint32_t); - - eventCounter++; - - TRC_STREAM_PORT_ALLOCATE_EVENT(largestEventType, event, eventSize); - if (event != NULL) - { - event->base.EventID = eventID | PARAM_COUNT(nParam); - event->base.EventCount = eventCounter; - event->base.TS = prvGetTimestamp32(); - - va_start(vl, eventID); - for (i = 0; i < nParam; i++) - { - uint32_t* tmp = (uint32_t*) &(event->data[i * 4]); - *tmp = va_arg(vl, uint32_t); - } - va_end(vl); - - TRC_STREAM_PORT_COMMIT_EVENT(event, eventSize); - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Stories an event with a string and 32-bit integer parameters */ -void vTraceStoreStringEvent(int nArgs, uint16_t eventID, const char* str, ...) -{ - va_list vl; - - va_start(vl, str); - prvTraceStoreStringEvent(nArgs, eventID, NULL, str, vl); - va_end(vl); -} - -/* Internal common function for storing string events */ -static void prvTraceStoreStringEvent( int nArgs, - uint16_t eventID, - const char* userEvtChannel, - const char* str, va_list vl) -{ - TRACE_ALLOC_CRITICAL_SECTION(); - int len; - int nParam; - int strParam; - int i; - - PSF_ASSERT(eventID < 4096, PSF_ERROR_EVENT_CODE_TOO_LARGE); - - len = 0; - for (len = 0; str[len] != 0; len++) - { - // Empty - } - - /* The string length in multiples of 32 bit words (+1 for null character) */ - strParam = (len+1+3)/4; - - /* If a user event channel is specified, add in the list */ - if (userEvtChannel) nArgs++; - - /* The total number of 32-bit words needed for the whole payload */ - nParam = strParam + nArgs; - - if (nParam > 15) /* if attempting to store more than 60 byte (= max) */ - { - /* Truncate event if too large. The string characters are stored - last, so usually only the string is truncated, unless there a lot - of parameters... */ - - /* Diagnostics ... */ - uint32_t bytesTrucated = (nParam - 15) * 4; - - if (bytesTrucated > MaxBytesTruncated) - { - MaxBytesTruncated = bytesTrucated; - } - - nParam = 15; - } - - TRACE_ENTER_CRITICAL_SECTION(); - - if (RecorderEnabled) - { - int eventSize = sizeof(BaseEvent) + nParam * sizeof(uint32_t); - - eventCounter++; - - TRC_STREAM_PORT_ALLOCATE_EVENT(largestEventType, event, eventSize); - if (event != NULL) - { - event->base.EventID = (eventID) | PARAM_COUNT(nParam); - event->base.EventCount = eventCounter; - event->base.TS = prvGetTimestamp32(); - - /* 32-bit write-pointer for the data argument */ - uint32_t* data32 = (uint32_t*) &(event->data[0]); - - for (i = 0; i < nArgs; i++) - { - if ((userEvtChannel != NULL) && (i == 0)) - { - /* First, add the User Event Channel if not NULL */ - data32[i] = (uint32_t)userEvtChannel; - } - else - { - /* Add data arguments... */ - data32[i] = va_arg(vl, uint32_t); - } - } - - for (i = 0; i < len; i++) - { - event->data[nArgs * 4 + i] = str[i]; - } - - event->data[nArgs * 4 + len] = 0; - TRC_STREAM_PORT_COMMIT_EVENT(event, eventSize); - } - } - TRACE_EXIT_CRITICAL_SECTION(); -} - -/* Saves a symbol name (task name etc.) in symbol table */ -void vTraceSaveSymbol(void *address, const char *name) -{ - uint32_t i = 0; - uint32_t foundSlot = SYMBOL_TABLE_BUFFER_SIZE; - void *ptr; - - for (i = 0; i < SYMBOL_TABLE_BUFFER_SIZE; i += SYMBOL_TABLE_SLOT_SIZE) - { - ptr = *((void**)&symbolTable.pSymbolTableBuffer[i]); - if (ptr == 0 && foundSlot == SYMBOL_TABLE_BUFFER_SIZE) - { - foundSlot = i; - } - else if (ptr == address) - { - foundSlot = i; - break; - } - } - - if (foundSlot != SYMBOL_TABLE_BUFFER_SIZE) - { - *((uint32_t*)&symbolTable.pSymbolTableBuffer[foundSlot]) = - (uint32_t)address; - - for (i = 0; i < TRC_SYMBOL_MAX_LENGTH; i++) - { - if (name[i] == 0) - break; - - symbolTable.pSymbolTableBuffer[foundSlot + sizeof(uint32_t) + i] = - name[i]; - } - - /* Check the length of "name", if longer than SYMBOL_MAX_LENGTH */ - while ((name[i] != 0) && i < 128) - { - i++; - } - - /* Remember the longest symbol name, for diagnostic purposes */ - if (i > LongestSymbolName) - { - LongestSymbolName = i; - } - } - else - { - NoRoomForSymbol++; - } -} - -/* Deletes a symbol name (task name etc.) from symbol table */ -void vTraceDeleteSymbol(void *address) -{ - uint32_t i = 0; - void **ptr; - - for (i = 0; i < SYMBOL_TABLE_BUFFER_SIZE; i += SYMBOL_TABLE_SLOT_SIZE) - { - ptr = ((void**)&symbolTable.pSymbolTableBuffer[i]); - if (*ptr == address) - { - *ptr = 0; - break; - } - } -} - -/* Saves an object data entry (task base priority) in object data table */ -void vTraceSaveObjectData(void *address, uint32_t data) -{ - uint32_t i = 0; - uint32_t foundSlot = OBJECT_DATA_TABLE_BUFFER_SIZE; - void *ptr; - - for (i = 0; i < OBJECT_DATA_TABLE_BUFFER_SIZE; i += OBJECT_DATA_SLOT_SIZE) - { - ptr = *((void**)&objectDataTable.pObjectDataTableBuffer[i]); - if (ptr == 0 && foundSlot == OBJECT_DATA_TABLE_BUFFER_SIZE) - { - foundSlot = i; - } - else if (ptr == address) - { - foundSlot = i; - break; - } - } - - if (foundSlot != OBJECT_DATA_TABLE_BUFFER_SIZE) - { - *(uint32_t*)&objectDataTable.pObjectDataTableBuffer[foundSlot] = (uint32_t)address; - *(uint32_t*)&objectDataTable.pObjectDataTableBuffer[foundSlot + sizeof(uint32_t)] = data; - } - else - { - NoRoomForObjectData++; - } -} - -/* Removes an object data entry (task base priority) from object data table */ -void vTraceDeleteObjectData(void *address) -{ - uint32_t i = 0; - void **ptr; - - for (i = 0; i < OBJECT_DATA_TABLE_BUFFER_SIZE; i += OBJECT_DATA_SLOT_SIZE) - { - ptr = (void**)&objectDataTable.pObjectDataTableBuffer[i]; - if (*ptr == address) - { - *ptr = 0; - break; - } - } -} - -/* Checks if the provided command is a valid command */ -int isValidCommand(TracealyzerCommandType* cmd) -{ - uint16_t checksum = (uint16_t)(0xFFFF - ( cmd->cmdCode + - cmd->param1 + - cmd->param2 + - cmd->param3 + - cmd->param4 + - cmd->param5)); - - if (cmd->checksumMSB != (unsigned char)(checksum >> 8)) - return 0; - - if (cmd->checksumLSB != (unsigned char)(checksum & 0xFF)) - return 0; - - if (cmd->cmdCode > CMD_LAST_COMMAND) - return 0; - - return 1; -} - -/* Executed the received command (Start or Stop) */ -void processCommand(TracealyzerCommandType* cmd) -{ - switch(cmd->cmdCode) - { - case CMD_SET_ACTIVE: - intSetRecorderEnabled(cmd->param1); - break; - - default: - break; - } -} - -/* Called on critical errors in the recorder. Stops the recorder! */ -void psfError(int errCode) -{ - if (! errorCode) - { - errorCode = errCode; - vTracePrintF(trcWarningChannel, "Error %d. Stopped recorder.", errorCode); - - intSetRecorderEnabled(0); - } -} - -/* Performs timestamping using definitions in trcHardwarePort.h */ -static uint32_t prvGetTimestamp32(void) -{ - int ticks = TRACE_GET_OS_TICKS(); - return (HWTC_COUNT & 0x00FFFFFF) + ((ticks & 0x000000FF) << 24); -} - -/* Store the Timestamp Config event */ -static void vTraceStoreTSConfig(void) -{ - vTraceStoreEvent3( PSF_EVENT_TS_CONFIG, - (uint32_t)TRACE_CPU_CLOCK_HZ, - (uint32_t)TRACE_TICK_RATE_HZ, - (int32_t)HWTC_TYPE); -} - -#endif diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcRecorder.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcRecorder.h deleted file mode 100644 index 3cec07be0..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcRecorder.h +++ /dev/null @@ -1,363 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v3.0.2 - * Percepio AB, www.percepio.com - * - * trcRecorder.c - * - * Public interface and configurations for the trace recorder library. - * - * Terms of Use - * This software (the "Tracealyzer Recorder Library") is the intellectual - * property of Percepio AB and may not be sold or in other ways commercially - * redistributed without explicit written permission by Percepio AB. - * - * Separate conditions applies for the SEGGER branded source code included. - * - * The recorder library is free for use together with Percepio products. - * You may distribute the recorder library in its original form, but public - * distribution of modified versions require approval by Percepio AB. - * - * Disclaimer - * The trace tool and recorder library is being delivered to you AS IS and - * Percepio AB makes no warranty as to its use or performance. Percepio AB does - * not and cannot warrant the performance or results you may obtain by using the - * software or documentation. Percepio AB make no warranties, express or - * implied, as to noninfringement of third party rights, merchantability, or - * fitness for any particular purpose. In no event will Percepio AB, its - * technology partners, or distributors be liable to you for any consequential, - * incidental or special damages, including any lost profits or lost savings, - * even if a representative of Percepio AB has been advised of the possibility - * of such damages, or for any claim by any third party. Some jurisdictions do - * not allow the exclusion or limitation of incidental, consequential or special - * damages, or the exclusion of implied warranties or limitations on how long an - * implied warranty may last, so the above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2015. - * www.percepio.com - ******************************************************************************/ - -#ifndef _TRC_RECORDER_H -#define _TRC_RECORDER_H - -#ifdef __cplusplus -extern “C” { -#endif - -#include "trcConfig.h" -#include "trcKernelPort.h" -#include "trcHardwarePort.h" - -#if (USE_TRACEALYZER_RECORDER == 1) - -/*** User API *****************************************************************/ - -/****************************************************************************** - * vTracePrint - * - * Generates "User Events", with unformatted text. - * - * User Events can be used for very efficient application logging, and are shown - * as yellow labels in the main trace view. - * - * You may group User Events into User Event Channels. The yellow User Event - * labels shows the logged string, preceeded by the channel name within - * brackets. For example: - * - * "[MyChannel] Hello World!" - * - * The User Event Channels are shown in the View Filter, which makes it easy to - * select what User Events you wish to display. User Event Channels are created - * using vTraceStoreUserEventChannelName(). - * - * Example: - * - * char* error_uechannel = vTraceStoreUserEventChannelName("Errors"); - * ... - * vTracePrint(error_uechannel, "Shouldn't reach this code!"); - * - ******************************************************************************/ -void vTracePrint(const char* chn, const char* str); - -/****************************************************************************** - * vTracePrintF - * - * Generates "User Events", with formatted text and data, similar to a "printf". - * It is very fast since the actual formatting is done on the host side when the - * trace is displayed. - * - * User Events can be used for very efficient application logging, and are shown - * as yellow labels in the main trace view. - * An advantage of User Events is that data can be plotted in the "User Event - * Signal Plot" view, visualizing any data you log as User Events, discrete - * states or control system signals (e.g. system inputs or outputs). - * - * You may group User Events into User Event Channels. The yellow User Event - * labels show the logged string, preceeded by the channel name within brackets. - * - * Example: - * - * "[MyChannel] Hello World!" - * - * The User Event Channels are shown in the View Filter, which makes it easy to - * select what User Events you wish to display. User Event Channels are created - * using vTraceStoreUserEventChannelName(). - * - * Example: - * - * char* adc_uechannel = vTraceStoreUserEventChannelName("ADC User Events"); - * ... - * vTracePrint(adc_uechannel, - * "ADC channel %d: %lf volts", - * ch, (double)adc_reading/(double)scale); - * - * All data arguments are assumed to be 32 bt wide. The following formats are - * supported in v2.8: - * %d - signed integer - * %u - unsigned integer - * %X - hexadecimal (uppercase) - * %x - hexadecimal (lowercase) - * %s - string (currently, this must be an earlier stored symbol name) - * - * Up to 15 data arguments are allowed, with a total size of maximum 60 byte - * including 8 byte for the base event fields and the format string. So with - * one data argument, the maximum string length is 48 chars. If this is exceeded - * the string is truncated (4 bytes at a time). - * - ******************************************************************************/ -void vTracePrintF(const char* chn, const char* fmt, ...); - -/******************************************************************************* - * vTraceStoreUserEventChannelName(const char* name) - * - * Parameter name: the channel name to store (const string literal) - * - * Stores a name for a user event channel, returns the handle (just a pointer - * to the provided string). Typically assigned to a "channel" variable that - * keeps it for later calls to vTracePrintF(); - ******************************************************************************/ -char* vTraceStoreUserEventChannelName(const char* name); - -/******************************************************************************* - * vTraceStoreKernelObjectName(void* object, const char* name) - * - * Parameter object: pointer to the kernel object that shall be named - * Parameter name: the name to store (const string literal) - * - * Stores a name for kernel objects (Semaphore, Mailbox, etc.). - ******************************************************************************/ -void vTraceStoreKernelObjectName(void* object, const char* name); - -/******************************************************************************* - * vTraceSetISRProperties(const char* name, char priority) - * - * Parameter name: the name to give the the ISR, also serves as handle. - * Parameter priority: the priority level of the ISR. - * - * Stores a name and priority level for an Interrupt Service Routine, to allow - * for better visualization. The string address is used as a unique handle. - * - * Example: - * - * vTraceSetISRProperties("ISRTimer1", ISRPriorityTimer1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin("ISRTimer1"); - * ... - * vTraceStoreISREnd(0); - * } - ******************************************************************************/ -void vTraceSetISRProperties(const char* name, char priority); - -/******************************************************************************* - * vTraceStoreISRBegin(void* handle); - * - * Parameter handle: ID of the ISR, which is "name" in vTraceSetISRProperties - * - * Registers the beginning of an Interrupt Service Routine (ISR), i.e., or an - * exception handler. - * - * Example: - * - * vTraceSetISRProperties("ISRTimer1", ISRPriorityTimer1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin("ISRTimer1"); - * ... - * vTraceStoreISREnd(0); - * } - ******************************************************************************/ -void vTraceStoreISRBegin(void* handle); - -/******************************************************************************* - * vTraceStoreISREnd - * - * Registers the end of an Interrupt Service Routine. - * - * This function attempts to automatically detect if a task switch will take - * place when interrupt ends. If this is possible depends on the kernel port. - * - * Example: - * #define PRIO_ISR_TIMER1 3 // the hardware priority of the interrupt - * ... - * vTraceSetISRProperties("ISRTimer1", PRIO_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin("ISRTimer1"); - * ... - * vTraceStoreISREnd(); - * } - * - ******************************************************************************/ -void vTraceStoreISREnd(void); - -/******************************************************************************* - * vTraceStoreISREndManual - * - * Registers the end of an Interrupt Service Routine. - * - * The parameter isTaskSwitchRequired indicates if the interrupt has requested a - * task-switch (= 1) or if the interrupt returns to the earlier context (= 0) - * - * Example: - * #define PRIO_ISR_TIMER1 3 // the hardware priority of the interrupt - * ... - * vTraceSetISRProperties("ISRTimer1", PRIO_ISR_TIMER1); - * ... - * void ISR_handler() - * { - * vTraceStoreISRBegin("ISRTimer1"); - * ... - * vTraceStoreISREndManual(0); - * } - * - ******************************************************************************/ -void vTraceStoreISREndManual(int isTaskSwitchRequired); - -/******************************************************************************* - * vTraceInstanceFinishNow - * - * Creates an event that ends the current task instance at this very instant. - * This makes the viewer to splits the current fragment at this point and begin - * a new actor instance, even if no task-switch has occurred. - *****************************************************************************/ -void vTraceInstanceFinishedNow(void); - -/******************************************************************************* - * vTraceInstanceFinishedNext - * - * Marks the current "task instance" as finished on the next kernel call. - * - * If that kernel call is blocking, the instance ends after the blocking event - * and the corresponding return event is then the start of the next instance. - * If the kernel call is not blocking, the viewer instead splits the current - * fragment right before the kernel call, which makes this call the first event - * of the next instance. - *****************************************************************************/ -void vTraceInstanceFinishedNext(void); - - -/******************************************************************************/ -/*** INTERNAL FUNCTIONS *******************************************************/ -/******************************************************************************/ - -/* Saves a symbol name (task name etc.) in symbol table */ -void vTraceSaveSymbol(void *address, const char *name); - -/* Deletes a symbol name (task name etc.) from symbol table */ -void vTraceDeleteSymbol(void *address); - -/* Saves an object data entry (task base priority) in object data table */ -void vTraceSaveObjectData(void *address, uint32_t data); - -/* Removes an object data entry (task base priority) from object data table */ -void vTraceDeleteObjectData(void *address); - -/* Store an event with zero parameters (event ID only) */ -void vTraceStoreEvent0(uint16_t eventID); - -/* Store an event with one 32-bit parameter (pointer address or an int) */ -void vTraceStoreEvent1(uint16_t eventID, uint32_t param1); - -/* Store an event with two 32-bit parameters */ -void vTraceStoreEvent2(uint16_t eventID, uint32_t param1, uint32_t param2); - -/* Store an event with three 32-bit parameters */ -void vTraceStoreEvent3( uint16_t eventID, - uint32_t param1, - uint32_t param2, - uint32_t param3); - -/* Stores an event with 32-bit integer parameters */ -void vTraceStoreEvent(int nParam, uint16_t EventID, ...); - -/* Stories an event with a string and 32-bit integer parameters */ -void vTraceStoreStringEvent(int nArgs, uint16_t eventID, const char* str, ...); - -/* The data structure for commands (a bit overkill) */ -typedef struct -{ - unsigned char cmdCode; - unsigned char param1; - unsigned char param2; - unsigned char param3; - unsigned char param4; - unsigned char param5; - unsigned char checksumLSB; - unsigned char checksumMSB; -} TracealyzerCommandType; - -/* Checks if the provided command is a valid command */ -int isValidCommand(TracealyzerCommandType* cmd); - -/* Executed the received command (Start or Stop) */ -void processCommand(TracealyzerCommandType* cmd); - -/* Backwards compatibility macros with old recorder */ -#define vTraceInitTraceData() Trace_Init() -#define uiTraceStart() (1) -#define vTraceStart() -#define vTraceStop() - -#else /*(USE_TRACEALYZER_RECORDER == 1)*/ - -#define vTraceStoreEvent0(e) -#define vTraceStoreEvent1(e, param1) -#define vTraceStoreEvent2(e, param1, param2) -#define vTraceStoreEvent3(e, param1, param2, param3) -#define vTraceStoreUserEventChannelName(x) 0 -#define vTracePrint(chn, ...) -#define vTracePrintF(chn, ...) -#define vTraceInstanceFinishedNow() -#define vTraceInstanceFinishedNext() -#define vTraceStoreISRBegin(x) -#define vTraceStoreISREnd() -#define vTraceStoreISREndManual(x) -#define vTraceSetISRProperties(a, b) -#define vTraceStoreKernelObjectName(a, b) - -/* Backwards compatibility macros with old recorder */ -#define vTraceInitTraceData() -#define uiTraceStart() (1) -#define vTraceStart() -#define vTraceStop() - -#endif /*(USE_TRACEALYZER_RECORDER == 1)*/ - -extern void psfError(int errCode); - -#define PSF_ASSERT(_assert, _err) if (! (_assert)){ psfError(_err); return; } - -#define PSF_ERROR_NONE 0 -#define PSF_ERROR_EVENT_CODE_TOO_LARGE 1 -#define PSF_ERROR_ISR_NESTING_OVERFLOW 2 - -#ifdef __cplusplus -} -#endif - -#endif /* _TRC_RECORDER_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcStreamPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcStreamPort.h deleted file mode 100644 index fd6d2e9bf..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcStreamPort.h +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v3.0.2 - * Percepio AB, www.percepio.com - * - * trcStreamPort.h - * - * This file defines the trace streaming interface used by the - * Trace Recorder Library. It comes preconfigured for use with SEGGER's RTT and - * a TCP/IP (needs additional configuration in trcTCPIPConfig.h). - * - * Terms of Use - * This software (the "Tracealyzer Recorder Library") is the intellectual - * property of Percepio AB and may not be sold or in other ways commercially - * redistributed without explicit written permission by Percepio AB. - * - * Separate conditions applies for the SEGGER branded source code included. - * - * The recorder library is free for use together with Percepio products. - * You may distribute the recorder library in its original form, but public - * distribution of modified versions require approval by Percepio AB. - * - * Disclaimer - * The trace tool and recorder library is being delivered to you AS IS and - * Percepio AB makes no warranty as to its use or performance. Percepio AB does - * not and cannot warrant the performance or results you may obtain by using the - * software or documentation. Percepio AB make no warranties, express or - * implied, as to noninfringement of third party rights, merchantability, or - * fitness for any particular purpose. In no event will Percepio AB, its - * technology partners, or distributors be liable to you for any consequential, - * incidental or special damages, including any lost profits or lost savings, - * even if a representative of Percepio AB has been advised of the possibility - * of such damages, or for any claim by any third party. Some jurisdictions do - * not allow the exclusion or limitation of incidental, consequential or special - * damages, or the exclusion of implied warranties or limitations on how long an - * implied warranty may last, so the above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2015. - * www.percepio.com - ******************************************************************************/ - -#ifndef _TRC_STREAM_PORT_H -#define _TRC_STREAM_PORT_H - -#ifdef __cplusplus -extern “C” { -#endif - -#if (USE_TRACEALYZER_RECORDER == 1) - -#define TRC_RECORDER_TRANSFER_METHOD_JLINK_RTT_BLOCK (0x01) -#define TRC_RECORDER_TRANSFER_METHOD_JLINK_RTT_NOBLOCK (0x02) -#define TRC_RECORDER_TRANSFER_METHOD_TCPIP (0x03) -#define TRC_RECORDER_TRANSFER_METHOD_CUSTOM (0xFF) - -#define TRC_RECORDER_BUFFER_ALLOCATION_STATIC (0x00) -#define TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC (0x01) - -/******************************************************************************* - * TRC_RECORDER_TRANSFER_METHOD_JLINK_RTT_BLOCK / NOBLOCK - ******************************************************************************/ -#if TRC_RECORDER_TRANSFER_METHOD == TRC_RECORDER_TRANSFER_METHOD_JLINK_RTT_BLOCK || TRC_RECORDER_TRANSFER_METHOD == TRC_RECORDER_TRANSFER_METHOD_JLINK_RTT_NOBLOCK - -#if TRC_RECORDER_TRANSFER_METHOD == TRC_RECORDER_TRANSFER_METHOD_JLINK_RTT_BLOCK -#define TRC_STREAM_PORT_BLOCKING_TRANSFER 1 -#define RTT_MODE SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL -#else -#define TRC_STREAM_PORT_BLOCKING_TRANSFER 0 -#define RTT_MODE SEGGER_RTT_MODE_NO_BLOCK_SKIP -#endif - -#include "SEGGER_RTT_Conf.h" -#include "SEGGER_RTT.h" - -/* Up-buffer. If index is defined as 0, the internal RTT buffers will be used instead of this. */ \ -#if TRC_RTT_UP_BUFFER_INDEX == 0 -#define TRC_RTT_ALLOC_UP() static char* _TzTraceData = NULL; /* Not actually used. Ignore allocation method. */ -#define TRC_STREAM_PORT_MALLOC() /* Static allocation. Not used. */ -#else -#if TRC_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_STATIC -#define TRC_RTT_ALLOC_UP() static char _TzTraceData[BUFFER_SIZE_UP]; /* Static allocation */ -#define TRC_STREAM_PORT_MALLOC() /* Static allocation. Not used. */ -#else -#define TRC_RTT_ALLOC_UP() static char* _TzTraceData = NULL; /* Dynamic allocation */ -#define TRC_STREAM_PORT_MALLOC() _TzTraceData = TRC_PORT_MALLOC(BUFFER_SIZE_UP); -#endif -#endif - -/* Down-buffer. If index is defined as 0, the internal RTT buffers will be used instead of this. */ \ -#if TRC_RTT_DOWN_BUFFER_INDEX == 0 -#define TRC_RTT_ALLOC_DOWN() static char* _TzCtrlData = NULL; /* Not actually used. Ignore allocation method. */ -#else -#define TRC_RTT_ALLOC_DOWN() static char _TzCtrlData[BUFFER_SIZE_DOWN]; /* This buffer should be ~32bytes. Ignore allocation method. */ -#endif - -#define TRC_STREAM_PORT_ALLOCATE_FIELDS() \ - TRC_RTT_ALLOC_UP() /* Macro that will result in proper UP buffer allocation */ \ - TRC_RTT_ALLOC_DOWN() /* Macro that will result in proper DOWN buffer allocation */ - -#define TRC_STREAM_PORT_INIT() \ - TRC_STREAM_PORT_MALLOC(); /*Dynamic allocation or empty if static */ \ - SEGGER_RTT_ConfigUpBuffer(TRC_RTT_UP_BUFFER_INDEX, "TzData", _TzTraceData, sizeof(_TzTraceData), RTT_MODE ); \ - SEGGER_RTT_ConfigDownBuffer(TRC_RTT_DOWN_BUFFER_INDEX, "TzCtrl", _TzCtrlData, sizeof(_TzCtrlData), 0); - -#define TRC_STREAM_PORT_ALLOCATE_EVENT(_type, _ptrData, _size) uint8_t tmpEvt[_size]; _type* _ptrData = (_type*)tmpEvt; -#define TRC_STREAM_PORT_COMMIT_EVENT(_ptrData, _size) SEGGER_RTT_Write(TRC_RTT_UP_BUFFER_INDEX, (const char*)_ptrData, _size); -#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) *_ptrBytesRead = SEGGER_RTT_Read(TRC_RTT_DOWN_BUFFER_INDEX, (char*)_ptrData, _size); -#define TRC_STREAM_PORT_PERIODIC_SEND_DATA(_ptrBytesSent) - -#define TRC_STREAM_PORT_ON_TRACE_BEGIN() /* Do nothing */ -#define TRC_STREAM_PORT_ON_TRACE_END() /* Do nothing */ - -#endif /*TRC_RECORDER_TRANSFER_METHOD == TRC_RECORDER_TRANSFER_METHOD_JLINK_RTT_BLOCK || TRC_RECORDER_TRANSFER_METHOD == TRC_RECORDER_TRANSFER_METHOD_JLINK_RTT_NOBLOCK*/ - -/******************************************************************************* - * TRC_RECORDER_TRANSFER_METHOD_TCPIP - * - * This TCP/IP implementation is using a secondary buffer consisting of multiple - * pages to avoid the endless recursive calls that occurr when "socket_send" - * uses kernel objects such as mutexes and semaphores, which in turn needs to be - * traced. To use your own TCP/IP stack, modify the functions declared in - * trcTCPIPConfig.h. - ******************************************************************************/ -#if TRC_RECORDER_TRANSFER_METHOD == TRC_RECORDER_TRANSFER_METHOD_TCPIP - -#include "trcTCPIP.h" -#include "trcPagedEventBuffer.h" -#include "trcPagedEventBufferConfig.h" -#define TRC_STREAM_PORT_BLOCKING_TRANSFER 0 - -#if TRC_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_STATIC -#define TRC_STREAM_PORT_ALLOCATE_FIELDS() static char _TzTraceData[TRC_PAGED_EVENT_BUFFER_PAGE_COUNT * TRC_PAGED_EVENT_BUFFER_PAGE_SIZE]; /* Static allocation. */ -#define TRC_STREAM_PORT_MALLOC() /* Static allocation. Not used. */ -#else -#define TRC_STREAM_PORT_ALLOCATE_FIELDS() static char* _TzTraceData = NULL; /* Dynamic allocation. */ -#define TRC_STREAM_PORT_MALLOC() _TzTraceData = TRC_PORT_MALLOC(TRC_PAGED_EVENT_BUFFER_PAGE_COUNT * TRC_PAGED_EVENT_BUFFER_PAGE_SIZE); -#endif - -#define TRC_STREAM_PORT_INIT() \ - TRC_STREAM_PORT_MALLOC(); /*Dynamic allocation or empty if static */ \ - vPagedEventBufferInit(_TzTraceData); - -#define TRC_STREAM_PORT_ALLOCATE_EVENT(_type, _ptrData, _size) _type* _ptrData; _ptrData = (_type*)vPagedEventBufferGetWritePointer(_size); -#define TRC_STREAM_PORT_COMMIT_EVENT(_ptrData, _size) /* Not needed since we write immediately into the buffer received above by TRC_STREAM_PORT_ALLOCATE_EVENT, and the TRC_STREAM_PORT_PERIODIC_SEND_DATA defined below will take care of the actual trace transfer. */ -#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) trcTcpRead(_ptrData, _size, _ptrBytesRead); -#define TRC_STREAM_PORT_PERIODIC_SEND_DATA(_ptrBytesSent) vPagedEventBufferTransfer(trcTcpWrite, _ptrBytesSent); - -#define TRC_STREAM_PORT_ON_TRACE_BEGIN() vPagedEventBufferInit(_TzTraceData); -#define TRC_STREAM_PORT_ON_TRACE_END() /* Do nothing */ - -#endif /*TRC_RECORDER_TRANSFER_METHOD == TRC_RECORDER_TRANSFER_METHOD_TCPIP*/ - -/******************************************************************************* - * TRC_RECORDER_TRANSFER_METHOD_CUSTOM - * - * Implement the following macros in trcConfig.h. If your transfer method uses - * kernel objects when sending data you will need to use a secondary buffer to - * store the trace data before sending it. For this reason we provide - * trcPagedEventBuffer. Look at the TCP/IP macros above to see how to use it. - ******************************************************************************/ -#if TRC_RECORDER_TRANSFER_METHOD == TRC_RECORDER_TRANSFER_METHOD_CUSTOM - -/* When using the custom transfer method, define TRC_STREAM_CUSTOM_XXXXXXXXXXXXX in trcConfig.h */ -#define TRC_STREAM_PORT_BLOCKING_TRANSFER TRC_STREAM_CUSTOM_BLOCKING_TRANSFER -#define TRC_STREAM_PORT_ALLOCATE_FIELDS() TRC_STREAM_CUSTOM_ALLOCATE_FIELDS() -#define TRC_STREAM_PORT_INIT() TRC_STREAM_CUSTOM_INIT() -#define TRC_STREAM_PORT_ALLOCATE_EVENT(_type, _ptr, _size) TRC_STREAM_CUSTOM_ALLOCATE_EVENT(_type, _ptr, _size) -#define TRC_STREAM_PORT_COMMIT_EVENT(_ptr, _size) TRC_STREAM_CUSTOM_COMMIT_EVENT(_ptr, _size) -#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) TRC_STREAM_CUSTOM_READ_DATA(_ptrData, _size, _ptrBytesRead) -#define TRC_STREAM_PORT_PERIODIC_SEND_DATA(_ptrBytesSent) TRC_STREAM_CUSTOM_PERIODIC_SEND_DATA(_ptrBytesSent) -#define TRC_STREAM_PORT_ON_TRACE_BEGIN() TRC_STREAM_CUSTOM_ON_TRACE_BEGIN() -#define TRC_STREAM_PORT_ON_TRACE_END() TRC_STREAM_CUSTOM_ON_TRACE_END() - -#endif /*TRC_RECORDER_TRANSFER_METHOD == TRC_RECORDER_TRANSFER_METHOD_CUSTOM*/ - -#ifndef TRC_STREAM_PORT_ALLOCATE_FIELDS -#error "Selected TRC_RECORDER_TRANSFER_METHOD does not define TRC_STREAM_PORT_ALLOCATE_FIELDS!" -#endif - -#ifndef TRC_STREAM_PORT_ALLOCATE_EVENT -#error "Selected TRC_RECORDER_TRANSFER_METHOD does not define TRC_STREAM_PORT_ALLOCATE_EVENT!" -#endif - -#ifndef TRC_STREAM_PORT_COMMIT_EVENT -#error "Selected TRC_RECORDER_TRANSFER_METHOD does not define TRC_STREAM_PORT_COMMIT_EVENT!" -#endif - -#ifndef TRC_STREAM_PORT_INIT -#error "Selected TRC_RECORDER_TRANSFER_METHOD does not define TRC_STREAM_PORT_INIT!" -#endif - -#ifndef TRC_STREAM_PORT_BLOCKING_TRANSFER -#error "Selected TRC_RECORDER_TRANSFER_METHOD does not define TRC_STREAM_PORT_BLOCKING_TRANSFER!" -#endif - -#ifndef TRC_STREAM_PORT_READ_DATA -#error "Selected TRC_RECORDER_TRANSFER_METHOD does not define TRC_STREAM_PORT_READ_DATA!" -#endif - -#ifndef TRC_STREAM_PORT_PERIODIC_SEND_DATA -#error "Selected TRC_RECORDER_TRANSFER_METHOD does not define TRC_STREAM_PORT_PERIODIC_SEND_DATA!" -#endif - -#ifndef TRC_STREAM_PORT_ON_TRACE_BEGIN -#error "Selected TRC_RECORDER_TRANSFER_METHOD does not define TRC_STREAM_PORT_ON_TRACE_BEGIN!" -#endif - -#ifndef TRC_STREAM_PORT_ON_TRACE_END -#error "Selected TRC_RECORDER_TRANSFER_METHOD does not define TRC_STREAM_PORT_ON_TRACE_END!" -#endif - -#endif /*(USE_TRACEALYZER_RECORDER == 1)*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _TRC_STREAM_PORT_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcTCPIP.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcTCPIP.c deleted file mode 100644 index 0f782be2b..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcTCPIP.c +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v3.0.2 - * Percepio AB, www.percepio.com - * - * trcTCPIP.c - * - * Simple generic TCP/IP layer. Modify trcTCPIPConfig.h to adapt it to any - * custom stack. - * - * Terms of Use - * This software (the "Tracealyzer Recorder Library") is the intellectual - * property of Percepio AB and may not be sold or in other ways commercially - * redistributed without explicit written permission by Percepio AB. - * - * Separate conditions applies for the SEGGER branded source code included. - * - * The recorder library is free for use together with Percepio products. - * You may distribute the recorder library in its original form, but public - * distribution of modified versions require approval by Percepio AB. - * - * Disclaimer - * The trace tool and recorder library is being delivered to you AS IS and - * Percepio AB makes no warranty as to its use or performance. Percepio AB does - * not and cannot warrant the performance or results you may obtain by using the - * software or documentation. Percepio AB make no warranties, express or - * implied, as to noninfringement of third party rights, merchantability, or - * fitness for any particular purpose. In no event will Percepio AB, its - * technology partners, or distributors be liable to you for any consequential, - * incidental or special damages, including any lost profits or lost savings, - * even if a representative of Percepio AB has been advised of the possibility - * of such damages, or for any claim by any third party. Some jurisdictions do - * not allow the exclusion or limitation of incidental, consequential or special - * damages, or the exclusion of implied warranties or limitations on how long an - * implied warranty may last, so the above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2015. - * www.percepio.com - ******************************************************************************/ - -#include -#include "trcTCPIP.h" -#include "trcTCPIPConfig.h" - -int32_t trcTcpWrite(void* data, uint32_t size, int32_t *ptrBytesWritten) -{ - return trcSocketSend(data, size, ptrBytesWritten); -} - -int32_t trcTcpRead(void* data, uint32_t size, int32_t *ptrBytesRead) -{ - trcSocketInitializeListener(); - - trcSocketAccept(); - - return trcSocketReceive(data, size, ptrBytesRead); -} diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcTCPIP.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcTCPIP.h deleted file mode 100644 index fa9a777fc..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcTCPIP.h +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v3.0.2 - * Percepio AB, www.percepio.com - * - * trcTCPIP.h - * - * Simple generic TCP/IP layer. Modify trcTCPIPConfig.h to adapt it to any - * custom stack. - * - * Terms of Use - * This software (the "Tracealyzer Recorder Library") is the intellectual - * property of Percepio AB and may not be sold or in other ways commercially - * redistributed without explicit written permission by Percepio AB. - * - * Separate conditions applies for the SEGGER branded source code included. - * - * The recorder library is free for use together with Percepio products. - * You may distribute the recorder library in its original form, but public - * distribution of modified versions require approval by Percepio AB. - * - * Disclaimer - * The trace tool and recorder library is being delivered to you AS IS and - * Percepio AB makes no warranty as to its use or performance. Percepio AB does - * not and cannot warrant the performance or results you may obtain by using the - * software or documentation. Percepio AB make no warranties, express or - * implied, as to noninfringement of third party rights, merchantability, or - * fitness for any particular purpose. In no event will Percepio AB, its - * technology partners, or distributors be liable to you for any consequential, - * incidental or special damages, including any lost profits or lost savings, - * even if a representative of Percepio AB has been advised of the possibility - * of such damages, or for any claim by any third party. Some jurisdictions do - * not allow the exclusion or limitation of incidental, consequential or special - * damages, or the exclusion of implied warranties or limitations on how long an - * implied warranty may last, so the above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2015. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_TCPIP_H -#define TRC_TCPIP_H - -#ifdef __cplusplus -extern “C” { -#endif - -int32_t trcTcpWrite(void* data, uint32_t size, int32_t *ptrBytesWritten); -int32_t trcTcpRead(void* data, uint32_t size, int32_t *ptrBytesRead); - -#ifdef __cplusplus -} -#endif - -#endif /*TRC_TCPIP_H*/ \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcTCPIPConfig.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcTCPIPConfig.h deleted file mode 100644 index be0b5534f..000000000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcTCPIPConfig.h +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Trace Recorder Library for Tracealyzer v3.0.2 - * Percepio AB, www.percepio.com - * - * trcTCPIPConfig.h - * - * Trace TCP/IP configuration. Modify these includes and functions to perform - * the same functionality using your specific TCP/IP stack. - * Will only be included by trcTCPIP.c. - * - * Terms of Use - * This software (the "Tracealyzer Recorder Library") is the intellectual - * property of Percepio AB and may not be sold or in other ways commercially - * redistributed without explicit written permission by Percepio AB. - * - * Separate conditions applies for the SEGGER branded source code included. - * - * The recorder library is free for use together with Percepio products. - * You may distribute the recorder library in its original form, but public - * distribution of modified versions require approval by Percepio AB. - * - * Disclaimer - * The trace tool and recorder library is being delivered to you AS IS and - * Percepio AB makes no warranty as to its use or performance. Percepio AB does - * not and cannot warrant the performance or results you may obtain by using the - * software or documentation. Percepio AB make no warranties, express or - * implied, as to noninfringement of third party rights, merchantability, or - * fitness for any particular purpose. In no event will Percepio AB, its - * technology partners, or distributors be liable to you for any consequential, - * incidental or special damages, including any lost profits or lost savings, - * even if a representative of Percepio AB has been advised of the possibility - * of such damages, or for any claim by any third party. Some jurisdictions do - * not allow the exclusion or limitation of incidental, consequential or special - * damages, or the exclusion of implied warranties or limitations on how long an - * implied warranty may last, so the above limitations may not apply to you. - * - * Tabs are used for indent in this file (1 tab = 4 spaces) - * - * Copyright Percepio AB, 2015. - * www.percepio.com - ******************************************************************************/ - -#ifndef TRC_TCPIP_CONFIG_H -#define TRC_TCPIP_CONFIG_H - -#ifdef __cplusplus -extern “C” { -#endif - -/* TCP/IP includes*/ -#include "tcpip.h" - -#define TRC_TCPIP_PORT 12000 - -socket* sock = NULL; -socket* listenerSocket = NULL; - -int32_t trcSocketSend(void* data, int32_t size, int32_t* bytesWritten) -{ - int32_t error; - if (sock == NULL) - return 1; - - error = socket_send(sock, data, size, (size_t*)bytesWritten, 0); - if (error) - { - socket_close(sock); - sock = NULL; - } - - return (int32_t)error; -} - -int32_t trcSocketReceive(void* data, int32_t size, int32_t* bytesRead) -{ - int32_t error; - if (sock == NULL) - return 1; - - error = socket_receive(sock, data, size, (size_t*)bytesRead, SOCKET_WAIT_ALL); - if (error != ERROR_NONE && error != ERROR_TIMEOUT) /* Timeout may be expected when there is no data */ - { - socket_close(sock); - sock = NULL; - return error; - } - - return 0; -} - -int32_t trcSocketInitializeListener() -{ - int32_t error; - - if (listenerSocket) - return 0; - - //Start of exception handling block - do - { - listenerSocket = socket_open(SOCKET_STREAM, SOCKET_TCP); - if(listenerSocket == NULL) - { - error = 1; - break; - } - - error = socket_set_timeout(listenerSocket, INFINITE); - if(error) break; - - error = socket_set_tx_buffer_size(listenerSocket, 1440 * 2); - if(error) break; - - error = socket_set_rx_buffer_size(listenerSocket, 128); - if(error) break; - - error = socket_bind_to_interface(listenerSocket, pNetInterface); - if(error) break; - - error = socket_bind(listenerSocket, ADDR_ANY, TRC_TCPIP_PORT); - if(error) break; - - error = socket_listen(listenerSocket); - if(error) break; - } while(0); - - if(error) - { - socket_close(listenerSocket); - listenerSocket = NULL; - } - - return error; -} - -int32_t trcSocketAccept() -{ - ip_addr clientIpAddr; - uint16_t clientPort; - - if (sock != NULL) - return 0; - - if (listenerSocket == NULL) - return 1; - - /* Wait for connection */ - sock = socket_accept(listenerSocket, &clientIpAddr, &clientPort); - if(sock != NULL) - { - socket_set_timeout(sock, 20); - } - else - return 1; - - return 0; -} - -#ifdef __cplusplus -} -#endif - -#endif /*TRC_TCPIP_CONFIG_H*/ \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h index 233b243c7..3458b0a8b 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h @@ -778,7 +778,7 @@ extern void vTraceStoreMemMangEvent(uint32_t ecode, uint32_t address, int32_t si #define traceMALLOC( pvAddress, uiSize ) {if (pvAddress != 0) vTraceStoreMemMangEvent(MEM_MALLOC_SIZE, ( uint32_t ) pvAddress, (int32_t)uiSize); } #undef traceFREE -#define traceFREE( pvAddress, uiSize ) {vTraceStoreMemMangEvent(MEM_FREE_SIZE, ( uint32_t ) pvAddress, (int32_t)(-uiSize)); } +#define traceFREE( pvAddress, uiSize ) {vTraceStoreMemMangEvent(MEM_FREE_SIZE, ( uint32_t ) pvAddress, -((int32_t)uiSize)); } #endif /* (TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_MEMMANG_EVENTS == 1) */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c index 2be923ef3..6da362010 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c @@ -1868,8 +1868,8 @@ static uint32_t prvTraceGetParam(uint32_t param_max, uint32_t param) if (xps != NULL) { xps->type = DIV_XPS; - xps->xps_8 = (uint8_t)(param & (0xFF00 & ~param_max)) >> 8; - xps->xps_16 = (uint16_t)(param & (0xFFFF0000 & ~param_max)) >> 16; + xps->xps_8 = (uint8_t)((param & (0xFF00 & ~param_max)) >> 8); + xps->xps_16 = (uint16_t)((param & (0xFFFF0000 & ~param_max)) >> 16); prvTraceUpdateCounters(); }