예제 #1
0
파일: main.c 프로젝트: wugsh/wgs
int main( void )
{
#ifdef DEBUG
  debug();
#endif

	prvSetupHardware();

	/* Start the standard demo tasks.  These are just here to exercise the
	kernel port and provide examples of how the FreeRTOS API can be used. */
	vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
    vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
    vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
    vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
    vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
	vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );
    vStartQueuePeekTasks();
    vStartRecursiveMutexTasks();

	/* Create the uIP task.  The WEB server runs in this task. */
    xTaskCreate( vuIP_Task, "uIP", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY, NULL );

	/* Create the queue used by the LCD task.  Messages for display on the LCD
	are received via this queue. */
	xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( char * ) );

	/* Start the LCD gatekeeper task - as described in the comments at the top
	of this file. */
	xTaskCreate( prvLCDTask, "LCD", configMINIMAL_STACK_SIZE * 2, NULL, mainLCD_TASK_PRIORITY, NULL );

	/* Configure the high frequency interrupt used to measure the interrupt
	jitter time.  When debugging it can be helpful to comment this line out
	to prevent the debugger repeatedly going into the interrupt service
	routine. */
	vSetupHighFrequencyTimer();

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

    /* Will only get here if there was insufficient memory to create the idle
    task.  The idle task is created within vTaskStartScheduler(). */
	for( ;; );
}
예제 #2
0
static void prvCheckTask( void *pvParameters )
{
static volatile unsigned long ulLastRegTest1CycleCount = 0UL, ulLastRegTest2CycleCount = 0UL;
TickType_t xNextWakeTime, xCycleFrequency = mainNO_ERROR_CYCLE_TIME;
extern void vSetupHighFrequencyTimer( void );

	/* If this is being executed then the kernel has been started.  Start the high
	frequency timer test as described at the top of this file.  This is only
	included in the optimised build configuration - otherwise it takes up too much
	CPU time. */
	#ifdef INCLUDE_HIGH_FREQUENCY_TIMER_TEST
		vSetupHighFrequencyTimer();
	#endif

	/* Initialise xNextWakeTime - this only needs to be done once. */
	xNextWakeTime = xTaskGetTickCount();

	for( ;; )
	{
		/* Place this task in the blocked state until it is time to run again. */
		vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );

		/* Check the standard demo tasks are running without error. */
		if( xAreGenericQueueTasksStillRunning() != pdTRUE )
		{
			/* Increase the rate at which this task cycles, which will increase the
			rate at which mainCHECK_LED flashes to give visual feedback that an error
			has occurred. */			
			pcStatusMessage = "Error: GenQueue";
			xPrintf( pcStatusMessage );
		}
		
		if( xAreQueuePeekTasksStillRunning() != pdTRUE )
		{
			pcStatusMessage = "Error: QueuePeek\r\n";
			xPrintf( pcStatusMessage );
		}
		
		if( xAreBlockingQueuesStillRunning() != pdTRUE )
		{
			pcStatusMessage = "Error: BlockQueue\r\n";
			xPrintf( pcStatusMessage );
		}
		
		if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
		{
			pcStatusMessage = "Error: BlockTime\r\n";
			xPrintf( pcStatusMessage );
		}
		
		if( xAreSemaphoreTasksStillRunning() != pdTRUE )
		{
			pcStatusMessage = "Error: SemTest\r\n";
			xPrintf( pcStatusMessage );
		}
		
		if( xArePollingQueuesStillRunning() != pdTRUE )
		{
			pcStatusMessage = "Error: PollQueue\r\n";
			xPrintf( pcStatusMessage );
		}
		
		if( xIsCreateTaskStillRunning() != pdTRUE )
		{
			pcStatusMessage = "Error: Death\r\n";
			xPrintf( pcStatusMessage );
		}
		
		if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
		{
			pcStatusMessage = "Error: IntMath\r\n";
			xPrintf( pcStatusMessage );
		}
		
		if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
		{
			pcStatusMessage = "Error: RecMutex\r\n";
			xPrintf( pcStatusMessage );
		}
		
		if( xAreIntQueueTasksStillRunning() != pdPASS )
		{
			pcStatusMessage = "Error: IntQueue\r\n";
			xPrintf( pcStatusMessage );
		}
		
		if( xAreMathsTaskStillRunning() != pdPASS )
		{
			pcStatusMessage = "Error: Flop\r\n";
			xPrintf( pcStatusMessage );
		}

		/* Check the reg test tasks are still cycling.  They will stop incrementing
		their loop counters if they encounter an error. */
		if( ulRegTest1CycleCount == ulLastRegTest1CycleCount )
		{
			pcStatusMessage = "Error: RegTest1\r\n";
			xPrintf( pcStatusMessage );
		}

		if( ulRegTest2CycleCount == ulLastRegTest2CycleCount )
		{
			pcStatusMessage = "Error: RegTest2\r\n";
			xPrintf( pcStatusMessage );
		}

		ulLastRegTest1CycleCount = ulRegTest1CycleCount;
		ulLastRegTest2CycleCount = ulRegTest2CycleCount;

		/* Toggle the check LED to give an indication of the system status.  If
		the LED toggles every 5 seconds then everything is ok.  A faster toggle
		indicates an error. */
		vParTestToggleLED( mainCHECK_LED );
		
		/* Ensure the LED toggles at a faster rate if an error has occurred. */
		if( pcStatusMessage != NULL )
		{
			xCycleFrequency = mainERROR_CYCLE_TIME;
		}
	}
}
예제 #3
0
파일: main.c 프로젝트: eeshanl/ee472
int main() {

  // Initializes all necessary hardware for the system.
  InitializeHardware();


  /**************************************/
  // These includes provided by FreeRTOS

  #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



  // These includes provided by FreeRTOS
  /**************************************/


  /* Our Tasks
   * NOTE: The xTaskCreate function is provided by FreeRTOS, we use them to create our tasks that we made.
   */

  /* Start the tasks */

  //creates the task for ADC sensors
  xTaskCreate(vTaskADC, "Task ADC", 100, NULL, 2, NULL);
  //creates the task that averages the ADC samples
  xTaskCreate(vTaskADCAverage, "Task Average", 100, NULL, 2, NULL);
  //creates the task that controls the motor via kepad/bluetooth
  xTaskCreate(vTaskControlMotor, "Task Control Motor", 100, NULL, 2, NULL); //3
  //creates the task that does the autonomous motion of the tank
  xTaskCreate(vAutoMotor, "Task Auto Motor", 100, NULL, 3, NULL); // 5
  //creates the task that controls the semi-autonomous mode for the tank
  xTaskCreate(vSemiMotor, "Task Semi-Motor", 100, NULL, 3, NULL); // 5
  //creates the task that controls the speaker
  xTaskCreate(vTaskSpeaker, "Task Control Motor", 100, NULL, 1, NULL);
  //creates the task the displays to the OLED Display
  xTaskCreate(vTaskDisplay, "Task OLED Display", 100, NULL, 3, NULL); // 4
  //creates the task that prints the distance from the distance sensors on the
  //OLED Display
  xTaskCreate(vPrintDistance, "Task Distance Please", 100, NULL, 2, NULL);
  // blinks LEDS
  xTaskCreate(vBlinkLED, "Blink", 100, NULL, 2, NULL);


  /**************************************/
  // These includes provided by FreeRTOS

  /*
  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. */

  // These includes provided by FreeRTOS
  /**************************************/

  return 0;
}
예제 #4
0
파일: main.c 프로젝트: gvb/quickstart
/**
 * 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;
}