Beispiel #1
0
static void prvCheckTask( void *pvParameters )
{
    /* This task is created in privileged mode so can access the file scope
    queue variable.  Take a stack copy of this before the task is set into user
    mode.  Once that task is in user mode the file scope queue variable will no
    longer be accessible but the stack copy will. */
    QueueHandle_t xQueue = xFileScopeCheckQueue;
    long lMessage;
    unsigned long ulStillAliveCounts[ 2 ] = { 0 };
    const char *pcStatusMessage = "PASS\r\n";

    /* The debug_printf() function uses RAM that is outside of the control of the
    application writer.  Therefore the application_defined_privileged_functions.h
    header file is used to provide a version that executes with privileges. */
    extern int MPU_debug_printf( const char *pcMessage );

    /* Just to remove compiler warning. */
    ( void ) pvParameters;

    /* Demonstrate how the various memory regions can and can't be accessed.
    The task privilege level is set down to user mode within this function. */
    prvTestMemoryRegions();

    /* Tests are done so lower the privilege status. */
    portSWITCH_TO_USER_MODE();

    /* This loop performs the main function of the task, which is blocking
    on a message queue then processing each message as it arrives. */
    for( ;; ) {
        /* Wait for the next message to arrive. */
        xQueueReceive( xQueue, &lMessage, portMAX_DELAY );

        switch( lMessage ) {
            case mainREG_TEST_1_STILL_EXECUTING	:
                /* Message from task 1, so task 1 must still be executing. */
                ( ulStillAliveCounts[ 0 ] )++;
                break;

            case mainREG_TEST_2_STILL_EXECUTING	:
                /* Message from task 2, so task 2 must still be executing. */
                ( ulStillAliveCounts[ 1 ] )++;
                break;

            case mainPRINT_SYSTEM_STATUS		:
                /* Message from tick hook, time to print out the system
                status.  If messages has stopped arriving from either reg
                test task then the status must be set to fail. */
                if( ( ulStillAliveCounts[ 0 ] == 0 ) || ( ulStillAliveCounts[ 1 ] == 0 )  ) {
                    /* One or both of the test tasks are no longer sending
                    'still alive' messages. */
                    pcStatusMessage = "FAIL\r\n";
                }

                /* Print a pass/fail message to the terminal.  This will be
                visible in the CrossWorks IDE. */
                MPU_debug_printf( pcStatusMessage );

                /* Reset the count of 'still alive' messages. */
                memset( ulStillAliveCounts, 0x00, sizeof( ulStillAliveCounts ) );
                break;

            default :
                /* Something unexpected happened.  Delete this task so the
                error is apparent (no output will be displayed). */
                prvDeleteMe();
                break;
        }
    }
}
Beispiel #2
0
static void prvCheckTask( void *pvParameters )
{
/* This task is created in privileged mode so can access the file scope
queue variable.  Take a stack copy of this before the task is set into user
mode.  Once that task is in user mode the file scope queue variable will no
longer be accessible but the stack copy will. */
QueueHandle_t xQueue = xFileScopeCheckQueue;
int32_t lMessage;
uint32_t ulStillAliveCounts[ 2 ] = { 0 };
const char *pcStatusMessage = "PASS\r\n";
volatile uint32_t ulStatus = pdPASS;


	/* Just to remove compiler warning. */
	( void ) pvParameters;

	/* Demonstrate how the various memory regions can and can't be accessed.
	The task privilege level is set down to user mode within this function. */
	prvTestMemoryRegions();

	/* Tests are done so lower the privilege status. */
	portSWITCH_TO_USER_MODE();

	/* This loop performs the main function of the task, which is blocking
	on a message queue then processing each message as it arrives. */
	for( ;; )
	{
		/* Wait for the next message to arrive. */
		xQueueReceive( xQueue, &lMessage, portMAX_DELAY );

		switch( lMessage )
		{
			case mainREG_TEST_1_STILL_EXECUTING	:
					/* Message from task 1, so task 1 must still be executing. */
					( ulStillAliveCounts[ 0 ] )++;
					break;

			case mainREG_TEST_2_STILL_EXECUTING	:
					/* Message from task 2, so task 2 must still be executing. */
					( ulStillAliveCounts[ 1 ] )++;
					break;

			case mainPRINT_SYSTEM_STATUS		:
					/* Message from tick hook, time to print out the system
					status.  If messages has stopped arriving from either reg
					test task then the status must be set to fail. */
					if( ( ulStillAliveCounts[ 0 ] == 0 ) || ( ulStillAliveCounts[ 1 ] == 0 )  )
					{
						/* One or both of the test tasks are no longer sending
						'still alive' messages. */
						pcStatusMessage = "FAIL\r\n";

						/* ulStatus can be viewed (live) in the Keil watch window. */
						ulStatus = pdFAIL;
						( void ) ulStatus;
					}

					/**** print pcStatusMessage here. ****/
					( void ) pcStatusMessage;

					/* Reset the count of 'still alive' messages. */
					memset( ulStillAliveCounts, 0x00, sizeof( ulStillAliveCounts ) );
					break;

		default :
					/* Something unexpected happened.  Delete this task so the
					error is apparent (no output will be displayed). */
					prvDeleteMe();
					break;
		}
	}
}
Beispiel #3
0
static void prvCheckTask( void *pvParameters )
{
/* This task is created in privileged mode so can access the file scope
queue variable.  Take a stack copy of this before the task is set into user
mode.  Once that task is in user mode the file scope queue variable will no
longer be accessible but the stack copy will. */
xQueueHandle xQueue = xFileScopeCheckQueue;
long lMessage;
unsigned long ulStillAliveCounts[ 2 ] = { 0 };
char *pcStatusMessage = "PASS\r\n";
unsigned char x = 5, y = 10;

	/* Just to remove compiler warning. */
	( void ) pvParameters;

	/* Demonstrate how the various memory regions can and can't be accessed. 
	The task privilege is set down to user mode within this function. */
	prvTestMemoryRegions();

	/* Change the memory regions allocated to this task to those initially
	set up for demonstration purposes to those actually required by the task. */
	vTaskAllocateMPURegions( NULL, xAltRegions );

	/* This loop performs the main function of the task, which is blocking
	on a message queue then processing each message as it arrives. */
	for( ;; )
	{
		/* Wait for the next message to arrive. */
		xQueueReceive( xQueue, &lMessage, portMAX_DELAY );
		
		switch( lMessage )
		{
			case mainREG_TEST_1_STILL_EXECUTING	:	
					/* Message from task 1, so task 1 must still be executing. */
					( ulStillAliveCounts[ 0 ] )++;
					break;

			case mainREG_TEST_2_STILL_EXECUTING	:						
					/* Message from task 2, so task 2 must still be executing. */
					( ulStillAliveCounts[ 1 ] )++;
					break;

			case mainPRINT_SYSTEM_STATUS		:	
					/* Message from tick hook, time to print out the system
					status.  If messages has stopped arriving from either reg
					test task then the status must be set to fail. */
					if( ( ulStillAliveCounts[ 0 ] == 0 ) || ( ulStillAliveCounts[ 1 ] == 0 )  )
					{
						/* One or both of the test tasks are no longer sending 
						'still alive' messages. */
						pcStatusMessage = "FAIL\r\n";
					}

					/* Print a pass/fail message to the LCD - moving the
					message each time to provide feedback that the output
					is still being produced.  LCD_PrintString() accesses const
					data stored in flash, which all tasks are at liberty to do, 
					and GPIO for which an MPU region has been set up for it. */
					LCD_ClearScreen();
					LCD_PrintString( x>>1, y>>1, pcStatusMessage, 6, COLOR_RED );
					x += 7;
					y += 9;

					/* Reset the count of 'still alive' messages. */
					memset( ulStillAliveCounts, 0x00, sizeof( ulStillAliveCounts ) );
					break;

		default :
					/* Something unexpected happened.  Delete this task so the 
					error is apparent (no output will be displayed). */
					prvDeleteMe();
					break;
		}
	}
}
Beispiel #4
0
static void prvCheckTask( void *pvParameters )
{
/* This task is created in privileged mode so can access the file scope
queue variable.  Take a stack copy of this before the task is set into user
mode.  Once that task is in user mode the file scope queue variable will no
longer be accessible but the stack copy will. */
QueueHandle_t xQueue = xGlobalScopeCheckQueue;
int32_t lMessage;
uint32_t ulStillAliveCounts[ 3 ] = { 0 };
const char *pcStatusMessage = "PASS\r\n";
uint32_t ulLastRegTest3CountValue = 0, ulLastRegTest4Value = 0;

/* The register test tasks that also test the floating point registers increment
a counter on each iteration of their loop.  The counters are inside the array
that this task has access to. */
volatile uint32_t *pulOverlaidCounter3 = ( uint32_t * ) &( cReadWriteArray[ 0 ] ), *pulOverlaidCounter4 = ( uint32_t * ) &( cReadWriteArray[ 4 ] );

/* ulCycleCount is incremented on each cycle of the check task.  It can be 
viewed updating in the Keil watch window as the simulator does not print to
the ITM port. */
volatile uint32_t ulCycleCount = 0;

	/* Just to remove compiler warning. */
	( void ) pvParameters;

	/* Demonstrate how the various memory regions can and can't be accessed.
	The task privilege level is set down to user mode within this function. */
	prvTestMemoryRegions();

	/* Clear overlaid reg test counters before entering the loop below. */
	*pulOverlaidCounter3 = 0UL;
	*pulOverlaidCounter4 = 0UL;

	/* This loop performs the main function of the task, which is blocking
	on a message queue then processing each message as it arrives. */
	for( ;; )
	{
		/* Wait for the next message to arrive. */
		xQueueReceive( xQueue, &lMessage, portMAX_DELAY );

		switch( lMessage )
		{
			case configREG_TEST_1_STILL_EXECUTING	:
			case configREG_TEST_2_STILL_EXECUTING	:
			case configTIMER_STILL_EXECUTING		:
					/* Message from the first or second register check task, or
					the timer callback function.  Increment the count of the
					number of times the message source has sent the message as
					the message source must still be executed. */
					( ulStillAliveCounts[ lMessage ] )++;
					break;

			case configPRINT_SYSTEM_STATUS		:
					/* Message from tick hook, time to print out the system
					status.  If messages have stopped arriving from either of
					the first two reg test task or the timer callback then the
					status must be set to fail. */
					if( ( ulStillAliveCounts[ 0 ] == 0 ) || ( ulStillAliveCounts[ 1 ] == 0 ) || ( ulStillAliveCounts[ 2 ] == 0 ) )
					{
						/* One or both of the test tasks are no longer sending
						'still alive' messages. */
						pcStatusMessage = "FAIL\r\n";
					}
					else
					{
						/* Reset the count of 'still alive' messages. */
						memset( ( void * ) ulStillAliveCounts, 0x00, sizeof( ulStillAliveCounts ) );
					}

					/* Check that the register test 3 task is still incrementing
					its counter, and therefore still running. */
					if( ulLastRegTest3CountValue == *pulOverlaidCounter3 )
					{
						pcStatusMessage = "FAIL\r\n";
					}
					ulLastRegTest3CountValue = *pulOverlaidCounter3;

					/* Check that the register test 4 task is still incrementing
					its counter, and therefore still running. */
					if( ulLastRegTest4Value == *pulOverlaidCounter4 )
					{
						pcStatusMessage = "FAIL\r\n";
					}
					ulLastRegTest4Value = *pulOverlaidCounter4;

					/**** Print pcStatusMessage here. ****/
					( void ) pcStatusMessage;
					
					/* The cycle count can be viewed updating in the Keil watch
					window if ITM printf is not being used. */
					ulCycleCount++;
					break;

		default :
					/* Something unexpected happened.  Delete this task so the
					error is apparent (no output will be displayed). */
					vMainDeleteMe();
					break;
		}
	}
}