mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-01 08:54:14 -04:00
Kernel source code:
+ Added xPortIsInsideInterrupt() to RVDS ARM CM4F port - the same will get added to other ports in time. Demo application code: + Added first pass Microchip CEC1302 demo for Keil. + Harden the new StaticAllocation.c standard demo tasks against integer promotion rules causing problems on 16-bit architectures.
This commit is contained in:
parent
732778a971
commit
42e73b9b8f
50 changed files with 24413 additions and 30 deletions
|
@ -244,7 +244,7 @@ stalled. */
|
|||
static volatile UBaseType_t uxCycleCounter = 0;
|
||||
|
||||
/* A variable that gets set to pdTRUE if an error is detected. */
|
||||
static BaseType_t xErrorOccurred = pdFALSE;
|
||||
static volatile BaseType_t xErrorOccurred = pdFALSE;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
@ -346,7 +346,7 @@ TickType_t xTickCount;
|
|||
xTickCount = xTaskGetTickCount();
|
||||
xReturned = xSemaphoreTake( xSemaphore, xShortBlockTime );
|
||||
|
||||
if( ( xTaskGetTickCount() - xTickCount) < xShortBlockTime )
|
||||
if( ( ( TickType_t ) ( xTaskGetTickCount() - xTickCount ) ) < xShortBlockTime )
|
||||
{
|
||||
/* Did not block on the semaphore as long as expected. */
|
||||
xErrorOccurred = pdTRUE;
|
||||
|
@ -396,7 +396,7 @@ TickType_t xTickCount;
|
|||
xTickCount = xTaskGetTickCount();
|
||||
xReturned = xSemaphoreTake( xSemaphore, xShortBlockTime );
|
||||
|
||||
if( ( xTaskGetTickCount() - xTickCount) < xShortBlockTime )
|
||||
if( ( ( TickType_t ) ( xTaskGetTickCount() - xTickCount ) ) < xShortBlockTime )
|
||||
{
|
||||
/* Did not block on the semaphore as long as expected. */
|
||||
xErrorOccurred = pdTRUE;
|
||||
|
|
|
@ -92,13 +92,28 @@
|
|||
|
||||
/* Task behaviour. */
|
||||
#define bktQUEUE_LENGTH ( 5 )
|
||||
#define bktSHORT_WAIT ( ( ( TickType_t ) 20 ) / portTICK_PERIOD_MS )
|
||||
#define bktSHORT_WAIT pdMS_TO_TICKS( ( TickType_t ) 20 )
|
||||
#define bktPRIMARY_BLOCK_TIME ( 10 )
|
||||
#define bktALLOWABLE_MARGIN ( 15 )
|
||||
#define bktTIME_TO_BLOCK ( 175 )
|
||||
#define bktDONT_BLOCK ( ( TickType_t ) 0 )
|
||||
#define bktRUN_INDICATOR ( ( UBaseType_t ) 0x55 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* The two test tasks. Their behaviour is commented within the files.
|
||||
*/
|
||||
static void vPrimaryBlockTimeTestTask( void *pvParameters );
|
||||
static void vSecondaryBlockTimeTestTask( void *pvParameters );
|
||||
|
||||
/*
|
||||
* Very basic tests to verify the block times are as expected.
|
||||
*/
|
||||
static void prvBasicDelayTests( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The queue on which the tasks block. */
|
||||
static QueueHandle_t xTestQueue;
|
||||
|
||||
|
@ -114,10 +129,6 @@ static volatile BaseType_t xErrorOccurred = pdFALSE;
|
|||
secondary task has executed. */
|
||||
static volatile UBaseType_t xRunIndicator;
|
||||
|
||||
/* The two test tasks. Their behaviour is commented within the files. */
|
||||
static void vPrimaryBlockTimeTestTask( void *pvParameters );
|
||||
static void vSecondaryBlockTimeTestTask( void *pvParameters );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vCreateBlockTimeTasks( void )
|
||||
|
@ -150,9 +161,16 @@ TickType_t xTimeToBlock, xBlockedTime;
|
|||
for( ;; )
|
||||
{
|
||||
/*********************************************************************
|
||||
Test 1
|
||||
Test 0
|
||||
|
||||
Simple block time wakeup test on queue receives. */
|
||||
Basic vTaskDelay() and vTaskDelayUntil() tests. */
|
||||
prvBasicDelayTests();
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
Test 1
|
||||
|
||||
Simple block time wakeup test on queue receives. */
|
||||
for( xItem = 0; xItem < bktQUEUE_LENGTH; xItem++ )
|
||||
{
|
||||
/* The queue is empty. Attempt to read from the queue using a block
|
||||
|
@ -187,9 +205,9 @@ TickType_t xTimeToBlock, xBlockedTime;
|
|||
}
|
||||
|
||||
/*********************************************************************
|
||||
Test 2
|
||||
Test 2
|
||||
|
||||
Simple block time wakeup test on queue sends.
|
||||
Simple block time wakeup test on queue sends.
|
||||
|
||||
First fill the queue. It should be empty so all sends should pass. */
|
||||
for( xItem = 0; xItem < bktQUEUE_LENGTH; xItem++ )
|
||||
|
@ -238,7 +256,7 @@ TickType_t xTimeToBlock, xBlockedTime;
|
|||
}
|
||||
|
||||
/*********************************************************************
|
||||
Test 3
|
||||
Test 3
|
||||
|
||||
Wake the other task, it will block attempting to post to the queue.
|
||||
When we read from the queue the other task will wake, but before it
|
||||
|
@ -313,7 +331,7 @@ TickType_t xTimeToBlock, xBlockedTime;
|
|||
|
||||
|
||||
/*********************************************************************
|
||||
Test 4
|
||||
Test 4
|
||||
|
||||
As per test 3 - but with the send and receive the other way around.
|
||||
The other task blocks attempting to read from the queue.
|
||||
|
@ -400,21 +418,21 @@ BaseType_t xData;
|
|||
for( ;; )
|
||||
{
|
||||
/*********************************************************************
|
||||
Test 1 and 2
|
||||
Test 0, 1 and 2
|
||||
|
||||
This task does does not participate in these tests. */
|
||||
vTaskSuspend( NULL );
|
||||
|
||||
/*********************************************************************
|
||||
Test 3
|
||||
Test 3
|
||||
|
||||
The first thing we do is attempt to read from the queue. It should be
|
||||
full so we block. Note the time before we block so we can check the
|
||||
wake time is as per that expected. */
|
||||
xTimeWhenBlocking = xTaskGetTickCount();
|
||||
|
||||
/* We should unblock after bktTIME_TO_BLOCK having not sent
|
||||
anything to the queue. */
|
||||
/* We should unblock after bktTIME_TO_BLOCK having not sent anything to
|
||||
the queue. */
|
||||
xData = 0;
|
||||
xRunIndicator = bktRUN_INDICATOR;
|
||||
if( xQueueSend( xTestQueue, &xData, bktTIME_TO_BLOCK ) != errQUEUE_FULL )
|
||||
|
@ -480,6 +498,52 @@ BaseType_t xData;
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvBasicDelayTests( void )
|
||||
{
|
||||
TickType_t xPreTime, xPostTime, x, xLastUnblockTime, xExpectedUnblockTime;
|
||||
const TickType_t xPeriod = 75, xCycles = 5, xAllowableMargin = ( bktALLOWABLE_MARGIN >> 1 );
|
||||
|
||||
/* Temporarily increase priority so the timing is more accurate, but not so
|
||||
high as to disrupt the timer tests. */
|
||||
vTaskPrioritySet( NULL, configTIMER_TASK_PRIORITY - 1 );
|
||||
|
||||
/* Crude check to too that vTaskDelay() blocks for the expected period. */
|
||||
xPreTime = xTaskGetTickCount();
|
||||
vTaskDelay( bktTIME_TO_BLOCK );
|
||||
xPostTime = xTaskGetTickCount();
|
||||
|
||||
/* The priority is higher, so the allowable margin is halved when compared
|
||||
to the other tests in this file. */
|
||||
if( ( xPostTime - xPreTime ) > ( bktTIME_TO_BLOCK + xAllowableMargin ) )
|
||||
{
|
||||
xErrorOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
/* Now crude tests to check the vTaskDelayUntil() functionality. */
|
||||
xPostTime = xTaskGetTickCount();
|
||||
xLastUnblockTime = xPostTime;
|
||||
|
||||
for( x = 0; x < xCycles; x++ )
|
||||
{
|
||||
/* Calculate the next expected unblock time from the time taken before
|
||||
this loop was entered. */
|
||||
xExpectedUnblockTime = xPostTime + ( x * xPeriod );
|
||||
|
||||
vTaskDelayUntil( &xLastUnblockTime, xPeriod );
|
||||
|
||||
if( ( xTaskGetTickCount() - xExpectedUnblockTime ) > ( bktTIME_TO_BLOCK + xAllowableMargin ) )
|
||||
{
|
||||
xErrorOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
xPrimaryCycles++;
|
||||
}
|
||||
|
||||
/* Reset to the original task priority ready for the other tests. */
|
||||
vTaskPrioritySet( NULL, bktPRIMARY_PRIORITY );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xAreBlockTimeTestTasksStillRunning( void )
|
||||
{
|
||||
static BaseType_t xLastPrimaryCycleCount = 0, xLastSecondaryCycleCount = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue