void main(void) { _U08 key; System_EnablePLL(); /*Elevamos la frecuencia de operacion a 48MHz*/ ANCON0 = 0XFF; /*Desativamos las salidas analogicas*/ ANCON1 = 0XFF; /*Desativamos las salidas analogicas*/ Timers_Init(); /*inicializamos el driver para genere una interrupcion cada 5ms*/ Timers_SetTime(0, 10/timers_ms); /*recargamos el canal 0 con un valor de 10ms*/ Keyboard_Init(); /*Inicilizamos las entradas y salidas del teclado*/ Gpios_WriteTris(GPIOS_PORTB, 0x00); /*puerto B como salida*/ Gpios_WritePort(GPIOS_PORTB, 0x00); /*limpiamos el puerto*/ Keyboard_SetDebounce(0, 50); /*500ms de debouncea a la tecla 0*/ Keyboard_SetDebounce(4, 50); /*500ms de debounce a la tecla 4*/ Keyboard_SetDebounce(8, 50); /*500ms de debounce a la tecla 8*/ Keyboard_SetDebounce(12, 50); /*500ms de debounce a la tecla 12*/ __ENABLE_INTERRUPTS(); /*se habilitan las interrupciones globales con prioridad*/ while (1) { if(Timers_u16GetTime(0) == 0) /*preguntamos si la interrupcion decrmento hasta llegar a 0 el canal 0*/ { Timers_SetTime(0, 10/timers_ms);/*se cumplen los 100ms asi que volvemos a recargar el mismo canal */ Keyboard_Task(); /*poleamos poleamos el teclado matrizial*/ } if(Keyboard_bIsPressed() == _TRUE) /*preguntamos si se presiono alguna tecla*/ { key = Keyboard_u8GetKey(); /*obtenemos cual tecla se presiono*/ Gpios_WritePort(GPIOS_PORTB, key); /*despliego el valor de la tecla en el puerto B*/ } } }
void Menu_Init(void) { Disp_Init(); //display init Port_Init(); //port init Keyboard_Init(); //keyboard init #ifdef LCD1602 Meter_Init(); //level meter init #endif if(ESignature != SIGNATURE) //check EEPROM signature, if error, init params: { for(char i = 0; i < PARAMS; i++) Par[i] = ParLim[i][P_NOM]; ParToEEPROM(); //params init for(char i = 0; i < MODES; i++) EScale[i] = SCALE_NOM + AUTO_SCALE; //scales init } else { for(char i = 0; i < PARAMS; i++) Par[i] = EPar[i]; //read params from EEPROM } SetupCounter(); Count_Start(); //start counter DispMenu = MNU_NO; //no menu Hold = 0; //no hold mode Hide = 0; //display not hided Menu = MNU_SPLASH; //go to splash screen menu }
SimpleDriver::SimpleDriver(Controller* cntrl, string logfile) { this->automatedControl = cntrl; this->logfile = logfile; if (automatedControl == NULL) { Keyboard_Init(); this->log = new vector<pair<CarState, CarControl> >; } }
int main(void) { LED_Init(LED_2 | LED_3); Beep_Init(); SysTick_Init(1, SYSTICK_MS); LED_On(LED_2 | LED_3); Usart_Init(); //Beep_On(); SysTick_Delay(200, SYSTICK_MS); //Beep_Off(); LED_Off(LED_2 | LED_3); Key_Init(KEY_S1 | KEY_S2 | KEY_S3 | KEY_S4); Keyboard_Init(); //LCD_Init(); ADS1118_Init(); while(1) { printf("准备完毕 开始转换!\n"); ADS1118_CS_Reset(); while(!GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_6)); ConversionValue = ADS1118_Read(count);//8283 ADS1118_CS_Set(); printf(" The Value is 0X%08x ,%08d\n",ConversionValue,ConversionValue); ad= ConversionValue*4.096/32768; printf("AD=%fV\n",ad); SysTick_Delay(1000, SYSTICK_MS); // Keyboard_Loop(); // //LCD_Clear(Color_White); // //LCD_Set_ForeColor(Color_Red); // //if(Keyboard_Scan() == KEYBOARD_S1) { LCD_Show_String(30,50,200,16,16, "Key Board Test"); } // if(Keyboard_Detect(KEYBOARD_S1, KEYBOARD_DOWN)) { printf("S1\r\n"); } // if(Keyboard_Detect(KEYBOARD_S2, KEYBOARD_DOWN)) { printf("S2\r\n"); } // if(Keyboard_Detect(KEYBOARD_S3, KEYBOARD_DOWN)) { printf("S3\r\n"); } // if(Keyboard_Detect(KEYBOARD_S4, KEYBOARD_DOWN)) { printf("S4\r\n"); } // if(Keyboard_Detect(KEYBOARD_S5, KEYBOARD_DOWN)) { printf("S5\r\n"); } // if(Keyboard_Detect(KEYBOARD_S6, KEYBOARD_DOWN)) { printf("S6\r\n"); } // if(Keyboard_Detect(KEYBOARD_S7, KEYBOARD_DOWN)) { printf("S7\r\n"); } // if(Keyboard_Detect(KEYBOARD_S8, KEYBOARD_DOWN)) { printf("S8\r\n"); } // if(Keyboard_Detect(KEYBOARD_S9, KEYBOARD_DOWN)) { printf("S9\r\n"); } // if(Keyboard_Detect(KEYBOARD_S10, KEYBOARD_DOWN)) { printf("S10\r\n"); } // if(Keyboard_Detect(KEYBOARD_S11, KEYBOARD_DOWN)) { printf("S11\r\n"); } // if(Keyboard_Detect(KEYBOARD_S12, KEYBOARD_DOWN)) { printf("S12\r\n"); } // if(Keyboard_Detect(KEYBOARD_S13, KEYBOARD_DOWN)) { printf("S13\r\n"); } // if(Keyboard_Detect(KEYBOARD_S14, KEYBOARD_DOWN)) { printf("S14\r\n"); } // if(Keyboard_Detect(KEYBOARD_S15, KEYBOARD_DOWN)) { printf("S15\r\n"); } // if(Keyboard_Detect(KEYBOARD_S16, KEYBOARD_DOWN)) { printf("S16\r\n"); } // //LCD_Set_ForeColor(Color_Green); // //LCD_Show_String(30,70,200,16,16, "TFT-LCD test"); // //LCD_Set_ForeColor(Color_Blue); // //LCD_Show_String(30,90,200,16,16, "www.doflye.net"); // //LCD_Draw_Circle(100,180,20); // //SysTick_Delay(1000, SYSTICK_MS); } }
/** * Inicializa todos los componentes del juego y reserva la memoria necesaria **/ void Game_Init(TGAME * lsGame) { lsGame->mbFinish=false; lsGame->mfAcumulatedTime = 0.0f; Keyboard_Init(&(lsGame->mKeyboard)); GraphicManager_Init(&(lsGame->mGraphic)); if (!Scene_Init(&(lsGame->mScene),&(lsGame->mGraphic),kiFIRST_LEVEL)) lsGame->mbFinish=true; }
/* 配置系统的顺序 CPU 内部、底层硬件 外部接口 外部硬件(按键、显示) 读取外部配置数据 传感器系统(RTC 时钟) 操作系统 任务 驻留任务(如:传感器读取、恒温箱温控、掉电时间记录) 采样任务 监控任务 */ __task int32_t main( void ) { BIOS_Init(); beep(); RTOS_Init(); // 尽早执行 ConfigureLoad(); // 先确定仪器型号 CalibrateLoad(); // 读传感器前执行, 远程存储器中的参数,应等通讯初始化后再读。 SampleSetLoad(); // 恢复采样前执行 Display_Init(); DisplaySetGrayVolt( Configure.DisplayGray * 0.022f ); DisplaySetLight( Configure.DisplayLight ); DisplaySetTimeout( Configure.TimeoutLight ); Keyboard_Init(); // 配置完背光超时时间后再初始化 RTC_Init(); // 为避免启动过程中时钟失败造成的假死现象,放在显示初始化之后 SD_Init(); // SD卡读写初始化,放在开关机存取之前 PowerLog_Init(); // 开关机存取,时间初始化之后 SENSOR_Local_Init(); delay( 1000u ); //配合下位机初始化 <注意!要进行下位机测试来确定参数!>300 Animation(); // 开机动画 delay( 1600u ); ShowEdition(); // 确定型号之后,显示初始化之后 delay( 1400u ); SENSOR_Remote_Init(); // modbus通信初始化 delay( 100u ); HCBox_Init(); delay( 100u ); Sampler_BootResume(); // 时间配置完成之后,设置参数读入之后。 delay( 100u ); SamplerTypeSelect(); delay( 100u ); for(;;) { menu_Main(); // 转主菜单 } }
/* 配置系统的顺序 CPU 内部、底层硬件 外部接口 外部硬件(按键、显示) 读取外部配置数据 传感器系统(RTC 时钟) 操作系统 任务 驻留任务(如:传感器读取、恒温箱温控、掉电时间记录) 采样任务 监控任务 */ __task int32_t main( void ) { BIOS_Init(); beep(); RTOS_Init(); // 尽早执行 EditionSelsct(); ConfigureLoad(); // 先确定仪器型号 CalibrateLoad(); // 读传感器前执行, 远程存储器中的参数,应等通讯初始化后再读。 SampleSetLoad(); // 恢复采样前执行 Display_Init(); DisplaySetGrayVolt( Configure.DisplayGray * 0.01f ); DisplaySetLight( Configure.DisplayLight ); DisplaySetTimeout( Configure.TimeoutLight ); Keyboard_Init(); // 配置完背光超时时间后再初始化。 ShowEdition(); // 版本显示 确定型号之后,显示初始化之后 SENSOR_Local_Init(); // 本地传感器读取以及液晶灰度调节 RTC_Init(); // 为避免启动过程中时钟失败造成的假死现象,放在显示初始化之后 SD_Init(); // SD卡读写初始化,放在开关机存取之前 delay( 500u ); PowerLog_Init(); // 开关机存取,时间和SD卡初始化之后 delay( 2000u ); // 配合下位机初始化 SENSOR_Remote_Init(); // modbus通信初始化 HCBox_Init(); delay( 500u ); Sampler_BootResume(); // 时间配置完成之后,设置参数读入之后。 delay( 1500u ); SamplerSelect = Q_ALL; // 初始化当前采样器为不合理的值,进行一次切换,切换到第一个合理的值。 SamplerTypeSwitch(); for(;;) { menu_Main(); // 转主菜单 } }
int main() { cpuSetup(); #if USE_DEBUG_PIN GpioPin_ConfigureOut(&DEBUG_PIN, 0); #endif SettingsStore_Init(); // intiailize sub-modules MIDI_Init(); Panel_Init(); // FIXME: panel must be configured first at the moment, // as LPC1343CodeBase SPI driver reconfigures PIO0.2 Keyboard_Init(); // enable TMR16B0 clock SCB_SYSAHBCLKCTRL |= SCB_SYSAHBCLKCTRL_CT16B0; // configure TMR16B0 to kick at 10kHz TMR_TMR16B0MR0 = TIMER16_CCLK_100US; TMR_TMR16B0MCR = TMR_TMR16B0MCR_MR0_INT_ENABLED | TMR_TMR16B0MCR_MR0_RESET_ENABLED; // Enable the TIMER0 interrupt, end eventually enable the timer itself NVIC_EnableIRQ(TIMER_16_0_IRQn); TMR_TMR16B0TCR = TMR_TMR16B0TCR_COUNTERENABLE_ENABLED; // keyboard and panel handling is performed in the timer interrupt context // all we need to do in the main code is to send any pendind MIDI data // and go to sleep until next interrupt while (1) { MIDI_SendQueued(); // Wait For Interrupt __asm volatile ("wfi"); } return 0; }
int main(void) { SVGA3DUtil_InitFullscreen(CID, 800, 600); SVGA3DText_Init(); Keyboard_Init(); APM_Init(); vertexSid = SVGA3DUtil_DefineStaticBuffer(vertexData, sizeof vertexData); indexSid = SVGA3DUtil_DefineStaticBuffer(indexData, sizeof indexData); Matrix_Perspective(perspectiveMat, 45.0f, gSVGA.width / (float)gSVGA.height, 0.1f, 100.0f); while (!Keyboard_IsKeyPressed(KEY_ESCAPE)) { if (SVGA3DUtil_UpdateFPSCounter(&gFPS)) { Console_Clear(); Console_Format("VMware SVGA3D Example:\n" "Spinning cube with static vertex and index buffer.\n" "Drag with left mouse button to rotate.\n" "Press ESC to exit.\n" "\n%s", gFPS.text); SVGA3DText_Update(); VMBackdoor_VGAScreenshot(); } while (VMBackdoor_MouseGetPacket(&lastMouseState)); SVGA3DUtil_ClearFullscreen(CID, SVGA3D_CLEAR_COLOR | SVGA3D_CLEAR_DEPTH, 0x113366, 1.0f, 0); render(); SVGA3DText_Draw(); SVGA3DUtil_PresentFullscreen(); } APM_SetPowerState(POWER_OFF); return 0; }
int GameInit(TGAME* Juego) { if(!Keyboard_Init(&(Juego->Teclado))) return -1; if(!GraphicManager_Init(&(Juego->Pantalla))) return -2; Juego->EstadoActual = Iniciando; Juego->cursorClock = clock(); Juego->cursor = char(177); Juego->pos_o_linea = false; Juego->turno = false; Juego->cant_cerradas_1 = Juego->cant_cerradas_2 = 0; Juego->GanadorEncontrado = false; InitPointsBox(Juego); return 0; }