mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-13 16:27:43 -04:00
Add uncrustify github workflow (#659)
* Add uncrustify github workflow * Fix exclusion pattern * fix find expression * exclude uncrustify files * Uncrustify common demo and test files * exlude white space checking files * Fix EOL whitespace checker * Remove whitespaces from EOL * Fix space at EOL * Fix find spaces at EOL Co-authored-by: Archit Aggarwal <architag@amazon.com>
This commit is contained in:
parent
dd80d615b5
commit
ae92d8c6ee
191 changed files with 17540 additions and 17102 deletions
|
@ -19,8 +19,8 @@
|
|||
* 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
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -68,22 +68,22 @@
|
|||
#include "MessageBufferAMP.h"
|
||||
|
||||
/* Enough for 3 4 byte pointers, including the additional 4 bytes per message
|
||||
overhead of message buffers. */
|
||||
#define mbaCONTROL_MESSAGE_BUFFER_SIZE ( 24 )
|
||||
* overhead of message buffers. */
|
||||
#define mbaCONTROL_MESSAGE_BUFFER_SIZE ( 24 )
|
||||
|
||||
/* Enough four 4 8 byte strings, plus the additional 4 bytes per message
|
||||
overhead of message buffers. */
|
||||
#define mbaTASK_MESSAGE_BUFFER_SIZE ( 60 )
|
||||
* overhead of message buffers. */
|
||||
#define mbaTASK_MESSAGE_BUFFER_SIZE ( 60 )
|
||||
|
||||
/* The number of instances of prvCoreBTasks that are created. */
|
||||
#define mbaNUMBER_OF_CORE_B_TASKS 2
|
||||
#define mbaNUMBER_OF_CORE_B_TASKS 2
|
||||
|
||||
/* A block time of 0 simply means, don't block. */
|
||||
#define mbaDONT_BLOCK 0
|
||||
#define mbaDONT_BLOCK 0
|
||||
|
||||
/* Macro that mimics an interrupt service routine executing by simply calling
|
||||
the routine inline. */
|
||||
#define mbaGENERATE_CORE_B_INTERRUPT() prvCoreBInterruptHandler()
|
||||
* the routine inline. */
|
||||
#define mbaGENERATE_CORE_B_INTERRUPT() prvCoreBInterruptHandler()
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
@ -91,14 +91,14 @@ the routine inline. */
|
|||
* Implementation of the task that, on a real dual core device, would run on
|
||||
* core A and send message to tasks running on core B.
|
||||
*/
|
||||
static void prvCoreATask( void *pvParameters );
|
||||
static void prvCoreATask( void * pvParameters );
|
||||
|
||||
/*
|
||||
* Implementation of the task that, on a real dual core device, would run on
|
||||
* core B and receive message from core A. The demo creates two instances of
|
||||
* this task.
|
||||
*/
|
||||
static void prvCoreBTasks( void *pvParameters );
|
||||
static void prvCoreBTasks( void * pvParameters );
|
||||
|
||||
/*
|
||||
* The function that, on a real dual core device, would handle inter-core
|
||||
|
@ -112,218 +112,217 @@ static void prvCoreBInterruptHandler( void );
|
|||
static MessageBufferHandle_t xCoreBMessageBuffers[ mbaNUMBER_OF_CORE_B_TASKS ];
|
||||
|
||||
/* The control message buffer. This is used to pass the handle of the message
|
||||
message buffer that holds application data into the core to core interrupt
|
||||
service routine. */
|
||||
* message buffer that holds application data into the core to core interrupt
|
||||
* service routine. */
|
||||
static MessageBufferHandle_t xControlMessageBuffer;
|
||||
|
||||
/* Counters used to indicate to the check that the tasks are still executing. */
|
||||
static uint32_t ulCycleCounters[ mbaNUMBER_OF_CORE_B_TASKS ];
|
||||
|
||||
/* Set to pdFALSE if any errors are detected. Used to inform the check task
|
||||
that something might be wrong. */
|
||||
* that something might be wrong. */
|
||||
BaseType_t xDemoStatus = pdPASS;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vStartMessageBufferAMPTasks( configSTACK_DEPTH_TYPE xStackSize )
|
||||
{
|
||||
BaseType_t x;
|
||||
BaseType_t x;
|
||||
|
||||
xControlMessageBuffer = xMessageBufferCreate( mbaCONTROL_MESSAGE_BUFFER_SIZE );
|
||||
xControlMessageBuffer = xMessageBufferCreate( mbaCONTROL_MESSAGE_BUFFER_SIZE );
|
||||
|
||||
xTaskCreate( prvCoreATask, /* The function that implements the task. */
|
||||
"AMPCoreA", /* Human readable name for the task. */
|
||||
xStackSize, /* Stack size (in words!). */
|
||||
NULL, /* Task parameter is not used. */
|
||||
tskIDLE_PRIORITY, /* The priority at which the task is created. */
|
||||
NULL ); /* No use for the task handle. */
|
||||
xTaskCreate( prvCoreATask, /* The function that implements the task. */
|
||||
"AMPCoreA", /* Human readable name for the task. */
|
||||
xStackSize, /* Stack size (in words!). */
|
||||
NULL, /* Task parameter is not used. */
|
||||
tskIDLE_PRIORITY, /* The priority at which the task is created. */
|
||||
NULL ); /* No use for the task handle. */
|
||||
|
||||
for( x = 0; x < mbaNUMBER_OF_CORE_B_TASKS; x++ )
|
||||
{
|
||||
xCoreBMessageBuffers[ x ] = xMessageBufferCreate( mbaTASK_MESSAGE_BUFFER_SIZE );
|
||||
configASSERT( xCoreBMessageBuffers[ x ] );
|
||||
for( x = 0; x < mbaNUMBER_OF_CORE_B_TASKS; x++ )
|
||||
{
|
||||
xCoreBMessageBuffers[ x ] = xMessageBufferCreate( mbaTASK_MESSAGE_BUFFER_SIZE );
|
||||
configASSERT( xCoreBMessageBuffers[ x ] );
|
||||
|
||||
/* Pass the loop counter into the created task using the task's
|
||||
parameter. The task then uses the value as an index into the
|
||||
ulCycleCounters and xCoreBMessageBuffers arrays. */
|
||||
xTaskCreate( prvCoreBTasks,
|
||||
"AMPCoreB1",
|
||||
xStackSize,
|
||||
( void * ) x,
|
||||
tskIDLE_PRIORITY + 1,
|
||||
NULL );
|
||||
}
|
||||
/* Pass the loop counter into the created task using the task's
|
||||
* parameter. The task then uses the value as an index into the
|
||||
* ulCycleCounters and xCoreBMessageBuffers arrays. */
|
||||
xTaskCreate( prvCoreBTasks,
|
||||
"AMPCoreB1",
|
||||
xStackSize,
|
||||
( void * ) x,
|
||||
tskIDLE_PRIORITY + 1,
|
||||
NULL );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCoreATask( void *pvParameters )
|
||||
static void prvCoreATask( void * pvParameters )
|
||||
{
|
||||
BaseType_t x;
|
||||
uint32_t ulNextValue = 0;
|
||||
const TickType_t xDelay = pdMS_TO_TICKS( 250 );
|
||||
char cString[ 15 ]; /* At least large enough to hold "4294967295\0" (0xffffffff). */
|
||||
BaseType_t x;
|
||||
uint32_t ulNextValue = 0;
|
||||
const TickType_t xDelay = pdMS_TO_TICKS( 250 );
|
||||
char cString[ 15 ]; /* At least large enough to hold "4294967295\0" (0xffffffff). */
|
||||
|
||||
/* Remove warning about unused parameters. */
|
||||
( void ) pvParameters;
|
||||
/* Remove warning about unused parameters. */
|
||||
( void ) pvParameters;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Create the next string to send. The value is incremented on each
|
||||
loop iteration, and the length of the string changes as the number of
|
||||
digits in the value increases. */
|
||||
sprintf( cString, "%lu", ( unsigned long ) ulNextValue );
|
||||
for( ; ; )
|
||||
{
|
||||
/* Create the next string to send. The value is incremented on each
|
||||
* loop iteration, and the length of the string changes as the number of
|
||||
* digits in the value increases. */
|
||||
sprintf( cString, "%lu", ( unsigned long ) ulNextValue );
|
||||
|
||||
/* Send the value from this (pseudo) Core A to the tasks on the (pseudo)
|
||||
Core B via the message buffers. This will result in sbSEND_COMPLETED()
|
||||
being executed, which in turn will write the handle of the message
|
||||
buffer written to into xControlMessageBuffer then generate an interrupt
|
||||
in core B. */
|
||||
for( x = 0; x < mbaNUMBER_OF_CORE_B_TASKS; x++ )
|
||||
{
|
||||
xMessageBufferSend( /* The message buffer to write to. */
|
||||
xCoreBMessageBuffers[ x ],
|
||||
/* The source of the data to send. */
|
||||
( void * ) cString,
|
||||
/* The length of the data to send. */
|
||||
strlen( cString ),
|
||||
/* The block time, should the buffer be full. */
|
||||
mbaDONT_BLOCK );
|
||||
}
|
||||
/* Send the value from this (pseudo) Core A to the tasks on the (pseudo)
|
||||
* Core B via the message buffers. This will result in sbSEND_COMPLETED()
|
||||
* being executed, which in turn will write the handle of the message
|
||||
* buffer written to into xControlMessageBuffer then generate an interrupt
|
||||
* in core B. */
|
||||
for( x = 0; x < mbaNUMBER_OF_CORE_B_TASKS; x++ )
|
||||
{
|
||||
xMessageBufferSend( /* The message buffer to write to. */
|
||||
xCoreBMessageBuffers[ x ],
|
||||
/* The source of the data to send. */
|
||||
( void * ) cString,
|
||||
/* The length of the data to send. */
|
||||
strlen( cString ),
|
||||
/* The block time, should the buffer be full. */
|
||||
mbaDONT_BLOCK );
|
||||
}
|
||||
|
||||
/* Delay before repeating with a different and potentially different
|
||||
length string. */
|
||||
vTaskDelay( xDelay );
|
||||
ulNextValue++;
|
||||
}
|
||||
/* Delay before repeating with a different and potentially different
|
||||
* length string. */
|
||||
vTaskDelay( xDelay );
|
||||
ulNextValue++;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCoreBTasks( void *pvParameters )
|
||||
static void prvCoreBTasks( void * pvParameters )
|
||||
{
|
||||
BaseType_t x;
|
||||
size_t xReceivedBytes;
|
||||
uint32_t ulNextValue = 0;
|
||||
char cExpectedString[ 15 ]; /* At least large enough to hold "4294967295\0" (0xffffffff). */
|
||||
char cReceivedString[ 15 ];
|
||||
BaseType_t x;
|
||||
size_t xReceivedBytes;
|
||||
uint32_t ulNextValue = 0;
|
||||
char cExpectedString[ 15 ]; /* At least large enough to hold "4294967295\0" (0xffffffff). */
|
||||
char cReceivedString[ 15 ];
|
||||
|
||||
/* The index into the xCoreBMessageBuffers and ulLoopCounter arrays is
|
||||
passed into this task using the task's parameter. */
|
||||
x = ( BaseType_t ) pvParameters;
|
||||
configASSERT( x < mbaNUMBER_OF_CORE_B_TASKS );
|
||||
/* The index into the xCoreBMessageBuffers and ulLoopCounter arrays is
|
||||
* passed into this task using the task's parameter. */
|
||||
x = ( BaseType_t ) pvParameters;
|
||||
configASSERT( x < mbaNUMBER_OF_CORE_B_TASKS );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Create the string that is expected to be received this time round. */
|
||||
sprintf( cExpectedString, "%lu", ( unsigned long ) ulNextValue );
|
||||
for( ; ; )
|
||||
{
|
||||
/* Create the string that is expected to be received this time round. */
|
||||
sprintf( cExpectedString, "%lu", ( unsigned long ) ulNextValue );
|
||||
|
||||
/* Wait to receive the next message from core A. */
|
||||
memset( cReceivedString, 0x00, sizeof( cReceivedString ) );
|
||||
xReceivedBytes = xMessageBufferReceive( /* The message buffer to receive from. */
|
||||
xCoreBMessageBuffers[ x ],
|
||||
/* Location to store received data. */
|
||||
cReceivedString,
|
||||
/* Maximum number of bytes to receive. */
|
||||
sizeof( cReceivedString ),
|
||||
/* Ticks to wait if buffer is empty. */
|
||||
portMAX_DELAY );
|
||||
/* Wait to receive the next message from core A. */
|
||||
memset( cReceivedString, 0x00, sizeof( cReceivedString ) );
|
||||
xReceivedBytes = xMessageBufferReceive( /* The message buffer to receive from. */
|
||||
xCoreBMessageBuffers[ x ],
|
||||
/* Location to store received data. */
|
||||
cReceivedString,
|
||||
/* Maximum number of bytes to receive. */
|
||||
sizeof( cReceivedString ),
|
||||
/* Ticks to wait if buffer is empty. */
|
||||
portMAX_DELAY );
|
||||
|
||||
/* Check the number of bytes received was as expected. */
|
||||
configASSERT( xReceivedBytes == strlen( cExpectedString ) );
|
||||
( void ) xReceivedBytes; /* Incase configASSERT() is not defined. */
|
||||
/* Check the number of bytes received was as expected. */
|
||||
configASSERT( xReceivedBytes == strlen( cExpectedString ) );
|
||||
( void ) xReceivedBytes; /* Incase configASSERT() is not defined. */
|
||||
|
||||
/* If the received string matches that expected then increment the loop
|
||||
counter so the check task knows this task is still running. */
|
||||
if( strcmp( cReceivedString, cExpectedString ) == 0 )
|
||||
{
|
||||
( ulCycleCounters[ x ] )++;
|
||||
}
|
||||
else
|
||||
{
|
||||
xDemoStatus = pdFAIL;
|
||||
}
|
||||
/* If the received string matches that expected then increment the loop
|
||||
* counter so the check task knows this task is still running. */
|
||||
if( strcmp( cReceivedString, cExpectedString ) == 0 )
|
||||
{
|
||||
( ulCycleCounters[ x ] )++;
|
||||
}
|
||||
else
|
||||
{
|
||||
xDemoStatus = pdFAIL;
|
||||
}
|
||||
|
||||
/* Expect the next string in sequence the next time around. */
|
||||
ulNextValue++;
|
||||
}
|
||||
/* Expect the next string in sequence the next time around. */
|
||||
ulNextValue++;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Called by the reimplementation of sbSEND_COMPLETED(), which can be defined
|
||||
as follows in FreeRTOSConfig.h:
|
||||
#define sbSEND_COMPLETED( pxStreamBuffer ) vGenerateCoreBInterrupt( pxStreamBuffer )
|
||||
*/
|
||||
* as follows in FreeRTOSConfig.h:
|
||||
#define sbSEND_COMPLETED( pxStreamBuffer ) vGenerateCoreBInterrupt( pxStreamBuffer )
|
||||
*/
|
||||
void vGenerateCoreBInterrupt( void * xUpdatedMessageBuffer )
|
||||
{
|
||||
MessageBufferHandle_t xUpdatedBuffer = ( MessageBufferHandle_t ) xUpdatedMessageBuffer;
|
||||
MessageBufferHandle_t xUpdatedBuffer = ( MessageBufferHandle_t ) xUpdatedMessageBuffer;
|
||||
|
||||
/* If sbSEND_COMPLETED() has been implemented as above, then this function
|
||||
is called from within xMessageBufferSend(). As this function also calls
|
||||
xMessageBufferSend() itself it is necessary to guard against a recursive
|
||||
call. If the message buffer just updated is the message buffer written to
|
||||
by this function, then this is a recursive call, and the function can just
|
||||
exit without taking further action. */
|
||||
if( xUpdatedBuffer != xControlMessageBuffer )
|
||||
{
|
||||
/* Use xControlMessageBuffer to pass the handle of the message buffer
|
||||
written to by core A to the interrupt handler about to be generated in
|
||||
core B. */
|
||||
xMessageBufferSend( xControlMessageBuffer, &xUpdatedBuffer, sizeof( xUpdatedBuffer ), mbaDONT_BLOCK );
|
||||
/* If sbSEND_COMPLETED() has been implemented as above, then this function
|
||||
* is called from within xMessageBufferSend(). As this function also calls
|
||||
* xMessageBufferSend() itself it is necessary to guard against a recursive
|
||||
* call. If the message buffer just updated is the message buffer written to
|
||||
* by this function, then this is a recursive call, and the function can just
|
||||
* exit without taking further action. */
|
||||
if( xUpdatedBuffer != xControlMessageBuffer )
|
||||
{
|
||||
/* Use xControlMessageBuffer to pass the handle of the message buffer
|
||||
* written to by core A to the interrupt handler about to be generated in
|
||||
* core B. */
|
||||
xMessageBufferSend( xControlMessageBuffer, &xUpdatedBuffer, sizeof( xUpdatedBuffer ), mbaDONT_BLOCK );
|
||||
|
||||
/* This is where the interrupt would be generated. In this case it is
|
||||
not a genuine interrupt handler that executes, just a standard function
|
||||
call. */
|
||||
mbaGENERATE_CORE_B_INTERRUPT();
|
||||
}
|
||||
/* This is where the interrupt would be generated. In this case it is
|
||||
* not a genuine interrupt handler that executes, just a standard function
|
||||
* call. */
|
||||
mbaGENERATE_CORE_B_INTERRUPT();
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Handler for the interrupts that are triggered on core A but execute on core
|
||||
B. */
|
||||
* B. */
|
||||
static void prvCoreBInterruptHandler( void )
|
||||
{
|
||||
MessageBufferHandle_t xUpdatedMessageBuffer;
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
MessageBufferHandle_t xUpdatedMessageBuffer;
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
/* xControlMessageBuffer contains the handle of the message buffer that
|
||||
contains data. */
|
||||
if( xMessageBufferReceive( xControlMessageBuffer,
|
||||
&xUpdatedMessageBuffer,
|
||||
sizeof( xUpdatedMessageBuffer ),
|
||||
mbaDONT_BLOCK ) == sizeof( xUpdatedMessageBuffer ) )
|
||||
{
|
||||
/* Call the API function that sends a notification to any task that is
|
||||
blocked on the xUpdatedMessageBuffer message buffer waiting for data to
|
||||
arrive. */
|
||||
xMessageBufferSendCompletedFromISR( xUpdatedMessageBuffer, &xHigherPriorityTaskWoken );
|
||||
}
|
||||
/* xControlMessageBuffer contains the handle of the message buffer that
|
||||
* contains data. */
|
||||
if( xMessageBufferReceive( xControlMessageBuffer,
|
||||
&xUpdatedMessageBuffer,
|
||||
sizeof( xUpdatedMessageBuffer ),
|
||||
mbaDONT_BLOCK ) == sizeof( xUpdatedMessageBuffer ) )
|
||||
{
|
||||
/* Call the API function that sends a notification to any task that is
|
||||
* blocked on the xUpdatedMessageBuffer message buffer waiting for data to
|
||||
* arrive. */
|
||||
xMessageBufferSendCompletedFromISR( xUpdatedMessageBuffer, &xHigherPriorityTaskWoken );
|
||||
}
|
||||
|
||||
/* Normal FreeRTOS yield from interrupt semantics, where
|
||||
xHigherPriorityTaskWoken is initialized to pdFALSE and will then get set to
|
||||
pdTRUE if the interrupt safe API unblocks a task that has a priority above
|
||||
that of the currently executing task. */
|
||||
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
/* Normal FreeRTOS yield from interrupt semantics, where
|
||||
* xHigherPriorityTaskWoken is initialized to pdFALSE and will then get set to
|
||||
* pdTRUE if the interrupt safe API unblocks a task that has a priority above
|
||||
* that of the currently executing task. */
|
||||
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xAreMessageBufferAMPTasksStillRunning( void )
|
||||
{
|
||||
static uint32_t ulLastCycleCounters[ mbaNUMBER_OF_CORE_B_TASKS ] = { 0 };
|
||||
BaseType_t x;
|
||||
static uint32_t ulLastCycleCounters[ mbaNUMBER_OF_CORE_B_TASKS ] = { 0 };
|
||||
BaseType_t x;
|
||||
|
||||
/* Called by the check task to determine the health status of the tasks
|
||||
implemented in this demo. */
|
||||
for( x = 0; x < mbaNUMBER_OF_CORE_B_TASKS; x++ )
|
||||
{
|
||||
if( ulLastCycleCounters[ x ] == ulCycleCounters[ x ] )
|
||||
{
|
||||
xDemoStatus = pdFAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
ulLastCycleCounters[ x ] = ulCycleCounters[ x ];
|
||||
}
|
||||
}
|
||||
/* Called by the check task to determine the health status of the tasks
|
||||
* implemented in this demo. */
|
||||
for( x = 0; x < mbaNUMBER_OF_CORE_B_TASKS; x++ )
|
||||
{
|
||||
if( ulLastCycleCounters[ x ] == ulCycleCounters[ x ] )
|
||||
{
|
||||
xDemoStatus = pdFAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
ulLastCycleCounters[ x ] = ulCycleCounters[ x ];
|
||||
}
|
||||
}
|
||||
|
||||
return xDemoStatus;
|
||||
return xDemoStatus;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue