示例#1
0
int main( void )
{
	prvSetupHardware();

	/* Create the queue used to pass "I'm alive" messages to the check task. */
	xFileScopeCheckQueue = xQueueCreate( 1, sizeof( uint32_t ) );

	/* One check task uses the task parameter to receive the queue handle.
	This allows the file scope variable to be accessed from within the task.
	The pvParameters member of xRegTest2Parameters can only be set after the
	queue has been created so is set here. */
	xRegTest2Parameters.pvParameters = xFileScopeCheckQueue;

	/* Create the three test tasks.  Handles to the created tasks are not
	required, hence the second parameter is NULL. */
	xTaskCreateRestricted( &xRegTest1Parameters, NULL );
    xTaskCreateRestricted( &xRegTest2Parameters, NULL );
	xTaskCreateRestricted( &xCheckTaskParameters, NULL );

	/* Create a task that does nothing but ensure some of the MPU API functions
	can be called correctly, then get deleted.  This is done for code coverage
	test purposes only.  The task's handle is saved in xTaskToDelete so it can 
	get deleted in the idle task hook. */
	xTaskCreateRestricted( &xTaskToDeleteParameters, &xTaskToDelete );

	/* Create the tasks that are created using the original xTaskCreate() API
	function. */
	xTaskCreate(	prvOldStyleUserModeTask,	/* The function that implements the task. */
					"Task1",					/* Text name for the task. */
					100,						/* Stack depth in words. */
					NULL,						/* Task parameters. */
					3,							/* Priority and mode (user in this case). */
					NULL						/* Handle. */
				);

	xTaskCreate(	prvOldStylePrivilegedModeTask,	/* The function that implements the task. */
					"Task2",						/* Text name for the task. */
					100,							/* Stack depth in words. */
					NULL,							/* Task parameters. */
					( 3 | portPRIVILEGE_BIT ),		/* Priority and mode. */
					NULL							/* Handle. */
				);

	/* Create and start the software timer. */
	xTimer = xTimerCreate( "Timer", 			/* Test name for the timer. */
							mainTIMER_PERIOD, 	/* Period of the timer. */
							pdTRUE,				/* The timer will auto-reload itself. */
							( void * ) 0,		/* The timer's ID is used to count the number of times it expires - initialise this to 0. */
							prvTimerCallback );	/* The function called when the timer expires. */
	configASSERT( xTimer );
	xTimerStart( xTimer, mainDONT_BLOCK );

	/* Start the scheduler. */
	vTaskStartScheduler();

	/* Will only get here if there was insufficient memory to create the idle
	task. */
	for( ;; );
	return 0;
}
示例#2
0
文件: main.c 项目: peterliu2/FreeRTOS
int main( void )
{
    prvSetupHardware();

    /* Create the queue used to pass "I'm alive" messages to the check task. */
    xFileScopeCheckQueue = xQueueCreate( 1, sizeof( unsigned long ) );

    /* One check task uses the task parameter to receive the queue handle.
    This allows the file scope variable to be accessed from within the task.
    The pvParameters member of xRegTest2Parameters can only be set after the
    queue has been created so is set here. */
    xRegTest2Parameters.pvParameters = xFileScopeCheckQueue;

    /* Create the three test tasks.  Handles to the created tasks are not
    required, hence the second parameter is NULL. */
    xTaskCreateRestricted( &xRegTest1Parameters, NULL );
    xTaskCreateRestricted( &xRegTest2Parameters, NULL );
    xTaskCreateRestricted( &xCheckTaskParameters, NULL );

    /* Create the tasks that are created using the original xTaskCreate() API
    function. */
    xTaskCreate(	prvOldStyleUserModeTask,	/* The function that implements the task. */
                    "Task1",					/* Text name for the task. */
                    100,						/* Stack depth in words. */
                    NULL,						/* Task parameters. */
                    3,							/* Priority and mode (user in this case). */
                    NULL						/* Handle. */
               );

    xTaskCreate(	prvOldStylePrivilegedModeTask,	/* The function that implements the task. */
                    "Task2",						/* Text name for the task. */
                    100,							/* Stack depth in words. */
                    NULL,							/* Task parameters. */
                    ( 3 | portPRIVILEGE_BIT ),		/* Priority and mode. */
                    NULL							/* Handle. */
               );

    /* Start the scheduler. */
    vTaskStartScheduler();

    /* Will only get here if there was insufficient memory to create the idle
    task. */
    for( ;; );
    return 0;
}
示例#3
0
BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask )
{
BaseType_t xReturn;
BaseType_t xRunningPrivileged = xPortRaisePrivilege();

	xReturn = xTaskCreateRestricted( pxTaskDefinition, pxCreatedTask );
	vPortResetPrivilege( xRunningPrivileged );
	return xReturn;
}