Example #1
0
void init_task_relay(void) {
    xTaskCreate( relay_task, ( signed portCHAR * ) "Relay", (configMINIMAL_STACK_SIZE * 2), \
                 NULL, tskIDLE_PRIORITY + 1, (xTaskHandle *) &hdl_relay );
}
Example #2
0
void vStartBlockingQueueTasks( unsigned portBASE_TYPE uxPriority )
{
xBlockingQueueParameters *pxQueueParameters1, *pxQueueParameters2;
xBlockingQueueParameters *pxQueueParameters3, *pxQueueParameters4;
xBlockingQueueParameters *pxQueueParameters5, *pxQueueParameters6;
const unsigned portBASE_TYPE uxQueueSize1 = 1, uxQueueSize5 = 5;
const portTickType xBlockTime = ( portTickType ) 1000 / portTICK_RATE_MS;
const portTickType xDontBlock = ( portTickType ) 0;

	/* Create the first two tasks as described at the top of the file. */

	/* First create the structure used to pass parameters to the consumer tasks. */
	pxQueueParameters1 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );

	/* Create the queue used by the first two tasks to pass the incrementing number.
	Pass a pointer to the queue in the parameter structure. */
	pxQueueParameters1->xQueue = xQueueCreate( uxQueueSize1, ( unsigned portBASE_TYPE ) sizeof( unsigned short ) );

	/* The consumer is created first so gets a block time as described above. */
	pxQueueParameters1->xBlockTime = xBlockTime;

	/* Pass in the variable that this task is going to increment so we can check it
	is still running. */
	pxQueueParameters1->psCheckVariable = &( sBlockingConsumerCount[ 0 ] );

	/* Create the structure used to pass parameters to the producer task. */
	pxQueueParameters2 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );

	/* Pass the queue to this task also, using the parameter structure. */
	pxQueueParameters2->xQueue = pxQueueParameters1->xQueue;

	/* The producer is not going to block - as soon as it posts the consumer will
	wake and remove the item so the producer should always have room to post. */
	pxQueueParameters2->xBlockTime = xDontBlock;

	/* Pass in the variable that this task is going to increment so we can check
	it is still running. */
	pxQueueParameters2->psCheckVariable = &( sBlockingProducerCount[ 0 ] );


	/* Note the producer has a lower priority than the consumer when the tasks are
	spawned. */
	xTaskCreate( vBlockingQueueConsumer, ( signed char * ) "QConsB1", blckqSTACK_SIZE, ( void * ) pxQueueParameters1, uxPriority, NULL );
	xTaskCreate( vBlockingQueueProducer, ( signed char * ) "QProdB2", blckqSTACK_SIZE, ( void * ) pxQueueParameters2, tskIDLE_PRIORITY, NULL );



	/* Create the second two tasks as described at the top of the file.   This uses
	the same mechanism but reverses the task priorities. */

	pxQueueParameters3 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
	pxQueueParameters3->xQueue = xQueueCreate( uxQueueSize1, ( unsigned portBASE_TYPE ) sizeof( unsigned short ) );
	pxQueueParameters3->xBlockTime = xDontBlock;
	pxQueueParameters3->psCheckVariable = &( sBlockingProducerCount[ 1 ] );

	pxQueueParameters4 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
	pxQueueParameters4->xQueue = pxQueueParameters3->xQueue;
	pxQueueParameters4->xBlockTime = xBlockTime;
	pxQueueParameters4->psCheckVariable = &( sBlockingConsumerCount[ 1 ] );

	xTaskCreate( vBlockingQueueConsumer, ( signed char * ) "QConsB3", blckqSTACK_SIZE, ( void * ) pxQueueParameters3, tskIDLE_PRIORITY, NULL );
	xTaskCreate( vBlockingQueueProducer, ( signed char * ) "QProdB4", blckqSTACK_SIZE, ( void * ) pxQueueParameters4, uxPriority, NULL );



	/* Create the last two tasks as described above.  The mechanism is again just
	the same.  This time both parameter structures are given a block time. */
	pxQueueParameters5 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
	pxQueueParameters5->xQueue = xQueueCreate( uxQueueSize5, ( unsigned portBASE_TYPE ) sizeof( unsigned short ) );
	pxQueueParameters5->xBlockTime = xBlockTime;
	pxQueueParameters5->psCheckVariable = &( sBlockingProducerCount[ 2 ] );

	pxQueueParameters6 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
	pxQueueParameters6->xQueue = pxQueueParameters5->xQueue;
	pxQueueParameters6->xBlockTime = xBlockTime;
	pxQueueParameters6->psCheckVariable = &( sBlockingConsumerCount[ 2 ] );

	xTaskCreate( vBlockingQueueProducer, ( signed char * ) "QProdB5", blckqSTACK_SIZE, ( void * ) pxQueueParameters5, tskIDLE_PRIORITY, NULL );
	xTaskCreate( vBlockingQueueConsumer, ( signed char * ) "QConsB6", blckqSTACK_SIZE, ( void * ) pxQueueParameters6, tskIDLE_PRIORITY, NULL );
}
Example #3
0
static void prvDemonstrateTaskStateAndHandleGetFunctions( void )
{
TaskHandle_t xIdleTaskHandle, xTimerTaskHandle;
char *pcTaskName;
static portBASE_TYPE xPerformedOneShotTests = pdFALSE;
TaskHandle_t xTestTask;

	/* Demonstrate the use of the xTimerGetTimerDaemonTaskHandle() and
	xTaskGetIdleTaskHandle() functions.  Also try using the function that sets
	the task number. */
	xIdleTaskHandle = xTaskGetIdleTaskHandle();
	xTimerTaskHandle = xTimerGetTimerDaemonTaskHandle();

	/* This is the idle hook, so the current task handle should equal the
	returned idle task handle. */
	if( xTaskGetCurrentTaskHandle() != xIdleTaskHandle )
	{
		pcStatusMessage = "Error:  Returned idle task handle was incorrect";
	}

	/* Check the timer task handle was returned correctly. */
	pcTaskName = pcTaskGetTaskName( xTimerTaskHandle );
	if( strcmp( pcTaskName, "Tmr Svc" ) != 0 )
	{
		pcStatusMessage = "Error:  Returned timer task handle was incorrect";
	}

	/* This task is running, make sure it's state is returned as running. */
	if( eTaskStateGet( xIdleTaskHandle ) != eRunning )
	{
		pcStatusMessage = "Error:  Returned idle task state was incorrect";
	}

	/* If this task is running, then the timer task must be blocked. */
	if( eTaskStateGet( xTimerTaskHandle ) != eBlocked )
	{
		pcStatusMessage = "Error:  Returned timer task state was incorrect";
	}

	/* Other tests that should only be performed once follow.  The test task
	is not created on each iteration because to do so would cause the death
	task to report an error (too many tasks running). */
	if( xPerformedOneShotTests == pdFALSE )
	{
		/* Don't run this part of the test again. */
		xPerformedOneShotTests = pdTRUE;

		/* Create a test task to use to test other eTaskStateGet() return values. */
		if( xTaskCreate( prvTestTask, "Test", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, &xTestTask ) == pdPASS )
		{
			/* If this task is running, the test task must be in the ready state. */
			if( eTaskStateGet( xTestTask ) != eReady )
			{
				pcStatusMessage = "Error: Returned test task state was incorrect 1";
			}

			/* Now suspend the test task and check its state is reported correctly. */
			vTaskSuspend( xTestTask );
			if( eTaskStateGet( xTestTask ) != eSuspended )
			{
				pcStatusMessage = "Error: Returned test task state was incorrect 2";
			}

			/* Now delete the task and check its state is reported correctly. */
			vTaskDelete( xTestTask );
			if( eTaskStateGet( xTestTask ) != eDeleted )
			{
				pcStatusMessage = "Error: Returned test task state was incorrect 3";
			}
		}
	}
}
Example #4
0
void main_full( void )
{
	/* The baud rate setting here has no effect, hence it is set to 0 to
	make that obvious. */
	xSerialPortInitMinimal( 0, mainUART_QUEUE_LENGTHS );

	/* If the file system is only going to be accessed from one task then
	F_FS_THREAD_AWARE can be set to 0 and the set of example files are created
	before the RTOS scheduler is started.  If the file system is going to be
	access from more than one task then F_FS_THREAD_AWARE must be set to 1 and
	the	set of sample files are created from the idle task hook function
	vApplicationIdleHook() - which is defined in this file. */
	#if ( mainINCLUDE_FAT_SL_DEMO == 1 )&& ( F_FS_THREAD_AWARE == 0 )
	{
		/* Initialise the drive and file system, then create a few example
		files.  The output from this function just goes to the stdout window,
		allowing the output to be viewed when the UDP command console is not
		connected. */
		vCreateAndVerifySampleFiles();
	}
	#endif

	/* Start all the other standard demo/test tasks.  The have not particular
	functionality, but do demonstrate how to use the FreeRTOS API and test the
	kernel port. */
	vStartDynamicPriorityTasks();
	vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
	vCreateBlockTimeTasks();
	vStartCountingSemaphoreTasks();
	vStartGenericQueueTasks( tskIDLE_PRIORITY );
	vStartRecursiveMutexTasks();
	vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
	vStartMathTasks( mainFLOP_TASK_PRIORITY );
	vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
	vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );

	#if mainINCLUDE_FAT_SL_DEMO == 1
	{
		/* Start the tasks that implements the command console on the UART, as
		described above. */
		vUARTCommandConsoleStart( mainUART_COMMAND_CONSOLE_STACK_SIZE, mainUART_COMMAND_CONSOLE_TASK_PRIORITY );

		/* Register both the standard and file system related CLI commands. */
		vRegisterSampleCLICommands();
		vRegisterFileSystemCLICommands();
	}
	#else
	{
		/* The COM test tasks can use the UART if the CLI is not used by the
		FAT SL demo.  The COM test tasks require a UART connector to be fitted
		to the UART port. */
		vAltStartComTestTasks( mainCOM_TEST_TASK_PRIORITY, mainBAUD_RATE, mainCOM_TEST_LED );
	}
	#endif


	/* Create the register check tasks, as described at the top of this
	file */
	xTaskCreate( prvRegTestTaskEntry1, "Reg1", configMINIMAL_STACK_SIZE, mainREG_TEST_TASK_1_PARAMETER, tskIDLE_PRIORITY, NULL );
	xTaskCreate( prvRegTestTaskEntry2, "Reg2", configMINIMAL_STACK_SIZE, mainREG_TEST_TASK_2_PARAMETER, tskIDLE_PRIORITY, NULL );

	/* Create the task that performs the 'check' functionality,	as described at
	the top of this file. */
	xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );

	/* The set of tasks created by the following function call have to be
	created last as they keep account of the number of tasks they expect to see
	running. */
	vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );

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

	/* If all is well, the scheduler will now be running, and the following
	line will never be reached.  If the following line does execute, then
	there was either insufficient FreeRTOS heap memory available for the idle
	and/or timer tasks to be created, or vTaskStartScheduler() was called from
	User mode.  See the memory management section on the FreeRTOS web site for
	more details on the FreeRTOS heap http://www.freertos.org/a00111.html.  The
	mode from which main() is called is set in the C start up code and must be
	a privileged mode (not user mode). */
	for( ;; );
}
Example #5
0
/*!
 * \brief The task function for the "Check" task.
 */
