[修改] 增加freeRTOS
1. 版本FreeRTOSv202212.01,命名为kernel;
This commit is contained in:
129
kernel/FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h
Normal file
129
kernel/FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* FreeRTOS V202212.01
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. See
|
||||
* https://www.FreeRTOS.org/a00110.html
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||
#define configUSE_IDLE_HOOK 1
|
||||
#define configUSE_TICK_HOOK 1
|
||||
#define configUSE_DAEMON_TASK_STARTUP_HOOK 1
|
||||
#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 49 * 1024 ) ) /* This demo tests heap_5 so places multiple blocks within this total heap size. See mainREGION_1_SIZE to mainREGION_3_SIZE definitions in main.c. */
|
||||
#define configMAX_TASK_NAME_LEN ( 12 )
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 0
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configQUEUE_REGISTRY_SIZE 20
|
||||
#define configUSE_MALLOC_FAILED_HOOK 1
|
||||
#define configUSE_APPLICATION_TASK_TAG 1
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configUSE_ALTERNATIVE_API 0
|
||||
#define configUSE_QUEUE_SETS 1
|
||||
#define configUSE_TASK_NOTIFICATIONS 1
|
||||
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 5
|
||||
#define configSUPPORT_STATIC_ALLOCATION 1
|
||||
#define configINITIAL_TICK_COUNT ( ( TickType_t ) 0 ) /* For test. */
|
||||
#define configSTREAM_BUFFER_TRIGGER_LEVEL_TEST_MARGIN 1 /* As there are a lot of tasks running. */
|
||||
|
||||
/* Software timer related configuration options. */
|
||||
#define configUSE_TIMERS 1
|
||||
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
|
||||
#define configTIMER_QUEUE_LENGTH 20
|
||||
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
|
||||
|
||||
#define configMAX_PRIORITIES ( 7 )
|
||||
|
||||
/* Run time stats gathering configuration options. */
|
||||
#define configRUN_TIME_COUNTER_TYPE uint64_t
|
||||
configRUN_TIME_COUNTER_TYPE ulGetRunTimeCounterValue( void ); /* Prototype of function that returns run time counter. */
|
||||
void vConfigureTimerForRunTimeStats( void ); /* Prototype of function that initialises the run time counter. */
|
||||
#define configGENERATE_RUN_TIME_STATS 1
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()
|
||||
|
||||
/* This demo makes use of one or more example stats formatting functions. These
|
||||
format the raw data provided by the uxTaskGetSystemState() function in to human
|
||||
readable ASCII form. See the notes in the implementation of vTaskList() within
|
||||
FreeRTOS/Source/tasks.c for limitations. */
|
||||
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
|
||||
|
||||
/* Set the following definitions to 1 to include the API function, or zero
|
||||
to exclude the API function. In most cases the linker will remove unused
|
||||
functions anyway. */
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskCleanUpResources 0
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||
#define INCLUDE_xTaskGetSchedulerState 1
|
||||
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1
|
||||
#define INCLUDE_xTaskGetIdleTaskHandle 1
|
||||
#define INCLUDE_xTaskGetHandle 1
|
||||
#define INCLUDE_eTaskGetState 1
|
||||
#define INCLUDE_xSemaphoreGetMutexHolder 1
|
||||
#define INCLUDE_xTimerPendFunctionCall 1
|
||||
#define INCLUDE_xTaskAbortDelay 1
|
||||
|
||||
/* The Win32 target is capable of running all the tests tasks at the same
|
||||
* time. */
|
||||
#define configRUN_ADDITIONAL_TESTS 1
|
||||
|
||||
/* It is a good idea to define configASSERT() while developing. configASSERT()
|
||||
uses the same semantics as the standard C assert() macro. */
|
||||
extern void vAssertCalled( unsigned long ulLine, const char * const pcFileName );
|
||||
#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __LINE__, __FILE__ )
|
||||
|
||||
#define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 0
|
||||
#if ( configINCLUDE_MESSAGE_BUFFER_AMP_DEMO == 1 )
|
||||
extern void vGenerateCoreBInterrupt( void * xUpdatedMessageBuffer );
|
||||
#define sbSEND_COMPLETED( pxStreamBuffer ) vGenerateCoreBInterrupt( pxStreamBuffer )
|
||||
#endif /* configINCLUDE_MESSAGE_BUFFER_AMP_DEMO */
|
||||
|
||||
/* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */
|
||||
#include "trcRecorder.h"
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
98
kernel/FreeRTOS/Demo/WIN32-MSVC/Run-time-stats-utils.c
Normal file
98
kernel/FreeRTOS/Demo/WIN32-MSVC/Run-time-stats-utils.c
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* FreeRTOS V202212.01
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Utility functions required to gather run time statistics. See:
|
||||
* https://www.FreeRTOS.org/rtos-run-time-stats.html
|
||||
*
|
||||
* Note that this is a simulated port, where simulated time is a lot slower than
|
||||
* real time, therefore the run time counter values have no real meaningful
|
||||
* units.
|
||||
*
|
||||
* Also note that it is assumed this demo is going to be used for short periods
|
||||
* of time only, and therefore timer overflows are not handled.
|
||||
*/
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include <FreeRTOS.h>
|
||||
|
||||
/* Variables used in the creation of the run time stats time base. Run time
|
||||
stats record how much time each task spends in the Running state. */
|
||||
static long long llInitialRunTimeCounterValue = 0LL, llTicksPerHundedthMillisecond = 0LL;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vConfigureTimerForRunTimeStats( void )
|
||||
{
|
||||
LARGE_INTEGER liPerformanceCounterFrequency, liInitialRunTimeValue;
|
||||
|
||||
/* Initialise the variables used to create the run time stats time base.
|
||||
Run time stats record how much time each task spends in the Running
|
||||
state. */
|
||||
|
||||
if( QueryPerformanceFrequency( &liPerformanceCounterFrequency ) == 0 )
|
||||
{
|
||||
llTicksPerHundedthMillisecond = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* How many times does the performance counter increment in 1/100th
|
||||
millisecond. */
|
||||
llTicksPerHundedthMillisecond = liPerformanceCounterFrequency.QuadPart / 100000LL;
|
||||
|
||||
/* What is the performance counter value now, this will be subtracted
|
||||
from readings taken at run time. */
|
||||
QueryPerformanceCounter( &liInitialRunTimeValue );
|
||||
llInitialRunTimeCounterValue = liInitialRunTimeValue.QuadPart;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
configRUN_TIME_COUNTER_TYPE ulGetRunTimeCounterValue( void )
|
||||
{
|
||||
LARGE_INTEGER liCurrentCount;
|
||||
configRUN_TIME_COUNTER_TYPE ulReturn;
|
||||
|
||||
/* What is the performance counter value now? */
|
||||
QueryPerformanceCounter( &liCurrentCount );
|
||||
|
||||
/* Subtract the performance counter value reading taken when the
|
||||
application started to get a count from that reference point, then
|
||||
scale to (simulated) 1/100ths of a millisecond. */
|
||||
if( llTicksPerHundedthMillisecond == 0 )
|
||||
{
|
||||
/* The trace macros are probably calling this function before the
|
||||
scheduler has been started. */
|
||||
ulReturn = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ulReturn = ( configRUN_TIME_COUNTER_TYPE ) ( ( liCurrentCount.QuadPart - llInitialRunTimeCounterValue ) / llTicksPerHundedthMillisecond );
|
||||
}
|
||||
|
||||
return ulReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
@ -0,0 +1,319 @@
|
||||
/*
|
||||
* Trace Recorder for Tracealyzer v4.6.0
|
||||
* Copyright 2021 Percepio AB
|
||||
* www.percepio.com
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Main configuration parameters for the trace recorder library.
|
||||
* More settings can be found in trcStreamingConfig.h and trcSnapshotConfig.h.
|
||||
*/
|
||||
|
||||
#ifndef TRC_CONFIG_H
|
||||
#define TRC_CONFIG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Include of processor header file
|
||||
*
|
||||
* Here you may need to include the header file for your processor. This is
|
||||
* required at least for the ARM Cortex-M port, that uses the ARM CMSIS API.
|
||||
* Try that in case of build problems. Otherwise, remove the #error line below.
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_HARDWARE_PORT
|
||||
* @brief Specify what hardware port to use (i.e., the "timestamping driver").
|
||||
*
|
||||
* All ARM Cortex-M MCUs are supported by "TRC_HARDWARE_PORT_ARM_Cortex_M".
|
||||
* This port uses the DWT cycle counter for Cortex-M3/M4/M7 devices, which is
|
||||
* available on most such devices. In case your device don't have DWT support,
|
||||
* you will get an error message opening the trace. In that case, you may
|
||||
* force the recorder to use SysTick timestamping instead, using this define:
|
||||
*
|
||||
* #define TRC_CFG_ARM_CM_USE_SYSTICK
|
||||
*
|
||||
* For ARM Cortex-M0/M0+ devices, SysTick mode is used automatically.
|
||||
*
|
||||
* See trcHardwarePort.h for available ports and information on how to
|
||||
* define your own port, if not already present.
|
||||
*/
|
||||
#define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_Win32
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_SCHEDULING_ONLY
|
||||
* @brief Macro which should be defined as an integer value.
|
||||
*
|
||||
* If this setting is enabled (= 1), only scheduling events are recorded.
|
||||
* If disabled (= 0), all events are recorded (unless filtered in other ways).
|
||||
*
|
||||
* Default value is 0 (= include additional events).
|
||||
*/
|
||||
#define TRC_CFG_SCHEDULING_ONLY 0
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_INCLUDE_MEMMANG_EVENTS
|
||||
* @brief Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* This controls if malloc and free calls should be traced. Set this to zero (0)
|
||||
* to exclude malloc/free calls, or one (1) to include such events in the trace.
|
||||
*
|
||||
* Default value is 1.
|
||||
*/
|
||||
#define TRC_CFG_INCLUDE_MEMMANG_EVENTS 1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_INCLUDE_USER_EVENTS
|
||||
* @brief Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If this is zero (0), all code related to User Events is excluded in order
|
||||
* to reduce code size. Any attempts of storing User Events are then silently
|
||||
* ignored.
|
||||
*
|
||||
* User Events are application-generated events, like "printf" but for the
|
||||
* trace log, generated using vTracePrint and vTracePrintF.
|
||||
* The formatting is done on host-side, by Tracealyzer. User Events are
|
||||
* therefore much faster than a console printf and can often be used
|
||||
* in timing critical code without problems.
|
||||
*
|
||||
* Note: In streaming mode, User Events are used to provide error messages
|
||||
* and warnings from the recorder (in case of incorrect configuration) for
|
||||
* display in Tracealyzer. Disabling user events will also disable these
|
||||
* warnings. You can however still catch them by calling xTraceErrorGetLast
|
||||
* or by putting breakpoints in xTraceError and xTraceWarning.
|
||||
*
|
||||
* Default value is 1.
|
||||
*/
|
||||
#define TRC_CFG_INCLUDE_USER_EVENTS 1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_INCLUDE_ISR_TRACING
|
||||
* @brief Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If this is zero (0), the code for recording Interrupt Service Routines is
|
||||
* excluded, in order to reduce code size. This means that any calls to
|
||||
* vTraceStoreISRBegin/vTraceStoreISREnd will be ignored.
|
||||
* This does not completely disable ISR tracing, in cases where an ISR is
|
||||
* calling a traced kernel service. These events will still be recorded and
|
||||
* show up in anonymous ISR instances in Tracealyzer, with names such as
|
||||
* "ISR sending to <queue name>".
|
||||
* To disable such tracing, please refer to vTraceSetFilterGroup and
|
||||
* vTraceSetFilterMask.
|
||||
*
|
||||
* Default value is 1.
|
||||
*
|
||||
* Note: tracing ISRs requires that you insert calls to vTraceStoreISRBegin
|
||||
* and vTraceStoreISREnd in your interrupt handlers.
|
||||
*/
|
||||
#define TRC_CFG_INCLUDE_ISR_TRACING 1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_INCLUDE_READY_EVENTS
|
||||
* @brief Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If one (1), events are recorded when tasks enter scheduling state "ready".
|
||||
* This allows Tracealyzer to show the initial pending time before tasks enter
|
||||
* the execution state, and present accurate response times.
|
||||
* If zero (0), "ready events" are not created, which allows for recording
|
||||
* longer traces in the same amount of RAM.
|
||||
*
|
||||
* Default value is 1.
|
||||
*/
|
||||
#define TRC_CFG_INCLUDE_READY_EVENTS 1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_INCLUDE_OSTICK_EVENTS
|
||||
* @brief Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If this is one (1), events will be generated whenever the OS clock is
|
||||
* increased. If zero (0), OS tick events are not generated, which allows for
|
||||
* recording longer traces in the same amount of RAM.
|
||||
*
|
||||
* Default value is 1.
|
||||
*/
|
||||
#define TRC_CFG_INCLUDE_OSTICK_EVENTS 1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_ENABLE_STACK_MONITOR
|
||||
* @brief If enabled (1), the recorder periodically reports the unused stack space of
|
||||
* all active tasks.
|
||||
* The stack monitoring runs in the Tracealyzer Control task, TzCtrl. This task
|
||||
* is always created by the recorder when in streaming mode.
|
||||
* In snapshot mode, the TzCtrl task is only used for stack monitoring and is
|
||||
* not created unless this is enabled.
|
||||
*/
|
||||
#define TRC_CFG_ENABLE_STACK_MONITOR 1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_STACK_MONITOR_MAX_TASKS
|
||||
* @brief Macro which should be defined as a non-zero integer value.
|
||||
*
|
||||
* This controls how many tasks that can be monitored by the stack monitor.
|
||||
* If this is too small, some tasks will be excluded and a warning is shown.
|
||||
*
|
||||
* Default value is 10.
|
||||
*/
|
||||
#define TRC_CFG_STACK_MONITOR_MAX_TASKS 50
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_STACK_MONITOR_MAX_REPORTS
|
||||
* @brief Macro which should be defined as a non-zero integer value.
|
||||
*
|
||||
* This defines how many tasks that will be subject to stack usage analysis for
|
||||
* each execution of the Tracealyzer Control task (TzCtrl). Note that the stack
|
||||
* monitoring cycles between the tasks, so this does not affect WHICH tasks that
|
||||
* are monitored, but HOW OFTEN each task stack is analyzed.
|
||||
*
|
||||
* This setting can be combined with TRC_CFG_CTRL_TASK_DELAY to tune the
|
||||
* frequency of the stack monitoring. This is motivated since the stack analysis
|
||||
* can take some time to execute.
|
||||
* However, note that the stack analysis runs in a separate task (TzCtrl) that
|
||||
* can be executed on low priority. This way, you can avoid that the stack
|
||||
* analysis disturbs any time-sensitive tasks.
|
||||
*
|
||||
* Default value is 1.
|
||||
*/
|
||||
#define TRC_CFG_STACK_MONITOR_MAX_REPORTS 1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_CTRL_TASK_PRIORITY
|
||||
* @brief The scheduling priority of the Tracealyzer Control (TzCtrl) task.
|
||||
*
|
||||
* In streaming mode, TzCtrl is used to receive start/stop commands from
|
||||
* Tracealyzer and in some cases also to transmit the trace data (for stream
|
||||
* ports that uses the internal buffer, like TCP/IP). For such stream ports,
|
||||
* make sure the TzCtrl priority is high enough to ensure reliable periodic
|
||||
* execution and transfer of the data, but low enough to avoid disturbing any
|
||||
* time-sensitive functions.
|
||||
*
|
||||
* In Snapshot mode, TzCtrl is only used for the stack usage monitoring and is
|
||||
* not created if stack monitoring is disabled. TRC_CFG_CTRL_TASK_PRIORITY should
|
||||
* be low, to avoid disturbing any time-sensitive tasks.
|
||||
*/
|
||||
#define TRC_CFG_CTRL_TASK_PRIORITY 1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_CTRL_TASK_DELAY
|
||||
* @brief The delay between loops of the TzCtrl task (see TRC_CFG_CTRL_TASK_PRIORITY),
|
||||
* which affects the frequency of the stack monitoring.
|
||||
*
|
||||
* In streaming mode, this also affects the trace data transfer if you are using
|
||||
* a stream port leveraging the internal buffer (like TCP/IP). A shorter delay
|
||||
* increases the CPU load of TzCtrl somewhat, but may improve the performance of
|
||||
* of the trace streaming, especially if the trace buffer is small.
|
||||
*/
|
||||
#define TRC_CFG_CTRL_TASK_DELAY 2
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_CTRL_TASK_STACK_SIZE
|
||||
* @brief The stack size of the Tracealyzer Control (TzCtrl) task.
|
||||
* See TRC_CFG_CTRL_TASK_PRIORITY for further information about TzCtrl.
|
||||
*/
|
||||
#define TRC_CFG_CTRL_TASK_STACK_SIZE 1024
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_RECORDER_BUFFER_ALLOCATION
|
||||
* @brief Specifies how the recorder buffer is allocated (also in case of streaming, in
|
||||
* port using the recorder's internal temporary buffer)
|
||||
*
|
||||
* Values:
|
||||
* TRC_RECORDER_BUFFER_ALLOCATION_STATIC - Static allocation (internal)
|
||||
* TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC - Malloc in vTraceEnable
|
||||
* TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM - Use vTraceSetRecorderDataBuffer
|
||||
*
|
||||
* Static and dynamic mode does the allocation for you, either in compile time
|
||||
* (static) or in runtime (malloc).
|
||||
* The custom mode allows you to control how and where the allocation is made,
|
||||
* for details see TRC_ALLOC_CUSTOM_BUFFER and vTraceSetRecorderDataBuffer().
|
||||
*/
|
||||
#define TRC_CFG_RECORDER_BUFFER_ALLOCATION TRC_RECORDER_BUFFER_ALLOCATION_STATIC
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_MAX_ISR_NESTING
|
||||
* @brief Defines how many levels of interrupt nesting the recorder can handle, in
|
||||
* case multiple ISRs are traced and ISR nesting is possible. If this
|
||||
* is exceeded, the particular ISR will not be traced and the recorder then
|
||||
* logs an error message. This setting is used to allocate an internal stack
|
||||
* for keeping track of the previous execution context (4 byte per entry).
|
||||
*
|
||||
* This value must be a non-zero positive constant, at least 1.
|
||||
*
|
||||
* Default value: 8
|
||||
*/
|
||||
#define TRC_CFG_MAX_ISR_NESTING 8
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_ISR_TAILCHAINING_THRESHOLD
|
||||
* @brief Macro which should be defined as an integer value.
|
||||
*
|
||||
* If tracing multiple ISRs, this setting allows for accurate display of the
|
||||
* context-switching also in cases when the ISRs execute in direct sequence.
|
||||
*
|
||||
* vTraceStoreISREnd normally assumes that the ISR returns to the previous
|
||||
* context, i.e., a task or a preempted ISR. But if another traced ISR
|
||||
* executes in direct sequence, Tracealyzer may incorrectly display a minimal
|
||||
* fragment of the previous context in between the ISRs.
|
||||
*
|
||||
* By using TRC_CFG_ISR_TAILCHAINING_THRESHOLD you can avoid this. This is
|
||||
* however a threshold value that must be measured for your specific setup.
|
||||
* See http://percepio.com/2014/03/21/isr_tailchaining_threshold/
|
||||
*
|
||||
* The default setting is 0, meaning "disabled" and that you may get an
|
||||
* extra fragments of the previous context in between tail-chained ISRs.
|
||||
*
|
||||
* Note: This setting has separate definitions in trcSnapshotConfig.h and
|
||||
* trcStreamingConfig.h, since it is affected by the recorder mode.
|
||||
*/
|
||||
#define TRC_CFG_ISR_TAILCHAINING_THRESHOLD 0
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_RECORDER_DATA_INIT
|
||||
* @brief Macro which states wether the recorder data should have an initial value.
|
||||
*
|
||||
* In very specific cases where traced objects are created before main(),
|
||||
* the recorder will need to be started even before that. In these cases,
|
||||
* the recorder data would be initialized by vTraceEnable(TRC_INIT) but could
|
||||
* then later be overwritten by the initialization value.
|
||||
* If this is an issue for you, set TRC_CFG_RECORDER_DATA_INIT to 0.
|
||||
* The following code can then be used before any traced objects are created:
|
||||
*
|
||||
* extern uint32_t RecorderEnabled;
|
||||
* RecorderEnabled = 0;
|
||||
* xTraceInitialize();
|
||||
*
|
||||
* After the clocks are properly initialized, use vTraceEnable(...) to start
|
||||
* the tracing.
|
||||
*
|
||||
* Default value is 1.
|
||||
*/
|
||||
#define TRC_CFG_RECORDER_DATA_INIT 1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_RECORDER_DATA_ATTRIBUTE
|
||||
* @brief When setting TRC_CFG_RECORDER_DATA_INIT to 0, you might also need to make
|
||||
* sure certain recorder data is placed in a specific RAM section to avoid being
|
||||
* zeroed out after initialization. Define TRC_CFG_RECORDER_DATA_ATTRIBUTE as
|
||||
* that attribute.
|
||||
*
|
||||
* Example:
|
||||
* #define TRC_CFG_RECORDER_DATA_ATTRIBUTE __attribute__((section(".bss.trace_recorder_data")))
|
||||
*
|
||||
* Default value is empty.
|
||||
*/
|
||||
#define TRC_CFG_RECORDER_DATA_ATTRIBUTE
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_USE_TRACE_ASSERT
|
||||
* @brief Enable or disable debug asserts. Information regarding any assert that is
|
||||
* triggered will be in trcAssert.c.
|
||||
*/
|
||||
#define TRC_CFG_USE_TRACE_ASSERT 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TRC_CONFIG_H */
|
||||
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Trace Recorder for Tracealyzer v4.6.0
|
||||
* Copyright 2021 Percepio AB
|
||||
* www.percepio.com
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Configuration parameters for the kernel port.
|
||||
* More settings can be found in trcKernelPortStreamingConfig.h and
|
||||
* trcKernelPortSnapshotConfig.h.
|
||||
*/
|
||||
|
||||
#ifndef TRC_KERNEL_PORT_CONFIG_H
|
||||
#define TRC_KERNEL_PORT_CONFIG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_RECORDER_MODE
|
||||
* @brief Specify what recording mode to use. Snapshot means that the data is saved in
|
||||
* an internal RAM buffer, for later upload. Streaming means that the data is
|
||||
* transferred continuously to the host PC.
|
||||
*
|
||||
* For more information, see http://percepio.com/2016/10/05/rtos-tracing/
|
||||
* and the Tracealyzer User Manual.
|
||||
*
|
||||
* Values:
|
||||
* TRC_RECORDER_MODE_SNAPSHOT
|
||||
* TRC_RECORDER_MODE_STREAMING
|
||||
*/
|
||||
#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_SNAPSHOT
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_FREERTOS_VERSION
|
||||
* @brief Specify what version of FreeRTOS that is used (don't change unless using the
|
||||
* trace recorder library with an older version of FreeRTOS).
|
||||
*
|
||||
* TRC_FREERTOS_VERSION_7_3_X If using FreeRTOS v7.3.X
|
||||
* TRC_FREERTOS_VERSION_7_4_X If using FreeRTOS v7.4.X
|
||||
* TRC_FREERTOS_VERSION_7_5_X If using FreeRTOS v7.5.X
|
||||
* TRC_FREERTOS_VERSION_7_6_X If using FreeRTOS v7.6.X
|
||||
* TRC_FREERTOS_VERSION_8_X_X If using FreeRTOS v8.X.X
|
||||
* TRC_FREERTOS_VERSION_9_0_0 If using FreeRTOS v9.0.0
|
||||
* TRC_FREERTOS_VERSION_9_0_1 If using FreeRTOS v9.0.1
|
||||
* TRC_FREERTOS_VERSION_9_0_2 If using FreeRTOS v9.0.2
|
||||
* TRC_FREERTOS_VERSION_10_0_0 If using FreeRTOS v10.0.0
|
||||
* TRC_FREERTOS_VERSION_10_0_1 If using FreeRTOS v10.0.1
|
||||
* TRC_FREERTOS_VERSION_10_1_0 If using FreeRTOS v10.1.0
|
||||
* TRC_FREERTOS_VERSION_10_1_1 If using FreeRTOS v10.1.1
|
||||
* TRC_FREERTOS_VERSION_10_2_0 If using FreeRTOS v10.2.0
|
||||
* TRC_FREERTOS_VERSION_10_2_1 If using FreeRTOS v10.2.1
|
||||
* TRC_FREERTOS_VERSION_10_3_0 If using FreeRTOS v10.3.0
|
||||
* TRC_FREERTOS_VERSION_10_3_1 If using FreeRTOS v10.3.1
|
||||
* TRC_FREERTOS_VERSION_10_4_0 If using FreeRTOS v10.4.0
|
||||
* TRC_FREERTOS_VERSION_10_4_1 If using FreeRTOS v10.4.1 or later
|
||||
*/
|
||||
#define TRC_CFG_FREERTOS_VERSION TRC_FREERTOS_VERSION_10_4_1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS
|
||||
* @brief Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If this is zero (0), the trace will exclude any "event group" events.
|
||||
*
|
||||
* Default value is 0 (excluded) since dependent on event_groups.c
|
||||
*/
|
||||
#define TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS 1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_INCLUDE_TIMER_EVENTS
|
||||
* @brief Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If this is zero (0), the trace will exclude any Timer events.
|
||||
*
|
||||
* Default value is 0 since dependent on timers.c
|
||||
*/
|
||||
#define TRC_CFG_INCLUDE_TIMER_EVENTS 1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS
|
||||
* @brief Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If this is zero (0), the trace will exclude any "pending function call"
|
||||
* events, such as xTimerPendFunctionCall().
|
||||
*
|
||||
* Default value is 0 since dependent on timers.c
|
||||
*/
|
||||
#define TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS 1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS
|
||||
* @brief Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If this is zero (0), the trace will exclude any stream buffer or message
|
||||
* buffer events.
|
||||
*
|
||||
* Default value is 0 since dependent on stream_buffer.c (new in FreeRTOS v10)
|
||||
*/
|
||||
#define TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS 1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_ACKNOWLEDGE_QUEUE_SET_SEND
|
||||
* @brief When using FreeRTOS v10.3.0 or v10.3.1, please make sure that the trace
|
||||
* point in prvNotifyQueueSetContainer() in queue.c is renamed from
|
||||
* traceQUEUE_SEND to traceQUEUE_SET_SEND in order to tell them apart from
|
||||
* other traceQUEUE_SEND trace points. Then set this to TRC_ACKNOWLEDGED.
|
||||
*/
|
||||
#define TRC_CFG_ACKNOWLEDGE_QUEUE_SET_SEND 0 /* TRC_ACKNOWLEDGED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TRC_KERNEL_PORT_CONFIG_H */
|
||||
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Trace Recorder for Tracealyzer v4.6.0
|
||||
* Copyright 2021 Percepio AB
|
||||
* www.percepio.com
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Kernel port configuration parameters for snapshot mode.
|
||||
*/
|
||||
|
||||
#ifndef TRC_KERNEL_PORT_SNAPSHOT_CONFIG_H
|
||||
#define TRC_KERNEL_PORT_SNAPSHOT_CONFIG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_NTASK, TRC_CFG_NISR, TRC_CFG_NQUEUE, TRC_CFG_NSEMAPHORE...
|
||||
* @brief A group of macros which should be defined as integer values, zero or larger.
|
||||
*
|
||||
* These define the capacity of the Object Property Table, i.e., the maximum
|
||||
* number of objects active at any given point, within each object class (e.g.,
|
||||
* task, queue, semaphore, ...).
|
||||
*
|
||||
* If tasks or other objects are deleted in your system, this
|
||||
* setting does not limit the total amount of objects created, only the number
|
||||
* of objects that have been successfully created but not yet deleted.
|
||||
*
|
||||
* Using too small values will cause vTraceError to be called, which stores an
|
||||
* error message in the trace that is shown when opening the trace file. The
|
||||
* error message can also be retrieved using xTraceGetLastError.
|
||||
*
|
||||
* It can be wise to start with large values for these constants,
|
||||
* unless you are very confident on these numbers. Then do a recording and
|
||||
* check the actual usage by selecting View menu -> Trace Details ->
|
||||
* Resource Usage -> Object Table.
|
||||
*/
|
||||
#define TRC_CFG_NTASK 150
|
||||
#define TRC_CFG_NISR 90
|
||||
#define TRC_CFG_NQUEUE 90
|
||||
#define TRC_CFG_NSEMAPHORE 90
|
||||
#define TRC_CFG_NMUTEX 90
|
||||
#define TRC_CFG_NTIMER 250
|
||||
#define TRC_CFG_NEVENTGROUP 90
|
||||
#define TRC_CFG_NSTREAMBUFFER 50
|
||||
#define TRC_CFG_NMESSAGEBUFFER 50
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_NAME_LEN_TASK, TRC_CFG_NAME_LEN_QUEUE, ...
|
||||
* @brief Macros that specify the maximum lengths (number of characters) for names of
|
||||
* kernel objects, such as tasks and queues. If longer names are used, they will
|
||||
* be truncated when stored in the recorder.
|
||||
*/
|
||||
#define TRC_CFG_NAME_LEN_TASK 15
|
||||
#define TRC_CFG_NAME_LEN_ISR 15
|
||||
#define TRC_CFG_NAME_LEN_QUEUE 15
|
||||
#define TRC_CFG_NAME_LEN_SEMAPHORE 15
|
||||
#define TRC_CFG_NAME_LEN_MUTEX 15
|
||||
#define TRC_CFG_NAME_LEN_TIMER 15
|
||||
#define TRC_CFG_NAME_LEN_EVENTGROUP 15
|
||||
#define TRC_CFG_NAME_LEN_STREAMBUFFER 15
|
||||
#define TRC_CFG_NAME_LEN_MESSAGEBUFFER 15
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TRC_KERNEL_PORT_SNAPSHOT_CONFIG_H */
|
||||
@ -0,0 +1,245 @@
|
||||
/*
|
||||
* Trace Recorder for Tracealyzer v4.6.0
|
||||
* Copyright 2021 Percepio AB
|
||||
* www.percepio.com
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Configuration parameters for trace recorder library in snapshot mode.
|
||||
* Read more at http://percepio.com/2016/10/05/rtos-tracing/
|
||||
*/
|
||||
|
||||
#ifndef TRC_SNAPSHOT_CONFIG_H
|
||||
#define TRC_SNAPSHOT_CONFIG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_SNAPSHOT_MODE
|
||||
* @brief Macro which should be defined as one of:
|
||||
* - TRC_SNAPSHOT_MODE_RING_BUFFER
|
||||
* - TRC_SNAPSHOT_MODE_STOP_WHEN_FULL
|
||||
* Default is TRC_SNAPSHOT_MODE_RING_BUFFER.
|
||||
*
|
||||
* With TRC_CFG_SNAPSHOT_MODE set to TRC_SNAPSHOT_MODE_RING_BUFFER, the
|
||||
* events are stored in a ring buffer, i.e., where the oldest events are
|
||||
* overwritten when the buffer becomes full. This allows you to get the last
|
||||
* events leading up to an interesting state, e.g., an error, without having
|
||||
* to store the whole run since startup.
|
||||
*
|
||||
* When TRC_CFG_SNAPSHOT_MODE is TRC_SNAPSHOT_MODE_STOP_WHEN_FULL, the
|
||||
* recording is stopped when the buffer becomes full. This is useful for
|
||||
* recording events following a specific state, e.g., the startup sequence.
|
||||
*/
|
||||
#define TRC_CFG_SNAPSHOT_MODE TRC_SNAPSHOT_MODE_RING_BUFFER
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_EVENT_BUFFER_SIZE
|
||||
* @brief Macro which should be defined as an integer value.
|
||||
*
|
||||
* This defines the capacity of the event buffer, i.e., the number of records
|
||||
* it may store. Most events use one record (4 byte), although some events
|
||||
* require multiple 4-byte records. You should adjust this to the amount of RAM
|
||||
* available in the target system.
|
||||
*
|
||||
* Default value is 1000, which means that 4000 bytes is allocated for the
|
||||
* event buffer.
|
||||
*/
|
||||
#define TRC_CFG_EVENT_BUFFER_SIZE 250000
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_INCLUDE_FLOAT_SUPPORT
|
||||
* @brief Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If this is zero (0), the support for logging floating point values in
|
||||
* vTracePrintF is stripped out, in case floating point values are not used or
|
||||
* supported by the platform used.
|
||||
*
|
||||
* Floating point values are only used in vTracePrintF and its subroutines, to
|
||||
* allow for storing float (%f) or double (%lf) arguments.
|
||||
*
|
||||
* vTracePrintF can be used with integer and string arguments in either case.
|
||||
*
|
||||
* Default value is 0.
|
||||
*/
|
||||
#define TRC_CFG_INCLUDE_FLOAT_SUPPORT 0
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_SYMBOL_TABLE_SIZE
|
||||
* @brief Macro which should be defined as an integer value.
|
||||
*
|
||||
* This defines the capacity of the symbol table, in bytes. This symbol table
|
||||
* stores User Events labels and names of deleted tasks, queues, or other kernel
|
||||
* objects. If you don't use User Events or delete any kernel
|
||||
* objects you set this to a very low value. The minimum recommended value is 4.
|
||||
* A size of zero (0) is not allowed since a zero-sized array may result in a
|
||||
* 32-bit pointer, i.e., using 4 bytes rather than 0.
|
||||
*
|
||||
* Default value is 800.
|
||||
*/
|
||||
#define TRC_CFG_SYMBOL_TABLE_SIZE 8000
|
||||
|
||||
#if ( TRC_CFG_SYMBOL_TABLE_SIZE == 0 )
|
||||
#error "TRC_CFG_SYMBOL_TABLE_SIZE may not be zero!"
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
*** ADVANCED SETTINGS ********************************************************
|
||||
******************************************************************************
|
||||
* The remaining settings are not necessary to modify but allows for optimizing
|
||||
* the recorder setup for your specific needs, e.g., to exclude events that you
|
||||
* are not interested in, in order to get longer traces.
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_HEAP_SIZE_BELOW_16M
|
||||
* @brief An integer constant that can be used to reduce the buffer usage of memory
|
||||
* allocation events (malloc/free). This value should be 1 if the heap size is
|
||||
* below 16 MB (2^24 byte), and you can live with reported addresses showing the
|
||||
* lower 24 bits only. If 0, you get the full 32-bit addresses.
|
||||
*
|
||||
* Default value is 0.
|
||||
*/
|
||||
#define TRC_CFG_HEAP_SIZE_BELOW_16M 0
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_USE_IMPLICIT_IFE_RULES
|
||||
* @brief Macro which should be defined as either zero (0) or one (1).
|
||||
* Default is 1.
|
||||
*
|
||||
* Tracealyzer groups the events into "instances" based on Instance Finish
|
||||
* Events (IFEs), produced either by default rules or calls to the recorder
|
||||
* functions xTraceTaskInstanceFinishedNow and xTraceTaskInstanceFinishedNext.
|
||||
*
|
||||
* If TRC_CFG_USE_IMPLICIT_IFE_RULES is one (1), the default IFE rules is
|
||||
* used, resulting in a "typical" grouping of events into instances.
|
||||
* If these rules don't give appropriate instances in your case, you can
|
||||
* override the default rules using xTraceTaskInstanceFinishedNow/Next for one
|
||||
* or several tasks. The default IFE rules are then disabled for those tasks.
|
||||
*
|
||||
* If TRC_CFG_USE_IMPLICIT_IFE_RULES is zero (0), the implicit IFE rules are
|
||||
* disabled globally. You must then call xTraceTaskInstanceFinishedNow or
|
||||
* xTraceTaskInstanceFinishedNext to manually group the events into instances,
|
||||
* otherwise the tasks will appear a single long instance.
|
||||
*
|
||||
* The default IFE rules count the following events as "instance finished":
|
||||
* - Task delay, delay until
|
||||
* - Task suspend
|
||||
* - Blocking on "input" operations, i.e., when the task is waiting for the
|
||||
* next a message/signal/event. But only if this event is blocking.
|
||||
*/
|
||||
#define TRC_CFG_USE_IMPLICIT_IFE_RULES 1
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_USE_16BIT_OBJECT_HANDLES
|
||||
* @brief Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If set to 0 (zero), the recorder uses 8-bit handles to identify kernel
|
||||
* objects such as tasks and queues. This limits the supported number of
|
||||
* concurrently active objects to 255 of each type (tasks, queues, mutexes,
|
||||
* etc.) Note: 255, not 256, since handle 0 is reserved.
|
||||
*
|
||||
* If set to 1 (one), the recorder uses 16-bit handles to identify kernel
|
||||
* objects such as tasks and queues. This limits the supported number of
|
||||
* concurrent objects to 65535 of each type (object class). However, since the
|
||||
* object property table is limited to 64 KB, the practical limit is about
|
||||
* 3000 objects in total.
|
||||
*
|
||||
* Default is 0 (8-bit handles)
|
||||
*
|
||||
* NOTE: An object with handle above 255 will use an extra 4-byte record in
|
||||
* the event buffer whenever the object is referenced. Moreover, some internal
|
||||
* tables in the recorder gets slightly larger when using 16-bit handles.
|
||||
*/
|
||||
#define TRC_CFG_USE_16BIT_OBJECT_HANDLES 0
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER
|
||||
* @brief Macro which should be defined as an integer value.
|
||||
*
|
||||
* Set TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER to 1 to enable the
|
||||
* separate user event buffer (UB).
|
||||
* In this mode, user events are stored separately from other events,
|
||||
* e.g., RTOS events. Thereby you can get a much longer history of
|
||||
* user events as they don't need to share the buffer space with more
|
||||
* frequent events.
|
||||
*
|
||||
* The UB is typically used with the snapshot ring-buffer mode, so the
|
||||
* recording can continue when the main buffer gets full. And since the
|
||||
* main buffer then overwrites the earliest events, Tracealyzer displays
|
||||
* "Unknown Actor" instead of task scheduling for periods with UB data only.
|
||||
*
|
||||
* In UB mode, user events are structured as UB channels, which contains
|
||||
* a channel name and a default format string. Register a UB channel using
|
||||
* xTraceRegisterUBChannel.
|
||||
*
|
||||
* Events and data arguments are written using vTraceUBEvent and
|
||||
* vTraceUBData. They are designed to provide efficient logging of
|
||||
* repeating events, using the same format string within each channel.
|
||||
*
|
||||
* Examples:
|
||||
* TraceStringHandle_t chn1;
|
||||
* TraceStringHandle_t fmt1;
|
||||
* xTraceStringRegister("Channel 1", &chn1);
|
||||
* xTraceStringRegister("Event!", &fmt1);
|
||||
* traceUBChannel UBCh1 = xTraceRegisterUBChannel(chn1, fmt1);
|
||||
*
|
||||
* TraceStringHandle_t chn2;
|
||||
* TraceStringHandle_t fmt2;
|
||||
* xTraceStringRegister("Channel 2", &chn2);
|
||||
* xTraceStringRegister("X: %d, Y: %d", &fmt2);
|
||||
* traceUBChannel UBCh2 = xTraceRegisterUBChannel(chn2, fmt2);
|
||||
*
|
||||
* // Result in "[Channel 1] Event!"
|
||||
* vTraceUBEvent(UBCh1);
|
||||
*
|
||||
* // Result in "[Channel 2] X: 23, Y: 19"
|
||||
* vTraceUBData(UBCh2, 23, 19);
|
||||
*
|
||||
* You can also use the other user event functions, like xTracePrintF.
|
||||
* as they are then rerouted to the UB instead of the main event buffer.
|
||||
* vTracePrintF then looks up the correct UB channel based on the
|
||||
* provided channel name and format string, or creates a new UB channel
|
||||
* if no match is found. The format string should therefore not contain
|
||||
* "random" messages but mainly format specifiers. Random strings should
|
||||
* be stored using %s and with the string as an argument.
|
||||
*
|
||||
* // Creates a new UB channel ("Channel 2", "%Z: %d")
|
||||
* xTracePrintF(chn2, "%Z: %d", value1);
|
||||
*
|
||||
* // Finds the existing UB channel
|
||||
* xTracePrintF(chn2, "%Z: %d", value2);
|
||||
*/
|
||||
#define TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER 0
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE
|
||||
* @brief Macro which should be defined as an integer value.
|
||||
*
|
||||
* This defines the capacity of the user event buffer (UB), in number of slots.
|
||||
* A single user event can use multiple slots, depending on the arguments.
|
||||
*
|
||||
* Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.
|
||||
*/
|
||||
#define TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE 200
|
||||
|
||||
/**
|
||||
* @def TRC_CFG_UB_CHANNELS
|
||||
* @brief Macro which should be defined as an integer value.
|
||||
*
|
||||
* This defines the number of User Event Buffer Channels (UB channels).
|
||||
* These are used to structure the events when using the separate user
|
||||
* event buffer, and contains both a User Event Channel (the name) and
|
||||
* a default format string for the channel.
|
||||
*
|
||||
* Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.
|
||||
*/
|
||||
#define TRC_CFG_UB_CHANNELS 32
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*TRC_SNAPSHOT_CONFIG_H*/
|
||||
25
kernel/FreeRTOS/Demo/WIN32-MSVC/WIN32.sln
Normal file
25
kernel/FreeRTOS/Demo/WIN32-MSVC/WIN32.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RTOSDemo", "WIN32.vcxproj", "{C686325E-3261-42F7-AEB1-DDE5280E1CEB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Optimised|Win32 = Optimised|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C686325E-3261-42F7-AEB1-DDE5280E1CEB}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{C686325E-3261-42F7-AEB1-DDE5280E1CEB}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{C686325E-3261-42F7-AEB1-DDE5280E1CEB}.Optimised|Win32.ActiveCfg = Debug|Win32
|
||||
{C686325E-3261-42F7-AEB1-DDE5280E1CEB}.Optimised|Win32.Build.0 = Debug|Win32
|
||||
{C686325E-3261-42F7-AEB1-DDE5280E1CEB}.Release|Win32.ActiveCfg = Debug|Win32
|
||||
{C686325E-3261-42F7-AEB1-DDE5280E1CEB}.Release|Win32.Build.0 = Debug|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
160
kernel/FreeRTOS/Demo/WIN32-MSVC/WIN32.vcxproj
Normal file
160
kernel/FreeRTOS/Demo/WIN32-MSVC/WIN32.vcxproj
Normal file
@ -0,0 +1,160 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{C686325E-3261-42F7-AEB1-DDE5280E1CEB}</ProjectGuid>
|
||||
<ProjectName>RTOSDemo</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Midl>
|
||||
<TypeLibraryName>.\Debug/WIN32.tlb</TypeLibraryName>
|
||||
<HeaderFileName>
|
||||
</HeaderFileName>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\..\Source\include;..\..\Source\portable\MSVC-MingW;..\Common\Include;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-Trace\Include;.\Trace_Recorder_Configuration;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0601;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeaderOutputFile>.\Debug/WIN32.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>.\Debug/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\Debug/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Debug/</ProgramDataBaseFileName>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
<AdditionalOptions>/wd4210 %(AdditionalOptions)</AdditionalOptions>
|
||||
<DisableSpecificWarnings>4574;4820;4668;4255;4710;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0c09</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<OutputFile>.\Debug/RTOSDemo.exe</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>.\Debug/WIN32.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
</Link>
|
||||
<Bscmake>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\Debug/WIN32.bsc</OutputFile>
|
||||
</Bscmake>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-Trace\trcKernelPort.c" />
|
||||
<ClCompile Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-Trace\trcSnapshotRecorder.c" />
|
||||
<ClCompile Include="..\..\Source\event_groups.c" />
|
||||
<ClCompile Include="..\..\Source\portable\MemMang\heap_5.c" />
|
||||
<ClCompile Include="..\..\Source\stream_buffer.c" />
|
||||
<ClCompile Include="..\..\Source\timers.c" />
|
||||
<ClCompile Include="..\Common\Minimal\AbortDelay.c" />
|
||||
<ClCompile Include="..\Common\Minimal\BlockQ.c" />
|
||||
<ClCompile Include="..\Common\Minimal\blocktim.c" />
|
||||
<ClCompile Include="..\Common\Minimal\countsem.c" />
|
||||
<ClCompile Include="..\Common\Minimal\death.c" />
|
||||
<ClCompile Include="..\Common\Minimal\dynamic.c" />
|
||||
<ClCompile Include="..\Common\Minimal\EventGroupsDemo.c" />
|
||||
<ClCompile Include="..\Common\Minimal\flop.c" />
|
||||
<ClCompile Include="..\Common\Minimal\GenQTest.c" />
|
||||
<ClCompile Include="..\Common\Minimal\integer.c" />
|
||||
<ClCompile Include="..\Common\Minimal\IntSemTest.c" />
|
||||
<ClCompile Include="..\Common\Minimal\MessageBufferAMP.c" />
|
||||
<ClCompile Include="..\Common\Minimal\PollQ.c" />
|
||||
<ClCompile Include="..\Common\Minimal\QPeek.c" />
|
||||
<ClCompile Include="..\Common\Minimal\QueueOverwrite.c" />
|
||||
<ClCompile Include="..\Common\Minimal\QueueSet.c" />
|
||||
<ClCompile Include="..\Common\Minimal\QueueSetPolling.c" />
|
||||
<ClCompile Include="..\Common\Minimal\recmutex.c" />
|
||||
<ClCompile Include="..\Common\Minimal\semtest.c" />
|
||||
<ClCompile Include="..\Common\Minimal\StaticAllocation.c" />
|
||||
<ClCompile Include="..\Common\Minimal\MessageBufferDemo.c" />
|
||||
<ClCompile Include="..\Common\Minimal\StreamBufferDemo.c" />
|
||||
<ClCompile Include="..\Common\Minimal\StreamBufferInterrupt.c" />
|
||||
<ClCompile Include="..\Common\Minimal\TaskNotify.c" />
|
||||
<ClCompile Include="..\Common\Minimal\TaskNotifyArray.c" />
|
||||
<ClCompile Include="..\Common\Minimal\timerdemo.c" />
|
||||
<ClCompile Include="main.c">
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\list.c">
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\portable\MSVC-MingW\port.c">
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\queue.c">
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\tasks.c">
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main_blinky.c" />
|
||||
<ClCompile Include="main_full.c" />
|
||||
<ClCompile Include="Run-time-stats-utils.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-Trace\Include\trcKernelPort.h" />
|
||||
<ClInclude Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-Trace\Include\trcRecorder.h" />
|
||||
<ClInclude Include="..\..\Source\include\event_groups.h" />
|
||||
<ClInclude Include="..\..\Source\include\message_buffer.h" />
|
||||
<ClInclude Include="..\..\Source\include\stream_buffer.h" />
|
||||
<ClInclude Include="..\..\Source\include\timers.h" />
|
||||
<ClInclude Include="..\..\Source\portable\MSVC-MingW\portmacro.h" />
|
||||
<ClInclude Include="FreeRTOSConfig.h" />
|
||||
<ClInclude Include="..\..\Source\include\FreeRTOS.h" />
|
||||
<ClInclude Include="..\..\Source\include\list.h" />
|
||||
<ClInclude Include="..\..\Source\include\portable.h" />
|
||||
<ClInclude Include="..\..\Source\include\projdefs.h" />
|
||||
<ClInclude Include="..\..\Source\include\queue.h" />
|
||||
<ClInclude Include="..\..\Source\include\semphr.h" />
|
||||
<ClInclude Include="..\..\Source\include\task.h" />
|
||||
<ClInclude Include="Trace_Recorder_Configuration\trcConfig.h" />
|
||||
<ClInclude Include="Trace_Recorder_Configuration\trcKernelPortConfig.h" />
|
||||
<ClInclude Include="Trace_Recorder_Configuration\trcKernelPortSnapshotConfig.h" />
|
||||
<ClInclude Include="Trace_Recorder_Configuration\trcSnapshotConfig.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
229
kernel/FreeRTOS/Demo/WIN32-MSVC/WIN32.vcxproj.filters
Normal file
229
kernel/FreeRTOS/Demo/WIN32-MSVC/WIN32.vcxproj.filters
Normal file
@ -0,0 +1,229 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{38712199-cebf-4124-bf15-398f7c3419ea}</UniqueIdentifier>
|
||||
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="FreeRTOS Source">
|
||||
<UniqueIdentifier>{af3445a1-4908-4170-89ed-39345d90d30c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="FreeRTOS Source\Source">
|
||||
<UniqueIdentifier>{f32be356-4763-4cae-9020-974a2638cb08}</UniqueIdentifier>
|
||||
<Extensions>*.c</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="FreeRTOS Source\Include">
|
||||
<UniqueIdentifier>{a60060e3-3949-4f60-b025-cb84164ae9ed}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Demo App Source">
|
||||
<UniqueIdentifier>{34567deb-d5ab-4a56-8640-0aaec609521a}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="FreeRTOS Source\Source\Portable">
|
||||
<UniqueIdentifier>{88f409e6-d396-4ac5-94bd-7a99c914be46}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Configuration Files">
|
||||
<UniqueIdentifier>{19ff1a34-36de-4c48-9d10-3fb1fa0d1fa4}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Demo App Source\FreeRTOS+Trace Recorder">
|
||||
<UniqueIdentifier>{90b56567-bab6-4d92-b319-b514d378329d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Demo App Source\Full_Demo">
|
||||
<UniqueIdentifier>{4ae1665e-a7bb-4c1a-81a3-531d883e6f2d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Demo App Source\Full_Demo\Common Demo Tasks">
|
||||
<UniqueIdentifier>{2d4a700c-06e3-4dd2-afbe-ab1be71ebe2a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Demo App Source\Blinky_Demo">
|
||||
<UniqueIdentifier>{fb86fa48-ac27-4f87-9215-ce9e1a1a85f9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Demo App Source\FreeRTOS+Trace Recorder\include">
|
||||
<UniqueIdentifier>{5cb8735d-498f-40aa-bf5c-9d41923b7968}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.c">
|
||||
<Filter>Demo App Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\list.c">
|
||||
<Filter>FreeRTOS Source\Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\queue.c">
|
||||
<Filter>FreeRTOS Source\Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\tasks.c">
|
||||
<Filter>FreeRTOS Source\Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\portable\MSVC-MingW\port.c">
|
||||
<Filter>FreeRTOS Source\Source\Portable</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\flop.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\GenQTest.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\integer.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\PollQ.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\QPeek.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\semtest.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\BlockQ.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\blocktim.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\timers.c">
|
||||
<Filter>FreeRTOS Source\Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\timerdemo.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\countsem.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\death.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\dynamic.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\QueueSet.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Run-time-stats-utils.c">
|
||||
<Filter>Demo App Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\QueueOverwrite.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\EventGroupsDemo.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\event_groups.c">
|
||||
<Filter>FreeRTOS Source\Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\portable\MemMang\heap_5.c">
|
||||
<Filter>FreeRTOS Source\Source\Portable</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\IntSemTest.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\TaskNotify.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\QueueSetPolling.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\recmutex.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main_full.c">
|
||||
<Filter>Demo App Source\Full_Demo</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main_blinky.c">
|
||||
<Filter>Demo App Source\Blinky_Demo</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\StaticAllocation.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\AbortDelay.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-Trace\trcKernelPort.c">
|
||||
<Filter>Demo App Source\FreeRTOS+Trace Recorder</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-Trace\trcSnapshotRecorder.c">
|
||||
<Filter>Demo App Source\FreeRTOS+Trace Recorder</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\stream_buffer.c">
|
||||
<Filter>FreeRTOS Source\Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\MessageBufferDemo.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\StreamBufferDemo.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\StreamBufferInterrupt.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\MessageBufferAMP.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Minimal\TaskNotifyArray.c">
|
||||
<Filter>Demo App Source\Full_Demo\Common Demo Tasks</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="FreeRTOSConfig.h">
|
||||
<Filter>Configuration Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\include\FreeRTOS.h">
|
||||
<Filter>FreeRTOS Source\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\include\list.h">
|
||||
<Filter>FreeRTOS Source\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\include\portable.h">
|
||||
<Filter>FreeRTOS Source\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\include\projdefs.h">
|
||||
<Filter>FreeRTOS Source\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\include\queue.h">
|
||||
<Filter>FreeRTOS Source\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\include\semphr.h">
|
||||
<Filter>FreeRTOS Source\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\include\task.h">
|
||||
<Filter>FreeRTOS Source\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\portable\MSVC-MingW\portmacro.h">
|
||||
<Filter>FreeRTOS Source\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\include\timers.h">
|
||||
<Filter>FreeRTOS Source\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Trace_Recorder_Configuration\trcConfig.h">
|
||||
<Filter>Configuration Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\include\event_groups.h">
|
||||
<Filter>FreeRTOS Source\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\include\message_buffer.h">
|
||||
<Filter>FreeRTOS Source\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\include\stream_buffer.h">
|
||||
<Filter>FreeRTOS Source\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Trace_Recorder_Configuration\trcKernelPortConfig.h">
|
||||
<Filter>Configuration Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Trace_Recorder_Configuration\trcKernelPortSnapshotConfig.h">
|
||||
<Filter>Configuration Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Trace_Recorder_Configuration\trcSnapshotConfig.h">
|
||||
<Filter>Configuration Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-Trace\Include\trcKernelPort.h">
|
||||
<Filter>Demo App Source\FreeRTOS+Trace Recorder\include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-Trace\Include\trcRecorder.h">
|
||||
<Filter>Demo App Source\FreeRTOS+Trace Recorder\include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
544
kernel/FreeRTOS/Demo/WIN32-MSVC/main.c
Normal file
544
kernel/FreeRTOS/Demo/WIN32-MSVC/main.c
Normal file
@ -0,0 +1,544 @@
|
||||
/*
|
||||
* FreeRTOS V202212.01
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* This project provides two demo applications. A simple blinky style project,
|
||||
* and a more comprehensive test and demo application. The
|
||||
* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is used to select between the two.
|
||||
* The simply blinky demo is implemented and described in main_blinky.c. The
|
||||
* more comprehensive test and demo application is implemented and described in
|
||||
* main_full.c.
|
||||
*
|
||||
* This file implements the code that is not demo specific, including the
|
||||
* hardware setup and FreeRTOS hook functions.
|
||||
*
|
||||
*******************************************************************************
|
||||
* NOTE: Windows will not be running the FreeRTOS demo threads continuously, so
|
||||
* do not expect to get real time behaviour from the FreeRTOS Windows port, or
|
||||
* this demo application. Also, the timing information in the FreeRTOS+Trace
|
||||
* logs have no meaningful units. See the documentation page for the Windows
|
||||
* port for further information:
|
||||
* https://www.FreeRTOS.org/FreeRTOS-Windows-Simulator-Emulator-for-Visual-Studio-and-Eclipse-MingW.html
|
||||
*
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <conio.h>
|
||||
|
||||
/* Visual studio intrinsics used so the __debugbreak() function is available
|
||||
* should an assert get hit. */
|
||||
#include <intrin.h>
|
||||
|
||||
/* FreeRTOS kernel includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* FreeRTOS+Trace includes. */
|
||||
#include "trcRecorder.h"
|
||||
|
||||
/* This project provides two demo applications. A simple blinky style demo
|
||||
* application, and a more comprehensive test and demo application. The
|
||||
* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is used to select between the two.
|
||||
*
|
||||
* If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is 1 then the blinky demo will be built.
|
||||
* The blinky demo is implemented and described in main_blinky.c.
|
||||
*
|
||||
* If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is not 1 then the comprehensive test and
|
||||
* demo application will be built. The comprehensive test and demo application is
|
||||
* implemented and described in main_full.c. */
|
||||
#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0
|
||||
|
||||
/* This demo uses heap_5.c, and these constants define the sizes of the regions
|
||||
* that make up the total heap. heap_5 is only used for test and example purposes
|
||||
* as this demo could easily create one large heap region instead of multiple
|
||||
* smaller heap regions - in which case heap_4.c would be the more appropriate
|
||||
* choice. See http://www.freertos.org/a00111.html for an explanation. */
|
||||
#define mainREGION_1_SIZE 8201
|
||||
#define mainREGION_2_SIZE 23905
|
||||
#define mainREGION_3_SIZE 16807
|
||||
|
||||
/* This demo allows for users to perform actions with the keyboard. */
|
||||
#define mainNO_KEY_PRESS_VALUE -1
|
||||
#define mainOUTPUT_TRACE_KEY 't'
|
||||
#define mainINTERRUPT_NUMBER_KEYBOARD 3
|
||||
|
||||
/* This demo allows to save a trace file. */
|
||||
#define mainTRACE_FILE_NAME "Trace.dump"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.
|
||||
* main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.
|
||||
*/
|
||||
extern void main_blinky( void );
|
||||
extern void main_full( void );
|
||||
|
||||
/*
|
||||
* Only the comprehensive demo uses application hook (callback) functions. See
|
||||
* https://www.FreeRTOS.org/a00016.html for more information.
|
||||
*/
|
||||
extern void vFullDemoTickHookFunction( void );
|
||||
extern void vFullDemoIdleFunction( void );
|
||||
|
||||
/*
|
||||
* This demo uses heap_5.c, so start by defining some heap regions. It is not
|
||||
* necessary for this demo to use heap_5, as it could define one large heap
|
||||
* region. Heap_5 is only used for test and example purposes. See
|
||||
* https://www.FreeRTOS.org/a00111.html for an explanation.
|
||||
*/
|
||||
static void prvInitialiseHeap( void );
|
||||
|
||||
/*
|
||||
* Prototypes for the standard FreeRTOS application hook (callback) functions
|
||||
* implemented within this file. See http://www.freertos.org/a00016.html .
|
||||
*/
|
||||
void vApplicationMallocFailedHook( void );
|
||||
void vApplicationIdleHook( void );
|
||||
void vApplicationStackOverflowHook( TaskHandle_t pxTask,
|
||||
char * pcTaskName );
|
||||
void vApplicationTickHook( void );
|
||||
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
|
||||
StackType_t ** ppxIdleTaskStackBuffer,
|
||||
uint32_t * pulIdleTaskStackSize );
|
||||
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
|
||||
StackType_t ** ppxTimerTaskStackBuffer,
|
||||
uint32_t * pulTimerTaskStackSize );
|
||||
|
||||
/*
|
||||
* Writes trace data to a disk file when the trace recording is stopped.
|
||||
* This function will simply overwrite any trace files that already exist.
|
||||
*/
|
||||
static void prvSaveTraceFile( void );
|
||||
|
||||
/*
|
||||
* Windows thread function to capture keyboard input from outside of the
|
||||
* FreeRTOS simulator. This thread passes data safely into the FreeRTOS
|
||||
* simulator using a stream buffer.
|
||||
*/
|
||||
static DWORD WINAPI prvWindowsKeyboardInputThread( void * pvParam );
|
||||
|
||||
/*
|
||||
* Interrupt handler for when keyboard input is received.
|
||||
*/
|
||||
static uint32_t prvKeyboardInterruptHandler( void );
|
||||
|
||||
/*
|
||||
* Keyboard interrupt handler for the blinky demo.
|
||||
*/
|
||||
extern void vBlinkyKeyboardInterruptHandler( int xKeyPressed );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* When configSUPPORT_STATIC_ALLOCATION is set to 1 the application writer can
|
||||
* use a callback function to optionally provide the memory required by the idle
|
||||
* and timer tasks. This is the stack that will be used by the timer task. It is
|
||||
* declared here, as a global, so it can be checked by a test that is implemented
|
||||
* in a different file. */
|
||||
StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
|
||||
|
||||
|
||||
/* Thread handle for the keyboard input Windows thread. */
|
||||
static HANDLE xWindowsKeyboardInputThreadHandle = NULL;
|
||||
|
||||
/* This stores the last key pressed that has not been handled.
|
||||
* Keyboard input is retrieved by the prvWindowsKeyboardInputThread
|
||||
* Windows thread and stored here. This is then read by the idle
|
||||
* task and handled appropriately. */
|
||||
static int xKeyPressed = mainNO_KEY_PRESS_VALUE;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int main( void )
|
||||
{
|
||||
/* This demo uses heap_5.c, so start by defining some heap regions. heap_5
|
||||
* is only used for test and example reasons. Heap_4 is more appropriate. See
|
||||
* http://www.freertos.org/a00111.html for an explanation. */
|
||||
prvInitialiseHeap();
|
||||
|
||||
/* Initialise the trace recorder. Use of the trace recorder is optional.
|
||||
* See http://www.FreeRTOS.org/trace for more information. */
|
||||
|
||||
configASSERT( xTraceInitialize() == TRC_SUCCESS );
|
||||
|
||||
/* Start the trace recording - the recording is written to a file if
|
||||
* configASSERT() is called. */
|
||||
printf(
|
||||
"Trace started.\r\n"
|
||||
"The trace will be dumped to the file \"%s\" whenever a call to configASSERT()\r\n"
|
||||
"fails or the \'%c\' key is pressed.\r\n"
|
||||
"Note that the trace output uses the ring buffer mode, meaning that the output trace\r\n"
|
||||
"will only be the most recent data able to fit within the trace recorder buffer.\r\n",
|
||||
mainTRACE_FILE_NAME, mainOUTPUT_TRACE_KEY );
|
||||
|
||||
configASSERT( xTraceEnable(TRC_START) == TRC_SUCCESS );
|
||||
|
||||
/* Set interrupt handler for keyboard input. */
|
||||
vPortSetInterruptHandler( mainINTERRUPT_NUMBER_KEYBOARD, prvKeyboardInterruptHandler );
|
||||
|
||||
/* Start keyboard input handling thread. */
|
||||
xWindowsKeyboardInputThreadHandle = CreateThread(
|
||||
NULL, /* Pointer to thread security attributes. */
|
||||
0, /* Initial thread stack size, in bytes. */
|
||||
prvWindowsKeyboardInputThread, /* Pointer to thread function. */
|
||||
NULL, /* Argument for new thread. */
|
||||
0, /* Creation flags. */
|
||||
NULL);
|
||||
|
||||
/* Use the cores that are not used by the FreeRTOS tasks for the Windows thread. */
|
||||
SetThreadAffinityMask( xWindowsKeyboardInputThreadHandle, ~0x01u );
|
||||
|
||||
/* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
|
||||
* of this file. */
|
||||
#if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
|
||||
{
|
||||
main_blinky();
|
||||
}
|
||||
#else
|
||||
{
|
||||
main_full();
|
||||
}
|
||||
#endif /* if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 ) */
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationMallocFailedHook( void )
|
||||
{
|
||||
/* vApplicationMallocFailedHook() will only be called if
|
||||
* configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
|
||||
* function that will get called if a call to pvPortMalloc() fails.
|
||||
* pvPortMalloc() is called internally by the kernel whenever a task, queue,
|
||||
* timer or semaphore is created. It is also called by various parts of the
|
||||
* demo application. If heap_1.c, heap_2.c or heap_4.c is being used, then the
|
||||
* size of the heap available to pvPortMalloc() is defined by
|
||||
* configTOTAL_HEAP_SIZE in FreeRTOSConfig.h, and the xPortGetFreeHeapSize()
|
||||
* API function can be used to query the size of free heap space that remains
|
||||
* (although it does not provide information on how the remaining heap might be
|
||||
* fragmented). See http://www.freertos.org/a00111.html for more
|
||||
* information. */
|
||||
vAssertCalled( __LINE__, __FILE__ );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationIdleHook( void )
|
||||
{
|
||||
/* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
|
||||
* to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle
|
||||
* task. It is essential that code added to this hook function never attempts
|
||||
* to block in any way (for example, call xQueueReceive() with a block time
|
||||
* specified, or call vTaskDelay()). If application tasks make use of the
|
||||
* vTaskDelete() API function to delete themselves then it is also important
|
||||
* that vApplicationIdleHook() is permitted to return to its calling function,
|
||||
* because it is the responsibility of the idle task to clean up memory
|
||||
* allocated by the kernel to any task that has since deleted itself. */
|
||||
|
||||
#if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY != 1 )
|
||||
{
|
||||
/* Call the idle task processing used by the full demo. The simple
|
||||
* blinky demo does not use the idle task hook. */
|
||||
vFullDemoIdleFunction();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationStackOverflowHook( TaskHandle_t pxTask,
|
||||
char * pcTaskName )
|
||||
{
|
||||
( void ) pcTaskName;
|
||||
( void ) pxTask;
|
||||
|
||||
/* Run time stack overflow checking is performed if
|
||||
* configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
|
||||
* function is called if a stack overflow is detected. This function is
|
||||
* provided as an example only as stack overflow checking does not function
|
||||
* when running the FreeRTOS Windows port. */
|
||||
vAssertCalled( __LINE__, __FILE__ );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationTickHook( void )
|
||||
{
|
||||
/* This function will be called by each tick interrupt if
|
||||
* configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be
|
||||
* added here, but the tick hook is called from an interrupt context, so
|
||||
* code must not attempt to block, and only the interrupt safe FreeRTOS API
|
||||
* functions can be used (those that end in FromISR()). */
|
||||
|
||||
#if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY != 1 )
|
||||
{
|
||||
vFullDemoTickHookFunction();
|
||||
}
|
||||
#endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationDaemonTaskStartupHook( void )
|
||||
{
|
||||
/* This function will be called once only, when the daemon task starts to
|
||||
* execute (sometimes called the timer task). This is useful if the
|
||||
* application includes initialisation code that would benefit from executing
|
||||
* after the scheduler has been started. */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vAssertCalled( unsigned long ulLine,
|
||||
const char * const pcFileName )
|
||||
{
|
||||
static BaseType_t xPrinted = pdFALSE;
|
||||
volatile uint32_t ulSetToNonZeroInDebuggerToContinue = 0;
|
||||
|
||||
/* Called if an assertion passed to configASSERT() fails. See
|
||||
* http://www.freertos.org/a00110.html#configASSERT for more information. */
|
||||
|
||||
/* Parameters are not used. */
|
||||
( void ) ulLine;
|
||||
( void ) pcFileName;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
printf("ASSERT! Line %ld, file %s, GetLastError() %ld\r\n", ulLine, pcFileName, GetLastError());
|
||||
|
||||
/* Stop the trace recording and save the trace. */
|
||||
( void ) xTraceDisable();
|
||||
prvSaveTraceFile();
|
||||
|
||||
/* Cause debugger break point if being debugged. */
|
||||
__debugbreak();
|
||||
|
||||
/* You can step out of this function to debug the assertion by using
|
||||
* the debugger to set ulSetToNonZeroInDebuggerToContinue to a non-zero
|
||||
* value. */
|
||||
while( ulSetToNonZeroInDebuggerToContinue == 0 )
|
||||
{
|
||||
__asm {
|
||||
NOP
|
||||
};
|
||||
__asm {
|
||||
NOP
|
||||
};
|
||||
}
|
||||
|
||||
/* Re-enable the trace recording. */
|
||||
( void ) xTraceEnable( TRC_START );
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSaveTraceFile( void )
|
||||
{
|
||||
FILE * pxOutputFile;
|
||||
|
||||
fopen_s( &pxOutputFile, mainTRACE_FILE_NAME, "wb" );
|
||||
|
||||
if( pxOutputFile != NULL )
|
||||
{
|
||||
fwrite( RecorderDataPtr, sizeof( RecorderDataType ), 1, pxOutputFile );
|
||||
fclose( pxOutputFile );
|
||||
printf( "\r\nTrace output saved to %s\r\n\r\n", mainTRACE_FILE_NAME );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "\r\nFailed to create trace dump file\r\n\r\n" );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvInitialiseHeap( void )
|
||||
{
|
||||
/* The Windows demo could create one large heap region, in which case it would
|
||||
* be appropriate to use heap_4. However, purely for demonstration purposes,
|
||||
* heap_5 is used instead, so start by defining some heap regions. No
|
||||
* initialisation is required when any other heap implementation is used. See
|
||||
* http://www.freertos.org/a00111.html for more information.
|
||||
*
|
||||
* The xHeapRegions structure requires the regions to be defined in start address
|
||||
* order, so this just creates one big array, then populates the structure with
|
||||
* offsets into the array - with gaps in between and messy alignment just for test
|
||||
* purposes. */
|
||||
static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
|
||||
volatile uint32_t ulAdditionalOffset = 19; /* Just to prevent 'condition is always true' warnings in configASSERT(). */
|
||||
const HeapRegion_t xHeapRegions[] =
|
||||
{
|
||||
/* Start address with dummy offsets Size */
|
||||
{ ucHeap + 1, mainREGION_1_SIZE },
|
||||
{ ucHeap + 15 + mainREGION_1_SIZE, mainREGION_2_SIZE },
|
||||
{ ucHeap + 19 + mainREGION_1_SIZE + mainREGION_2_SIZE, mainREGION_3_SIZE },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
/* Sanity check that the sizes and offsets defined actually fit into the
|
||||
* array. */
|
||||
configASSERT( ( ulAdditionalOffset + mainREGION_1_SIZE + mainREGION_2_SIZE + mainREGION_3_SIZE ) < configTOTAL_HEAP_SIZE );
|
||||
|
||||
/* Prevent compiler warnings when configASSERT() is not defined. */
|
||||
( void ) ulAdditionalOffset;
|
||||
|
||||
vPortDefineHeapRegions( xHeapRegions );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
|
||||
* implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
|
||||
* used by the Idle task. */
|
||||
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
|
||||
StackType_t ** ppxIdleTaskStackBuffer,
|
||||
uint32_t * pulIdleTaskStackSize )
|
||||
{
|
||||
/* If the buffers to be provided to the Idle task are declared inside this
|
||||
* function then they must be declared static - otherwise they will be allocated on
|
||||
* the stack and so not exists after this function exits. */
|
||||
static StaticTask_t xIdleTaskTCB;
|
||||
static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
|
||||
|
||||
/* Pass out a pointer to the StaticTask_t structure in which the Idle task's
|
||||
* state will be stored. */
|
||||
*ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
|
||||
|
||||
/* Pass out the array that will be used as the Idle task's stack. */
|
||||
*ppxIdleTaskStackBuffer = uxIdleTaskStack;
|
||||
|
||||
/* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
|
||||
* Note that, as the array is necessarily of type StackType_t,
|
||||
* configMINIMAL_STACK_SIZE is specified in words, not bytes. */
|
||||
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
|
||||
* application must provide an implementation of vApplicationGetTimerTaskMemory()
|
||||
* to provide the memory that is used by the Timer service task. */
|
||||
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
|
||||
StackType_t ** ppxTimerTaskStackBuffer,
|
||||
uint32_t * pulTimerTaskStackSize )
|
||||
{
|
||||
/* If the buffers to be provided to the Timer task are declared inside this
|
||||
* function then they must be declared static - otherwise they will be allocated on
|
||||
* the stack and so not exists after this function exits. */
|
||||
static StaticTask_t xTimerTaskTCB;
|
||||
|
||||
/* Pass out a pointer to the StaticTask_t structure in which the Timer
|
||||
* task's state will be stored. */
|
||||
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
|
||||
|
||||
/* Pass out the array that will be used as the Timer task's stack. */
|
||||
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
|
||||
|
||||
/* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
|
||||
* Note that, as the array is necessarily of type StackType_t,
|
||||
* configMINIMAL_STACK_SIZE is specified in words, not bytes. */
|
||||
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Interrupt handler for when keyboard input is received.
|
||||
*/
|
||||
static uint32_t prvKeyboardInterruptHandler(void)
|
||||
{
|
||||
/* Handle keyboard input. */
|
||||
switch (xKeyPressed)
|
||||
{
|
||||
case mainNO_KEY_PRESS_VALUE:
|
||||
break;
|
||||
case mainOUTPUT_TRACE_KEY:
|
||||
/* Saving the trace file requires Windows system calls, so enter a critical
|
||||
section to prevent deadlock or errors resulting from calling a Windows
|
||||
system call from within the FreeRTOS simulator. */
|
||||
portENTER_CRITICAL();
|
||||
{
|
||||
( void ) xTraceDisable();
|
||||
prvSaveTraceFile();
|
||||
( void ) xTraceEnable(TRC_START);
|
||||
}
|
||||
portEXIT_CRITICAL();
|
||||
break;
|
||||
default:
|
||||
#if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
|
||||
{
|
||||
/* Call the keyboard interrupt handler for the blinky demo. */
|
||||
vBlinkyKeyboardInterruptHandler( xKeyPressed );
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
/* This interrupt does not require a context switch so return pdFALSE */
|
||||
return pdFALSE;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
/*
|
||||
* Windows thread function to capture keyboard input from outside of the
|
||||
* FreeRTOS simulator. This thread passes data into the simulator using
|
||||
* an integer.
|
||||
*/
|
||||
static DWORD WINAPI prvWindowsKeyboardInputThread( void * pvParam )
|
||||
{
|
||||
( void ) pvParam;
|
||||
|
||||
for ( ; ; )
|
||||
{
|
||||
/* Block on acquiring a key press. */
|
||||
xKeyPressed = _getch();
|
||||
|
||||
/* Notify FreeRTOS simulator that there is a keyboard interrupt.
|
||||
* This will trigger prvKeyboardInterruptHandler.
|
||||
*/
|
||||
vPortGenerateSimulatedInterrupt( mainINTERRUPT_NUMBER_KEYBOARD );
|
||||
}
|
||||
|
||||
/* Should not get here so return negative exit status. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The below code is used by the trace recorder for timing. */
|
||||
static uint32_t ulEntryTime = 0;
|
||||
|
||||
void vTraceTimerReset( void )
|
||||
{
|
||||
ulEntryTime = xTaskGetTickCount();
|
||||
}
|
||||
|
||||
uint32_t uiTraceTimerGetFrequency( void )
|
||||
{
|
||||
return configTICK_RATE_HZ;
|
||||
}
|
||||
|
||||
uint32_t uiTraceTimerGetValue( void )
|
||||
{
|
||||
return( xTaskGetTickCount() - ulEntryTime );
|
||||
}
|
||||
305
kernel/FreeRTOS/Demo/WIN32-MSVC/main_blinky.c
Normal file
305
kernel/FreeRTOS/Demo/WIN32-MSVC/main_blinky.c
Normal file
@ -0,0 +1,305 @@
|
||||
/*
|
||||
* FreeRTOS V202212.01
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* NOTE: Windows will not be running the FreeRTOS demo threads continuously, so
|
||||
* do not expect to get real time behaviour from the FreeRTOS Windows port, or
|
||||
* this demo application. Also, the timing information in the FreeRTOS+Trace
|
||||
* logs have no meaningful units. See the documentation page for the Windows
|
||||
* port for further information:
|
||||
* https://www.FreeRTOS.org/FreeRTOS-Windows-Simulator-Emulator-for-Visual-Studio-and-Eclipse-MingW.html
|
||||
*
|
||||
* NOTE 2: This project provides two demo applications. A simple blinky style
|
||||
* project, and a more comprehensive test and demo application. The
|
||||
* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select
|
||||
* between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY
|
||||
* in main.c. This file implements the simply blinky version. Console output
|
||||
* is used in place of the normal LED toggling.
|
||||
*
|
||||
* NOTE 3: This file only contains the source code that is specific to the
|
||||
* basic demo. Generic functions, such FreeRTOS hook functions, are defined
|
||||
* in main.c.
|
||||
******************************************************************************
|
||||
*
|
||||
* main_blinky() creates one queue, one software timer, and two tasks. It then
|
||||
* starts the scheduler.
|
||||
*
|
||||
* The Queue Send Task:
|
||||
* The queue send task is implemented by the prvQueueSendTask() function in
|
||||
* this file. It uses vTaskDelayUntil() to create a periodic task that sends
|
||||
* the value 100 to the queue every 200 milliseconds (please read the notes
|
||||
* above regarding the accuracy of timing under Windows).
|
||||
*
|
||||
* The Queue Send Software Timer:
|
||||
* The timer is a one-shot timer that is reset by a key press. The timer's
|
||||
* period is set to two seconds - if the timer expires then its callback
|
||||
* function writes the value 200 to the queue. The callback function is
|
||||
* implemented by prvQueueSendTimerCallback() within this file.
|
||||
*
|
||||
* The Queue Receive Task:
|
||||
* The queue receive task is implemented by the prvQueueReceiveTask() function
|
||||
* in this file. prvQueueReceiveTask() waits for data to arrive on the queue.
|
||||
* When data is received, the task checks the value of the data, then outputs a
|
||||
* message to indicate if the data came from the queue send task or the queue
|
||||
* send software timer.
|
||||
*
|
||||
* Expected Behaviour:
|
||||
* - The queue send task writes to the queue every 200ms, so every 200ms the
|
||||
* queue receive task will output a message indicating that data was received
|
||||
* on the queue from the queue send task.
|
||||
* - The queue send software timer has a period of two seconds, and is reset
|
||||
* each time a key is pressed. So if two seconds expire without a key being
|
||||
* pressed then the queue receive task will output a message indicating that
|
||||
* data was received on the queue from the queue send software timer.
|
||||
*
|
||||
* NOTE: Console input and output relies on Windows system calls, which can
|
||||
* interfere with the execution of the FreeRTOS Windows port. This demo only
|
||||
* uses Windows system call occasionally. Heavier use of Windows system calls
|
||||
* can crash the port.
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
|
||||
/* Kernel includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "timers.h"
|
||||
#include "semphr.h"
|
||||
|
||||
/* Priorities at which the tasks are created. */
|
||||
#define mainQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainQUEUE_SEND_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
|
||||
/* The rate at which data is sent to the queue. The times are converted from
|
||||
milliseconds to ticks using the pdMS_TO_TICKS() macro. */
|
||||
#define mainTASK_SEND_FREQUENCY_MS pdMS_TO_TICKS( 200UL )
|
||||
#define mainTIMER_SEND_FREQUENCY_MS pdMS_TO_TICKS( 2000UL )
|
||||
|
||||
/* The number of items the queue can hold at once. */
|
||||
#define mainQUEUE_LENGTH ( 2 )
|
||||
|
||||
/* The values sent to the queue receive task from the queue send task and the
|
||||
queue send software timer respectively. */
|
||||
#define mainVALUE_SENT_FROM_TASK ( 100UL )
|
||||
#define mainVALUE_SENT_FROM_TIMER ( 200UL )
|
||||
|
||||
/* This demo allows for users to perform actions with the keyboard. */
|
||||
#define mainNO_KEY_PRESS_VALUE ( -1 )
|
||||
#define mainRESET_TIMER_KEY ( 'r' )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* The tasks as described in the comments at the top of this file.
|
||||
*/
|
||||
static void prvQueueReceiveTask( void *pvParameters );
|
||||
static void prvQueueSendTask( void *pvParameters );
|
||||
|
||||
/*
|
||||
* The callback function executed when the software timer expires.
|
||||
*/
|
||||
static void prvQueueSendTimerCallback( TimerHandle_t xTimerHandle );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The queue used by both tasks. */
|
||||
static QueueHandle_t xQueue = NULL;
|
||||
|
||||
/* A software timer that is started from the tick hook. */
|
||||
static TimerHandle_t xTimer = NULL;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*** SEE THE COMMENTS AT THE TOP OF THIS FILE ***/
|
||||
void main_blinky( void )
|
||||
{
|
||||
const TickType_t xTimerPeriod = mainTIMER_SEND_FREQUENCY_MS;
|
||||
|
||||
printf( "\r\nStarting the blinky demo. Press \'%c\' to reset the software timer used in this demo.\r\n\r\n", mainRESET_TIMER_KEY );
|
||||
|
||||
/* Create the queue. */
|
||||
xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( uint32_t ) );
|
||||
|
||||
if( xQueue != NULL )
|
||||
{
|
||||
/* Start the two tasks as described in the comments at the top of this
|
||||
file. */
|
||||
xTaskCreate( prvQueueReceiveTask, /* The function that implements the task. */
|
||||
"Rx", /* The text name assigned to the task - for debug only as it is not used by the kernel. */
|
||||
configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */
|
||||
NULL, /* The parameter passed to the task - not used in this simple case. */
|
||||
mainQUEUE_RECEIVE_TASK_PRIORITY,/* The priority assigned to the task. */
|
||||
NULL ); /* The task handle is not required, so NULL is passed. */
|
||||
|
||||
xTaskCreate( prvQueueSendTask, "TX", configMINIMAL_STACK_SIZE, NULL, mainQUEUE_SEND_TASK_PRIORITY, NULL );
|
||||
|
||||
/* Create the software timer, but don't start it yet. */
|
||||
xTimer = xTimerCreate( "Timer", /* The text name assigned to the software timer - for debug only as it is not used by the kernel. */
|
||||
xTimerPeriod, /* The period of the software timer in ticks. */
|
||||
pdTRUE, /* xAutoReload is set to pdTRUE, so this timer goes off periodically with a period of xTimerPeriod ticks. */
|
||||
NULL, /* The timer's ID is not used. */
|
||||
prvQueueSendTimerCallback );/* The function executed when the timer expires. */
|
||||
|
||||
xTimerStart( xTimer, 0 ); /* The scheduler has not started so use a block time of 0. */
|
||||
|
||||
/* Start the tasks and timer running. */
|
||||
vTaskStartScheduler();
|
||||
}
|
||||
|
||||
/* If all is well, the scheduler will now be running, and the following
|
||||
line will never be reached. If the following line does execute, then
|
||||
there was insufficient FreeRTOS heap memory available for the idle and/or
|
||||
timer tasks to be created. See the memory management section on the
|
||||
FreeRTOS web site for more details. */
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvQueueSendTask( void *pvParameters )
|
||||
{
|
||||
TickType_t xNextWakeTime;
|
||||
const TickType_t xBlockTime = mainTASK_SEND_FREQUENCY_MS;
|
||||
const uint32_t ulValueToSend = mainVALUE_SENT_FROM_TASK;
|
||||
|
||||
/* Prevent the compiler warning about the unused parameter. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Initialise xNextWakeTime - this only needs to be done once. */
|
||||
xNextWakeTime = xTaskGetTickCount();
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Place this task in the blocked state until it is time to run again.
|
||||
The block time is specified in ticks, pdMS_TO_TICKS() was used to
|
||||
convert a time specified in milliseconds into a time specified in ticks.
|
||||
While in the Blocked state this task will not consume any CPU time. */
|
||||
vTaskDelayUntil( &xNextWakeTime, xBlockTime );
|
||||
|
||||
/* Send to the queue - causing the queue receive task to unblock and
|
||||
write to the console. 0 is used as the block time so the send operation
|
||||
will not block - it shouldn't need to block as the queue should always
|
||||
have at least one space at this point in the code. */
|
||||
xQueueSend( xQueue, &ulValueToSend, 0U );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvQueueSendTimerCallback( TimerHandle_t xTimerHandle )
|
||||
{
|
||||
const uint32_t ulValueToSend = mainVALUE_SENT_FROM_TIMER;
|
||||
|
||||
/* This is the software timer callback function. The software timer has a
|
||||
period of two seconds and is reset each time a key is pressed. This
|
||||
callback function will execute if the timer expires, which will only happen
|
||||
if a key is not pressed for two seconds. */
|
||||
|
||||
/* Avoid compiler warnings resulting from the unused parameter. */
|
||||
( void ) xTimerHandle;
|
||||
|
||||
/* Send to the queue - causing the queue receive task to unblock and
|
||||
write out a message. This function is called from the timer/daemon task, so
|
||||
must not block. Hence the block time is set to 0. */
|
||||
xQueueSend( xQueue, &ulValueToSend, 0U );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvQueueReceiveTask( void *pvParameters )
|
||||
{
|
||||
uint32_t ulReceivedValue;
|
||||
|
||||
/* Prevent the compiler warning about the unused parameter. */
|
||||
( void ) pvParameters;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Wait until something arrives in the queue - this task will block
|
||||
indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
|
||||
FreeRTOSConfig.h. It will not use any CPU time while it is in the
|
||||
Blocked state. */
|
||||
xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );
|
||||
|
||||
/* Enter critical section to use printf. Not doing this could potentially cause
|
||||
a deadlock if the FreeRTOS simulator switches contexts and another task
|
||||
tries to call printf - it should be noted that use of printf within
|
||||
the FreeRTOS simulator is unsafe, but used here for simplicity. */
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
/* To get here something must have been received from the queue, but
|
||||
is it an expected value? Normally calling printf() from a task is not
|
||||
a good idea. Here there is lots of stack space and only one task is
|
||||
using console IO so it is ok. However, note the comments at the top of
|
||||
this file about the risks of making Windows system calls (such as
|
||||
console output) from a FreeRTOS task. */
|
||||
if (ulReceivedValue == mainVALUE_SENT_FROM_TASK)
|
||||
{
|
||||
printf("Message received from task - idle time %llu%%\r\n", ulTaskGetIdleRunTimePercent());
|
||||
}
|
||||
else if (ulReceivedValue == mainVALUE_SENT_FROM_TIMER)
|
||||
{
|
||||
printf("Message received from software timer\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unexpected message\r\n");
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Called from prvKeyboardInterruptSimulatorTask(), which is defined in main.c. */
|
||||
void vBlinkyKeyboardInterruptHandler( int xKeyPressed )
|
||||
{
|
||||
/* Handle keyboard input. */
|
||||
switch ( xKeyPressed )
|
||||
{
|
||||
case mainRESET_TIMER_KEY:
|
||||
|
||||
if ( xTimer != NULL )
|
||||
{
|
||||
/* Critical section around printf to prevent a deadlock
|
||||
on context switch. */
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
printf("\r\nResetting software timer.\r\n\r\n");
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
/* Reset the software timer. */
|
||||
xTimerReset( xTimer, portMAX_DELAY );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
816
kernel/FreeRTOS/Demo/WIN32-MSVC/main_full.c
Normal file
816
kernel/FreeRTOS/Demo/WIN32-MSVC/main_full.c
Normal file
@ -0,0 +1,816 @@
|
||||
/*
|
||||
* FreeRTOS V202212.01
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* NOTE 1: The Win32 port is a simulation (or is that emulation?) only! Do not
|
||||
* expect to get real time behaviour from the Win32 port or this demo
|
||||
* application. It is provided as a convenient development and demonstration
|
||||
* test bed only.
|
||||
*
|
||||
* Windows will not be running the FreeRTOS simulator threads continuously, so
|
||||
* the timing information in the FreeRTOS+Trace logs have no meaningful units.
|
||||
* See the documentation page for the Windows simulator for an explanation of
|
||||
* the slow timing:
|
||||
* https://www.FreeRTOS.org/FreeRTOS-Windows-Simulator-Emulator-for-Visual-Studio-and-Eclipse-MingW.html
|
||||
* - READ THE WEB DOCUMENTATION FOR THIS PORT FOR MORE INFORMATION ON USING IT -
|
||||
*
|
||||
* NOTE 2: This project provides two demo applications. A simple blinky style
|
||||
* project, and a more comprehensive test and demo application. The
|
||||
* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select
|
||||
* between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY
|
||||
* in main.c. This file implements the comprehensive test and demo version.
|
||||
*
|
||||
* NOTE 3: This file only contains the source code that is specific to the
|
||||
* full demo. Generic functions, such FreeRTOS hook functions, are defined in
|
||||
* main.c.
|
||||
*******************************************************************************
|
||||
*
|
||||
* main() creates all the demo application tasks, then starts the scheduler.
|
||||
* The web documentation provides more details of the standard demo application
|
||||
* tasks, which provide no particular functionality but do provide a good
|
||||
* example of how to use the FreeRTOS API.
|
||||
*
|
||||
* In addition to the standard demo tasks, the following tasks and tests are
|
||||
* defined and/or created within this file:
|
||||
*
|
||||
* "Check" task - This only executes every five seconds but has a high priority
|
||||
* to ensure it gets processor time. Its main function is to check that all the
|
||||
* standard demo tasks are still operational. While no errors have been
|
||||
* discovered the check task will print out "OK" and the current simulated tick
|
||||
* time. If an error is discovered in the execution of a task then the check
|
||||
* task will print out an appropriate error message.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Kernel includes. */
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <queue.h>
|
||||
#include <timers.h>
|
||||
#include <semphr.h>
|
||||
|
||||
/* Standard demo includes. */
|
||||
#include "BlockQ.h"
|
||||
#include "integer.h"
|
||||
#include "semtest.h"
|
||||
#include "PollQ.h"
|
||||
#include "GenQTest.h"
|
||||
#include "QPeek.h"
|
||||
#include "recmutex.h"
|
||||
#include "flop.h"
|
||||
#include "TimerDemo.h"
|
||||
#include "countsem.h"
|
||||
#include "death.h"
|
||||
#include "dynamic.h"
|
||||
#include "QueueSet.h"
|
||||
#include "QueueOverwrite.h"
|
||||
#include "EventGroupsDemo.h"
|
||||
#include "IntSemTest.h"
|
||||
#include "TaskNotify.h"
|
||||
#include "TaskNotifyArray.h"
|
||||
#include "QueueSetPolling.h"
|
||||
#include "StaticAllocation.h"
|
||||
#include "blocktim.h"
|
||||
#include "AbortDelay.h"
|
||||
#include "MessageBufferDemo.h"
|
||||
#include "StreamBufferDemo.h"
|
||||
#include "StreamBufferInterrupt.h"
|
||||
#include "MessageBufferAMP.h"
|
||||
|
||||
/* Priorities at which the tasks are created. */
|
||||
#define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
|
||||
#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
#define mainFLOP_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
#define mainQUEUE_OVERWRITE_PRIORITY ( tskIDLE_PRIORITY )
|
||||
|
||||
#define mainTIMER_TEST_PERIOD ( 50 )
|
||||
|
||||
/* Task function prototypes. */
|
||||
static void prvCheckTask( void *pvParameters );
|
||||
|
||||
/* A task that is created from the idle task to test the functionality of
|
||||
eTaskStateGet(). */
|
||||
static void prvTestTask( void *pvParameters );
|
||||
|
||||
/*
|
||||
* Called from the idle task hook function to demonstrate a few utility
|
||||
* functions that are not demonstrated by any of the standard demo tasks.
|
||||
*/
|
||||
static void prvDemonstrateTaskStateAndHandleGetFunctions( void );
|
||||
|
||||
/*
|
||||
* Called from the idle task hook function to demonstrate the use of
|
||||
* xTimerPendFunctionCall() as xTimerPendFunctionCall() is not demonstrated by
|
||||
* any of the standard demo tasks.
|
||||
*/
|
||||
static void prvDemonstratePendingFunctionCall( void );
|
||||
|
||||
/*
|
||||
* The function that is pended by prvDemonstratePendingFunctionCall().
|
||||
*/
|
||||
static void prvPendedFunction( void *pvParameter1, uint32_t ulParameter2 );
|
||||
|
||||
/*
|
||||
* prvDemonstrateTimerQueryFunctions() is called from the idle task hook
|
||||
* function to demonstrate the use of functions that query information about a
|
||||
* software timer. prvTestTimerCallback() is the callback function for the
|
||||
* timer being queried.
|
||||
*/
|
||||
static void prvDemonstrateTimerQueryFunctions( void );
|
||||
static void prvTestTimerCallback( TimerHandle_t xTimer );
|
||||
|
||||
/*
|
||||
* A task to demonstrate the use of the xQueueSpacesAvailable() function.
|
||||
*/
|
||||
static void prvDemoQueueSpaceFunctions( void *pvParameters );
|
||||
|
||||
/*
|
||||
* Tasks that ensure indefinite delays are truly indefinite.
|
||||
*/
|
||||
static void prvPermanentlyBlockingSemaphoreTask( void *pvParameters );
|
||||
static void prvPermanentlyBlockingNotificationTask( void *pvParameters );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The variable into which error messages are latched. */
|
||||
static char *pcStatusMessage = "No errors";
|
||||
|
||||
/* This semaphore is created purely to test using the vSemaphoreDelete() and
|
||||
semaphore tracing API functions. It has no other purpose. */
|
||||
static SemaphoreHandle_t xMutexToDelete = NULL;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int main_full( void )
|
||||
{
|
||||
/* Start the check task as described at the top of this file. */
|
||||
xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
|
||||
|
||||
/* Create the standard demo tasks. */
|
||||
vStartTaskNotifyTask();
|
||||
vStartTaskNotifyArrayTask();
|
||||
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
|
||||
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
|
||||
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
|
||||
vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
|
||||
vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
|
||||
vStartQueuePeekTasks();
|
||||
vStartMathTasks( mainFLOP_TASK_PRIORITY );
|
||||
vStartRecursiveMutexTasks();
|
||||
vStartCountingSemaphoreTasks();
|
||||
vStartDynamicPriorityTasks();
|
||||
vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );
|
||||
vStartEventGroupTasks();
|
||||
vStartInterruptSemaphoreTasks();
|
||||
vCreateBlockTimeTasks();
|
||||
vCreateAbortDelayTasks();
|
||||
xTaskCreate( prvDemoQueueSpaceFunctions, "QSpace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
xTaskCreate( prvPermanentlyBlockingSemaphoreTask, "BlockSem", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
xTaskCreate( prvPermanentlyBlockingNotificationTask, "BlockNoti", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
|
||||
vStartMessageBufferTasks( configMINIMAL_STACK_SIZE );
|
||||
vStartStreamBufferTasks();
|
||||
vStartStreamBufferInterruptDemo();
|
||||
vStartMessageBufferAMPTasks( configMINIMAL_STACK_SIZE );
|
||||
|
||||
#if( configUSE_QUEUE_SETS == 1 )
|
||||
{
|
||||
vStartQueueSetTasks();
|
||||
vStartQueueSetPollingTask();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
{
|
||||
vStartStaticallyAllocatedTasks();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if( configUSE_PREEMPTION != 0 )
|
||||
{
|
||||
/* Don't expect these tasks to pass when preemption is not used. */
|
||||
vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
|
||||
}
|
||||
#endif
|
||||
|
||||
/* The suicide tasks must be created last as they need to know how many
|
||||
tasks were running prior to their creation. This then allows them to
|
||||
ascertain whether or not the correct/expected number of tasks are running at
|
||||
any given time. */
|
||||
vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
|
||||
|
||||
/* Create the semaphore that will be deleted in the idle task hook. This
|
||||
is done purely to test the use of vSemaphoreDelete(). */
|
||||
xMutexToDelete = xSemaphoreCreateMutex();
|
||||
|
||||
/* Start the scheduler itself. */
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* Should never get here unless there was not enough heap space to create
|
||||
the idle and other system tasks. */
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCheckTask( void *pvParameters )
|
||||
{
|
||||
TickType_t xNextWakeTime;
|
||||
const TickType_t xCycleFrequency = pdMS_TO_TICKS( 5000UL );
|
||||
HeapStats_t xHeapStats;
|
||||
|
||||
/* Just to remove compiler warning. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Initialise xNextWakeTime - this only needs to be done once. */
|
||||
xNextWakeTime = xTaskGetTickCount();
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Place this task in the blocked state until it is time to run again. */
|
||||
vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );
|
||||
|
||||
/* Check the standard demo tasks are running without error. */
|
||||
#if( configUSE_PREEMPTION != 0 )
|
||||
{
|
||||
/* These tasks are only created when preemption is used. */
|
||||
if( xAreTimerDemoTasksStillRunning( xCycleFrequency ) != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: TimerDemo";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( xAreStreamBufferTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: StreamBuffer";
|
||||
}
|
||||
else if( xAreMessageBufferTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: MessageBuffer";
|
||||
}
|
||||
else if( xAreTaskNotificationTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: Notification";
|
||||
}
|
||||
else if( xAreTaskNotificationArrayTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: NotificationArray";
|
||||
}
|
||||
else if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: IntSem";
|
||||
}
|
||||
else if( xAreEventGroupTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: EventGroup";
|
||||
}
|
||||
else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: IntMath";
|
||||
}
|
||||
else if( xAreGenericQueueTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: GenQueue";
|
||||
}
|
||||
else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: QueuePeek";
|
||||
}
|
||||
else if( xAreBlockingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: BlockQueue";
|
||||
}
|
||||
else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: SemTest";
|
||||
}
|
||||
else if( xArePollingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: PollQueue";
|
||||
}
|
||||
else if( xAreMathsTaskStillRunning() != pdPASS )
|
||||
{
|
||||
pcStatusMessage = "Error: Flop";
|
||||
}
|
||||
else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: RecMutex";
|
||||
}
|
||||
else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: CountSem";
|
||||
}
|
||||
else if( xIsCreateTaskStillRunning() != pdTRUE )
|
||||
{
|
||||
pcStatusMessage = "Error: Death";
|
||||
}
|
||||
else if( xAreDynamicPriorityTasksStillRunning() != pdPASS )
|
||||
{
|
||||
pcStatusMessage = "Error: Dynamic";
|
||||
}
|
||||
else if( xIsQueueOverwriteTaskStillRunning() != pdPASS )
|
||||
{
|
||||
pcStatusMessage = "Error: Queue overwrite";
|
||||
}
|
||||
else if( xAreBlockTimeTestTasksStillRunning() != pdPASS )
|
||||
{
|
||||
pcStatusMessage = "Error: Block time";
|
||||
}
|
||||
else if( xAreAbortDelayTestTasksStillRunning() != pdPASS )
|
||||
{
|
||||
pcStatusMessage = "Error: Abort delay";
|
||||
}
|
||||
else if( xIsInterruptStreamBufferDemoStillRunning() != pdPASS )
|
||||
{
|
||||
pcStatusMessage = "Error: Stream buffer interrupt";
|
||||
}
|
||||
else if( xAreMessageBufferAMPTasksStillRunning() != pdPASS )
|
||||
{
|
||||
pcStatusMessage = "Error: Message buffer AMP";
|
||||
}
|
||||
|
||||
#if( configUSE_QUEUE_SETS == 1 )
|
||||
else if( xAreQueueSetTasksStillRunning() != pdPASS )
|
||||
{
|
||||
pcStatusMessage = "Error: Queue set";
|
||||
}
|
||||
else if( xAreQueueSetPollTasksStillRunning() != pdPASS )
|
||||
{
|
||||
pcStatusMessage = "Error: Queue set polling";
|
||||
}
|
||||
#endif
|
||||
|
||||
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
else if( xAreStaticAllocationTasksStillRunning() != pdPASS )
|
||||
{
|
||||
pcStatusMessage = "Error: Static allocation";
|
||||
}
|
||||
#endif /* configSUPPORT_STATIC_ALLOCATION */
|
||||
|
||||
/* This is the only task that uses stdout so its ok to call printf()
|
||||
directly. */
|
||||
vPortGetHeapStats( &xHeapStats );
|
||||
|
||||
configASSERT( xHeapStats.xAvailableHeapSpaceInBytes == xPortGetFreeHeapSize() );
|
||||
configASSERT( xHeapStats.xMinimumEverFreeBytesRemaining == xPortGetMinimumEverFreeHeapSize() );
|
||||
|
||||
printf( "%s - tick count %zu - free heap %zu - min free heap %zu - largest free block %zu - idle time %llu%%\r\n",
|
||||
pcStatusMessage,
|
||||
xTaskGetTickCount(),
|
||||
xHeapStats.xAvailableHeapSpaceInBytes,
|
||||
xHeapStats.xMinimumEverFreeBytesRemaining,
|
||||
xHeapStats.xSizeOfLargestFreeBlockInBytes,
|
||||
ulTaskGetIdleRunTimePercent() );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvTestTask( void *pvParameters )
|
||||
{
|
||||
const unsigned long ulMSToSleep = 5;
|
||||
|
||||
/* Just to remove compiler warnings. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* This task is just used to test the eTaskStateGet() function. It
|
||||
does not have anything to do. */
|
||||
for( ;; )
|
||||
{
|
||||
/* Sleep to reduce CPU load, but don't sleep indefinitely in case there are
|
||||
tasks waiting to be terminated by the idle task. */
|
||||
Sleep( ulMSToSleep );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Called from vApplicationIdleHook(), which is defined in main.c. */
|
||||
void vFullDemoIdleFunction( void )
|
||||
{
|
||||
const unsigned long ulMSToSleep = 15;
|
||||
void *pvAllocated;
|
||||
|
||||
/* Sleep to reduce CPU load, but don't sleep indefinitely in case there are
|
||||
tasks waiting to be terminated by the idle task. */
|
||||
Sleep( ulMSToSleep );
|
||||
|
||||
/* Demonstrate a few utility functions that are not demonstrated by any of
|
||||
the standard demo tasks. */
|
||||
prvDemonstrateTaskStateAndHandleGetFunctions();
|
||||
|
||||
/* Demonstrate the use of xTimerPendFunctionCall(), which is not
|
||||
demonstrated by any of the standard demo tasks. */
|
||||
prvDemonstratePendingFunctionCall();
|
||||
|
||||
/* Demonstrate the use of functions that query information about a software
|
||||
timer. */
|
||||
prvDemonstrateTimerQueryFunctions();
|
||||
|
||||
|
||||
/* If xMutexToDelete has not already been deleted, then delete it now.
|
||||
This is done purely to demonstrate the use of, and test, the
|
||||
vSemaphoreDelete() macro. Care must be taken not to delete a semaphore
|
||||
that has tasks blocked on it. */
|
||||
if( xMutexToDelete != NULL )
|
||||
{
|
||||
/* For test purposes, add the mutex to the registry, then remove it
|
||||
again, before it is deleted - checking its name is as expected before
|
||||
and after the assertion into the registry and its removal from the
|
||||
registry. */
|
||||
configASSERT( pcQueueGetName( xMutexToDelete ) == NULL );
|
||||
vQueueAddToRegistry( xMutexToDelete, "Test_Mutex" );
|
||||
configASSERT( strcmp( pcQueueGetName( xMutexToDelete ), "Test_Mutex" ) == 0 );
|
||||
vQueueUnregisterQueue( xMutexToDelete );
|
||||
configASSERT( pcQueueGetName( xMutexToDelete ) == NULL );
|
||||
|
||||
vSemaphoreDelete( xMutexToDelete );
|
||||
xMutexToDelete = NULL;
|
||||
}
|
||||
|
||||
/* Exercise heap_5 a bit. The malloc failed hook will trap failed
|
||||
allocations so there is no need to test here. */
|
||||
pvAllocated = pvPortMalloc( ( rand() % 500 ) + 1 );
|
||||
vPortFree( pvAllocated );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Called by vApplicationTickHook(), which is defined in main.c. */
|
||||
void vFullDemoTickHookFunction( void )
|
||||
{
|
||||
TaskHandle_t xTimerTask;
|
||||
|
||||
/* Call the periodic timer test, which tests the timer API functions that
|
||||
can be called from an ISR. */
|
||||
#if( configUSE_PREEMPTION != 0 )
|
||||
{
|
||||
/* Only created when preemption is used. */
|
||||
vTimerPeriodicISRTests();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Call the periodic queue overwrite from ISR demo. */
|
||||
vQueueOverwritePeriodicISRDemo();
|
||||
|
||||
#if( configUSE_QUEUE_SETS == 1 ) /* Remove the tests if queue sets are not defined. */
|
||||
{
|
||||
/* Write to a queue that is in use as part of the queue set demo to
|
||||
demonstrate using queue sets from an ISR. */
|
||||
vQueueSetAccessQueueSetFromISR();
|
||||
vQueueSetPollingInterruptAccess();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Exercise event groups from interrupts. */
|
||||
vPeriodicEventGroupsProcessing();
|
||||
|
||||
/* Exercise giving mutexes from an interrupt. */
|
||||
vInterruptSemaphorePeriodicTest();
|
||||
|
||||
/* Exercise using task notifications from an interrupt. */
|
||||
xNotifyTaskFromISR();
|
||||
xNotifyArrayTaskFromISR();
|
||||
|
||||
/* Writes to stream buffer byte by byte to test the stream buffer trigger
|
||||
level functionality. */
|
||||
vPeriodicStreamBufferProcessing();
|
||||
|
||||
/* Writes a string to a string buffer four bytes at a time to demonstrate
|
||||
a stream being sent from an interrupt to a task. */
|
||||
vBasicStreamBufferSendFromISR();
|
||||
|
||||
/* For code coverage purposes. */
|
||||
xTimerTask = xTimerGetTimerDaemonTaskHandle();
|
||||
configASSERT( uxTaskPriorityGetFromISR( xTimerTask ) == configTIMER_TASK_PRIORITY );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvPendedFunction( void *pvParameter1, uint32_t ulParameter2 )
|
||||
{
|
||||
static uint32_t ulLastParameter1 = 1000UL, ulLastParameter2 = 0UL;
|
||||
uint32_t ulParameter1;
|
||||
|
||||
ulParameter1 = ( uint32_t ) pvParameter1;
|
||||
|
||||
/* Ensure the parameters are as expected. */
|
||||
configASSERT( ulParameter1 == ( ulLastParameter1 + 1 ) );
|
||||
configASSERT( ulParameter2 == ( ulLastParameter2 + 1 ) );
|
||||
|
||||
/* Remember the parameters for the next time the function is called. */
|
||||
ulLastParameter1 = ulParameter1;
|
||||
ulLastParameter2 = ulParameter2;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvTestTimerCallback( TimerHandle_t xTimer )
|
||||
{
|
||||
/* This is the callback function for the timer accessed by
|
||||
prvDemonstrateTimerQueryFunctions(). The callback does not do anything. */
|
||||
( void ) xTimer;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvDemonstrateTimerQueryFunctions( void )
|
||||
{
|
||||
static TimerHandle_t xTimer = NULL;
|
||||
const char *pcTimerName = "TestTimer";
|
||||
volatile TickType_t xExpiryTime;
|
||||
const TickType_t xDontBlock = 0;
|
||||
|
||||
if( xTimer == NULL )
|
||||
{
|
||||
xTimer = xTimerCreate( pcTimerName, portMAX_DELAY, pdTRUE, NULL, prvTestTimerCallback );
|
||||
|
||||
if( xTimer != NULL )
|
||||
{
|
||||
/* Called from the idle task so a block time must not be
|
||||
specified. */
|
||||
xTimerStart( xTimer, xDontBlock );
|
||||
}
|
||||
}
|
||||
|
||||
if( xTimer != NULL )
|
||||
{
|
||||
/* Demonstrate querying a timer's name. */
|
||||
configASSERT( strcmp( pcTimerGetName( xTimer ), pcTimerName ) == 0 );
|
||||
|
||||
/* Demonstrate querying a timer's period. */
|
||||
configASSERT( xTimerGetPeriod( xTimer ) == portMAX_DELAY );
|
||||
|
||||
/* Demonstrate querying a timer's next expiry time, although nothing is
|
||||
done with the returned value. Note if the expiry time is less than the
|
||||
maximum tick count then the expiry time has overflowed from the current
|
||||
time. In this case the expiry time was set to portMAX_DELAY, so it is
|
||||
expected to be less than the current time until the current time has
|
||||
itself overflowed. */
|
||||
xExpiryTime = xTimerGetExpiryTime( xTimer );
|
||||
( void ) xExpiryTime;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvDemonstratePendingFunctionCall( void )
|
||||
{
|
||||
static uint32_t ulParameter1 = 1000UL, ulParameter2 = 0UL;
|
||||
const TickType_t xDontBlock = 0; /* This is called from the idle task so must *not* attempt to block. */
|
||||
|
||||
/* prvPendedFunction() just expects the parameters to be incremented by one
|
||||
each time it is called. */
|
||||
ulParameter1++;
|
||||
ulParameter2++;
|
||||
|
||||
/* Pend the function call, sending the parameters. */
|
||||
xTimerPendFunctionCall( prvPendedFunction, ( void * ) ulParameter1, ulParameter2, xDontBlock );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvDemonstrateTaskStateAndHandleGetFunctions( void )
|
||||
{
|
||||
TaskHandle_t xIdleTaskHandle, xTimerTaskHandle;
|
||||
char *pcTaskName;
|
||||
static portBASE_TYPE xPerformedOneShotTests = pdFALSE;
|
||||
TaskHandle_t xTestTask;
|
||||
TaskStatus_t xTaskInfo;
|
||||
extern StackType_t uxTimerTaskStack[];
|
||||
|
||||
/* Demonstrate the use of the xTimerGetTimerDaemonTaskHandle() and
|
||||
xTaskGetIdleTaskHandle() functions. Also try using the function that sets
|
||||
the task number. */
|
||||
xIdleTaskHandle = xTaskGetIdleTaskHandle();
|
||||
xTimerTaskHandle = xTimerGetTimerDaemonTaskHandle();
|
||||
|
||||
/* This is the idle hook, so the current task handle should equal the
|
||||
returned idle task handle. */
|
||||
if( xTaskGetCurrentTaskHandle() != xIdleTaskHandle )
|
||||
{
|
||||
pcStatusMessage = "Error: Returned idle task handle was incorrect";
|
||||
}
|
||||
|
||||
/* Check the same handle is obtained using the idle task's name. First try
|
||||
with the wrong name, then the right name. */
|
||||
if( xTaskGetHandle( "Idle" ) == xIdleTaskHandle )
|
||||
{
|
||||
pcStatusMessage = "Error: Returned handle for name Idle was incorrect";
|
||||
}
|
||||
|
||||
if( xTaskGetHandle( "IDLE" ) != xIdleTaskHandle )
|
||||
{
|
||||
pcStatusMessage = "Error: Returned handle for name Idle was incorrect";
|
||||
}
|
||||
|
||||
/* Check the timer task handle was returned correctly. */
|
||||
pcTaskName = pcTaskGetName( xTimerTaskHandle );
|
||||
if( strcmp( pcTaskName, "Tmr Svc" ) != 0 )
|
||||
{
|
||||
pcStatusMessage = "Error: Returned timer task handle was incorrect";
|
||||
}
|
||||
|
||||
if( xTaskGetHandle( "Tmr Svc" ) != xTimerTaskHandle )
|
||||
{
|
||||
pcStatusMessage = "Error: Returned handle for name Tmr Svc was incorrect";
|
||||
}
|
||||
|
||||
/* This task is running, make sure it's state is returned as running. */
|
||||
if( eTaskStateGet( xIdleTaskHandle ) != eRunning )
|
||||
{
|
||||
pcStatusMessage = "Error: Returned idle task state was incorrect";
|
||||
}
|
||||
|
||||
/* If this task is running, then the timer task must be blocked. */
|
||||
if( eTaskStateGet( xTimerTaskHandle ) != eBlocked )
|
||||
{
|
||||
pcStatusMessage = "Error: Returned timer task state was incorrect";
|
||||
}
|
||||
|
||||
/* Also with the vTaskGetInfo() function. */
|
||||
vTaskGetInfo( xTimerTaskHandle, /* The task being queried. */
|
||||
&xTaskInfo, /* The structure into which information on the task will be written. */
|
||||
pdTRUE, /* Include the task's high watermark in the structure. */
|
||||
eInvalid ); /* Include the task state in the structure. */
|
||||
|
||||
/* Check the information returned by vTaskGetInfo() is as expected. */
|
||||
if( ( xTaskInfo.eCurrentState != eBlocked ) ||
|
||||
( strcmp( xTaskInfo.pcTaskName, "Tmr Svc" ) != 0 ) ||
|
||||
( xTaskInfo.uxCurrentPriority != configTIMER_TASK_PRIORITY ) ||
|
||||
( xTaskInfo.pxStackBase != uxTimerTaskStack ) ||
|
||||
( xTaskInfo.xHandle != xTimerTaskHandle ) )
|
||||
{
|
||||
pcStatusMessage = "Error: vTaskGetInfo() returned incorrect information about the timer task";
|
||||
}
|
||||
|
||||
/* Other tests that should only be performed once follow. The test task
|
||||
is not created on each iteration because to do so would cause the death
|
||||
task to report an error (too many tasks running). */
|
||||
if( xPerformedOneShotTests == pdFALSE )
|
||||
{
|
||||
/* Don't run this part of the test again. */
|
||||
xPerformedOneShotTests = pdTRUE;
|
||||
|
||||
/* Create a test task to use to test other eTaskStateGet() return values. */
|
||||
if( xTaskCreate( prvTestTask, "Test", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, &xTestTask ) == pdPASS )
|
||||
{
|
||||
/* If this task is running, the test task must be in the ready state. */
|
||||
if( eTaskStateGet( xTestTask ) != eReady )
|
||||
{
|
||||
pcStatusMessage = "Error: Returned test task state was incorrect 1";
|
||||
}
|
||||
|
||||
/* Now suspend the test task and check its state is reported correctly. */
|
||||
vTaskSuspend( xTestTask );
|
||||
if( eTaskStateGet( xTestTask ) != eSuspended )
|
||||
{
|
||||
pcStatusMessage = "Error: Returned test task state was incorrect 2";
|
||||
}
|
||||
|
||||
/* Now delete the task and check its state is reported correctly. */
|
||||
vTaskDelete( xTestTask );
|
||||
if( eTaskStateGet( xTestTask ) != eDeleted )
|
||||
{
|
||||
pcStatusMessage = "Error: Returned test task state was incorrect 3";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvDemoQueueSpaceFunctions( void *pvParameters )
|
||||
{
|
||||
QueueHandle_t xQueue = NULL;
|
||||
const unsigned portBASE_TYPE uxQueueLength = 10;
|
||||
unsigned portBASE_TYPE uxReturn, x;
|
||||
|
||||
/* Remove compiler warnings. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Create the queue that will be used. Nothing is actually going to be
|
||||
sent or received so the queue item size is set to 0. */
|
||||
xQueue = xQueueCreate( uxQueueLength, 0 );
|
||||
configASSERT( xQueue );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
for( x = 0; x < uxQueueLength; x++ )
|
||||
{
|
||||
/* Ask how many messages are available... */
|
||||
uxReturn = uxQueueMessagesWaiting( xQueue );
|
||||
|
||||
/* Check the number of messages being reported as being available
|
||||
is as expected, and force an assert if not. */
|
||||
if( uxReturn != x )
|
||||
{
|
||||
/* xQueue cannot be NULL so this is deliberately causing an
|
||||
assert to be triggered as there is an error. */
|
||||
configASSERT( xQueue == NULL );
|
||||
}
|
||||
|
||||
/* Ask how many spaces remain in the queue... */
|
||||
uxReturn = uxQueueSpacesAvailable( xQueue );
|
||||
|
||||
/* Check the number of spaces being reported as being available
|
||||
is as expected, and force an assert if not. */
|
||||
if( uxReturn != ( uxQueueLength - x ) )
|
||||
{
|
||||
/* xQueue cannot be NULL so this is deliberately causing an
|
||||
assert to be triggered as there is an error. */
|
||||
configASSERT( xQueue == NULL );
|
||||
}
|
||||
|
||||
/* Fill one more space in the queue. */
|
||||
xQueueSendToBack( xQueue, NULL, 0 );
|
||||
}
|
||||
|
||||
/* Perform the same check while the queue is full. */
|
||||
uxReturn = uxQueueMessagesWaiting( xQueue );
|
||||
if( uxReturn != uxQueueLength )
|
||||
{
|
||||
configASSERT( xQueue == NULL );
|
||||
}
|
||||
|
||||
uxReturn = uxQueueSpacesAvailable( xQueue );
|
||||
|
||||
if( uxReturn != 0 )
|
||||
{
|
||||
configASSERT( xQueue == NULL );
|
||||
}
|
||||
|
||||
/* The queue is full, start again. */
|
||||
xQueueReset( xQueue );
|
||||
|
||||
#if( configUSE_PREEMPTION == 0 )
|
||||
taskYIELD();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvPermanentlyBlockingSemaphoreTask( void *pvParameters )
|
||||
{
|
||||
SemaphoreHandle_t xSemaphore;
|
||||
|
||||
/* Prevent compiler warning about unused parameter in the case that
|
||||
configASSERT() is not defined. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* This task should block on a semaphore, and never return. */
|
||||
xSemaphore = xSemaphoreCreateBinary();
|
||||
configASSERT( xSemaphore );
|
||||
|
||||
xSemaphoreTake( xSemaphore, portMAX_DELAY );
|
||||
|
||||
/* The above xSemaphoreTake() call should never return, force an assert if
|
||||
it does. */
|
||||
configASSERT( pvParameters != NULL );
|
||||
vTaskDelete( NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvPermanentlyBlockingNotificationTask( void *pvParameters )
|
||||
{
|
||||
/* Prevent compiler warning about unused parameter in the case that
|
||||
configASSERT() is not defined. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* This task should block on a task notification, and never return. */
|
||||
ulTaskNotifyTake( pdTRUE, portMAX_DELAY );
|
||||
|
||||
/* The above ulTaskNotifyTake() call should never return, force an assert
|
||||
if it does. */
|
||||
configASSERT( pvParameters != NULL );
|
||||
vTaskDelete( NULL );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user