Пример #1
0
int main(void)
{   
	int * p;
	unsigned char buffer[16]= {1,2,3,4,5,6,7,8,9,0};
	SystemInit(); //设置系统时钟为72M
	KeyInit();	  //按键管脚初始化
	LED_GPIO_Config();//LED管脚初始化
  lcd_gpio_config();
	CAN_GPIO_Config();//CAN管脚初始化
	CAN_NVIC_Configuration(); //CAN中断初始化   
	CAN_INIT();//CA初始化N模块	
//	p = (int*)0x8001600;
//	*p = 0xaaaa;

	lcd_init();
	sw_i2c_init();
	lcd_clear(0x00);
	write_32byte(X_1,Y_1,2);
	write_32byte(X_2,Y_1,2);
	write_32byte(X_3,Y_1,2);
	write_32byte(X_4,Y_1,2);
	sw_i2c_read(0,1,buffer,16);
 	while(1)
    {
	 GetKey();	//检测是否有按键按下
	   
  	}
}
Пример #2
0
void EventReset(EventHandlers *handlers, Pic *mouseCursor, Pic *mouseTrail)
{
	KeyInit(&handlers->keyboard);
	JoyReset(&handlers->joysticks);
	MouseInit(
		&handlers->mouse, mouseCursor, mouseTrail, handlers->mouse.hideMouse);
}
Пример #3
0
Файл: med.c Проект: paud/d2x-xl
int DosShell()
{
	int ok, w, h;
	grsBitmap * save_bitmap;

	// Save the current graphics state.

	w = grdCurScreen->scCanvas.cvBitmap.bmProps.w;
	h = grdCurScreen->scCanvas.cvBitmap.bmProps.h;

	save_bitmap = GrCreateBitmap( w, h );
	GrBmUBitBlt(w, h, 0, 0, 0, 0, &(grdCurScreen->scCanvas.cvBitmap), save_bitmap );

	GrSetMode( SM_ORIGINAL );

	//printf( "\n\nType EXIT to return to Inferno" );
	//fflush(stdout);

	KeyClose();
#ifndef __LINUX__
	ok = spawnl(P_WAIT,getenv("COMSPEC"), NULL );
#else
        system("");
#endif
	KeyInit();

	GrSetMode(grdCurScreen->scMode);
	GrBmUBitBlt(w, h, 0, 0, 0, 0, save_bitmap, &(grdCurScreen->scCanvas.cvBitmap);
	GrFreeBitmap( save_bitmap );
	//gr_pal_setblock( 0, 256, grdCurScreen->pal );
	//GrUsePaletteTable();

	return 1;

}
Пример #4
0
/*************************************************************************
* STARTUP TASK - Prints out checksum and waits for c press. When C is pressed,
* starts LCD and Demo Task, then deletes itself
* Functions included: CalcChkSum, LcdDispStrg, DisplayCheckSum
* Creates: LCDDemoTask and DemoCntrlTask
*************************************************************************/
static void StartTask(void *p_arg) 
{    
    (void)p_arg;                          /* Avoid compiler warning     */
    OSTickInit();
   	TimeInit();
                          /* Initialize uC/OS-II              */
    KeyInit();
    //LcdInit();
     
     LcdInit(TRUE,TRUE,FALSE);
     
    DBUG_PORT |= PP7;
    
    //LcdClrDisp();	
    //LcdMoveCursor(1,5);
    
     
    (void)OSTaskCreate(UITask,         /* Create UITask   */
                (void *)0,
                (void *)&UITaskStk[UITASK_STK_SIZE],
                UITASK_PRIO);
    (void)OSTaskCreate(TimeDispTask,         /* Create TimeDispTask  */
                (void *)0,
                (void *)&TimeDispTaskStk[TIMEDISPTASK_STK_SIZE],
                TIMEDISPTASK_PRIO);
     //LcdDispChar(1,1,CLOCK_LAYER,'2');
    DBUG_PORT &= ~PP7;
    (void)OSTaskDel(STARTTASK_PRIO);
    FOREVER()
    {
      //do nothing
    }
}
Пример #5
0
Файл: key.c Проект: paud/d2x-xl
void KeyFlush()
{
 	int i;
	fix curtime;

	if (!Installed)
		KeyInit();

	key_data.keyhead = key_data.keytail = 0;

	//Clear the keyboard buffer
	for (i=0; i<KEY_BUFFER_SIZE; i++ )	{
		key_data.keybuffer[i] = 0;
		key_data.time_pressed[i] = 0;
	}

	curtime = TimerGetFixedSeconds();

	for (i=0; i<256; i++ )	{
		keyd_pressed[i] = 0;
		key_data.keys[i].state = 1;
		key_data.keys[i].lastState = 0;
		key_data.keys[i].timewentdown = curtime;
		key_data.keys[i].downcount=0;
		key_data.keys[i].upcount=0;
		key_data.keys[i].timehelddown = 0;
		key_data.keys[i].counter = 0;
	}
}
Пример #6
0
/*************************************************************************
* STARTUP TASK - Prints out checksum and waits for c press. When C is pressed,
* starts LCD and Demo Task, then deletes itself
* Functions included: CalcChkSum, LcdDispStrg, DisplayCheckSum
* Creates: LCDDemoTask and DemoCntrlTask
*************************************************************************/
static void StartTask(void *p_arg) 
{    
    (void)p_arg;                          /* Avoid compiler warning     */
    OSTickInit();
   	    
    DBUG_PORT |= PP7;
           
    KeyInit();     
    TimeInit();                          
    LcdInit(TRUE,TRUE,FALSE);
    SetTheTime();//for reset purposes
    (void)OSTaskCreate(UITask,         /* Create UITask   */
                (void *)0,
                (void *)&UITaskStk[UITASK_STK_SIZE],
                UITASK_PRIO);
    (void)OSTaskCreate(TimeDispTask,         /* Create TimeDispTask  */
                (void *)0,
                (void *)&TimeDispTaskStk[TIMEDISPTASK_STK_SIZE],
                TIMEDISPTASK_PRIO);
    (void)OSTaskCreate(TransmitTask,         /* Create UITask   */
                (void *)0,
                (void *)&TransmitTaskStk[TRANSMITTASK_STK_SIZE],
                TRANSMIT_PRIO);
    (void)OSTaskCreate(ReceiveTask,         /* Create UITask   */
                (void *)0,
                (void *)&ReceiveTaskStk[RECEIVETASK_STK_SIZE],
               RECEIVE_PRIO);
         
    DBUG_PORT &= ~PP7;
    (void)OSTaskDel(STARTTASK_PRIO);
    
    FOREVER()
    {
    }
}
Пример #7
0
/**
 ******************************************************************************
 ** \brief  Main function of project for MB9B560 series.
 **
 ** \return uint32_t return value, if needed
 ******************************************************************************/
int32_t main(void)
{
#ifdef DEBUG_PRINT
    printf("==================================================\n");
    printf("          WFG Sample Start \n");
    printf(" WFG running with through mode\n");
    printf(" Connect P50 with key\n");
    printf(" please observe the RTO00_0 and RTO01_0 output by \n oscillograph\n");
    printf(".......\n");
#endif
    KeyInit();
    //init FRT
    InitFrt();
    //init OCU
    InitOcu();
    //init WFG
    InitWfg();

    //enable OCU operation
    Mft_Ocu_EnableOperation(&USER_OCU,USER_OCU_CH0);
    Mft_Ocu_EnableOperation(&USER_OCU,USER_OCU_CH1);

    //start FRT
    Mft_Frt_Start(&USER_FRT,USER_MFT_FRT_CH);

    
    while(1)
    {
        ;
    }
}
Пример #8
0
void init () {
	char *buf;

	buf = (char *) MemAlloc (2048);
	if (! CapInit (buf)) {
		outerr("cannot read termcap\n",0);
		exit (1);
	}
	if (! v.VInit ()) {
		outerr("cannot initialize terminal\n",0);
		exit (1);
	}
	if (COLS < 80) {
		outerr("must be 80 columns on terminal\n",0);
		exit (1);
	}
	KeyInit (keymap, VFlush);
	v.VOpen();
	MemFree ((mem *) buf);

	/* H is the number of lines at file window */

	H = LINES/2-1;

}
Пример #9
0
void EventInit(
	EventHandlers *handlers, Pic *mouseCursor, Pic *mouseTrail,
	const bool hideMouse)
{
	memset(handlers, 0, sizeof *handlers);
	KeyInit(&handlers->keyboard);
	JoyInit(&handlers->joysticks);
	MouseInit(&handlers->mouse, mouseCursor, mouseTrail, hideMouse);
}
Пример #10
0
void BspInit(void)
{
	AdcInit();
//	BeepInit();
	KeyInit();
	LedInit();
//	MotorInit();
	UartInit();	
//	InitEEPROM();
}
Пример #11
0
GLFWEngine::GLFWEngine(WindowSettings& w) : BasicEngine(new GLFWTimerProvider()),
	currentSettings(new WindowSettings()),
	Window(*currentSettings)
{
	if (!InitWindow(w))
		printf("Could not open window");

	KeyInit();
	MouseInit();
	InitListen();
}
Пример #12
0
Файл: key.c Проект: paud/d2x-xl
int KeyInKeyTime(fix * time)
{
	int key = 0;

	if (!Installed)
		KeyInit();
        event_poll();
	if (key_data.keytail!=key_data.keyhead)	{
		key = key_data.keybuffer[key_data.keyhead];
		*time = key_data.time_pressed[key_data.keyhead];
		key_data.keyhead = add_one(key_data.keyhead);
	}
	return key;
}
Пример #13
0
Файл: key.c Проект: paud/d2x-xl
int KeyInKey()
{
	int key = 0;
	if (!Installed)
		KeyInit();
        event_poll();
	if (key_data.keytail!=key_data.keyhead) {
		key = key_data.keybuffer[key_data.keyhead];
		key_data.keyhead = add_one(key_data.keyhead);
	}
//added 9/3/98 by Matt Mueller to D2_FREE cpu time instead of hogging during menus and such
//	else timer_delay(1);
//end addition - Matt Mueller
        return key;
}
Пример #14
0
void main(void) {
    
    OCDlyInit();
    ENABLE_INT();         /* Enable interrupts to use OCDelay()   */
    KeyInit();
    LcdInit();
    LcdClrDisp();	
    LcdMoveCursor(1,1);
    
    FOREVER(){
        WaitForSlice();
        KeyTask();
        DispKeyTask();
    }
}
Пример #15
0
Файл: init.c Проект: paud/d2x-xl
void arch_init()
{
 // Initialise the library
	arch_sdl_init();
#ifdef SVGALIB_INPUT
	arch_svgalib_init();
#endif
	//added 06/09/99 Matt Mueller - fix nonetwork compile
	//end addition -MM
//added on 10/19/98 by Victor Rachels to add serial support (from DPH)
    if(!(FindArg("-noserial")))
     com_init();
//end this section addition - Victor 
	//added 06/09/99 Matt Mueller - fix nonetwork compile
	//end addition -MM
    KeyInit();
}
Пример #16
0
//---------------------------------------------------------------------------
void SysInit(void)
{
	power_timer2_disable();
	power_adc_disable();
	power_twi_disable();
	power_usart0_disable();
	power_usart1_disable();

	OledInit();
	FrameInit();
	SndInit();
	EepInit();
	KeyInit();
	MathInit();
	RndInit();
	DebugInit();
}
Пример #17
0
static void DriverInit(void) {

    SysTimerInit();
    WT588DInit();
    LEDInit();
    if (1 == W25qFlashInit()) {
        while (1);
    }
    SysInfoInit();
    KeyInit();
    PirInit();
    DahuaInit();
    if (WIFI_RET_SUCCESS != WifiInit()) {
        SYSLOG("WIFI Work Failure\r\n");
        WifiResetModule();
        NVIC_SystemReset();
    }
    DOG_INIT();
    SysInfoCheckDevID(); 
    
}
Пример #18
0
int main(void)
{
	  SystemClock_HSI(9);    //系统时钟设置,9倍频,36M
    LedInit();						 //LED 初始化	
    Adc_Init();            //摇杆AD初始化
    NRF24L01_Init();       //无线模块初始化
		TX_Mode();						 //发送模式
    TIM4_Init();           //定时器初始化,定时周期为1ms,1ms发送一次摇杆AD值
    KeyInit();             //按键初始化
    TxBuf[30]=0xA5;        //对应遥控器,该位写0xA5,保证飞机能在开机的时候能收到一个完整的32字节的数据包
    GetAD(R_Mode);          
/*******************************************************/
//以下为遥控解锁段         
/*******************************************************/
     while((Throttle>5)||(Roll>5))//解锁条件:油门拉到最低,方向打到最左解锁
        {
          GetAD(R_Mode);//得到各路AD值并显示
        }
        TxBuf[28]=0;   //对应遥控器,该字节写0,使飞机跳过写参数那一步
        TxBuf[27]=0xA5;//解锁飞机
        TxBuf[31]=0xA5;//解锁成功,使能飞控
/*******************************************************/
//解锁完成
/*******************************************************/
    
   Led1=1;
   Led2=1;
   Led3=1;
   Led4=1;
   Led5=0;
  while(1)
		{  

      GetAD(R_Mode);                            //得到各路AD值并显示
      if(Key1==0){TxBuf[10]=0xA5;Led1=1; }//按键子程序,用于设置一键操作,如一键翻滚,一键返航等
      else {TxBuf[10]=0;Led1=0;}
		}
}
Пример #19
0
int KeyInKeyTime (fix * time)
{
    int key = 0;
    int bLegacy = gameOpts->legacy.bInput;

    gameOpts->legacy.bInput = 1;

    if (!bInstalled)
        KeyInit ();
    event_poll (SDL_KEYDOWNMASK | SDL_KEYUPMASK);
    if (keyData.nKeyTail != keyData.nKeyHead) {
        key = keyData.keyBuffer [keyData.nKeyHead];
        if (key == KEY_CTRLED + KEY_ALTED + KEY_ENTER)
            exit (0);
        keyData.nKeyHead = KeyAddKey(keyData.nKeyHead);
        if (time)
            *time = keyData.xTimePressed [keyData.nKeyHead];
    }
    else if (!time)
        G3_SLEEP (0);
    gameOpts->legacy.bInput = bLegacy;
    return key;
}
Пример #20
0
int PlayerSelection(int twoPlayers, void *bkg)
{
	int mode1, mode2;

	mode1 = MODE_MAIN;
	mode2 = twoPlayers ? MODE_MAIN : MODE_DONE;

	SetPlayer(0, &gPlayer1Data);
	SetPlayer(1, &gPlayer2Data);

	KeyInit(&gKeyboard);
	while (mode1 != MODE_DONE || mode2 != MODE_DONE)
	{
		int cmd1 = 0;
		int cmd2 = 0;
		InputPoll(&gJoysticks, &gKeyboard);
		memcpy(GetDstScreen(), bkg, GraphicsGetMemSize(&gGraphicsDevice.cachedConfig));
		GetPlayerCmd(&cmd1, &cmd2, 1);

		if (KeyIsPressed(&gKeyboard, keyEsc)) return 0; // hack to allow exit

		if (twoPlayers)
		{
			mode1 = MakeSelection(mode1, CenterOfLeft(50), CHARACTER_PLAYER1, &gPlayer1Data, cmd1);
			mode2 = MakeSelection(mode2, CenterOfRight(50), CHARACTER_PLAYER2, &gPlayer2Data, cmd2);
		}
		else
		{
			mode1 = MakeSelection(mode1, CenterX(50), CHARACTER_PLAYER1, &gPlayer1Data, cmd1);
		}

		CopyToScreen();
		SDL_Delay(10);
	}

	return 1;
}
Пример #21
0
void KeyFlush (void)
{
    int i;

    if (!bInstalled)
        KeyInit();
    keyData.nKeyHead = keyData.nKeyTail = 0;
// clear the tKeyboard buffer
    for (i = 0; i < KEY_BUFFER_SIZE; i++) {
        keyData.keyBuffer [i] = 0;
        keyData.xTimePressed [i] = 0;
    }
    int curtime = TimerGetFixedSeconds ();
    for (i = 0; i < 256; i++) {
        gameStates.input.keys.pressed [i] = 0;
        keyData.keys [i].state = 1;
        keyData.keys [i].lastState = 0;
        keyData.keys [i].timeWentDown = curtime;
        keyData.keys [i].downCount = 0;
        keyData.keys [i].upCount = 0;
        keyData.keys [i].timeHeldDown = 0;
        keyData.keys [i].counter = 0;
    }
}
Пример #22
0
// @breif Copy and initialize FIRM
void PrepareFirmLaunch(void)
{
	DrawDebug(0, 1, "Preparing for firmlaunch");
	DrawDebug(0, 1, "");
	uint32_t magic = 0x4D524946;
	size_t bytesRead;
	if (key7Xneeded)
		Key7X();
	FSFileOpen("/3ds/PastaCFW/firm.bin");
	bytesRead = FSFileRead(&firm, 0x200, 0);
	if (bytesRead != 0x200)
		error();
	if (firm.magic != magic)
		error();
	FSFileRead(firm.sect[0].p, firm.sect[0].size, firm.sect[0].offset);
	FSFileRead(firm.sect[1].p, firm.sect[1].size, firm.sect[1].offset);
	FSFileRead(firm.sect[2].p, firm.sect[2].size, firm.sect[2].offset);
	if (cfw_FWValue == 'd')
	{
		u8 key[16] = { 0 };
		FSFileRead(&key, 0x10, (firm.sect[2].offset + 0x60));
		KeyInit(key);
	}
}
Пример #23
0
/*********************************************************** 
函数功能:上电模式初始化
入口参数:
出口参数:
备注说明:1 市电上电时调用
          2 调用每个模块初始化函数,初始化函数包括所有的硬件初始化、数据初始化、任务初始化
***********************************************************/
uint16 PowerUpInit(void)
{
	DRV_WD_FeedDog();		//喂狗
	//切换到高速时钟
    SwitchToMainPLL(CLOCK_SUB_OSC_ON,BaseSysetmClockDIV1,PLLMultiplier2);
    DRV_RTC_CalcSecDeviation();           //上电马上进行补偿
	/*设置中断优先级*/
	Config_SystemClock_Priority();
    LvdOpen();		//打开LVD
    EXTI_DisableInt(EXTI_CH1);
	if(PowerDownDetect() != 0)
	{
		return 0;
	}
	/*初始化主任务*/
	TaskInit(SYS_TICK_LOW, SYS_TICK_HIGH);	//只初始化,不启动		
	/*初始化驱动模块*/
	DRV_IO_Init();
	Drv_Calibrate_Init();
	DRV_Calibrate_PRO_SWI_INIT();			//used for calibrate
	IIcInit();	
	//MX25L3206_IOInt();
	KeyInit();
	DRV_ADC_Init(1);
    DRV_ADC_On();
//	DRV_RTC_CalcSecDeviation();
    DRV_RTC_Init();  		//rtc初始化
    InitCaliVal();      	//RTC温补
    DRV_RTCSecPulseInit();  //rtc秒脉冲初始化
	DRV_LCD_Init(0);
	DRV_LCD_FillAll();
	LEDInit();
	ProtocolManageInit();	//通讯串口打开
	//RF 初始化
	RFModeChangeInit();     //RF切换模块
	RFIOPowerUpInit();
    
	if(0 == DRV_EMU_PowerUpInit())//used for EMU,load cailibrate data
	{
		return POWER_UP_INIT_FAIL;
	}
	//初始化应用模块
	ClockPowerUpInit();
//	if(POWER_UP_INIT_FAIL == TariffInit())
//	{
//		return POWER_UP_INIT_FAIL;
//	}
	//DRV_WD_FeedDog();		//?11·
	//DemandDataClear();
	//DemandInit();
	if(POWER_UP_INIT_FAIL == EnergyDataInit())
	{
		return POWER_UP_INIT_FAIL;
	}
	DRV_WD_FeedDog();		//?11·
	if(POWER_UP_INIT_FAIL == BillingPowerUpInit())
	{
		return POWER_UP_INIT_FAIL;
	}
	DRV_WD_FeedDog();		//?11·
//	if(POWER_UP_INIT_FAIL == LoadProfilePowerUpInit())
//	{
//		return POWER_UP_INIT_FAIL;
//	}
	if(POWER_UP_INIT_FAIL == FreezeInit())
	{
		return POWER_UP_INIT_FAIL;
	}
	DRV_WD_FeedDog();		//?11·
	if(POWER_UP_INIT_FAIL == EventPowerUpInit())
	{
		return POWER_UP_INIT_FAIL;
	}
	MeterInfoPowerUpInit();
	//DLMS_AA_Init();
	//------end----------
   //==============================================================
	Init_Disp();
   //==============================================================
    MeterPowerUPClearAll();         //全清,生产用
	//任务起动
   	MFT_FRTStart(MFT_UNIT0, FRT_CH2);
	TaskStart();
	//RF1MSStart();
	return POWER_UP_INIT_SUCESS;
}
Пример #24
0
/********************************************************************
函数功能:主函数。
入口参数:无。
返    回:无。
备    注:无。
********************************************************************/
void main(void)
{
#ifdef DEBUG0
 int i;
#endif

 int InterruptSource;
 
 SystemClockInit(); //系统时钟初始化
 LedInit();         //LED对应的管脚初始化
 LcdInit();         //LCD初始化
 AdcInit();         //ADC初始化
 Timer1Init();      //定时器1初始化,用来产生10ms的定时扫描信号
 KeyInit();         //键盘初始化
 Uart0Init();       //串口0初始化

#ifdef DEBUG0
 for(i=0;i<16;i++)   //显示头信息
 {
  Prints(HeadTable[i]);
 }
#endif

 UsbChipInit();  //初始化USB部分
 
 while(1)
 {
  InterruptSource=(*AT91C_UDP_ISR)&(0x0F|(1<<8)|(1<<12)); //取出需要的中断
  if(InterruptSource) //如果监视的中断发生
  {
   if(InterruptSource&(1<<8))
   {
    *AT91C_UDP_ICR=1<<8; //清除中断
    UsbBusSuspend(); //总线挂起中断处理
   }
   if(InterruptSource&(1<<12))
   {
    *AT91C_UDP_ICR=1<<12; //清除中断
    UsbBusReset();   //总线复位中断处理
   }
   if(InterruptSource&(1<<0))
   {
    if(AT91C_UDP_CSR[0]&((1<<1)|(1<<2)|(1<<6)))  //如果是SETUP包、缓冲未空等
    {
     UsbEp0Out();     //端点0输出中断处理
    }
    if(AT91C_UDP_CSR[0]&(1<<0)) //如果是端点0输入完成
    {
     UsbEp0In();     //端点0输入中断处理
    }
   }
   if(InterruptSource&(1<<1))
   {
    UsbEp1In();      //端点1输入中断处理
   }
   if(InterruptSource&(1<<2))
   {
    UsbEp2Out();     //端点2输出中断处理
   }
   if(InterruptSource&(1<<3))
   {
    UsbEp3In();     //端点3输入中断处理
   }
  }
  if(KeyUp||KeyDown)  //如果用户操作了按键
  {
   DispKey(); //在LCD上显示按键情况
   if(ConfigValue!=0) //如果已经设置为非0的配置,则可以返回报告数据
   {
    if(!Ep1InIsBusy)  //如果端点1输入没有处于忙状态,则可以发送数据
    {
     KeyCanChange=0;  //禁止按键扫描
     if(KeyUp||KeyDown) //如果有按键事件发生
     {
      SendReport();  //则返回报告
     }
     KeyCanChange=1;  //允许按键扫描
    }
   }
   //清除KeyUp和KeyDown
   KeyUp=0;
   KeyDown=0;
   LcdRefresh();  //刷新LCD显示
  }
 }
}
Пример #25
0
int main(void)
{
	int nCounter = 0; //給Beep Loop用的Counter
	
	//初始化參數
	u8gLCD_BOOT = 1;
	u32NeedWriteFlash = 0;
	u32ADC = POWER_LOWEST_ADC + 100; //檢查電源用的參數,電不夠時把馬達動作變小。
	u8MotorSuspended = 0; //看看馬達是不是在暫停狀態
	
	//正式程式碼,開始初始化動作。
	
	SysCLK_config_clock_select(0);   // 配置時鐘
	EL_Init();

	ADC_Init();
	//讀取CPU ID
	u32IAP_ReadUID(uid);
	sn = uid[0] + uid[1] +uid[2] +uid[3];

	//讀取記憶的速度
	memset(BufferFlash, 0x0, IAP_FLASH_PAGE_SIZE_BYTES);
	u32IAP_ReadUserDataFlash(BufferFlash, IAP_FLASH_PAGE_SIZE_BYTES);
	memcpy(BackupBuffer, BufferFlash,IAP_FLASH_PAGE_SIZE_BYTES);
	
	BeeperInit();

	HallInit();
	KeyInit();
	
	PWMInit(); // For motor control voltage.
 	WDT_Enable(); //Enable the watch dog.
	
	InitialTimeTick(TIME_TICK_NUMBER); 
	while(u8gLCD_BOOT != 0);
	//time tic 開始後就會叫callback, 此時LCD及Beeper,KeyBounce要初始完成。

	u32ADC = ADC_Read();

	
	if(u32ADC > POWER_LOWEST_ADC && u32ADC != 0)
	{
		LCD_Init(); // LCD update
		for(nCounter = 0 ; nCounter < 2; nCounter++)
		{
			BeepMillisecondsAndWait(500); 
			WDTFeed();
		}
	}
	else
	{
		//如果一開始就電量不足,在閃一下後,就離開,等下次初始化。
		EL_OnOff();
		delay_us(1000);
		EL_OnOff();
		delay_us(1000);
		return 0;  
	}

	StatusInit();

	nCounter = 0;

	while(sn % 1000 != UID)
	{
#ifndef PROGRAMING
		BeepMillisecondsAndWait(500); 
#endif
		WDTFeed();
	}
	
	if( !(GPIO2->DATA & (1 << 1)) && !(GPIO0->DATA & (1 << 5)))
	{
		while(1)
		{
			WDTFeed();// Feed Dog.
		}
	}
	
	while(1)
	{
 		WDTFeed();// Feed Dog.
		u32ADC = ADC_Read();
		PWM_CheckSuspend(u32ADC);
		
 		WDTFeed();// Feed Dog.

		ProcessHall();
 		Status_ProcessKey(GetKey());
		WriteFlash();
	}
}
Пример #26
0
static int InitializePoll (CMenu& menu, int& key, int nCurItem, int nState)
{
if (nState)
	return nCurItem;

paletteManager.LoadEffect ();
switch (loadOp) {
	case 0:
		/*---*/PrintLog ("Creating default tracker list\n");
		tracker.CreateList ();
		break;
	case 1:
		/*---*/PrintLog ("Loading ban list\n");
		banList.Load ();
		break;
	case 2:
		/*---*/PrintLog ("Initializing control types\n");
		SetControlType ();
		break;
	case 3:
		/*---*/PrintLog ("Initializing keyboard\n");
		KeyInit ();
		break;
	case 4:
		/*---*/PrintLog ("Initializing joystick\n");
		DoJoystickInit ();
		break;
	case 5:
		int i;
		if ((i = FindArg ("-xcontrol")) > 0)
			externalControls.Init (strtol (pszArgList [i+1], NULL, 0), strtol (pszArgList [i+2], NULL, 0));
		break;
	case 6:
		/*---*/PrintLog ("Initializing movies\n");
		if (FindArg ("-nohires") || FindArg ("-nohighres") || !GrVideoModeOK (MENU_HIRES_MODE))
			gameOpts->movies.bHires = 
			gameStates.menus.bHires = 
			gameStates.menus.bHiresAvailable = 0;
		else
			gameStates.menus.bHires = gameStates.menus.bHiresAvailable = 1;
		movieManager.InitLibs ();		//init movie libraries
		break;
	case 7:
		BMInit ();
		break;
	case 8:
		/*---*/PrintLog ("Initializing sound\n");
		audio.Setup (1);
		break;
	case 9:
		/*---*/PrintLog ("Loading hoard data\n");
		LoadHoardData ();
		break;
	case 10:
		error_init (ShowInGameWarning, NULL);
		break;
	case 11:
		break;
		g3_init ();
	case 12:
		/*---*/PrintLog ("Initializing texture merge buffer\n");
		TexMergeInit (100); // 100 cache bitmaps
		break;
	case 13:
		InitPowerupTables ();
		break;
	case 14:
		LoadGameBackground ();
		atexit (CloseGame);
		break;
	case 15:
		InitThreads ();
		break;
	case 16:
		PiggyInitMemory ();
		break;
	case 17:
		if (!FindArg ("-nomouse"))
			MouseInit ();
		break;
	case 18:
		/*---*/PrintLog ("Enabling TrackIR support\n");
		TIRLoad ();
		break;
	}
loadOp++;
if (gameStates.app.bProgressBars && gameOpts->menus.nStyle) {
	if (loadOp == InitGaugeSize ())
		key = -2;
	else {
		menu [0].m_value++;
		menu [0].m_bRebuild = 1;
		key = 0;
		}
	}
paletteManager.LoadEffect ();
return nCurItem;
}
Пример #27
0
int PlayerSelection(int numPlayers, GraphicsDevice *graphics)
{
	int i;
	int hasInputDevice[MAX_PLAYERS];
	PlayerSelectMenu menus[MAX_PLAYERS];
	for (i = 0; i < numPlayers; i++)
	{
		PlayerSelectMenusCreate(
			&menus[i], numPlayers, i,
			&gCampaign.Setting.characters.players[i], &gPlayerDatas[i],
			&gInputDevices, graphics, &gConfig.Input);
		hasInputDevice[i] = 0;
	}

	KeyInit(&gInputDevices.keyboard);
	for (;;)
	{
		int cmds[MAX_PLAYERS];
		int isDone = 1;
		InputPoll(&gInputDevices, SDL_GetTicks());
		if (KeyIsPressed(&gInputDevices.keyboard, SDLK_ESCAPE))
		{
			// TODO: destroy menus
			return 0; // hack to allow exit
		}
		GetPlayerCmds(&cmds, gPlayerDatas);
		for (i = 0; i < numPlayers; i++)
		{
			if (hasInputDevice[i] && !MenuIsExit(&menus[i].ms))
			{
				MenuProcessCmd(&menus[i].ms, cmds[i]);
			}
		}
		for (i = 0; i < numPlayers; i++)
		{
			if (!MenuIsExit(&menus[i].ms))
			{
				isDone = 0;
			}
		}
		if (isDone)
		{
			break;
		}

		AssignPlayerInputDevices(
			hasInputDevice, numPlayers,
			gPlayerDatas, &gInputDevices, &gConfig.Input);

		GraphicsBlitBkg(graphics);
		for (i = 0; i < numPlayers; i++)
		{
			if (hasInputDevice[i])
			{
				MenuDisplay(&menus[i].ms);
			}
			else
			{
				Vec2i center;
				const char *prompt = "Press Fire to join...";
				Vec2i offset = Vec2iScaleDiv(TextGetSize(prompt), -2);
				int w = graphics->cachedConfig.ResolutionWidth;
				int h = graphics->cachedConfig.ResolutionHeight;
				switch (numPlayers)
				{
				case 1:
					// Center of screen
					center = Vec2iNew(w / 2, h / 2);
					break;
				case 2:
					// Side by side
					center = Vec2iNew(i * w / 2 + w / 4, h / 2);
					break;
				case 3:
				case 4:
					// Four corners
					center = Vec2iNew(
						(i & 1) * w / 2 + w / 4, (i / 2) * h / 2 + h / 4);
					break;
				default:
					assert(0 && "not implemented");
					break;
				}
				DrawTextString(prompt, graphics, Vec2iAdd(center, offset));
			}
		}
		BlitFlip(graphics, &gConfig.Graphics);
		SDL_Delay(10);
	}

	for (i = 0; i < numPlayers; i++)
	{
		MenuSystemTerminate(&menus[i].ms);
	}
	return 1;
}
Пример #28
0
/*********************************************************************************************************
** Function name:           taskStart	   
** Descriptions:            Start task	
** input parameters:        *parg
** output parameters:       ?      
** Returned value:          ? 
*********************************************************************************************************/
static void TaskStart (void  *parg)
{

		INT8U err;
		UserRS485Send ussend;
	
    (void)parg;


	
    #if OS_TASK_STAT_EN > 0
    OSStatInit();                                                       /*  Enable statistics           */
    #endif
	
		/* Init the file system */
	
	optionSaveStruct.masterIP[1]=0xaa;
	
	EEPROM_WriteStruct(optionSaveStruct);
	
    yaffs_start_up();	
		File_Init();
		
		KeyInit();
   	KeyQueueHead=OSQCreate(KeyMsg,KEYQSIZE);		//创建按键消息队列 在优先级较高的任务中执行
		
		ConfigQueueHead = OSQCreate( ConfigMsg, CONFIGQSIZE );
		UploadQueueHead = OSQCreate( UploadMsg, UPLOADQSIZE );
	
		EquipmentTaskSem = OSSemCreate(0);
		UartRcvTaskSem   = OSSemCreate(1);
		sem_tcp_init_done = OSSemCreate(0);
		UartSendTaskSem = OSSemCreate(1);
		
		tcpip_init(tcpip_init_done, NULL);
    OSSemPend(sem_tcp_init_done, 0, &err);

    eth_netif_init(ipConfig);
		
		TCPTest();
 
    err = OSTaskCreate((void (*)(void *)) Equipment_Task,				
                          (void          * ) 0,							
                          (OS_STK        * )&TaskEquipmentStk[TASK_KEY_STK_SIZE - 1],		
                          (INT8U           ) TASK_EQUIPMENT_PRIO  );  				/*	Create Equipment Task */
		
		//printf("Equipment_Task: err = %d\n", err );
	
		err = OSTaskCreate((void (*)(void *)) UartRcv_Task,				
                          (void          * ) 0,							
                          (OS_STK        * )&TaskUartRcvStk[TASK_KEY_STK_SIZE - 1],		
                          (INT8U           ) TASK_UART_RCV_PRIO  );  				  /*	Create Equipment Task */
													
		//printf("UartRcv_Task: err = %d\n", err );
													
		err = OSTaskCreate((void (*)(void *)) FileReceive_Task,				
                          (void          * ) 0,							
                          (OS_STK        * )&TaskFileRcvStk[TASK_FILERCV_STK_SIZE - 1],		
                          (INT8U           ) TASK_FILE_RCV_PRIO  );  			  	/*	Create FileReceive Task */
		
		//printf("FileReceive_Task: err = %d\n", err );
				
		err = OSTaskCreate((void (*)(void *)) hvsftpd_main,				
                          (void          * ) 0,							
                          (OS_STK        * )&TaskFtpStk[TASK_FTP_STK_SIZE - 1],		
                          (INT8U           ) TASK_FTP_PRIO  );  			  	/*	Create FileReceive Task */
		
		printf(" hvsftpd_Task: err = %d\n", err );
													
	
		err = OSTaskCreate ((void (*)(void	*))Menu_Task, 
						   (void 	*)0,   
						   (OS_STK	*)&Gstk2[MENU_TASK_STK_SIZE-1],
						   (INT8U	 )MENU_TASK_PRIO  	);                           /*  Create Menu Task     */ 	
							 
/*		err = OSTaskCreate ((void (*)(void	*))Test_Key, 
						   (void 	*)0,   
						   (OS_STK	*)&TestStk[511],
						   (INT8U	 )44  	);                           /  Create Menu Task     */ 	
			
		App_KeyTaskCreate();						  /* Create Task Key */

#if	FRMB_DEBUG
		ussend.address=0x00;
		ussend.ctrl=0x01;
		ussend.data[0]=0xaa;
		ussend .len=1;
		ussend.CRCH=0x00;
		ussend.CRCL=0x11;
#else

//		err=OSTaskCreate((void (*)(void *))FMB_Task,
//											(void *)0,
//											(OS_STK *)&FMBStk[FMB_TASK_STK_SIZE-1],
//											(INT8U )FMB_TASK_PRIO	);
//											
//		err=OSTaskCreate((void (*)(void *))FMB_Poll_Task,
//											(void *)0,
//											(OS_STK *)&FMBPollStk[FMB_TASK_STK_SIZE-1],
//											(INT8U )FMB_POLL_TASK_PRIO	);									
											
		
		
	
#endif

		while (1) 
		{
#if	FRMB_DEBUG
			RS485Send_Struct(RS485_UART0,&ussend);
			RS485Send_Struct(RS485_UART2,&ussend);
			RS485Send_Struct(RS485_UART3,&ussend);
			RS485Send_Struct(RS485_UART4,&ussend);
#else			
 			
			
			
#endif
			//OSTimeDly(500);		
			OSTaskSuspend(OS_PRIO_SELF);                                    /*  The start task can be pended*/
                                                                        /*  here. ??????????  */			
		}
}
Пример #29
0
Файл: wgl.c Проект: paud/d2x-xl
void win32_create_window(int x,int y)
{
	int flags;

	WNDCLASS wcDescentClass;

	if (!hInst)
		Error("hInst=NULL\n");


	wcDescentClass.lpszClassName = "WinD1X";
	wcDescentClass.hInstance     = hInst;
	wcDescentClass.lpfnWndProc   = DescentWndProc;
	wcDescentClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
	//wcDescentClass.hIcon         = LoadIcon(NULL, IDI_WINLOGO);
	wcDescentClass.hIcon         = LoadIcon(hInst, MAKEINTRESOURCE(IDI_MAIN_ICON);
	wcDescentClass.lpszMenuName  = NULL;
	wcDescentClass.hbrBackground = NULL;
	wcDescentClass.style         = CS_OWNDC;
	wcDescentClass.cbClsExtra    = 0;
	wcDescentClass.cbWndExtra    = 0;
	
	// Register the class
	if (!RegisterClass(&wcDescentClass)){
//		//printf("RegisterClass==0?\n");
		//always seems to return 0 after the first time, yet if you remove the call, it crashes. Heh.
	}

	if (gameStates.ogl.bFullScreen)
		flags=WS_POPUP;//uh.. don't remember if removing sysmenu did anything or not.. but it works.
		//flags=WS_POPUP | WS_SYSMENU;
	else
		flags=WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;//let us minimize it.
		//flags=WS_OVERLAPPED | WS_BORDER | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;

	if (!gameStates.ogl.bFullScreen){
		x+=get_win_x_bs();y+=get_win_y_bs();
	}else{
		if (FindArg("-gl_test2")){
			x=GetSystemMetrics(SM_CXSCREEN);
			y=GetSystemMetrics(SM_CYSCREEN);
		}
	}
	g_hWnd = CreateWindowEx(0,
			"WinD1X",
			"Descent",
			flags,
			0, 0,
			x,y,
			NULL,
			NULL,
			hInst,
			NULL
						   );

	if (!g_hWnd) Error("no window?\n");
	ShowWindow(g_hWnd,SW_SHOWNORMAL);
	UpdateWindow(g_hWnd);

	OpenGL_Initialize();

	if (gameStates.ogl.bFullScreen){
        ShowCursor(FALSE);
        mouse_hidden = 1;
	}

	KeyInit();
	MouseInit(0);
	joy_init(JOYSTICKID1);
	if (!FindArg( "-nosound" ))
		DigiInit();
	gameStates.ogl.bInitialized=1;
}
Пример #30
0
int main(void)
{
	static char ledsta;
	/***********************************/
	SystemClock_HSI(9);           //系统时钟初始化,时钟源内部HSI
	cycleCounterInit();				    // Init cycle counter
	SysTick_Config(SystemCoreClock / 1000);	//SysTick开启系统tick定时器并初始化其中断,1ms
	UART1_init(SysClock,uart1baudSet); //串口1初始化
  NVIC_INIT();	                //中断初始化
  STMFLASH_Unlock();            //内部flash解锁
  LoadParamsFromEEPROM();				//加载系统参数配置表
  LedInit();	                  //IO初始化
  Adc_Init();										//摇杆AD初始化
	KeyInit();										//按键初始化
 	NRF24L01_INIT();              //NRF24L01初始化
  SetTX_Mode();                 //设无线模块为接收模式
  controlClibra();							//遥控摇杆校准
#ifdef UART_DEBUG  
	TIM3_Init(SysClock,2000);			//定时器初始化,1s为周期打印摇杆值
#endif
	TIM4_Init(SysClock,TIME4_Preiod);	  //定时器4初始化,定时时间单位:(TIME4_Preiod)微秒
	
	LedSet(led2,1);
	LedSet(led3,1);
	
	LoadRCdata();                //摇杆赋值
	//RockerUnlockcrazepony();	 //摆杆启动
  Lockflag = 0;								 //解锁标志,1表示产生了一次按键操作,0表示该按键操作已经发送到飞控
	
  LedSet(led2,0);
	LedSet(led3,0);
	 
  while (1)             
	{ 
		//10Hz loop
		if(flag10Hz == 1)  //10Hz 
		{		
			flag10Hz = 0;
			/*status led*/
			ledsta = !ledsta;
			LedSet(signalLED,ledsta);				        
			/*crazepony Lock*/
			KeyLockcrazepony();
			/*IMUcalibrate  */
			IMUcalibrate();
			/*remote calibrate*/
			Remotecalibrate();
		}

		//50Hz loop
		if(flag50Hz == 1)
		{
			LoadRCdata();
			flag50Hz = 0;
			
		}
		
		// 80Hz 12.5ms
		if(flag80Hz)
		{
			flag80Hz = 0;
			CommUAVUpload(MSP_SET_4CON);   
		}
	}
}