Fix formatting in kernel demo application files (#1148)

* Fix formatting in kernel demo application files

* Fix header check fail in the demo files

* Add ignored patterns in core header check file

* Fix formatting

* Update vApplicationStackOverflowHook for AVR_ATMega4809_MPLAB.X/main.c

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>

* Update vApplicationStackOverflowHook for AVR_ATMega4809_MPLAB.X/main.c

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>

* Update vApplicationStackOverflowHook for AVR_Dx_IAR/main.c

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>

* Update vApplicationStackOverflowHook for AVR_Dx_IAR/main.c

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>

* Update vApplicationStackOverflowHook for AVR_Dx_MPLAB.X/main.c

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>

* Update vApplicationMallocFailedHook for AVR_Dx_MPLAB.X/main.c

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>

* Fix formatting AVR32_UC3

---------

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
This commit is contained in:
Rahul Kar 2024-01-02 11:05:59 +05:30 committed by GitHub
parent 85ed21bcfb
commit 121fbe295b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
169 changed files with 22211 additions and 21557 deletions

View file

@ -1,6 +1,6 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* 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
@ -52,18 +52,18 @@
#pragma config CP = OFF, BWP = OFF, PWP = OFF
/* Additional config fuse settings for other supported processors */
#if defined(__32MX460F512L__)
#pragma config UPLLEN = OFF
#elif defined(__32MX795F512L__)
#pragma config UPLLEN = OFF
#pragma config FSRSSEL = PRIORITY_7
#if defined( __32MX460F512L__ )
#pragma config UPLLEN = OFF
#elif defined( __32MX795F512L__ )
#pragma config UPLLEN = OFF
#pragma config FSRSSEL = PRIORITY_7
#endif
/*-----------------------------------------------------------*/
/* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,
or 0 to run the more comprehensive test and demo application. */
#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0
* or 0 to run the more comprehensive test and demo application. */
#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0
/*-----------------------------------------------------------*/
@ -86,118 +86,129 @@ extern void main_full( void );
*/
int main( void )
{
/* Prepare the hardware to run this demo. */
prvSetupHardware();
/* Prepare the hardware to run this demo. */
prvSetupHardware();
/* 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
/* 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
return 0;
return 0;
}
/*-----------------------------------------------------------*/
static void prvSetupHardware( void )
{
/* Configure the hardware for maximum performance. */
vHardwareConfigurePerformance();
/* Configure the hardware for maximum performance. */
vHardwareConfigurePerformance();
/* Setup to use the external interrupt controller. */
vHardwareUseMultiVectoredInterrupts();
/* Setup to use the external interrupt controller. */
vHardwareUseMultiVectoredInterrupts();
portDISABLE_INTERRUPTS();
portDISABLE_INTERRUPTS();
/* Setup the digital IO for the LED's. */
vParTestInitialise();
/* Setup the digital IO for the LED's. */
vParTestInitialise();
}
/*-----------------------------------------------------------*/
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 or heap_2.c are 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). */
taskDISABLE_INTERRUPTS();
for( ;; );
/* 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 or heap_2.c are 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). */
taskDISABLE_INTERRUPTS();
for( ; ; )
{
}
}
/*-----------------------------------------------------------*/
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 the application makes use of the
vTaskDelete() API function (as this demo application does) 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 been deleted. */
/* 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 the application makes use of the
* vTaskDelete() API function (as this demo application does) 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 been deleted. */
}
/*-----------------------------------------------------------*/
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
void vApplicationStackOverflowHook( TaskHandle_t pxTask,
char * pcTaskName )
{
( void ) pcTaskName;
( void ) pxTask;
( void ) pcTaskName;
( void ) pxTask;
/* Run time task stack overflow checking is performed if
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is
called if a task stack overflow is detected. Note the system/interrupt
stack is not checked. */
taskDISABLE_INTERRUPTS();
for( ;; );
/* Run time task stack overflow checking is performed if
* configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is
* called if a task stack overflow is detected. Note the system/interrupt
* stack is not checked. */
taskDISABLE_INTERRUPTS();
for( ; ; )
{
}
}
/*-----------------------------------------------------------*/
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()). */
/* 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()). */
}
/*-----------------------------------------------------------*/
void _general_exception_handler( unsigned long ulCause, unsigned long ulStatus )
void _general_exception_handler( unsigned long ulCause,
unsigned long ulStatus )
{
/* This overrides the definition provided by the kernel. Other exceptions
should be handled here. */
for( ;; );
/* This overrides the definition provided by the kernel. Other exceptions
* should be handled here. */
for( ; ; )
{
}
}
/*-----------------------------------------------------------*/
void vAssertCalled( const char * pcFile, unsigned long ulLine )
void vAssertCalled( const char * pcFile,
unsigned long ulLine )
{
volatile unsigned long ul = 0;
volatile unsigned long ul = 0;
( void ) pcFile;
( void ) ulLine;
( void ) pcFile;
( void ) ulLine;
__asm volatile( "di" );
{
/* Set ul to a non-zero value using the debugger to step out of this
function. */
while( ul == 0 )
{
portNOP();
}
}
__asm volatile( "ei" );
__asm volatile ( "di" );
{
/* Set ul to a non-zero value using the debugger to step out of this
* function. */
while( ul == 0 )
{
portNOP();
}
}
__asm volatile ( "ei" );
}

