Ejemplo n.º 1
0
/*********************************************************************************************************
** 函数名称:  InitAllIRQ
** 函数功能:  对所有需要的中断进行初始化
** 入口参数:  无
** 出口参数:  无
** 函数说明:
*********************************************************************************************************/
void InitAllIRQ(void)
{
/********************************
* 在此处添加中断初始化调用
*********************************/
//	uint8 status;
	Time0Init();	//定时器 

	I2C1Init(I2C_CLK_100K);	//I2C,默认速度100
	I2C2Init(I2C_CLK_100K);	//I2C,默认速度100
	          
#ifndef	__UCOS				
	PCF8563Init();			//UCOS下在时间任务中初始化
//	KeyboardInit();			//键盘任务中初始化
#endif										   
	StorageInit();
	LCDInit();
	DS18B20Init();
}
Ejemplo n.º 2
0
Archivo: init.c Proyecto: mrtos/testing
//--------------------------------------------------------------------------------------------------------------------------
void uComOnChipInitial(void)
{
//	BYTE testi = 89;
//	BYTE test2[2] ;
//	BYTE i;
	SystemInit();
	GPIO_init();
	SetUARTFunction();		// set uart operation		right
	AnalogI2CInit();
	I2C1Init(100000);			//adv7181
	DSA_Init();
	timer0Init();
//	Delayms(2000);

	ADV_RST_LOW();
	REST_N_380_LOW();
	Delayms(500);
	ADV_RST_HIGH();
	REST_N_380_HIGH();


}
/******************************************************************************
** Function name:   main
**
** Description:     Program entry point. Contains initializations and menu loop
**
** Parameters:      None
** Returned value:  Program exit value
**
******************************************************************************/
int main(void)
{
	SystemInit();
	SystemCoreClockUpdate();

	setCANBUS1();

	load_nonpersistent();

	SysTick_Config(SystemCoreClock / 10);	// 100mS Systicker.

	I2C1Init();

	ADCInit(ADC_CLK);

	init_GPIO();

	init_watchdog();

	while(1){shunt_read();}

	return 0;
}
Ejemplo n.º 4
0
/*******************************************************************************
**   Main Function  main()
*******************************************************************************/
int main (void)
{
  uint32_t i;

  /* SystemClockUpdate() updates the SystemFrequency variable */
  SystemClockUpdate();

  I2C0Init( );			/* initialize I2c0 */
  I2C1Init( );			/* initialize I2c1 */
  I2C2Init( );			/* initialize I2c2 */

  /* In order to start the I2CEngine, the all the parameters 
  must be set in advance, including I2CWriteLength, I2CReadLength,
  I2CCmd, and the I2cMasterBuffer which contains the stream
  command/data to the I2c slave device. 
  (1) If it's a I2C write only, the number of bytes to be written is 
  I2CWriteLength, I2CReadLength is zero, the content will be filled 
  in the I2CMasterBuffer. 
  (2) If it's a I2C read only, the number of bytes to be read is 
  I2CReadLength, I2CWriteLength is 0, the read value will be filled 
  in the I2CMasterBuffer. 
  (3) If it's a I2C Write/Read with repeated start, specify the 
  I2CWriteLength, fill the content of bytes to be written in 
  I2CMasterBuffer, specify the I2CReadLength, after the repeated 
  start and the device address with RD bit set, the content of the 
  reading will be filled in I2CMasterBuffer index at 
  I2CMasterBuffer[I2CWriteLength+2]. 
  
  e.g. Start, DevAddr(W), WRByte1...WRByteN, Repeated-Start, DevAddr(R), 
  RDByte1...RDByteN Stop. The content of the reading will be filled 
  after (I2CWriteLength + two devaddr) bytes. */

  /* Write SLA(W), address and one data byte */
  I2CWriteLength[PORT_USED] = 6;
  I2CReadLength[PORT_USED] = 0;
  I2CMasterBuffer[PORT_USED][0] = PCF8594_ADDR;
  I2CMasterBuffer[PORT_USED][1] = 0x00;		/* address */
  I2CMasterBuffer[PORT_USED][2] = 0x55;		/* Data0 */
  I2CMasterBuffer[PORT_USED][3] = 0xAA;		/* Data1 */
  I2CMasterBuffer[PORT_USED][4] = 0x12;		/* Data0 */
  I2CMasterBuffer[PORT_USED][5] = 0x34;		/* Data1 */
  I2CEngine( PORT_USED );

  /* Be careful with below fixed delay. From device to device, or
  even same device with different write length, or various I2C clock, 
  below delay length may need to be changed accordingly. Having 
  a break point before Write/Read start will be helpful to isolate 
  the problem. */
  for ( i = 0; i < 0x200000; i++ );	/* Delay after write */

  for ( i = 0; i < BUFSIZE; i++ )
  {
	I2CSlaveBuffer[PORT_USED][i] = 0x00;
  }
  /* Write SLA(W), address, SLA(R), and read one byte back. */
  I2CWriteLength[PORT_USED] = 2;
  I2CReadLength[PORT_USED] = 4;
  I2CMasterBuffer[PORT_USED][0] = PCF8594_ADDR;
  I2CMasterBuffer[PORT_USED][1] = 0x00;		/* address */
  I2CMasterBuffer[PORT_USED][2] = PCF8594_ADDR | RD_BIT;
  I2CEngine( PORT_USED );

  /* Check the content of the Master and slave buffer */
  while ( 1 );

}
Ejemplo n.º 5
0
  main()
  {
     uint8 option=0;
     uint8 key;
  
    SysCtlClockSet(SYSCTL_SYSDIV_4| SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ);
    Uart0Init(19200);
	Uart1Init(9600);
	Uart2Init(19200);
    IntMasterEnable();
    SysLinearTimer =0;
    IoPortInit();	  //IO口初始化
    I2C1Init() ;//Fm31256
   	TimerInit();
	xs6963_init();
	PIN_TDA7367stand_Write(ETDA7367work_no);
	FlashUsecSet(49);
	//T1Init_LM331();
    DPRINTF(("Bat=%d  ,cha=%d ,Temp=%d \n",1,2,3));
    Usb_Host_Init();  
    mainHandleinit();
	
    signPWM_init(50.0);
    PWM_sign_stop();
	/*LCD初始化*/
	start_mune();
	/* fm31256 eeprom 8 */
    readbyte_much(setsto_addr,settype_nub,set.byte );
 	/*修正系数*/
    modify_read();
	/**/
	Oiltempset.oilTwork=EOiltemp_Workon; 
	/*lm331初始化 温度测量使用*/
	T1Init_LM331();
	/*系统节拍*/
    SysLinearTimer=0;	
	while(SysLinearTimer<3*TIMER_FREQ)//后台参数设置
     {
       key=Keyset.keyEfficiency;
       if(key==key_modify)
    	 {
		   while(Keyset.keyEfficiency==key_modify); 
    	   option++;
		   if(option>=4)
	       	{
			   modify_read();//读取修正参数
			   TgC_read();
    	       modify();//修正
	   	    }
       	 }
    }	
   	modifyK_js();
    SysLinearTimer=0;
    rx_flag=0;
 	option=0;
mainset_go:
	  key=Keyset.keyEfficiency;
      mainset_mune();
      Reversepic(mainset_lin+option*mainset_high, mainset_column, mainset_high, 2*4);
	  while(1)
	  	{
	      while(key==Keyset.keyEfficiency)
		    {
		     if(SysLinearTimer>(3*TIMER_FREQ/4))  	   
              {
			    // Temp_account();
			  if(TRUE_z==Gandispose())//地线检测
			  	{
			  	  mainset_mune();
				  Reversepic(mainset_lin+option*mainset_high, mainset_column, mainset_high, 2*4);
			  	}
           	 
			   read_time();
			    {
				 uint8 byte[12];	
			   	 Clock_viewxs(byte)	;
			   	}
				 SysLinearTimer=0;
			 }
	  	   }
		   key=Keyset.keyEfficiency;
		  /*按键处理*/
           switch(key)
		   	{
               case key_no:
			   case key_back:
			   	        continue;
		       case key_down:
			   case key_up:
			   	      Reversepic(mainset_lin+option*mainset_high, mainset_column, mainset_high, 2*4);
			   	      option=keyoption_js(option, key,4,Emune_key);//
					  Reversepic(mainset_lin+option*mainset_high, mainset_column, mainset_high, 2*4);
                    /*  if(key==key_up)
                      	{
                         PWM_sign_acc(0.0, 0.0);
						 delay(0x80000);
                         PIN_DCAC_pwm(EDC_power);
                      	 PWM_sign_acc(0.0, 0.7);
                      	}
					  else
					  	{
					  	 PWM_sign_acc(0.0, 0.0);
						 delay(0x80000);
					   	 PIN_DCAC_pwm(EAC_power);
					  	 PWM_sign_acc(50.0, 0.8);
					  	}
					 */ 	
					  break;				
			   case key_ok:	
			   	      switch(option)
			   	      	{
			   	      	 
                          case ELan_main://语言
							    set.mune.Langue++;
							    set.mune.Langue&=0x01;
                                //ShowtextLine(mainset_lin+option*mainset_high, mainset_column+0x10,Lanset_p[set.mune.Langue]);	
								break;
					      case EOilset_main://油样设置
						  	    oidset();
							    break;
						  case EView_main://历史数据
						  	    Viewdata_Hander();
						  	   break;
						  case EClock_main://时钟设置
							   clockset_mune();
                               break;			   
			   	      	}					  
					    goto mainset_go ;
               case key_oil:                     			
			          Oilclear();//排油
					 break;
			   	     					  
		   	}
	  	}
}	
Ejemplo n.º 6
0
/**********************************************************
                       MAIN
**********************************************************/
int	main (void) {

  static int vbat1; //battery_voltage (lowpass-filtered)
  unsigned int TimerT1, TimerT2;

  init();
  buzzer(OFF);
  LL_write_init();

  //initialize AscTec Firefly LED fin on I2C1 (not necessary on AscTec Hummingbird or Pelican)
  I2C1Init();
  I2C1_setRGBLed(255,0,0);

	/* Initialize I2C controller. by Xun */
	I2CInit(I2CMASTER);

  ADC0triggerSampling(1<<VOLTAGE_1); //activate ADC sampling

  generateBuildInfo();

  HL_Status.up_time=0;

  LED(1,ON);

  ACISDK();	//AscTec Communication Interface: publish variables, set callbacks, etc.

  //update parameters stored by ACI:
  //...

  PTU_init();	//initialize camera PanTiltUnit
#ifdef MATLAB
  //ee_read((unsigned int*)&matlab_params); //read params from eeprom
  onboard_matlab_initialize(); //initialize matlab code
#endif

  while(1)
  {
      if(mainloop_trigger)
      {
      	TimerT1 =  T0TC;
     	if(GPS_timeout<ControllerCyclesPerSecond) GPS_timeout++;
	  	else if(GPS_timeout==ControllerCyclesPerSecond)
	  	{
  	 		GPS_timeout=ControllerCyclesPerSecond+1;
	  		GPS_Data.status=0;
	  		GPS_Data.numSV=0;
	  	}

        //battery monitoring
        ADC0getSamplingResults(0xFF,adcChannelValues);
        vbat1=(vbat1*14+(adcChannelValues[VOLTAGE_1]*9872/579))/15;	//voltage in mV

		HL_Status.battery_voltage_1=vbat1;
        mainloop_cnt++;
		if(!(mainloop_cnt%10)) buzzer_handler(HL_Status.battery_voltage_1);

	    if(mainloop_trigger) mainloop_trigger--;
        mainloop();
        // CPU Usage calculation
        TimerT2 = T0TC;
        if (mainloop_trigger)
        {
        	HL_Status.cpu_load = 1000;
        	mainloop_overflows++;
        }
        else if (TimerT2 < TimerT1)
        	HL_Status.cpu_load = (T0MR0 - TimerT1 + TimerT2)*1000/T0MR0; // load = "timer cycles" / "timer cycles per controller cycle" * 1000
        else
        	HL_Status.cpu_load = (TimerT2 - TimerT1)*1000/T0MR0; // load = "timer cycles" / "timer cycles per controller cycle" * 1000
      }

  }
  return 0;
}