Exemplo n.º 1
0
int main(void) {
  InitializeA36772();
  _CONTROL_NOT_CONFIGURED = 0;
  _CONTROL_NOT_READY = 1;
  
  while (global_data_A36772.run_time_counter < 300) {
    DoStartupLEDs();
    if (_T2IF) {
      _T2IF = 0;
      global_data_A36772.run_time_counter++;
    } 
  }
 
  while (1) {
    DoA36772();
  }
}
Exemplo n.º 2
0
void DoStateMachine(void) {
  switch (global_data_A36582.control_state) {
    
  case STATE_STARTUP:
    InitializeA36582();
    _CONTROL_NOT_CONFIGURED = 0;
    _CONTROL_NOT_READY = 1;
    global_data_A36582.control_state = STATE_FLASH_LED;
    break;


  case STATE_FLASH_LED:
    _CONTROL_NOT_READY = 1;
    ResetPulseLatches();
    while (global_data_A36582.control_state == STATE_FLASH_LED) {
      DoA36582();
      DoStartupLEDs();
      
      if (global_data_A36582.led_flash_counter >= LED_STARTUP_FLASH_TIME) {
	global_data_A36582.control_state = STATE_OPERATE;
      }
    }
    break;
    
  case STATE_OPERATE:
    global_data_A36582.fast_arc_counter = 0;
    global_data_A36582.poor_pulse_counter = 0;
    global_data_A36582.slow_arc_counter = 0;
    global_data_A36582.consecutive_arc_counter = 0;
    global_data_A36582.pulse_counter_fast = 0;
    global_data_A36582.pulse_counter_slow = 0;
    global_data_A36582.false_trigger_counter = 0;
    under_current_arc_count = 0;
    over_current_arc_count = 0;
    _FAULT_REGISTER = 0;
    _CONTROL_NOT_READY = 0;
    while (global_data_A36582.control_state == STATE_OPERATE) {
      DoA36582();
      if (global_data_A36582.sample_complete) {
	DoPostPulseProcess();
	global_data_A36582.sample_complete = 0;
      }

      if (_FAULT_REGISTER) {
	global_data_A36582.control_state = STATE_FAULT;
      }
    }
    break;
    
    
  case STATE_FAULT:
    _CONTROL_NOT_READY = 1;
    while (global_data_A36582.control_state == STATE_FAULT) {
      DoA36582();
      if (global_data_A36582.sample_complete) {
	global_data_A36582.sample_complete = 0;
	DoPostPulseProcess();
      }
      
      if (ETMCanSlaveGetSyncMsgResetEnable()) {
	global_data_A36582.control_state = STATE_OPERATE;
      }
    }
    break;
    

  default:
    global_data_A36582.control_state = STATE_FAULT;
    break;
  }
}