View file

@ -1,6 +1,6 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* 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
@ -78,41 +78,41 @@
#include "partest.h"
/* Priorities at which the tasks are created. */
#define mainQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainQUEUE_SEND_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
#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 200ms value is converted
to ticks using the portTICK_PERIOD_MS constant. */
#define mainQUEUE_SEND_FREQUENCY_MS ( 200 / portTICK_PERIOD_MS )
* to ticks using the portTICK_PERIOD_MS constant. */
#define mainQUEUE_SEND_FREQUENCY_MS ( 200 / portTICK_PERIOD_MS )
/* The number of items the queue can hold. This is 1 as the receive task
will remove items as they are added, meaning the send task should always find
the queue empty. */
#define mainQUEUE_LENGTH ( 1 )
* will remove items as they are added, meaning the send task should always find
* the queue empty. */
#define mainQUEUE_LENGTH ( 1 )
/* Values passed to the two tasks just to check the task parameter
functionality. */
#define mainQUEUE_SEND_PARAMETER ( 0x1111UL )
#define mainQUEUE_RECEIVE_PARAMETER ( 0x22UL )
* functionality. */
#define mainQUEUE_SEND_PARAMETER ( 0x1111UL )
#define mainQUEUE_RECEIVE_PARAMETER ( 0x22UL )
/* The period of the blinky software timer. The period is specified in ms and
converted to ticks using the portTICK_PERIOD_MS constant. */
#define mainBLINKY_TIMER_PERIOD ( 50 / portTICK_PERIOD_MS )
* converted to ticks using the portTICK_PERIOD_MS constant. */
#define mainBLINKY_TIMER_PERIOD ( 50 / portTICK_PERIOD_MS )
/* The LED used by the communicating tasks and the blinky timer respectively. */
#define mainTASKS_LED ( 0 )
#define mainTIMER_LED ( 1 )
#define mainTASKS_LED ( 0 )
#define mainTIMER_LED ( 1 )
/* Misc. */
#define mainDONT_BLOCK ( 0 )
#define mainDONT_BLOCK ( 0 )
/*-----------------------------------------------------------*/
/*
* The tasks as described in the comments at the top of this file.
*/
static void prvQueueReceiveTask( void *pvParameters );
static void prvQueueSendTask( void *pvParameters );
static void prvQueueReceiveTask( void * pvParameters );
static void prvQueueSendTask( void * pvParameters );
/*
* The callback function for the blinky software timer, as described at the top
@ -135,109 +135,110 @@ static QueueHandle_t xQueue = NULL;
void main_blinky( void )
{
TimerHandle_t xTimer;
TimerHandle_t xTimer;
/* Create the queue. */
xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) );
/* Create the queue. */
xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) );
if( xQueue != NULL )
{
/* Create 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. */
( void * ) mainQUEUE_RECEIVE_PARAMETER, /* The parameter passed to the task - just to check the functionality. */
mainQUEUE_RECEIVE_TASK_PRIORITY, /* The priority assigned to the task. */
NULL ); /* The task handle is not required, so NULL is passed. */
if( xQueue != NULL )
{
/* Create 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. */
( void * ) mainQUEUE_RECEIVE_PARAMETER, /* The parameter passed to the task - just to check the functionality. */
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, ( void * ) mainQUEUE_SEND_PARAMETER, mainQUEUE_SEND_TASK_PRIORITY, NULL );
xTaskCreate( prvQueueSendTask, "TX", configMINIMAL_STACK_SIZE, ( void * ) mainQUEUE_SEND_PARAMETER, mainQUEUE_SEND_TASK_PRIORITY, NULL );
/* Create the blinky software timer as described at the top of this
file. */
xTimer = xTimerCreate( "Blinky", /* A text name, purely to help debugging. */
( mainBLINKY_TIMER_PERIOD ),/* The timer period. */
pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */
( void * ) 0, /* The ID is not used, so can be set to anything. */
prvBlinkyTimerCallback /* The callback function that inspects the status of all the other tasks. */
);
/* Create the blinky software timer as described at the top of this
* file. */
xTimer = xTimerCreate( "Blinky", /* A text name, purely to help debugging. */
( mainBLINKY_TIMER_PERIOD ), /* The timer period. */
pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */
( void * ) 0, /* The ID is not used, so can be set to anything. */
prvBlinkyTimerCallback /* The callback function that inspects the status of all the other tasks. */
);
if( xTimer != NULL )
{
xTimerStart( xTimer, mainDONT_BLOCK );
}
if( xTimer != NULL )
{
xTimerStart( xTimer, mainDONT_BLOCK );
}
/* Start the tasks and timer running. */
vTaskStartScheduler();
}
/* 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( ;; );
/* 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 )
static void prvQueueSendTask( void * pvParameters )
{
TickType_t xNextWakeTime;
const unsigned long ulValueToSend = 100UL;
TickType_t xNextWakeTime;
const unsigned long ulValueToSend = 100UL;
/* Check the task parameter is as expected. */
configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_SEND_PARAMETER );
/* Check the task parameter is as expected. */
configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_SEND_PARAMETER );
/* Initialise xNextWakeTime - this only needs to be done once. */
xNextWakeTime = xTaskGetTickCount();
/* 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, the constant used converts ticks
to ms. While in the Blocked state this task will not consume any CPU
time. */
vTaskDelayUntil( &xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS );
for( ; ; )
{
/* Place this task in the blocked state until it is time to run again.
* The block time is specified in ticks, the constant used converts ticks
* to ms. While in the Blocked state this task will not consume any CPU
* time. */
vTaskDelayUntil( &xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS );
/* Send to the queue - causing the queue receive task to unblock and
toggle the LED. 0 is used as the block time so the sending operation
will not block - it shouldn't need to block as the queue should always
be empty at this point in the code. */
xQueueSend( xQueue, &ulValueToSend, 0U );
}
/* Send to the queue - causing the queue receive task to unblock and
* toggle the LED. 0 is used as the block time so the sending operation
* will not block - it shouldn't need to block as the queue should always
* be empty at this point in the code. */
xQueueSend( xQueue, &ulValueToSend, 0U );
}
}
/*-----------------------------------------------------------*/
static void prvQueueReceiveTask( void *pvParameters )
static void prvQueueReceiveTask( void * pvParameters )
{
unsigned long ulReceivedValue;
unsigned long ulReceivedValue;
/* Check the task parameter is as expected. */
configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_RECEIVE_PARAMETER );
/* Check the task parameter is as expected. */
configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_RECEIVE_PARAMETER );
for( ;; )
{
/* Wait until something arrives in the queue - this task will block
indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
FreeRTOSConfig.h. */
xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );
for( ; ; )
{
/* Wait until something arrives in the queue - this task will block
* indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
* FreeRTOSConfig.h. */
xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );
/* To get here something must have been received from the queue, but
is it the expected value? If it is, toggle the LED. */
if( ulReceivedValue == 100UL )
{
vParTestToggleLED( mainTASKS_LED );
ulReceivedValue = 0U;
}
}
/* To get here something must have been received from the queue, but
* is it the expected value? If it is, toggle the LED. */
if( ulReceivedValue == 100UL )
{
vParTestToggleLED( mainTASKS_LED );
ulReceivedValue = 0U;
}
}
}
/*-----------------------------------------------------------*/
static void prvBlinkyTimerCallback( TimerHandle_t xTimer )
{
/* This function is called when the blinky software time expires. All the
function does is toggle the LED. LED mainTIMER_LED should therefore toggle
with the period set by mainBLINKY_TIMER_PERIOD. */
vParTestToggleLED( mainTIMER_LED );
/* This function is called when the blinky software time expires. All the
* function does is toggle the LED. LED mainTIMER_LED should therefore toggle
* with the period set by mainBLINKY_TIMER_PERIOD. */
vParTestToggleLED( mainTIMER_LED );
}