static void vErrorChecks( void *pvParameters )
{
static volatile unsigned portLONG ulDummyVariable = 3UL;
unsigned portLONG ulMemCheckTaskRunningCount;
xTaskHandle xCreatedTask;
portBASE_TYPE bSuicidalTask = 0;

	/* The parameters are not used.  Prevent compiler warnings. */
	( void ) pvParameters;

	/* Cycle for ever, delaying then checking all the other tasks are still
	operating without error.

	In addition to the standard tests the memory allocator is tested through
	the dynamic creation and deletion of a task each cycle.  Each time the
	task is created memory must be allocated for its stack.  When the task is
	deleted this memory is returned to the heap.  If the task cannot be created
	then it is likely that the memory allocation failed. */

	for( ;; )
	{
		/* Do this only once. */
		if( bSuicidalTask == 0 )
		{
			bSuicidalTask++;

			/* This task has to be created last as it keeps account of the number of
			tasks it expects to see running. However its implementation expects
			to be called before vTaskStartScheduler(). We're in the case here where
			vTaskStartScheduler() has already been called (thus the hidden IDLE task
			has already been spawned). Since vCreateSuicidalTask() supposes that the
			IDLE task isn't included in the response from uxTaskGetNumberOfTasks(),
			let the MEM_CHECK task play that role. => this is why vCreateSuicidalTasks()
			is not called as the last task. */
			vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
		}

		/* Reset xCreatedTask.  This is modified by the task about to be
		created so we can tell if it is executing correctly or not. */
		xCreatedTask = mainNO_TASK;

		/* Dynamically create a task - passing ulMemCheckTaskRunningCount as a
		parameter. */
		ulMemCheckTaskRunningCount = mainCOUNT_INITIAL_VALUE;

		if( xTaskCreate( vMemCheckTask,
			( signed portCHAR * ) "MEM_CHECK",
			configMINIMAL_STACK_SIZE,
			( void * ) &ulMemCheckTaskRunningCount,
			tskIDLE_PRIORITY, &xCreatedTask ) != pdPASS )
		{
			/* Could not create the task - we have probably run out of heap.
			Don't go any further and flash the LED faster to provide visual
			feedback of the error. */
			prvIndicateError();
		}

		/* Delay until it is time to execute again. */
		vTaskDelay( mainCHECK_PERIOD );

		/* Delete the dynamically created task. */
		if( xCreatedTask != mainNO_TASK )
		{
			vTaskDelete( xCreatedTask );
		}

		/* Perform a bit of 32bit maths to ensure the registers used by the
		integer tasks get some exercise. The result here is not important -
		see the demo application documentation for more info. */
		ulDummyVariable *= 3;

		/* Check all other tasks are still operating without error.
		Check that vMemCheckTask did increment the counter. */
		if( ( prvCheckOtherTasksAreStillRunning() != pdFALSE )
		 || ( ulMemCheckTaskRunningCount == mainCOUNT_INITIAL_VALUE ) )
		{
			/* An error has occurred in one of the tasks.
			Don't go any further and flash the LED faster to give visual
			feedback of the error. */
			prvIndicateError();
		}
		else
		{
			/* Toggle the LED if everything is okay. */
			vParTestToggleLED( mainCHECK_TASK_LED );
		}
	}
}
Example #6
0
int main()
{
	microcontroller_init();

	uart1_queue_init(57600l);  // default baudrate: 57600 due to XBee bi-direction communication


	printf("Gluonpilot v%s ", version);
#ifdef LIMITED  // Limited version is pre-loaded on modules sent to Non-European countries
	printf("Limited version");
#endif
	
	printf(" [%s %s, config: %dB, logline: %dB, navigation: %dB, double: %dB]\r\n\r\n",
                __DATE__, __TIME__, sizeof(struct Configuration), sizeof(struct LogLine), sizeof(gluonscript_data.codes), sizeof(double));
	
	microcontroller_reset_type();  // printf out reason of reset; for debugging
	led_init();

	// Create semaphores needed for FreeRTOS synchronization (better to do it know, they are changed in interrupts of uart2 and ppm)
	vSemaphoreCreateBinary( xSpiSemaphore );
	vSemaphoreCreateBinary( xGpsSemaphore );

	// What hardware version are we using?
	configuration_determine_hardware_version();
	if (HARDWARE_VERSION == V01N)
		printf("Found hardware version v0.1n\r\n");
	else if (HARDWARE_VERSION == V01O)
		printf("Found hardware version v0.1o\r\n");
    else if (HARDWARE_VERSION == V01Q)
		printf("Found hardware version v0.1q (GP2)\r\n");
	else
		printf("Found hardware version v0.1j or earlier\r\n");
	
	// Open flash & load configuration
	dataflash_open();
	printf("%d MB flash found \r\n", (int)PAGE_SIZE/264);
	//printf("Loading configuration...");
	configuration_load();
	//printf("done\r\n");

	
	// Open RC receiver input: pwm_in/ppm_in task: in ppm_in/pwm_in.c
	// This is too low level to do it in the control task
	if (config.control.use_pwm)
	{
		pwm_in_open(); 
		uart1_puts("Waiting for pwm");
		pwm_in_wait_for();
		if (! (ppm.channel[0] > 900 && ppm.channel[0] < 2100))
			uart1_puts("not found!\r\n");
		else
			uart1_puts("done\r\n");
	} 
	else
	{
		uart1_puts("Opening ppm...");
		ppm_in_open(); // We need a complete frame (which takes at least 20ms) to start so never can start early enough!
		uart1_puts(" done\r\n");
	}	
	

	// Create our tasks. 
	if (config.control.servo_mix == QUADROCOPTER)
		xTaskCreate( control_copter_task,            ( signed portCHAR * ) "CControl",      ( configMINIMAL_STACK_SIZE * 3 ), NULL, tskIDLE_PRIORITY + 7, NULL );
	else
		xTaskCreate( control_wing_task,            ( signed portCHAR * ) "WControl",      ( configMINIMAL_STACK_SIZE * 3 ), NULL, tskIDLE_PRIORITY + 7, NULL );

    if (HARDWARE_VERSION == V01Q)
    	xTaskCreate( sensors_mpu6000_task,                 ( signed portCHAR * ) "Sensors",      ( configMINIMAL_STACK_SIZE * 5 ), NULL, tskIDLE_PRIORITY + 6, NULL );
    else
        xTaskCreate( sensors_analog_task,                 ( signed portCHAR * ) "Sensors",      ( configMINIMAL_STACK_SIZE * 5 ), NULL, tskIDLE_PRIORITY + 6, NULL );

    xTaskCreate( sensors_gps_task,             ( signed portCHAR * ) "GpsNavi",      ( configMINIMAL_STACK_SIZE * 4 ), NULL, tskIDLE_PRIORITY + 5, NULL );
	xTaskCreate( communication_input_task,     ( signed portCHAR * ) "ConsoleInput", ( configMINIMAL_STACK_SIZE * 5 ), NULL, tskIDLE_PRIORITY + 4, NULL );
	xTaskCreate( datalogger_task,              ( signed portCHAR * ) "Dataflash",    ( configMINIMAL_STACK_SIZE * 3 ), NULL, tskIDLE_PRIORITY + 3, NULL );
	xTaskCreate( communication_telemetry_task, ( signed portCHAR * ) "Telemetry",    ( configMINIMAL_STACK_SIZE * 2 ), NULL, tskIDLE_PRIORITY + 2, NULL );
    xTaskCreate( osd_task,                     ( signed portCHAR * ) "OSD",          ( configMINIMAL_STACK_SIZE * 1 ), NULL, tskIDLE_PRIORITY + 1, NULL );

#ifdef USE_TRACING
    printf("\r\nENABLING TRACING\r\n");
    setup_trace_pins();
#endif

	// Order the scheduler to start scheduling our two tasks.
	vTaskStartScheduler();
	
	// We should only get here when the scheduler wasn't able to allocate enough memory.
	uart1_puts("Not enough heap!\r\n");
	
	return 1;
}
Example #7
0
File: main.c Project: wugsh/wgs
static void prvOptionallyCreateComprehensveTestApplication( void )
{
	#if ( mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY == 0 )
	{
	TimerHandle_t xCheckTimer = NULL;

		/* Configure the interrupts used to test FPU registers being used from
		nested interrupts. */
		prvSetupNestedFPUInterruptsTest();

		/* Start all the other standard demo/test tasks. */
		vStartIntegerMathTasks( tskIDLE_PRIORITY );
		vStartDynamicPriorityTasks();
		vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
		vCreateBlockTimeTasks();
		vStartCountingSemaphoreTasks();
		vStartGenericQueueTasks( tskIDLE_PRIORITY );
		vStartRecursiveMutexTasks();
		vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
		vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );

		/* Most importantly, start the tasks that use the FPU. */
		vStartMathTasks( mainFLOP_TASK_PRIORITY );

		/* Create the register check tasks, as described at the top of this
		file */
		xTaskCreate( vRegTest1Task, "Reg1", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );
		xTaskCreate( vRegTest2Task, "Reg2", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );

		/* Create the semaphore that is used to demonstrate a task being
		synchronised with an interrupt. */
		vSemaphoreCreateBinary( xTestSemaphore );

		/* Create the task that is unblocked by the demonstration interrupt. */
		xTaskCreate( prvButtonTestTask, "BtnTest", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );

		/* Create the software timer that performs the 'check' functionality,
		as described at the top of this file. */
		xCheckTimer = xTimerCreate( "CheckTimer",					/* A text name, purely to help debugging. */
									( mainCHECK_TIMER_PERIOD_MS ),	/* The timer period, in this case 3000ms (3s). */
									pdTRUE,							/* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */
									( void * ) 0,					/* The ID is not used, so can be set to anything. */
									prvCheckTimerCallback			/* The callback function that inspects the status of all the other tasks. */
								  );

		if( xCheckTimer != NULL )
		{
			xTimerStart( xCheckTimer, mainDONT_BLOCK );
		}

		/* This task has to be created last as it keeps account of the number of
		tasks it expects to see running. */
		vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
	}
	#else /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
	{
		/* Just to prevent compiler warnings when the configuration options are
		set such that these static functions are not used. */
		( void ) vRegTest1Task;
		( void ) vRegTest2Task;
		( void ) prvCheckTimerCallback;
		( void ) prvSetupNestedFPUInterruptsTest;
	}
	#endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
}
Example #8
0
File: main.c Project: Eclo/FreeRTOS
int main( void )
{
	configASSERT( ul1 == 0x123 );
	configASSERT( ul2 == 0 );
	prvSetupHardware();

	/* Create the queue used to pass "I'm alive" messages to the check task. */
	xGlobalScopeCheckQueue = 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 = xGlobalScopeCheckQueue;

	/* Create 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 the third and fourth register check tasks, as described at the top
	of this file. */
	xTaskCreate( prvRegTest3Task, "Reg3", configMINIMAL_STACK_SIZE, configREG_TEST_TASK_3_PARAMETER, tskIDLE_PRIORITY, NULL );
	xTaskCreate( prvRegTest4Task, "Reg4", configMINIMAL_STACK_SIZE, configREG_TEST_TASK_4_PARAMETER, tskIDLE_PRIORITY, NULL );

	/* 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( ;; );
}
Example #9
0
/**
* @brief Menu Task.
*
*   This function allows the user to select which task to start:
*   Record a program or Play a program.
*
*   On initial launch, the arm may be in an unknown state so the first
*   function called is used to reset the arm into a known position.
*
*   Upon return to the menu task, from the record and play tasks,
*   the arm may be in an unknown position, so the reset task may
*   be called appropriately.
*
* @param [in] pvParameter Standard FreeRTOS method of passing parameters.
* @return Void.
*/
void vTaskMenu( void *pvParameters )
{
    portSHORT sReceivedValue;
    portBASE_TYPE xKeyPadQueueStatus;
    const portTickType xTicksToWait = 1000 / portTICK_RATE_MS;
    enum xChoice_t {RECORD_A_PROGRAM, PLAY_A_PROGRAM} xChoice;
    portCHAR *pcChoices[] =
    {
        "Record a Program",
        "Play a Program"
    };
    xChoice = RECORD_A_PROGRAM;

    printf("Menu\n");
    if (xSystemState != MENU_SELECT)
    {
        vWaitForReset();
    }

    vPrintToLCD(1,"Select Option:");
    vPrintToLCD(2,pcChoices[xChoice]);

    for(;;)
    {
        if( uxQueueMessagesWaiting( xKeyPadQueue ) != 0)
        {
            printf( "Queue should have been empty!\r\n" );
        }
        xKeyPadQueueStatus = xQueueReceive( xKeyPadQueue, &sReceivedValue, xTicksToWait );
        if( xKeyPadQueueStatus == pdPASS )
        {
//      printf( "Received = %d \t", sReceivedValue);
            switch (sReceivedValue)
            {

            case RESET:
                break;
            case PLAY:
                break;
            case PAUSE:
                break;
            case STOP:
                break;

            case ENTER:
                switch (xChoice)
                {
                case RECORD_A_PROGRAM:
                    printf("%s\n",pcChoices[xChoice]);
                    xSystemState = RECORDING;

                    xTaskCreate(vTaskRecord,
                                "Record Task",
                                2000,
                                NULL,
                                1,
                                &xRecordHandle);
                    /* Get out of here */
                    vTaskDelete( NULL);
                    break;

                case PLAY_A_PROGRAM:
                    printf("%s\n",pcChoices[xChoice]);
                    xSystemState = PLAYING;

                    xTaskCreate(vTaskPlay,
                                "Play Task",
                                PLAY_TASK_STACK_SIZE,
                                NULL,
                                1,
                                &xPlayHandle);
                    /* Get out of here */
                    vTaskDelete( NULL);
                    break;
                default:
                    break;
                }
                break;
            case CANCEL:
                break;

            case XUP:
            case UP:
            case XRIGHT:
            case RIGHT:
                if (++xChoice >= NUMBER_OF_CHOICES)
                {
                    xChoice = 0;
                }
                break;
            case XDOWN:
            case DOWN:
            case XLEFT:
            case LEFT:
                /* enum is an unsigned int, checking below zero doesn't work
                 * so check if value is above the max number aswell */
                --xChoice;
                if (xChoice < 0 || xChoice > NUMBER_OF_CHOICES)
                {
                    xChoice = NUMBER_OF_CHOICES - 1;
                }
                break;

            default:
                break;
            }
            vPrintToLCD(2,pcChoices[xChoice]);
        }
        else
        {
            //printf( "Could not receive from the queue.\r\n");
        }
        taskYIELD();
    }


    for (;;)
    {
        /* Catch a problem - Do nothing */
    }

    vTaskDelete(NULL);
}
Example #10
0
/* Callback to be invoked by timer */
static void _stop_prov_cb(void * arg)
{
    xTaskCreate(&stop_prov_task, "stop_prov", 2048, NULL, tskIDLE_PRIORITY, NULL);
}
Example #11
0
void init_led_utama(void) {
    xTaskCreate(task_led2, ( signed portCHAR * ) "Led2",  (configMINIMAL_STACK_SIZE * 2) ,\
                NULL, tskIDLE_PRIORITY - 2, ( xTaskHandle * ) &hdl_led );
}
Example #12
0
/* ----- Main -------------------------------------------------------------- */
int main(int argc, char* argv[])
{
	/*
	 * The NVIC priority group is set to NVIC_PRIORITYGROUP_4 in HAL_Init
	 * called in _initialize_hardware.c
	 * At this point everything is ready to go!
	 */

	/* Create the tasks */
#if 1
	xTaskCreate(backgroundTask,					/* Pointer to the task entry function */
				"Background",					/* Name for the task */
				configMINIMAL_STACK_SIZE,		/* The size of the stack */
				NULL,							/* Pointer to parameters for the task */
				mainBACKGROUND_TASK_PRIORITY,	/* The priority for the task */
				NULL);							/* Handle for the created task */
#endif
#if 1
	xTaskCreate(lcdTask,						/* Pointer to the task entry function */
				"LCD",							/* Name for the task */
				configMINIMAL_STACK_SIZE * 2,	/* The size of the stack */
				NULL,							/* Pointer to parameters for the task */
				mainLCD_TASK_PRIORITY,			/* The priority for the task */
				NULL);							/* Handle for the created task */
#endif
#if 1
	xTaskCreate(can1Task,						/* Pointer to the task entry function */
				"CAN1",							/* Name for the task */
				configMINIMAL_STACK_SIZE,		/* The size of the stack */
				NULL,							/* Pointer to parameters for the task */
				mainCAN1_TASK_PRIORITY,			/* The priority for the task */
				NULL);							/* Handle for the created task */
#endif
#if 1
	xTaskCreate(can2Task,						/* Pointer to the task entry function */
				"CAN2",							/* Name for the task */
				configMINIMAL_STACK_SIZE,		/* The size of the stack */
				NULL,							/* Pointer to parameters for the task */
				mainCAN2_TASK_PRIORITY,			/* The priority for the task */
				NULL);							/* Handle for the created task */
#endif
#if 1
	xTaskCreate(uart1Task,						/* Pointer to the task entry function */
				"UART1",						/* Name for the task */
				configMINIMAL_STACK_SIZE,		/* The size of the stack */
				NULL,							/* Pointer to parameters for the task */
				mainUART1_TASK_PRIORITY,		/* The priority for the task */
				NULL);							/* Handle for the created task */
#endif
#if 1
	xTaskCreate(uart2Task,						/* Pointer to the task entry function */
				"UART2",						/* Name for the task */
				configMINIMAL_STACK_SIZE,		/* The size of the stack */
				NULL,							/* Pointer to parameters for the task */
				mainUART2_TASK_PRIORITY,		/* The priority for the task */
				NULL);							/* Handle for the created task */
#endif
#if 1
	xTaskCreate(rs232Task,						/* Pointer to the task entry function */
				"RS232",						/* Name for the task */
				configMINIMAL_STACK_SIZE,		/* The size of the stack */
				NULL,							/* Pointer to parameters for the task */
				mainRS232_TASK_PRIORITY,		/* The priority for the task */
				NULL);							/* Handle for the created task */
#endif
#if 1
	xTaskCreate(gpio0Task,						/* Pointer to the task entry function */
				"GPIO0",						/* Name for the task */
				configMINIMAL_STACK_SIZE,		/* The size of the stack */
				NULL,							/* Pointer to parameters for the task */
				mainGPIO0_TASK_PRIORITY,		/* The priority for the task */
				NULL);							/* Handle for the created task */
#endif
#if 1
	xTaskCreate(gpio1Task,						/* Pointer to the task entry function */
				"GPIO1",						/* Name for the task */
				configMINIMAL_STACK_SIZE,		/* The size of the stack */
				NULL,							/* Pointer to parameters for the task */
				mainGPIO1_TASK_PRIORITY,		/* The priority for the task */
				NULL);							/* Handle for the created task */
#endif
#if 1
	xTaskCreate(adcTask,						/* Pointer to the task entry function */
				"ADC",							/* Name for the task */
				configMINIMAL_STACK_SIZE,		/* The size of the stack */
				NULL,							/* Pointer to parameters for the task */
				mainADC_TASK_PRIORITY,			/* The priority for the task */
				NULL);							/* Handle for the created task */
#endif

	/* Start the scheduler */
	vTaskStartScheduler();

	/* If all is well, the scheduler will now be running, and the following line
	will never be reached.  If the following line does execute, then there was
	insufficient FreeRTOS heap memory available for the idle and/or timer tasks
	to be created.  See the memory management section on the FreeRTOS web site
	for more details. */
	while (1);
}
Example #13
0
/**
 * Main function
 *
 * This is the traditional C main().
 */
int main(void)
{

#if USE_PROGRAM_STARTUP
	program_startup();
#else
	char s[64];		/* sprintf string */
	unsigned long why;	/* Why did we get reset? Why? */

	prvSetupHardware();
	init_logger();

#if PART == LM3S8962
	RIT128x96x4Init(1000000);
#endif

	/*
	 * \todo maybe this needs to be earlier or later in the code.
	 * Enable fault handlers in addition to FaultIsr()
	 */
	NVIC_SYS_HND_CTRL_R |= NVIC_SYS_HND_CTRL_USAGE
			              |NVIC_SYS_HND_CTRL_BUS
			              |NVIC_SYS_HND_CTRL_MEM;

#if (PART != LM3S2110)
	/*
	 * Allow the following to erase the permanent configuration flash page:
	 *
	 * make PROTECT_PERMCFG="-D PROTECT_PERMCFG=0" \
	 * ERASE_PERMCFG="-D ERASE_PERMCFG=1"
	 *
	 * The program will continue to erase the permanent configuration structure
	 * at every powerup, so the program must be recompiled without the
	 * ERASE_PERMCFG=1 part and reloaded to allow a permanent configuration
	 * record to persist through power cycles.
	 */
#if ERASE_PERMCFG
#if !PROTECT_PERMCFG

	if (permcfg_erase()) {
#if (PART == LM3S8962)
		RIT128x96x4StringDraw("permcfg Blank",
							0, RITLINE(10), 15);
#endif
	}
	else {
#if (PART == LM3S8962)
		RIT128x96x4StringDraw("permcfg Not Blank",
							0, RITLINE(10), 15);
#endif
	}
#endif
#endif

	config_init();
#endif
	/**
	 * \req \req_id The \program \shall identify:
	 * - The program version.
	 * - A copyright string.
	 * - The board identification.
	 * - The assembly identification.
	 * - Network configuration information.
	 *
	 * \todo Issue #1175 Add software build time, git hash, software
	 *    version to build.
	 */
	lstr("\r\nCRI Quickstart\r\n");
#if (PART == LM3S2110)
	lstr("LM3S2110 Eval Board\r\n");
#elif (PART == LM3S8962)
	lstr("LM3S8962 Eval Board\r\n");
#elif (PART == LM3S9B96)
	lstr("LM3S9B96 Eval Board\r\n");
#endif
	lstr("Copyright (C) 2011 Consolidated Resource Imaging\r\n");

	lprintf("   Software Build Date: %s\n", buildDate);
#if (PART != LM3S2110)
	lprintf("  Assembly Part Number: %s\n", usercfg.assy_pn);
	lprintf("Assembly Serial Number: %s\n", usercfg.assy_sn);
	lprintf("     Board Part Number: %s\n", permcfg.bd_pn);
	lprintf("   Board Serial Number: %s\n", permcfg.bd_sn);
	lprintf("Notes:\r\n %s\r\n", usercfg.notes);
#endif
#if (PART == LM3S8962)
	/*
	 * Display our configuration on the OLED display.
	 */
	RIT128x96x4StringDraw("CRI Quickstart", 0, RITLINE(0), 15);
	RIT128x96x4StringDraw("LM3S8962", 0, RITLINE(1), 15);
	/*
	 * Split date
	 * 0123456789012345678901234567890
	 * Sun, 08 May 2011 19:05:42 -0400
	 *
	 * into:
	 * 0123456789012345678901234567890
	 * Sun, 08 May 2011
	 *
	 * and
	 *
	 * 0123456789012345678901234567890
	 *                  19:05:42 -0400
	 */
	strcpy(s,buildDate);
	s[16]=0;
	RIT128x96x4StringDraw(s, 0, RITLINE(2), 15);
	RIT128x96x4StringDraw(&s[17], 0, RITLINE(3), 15);
#endif

	/**
	 * \req \req_id The \program \shall identify:
	 * - The reason for the reset.
	 */
	why = SysCtlResetCauseGet();
	if (why != 0) {
		SysCtlResetCauseClear(why);

		lprintf("Reset reason: ");
		if (why & SYSCTL_CAUSE_LDO)
			lprintf("LDO ");
		if (why & SYSCTL_CAUSE_SW)
			lprintf("SW ");
		if (why & SYSCTL_CAUSE_WDOG)
			lprintf("WDOG ");
		if (why & SYSCTL_CAUSE_BOR)
			lprintf("Brown-out ");
		if (why & SYSCTL_CAUSE_POR)
			lprintf("Power-on ");
		if (why & SYSCTL_CAUSE_EXT)
			lprintf("External ");
		lprintf("\r\n");
	}

	io_init();

#endif

	util_init();

	/**
	 * \req \req_tcpip The \program \shall support TCP/IP communications.
	 *
	 * Create the LWIP task if running on a processor that includes a MAC
	 * and PHY.
	 */

#if QUICK_ETHERNET

	if( SysCtlPeripheralPresent( SYSCTL_PERIPH_ETH ) ) {
		xTaskCreate(ethernetThread,
			    (signed char *)"eth-init",
			    DEFAULT_STACK_SIZE,
			    NULL,
			    ETH_INIT_PRIORITY,
			    NULL);
	}
#endif

	/*
	 * Enable interrupts...
	 */
	IntMasterEnable();

	vSetupHighFrequencyTimer();
	vTaskStartScheduler();
	DPRINTF(0,"Idle Task Create Failed.");

	/*
	 * Will only get here if there was insufficient memory to create the
	 * idle task.
	 */

	for( ;; );
	return 0;
}
Example #14
0
/**
**===========================================================================
**
**  Abstract: main program
**
**===========================================================================
*/
int main(void)
{
#if SYS_STARTUP == 0
  SystemInit();
#endif

  nvic_init();			// настройка векторов прерываний
  led_init();			// инициализация светодиода, индицирующего работу процессора
  init_calendar();		// инициализация календаря
  _SPI_init();			// SPI для внешней FRAM

  // чтение заводских установок

  read_data(0x7B,0x00,128,(unsigned char*)&_Sys.FR.b1[0]);
  read_data(0x7B,0x80,128,(unsigned char*)&_Sys.FR.b1[0x80]);
  read_data(0x7C,0x00,128,(unsigned char*)&_Sys.FR.b1[0x100]);
  read_data(0x7C,0x80,128,(unsigned char*)&_Sys.FR.b1[0x180]);
  read_data(0x7D,0x00,128,(unsigned char*)&_Sys.FR.b1[0x200]);
  read_data(0x7D,0x80,128,(unsigned char*)&_Sys.FR.b1[0x280]);
  read_data(0x7E,0x00,128,(unsigned char*)&_Sys.FR.b1[0x300]);
  read_data(0x7E,0x80,128,(unsigned char*)&_Sys.FR.b1[0x380]);

  // чтение системных настроек контроллера

  //read_data(0x7F,0x58,1,&rf_ch);

  read_data(0x7F,0x00,6,(unsigned char*)&_Sys.Mem.b1[0]);

  _Sys.Adr=_Sys.Mem.b1[0];
  if((_Sys.Adr==0)||(_Sys.Adr==0xFF)) _Sys.Adr=0x01;

  _Sys.Can1_Baudrate=_Sys.Mem.b1[1];
  if(_Sys.Can1_Baudrate>5) _Sys.Can1_Baudrate=5;
  _Sys.Can1_Type = _Sys.Mem.b1[2];
  if(_Sys.Can1_Type>1) _Sys.Can1_Type=0;

  _Sys.Can2_Baudrate=_Sys.Mem.b1[3];
  if(_Sys.Can2_Baudrate>5) _Sys.Can2_Baudrate=5;
  _Sys.Can2_Type = _Sys.Mem.b1[4];
  if(_Sys.Can2_Type>1) _Sys.Can2_Type=0;

  emu_mode = _Sys.Mem.b1[5];
  if(emu_mode>2) emu_mode=0;

  read_data(0x7F,0x4C,4,ip_addr);set_ip(ip_addr);
  read_data(0x7F,0x50,6,mac_addr);set_mac(mac_addr);
  read_data(0x7F,0x5A,4,ip_gate);set_gate(ip_gate);
  read_data(0x7F,0x5E,1,&modbus_master_emu);
  read_data(0x7F,0x5F,4,ip_mask);set_mask(ip_mask);
  
#if FRAM_YEAR
  read_data(0x7F,0x56,1,(unsigned char*)&times.year);
  if(times.year>99) times.year=0;
#endif

  read_data(0x7F,0x57,1,(unsigned char*)&pult_dis);
  read_data(0x7F,0x59,1,(unsigned char*)&sd_dis);

/*  read_data(0x7F,0x5A,32,ssid_name);
  read_data(0x7F,0x7A,32,wifi_password);
  read_data(0x7F,0x9A,1,&wifi_type);
  read_data(0x7F,0x9B,4,wifi_ip);*/

  // начальные значения номеров строк пульта
  _Sys.S1=0x00;_Sys.S2=0x00;_Sys.S3=0x00;_Sys.S4=0x00;

  // системные миллисекундные задачи
  xTaskCreate( R1Task, ( signed portCHAR * ) "R1", configMINIMAL_STACK_SIZE*2, NULL, R1_TASK_PRIORITY, NULL );
  xTaskCreate( R5Task, ( signed portCHAR * ) "R5", configMINIMAL_STACK_SIZE*2, NULL, R5_TASK_PRIORITY, NULL );
  xTaskCreate( R10Task, ( signed portCHAR * ) "R10", configMINIMAL_STACK_SIZE*2, NULL, R10_TASK_PRIORITY, NULL );
  xTaskCreate( R100Task, ( signed portCHAR * ) "R100", configMINIMAL_STACK_SIZE*2, NULL, R100_TASK_PRIORITY, NULL );
  xTaskCreate( R1000Task, ( signed portCHAR * ) "R1000", configMINIMAL_STACK_SIZE*2, NULL, R1000_TASK_PRIORITY, NULL );
  // служебная вспомогательная задача (светодиод,фильтр ацп,...)
  xTaskCreate( prvFlashTask, (signed portCHAR *) "Flash", configMINIMAL_STACK_SIZE*2, NULL, mainFLASH_TASK_PRIORITY, NULL );
  // стандартный пульт или коммуникационный канал
  if(pult_dis!=0x31) xTaskCreate( LCDTask, ( signed portCHAR * ) "Lcd", configMINIMAL_STACK_SIZE*2, NULL, LCD_TASK_PRIORITY, NULL );
    else xTaskCreate( PultCanTask, ( signed portCHAR * ) "Lcd", configMINIMAL_STACK_SIZE*5, NULL, Canal_TASK_PRIORITY, NULL );
  // задача обработки входов/выходов включая модули расширения
  xTaskCreate( InOutTask, ( signed portCHAR * ) "InOut", configMINIMAL_STACK_SIZE*2, NULL, InOut_TASK_PRIORITY, NULL );
  // два основных коммуникационных канала RS485
  if(_Sys.Can1_Type==0) xTaskCreate( BinCanTask, ( signed portCHAR * ) "Canal", configMINIMAL_STACK_SIZE*2, NULL, Canal_TASK_PRIORITY, NULL );
  else xTaskCreate( AsciiCanTask, ( signed portCHAR * ) "Canal", configMINIMAL_STACK_SIZE*2, NULL, Canal_TASK_PRIORITY, NULL );
  if(_Sys.Can2_Type==0) xTaskCreate( BinCan2Task, ( signed portCHAR * ) "Canal2", configMINIMAL_STACK_SIZE*2, NULL, Canal_TASK_PRIORITY, NULL );
  else xTaskCreate( AsciiCan2Task, ( signed portCHAR * ) "Canal2", configMINIMAL_STACK_SIZE*2, NULL, Canal_TASK_PRIORITY, NULL );
  // WIFI задачи
/*  if(wifi_ip[0])
  {
    xTaskCreate( WIFITask, ( signed portCHAR * ) "Wifi", configMINIMAL_STACK_SIZE, NULL, WF_TASK_PRIORITY, NULL );
    xTaskCreate( SCAN_WIFITask, ( signed portCHAR * ) "SCANWifi", configMINIMAL_STACK_SIZE, NULL, WF_TASK_PRIORITY+1, NULL );
  }*/
  // проводной ethernet
  if(ip_addr[0]) xTaskCreate( EthTask, ( signed portCHAR * ) "Eth", configMINIMAL_STACK_SIZE*3, NULL, ETH_TASK_PRIORITY, NULL );
  // задача работы с sd картой
  if(sd_dis==0x31) xTaskCreate( ArchiveTask, ( signed portCHAR * ) "SD_Task", configMINIMAL_STACK_SIZE*2, NULL, SD_TASK_PRIORITY, NULL );

  Relkon_init(); // блок инициализации - формируется верхним уровнем (раздел #init релкона)

  init_timer();	// аппаратный таймер для определения загрузки процессора
  vTaskStartScheduler();  // старт планировщика задач
  while (1){}
}
Example #15
0
void smooth_traj_start()
{
  xTaskCreate(smooth_traj_task, (const signed char *)"TrajectoryManager", 200, NULL, 1, NULL );
}
void vStartUDPCommandInterpreterTask( uint16_t usStackSize, uint32_t ulPort, UBaseType_t uxPriority )
{
    xTaskCreate( vUDPCommandInterpreterTask, "CLI", usStackSize, ( void * ) ulPort, uxPriority, NULL );
}
Example #17
0
void pl_arcook_init(void)
{
	xTaskCreate((pdTASK_CODE)plasma_task, "Plasma task", 512, NULL, 7, &xPlasmaTaskHandle );
    /* Attempt to create a semaphore. */
	xArcoOkSync = xSemaphoreCreateBinary();
}
void CCID_Test_task_init (void)
{
    xTaskCreate (CCID_Test_task, configTSK_CCID_TEST_NAME, configTSK_CCID_TEST_STACK_SIZE, NULL, configTSK_CCID_TEST_PRIORITY, NULL);
}
Example #19
0
int main(void)
{
	/* Configure the NVIC, LED outputs and button inputs. */
	prvSetupHardware();

	/* Create the queue. */
	xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) );

	if( xQueue != NULL )
	{
		/* Start the three application specific demo tasks, as described in the
		comments at the top of this	file. */
		xTaskCreate( prvQueueReceiveTask, "Rx", configMINIMAL_STACK_SIZE, NULL, mainQUEUE_RECEIVE_TASK_PRIORITY, NULL );
		xTaskCreate( prvQueueSendTask, "TX", configMINIMAL_STACK_SIZE, NULL, mainQUEUE_SEND_TASK_PRIORITY, NULL );
		xTaskCreate( prvOLEDTask, "OLED", configMINIMAL_STACK_SIZE, NULL, mainOLED_TASK_PRIORITY, NULL );

		/* Create the software timer that is responsible for turning off the LED
		if the button is not pushed within 5000ms, as described at the top of
		this file. */
		xLEDTimer = xTimerCreate( 	"LEDTimer", 					/* A text name, purely to help debugging. */
									( mainLED_TIMER_PERIOD_MS ),	/* The timer period, in this case 5000ms (5s). */
									pdFALSE,						/* This is a one shot timer, so xAutoReload is set to pdFALSE. */
									( void * ) 0,					/* The ID is not used, so can be set to anything. */
									prvLEDTimerCallback				/* The callback function that switches the LED off. */
								);

		/* Create the software timer that performs the 'check' functionality,
		as described at the top of this file. */
		xCheckTimer = xTimerCreate( "CheckTimer",					/* A text name, purely to help debugging. */
									( mainCHECK_TIMER_PERIOD_MS ),	/* The timer period, in this case 3000ms (3s). */
									pdTRUE,							/* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */
									( void * ) 0,					/* The ID is not used, so can be set to anything. */
									prvCheckTimerCallback			/* The callback function that inspects the status of all the other tasks. */
								  );

		/* Create a lot of 'standard demo' tasks. */
		vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
		vCreateBlockTimeTasks();
		vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
		vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
		vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );
		vStartQueuePeekTasks();
		vStartRecursiveMutexTasks();
		vStartTimerDemoTask( mainTIMER_TEST_PERIOD );

		/* Create the web server task. */
		xTaskCreate( vuIP_Task, "uIP", mainuIP_STACK_SIZE, NULL, mainuIP_TASK_PRIORITY, NULL );
		
		/* The suicide tasks must be created last, as they need to know how many
		tasks were running prior to their creation in order to ascertain whether
		or not the correct/expected number of tasks are running at any given
		time. */
		vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );

		/* Start the tasks and timer running. */
		vTaskStartScheduler();
	}

	/* If all is well, the scheduler will now be running, and the following line
	will never be reached.  If the following line does execute, then there was
	insufficient FreeRTOS heap memory available for the idle and/or timer tasks
	to be created.  See the memory management section on the FreeRTOS web site
	for more details. */
	for( ;; );
}
Example #20
0
int main()
{
	logfile = open("log", 4);

	init_led();

	init_button();
	enable_button_interrupts();

	init_rs232();
	enable_rs232_interrupts();
	enable_rs232();

	/* Create the queue used by the serial task.  Messages for write to
	 * the RS232. */
	serial_str_queue = xQueueCreate(10, sizeof(serial_str_msg));
	vSemaphoreCreateBinary(serial_tx_wait_sem);
	serial_rx_queue = xQueueCreate(1, sizeof(serial_ch_msg));

	/* Create a task to flash the LED. */
	xTaskCreate(led_flash_task,
	            (signed portCHAR *) "LED Flash",
	            512 /* stack size */, NULL,
	            tskIDLE_PRIORITY + 5, NULL);

	/* Create tasks to queue a string to be written to the RS232 port. */
	xTaskCreate(queue_str_task1,
	            (signed portCHAR *) "Serial Write 1",
	            512 /* stack size */, NULL,
	            tskIDLE_PRIORITY + 10, NULL);
	xTaskCreate(queue_str_task2,
	            (signed portCHAR *) "Serial Write 2",
	            512 /* stack size */,
	            NULL, tskIDLE_PRIORITY + 10, NULL);

	/* Create a task to write messages from the queue to the RS232 port. */
	xTaskCreate(rs232_xmit_msg_task,
	            (signed portCHAR *) "Serial Xmit Str",
	            512 /* stack size */, NULL, tskIDLE_PRIORITY + 2, NULL);

	/* Create a task to receive characters from the RS232 port and echo
	 * them back to the RS232 port. */
	xTaskCreate(serial_readwrite_task,
	            (signed portCHAR *) "Serial Read/Write",
	            512 /* stack size */, NULL,
	            tskIDLE_PRIORITY + 10, NULL);

    xTaskCreate(new_task,
                (signed portCHAR *) "Task 1",
                512 /* stack size */, NULL,
                tskIDLE_PRIORITY + 12, NULL);

    xTaskCreate(new_task,
                (signed portCHAR *) "Task 2",
                512 /* stack size */, NULL,
                tskIDLE_PRIORITY + 12, NULL);

	/* Start running the tasks. */
	vTaskStartScheduler();

	return 0;
}
Example #21
0
int main( void )
{
    prvSetupHardware();

    /*  
        Create the queue used by the OLED task.  Messages for display on the OLED
        are received via this queue. 
    */
    
    xOLEDQueue = xQueueCreate( mainOLED_QUEUE_SIZE, sizeof( xOLEDMessage ) );

    initializeGlobalVariables();
    
    //Depricated, but included out of love <3
    //DebugWorkGodDamnit DebugWork                = {&panelState, &panelDeploy, &panelRetract, &batteryLevelArray, &battTempArray0, &battTempArray1, &battOverTemp, &powerConsumption, &powerGeneration};

    satelliteCommsDataStruct satelliteCommsData = {&fuelLow, &battLow, &panelState, &batteryLevelArray, &battTempArray0, &battTempArray1, &fuelLevel, &thrust, &globalCount, &isMajorCycle, &processedImageData, &systemInfo, &transportDistance};
    thrusterSubDataStruct thrusterSubData       = {&thrust, &fuelLevel, &globalCount, &isMajorCycle};
    vehicleCommsStruct vehicleCommsData         = {&vehicleCommand, &vehicleResponse, &globalCount, &isMajorCycle};
    oledDisplayDataStruct oledDisplayData       = {&fuelLow, &battLow, &panelState, &panelDeploy, &panelRetract, &batteryLevelArray, &battTempArray0, &battTempArray1, &fuelLevel, &transportDistance};
    keyboardDataStruct keyboardData             = {&panelMotorSpeedUp, &panelMotorSpeedDown};
    warningAlarmDataStruct warningAlarmData     = {&fuelLow, &battLow, &batteryLevelArray, &battOverTemp, &fuelLevel, &globalCount, &isMajorCycle};
    scheduleDataStruct scheduleData             = {&globalCount, &isMajorCycle, &battOverTemp};
    transportDataStruct transportData           = {&globalCount};
    powerSubDataStruct powerSubData             = {&panelState, &panelDeploy, &panelRetract, &batteryLevelArray, &battTempArray0, &battTempArray1, &battOverTemp};
    solarPanelStruct solarPanelData             = {&panelState, &panelDeploy, &panelRetract, &panelMotorSpeedUp, &panelMotorSpeedDown, &globalCount, &isMajorCycle};
    pirateDataStruct pirateData                 = {&pirateProximity};
    imageCaptureDataStruct imageCaptureData     = {&processedImageData, &imageFrequency};
    commandDataStruct commandData               = {&remoteCommand};
    
    // Create Handles for temp tasks
    solarPanelHandle = NULL;
    consoleKeyboardHandle = NULL;
    imageCaptureHandle = NULL;
    pirateHandle = NULL;
    commandHandle = NULL;
    transportHandle = NULL;
      
    /* Start the tasks */
    
    xTaskCreate( vOLEDTask, ( signed portCHAR * ) "OLED", mainOLED_TASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
    xTaskCreate(schedule,          "schedule",          40, (void*)&scheduleData,       mainCHECK_TASK_PRIORITY - 1, NULL);
    xTaskCreate(powerSub,          "powerSub",          100,(void*)&powerSubData,       mainCHECK_TASK_PRIORITY, NULL);
    xTaskCreate(solarPanelControl, "solarPanelControl", 60, (void*)&solarPanelData,     mainCHECK_TASK_PRIORITY, &solarPanelHandle);         
    vTaskSuspend(solarPanelHandle);
    xTaskCreate(satelliteComms,    "satelliteComms",    mainBASIC_WEB_STACK_SIZE, (void*)&satelliteCommsData, mainCHECK_TASK_PRIORITY + 1, NULL);
    xTaskCreate(vehicleComms,      "vehicleComms",      50, (void*)&vehicleCommsData,   mainCHECK_TASK_PRIORITY, NULL);
    xTaskCreate(thrusterSub,       "thrusterSub",       60, (void*)&thrusterSubData,    mainCHECK_TASK_PRIORITY, NULL);
    xTaskCreate(oledDisplay,       "oledDisplay",       120,(void*)&oledDisplayData,    mainCHECK_TASK_PRIORITY, NULL);
    xTaskCreate(consoleKeyboard,   "consoleKeyboard",   60, (void*)&keyboardData,       mainCHECK_TASK_PRIORITY, &consoleKeyboardHandle);    
    vTaskSuspend(consoleKeyboardHandle);
    xTaskCreate(warningAlarm,      "warningAlarm",      100,(void*)&warningAlarmData,   mainCHECK_TASK_PRIORITY, NULL);
    xTaskCreate(transport,         "transport",         100,(void*)&transportData,      mainCHECK_TASK_PRIORITY, NULL);
    xTaskCreate(pirates,           "pirates",           100,(void*)&pirateData,         mainCHECK_TASK_PRIORITY, &pirateHandle);
    vTaskSuspend(pirateHandle);
    xTaskCreate(imageCapture,      "imageCapture",      800,(void*)&imageCaptureData,   2, &imageCaptureHandle);
    vTaskSuspend(imageCaptureHandle);
    xTaskCreate(command,           "command",           800,(void*)&commandData,        2, &commandHandle);
    vTaskSuspend(commandHandle);
    
    #if mainINCLUDE_WEB_SERVER != 0
    {
      /* 
          Create the uIP task if running on a processor that includes a MAC and PHY. 
      */
      
      if( SysCtlPeripheralPresent( SYSCTL_PERIPH_ETH ) )
      {
          xTaskCreate( vuIP_Task, ( signed portCHAR * ) "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
      }
    }
    #endif
    /* 
      Configure the high frequency interrupt used to measure the interrupt
      jitter time. 
    */
    
    //vSetupHighFrequencyTimer();

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

    /* Will only get here if there was insufficient memory to create the idle task. */
    
    return 0;
}
Example #22
0
FreeRTOSTask::FreeRTOSTask(size_t stackSize, unsigned long priority) {
	xTaskCreate(taskBody, "Task", stackSize, this, tskIDLE_PRIORITY + priority, &handle);
}
void userinput_init(void) {
    userinput_mutex = xSemaphoreCreateMutex();
    xTaskCreate(userinput_task, (signed char *)"user", 1024, NULL, 0,
                &userinput_task_handle);
}
/*******************************************************************************
 * vTraceEnable
 *
 * Function that enables the tracing and creates the control task. It will halt
 * execution until a Start command has been received if haltUntilStart is true.
 *
 ******************************************************************************/
void vTraceEnable(int startOption)
{
	int32_t bytes = 0;
	int32_t status;
	extern uint32_t RecorderEnabled;
	TracealyzerCommandType msg;

	/* Only do this first time...*/
	if (HandleTzCtrl == NULL)
	{
		TRC_STREAM_PORT_INIT();
		
		/* Note: Requires that TRC_CFG_INCLUDE_USER_EVENTS is 1. */
		trcWarningChannel = xTraceRegisterString("Warnings from Recorder");

		/* Creates the TzCtrl task - receives trace commands (start, stop, ...) */
		#if defined(configSUPPORT_STATIC_ALLOCATION) && (configSUPPORT_STATIC_ALLOCATION == 1)
		HandleTzCtrl = xTaskCreateStatic(TzCtrl, STRING_CAST("TzCtrl"), TRC_CFG_CTRL_TASK_STACK_SIZE, NULL, TRC_CFG_CTRL_TASK_PRIORITY, stackTzCtrl, &tcbTzCtrl);
		#else
		xTaskCreate( TzCtrl, STRING_CAST("TzCtrl"), TRC_CFG_CTRL_TASK_STACK_SIZE, NULL, TRC_CFG_CTRL_TASK_PRIORITY, &HandleTzCtrl );
		#endif

		if (HandleTzCtrl == NULL)
		{
			prvTraceError(PSF_ERROR_TZCTRLTASK_NOT_CREATED);
		}
	}

	if (startOption == TRC_START_AWAIT_HOST)
	{
		/* We keep trying to read commands until the recorder has been started */
		do
		{
			bytes = 0;
			
			status = TRC_STREAM_PORT_READ_DATA(&msg, sizeof(TracealyzerCommandType), (int32_t*)&bytes);
			
			if (status != 0)
			{
				prvTraceWarning(PSF_WARNING_STREAM_PORT_READ);
			}

			if ((status == 0) && (bytes == sizeof(TracealyzerCommandType)))
			{
				if (prvIsValidCommand(&msg))
				{
					if (msg.cmdCode == CMD_SET_ACTIVE && msg.param1 == 1)
					{
						/* On start, init and reset the timestamping */
						TRC_PORT_SPECIFIC_INIT();
					}
					
					prvProcessCommand(&msg);
				}
			}
		}
		while (RecorderEnabled == 0);
	}
	else if (startOption == TRC_START)
	{
		/* We start streaming directly - this assumes that the interface is ready! */
		TRC_PORT_SPECIFIC_INIT();
		
		msg.cmdCode = CMD_SET_ACTIVE;
		msg.param1 = 1;
		prvProcessCommand(&msg);
	}
	else
	{
		/* On TRC_INIT */
		TRC_PORT_SPECIFIC_INIT();
	}
}
Example #25
0
void StartSecPulse(unsigned portBASE_TYPE Priority)
{
    xTaskCreate(LedSecTask, (signed portCHAR *)"LedSecTask", configMINIMAL_STACK_SIZE, NULL, Priority, NULL );
}
Example #26
0
static void prvConfigureCaptureBehaviour( void )
{
struct bpf_program xFilterCode;
uint32_t ulNetMask;

	/* Set up a filter so only the packets of interest are passed to the IP
	stack.  cErrorBuffer is used for convenience to create the string.  Don't
	confuse this with an error message. */
	sprintf( cErrorBuffer, "broadcast or multicast or ether host %x:%x:%x:%x:%x:%x",
		ucMACAddress[0], ucMACAddress[1], ucMACAddress[2], ucMACAddress[3], ucMACAddress[4], ucMACAddress[5] );

	ulNetMask = ( configNET_MASK3 << 24UL ) | ( configNET_MASK2 << 16UL ) | ( configNET_MASK1 << 8L ) | configNET_MASK0;

	if( pcap_compile( pxOpenedInterfaceHandle, &xFilterCode, cErrorBuffer, 1, ulNetMask ) < 0 )
	{
		printf( "\nThe packet filter string is invalid\n" );
	}
	else
	{
		if( pcap_setfilter( pxOpenedInterfaceHandle, &xFilterCode ) < 0 )
		{
			printf( "\nAn error occurred setting the packet filter.\n" );
		}
	}

	/* Create the buffers used to pass packets between the FreeRTOS simulator
	and the Win32 threads that are handling WinPCAP. */
	prvCreateThreadSafeBuffers();

	if( pvSendEvent == NULL )
	{
		/* Create event used to signal the Win32 WinPCAP Tx thread. */
		pvSendEvent = CreateEvent( NULL, FALSE, TRUE, NULL );

		/* Create the Win32 thread that handles WinPCAP Rx. */
		vWinPcapRecvThreadHandle = CreateThread(
			NULL,	/* Pointer to thread security attributes. */
			0,		/* Initial thread stack size, in bytes. */
			prvWinPcapRecvThread,	/* Pointer to thread function. */
			NULL,	/* Argument for new thread. */
			0,		/* Creation flags. */
			NULL );

		/* Use the cores that are not used by the FreeRTOS tasks. */
		SetThreadAffinityMask( vWinPcapRecvThreadHandle, ~0x01u );

		/* Create the Win32 thread that handlers WinPCAP Tx. */
		vWinPcapSendThreadHandle = CreateThread(
			NULL,	/* Pointer to thread security attributes. */
			0,		/* initial thread stack size, in bytes. */
			prvWinPcapSendThread,	/* Pointer to thread function. */
			NULL,	/* Argument for new thread. */
			0,		/* Creation flags. */
			NULL );

		/* Use the cores that are not used by the FreeRTOS tasks. */
		SetThreadAffinityMask( vWinPcapSendThreadHandle, ~0x01u );

		/* Create a task that simulates an interrupt in a real system.  This will
		block waiting for packets, then send a message to the IP task when data
		is available. */
		xTaskCreate( prvInterruptSimulatorTask, "MAC_ISR", configMINIMAL_STACK_SIZE, NULL, configMAC_ISR_SIMULATOR_PRIORITY, NULL );
	}
}
void log_init(void) {
	xTaskCreate( vLogTask, ( signed char * ) "LOG", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);
}
Example #28
0
void main_full( void )
{
TimerHandle_t xTimer = NULL;

/* The register test tasks are asm functions that don't use a stack.  The
stack allocated just has to be large enough to hold the task context, and
for the additional required for the stack overflow checking to work (if
configured). */
const size_t xRegTestStackSize = 25U;

	/* Create the standard demo tasks */
	vCreateBlockTimeTasks();
	vStartDynamicPriorityTasks();
	vStartCountingSemaphoreTasks();
	vStartRecursiveMutexTasks();
	vStartQueueOverwriteTask( tskIDLE_PRIORITY );
	vStartQueueSetTasks();
	vStartGenericQueueTasks( tskIDLE_PRIORITY );
	vStartQueuePeekTasks();
	
	/* Start the task that manages the command console for FreeRTOS+CLI. */
	vUARTCommandConsoleStart( ( configMINIMAL_STACK_SIZE * 3 ), tskIDLE_PRIORITY );	

	/* Create the register test tasks as described at the top of this file.
	These are naked functions that don't use any stack.  A stack still has
	to be allocated to hold the task context. */
	xTaskCreate( 	vRegTest1Task,			/* Function that implements the task. */
					"Reg1",					/* Text name of the task. */
					xRegTestStackSize,		/* Stack allocated to the task. */
					NULL, 					/* The task parameter is not used. */
					tskIDLE_PRIORITY, 		/* The priority to assign to the task. */
					NULL );					/* Don't receive a handle back, it is not needed. */

	xTaskCreate( 	vRegTest2Task,			/* Function that implements the task. */
					"Reg2",					/* Text name of the task. */
					xRegTestStackSize,		/* Stack allocated to the task. */
					NULL, 					/* The task parameter is not used. */
					tskIDLE_PRIORITY, 		/* The priority to assign to the task. */
					NULL );					/* Don't receive a handle back, it is not needed. */

	/* Create the software timer that performs the 'check' functionality,
	as described at the top of this file. */
	xTimer = xTimerCreate( 	"CheckTimer",						/* A text name, purely to help debugging. */
							( mainCHECK_TIMER_PERIOD_MS ),		/* The timer period, in this case 3000ms (3s). */
							pdTRUE,								/* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */
							( void * ) 0,						/* The ID is not used, so can be set to anything. */
							prvCheckTimerCallback				/* The callback function that inspects the status of all the other tasks. */
					  	);

	/* If the software timer was created successfully, start it.  It won't
	actually start running until the scheduler starts.  A block time of
	zero is used in this call, although any value could be used as the block
	time will be ignored because the scheduler has not started yet. */
	configASSERT( xTimer );
	if( xTimer != NULL )
	{
		xTimerStart( xTimer, mainDONT_BLOCK );
	}

	/* Start the kernel.  From here on, only tasks and interrupts will run. */
	vTaskStartScheduler();

	/* If all is well, the scheduler will now be running, and the following
	line will never be reached.  If the following line does execute, then there
	was	insufficient FreeRTOS heap memory available for the idle and/or timer
	tasks to be created.  See the memory management section on the FreeRTOS web
	site, or the FreeRTOS tutorial books for more details. */
	for( ;; );
}
Example #29
0
int audioPlayer_start(audioPlayer_t *pThis) {
	/* create the audio task */
	printf("Start!\n");
	xTaskCreate( audioPlayer_task, ( signed char * ) "HW", configMINIMAL_STACK_SIZE, pThis, tskIDLE_PRIORITY + 1 , NULL );
	return 0;
}
Example #30
0
void
vUSBShellInit (void)
{
  xTaskCreate (usbshell_task, (signed portCHAR *) "USBSHELL",
	       TASK_USBSHELL_STACK, NULL, TASK_USBSHELL_PRIORITY, NULL);
}