Exemple #1
0
void APP_init(void)
{



COM_init(CMD_SOP , CMD_EOP ,RESP_SOP , RESP_EOP , APP_comCallBack);



}
Exemple #2
0
/*======================= configuracon de dispositivos =======================*/
void setup_devices(){
	//int myerror = 0;
   /*========================= configuracion del USB =========================*/
   myerror = COM_init();
   /*========================= configuracion del MMA7455 =====================*/
   //myerror += MEMORIA_init_hw();
   //myerror += MEMORIA_init();
   
   /*========================= conversor analogo/digital =====================*/
   // myerror = AD_init_adc();
   
   /*========================= modulo CPP ====================================*/
   //myerror = CP_init_ccp();
   
   /*========================= configuracion del Reloj Digital ===============*/
   //ds1307_init(DS1307_OUT_ON_DISABLED_HIHG | DS1307_OUT_ENABLED | DS1307_OUT_1_HZ);
   //ds1307_set_date_time(0x0d, 0x01, 0x0d, 0x00, 0x0a, 0x2a, 0x00);
   
   
   
   /*-------------------------------------------------------------------------*/
   setup_psp(PSP_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   
   #ifndef CAPTURA_FRECUENCIA_H
	setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
	setup_ccp1(CCP_OFF);
   #endif
   
   /*-------------------------------------------------------------------------*/
   
   /*===================para los indicadores========================*/
   set_tris_e(0x00);
   set_tris_b(0x00);
   set_tris_c(0x80);		//configuracion para el modulo de memoria
   set_tris_d(0x48);
   output_bit(INDICADOR_USB, 0);
   output_bit(INDICADOR_AMARILLO, 1);
   ////////////////////////////////
   output_low(SPI_SCL);
   output_high(SPI_SS);
   output_low(SPI_MOSI);
   output_high(SPI_MISO);
   ////////////////////////////////
   //delay_ms(3000);
   /*===============================================================*/
   return;
}
int SolverModuleDriver::init(int argc, char *argv[]){

  COM_init( &argc, &argv);

  std::cout << "SoverModuleDriver:init: After COM_init" << std::endl;

  isNum =  isFSI = changeLoads = false;
  Disp = NULL;
  DispSize = 0;
  Coord = NULL;
  Conn = NULL;
  coord_handle = -1;
  CoordSize=0;
  coordData = false;
  connCorrect = true;
  ConnSize = 0;
  Loads = NULL;
  LoadsSize = 0;
  
  std::string arg;

  if(argc > 1){
    for(int i=1; i < argc; i++){
        ss.clear();
        ss.str("");
        ss << argv[i];
        if(ss.str() == "-com-mpi")
          continue;
        if(ss.str() == "-fsi"){
          isFSI = true;
          continue;
        }
        if(ss.str() == "-loads"){
          changeLoads = true;
          continue;
        }
        for(int j=0; j < ss.str().size(); j++){
          if(!isdigit(ss.str()[j]) && ss.str()[j] != 'e' 
             && ss.str()[j] != 'E' && ss.str()[j] != '-'
             && ss.str()[j] != '.')
            usage(argv[0]);
        }
        ss >> var;
        tNext.push_back(var);
    }
  }      
  else
Exemple #4
0
void main(void)
{
	UINT8 count=0, i, uartData;
	UINT8 blink = 0;

	BRD_init();			//board initialization

	DigitDisplay_init(NO_OF_DIGITS); //Digit Display initialization

	TMR0_init(DIGIT_REFRESH_PERIOD,DigitDisplay_task);		//initialize timer0
 	COM_init(CMD_SOP , CMD_EOP ,RESP_SOP , RESP_EOP , APP_comCallBack);
	APP_init();

	EnableInterrupts();		//Interrupts initialization
	
	ENABLE_GLOBAL_INT();

	

	while(1)
	{


	`	if(heartBeatCount >= 600 )
		{	

			HB_task();
			heartBeatCount = 0;
		}
		
		if(appUpdateCount >= 500)
		{
			APP_task();	
			appUpdateCount = 0;
		}
		COM_task();
	}


}
Exemple #5
0
/*!
 *******************************************************************************
 * main program
 ******************************************************************************/
int main(void)
{
    //! initalization
    init();

	task=0;

    //! Enable interrupts
    sei();
    
    /* check EEPROM layout */
    if (EEPROM_read((uint16_t)&ee_layout)!=EE_LAYOUT) {
        LCD_PrintStringID(LCD_STRING_EEPr,LCD_MODE_ON);
        task_lcd_update();
        for(;;) {;}  //fatal error, stop startup
    }

	COM_init();

	// We should do the following once here to have valid data from the start

		
    /*!
    ****************************************************************************
    * main loop
    ***************************************************************************/
    for (;;){        
		// go to sleep with ADC conversion start
		asm volatile ("cli");
		if (
          ! task &&
          ((ASSR & (_BV(OCR2UB)|_BV(TCN2UB)|_BV(TCR2UB))) == 0) // ATmega169 datasheet chapter 17.8.1
            ) {
  			// nothing to do, go to sleep
            if(timer0_need_clock() || RS_need_clock()) {
			    SMCR = (0<<SM1)|(0<<SM0)|(1<<SE); // Idle mode
            } else {
    			if (sleep_with_ADC) {
    				SMCR = (0<<SM1)|(1<<SM0)|(1<<SE); // ADC noise reduction mode
				} else {
				    SMCR = (1<<SM1)|(1<<SM0)|(1<<SE); // Power-save mode
                }
            }

			if (sleep_with_ADC) {
				sleep_with_ADC=0;
				// start conversions
		        ADCSRA |= (1<<ADSC);
			}

			DEBUG_BEFORE_SLEEP();
			asm volatile ("sei");	//  sequence from ATMEL datasheet chapter 6.8.
			asm volatile ("sleep");
			asm volatile ("nop");
			DEBUG_AFTER_SLEEP(); 
			SMCR = (1<<SM1)|(1<<SM0)|(0<<SE); // Power-save mode
		} else {
			asm volatile ("sei");
		}

        // update LCD task
		if (task & TASK_LCD) {
			task&=~TASK_LCD;
			task_lcd_update();
			continue; // on most case we have only 1 task, iprove time to sleep
		}

		if (task & TASK_ADC) {
			task&=~TASK_ADC;
			if (task_ADC()==0) {
                // ADC is done
                // TODO
            }
			continue; // on most case we have only 1 task, iprove time to sleep
		}
		
        // communication
		if (task & TASK_COM) {
			task&=~TASK_COM;
			COM_commad_parse();
			continue; // on most case we have only 1 task, iprove time to sleep
		}

        // motor stop
        if (task & TASK_MOTOR_STOP) {
            task&=~TASK_MOTOR_STOP;
            MOTOR_timer_stop();
			continue; // on most case we have only 1 task, iprove time to sleep
        }

        // update motor possition
        if (task & TASK_MOTOR_PULSE) {
            task&=~TASK_MOTOR_PULSE;
            MOTOR_updateCalibration(mont_contact_pooling());
            MOTOR_timer_pulse();
			continue; // on most case we have only 1 task, iprove time to sleep
        }

		//! check keyboard and set keyboards events
		if (task & TASK_KB) {
			task&=~TASK_KB;
			task_keyboard();
		}

        if (task & TASK_RTC) {
            task&=~TASK_RTC;
            {
                bool minute = RTC_AddOneSecond();
                valve_wanted = CTL_update(minute,valve_wanted);
                if (minute && (RTC_GetDayOfWeek()==6) && (RTC_GetHour()==10) && (RTC_GetMinute()==0)) {
                    // every sunday 10:00AM
                    // TODO: improve this code!
                    // valve protection / CyCL
                    MOTOR_updateCalibration(0);
                }
            }
            MOTOR_updateCalibration(mont_contact_pooling());
            MOTOR_Goto(valve_wanted);
            task_keyboard_long_press_detect();
            if ((MOTOR_Dir==stop) || (config.allow_ADC_during_motor)) start_task_ADC();
            if (menu_auto_update_timeout>=0) {
                menu_auto_update_timeout--;
            }
            menu_view(false); // TODO: move it, it is wrong place
            LCD_Update(); // TODO: move it, it is wrong place
            // do not use continue here (menu_auto_update_timeout==0)
        }

		// menu state machine
		if (kb_events || (menu_auto_update_timeout==0)) {
           bool update = menu_controller(false);
           if (update) {
               menu_controller(true); // menu updated, call it again
           } 
           menu_view(update); // TODO: move it, it is wrong place
	       LCD_Update(); // TODO: move it, it is wrong place
		}
    } //End Main loop
Exemple #6
0
void IAS_init(void)
{

	UINT16 i;
	UINT8 j,*ptr;
	UINT8 ackStatus = 0;
	UINT8 grn =0 ,org = 0,red = 0,buz = 0; 

#ifdef __FACTORY_CONFIGURATION__

	ias.state = ISSUE_RESOLVED;
	ias.issues_raised = 0;														//No. of raised issues should be 0 initially
	ias.issues_critical = 0;													//No. of critical issues should be 0 initially
	ias.preAppTime = 0;
	ias.curAppTime = 0;
	log.index = 0;
	ias.logonStatus = 0;
	updateIndication(1,0,0,0);
	for(i = 0; i < 256; i++)
	{
		Write_b_eep(i,0);
		Busy_eep();
		ClrWdt();

	}

#else

	ias.preAppTime = 0;
	ias.curAppTime = 0;
	log.index = 0;

	for( i = 0; i < MAX_ISSUES; i++)
	{
		ptr = (UINT8*) &ias.issues[i];
		for( j = 0 ; j < ISSUE_ENTRY_SIZE; j++)
		{
			Busy_eep();
			ClrWdt();
			*(ptr+j) = Read_b_eep((i*ISSUE_ENTRY_SIZE)+j );

			Busy_eep();
			ClrWdt();

		}

		if( ias.issues[i].state == ISSUE_RAISED)
			ias.issues_raised++;
		if(ias.issues[i].state == ISSUE_CRITICAL)
			ias.issues_critical++;
		if(ias.issues[i].ackStatus == 1)
			ackStatus = 1;
	}

	if( ias.issues_critical > 0 )
		red = 1;
	else if( ias.issues_raised > 0 )
		org = 1;
	else grn = 1;
	
	if( ackStatus == 1 )
		buz = 1;


	ias.buzzerTimeout = 6;
	Busy_eep();
	ClrWdt();

	updateIndication(0,0,0,0);
	
	
	login();
	ias.logonStatus = 1;
	
	updateIndication(grn,org,red,buz);

#endif

COM_init(CMD_SOP , CMD_EOP ,RESP_SOP , RESP_EOP , APP_comCallBack);



}
void main(void)
{
	UINT8 i,j;
	BOOL ledStrip_On = 0;
	BRD_init();
	HB_init();
    External_Init();
	MMD_init();  // Display initialization
    


	COM_init(CMD_SOP,CMD_EOP,RESP_SOP,RESP_EOP,APP_comCallBack);
	
	LinearKeyPad_init( );

	DelayMs(3000);

	InitializeRtc();	


	APP_init();




	TMR0_init(TICK_PERIOD,0);	//initialize timer0
	TMR1_init(MMD_REFRESH_PERIOD,MMD_refreshDisplay);


	EnableInterrupts();

#ifdef __SET_RTC__


	WriteRtcTimeAndDate(writeTimeDateBuffer);
#endif

	while(1)
	{

		if( comUpdateCount > 5 )
		{
		
			COM1_task();	
			//COM2_task();	
			comUpdateCount = 0;
		}
#ifdef TIME_DEBUG	
		if(  heartBeatCount >= 250 )
		{
#endif
			UpdateRealTimeClockTask();
			if( TimeClockUpdateRequired == TRUE)
			{
				HB_task();
			
				TimeClockUpdateRequired = FALSE;
			}

#ifdef TIME_DEBUG
		heartBeatCount = 0;
		}
#endif
		if(  heartBeatCount >= 250 )
		{
				APP_task();
				 heartBeatCount = 0;
		}

		if( mmdUpdateCount >= 5 )
		{
			MMD_task();
			mmdUpdateCount = 0;
		}
		
		if(keypadUpdate_count >= 10)
		{
			//LinearKeyPad_scan();
			keypadUpdate_count = 0;
		}


	}
}