示例#1
0
void main(void)
{
	Init_Ports();                             // Initialize Ports
	Init_Clocks();                            // Initialize Clock System 
	Init_Conditions();
	Init_Interrupts();
	  
	TimeMsec = RESET_TIME;
	Init_Timers(); 				// Initialize Timers
	Init_LCD();				// Initialize LCD    
        
        
	//          "0123456789abcdef"
	display_1 = "   Homework 9   ";
	display_2 = "                ";
	Display_Process();
	
/* ---------- Begining of the "While" Operating System ------------- */
	while(ALWAYS) 										// Can the Operating system run
	{                            
                ADC_Process();
                Control_Process();
                Menu_Process();
                
          
                if(TimeMsec % EVERY_50 == RESET_TIME)
                {
                        Display_Process();
                }	
	}
}
示例#2
0
文件: PWM.C 项目: vladislav1983/MCD
void __attribute__((__interrupt__,no_auto_psv)) _PWMInterrupt(void)
{
	struct sTaskCounterStruct *tc;
	
	tc = _get_task_count();
	
	if( PWM_MODULE_COUNT_UP )
	{
		if(_drive_enabled()) Load_Ton();			// Load T_ON PDCx Registers	
		if( _is_task1_execute() ) _set_task1_runtime_fault(1);
		else _INT1IF = 1; 	// Run TASK1
	}
	else
	{
		ADC_Process();		// Run ADC Measurement
		if(_drive_enabled()) Load_Toff();		// Load T_OFF PDCx Registers	
	}
	
	if( --(tc)->T2_count <= 0 )
	{
		if( _is_task2_execute() ) _set_task2_runtime_fault(1);
		else _INT2IF = 1; // Run TASK2
		
		(tc)->T2_count = T2_PERIOD;
	}

	_PWMIF = 0;					//Clear Interrupt flag
}
示例#3
0
文件: main.c 项目: dapryor/Embedded
void main(void){
//==============================================================================
// Main Program
// 
// Description: This function contains the while loop that runs continuously
// to act for the operating system. It also calls all the functions to
// initialize the system.
//
// Passed : no variables passed
// Locals: no variables declared
// Returned: no values returned
// Globals:     volatile unsigned int Time_Sequence;
//              volatile char one_time;
//              char* display_1
//              char* display_2
//              char* display_3
//              char* display_4
//              slow_input_down
//              control_state[CNTL_STATE_INDEX]
//              char big
//              char size_count;
//              char posL1
//              char posL2
//              char posL3
//              char posL4
//
// Author: David Pryor
// Date: Feb 2016
// Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1)
//==============================================================================
  Init_Ports();                             // Initialize Ports
  Init_Clocks();                            // Initialize Clock System 
  Init_Conditions();
  Time_Sequence = SWITCH_OFF;               // 
  Init_Timers();                            // Initialize Timers
  Init_LEDs();                              // Initialize LEDs
  Init_LCD();                               // Initialize LCD
  Init_ADC();                               // Initialize ADC

//------------------------------------------------------------------------------
// Begining of the "While" Operating System
//------------------------------------------------------------------------------
  while(ALWAYS) {                            // Can the Operating system run
    Menu_Process();
    ADC_Process();              // call sampling function
    if(display_count >= FOR_FOURTH_SECOND){    // update screen every 250 msec
      Display_Process();
      display_count = SWITCH_OFF;
    }
    if(menu_items == FALSE){  
      display_4 = "SW2: Menu";
    }
    if(switch_two_pressed){
      menu_items = TRUE;
      switch_two_pressed = SWITCH_OFF;
    }
  }
//------------------------------------------------------------------------------
}
示例#4
0
文件: main.c 项目: lzheng5/xcar
void main(void)
{
  // The 'while' operating system
  
  Init_System();
  
  while(ALWAYS)
    {   
      Display_Process();
      Menu_Process();
      ADC_Process();
      CMD_Process();
    }
}
示例#5
0
void main(void)
{
	Init_Ports();                             // Initialize Ports
	Init_Clocks();                            // Initialize Clock System 
	Init_Conditions();
	Init_Interrupts();
       
	//PJOUT |= LED1;                          // Turn LED 1 on to indicate boot
	  
	TimeMsec = RESET_TIME;
	Init_Timers(); 				// Initialize Timers
	Init_LCD();				// Initialize LCD
	//Init_LEDs();                            // Initialize LEDs       
        
        
        
	//          "0123456789abcdef"
	display_1 = "   PROJECT  5   ";
	display_2 = "                ";
	Display_Process();
	
	P1OUT |= IR_LED;
	waitMsec(10);
	
/* ---------- Begining of the "While" Operating System ------------- */
	while(ALWAYS) 										// Can the Operating system run
	{                            
		if(TimeMsec % EVERY_50 == RESET_TIME)
			Display_Process();					//Refreshes screen every 50 'ticks'
                
		if(TimeMsec % EVERY_2 == RESET_TIME)
		{
			Switches_Process();                 // Poll for switch state change every other 'tick'
			ADC_Process();
		}
		
		Motors_Process();
		Control_Process();
	}
}
示例#6
0
文件: main.c 项目: dapryor/Embedded
void main(void){
//==============================================================================
// Main Program
// 
// Description: This function contains the while loop that runs continuously
// to act for the operating system. It also calls all the functions to
// initialize the system.
//
// Passed : no variables passed
// Locals: no variables declared
// Returned: no values returned
// Globals:     volatile unsigned int Time_Sequence;
//              volatile char one_time;
//              char* display_1
//              char* display_2
//              char* display_3
//              char* display_4
//              slow_input_down
//              control_state[CNTL_STATE_INDEX]
//              char big
//              char size_count;
//              char posL1
//              char posL2
//              char posL3
//              char posL4
//
// Author: David Pryor
// Date: Feb 2016
// Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1)
//==============================================================================
  Init_Ports();                             // Initialize Ports
  Init_Clocks();                            // Initialize Clock System 
  Init_Conditions();
  Time_Sequence = SWITCH_OFF;               // 
  Init_Timers();                            // Initialize Timers
  Init_LEDs();                              // Initialize LEDs
  Init_LCD();                               // Initialize LCD
  Init_ADC();                               // Initialize ADC
  Init_Serial_UCA1(0);                      // BAUD rate 9600
  Init_Serial_UCA0(1);                      // BAUD rate 9600
  Five_msec_Delay(1);
  PJOUT |= IOT_STA_MINIAP; //turning on miniap (only works this way)
  IR_LED_OFF();
  lcd_BIG_mid();
  display_1 = "  David   ";
  display_2 = "Project  8";  
  display_3 = "  Pryor   ";
  display_4 = "";
  Display_Process();



//------------------------------------------------------------------------------
// Begining of the "While" Operating System
//------------------------------------------------------------------------------
  while(ALWAYS) {                            // Can the Operating system run
    
    ADC_Process();              // call sampling function
    if(MainFG){
        Menu_Process();
    }
    else if(BaudMenuFG==TRUE){
        Baud_Menu(); 
    }
    else if(IOTMenuFG==TRUE){
        IOT_Menu();
    }
    
    if(StartCommandFG){ //StartCommandFG is true once "." has been received
        commandTree();
    }
    printMacAddress(); //prints mac address to screen
    macFG=FALSE; //turn off command to print mac address
    clearReceiveBuffer();
    parseIOTData();
  }
//------------------------------------------------------------------------------
}
示例#7
0
文件: adc.c 项目: dapryor/Embedded
void IR_Calibration(void){
  //==============================================================================
  // COMMANDTREE
  // 
  // Description: This function is used as a command tree for input commands
  //
  // Passed : no variables passed
  // Locals:    proceed
  // Returned: no values returned
  // Globals:   ADC_Left_Detector
  //            ADC_Right_Detector
  //            thresholdL
  //            thresholdR
  //            left_calibration_black
  //            right_calibration_black
  //            left_calibration_white
  //            right_calibration_white
  //            display_1
  //            display_2
  //            display_3
  //            display_4
  //            switch_two_pressed
  //
  // Author: David Pryor
  // Date: April 2016
  // Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1)
  //============================================================================== 
  int proceed = RESET;
  ADC_Process();              // call sampling function
  
  IR_LED_ON();
  Five_msec_Delay(FOR_ONE_SECOND);
  display_1 = "White Test";
  display_2 = "Press SW2";
  display_3 = "";  
  display_4 = "";
  Display_Process();
  while(proceed == FALSE){
    if(switch_two_pressed){
      proceed = TRUE;
      switch_two_pressed = FALSE;
    }
  }
  ADC_Process();              // call sampling function
  right_calibration_white = ADC_Right_Detector;
  left_calibration_white = ADC_Left_Detector;
  proceed = RESET;
  
  display_1 = "Black Test";
  display_2 = "Press SW2";
  display_3 = "";  
  display_4 = "";
  Display_Process();
  while(proceed == FALSE){
    if(switch_two_pressed){
      proceed = TRUE;
      switch_two_pressed = FALSE;
    }
  }
  ADC_Process();              // call sampling function
  right_calibration_black = ADC_Right_Detector;
  left_calibration_black = ADC_Left_Detector;
    
  IR_LED_OFF();
  thresholdR = ((right_calibration_black + right_calibration_white)/HALF)+THRESHOLD_SENSITIVITY;
  thresholdL = ((left_calibration_black + left_calibration_white)/HALF)+THRESHOLD_SENSITIVITY;
  
}