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
@ -29,15 +29,16 @@
#include <task.h>
/* Run a simple demo just prints 'Blink' */
#define DEMO_BLINKY 1
#define mainVECTOR_MODE_DIRECT 1
#define DEMO_BLINKY 1
#define mainVECTOR_MODE_DIRECT 1
extern void freertos_risc_v_trap_handler( void );
extern void freertos_vector_table( void );
void vApplicationMallocFailedHook( void );
void vApplicationIdleHook( void );
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
void vApplicationStackOverflowHook( TaskHandle_t pxTask,
char * pcTaskName );
void vApplicationTickHook( void );
int main_blinky( void );
@ -46,70 +47,78 @@ int main_blinky( void );
int main( void )
{
int ret;
// trap handler initialization
#if( mainVECTOR_MODE_DIRECT == 1 )
{
__asm__ volatile( "csrw mtvec, %0" :: "r"( freertos_risc_v_trap_handler ) );
}
#else
{
__asm__ volatile( "csrw mtvec, %0" :: "r"( ( uintptr_t )freertos_vector_table | 0x1 ) );
}
#endif
int ret;
#if defined(DEMO_BLINKY)
ret = main_blinky();
#else
#error "Please add or select demo."
#endif
/* trap handler initialization */
#if ( mainVECTOR_MODE_DIRECT == 1 )
{
__asm__ volatile ( "csrw mtvec, %0" : : "r" ( freertos_risc_v_trap_handler ) );
}
#else
{
__asm__ volatile ( "csrw mtvec, %0" : : "r" ( ( uintptr_t ) freertos_vector_table | 0x1 ) );
}
#endif
return ret;
#if defined( DEMO_BLINKY )
ret = main_blinky();
#else
#error "Please add or select demo."
#endif
return ret;
}
/*-----------------------------------------------------------*/
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 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. */
taskDISABLE_INTERRUPTS();
for( ;; );
/* 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. */
taskDISABLE_INTERRUPTS();
for( ; ; )
{
}
}
/*-----------------------------------------------------------*/
@ -120,11 +129,12 @@ void vApplicationTickHook( void )
void vAssertCalled( void )
{
volatile uint32_t ulSetTo1ToExitFunction = 0;
volatile uint32_t ulSetTo1ToExitFunction = 0;
taskDISABLE_INTERRUPTS();
while( ulSetTo1ToExitFunction != 1 )
{
__asm volatile( "NOP" );
}
taskDISABLE_INTERRUPTS();
while( ulSetTo1ToExitFunction != 1 )
{
__asm volatile ( "NOP" );
}
}

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
@ -20,7 +20,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://www.github.com/FreeRTOS
* https://github.com/FreeRTOS
*
*/
@ -35,20 +35,20 @@
#include "ns16550.h"
/* Priorities used by the tasks. */
#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 pdMS_TO_TICKS() macro. */
#define mainQUEUE_SEND_FREQUENCY_MS pdMS_TO_TICKS( 1000 )
* to ticks using the pdMS_TO_TICKS() macro. */
#define mainQUEUE_SEND_FREQUENCY_MS pdMS_TO_TICKS( 1000 )
/* The maximum number items the queue can hold. The priority of the receiving
task is above the priority of the sending task, so the receiving task will
preempt the sending task and remove the queue items each time the sending task
writes to the queue. Therefore the queue will never have more than one item in
it at any time, and even with a queue length of 1, the sending task will never
find the queue full. */
#define mainQUEUE_LENGTH ( 1 )
* task is above the priority of the sending task, so the receiving task will
* preempt the sending task and remove the queue items each time the sending task
* writes to the queue. Therefore the queue will never have more than one item in
* it at any time, and even with a queue length of 1, the sending task will never
* find the queue full. */
#define mainQUEUE_LENGTH ( 1 )
/*-----------------------------------------------------------*/
@ -57,103 +57,103 @@ static QueueHandle_t xQueue = NULL;
/*-----------------------------------------------------------*/
static void prvQueueSendTask( void *pvParameters )
static void prvQueueSendTask( void * pvParameters )
{
TickType_t xNextWakeTime;
const unsigned long ulValueToSend = 100UL;
const char * const pcMessage1 = "Transfer1";
const char * const pcMessage2 = "Transfer2";
int f = 1;
TickType_t xNextWakeTime;
const unsigned long ulValueToSend = 100UL;
const char * const pcMessage1 = "Transfer1";
const char * const pcMessage2 = "Transfer2";
int f = 1;
/* Remove compiler warning about unused parameter. */
( void ) pvParameters;
/* Remove compiler warning about unused parameter. */
( void ) pvParameters;
/* Initialise xNextWakeTime - this only needs to be done once. */
xNextWakeTime = xTaskGetTickCount();
/* Initialise xNextWakeTime - this only needs to be done once. */
xNextWakeTime = xTaskGetTickCount();
for( ;; )
{
char buf[40];
for( ; ; )
{
char buf[ 40 ];
sprintf( buf, "%d: %s: %s", xGetCoreID(),
pcTaskGetName( xTaskGetCurrentTaskHandle() ),
( f ) ? pcMessage1 : pcMessage2 );
vSendString( buf );
f = !f;
sprintf( buf, "%d: %s: %s", xGetCoreID(),
pcTaskGetName( xTaskGetCurrentTaskHandle() ),
( f ) ? pcMessage1 : pcMessage2 );
vSendString( buf );
f = !f;
/* Place this task in the blocked state until it is time to run again. */
vTaskDelayUntil( &xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS );
/* Place this task in the blocked state until it is time to run again. */
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;
const unsigned long ulExpectedValue = 100UL;
const char * const pcMessage1 = "Blink1";
const char * const pcMessage2 = "Blink2";
const char * const pcFailMessage = "Unexpected value received\r\n";
int f = 1;
unsigned long ulReceivedValue;
const unsigned long ulExpectedValue = 100UL;
const char * const pcMessage1 = "Blink1";
const char * const pcMessage2 = "Blink2";
const char * const pcFailMessage = "Unexpected value received\r\n";
int f = 1;
/* Remove compiler warning about unused parameter. */
( void ) pvParameters;
/* Remove compiler warning about unused parameter. */
( void ) pvParameters;
for( ;; )
{
char buf[40];
for( ; ; )
{
char buf[ 40 ];
/* 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 );
/* 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 == ulExpectedValue )
{
sprintf( buf, "%d: %s: %s", xGetCoreID(),
pcTaskGetName( xTaskGetCurrentTaskHandle() ),
( f ) ? pcMessage1 : pcMessage2 );
vSendString( buf );
f = !f;
/* 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 == ulExpectedValue )
{
sprintf( buf, "%d: %s: %s", xGetCoreID(),
pcTaskGetName( xTaskGetCurrentTaskHandle() ),
( f ) ? pcMessage1 : pcMessage2 );
vSendString( buf );
f = !f;
ulReceivedValue = 0U;
}
else
{
vSendString( pcFailMessage );
}
}
ulReceivedValue = 0U;
}
else
{
vSendString( pcFailMessage );
}
}
}
/*-----------------------------------------------------------*/
int main_blinky( void )
{
vSendString( "Hello FreeRTOS!" );
vSendString( "Hello FreeRTOS!" );
/* Create the queue. */
xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( uint32_t ) );
/* 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, "Rx", configMINIMAL_STACK_SIZE * 2U, NULL,
mainQUEUE_RECEIVE_TASK_PRIORITY, NULL );
xTaskCreate( prvQueueSendTask, "Tx", configMINIMAL_STACK_SIZE * 2U, NULL,
mainQUEUE_SEND_TASK_PRIORITY, NULL );
}
if( xQueue != NULL )
{
/* Start the two tasks as described in the comments at the top of this
* file. */
xTaskCreate( prvQueueReceiveTask, "Rx", configMINIMAL_STACK_SIZE * 2U, NULL,
mainQUEUE_RECEIVE_TASK_PRIORITY, NULL );
xTaskCreate( prvQueueSendTask, "Tx", configMINIMAL_STACK_SIZE * 2U, NULL,
mainQUEUE_SEND_TASK_PRIORITY, NULL );
}
vTaskStartScheduler();
vTaskStartScheduler();
return 0;
return 0;
}