void main(void)
   {
   // Set up the scheduler 
   SCU_B_SLAVE_Init_T1(9600);

   // Set up the flash LED task (demo purposes)
   LED_Flash_Init();

   // Prepare for the traffic light task
   TRAFFIC_LIGHTS_Init();

   // Add a 'flash LED' task (on for 1000 ms, off for 1000 ms)
   SCH_Add_Task(LED_Flash_Update, 0, 200);

   // Add a 'traffic lights' task
   SCH_Add_Task(TRAFFIC_LIGHTS_Update, 10, 200);

   // Start the scheduler
   SCU_B_SLAVE_Start();

   while(1)
      {
      SCH_Dispatch_Tasks();
      }
   }
void main(void)
   {
   // Set up the scheduler 
   SCH_Init_T2();

   // Set up the display
   BARGRAPH_Init();

   // Set up the switch pin
   SWITCH_MS_Init();

   // Add a 'SWITCH_MS_Update' task, every ~200 ms
   // - timings are in ticks (50 ms tick interval - see Sch 'init' function)
   SCH_Add_Task(SWITCH_MS_Update, 0, 4);

   // Add a 'COUNTER_Update' task every ~1000 ms
   SCH_Add_Task(COUNTER_Update, 0, 20);

   SCH_Start();

   while(1)
      {
      SCH_Dispatch_Tasks();
      }
   }
/* ............................................................... */
void main(void)
   {
   // Initialisation can be problematic with some display / supply
   // combinations.  You may get away with calling this function
   // twice (or once) but - for maximum reliability under a very wide range 
   // of conditions - it is called three times here.
   LCD_Init(0);
   LCD_Init(0);
   LCD_Init(1);

   // Prepare the elapsed time library
   Elapsed_Time_LCD_Init();

   // Prepare the scheduler
   SCH_Init_T2();

   // Add tasks to the scheduler
   //
   // Update the time every second (*** 1ms sched ticks ***)
   SCH_Add_Task(Elapsed_Time_LCD_Update, 100, 1000);

   // Update the whole display ~ every second 
   // - do this by updating a character once every 24 ms
   // (assumes a 40 character display)
   SCH_Add_Task(LCD_Update, 1000, 24);

   // All tasks added: start running the scheduler
   SCH_Start();   

   while(1)
      {
      SCH_Dispatch_Tasks();
      }
   }
void main(void)
   {
   // Set up the scheduler 
   SCC_A_SLAVE_Init_CAN();

   // Set up the flash LED task (demo purposes)
   LED_Flash_Init();

   // Prepare for the traffic light task
   TRAFFIC_LIGHTS_Init();

   // TIMING IS IN TICKS (6 ms tick interval)
   // Add a 'flash LED' task (on for 1002 ms, off for 1002 ms)
   SCH_Add_Task(LED_Flash_Update, 0, 167);

   // Add the traffic-light task
   SCH_Add_Task(TRAFFIC_LIGHTS_Update, 30, 167);

   // Start the scheduler
   SCC_A_SLAVE_Start();

   while(1)
      {
      SCH_Dispatch_Tasks();
      }
   }
Beispiel #5
0
void main(void)
{  
   // setup microcontroller
   PLLCON = 0x00;
   P0 = 0x00;
   P1 &= ~(1<<6);
   P1 &= ~(1<<7);

   // Set up the scheduler
   SCH_Init_T2();

   // init tasks
   init_statemachine();

   // - timings are in ticks (~1 ms tick interval)
   SCH_Add_Task(statemachine, 0, 10);
   SCH_Add_Task(switchStateMachine, 5, 20);

   // Start the scheduler
   SCH_Start();				

   while(1) {
      SCH_Dispatch_Tasks();
   }
}
void main(void)
   {
   // Set up the scheduler 
   SCU_A_MASTER_Init_T1_T2(9600);       

   // Prepare for the traffic light task
   TRAFFIC_LIGHTS_Init();

   // Prepare for the flash LED task (demo only)
   LED_Flash_Init();

   // Add a 'flash LED' task (on for 1000 ms, off for 1000 ms)
   SCH_Add_Task(LED_Flash_Update, 0, 200);

   // Add a 'traffic light' task
   SCH_Add_Task(TRAFFIC_LIGHTS_Update, 30, 200);
   
   // Start the scheduler
   SCU_A_MASTER_Start();

   while(1)
      {
      SCH_Dispatch_Tasks();
      }
   }
