Example #1
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 ) );
    

    /* 
        Exclude some tasks if using the kickstart version to ensure we stay within
        the 32K code size limit. 
    */
    
    #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
    
    
    
    /* Start the tasks */
    
    xTaskCreate( vOLEDTask, ( signed portCHAR * ) "OLED", mainOLED_TASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );

    xTaskCreate(vTask1, "Task 1", 100,NULL, 1,NULL);
    xTaskCreate(vTask2, "Task 2", 100,NULL, 2,NULL);
    xTaskCreate(vTask3, "Task 3", 100,NULL, 3,NULL);
    
    /* 
      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 #2
0
File: main.c Project: HclX/freertos
/*************************************************************************
 * Please ensure to read http://www.freertos.org/portlm3sx965.html
 * which provides information on configuring and running this demo for the
 * various Luminary Micro EKs.
 *************************************************************************/
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 ) );

	/* Start the standard demo tasks. */
    vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
    vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
    vStartInterruptQueueTasks();
	vStartRecursiveMutexTasks();
	vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
	vCreateBlockTimeTasks();
	vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
	vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
	vStartQueuePeekTasks();
	vStartQueueSetTasks();
	vStartEventGroupTasks();

	/* Exclude some tasks if using the kickstart version to ensure we stay within
	the 32K code size limit. */
	#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, "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
		}
	}
	#endif



	/* Start the tasks defined within this file/specific to this demo. */
	xTaskCreate( vOLEDTask, "OLED", mainOLED_TASK_STACK_SIZE, NULL, tskIDLE_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 );

	/* 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 #3
0
void RMBD01Init( void )
{

  //
  // Configure the ADC for Pitch and Roll
  // sequence 3 means a single sample
  // sequence 1, 2 means up to 4 samples
  // sequence 0 means up to 8 samples
  // we use sequence 1
  //
  if (SysCtlPeripheralPresent(SYSCTL_PERIPH_ADC0))
  {

    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_TIMER, 0); // 1 captures up to 4 samples

    //
    // Select the external reference for greatest accuracy.
    //
    ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V);

    ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ENCODER_CHANNEL_PITCH);     // sample pitch
    ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ENCODER_CHANNEL_ROLL | ADC_CTL_IE | ADC_CTL_END);     // sample roll
    ADCIntRegister(ADC0_BASE,1,ADCIntHandler);
    ADCSequenceEnable(ADC0_BASE, 1);
    ADCIntEnable(ADC0_BASE, 1);


    //
    // Setup timer for ADC_TRIGGER_TIMER
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
	
    //
    // Configure the second timer to generate triggers to the ADC 
    //
    TimerConfigure(TIMER1_BASE, TIMER_CFG_32_BIT_PER);
    TimerLoadSet(TIMER1_BASE, TIMER_A, SysCtlClockGet() / 1000); // 2 ms
  
    TimerControlStall(TIMER1_BASE, TIMER_A, true);
    TimerControlTrigger(TIMER1_BASE, TIMER_A, true);

    //
    // Enable the timers.
    //	
    TimerEnable(TIMER1_BASE, TIMER_A);
    new_adc = false;
    //
  }
  //
  // Clear outstanding ADC interrupt and enable
  //
  ADCIntClear(ADC0_BASE, 1);
  IntEnable(INT_ADC0);
} // InitADC
Example #4
0
void uartStdioConfig (uint32_t ui32PortNum, uint32_t ui32Baud, uint32_t ui32SrcClock)
{
        // Check the arguments.
        ASSERT((ui32PortNum == 0) || (ui32PortNum == 1) || (ui32PortNum == 2));

        // Check to make sure the UART peripheral is present.
        if (!SysCtlPeripheralPresent(SYSCTL_PERIPH_UART0)) {
                return;
        }

        // Enable the UART peripheral for use.
        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

        // Configure the UART for 115200, n, 8, 1
        UARTConfigSetExpClk(UART0_BASE, ui32SrcClock, ui32Baud, (UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
        UART_CONFIG_WLEN_8));

        // Enable the UART operation.
        UARTEnable(UART0_BASE);
}
Example #5
0
/*************************************************************************
 * Please ensure to read http://www.freertos.org/portLM3Sxxxx_Eclipse.html
 * which provides information on configuring and running this demo for the
 * various Luminary Micro EKs.
 *************************************************************************/
