int main(void) {

    // Init PIC24
    InitMain();

    // Init modules
    AudioInInit();
    Uart2Init(UART_BAUD_250000, 0);
    LedsInit();

    // Main loop
    while(1) {
        if(AudioInIsGetReady()) {
            Fixed audioSample = AudioInGet();

            // Update LEDs
            LedsUpdate(audioSample);

            // Print audio sample
            Uart2RxTasks();
            if(Uart2IsPutReady() >= 6) {
                static const char asciiDigits[10] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
                int i = FIXED_TO_INT(audioSample);
                div_t n;
                int print = 0;
                if(i < 0) {
                    Uart2PutChar('-');
                    i = -i;
                }
                if(i >= 10000) {
                    n = div(i, 10000);
                    Uart2PutChar(asciiDigits[n.quot]);
                    i = n.rem;
                    print = 1;
                }
                if(i >= 1000 || print) {
                    n = div(i, 1000);
                    Uart2PutChar(asciiDigits[n.quot]);
                    i = n.rem;
                    print = 1;
                }
                if(i >= 100 || print) {
                    n = div(i, 100);
                    Uart2PutChar(asciiDigits[n.quot]);
                    i = n.rem;
                    print = 1;
                }
                if(i >= 10 || print) {
                    n = div(i, 10);
                    Uart2PutChar(asciiDigits[n.quot]);
                    i = n.rem;
                }
                Uart2PutChar(asciiDigits[i]);
                Uart2PutChar('\r');
            }
        }
    }
}
/***************************************************************
** 作   者: Songyimiao
** 官    网:http://www.miaowlabs.com
** 淘    宝:http://miaowlabs.taobao.com
** 日   期: 2015年11月29日
** 函数名称: DriversInit
** 功能描述: 底层驱动初始化            
** 输   入:   
** 输   出:   
** 备    注: 
********************喵呜实验室版权所有**************************
***************************************************************/
void DriversInit(void)
{

	GPIOInit();
  	Timer1Init();
	PWMInit();
	Uart1Init();
	Uart2Init();
	Timer3Timer4Init();

}
Exemple #3
0
void init_system()
{       
  delay_init();	    	 //延时函数初始化
		  
  NVIC_Configuration(); 	      //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
  
  init_leds();        //初始化led
  init_jdqs();        //初始化继电器

  uart1_init(9600);	 //串口1初始化为9600 调试用
  //uart2_init(115200);	 //串口2初始化为115200 WIFI模块用
  Uart2Init();		   //串口2初始化为115200 WIFI模块用

  uart1_send("System Running...\r\n\0",19);
}
Exemple #4
0
int main()
{
    //Clock init  M=43, N1,2 = 2 == 39.61MIPS
    PLLFBD = 43;
    CLKDIVbits.PLLPOST = 0; // N1 = 2
    CLKDIVbits.PLLPRE = 0; // N2 = 2
    OSCTUN = 0;
    RCONbits.SWDTEN = 0;

    __builtin_write_OSCCONH(0x01); // Initiate Clock Switch to Primary (3?)

    __builtin_write_OSCCONL(0x01); // Start clock switching

    while (OSCCONbits.COSC != 0b001); // Wait for Clock switch to occur

    while (OSCCONbits.LOCK != 1) {
    };
    //End of clock init.
    
    initPins();
    
    Uart2Init(115200L, InterruptRoutine);

//    Uart2PrintChar('S');
    while (!SD_IN);
    
    // initialize the file system, open the file, read the file and send in chunks
    FSInit();

    FSFILE * openFile = FSfopen("send.txt", FS_READ);

    char toSend[512];
    int n;
    while (n = FSfread(toSend, 1, 512, openFile)) {
        Uart2SendBytes(toSend, n);
    }
    FSfclose(openFile);

    // turn on amber LED
    TRISAbits.TRISA4 = 0;
    LATAbits.LATA4 = 1;
    
    while (1);
}
Exemple #5
0
int main()
{
	unsigned char keyScanResult = 0;	// 按键结果
	unsigned char i = 0;
	unsigned char j = 0;

	unsigned char batCnt = 0;
	int batteryValue = 0;
	
//	unsigned char id[12] = {1,2,3,4,5,6,7,8,9,'a','b','c'};
//	unsigned char temp[2] = {31, 23};
//	unsigned char sen[2] = {12, 13};
//	unsigned char rssi[2] = {13, 14};
		
//	unsigned char fail_cnt = 0;
	unsigned char send_times = 0;

	// enum BLE_CMD blecmd;
	beep200msBZ();	// 上电提醒

	UartInit();		// Uart1 (for indy)	//[email protected]
	Uart2Init();	// Uart2 	// [email protected]
	Uart3Init(); 	// Uart3 (for BT)	[email protected]
	Uart4Init();	// Uart4 (for debug) //[email protected]
	
	batteryInit();	// 初始化电源芯片
		
	InitOled();		// 初始化OLED
	
	OledPowerUp();		// 开启OLED

	ble_init();	// 默认透传模式
	//BLE_CMD_MODE_IN;
	
	//t0IntInit();	// t0初始化
	// OledClear();
	//Delay999ms();
	OledFlush((unsigned char *)HM);


//	OledFlushBaseState();
//	OledBatteryPower(97);
//	OledBatteryState(3);
//	OledBtConnectState(1);
//	OledChargingState(1);

//	OledWriteWordByHex(1,0,sizeof(buf));
	//OledWeakUpDownMode(9);	// 启动睡眠模式
	
	// ------------------- 亮度调节 ---------------------------	
/*	
	while(1)
	{
		Delay100ms();
		checkCharging();
		keyScanResult = keyScan();
		if(keyScanResult != S0_NO_INPUT){
			//i += 5;
			//GetPwmBRT(i);
			OledWriteWordByHex(1, 0, OLED_BRT_DUTY);
			OledBrtAdjust(1);
			
		}
		if(OLED_BRT_DUTY == 90)
			OLED_BRT_DUTY = 5;		  
	}
*/

	// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

	
	// ------------------- indy ----------------------------------
  

	
	clear_rec_data();
	OledClear();
//	Delay20ms();
	OledWriteMessage57("connect... ");
	indyInitCh875();
	OledClear();
	//OledAssicForState(0,90,'*');	
	while(1)
		{	
			//indySetBD(1001, 1002, 1003, 1004, 0);
			// WDT_CONTR |= 0X37;//使能看门狗。128分频,喂狗时间大约2.6S.
			bleParseData();	// 对蓝牙收到的数据进行解析
			
			clear_mes_body();
		 	Delay50ms();
			//getBatteryPercent();
			//batteryScan();

			
			// 发送电量信息给蓝牙
			batCnt++;
			if(batCnt >= 20){	// 50ms * 20 = 1s;发送一次电量
				batCnt = 0;		
				if(bleState.moreInfor == 1){							
					 bleState.battery[0] = batteryCharge;	// 充电状态;检测P07
					 bleState.battery[1] = getBatteryPercent();	// 得到电量的百分比
					bleSendData(BATTERY, bleState.battery, 2, SUC);
				}
			}
			
			// 按键扫描
			keyScanResult = keyScan();
	 		
			if(keyScanResult == S0_NO_INPUT){ // 过一段时间清除OLED
				if(i < 80){
					i++;
					continue;
				}
				else{
					i = 0;
					OledClear();
				}	
			}
			else if(keyScanResult == S4_MODE){	// 关
				OledPowerDown();
				death_ctron = 0;		
				System_Power_Vcc_ON_OFF = 0;
				}
			else if(keyScanResult == S5_ENTER){	// 开
				if(death_ctron == 0){
					System_Power_Vcc_ON_OFF = 1;
					death_ctron = 1;	
					ble_init();	// 默认透传模式
					beep200msBZ();	// 重启提示
					OledPowerUp();	
					OledClear();
					OledWriteMessage57("init... ");
					indyInitCh875();
					OledClear();	
				}
			}else{			
					//clear_rec_data();
					for(send_times = 0; send_times < 5; send_times++){
						switch(keyScanResult)
						{
								case S1_TUCH: 
									if(bleState.moreInfor == 1)
										indy_readall();		// 读所有
									else
										{
										indyGetBD();
										indy_readtemp();	//temp
										}
										break;

								case S2_KEYP: 
										indy_read_sensorcode();	//sensor code
										break;

								case S3_KEYM: 
										indy_readrssi();	//rssi
										break;

							 	default:
										break;
						}  
					}
				if(keyScanResult && rec_num == 0)
					OledAssicForState(0,90,'*');
				else
					OledAssicForState(0,90,' ');
			}	

	    }

	
	// ----------------------- 按键 -----------------------------
/*	while(1){
		
		Delay100ms();
		keyScanResult = keyScan();
		
		if(keyScanResult != S0_NO_INPUT){
			if(System_Power_Vcc_ON_OFF == 1){				
				OledPowerDown();
				CS_OLED = 0;
				DC_OLED = 0;
				death_ctron = 0;
				WR_OLED = 0;
				RD_OLED = 0;
				System_Power_Vcc_ON_OFF = 0;
			}
			else{
				System_Power_Vcc_ON_OFF = 1;
				death_ctron = 1;
				OledPowerUp();				
			}
		}
	}	
*/
	// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		
	// ------------------------ 充电检测 -----------------------------
		
//		checkCharging();
//		Delay999ms();	

	
	// ---------------------------- 蓝牙 ---------------------------------
	/*	
		
		Delay999ms();
		BT_OPEN;
		WEEK_UP_BT;
		BLE_TRAN_MODE_IN;	// 默认透传模式
		
		Delay999ms();
		BT_CLOSE;
		SLEEP_BT;
		BLE_CMD_MODE_IN;		
		clear_uart2_data();
	*/	

	//SendString4("BT test \n ");
/*
	while(1){
		Delay100ms();
		if(uart3_rec_cnt > 0){
			SendBuf4(uart3_rec_data, uart3_rec_cnt);			
		}
		if( bleParseData() ){
			bleDoCmd();
		//	Delay100ms();
		}
		
		//P50 = 1;
		//P51 = 1;
		//Delay999ms();
		//P50 = 0;
		//P51 = 0;
		//Delay999ms();

//		bleSendData(BLANK, NULL, 1, 0);	
//		bleRecvError();
//		bleSendChar(0xff);
//		bleSendData(ID, id, 12, 0);
		
//		bleSendChar(0xff);
//		bleSendData(TEMP, temp, 2, 0);
//		temp[0]++;
//		temp[1]++;
//		bleSendChar(0xff);
//		bleSendData(SENSORCODE, sen, 2, 0);
//		sen[0]++;
//		sen[1]++;
//		bleSendChar(0xff);
//		bleSendData(RSSI, rssi, 2, 0);
//		rssi[0]++;
//		rssi[1]++;
//		bleSendChar(0xff);
//		Delay999ms();
		
		keyScanResult = keyScan();	// 扫描按键
		switch(keyScanResult){	// 处理按键
			case S0_NO_INPUT:
				break;
			case S1_TUCH:
				bleSendData(ID, id, 12, 0);
				bleSendData(TEMP, temp, 2, 0);
				temp[0]++;
				temp[1]++;
			if(temp[0] > 45)
					temp[0] = 20;
			if(temp[1] > 99)
					temp[1] = 0;
				break;
			case S2_KEYP:
				BLE_CMD_MODE_IN;
				break;	
			case S3_KEYM:
				BLE_TRAN_MODE_IN;	// 默认透传模式
				break;
			case S4_MODE:
				SendString3("BT test \n ");
				break;
			case S5_ENTER:
				OledClear();
				OledWriteMessage(" BT TEST ");
				SendString4("Debug test \n ");
				break;
			default:
				SendString4("error \n ");
				break;
		}
*/				
		/*
		if(uart3_rec_cnt > 0){
			Delay10ms();
			OledClear();
			
			SendString4(uart3_rec_data);
			OledWriteBufByHex57(uart3_rec_data, uart3_rec_cnt);
			bleClearRecData();
		}
		*/
	
//	}
	
	// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

	// -----进入掉电模式(休眠) 5ms唤醒一次	10 * 0.488ms ----------------
//		P51  = 1;	// 用于检测CPU使用率
//		InPowerDownMode;
//		P51 = 0;
	//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

	// ------------------------------ 温度 电量 --------------------------------	
/*	
		while(1){
			//batteryValue = batteryScan();
			//OledWriteDouble(1,0, batteryValue);
			//temp = tempScan();
			//OledWriteDouble(3,0, temp);

			Delay100ms();
			keyScanResult = keyScan();
			if(keyScanResult != S0_NO_INPUT){
				if(System_Power_Vcc_ON_OFF == 1){				
					OledPowerDown();
					System_Power_Vcc_ON_OFF = 0;
				}
				else{
					System_Power_Vcc_ON_OFF = 1;
					OledPowerUp();
					
				}
			}
		}
*/
//		memset(tempStr, 0, sizeof(tempStr));
//		
		
//
//		bat = getBatteryPercent();

//		OledWriteMessage57(tempStr);
	// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	
	//------------------ 查询事件 -----------------------------------------
//		keyScanResult = keyScan();	// 扫描按键
//		switch(keyScanResult){	// 处理按键
//			case S0_NO_INPUT:
//				break;
//			case S1_TUCH:
//				SendString4("S1 \n ");
//				break;
//			case S2_KEYP:
//				SendString4("S2 \n ");
//				pageScan(keyScanResult);
//				break;
//			case S3_KEYM:
//				SendString4("S3 \n ");
//				pageScan(keyScanResult);	
//				break;
//			case S4_MODE:
//				
//				SendString4("S4 \n ");
//				mode_flag_t = 0;
//				pageScan(S0_NO_INPUT);
//				break;
//	
//			case S5_ENTER:
//				pageScan(keyScanResult);	
//				break;
//			default	:
//				SendString4("ERROR \n ");
//				//pageScan(keyScanResult, mode_flag_t);
//				break;
//				
//		}
	// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^								
	
	// --------------------- 业务 ---------------------------------

	//OledWriteWordByHex(3,0,WIRC_H);
	//OledWriteWordByHex(3,16,WIRC_L);
	//WKTCL = 100;
	// WKTCH = 0;
	//WKTCH = 0x80;
	//WeakUpDownMode(20408);
/*
	while(1){
		Delay10ms();
		keyScanResult = keyScan();	// 扫描按键
		if(keyScanResult != S0_NO_INPUT){
			switch(i){
				case 0 :
					GetPwm4(1000);	// 1MHZ
					i = 1;
					break;
				case 1 :
					GetPwm4(100);	// 100KHZ
					i = 2;
					break;
				case 2 :
					GetPwm4(10);	// 10KHZ
					i = 3;
					break;
				case 3 :
					GetPwm4(10000);	// 10KHZ
					i = 0;
					break;	
				default:
					break;
			}

		}
*/

		//OledWriteMessage("Sleep");
		//InPowerDownMode;
		//OledWriteMessage("Weekup");
		//Delay999ms();
		// Delay999ms();
//		SendData2(0xea);
//		Delay20ms();
//		while(uart2_rec_cnt > 0){
			//SendString2(uart2_rec_data);
			//OledWriteAssic57(1, 0, 0xff);
//			OledWriteBufByHex57(uart2_rec_data, uart2_rec_cnt);
//			clear_uart2_data();
//		} 

//	}
//		
	
	

//	P51 = 1;
	return 0;

}
Exemple #6
0
int main(void)
{
    // Watchdog Timer Enabled/disabled by user software
    // (LPRC can be disabled by clearing SWDTEN bit in RCON registe

    // Configure Oscillator to operate the device at 40Mhz
    // Fosc= Fin*M/(N1*N2), Fcy=Fosc/2
    // Fosc= 8M*40/(2*2)=80Mhz for 8M input clock
    PLLFBD = 38; // M=40
    CLKDIVbits.PLLPOST = 0; // N1=2
    CLKDIVbits.PLLPRE = 0; // N2=2
    OSCTUN = 0; // Tune FRC oscillator, if FRC is used

    RCONbits.SWDTEN = 0; /* Disable Watch Dog Timer*/

    // Clock switch to incorporate PLL
    __builtin_write_OSCCONH(0x03); // Initiate Clock Switch to Primary
    // Oscillator with PLL (NOSC=0b011)
    __builtin_write_OSCCONL(0x01); // Start clock switching
    while (OSCCONbits.COSC != 0b011); // Wait for Clock switch to occur

    while (OSCCONbits.LOCK != 1) {
    }; /* Wait for PLL to lock*/

//    bufferPointer = NULL;
    Uart2Init(InterruptRoutine);

    if (!CB_Init(&circBuf, cbData, CB_SIZE)) FATAL_ERROR();

    // Generate a fake input to record to the circular buffer
    // give beginning and end special characters
    unsigned char goodData[512];
    int i;
    for (i=0; i<512; i++) {
        goodData[i] = (char)i;
    }
    goodSum = checksum(goodData, 512);
    
    Uart2PrintStr("Begin.\n");
    file = NewSDInit("newfile.txt");

    int SDConnected = 0;
    while(1)
    {
//        if (bufferPointer != NULL) { TODO implement this?
//            CB_WriteMany(&circBuf, bufferPointer, UART2_BUFFER_SIZE, 1); // the 1 is arbitrary
//            bufferPointer = NULL;
//        }
        if (SD_IN)
        {
            // if the board was just plugged in try to reinitialize
            if(!SDConnected) {
                MEDIA_INFORMATION * Minfo;
                do {
                    Minfo = MDD_MediaInitialize();
                } while(Minfo->errorCode == MEDIA_CANNOT_INITIALIZE);
                SDConnected = 1;
            }
            // When we are connected and initialized, poll the buffer, if there
            // is data, write it.
            unsigned char outData[SD_SECTOR_SIZE];
            if (CB_PeekMany(&circBuf, outData, SD_SECTOR_SIZE)){
                if(NewSDWriteSector(file, outData)){
                    // Remove the data we just written.
                    if(checksum(outData, 512) != goodSum) {
                        FATAL_ERROR();
                    }
                    CB_Remove(&circBuf, SD_SECTOR_SIZE);
                }
            }
        } else {
            SDConnected = 0;
        }
    }
}
Exemple #7
0
int main ( void )
{
	//uint8_t static active= 0;
	//uint8_t static ledstat;
	SystemInit();//系统时钟等初始化

	if(SysTick_Config(72000*1))	 //配置错误返回1,max 16777216   默认72Mhz 时钟 ,1ms延时
	{							
		//LED4_ON; 	//错误处理 		
		while(1);
	}
	
	LED_Init();	 //LED端口初始化
	LED2_ON;
	NVIC_Configuration();//设置NVIC中断分组2:2位抢占优先级,2位响应优先级
	
	
	Uart1Init ( 115200 ); //串口初始化为115200

	GSM_RST = 0; //启动GSM模块
	
	delay_ms(1800);
	USB_Port_Set(0); 	//USB???
	delay_ms(700);
	USB_Port_Set(1);	//USB????
 	Set_USBClock();   
 	USB_Interrupts_Config();    
 	USB_Init();	
	
	
	Uart2Init ( 115200 ); //串口初始化为115200
	Uart3Init ( 115200 );//串口初始化为115200

	//Uart1SendStr(STR("uart1 init\r\n"));

	//Uart2SendStr(STR("uart2 init\r\n"));

	//Uart3SendStr(STR("uart3 init\r\n"));
	
	C_bt_init();
	C_bt_module_reset();
	C_bt_module_init();

	GSM_RST = 1; //启动GSM模块
	while(1)
	{
		
		if(C_bt_device_active())
		{
			LED2_ON;
			if(USB_USART_RX_STA&0x8000){
				//delay_ms(100);
				C_bt_sendBinary((char*)USB_USART_RX_BUF,USB_USART_RX_STA&0x3FFF);
				USB_USART_RX_STA=0;	
			}		
		}
		else
		{
			LED2_OFF;
		}
		
		if((ms_timer %2) == 0){
			C_bt_step();
		}
		
		//模块初始化
		if(C_bt_selftest()){
			LED2_OFF;
		}else{
			//LED2_ON;			
		}
	}
}
Exemple #8
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;
			   	     					  
		   	}
	  	}
}	
Exemple #9
0
void init_ap( void ) {
#ifndef SINGLE_MCU /** init done in main_fbw in single MCU */
  hw_init();
  sys_time_init();

#ifdef LED
  led_init();
#endif

#ifdef ADC
  adc_init();
#endif
#endif /* SINGLE_MCU */

  /************* Sensors initialization ***************/
#ifdef USE_INFRARED
  ir_init();
#endif
#ifdef USE_GYRO
  gyro_init();
#endif
#ifdef USE_GPS
  gps_init();
#endif
#ifdef USE_UART0
  Uart0Init();
#endif
#ifdef USE_UART1
  Uart1Init();
#endif
#ifdef USE_UART2
  Uart2Init();
#endif
#ifdef USE_UART3
  Uart3Init();
#endif
#ifdef USE_USB_SERIAL
  VCOM_init();
#endif

#ifdef USE_GPIO
  GpioInit();
#endif

#ifdef USE_I2C0
  i2c0_init();
#endif
#ifdef USE_I2C1
  i2c1_init();
#endif
#ifdef USE_I2C2
  i2c2_init();
#endif

  /************* Links initialization ***************/
#if defined USE_SPI
  spi_init();
#endif
#if defined MCU_SPI_LINK
  link_mcu_init();
#endif
#ifdef MODEM
  modem_init();
#endif

  /************ Internal status ***************/
  h_ctl_init();
  v_ctl_init();
  estimator_init();
#ifdef ALT_KALMAN
  alt_kalman_init();
#endif
  nav_init();

  modules_init();

  /** - start interrupt task */
  int_enable();

  /** wait 0.5s (historical :-) */
  sys_time_usleep(500000);

#if defined GPS_CONFIGURE
  gps_configure_uart();
#endif

#if defined DATALINK

#if DATALINK == XBEE
  xbee_init();
#endif
#endif /* DATALINK */

#if defined AEROCOMM_DATA_PIN
  IO0DIR |= _BV(AEROCOMM_DATA_PIN);
  IO0SET = _BV(AEROCOMM_DATA_PIN);
#endif

  power_switch = FALSE;

  /************ Multi-uavs status ***************/

#ifdef TRAFFIC_INFO
  traffic_info_init();
#endif

}