/*--------------------------------------------------------------------*-

  SYSTEM_Configure_Required_Mode()

  Configure the system in the required mode.  

-*--------------------------------------------------------------------*/
void SYSTEM_Configure_Required_Mode(void)
{
	switch (System_mode_G)
	{
		default:          // Default to "FAIL_SILENT"

		case FAIL_SILENT:
			// Reset caused by WDT
			// Trigger "fail silent" behaviour
			SYSTEM_Perform_Safe_Shutdown();

			break;

		case NORMAL:
            mcu_init();
        
			// Set up WDT 
			// Set to overflow after ~12ms
			WATCHDOG_Init();

			// Set up scheduler for 1 ms ticks
			SCH_Init();

			// Prepare for heartbeat task
			HEARTBEAT_Init();

			// Add tasks to schedule.
			// Parameters are:
			// 1. Task name
			// 2. Initial delay / offset (in Ticks)
			// 3. Task period (in Ticks): Must be > 0
			// 4. Task WCET (in microseconds)
			// 5. Task BCET (in microseconds)

			// Add watchdog task first
			SCH_Add_Task(WATCHDOG_Update, 0, 1500, 10, 0);

			// Add heartbeat task
			SCH_Add_Task(HEARTBEAT_Update, 0, 1000, 20, 0);

			// Feed the watchdog
			WATCHDOG_Update();

			break;
	}
}
Beispiel #8
0
void main(){
	SCH_Init_T2();

	led_init();

	SCH_Add_Task(draw1,0,2);
	SCH_Add_Task(draw2,1,2);
	SCH_Add_Task(draw,0,34);

	SCH_Start();
	while(1){
		SCH_Dispatch_Tasks();
		button();
		if(350==count++){
			count=0;
			move();
		}	
	}
}
void main(void)
   {
   // Set up the scheduler
   SCH_Init_T2();

   // Add the 'Time Update' task (once per second)
   // - timings are in ticks (1 ms tick interval)
   // (Max interval / delay is 65535 ticks)
   SCH_Add_Task(CLOCK_LED_Time_Update,100,10);

   // Add the 'Display Update' task (once per second)
   // Need to update a 4-segment display every 3 ms (approx)
   // Need to update a 2-segment display every 6 ms (approx)
   SCH_Add_Task(LED_MX4_Display_Update,0,3);

   // Start the scheduler
   SCH_Start();

   while(1)
      {
      SCH_Dispatch_Tasks();
      }
   }
void main()
{
	cli();          	// disable INT. during peripheral setting
	Peripheral_Init();
	SCH_Init_T2_1ms();  //初始化systick为1ms
	sei();          	// enable INT.
	
	SCH_Add_Task(UART0_TX,0,10);     
	SCH_Start();
	
	// TODO: add your main code here
	while(1)
	{
		SCH_Dispatch_Tasks();
	}
}
void main(void)
   {
   // Set up the scheduler
   SCH_Init_T0();

   // Prepare for the 'Flash_LED' task
   LED_Flash_Init();

   // Add the 'Flash LED' task (on for ~1000 ms, off for ~1000 ms)
   // - timings are in ticks (5 ms tick interval)
   // (Max interval / delay is 65535 ticks)
   SCH_Add_Task(LED_Flash_Update, 0, 200);

   // Start the scheduler
   SCH_Start();

   while(1)
      {
      SCH_Dispatch_Tasks();
      }
   }
void main(void)
   {
   // Set up the scheduler
   SCH_Init_T2();

   // Set baud rate to 9600, using internal baud rate generator
   // Generic 8051 version
   PC_LINK_IO_Init_Internal(9600);

   // We have to schedule this task (10x a second is enough here)
   // - this checks if a character has been received by the USART
   // - if so, responds appropriately. 
   //
   // TIMING IS IN TICKS NOT MILLISECONDS (1 ms tick interval)
   SCH_Add_Task(MENU_Command_Processor,100,100);

   SCH_Start();

   while(1)
      {
      SCH_Dispatch_Tasks();
      }
   }