int main( void ) {
	prvSetupHardware();

	/* Create the uIP task if running on a processor that includes a MAC and
	PHY. */
	if( SysCtlPeripheralPresent( SYSCTL_PERIPH_ETH ) )	{
		xTaskCreate( ethernetThread, ( signed portCHAR * ) "uIP", mainBASIC_TELNET_STACK_SIZE, NULL, CHECK_TASK_PRIORITY , NULL );
	}

	if (pdPASS != xTaskCreate( console, ( signed portCHAR * ) "CONS", SIM_TASK_STACK_SIZE, NULL, CHECK_TASK_PRIORITY , NULL )) {
		LWIPDebug("Cant create console!");
	}

	vTaskStartScheduler(); // Start the scheduler. 

    /* Will only get here if there was insufficient memory to create the idle
    task. */
	for( ;; );
	return 0;
}
Example #6
0
void hwInitWatchdog(long intervalMilliseconds) {
	if (SysCtlPeripheralPresent(SYSCTL_PERIPH_WDOG)){
		SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG);

		WatchdogUnlock(WATCHDOG_BASE);			// unlock WD register

		WatchdogResetEnable(WATCHDOG_BASE);		// enable reset capability on second timeout
		/* watchdog resets the system on the second timeout!
		 * -> so we have to divide the time by 2
		 * -> on the first time-out only an interrupt is generated
		 */
		glWDLoad = (SysCtlClockGet()/1000) * (intervalMilliseconds/2);
		WatchdogReloadSet(WATCHDOG_BASE, glWDLoad);
		WatchdogStallEnable(WATCHDOG_BASE); 	// stops the watchdog during debug break
		WatchdogIntUnregister(WATCHDOG_BASE); 	// mask interrupt -> interrupts are not seen and handled by processor
		WatchdogEnable(WATCHDOG_BASE);

		WatchdogLock(WATCHDOG_BASE);			// lock WD register
	}
}
Example #7
0
//*****************************************************************************
//
//! Initialize UART console.
//!
//! \param ulPortNum is the number of UART port to use for the serial console
//! (0-2)
//!
//! This function will initialize the specified serial port to be used as a
//! serial console.  The serial parameters will be set to 115200, 8-N-1.
//!
//! This function must be called prior to using any of the other UART console
//! functions: UARTprintf() or UARTgets().  In order for this function to work
//! correctly, SysCtlClockSet() must be called prior to calling this function.
//!
//! This function is contained in <tt>utils/uartstdio.c</tt>, with
//! <tt>utils/uartstdio.h</tt> containing the API definition for use by
//! applications.
//!
//! \return None.
//
//*****************************************************************************
void
UARTStdioInit(unsigned long ulPortNum)
{
    //
    // Check the arguments.
    //
    ASSERT((ulPortNum == 0) || (ulPortNum == 1) ||
           (ulPortNum == 2));

    //
    // Check to make sure the UART peripheral is present.
    //
    if(!SysCtlPeripheralPresent(g_ulUartPeriph[ulPortNum]))
    {
        return;
    }

    //
    // Select the base address of the UART.
    //
    g_ulBase = g_ulUartBase[ulPortNum];

    //
    // Enable the UART peripheral for use.
    //
    SysCtlPeripheralEnable(g_ulUartPeriph[ulPortNum]);

    //
    // Configure the UART for 115200, n, 8, 1
    //
    UARTConfigSetExpClk(g_ulBase, SysCtlClockGet(), 115200,
                        (UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
                         UART_CONFIG_WLEN_8));

    //
    // Enable the UART operation.
    //
    UARTEnable(g_ulBase);
}
Example #8
0
//*****************************************************************************
//
//! Initialize the OLED display.
//!
//! \param ulFrequency specifies the SSI Clock Frequency to be used.
//!
//! This function initializes the SSI interface to the OLED display and
//! configures the SSD1329 controller on the panel.
//!
//! This function is contained in <tt>rit128x96x4.c</tt>, with
//! <tt>rit128x96x4.h</tt> containing the API definition for use by
//! applications.
//!
//! \return None.
//
//*****************************************************************************
void
RIT128x96x4Init(unsigned long ulFrequency)
{
    unsigned long ulIdx;


	/* Determine which board is being used. */
	if( SysCtlPeripheralPresent( SYSCTL_PERIPH_ETH ) )
	{
		/* Ethernet is present, we must be using the LM3S8962 EK. */
		ulGPIOId = LM3S8962_SYSCTL_PERIPH_GPIO_OLEDDC;
		ulGPIOBase = LM3S8962_GPIO_OLEDDC_BASE;
		ulOLEDDC_PIN = GPIO_PIN_6;
		ulOLEDEN_PIN = GPIO_PIN_7;
	}
	else
	{
		/* Ethernet is not present, we must be using the LM3S1968 EK. */
		ulGPIOId = LM3S1968_SYSCTL_PERIPH_GPIO_OLEDDC;
		ulGPIOBase = LM3S1968_GPIO_OLEDDC_BASE;
		ulOLEDDC_PIN = GPIO_PIN_2;
		ulOLEDEN_PIN = GPIO_PIN_3;
	}

    //
    // Enable the SSI0 and GPIO port blocks as they are needed by this driver.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(ulGPIOId); 

    //
    // Configure the SSI0CLK and SSIOTX pins for SSI operation.
    //
    GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5);
    GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5,
                     GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD_WPU);

    //
    // Configure the GPIO port pin used as a D/Cn signal for OLED device,
    // and the port pin used to enable power to the OLED panel.
    //
    GPIOPinTypeGPIOOutput(ulGPIOBase, ulOLEDDC_PIN | ulOLEDEN_PIN);
    GPIOPadConfigSet(ulGPIOBase, ulOLEDDC_PIN | ulOLEDEN_PIN,
                     GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
    GPIOPinWrite(ulGPIOBase, ulOLEDDC_PIN | ulOLEDEN_PIN,
                 ulOLEDDC_PIN | ulOLEDEN_PIN);

    //
    // Configure and enable the SSI0 port for master mode.
    //
    RIT128x96x4Enable(ulFrequency);

    //
    // Clear the frame buffer.
    //
    RIT128x96x4Clear();

    //
    // Initialize the SSD1329 controller.  Loop through the initialization
    // sequence array, sending each command "string" to the controller.
    //
    for(ulIdx = 0; ulIdx < sizeof(g_pucRIT128x96x4Init);
        ulIdx += g_pucRIT128x96x4Init[ulIdx] + 1)
    {
        //
        // Send this command.
        //
        RITWriteCommand(g_pucRIT128x96x4Init + ulIdx + 1,
                        g_pucRIT128x96x4Init[ulIdx] - 1);
    }
}
Example #9
0
File: main.c Project: 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;
}
Example #10
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 #11
0
void RMBD01Init(void)
{


  //
  // Configure the ADC for Pitch and Roll
  // sequence 3 means a single sample
  // sequence 1, 2 means up to 4 samples
  // sequence 0 means up to 8 samples
  // we use sequence 1
  //
  if (SysCtlPeripheralPresent(SYSCTL_PERIPH_ADC0))
  {

    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);	
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);


    //
    // Configure the pins to be used as analog inputs.
    //
    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2 | GPIO_PIN_3);

    //
    // Select the external reference for greatest accuracy.
    //
    //ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V);

    //
    // Only for LM4F232 Apply workaround for erratum 6.1, in order to use the
    // external reference.
    //
    //SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    //HWREG(GPIO_PORTB_BASE + GPIO_O_AMSEL) |= GPIO_PIN_6;
	
    ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0); // 1 captures up to 4 samples
    //ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0); // 1 captures up to 4 samples


    //ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ENCODER_CHANNEL_PITCH);     // sample pitch
    //ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ENCODER_CHANNEL_ROLL | ADC_CTL_IE | ADC_CTL_END);     // sample roll

    ADCHardwareOversampleConfigure(ADC0_BASE, 64);
    //ADCSoftwareOversampleConfigure(ADC0_BASE, 0, 8);	

	//ADCSoftwareOversampleStepConfigure(ADC0_BASE, 0, 0, (ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END));
	ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_IE | ADC_CTL_END | ADC_CTL_CH0);


	//ADCSoftwareOversampleStepConfigure(ADC0_BASE, 0, 0, (ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END));
    //ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0);     // sample roll
    //ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END);     // sample roll
	    
    //ADCIntRegister(ADC0_BASE,0,ADCIntHandler);

	//
	// Enable the sequencer and interrupt
	//
	ADCSequenceEnable(ADC0_BASE, 3);
	ADCIntEnable(ADC0_BASE, 3);
	IntEnable(INT_ADC3);
	//
	// Zero the oversample counter and the sum
	//
	g_ucOversampleCnt = 0;
	g_ulSum = 0;
	
    //ADCSequenceEnable(ADC0_BASE, 2);
    //ADCIntEnable(ADC0_BASE, 2);

	#if 0
    //
    // Enable the ADC sequencers
    //
    ADCSequenceEnable(ADC0_BASE, 0);

    //
    // Flush the ADC sequencers to be sure there is no lingering data.
    //
    ADCSequenceDataGet(ADC0_BASE, 0, PitchRollAmp);

    //
    // Enable ADC interrupts
    //
    ADCIntClear(ADC0_BASE, 0);
    ADCIntEnable(ADC0_BASE, 0);
    IntEnable(INT_ADC0SS0);

	#else
    //
    // Setup timer for ADC_TRIGGER_TIMER
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
	
    //
    // Configure the second timer to generate triggers to the ADC 
    //
    TimerConfigure(TIMER1_BASE, TIMER_CFG_32_BIT_PER);
    TimerLoadSet(TIMER1_BASE, TIMER_A, ROM_SysCtlClockGet() / 20000); // 50 us == 20K
    ulTimeSysClock = ROM_SysCtlClockGet()/20000;

  
    TimerControlStall(TIMER1_BASE, TIMER_A, true);
    TimerControlTrigger(TIMER1_BASE, TIMER_A, true);

    //
    // Enable the timers.
    //	
    TimerEnable(TIMER1_BASE, TIMER_A);
	#endif
	
    new_adc = false;
    //
  }
  //
  // Clear outstanding ADC interrupt and enable
  //
  //ADCIntClear(ADC0_BASE, 2);
  //ADCIntEnable(ADC0_BASE, 2);  
  //IntEnable(INT_ADC2);

  //
  // Set the zero current to indicate that the initial sampling has just
  // begun.
  //
  g_usCurrentZero = 0xffff;
} // InitADC
Example #12
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 #13
0
/**
 *
 * The entry point for the application.
 * It is responsible for creating queues, starting tasks and running the
 * main scheduler
 *
 */