View file

@ -1,6 +1,6 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* 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
@ -117,49 +117,49 @@
/*-----------------------------------------------------------*/
/* The period after which the check timer will expire, in ms, provided no errors
have been reported by any of the standard demo tasks. ms are converted to the
equivalent in ticks using the portTICK_PERIOD_MS constant. */
#define mainCHECK_TIMER_PERIOD_MS ( 3000UL / portTICK_PERIOD_MS )
* have been reported by any of the standard demo tasks. ms are converted to the
* equivalent in ticks using the portTICK_PERIOD_MS constant. */
#define mainCHECK_TIMER_PERIOD_MS ( 3000UL / portTICK_PERIOD_MS )
/* The period at which the check timer will expire, in ms, if an error has been
reported in one of the standard demo tasks. ms are converted to the equivalent
in ticks using the portTICK_PERIOD_MS constant. */
#define mainERROR_CHECK_TIMER_PERIOD_MS ( 200UL / portTICK_PERIOD_MS )
* reported in one of the standard demo tasks. ms are converted to the equivalent
* in ticks using the portTICK_PERIOD_MS constant. */
#define mainERROR_CHECK_TIMER_PERIOD_MS ( 200UL / portTICK_PERIOD_MS )
/* The priorities of the various demo application tasks. */
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
/* Misc. */
#define mainDONT_BLOCK ( 0 )
#define mainDONT_BLOCK ( 0 )
/* Dimension the buffer used to hold the value of the high frequency timer
count when it is converted to a string. */
#define mainMAX_STRING_LENGTH ( 20 )
* count when it is converted to a string. */
#define mainMAX_STRING_LENGTH ( 20 )
/* The frequency at which the "fast interrupt test" interrupt will occur. */
#define mainTEST_INTERRUPT_FREQUENCY ( 20000 )
#define mainTEST_INTERRUPT_FREQUENCY ( 20000 )
/* The number of timer clocks expected to occur between each "fast interrupt
test" interrupt. */
#define mainEXPECTED_CLOCKS_BETWEEN_INTERRUPTS ( ( configCPU_CLOCK_HZ >> 1 ) / mainTEST_INTERRUPT_FREQUENCY )
* test" interrupt. */
#define mainEXPECTED_CLOCKS_BETWEEN_INTERRUPTS ( ( configCPU_CLOCK_HZ >> 1 ) / mainTEST_INTERRUPT_FREQUENCY )
/* The number of nano seconds between each core clock. */
#define mainNS_PER_CLOCK ( ( unsigned long ) ( ( 1.0 / ( double ) ( configCPU_CLOCK_HZ >> 1 ) ) * 1000000000.0 ) )
#define mainNS_PER_CLOCK ( ( unsigned long ) ( ( 1.0 / ( double ) ( configCPU_CLOCK_HZ >> 1 ) ) * 1000000000.0 ) )
/* The number of LEDs that should be controlled by the flash software timer
standard demo and the LED to be toggle by the check task. The starter kit only
has three LEDs so when the demo is configured to run on the starter kit there
is one less flash timer so the check task can use the third LED. */
* standard demo and the LED to be toggle by the check task. The starter kit only
* has three LEDs so when the demo is configured to run on the starter kit there
* is one less flash timer so the check task can use the third LED. */
#ifdef PIC32_STARTER_KIT
#define mainNUM_FLASH_TIMER_LEDS ( 2 )
#define mainCHECK_LED ( 2 )
#define mainNUM_FLASH_TIMER_LEDS ( 2 )
#define mainCHECK_LED ( 2 )
#else
#define mainNUM_FLASH_TIMER_LEDS ( 3 )
#define mainCHECK_LED ( 7 )
#define mainNUM_FLASH_TIMER_LEDS ( 3 )
#define mainCHECK_LED ( 7 )
#endif
/*-----------------------------------------------------------*/
@ -185,8 +185,8 @@ static void prvSetupHighFrequencyTimerTest( TimerHandle_t xTimer );
* in and out between setting the register values and checking the register
* values.
*/
static void prvRegTestTask1( void *pvParameters );
static void prvRegTestTask2( void *pvParameters );
static void prvRegTestTask1( void * pvParameters );
static void prvRegTestTask2( void * pvParameters );
/*-----------------------------------------------------------*/
@ -194,8 +194,8 @@ static void prvRegTestTask2( void *pvParameters );
static QueueHandle_t xLCDQueue;
/* Variables incremented by prvRegTestTask1() and prvRegTestTask2() respectively on
each iteration of their function. This is used to detect either task stopping
their execution.. */
* each iteration of their function. This is used to detect either task stopping
* their execution.. */
volatile unsigned long ulRegTest1Cycles = 0, ulRegTest2Cycles = 0;
/*-----------------------------------------------------------*/
@ -205,170 +205,172 @@ volatile unsigned long ulRegTest1Cycles = 0, ulRegTest2Cycles = 0;
*/
int main_full( void )
{
TimerHandle_t xTimer = NULL;
TimerHandle_t xTimer = NULL;
/* Create all the other standard demo tasks. */
vStartLEDFlashTimers( mainNUM_FLASH_TIMER_LEDS );
/* Create all the other standard demo tasks. */
vStartLEDFlashTimers( mainNUM_FLASH_TIMER_LEDS );
vCreateBlockTimeTasks();
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
vStartQueuePeekTasks();
vStartInterruptQueueTasks();
vStartInterruptQueueTasks();
/* Create the tasks defined within this file. */
xTaskCreate( prvRegTestTask1, "Reg1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
xTaskCreate( prvRegTestTask2, "Reg2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
/* Create the tasks defined within this file. */
xTaskCreate( prvRegTestTask1, "Reg1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
xTaskCreate( prvRegTestTask2, "Reg2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
/* Create the software timer that performs the 'check' functionality, as
described at the top of this file. */
xTimer = xTimerCreate( "CheckTimer",/* A text name, purely to help debugging. */
( mainCHECK_TIMER_PERIOD_MS ), /* The timer period, in this case 3000ms (3s). */
pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */
( void * ) 0, /* The ID is not used, so can be set to anything. */
prvCheckTimerCallback /* The callback function that inspects the status of all the other tasks. */
);
/* Create the software timer that performs the 'check' functionality, as
* described at the top of this file. */
xTimer = xTimerCreate( "CheckTimer", /* A text name, purely to help debugging. */
( mainCHECK_TIMER_PERIOD_MS ), /* The timer period, in this case 3000ms (3s). */
pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */
( void * ) 0, /* The ID is not used, so can be set to anything. */
prvCheckTimerCallback /* The callback function that inspects the status of all the other tasks. */
);
if( xTimer != NULL )
{
xTimerStart( xTimer, mainDONT_BLOCK );
}
if( xTimer != NULL )
{
xTimerStart( xTimer, mainDONT_BLOCK );
}
/* A software timer is also used to start the high frequency timer test.
This is to ensure the test does not start before the kernel. This time a
one-shot software timer is used. */
xTimer = xTimerCreate( "HighHzTimerSetup", 1, pdFALSE, ( void * ) 0, prvSetupHighFrequencyTimerTest );
if( xTimer != NULL )
{
xTimerStart( xTimer, mainDONT_BLOCK );
}
/* A software timer is also used to start the high frequency timer test.
* This is to ensure the test does not start before the kernel. This time a
* one-shot software timer is used. */
xTimer = xTimerCreate( "HighHzTimerSetup", 1, pdFALSE, ( void * ) 0, prvSetupHighFrequencyTimerTest );
/* Finally start the scheduler. */
vTaskStartScheduler();
if( xTimer != NULL )
{
xTimerStart( xTimer, mainDONT_BLOCK );
}
/* 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( ;; );
/* Finally start the scheduler. */
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 prvRegTestTask1( void *pvParameters )
static void prvRegTestTask1( void * pvParameters )
{
extern void vRegTest1( volatile unsigned long * );
extern void vRegTest1( volatile unsigned long * );
/* Avoid compiler warnings. */
( void ) pvParameters;
/* Avoid compiler warnings. */
( void ) pvParameters;
/* Pass the address of the RegTest1 loop counter into the test function,
which is necessarily implemented in assembler. */
vRegTest1( &ulRegTest1Cycles );
/* Pass the address of the RegTest1 loop counter into the test function,
* which is necessarily implemented in assembler. */
vRegTest1( &ulRegTest1Cycles );
/* vRegTest1 should never exit! */
vTaskDelete( NULL );
/* vRegTest1 should never exit! */
vTaskDelete( NULL );
}
/*-----------------------------------------------------------*/
static void prvRegTestTask2( void *pvParameters )
static void prvRegTestTask2( void * pvParameters )
{
extern void vRegTest2( volatile unsigned long * );
extern void vRegTest2( volatile unsigned long * );
/* Avoid compiler warnings. */
( void ) pvParameters;
/* Avoid compiler warnings. */
( void ) pvParameters;
/* Pass the address of the RegTest2 loop counter into the test function,
which is necessarily implemented in assembler. */
vRegTest2( &ulRegTest2Cycles );
/* Pass the address of the RegTest2 loop counter into the test function,
* which is necessarily implemented in assembler. */
vRegTest2( &ulRegTest2Cycles );
/* vRegTest1 should never exit! */
vTaskDelete( NULL );
/* vRegTest1 should never exit! */
vTaskDelete( NULL );
}
/*-----------------------------------------------------------*/
static void prvCheckTimerCallback( TimerHandle_t xTimer )
{
static long lChangedTimerPeriodAlready = pdFALSE;
static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;
static long lChangedTimerPeriodAlready = pdFALSE;
static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;
/* Buffer into which the high frequency timer count is written as a string. */
static char cStringBuffer[ mainMAX_STRING_LENGTH ];
static char cStringBuffer[ mainMAX_STRING_LENGTH ];
/* The count of the high frequency timer interrupts. */
extern unsigned long ulHighFrequencyTimerInterrupts;
static xLCDMessage xMessage = { ( 200 / portTICK_PERIOD_MS ), cStringBuffer };
extern unsigned long ulHighFrequencyTimerInterrupts;
static xLCDMessage xMessage = { ( 200 / portTICK_PERIOD_MS ), cStringBuffer };
/* Check that the register test 1 task is still running. */
if( ulLastRegTest1Value == ulRegTest1Cycles )
{
xMessage.pcMessage = "Error: Reg test2";
}
ulLastRegTest1Value = ulRegTest1Cycles;
/* Check that the register test 1 task is still running. */
if( ulLastRegTest1Value == ulRegTest1Cycles )
{
xMessage.pcMessage = "Error: Reg test2";
}
ulLastRegTest1Value = ulRegTest1Cycles;
/* Check that the register test 2 task is still running. */
if( ulLastRegTest2Value == ulRegTest2Cycles )
{
xMessage.pcMessage = "Error: Reg test3";
}
ulLastRegTest2Value = ulRegTest2Cycles;
/* Check that the register test 2 task is still running. */
if( ulLastRegTest2Value == ulRegTest2Cycles )
{
xMessage.pcMessage = "Error: Reg test3";
}
ulLastRegTest2Value = ulRegTest2Cycles;
/* Have any of the standard demo tasks detected an error in their
operation? */
if( xAreGenericQueueTasksStillRunning() != pdTRUE )
{
xMessage.pcMessage = "Error: Gen Q";
}
else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
{
xMessage.pcMessage = "Error: Q Peek";
}
else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
{
xMessage.pcMessage = "Error: Blck time";
}
else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
{
xMessage.pcMessage = "Error: Sem test";
}
else if( xAreIntQueueTasksStillRunning() != pdTRUE )
{
xMessage.pcMessage = "Error: Int queue";
}
/* Have any of the standard demo tasks detected an error in their
* operation? */
if( xAreGenericQueueTasksStillRunning() != pdTRUE )
{
xMessage.pcMessage = "Error: Gen Q";
}
else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
{
xMessage.pcMessage = "Error: Q Peek";
}
else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
{
xMessage.pcMessage = "Error: Blck time";
}
else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
{
xMessage.pcMessage = "Error: Sem test";
}
else if( xAreIntQueueTasksStillRunning() != pdTRUE )
{
xMessage.pcMessage = "Error: Int queue";
}
if( xMessage.pcMessage != cStringBuffer )
{
/* An error string has been logged. If the timer period has not yet
been changed it should be changed now. Increasing the frequency of the
LED gives visual feedback of the error status. */
if( lChangedTimerPeriodAlready == pdFALSE )
{
lChangedTimerPeriodAlready = pdTRUE;
if( xMessage.pcMessage != cStringBuffer )
{
/* An error string has been logged. If the timer period has not yet
* been changed it should be changed now. Increasing the frequency of the
* LED gives visual feedback of the error status. */
if( lChangedTimerPeriodAlready == pdFALSE )
{
lChangedTimerPeriodAlready = pdTRUE;
/* This call to xTimerChangePeriod() uses a zero block time.
Functions called from inside of a timer callback function must
*never* attempt to block as to do so could impact other software
timers. */
xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );
}
}
else
{
/* Write the ulHighFrequencyTimerInterrupts value to the string
buffer. It will only be displayed if no errors have been detected. */
sprintf( cStringBuffer, "Pass %u", ( unsigned int ) ulHighFrequencyTimerInterrupts );
}
/* This call to xTimerChangePeriod() uses a zero block time.
* Functions called from inside of a timer callback function must
* never* attempt to block as to do so could impact other software
* timers. */
xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );
}
}
else
{
/* Write the ulHighFrequencyTimerInterrupts value to the string
* buffer. It will only be displayed if no errors have been detected. */
sprintf( cStringBuffer, "Pass %u", ( unsigned int ) ulHighFrequencyTimerInterrupts );
}
vParTestToggleLED( mainCHECK_LED );
vParTestToggleLED( mainCHECK_LED );
}
/*-----------------------------------------------------------*/
static void prvSetupHighFrequencyTimerTest( TimerHandle_t xTimer )
{
/* Setup the high frequency, high priority, timer test. It is setup in this
software timer callback to ensure it does not start before the kernel does.
This is a one-shot timer - so the setup routine will only be executed once. */
vSetupTimerTest( mainTEST_INTERRUPT_FREQUENCY );
/* Setup the high frequency, high priority, timer test. It is setup in this
* software timer callback to ensure it does not start before the kernel does.
* This is a one-shot timer - so the setup routine will only be executed once. */
vSetupTimerTest( mainTEST_INTERRUPT_FREQUENCY );
}