示例#1
0
// Perform module initialization
static void initialize(void)
{
   // Set the system clock to run at 50MHz from the PLL
   SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

   lfMotorsInit();
   lfDisplayInit();
   lfSoundInit();

   // Initialize the task scheduler.
   SchedulerInit(TICKS_PER_SECOND);

   // Initialize the IR sensors only for the follower robot
#ifdef FOLLOWER_ROBOT
   lfSensorsInit();
#endif

   // Enable interrupts to the CPU
   IntMasterEnable();

   // Initialize the state machine
#ifdef FOLLOWER_ROBOT
   gblDisplayArgs.state = SEARCH;
#endif

#ifdef LEADER_ROBOT
   gblDisplayArgs.state = WANDER;
#endif
}
示例#2
0
int main(void)
{
  /* Watchdog timer disabled */
  WDTCTL = WDTPW + WDTHOLD;
  
  BspInit();

  DioInit();
  DioSet(BUTTON0);
  UartInit(9600, UartCallback);

  LedInit();

  ButtonInit();
  ButtonSetup(0, Button0Cbf, 20);

  LedOn(0);

  SchedulerInit(100, 1, 2); // 1ms tick, 1 timed task, 2 loop task
  SetSchedulerTimedTask(LedRedFlash, 0, 500, 0); // schedule timed_task[0] as led_red_flash, set off every 500ms
  SetSchedulerLoopTask(ButtonLoop, 0); // schedule loop_task[0] as button_loop
  SetSchedulerLoopTask(UartManage, 1); // schedule loop_task[1] as uart_loop

  __eint();
  SchedulerRun();
  
  while(1)
  {
  }
}
示例#3
0
void main (void)
{
	TTaskHandle xdata A2DTaskHandle, HeaterStatusTaskHandle, HeaterControlTaskHandle;
 	TTaskHandle xdata EdenProtocolTaskHandle, OHDBMessageDecodeTaskHandle;

 	WDTCN = 0xde;               // disable watchdog timer
  	WDTCN = 0xad;

	XBR_Init(); // Initialize cross bars 

    SysClkInit();
	Uart0Init();
	Timer_0_Init();

	SchedulerInit();

	InitCoolingFans(); // Material and UV
 	XilinxWatchdogInit();
 	SpiA2D_Init();
	A2D_Init();
 	SpiInit();
	E2PROMInit();
	XilinxInit();
	OHDBPotenmtrInit();
	Roller_Init();
 	Bumper_Init();
	CommunicationLossTaskInit();
	EdenProtocolInit();
	MessageDecodeInitOHDB();
	HeadData_Init();
 
	EA |= ENABLE;
	
    HeaterControlInit();
	PrintDrv_Init();
	SendWakeUpNotification();
    HeadData_ReadDataFromAllE2PROMs();

	A2DTaskHandle               = SchedulerInstallTask(SpiA2D_Task);
	EdenProtocolTaskHandle      = SchedulerInstallTask(EdenProtocolDecodeTask);
	OHDBMessageDecodeTaskHandle = SchedulerInstallTask(OHDBMessageDecodeTask);
	HeaterStatusTaskHandle      = SchedulerInstallTask(HeaterStatusTask);
	HeaterControlTaskHandle     = SchedulerInstallTask(HeaterControlTask);

	HeaterSetTasksHandles(HeaterStatusTaskHandle, HeaterControlTaskHandle);

	SchedulerResumeTask(GetXilinxWatchdogTaskHandle(),0);
	SchedulerResumeTask(A2DTaskHandle,0);
	SchedulerResumeTask(HeaterStatusTaskHandle,0); 
	SchedulerResumeTask(EdenProtocolTaskHandle,0);
	SchedulerResumeTask(OHDBMessageDecodeTaskHandle,0);
		
 
  	while(1)
  	{ 
	  	SchedulerRun();	
  	} 
}
//*****************************************************************************
//
// The main entry point for the qs-autonomous example.  It initializes the
// system, then eners a forever loop where it runs the scheduler.  The
// scheduler then periodically calls all the tasks in the example to keep
// the program running.
//
//*****************************************************************************
int
main (void)
{
    //
    // Set the system clock to run at 50MHz from the PLL
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_16MHZ);

    //
    // Enable UART0, to be used as a serial console.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Initialize the UART standard I/O.
    //
    UARTStdioInit(0);
    UARTprintf("EVALBOT starting\n");

    //
    // Initialize the simple scheduler to use a tick rate of 100 Hz.
    //
    SchedulerInit(100);

    //
    // Initialize all the tasks used in the example.
    //
    DriveInit();
    DisplayTaskInit();
    LEDTaskInit();
    SoundTaskInit();
    AutoTaskInit();

    //
    // Enter a forever loop and call the scheduler.  The scheduler will
    // periodically call all the tasks in the system according to the timeout
    // value of each task.
    //
    for(;;)
    {
        SchedulerRun();
    }
}
/*****************************************************************************
 *  FUNCTION IMPLEMENTATIONS
 *****************************************************************************/
int main(void)
{
    /* One-time initialization of hardware */
    vInit();

    SchedulerInit(TICKS_PER_SECOND);

    char statusStr[96];

    int sounddemo=0; // sound demo
    SoundVolumeSet(80); // less obnoxious during testing


    while (1)
    {
        SchedulerRun();

        // to get measurements
        // currentMeasuredDistance

        // to play sound
        // soundStart(sounddemo) where soundemo is 0-9

        // A DEMO OF SOUNDS
       ///////////////////////////////////////////////////
        if(GamepadButtons.buttonA && bWavPlaying==false)
        {
        	usprintf(statusStr,"sound=%d\r",sounddemo);
        	Display96x16x1StringDrawCentered(statusStr,0,false);
        	sounddemo = soundStart(sounddemo); // returns the actual sound index used
        	sounddemo++;
        }
    }

    /* This should never happen */
    return 0;
}