int main(void)
{
	//
	// Setup the Hardware
	//
	prvSetupHardware();

	//
	// start Logging
	//
	UARTprintf("Init log file: Status = %d\n", initLog());
	appendToLog("Starting Firmware");
	appendToLog("Universelles Interface von Anzinger Martin und Hahn Florian");

	//
	// write welcome text to the debug console
	//
	printf("\n\n\nStarte Programm ...\n");
	printf("Universelles Interface von Anzinger Martin und Hahn Florian\n");
	printf("Starting Firmware ...\n");

	//
	// initialize Taglibrary
	//
	printf("Initialisiere Taglib ...");
	vInitTagLibrary();
	printf(" done\n");

	//
	// Queue Definition
	// The main Communication between COMM-, GRAPH and HTTPD Task
	//
	printf("Initialize Queues ...\n\txComQueue\n");
	xComQueue = xQueueCreate(COM_QUEUE_SIZE, sizeof(xComMessage));
	printf("\txHttpdQueue\n");
	xHttpdQueue = xQueueCreate(HTTPD_QUEUE_SIZE, sizeof(xComMessage));
	appendToLog("Queues created");

	//
	// start Tasks
	//

	//
	//Real Time Clock Task
	//
	printf("Starting RealTimeClock ... ");
	xTaskCreate( vRealTimeClockTask, (const signed char * const)TIME_TASK_NAME, TIME_STACK_SIZE, NULL, TIME_TASK_PRIORITY, &xRealtimeTaskHandle );
	printf("ok\n");
	appendToLog("RealTimeClock started");

	//
	// Communication Task
	//
	printf("Starting Communication Task ... ");
	xTaskCreate( vComTask, (const signed char * const)COM_TASK_NAME, COM_STACK_SIZE, NULL, COM_TASK_PRIORITY, &xComTaskHandle);
	printf("ok\n");
	appendToLog("ComTask started");

	//
	// Check if an Ethernet Port is available
	//
	if (SysCtlPeripheralPresent(SYSCTL_PERIPH_ETH))
	{
		//
		// LWIP Task
		//
		printf("Starting LWIP ...\n");
		xTaskCreate( LWIPServiceTaskInit, (const signed char * const)LWIP_TASK_NAME, LWIP_STACK_SIZE, NULL, LWIP_TASK_PRIORITY, &xLwipTaskHandle );
		appendToLog("IP-Stack started");
	}

#if ENABLE_GRAPHIC
	//
	// Graphic Task
	//
	printf("Starting Graphic Task ... ");
	xTaskCreate( vGraphicTask, (const signed char * const)GRAPH_TASK_NAME, GRAPH_STACK_SIZE, NULL, GRAPH_TASK_PRIORITY, &xGraphTaskHandle );
	printf("ok\n");
#endif

	//
	// Starting the scheduler.
	//
	vTaskStartScheduler();

	//
	// Fallbackloop if Scheduler Fails
	//
	while (1)
		;
	return 0;
}