int main(int argc, char *argv[]) { if (!MainInit(argc, argv)) { printf("Error: %s\n", GetTranslation("Init failed, aborting")); return 1; } // Init if (!(MainWin = initscr())) throwerror(false, "Could not init ncurses"); if (!(CDKScreen = initCDKScreen(MainWin))) throwerror(false, "Could not init CDK"); initCDKColor(); if ((InstallInfo.dest_dir_type == DEST_DEFAULT) && !ReadAccess(InstallInfo.dest_dir)) throwerror(true, CreateText("This installer will install files to the following directory:\n%s\n" "However you don't have read permissions to this directory\n" "Please restart the installer as a user who does or as the root user", InstallInfo.dest_dir.c_str())); int i=0; while(Functions[i]) { if (Functions[i]()) i++; else { if (YesNoBox(GetTranslation("This will abort the installation\nAre you sure?"))) break; } } EndProg(); return 0; }
/*! * \brief i2cwrite main() * * \param argc Count of command-line options and arguments. * \param argv Array of command-line options and arguments. * * \return Exit value. */ int main(int argc, char *argv[]) { i2c_t i2c; int rc; MainInit(argc, argv, &i2c); rc = execWrite(&i2c, OptI2CAddr, ArgWriteBuf, ArgWriteLen); return rc == ArgWriteLen? 0: (rc >= 0? 1: 2); }
/*! * \brief i2ccheck main() * * \param argc Count of command-line options and arguments. * \param argv Array of command-line options and arguments. * * \return Exit value. */ int main(int argc, char *argv[]) { i2c_t i2c; int rc; MainInit(argc, argv, &i2c); rc = execCheck(&i2c, OptI2CAddr); return rc > 0? 0: (rc == 0? 1: 2); }
/*! * \brief i2csh main() * * \param argc Count of command-line options and arguments. * \param argv Array of command-line options and arguments. * * \return Exit value. */ int main(int argc, char *argv[]) { i2c_t i2c; MainInit(argc, argv, &i2c); printf("I2C Raw Shell\n"); printf("-------------\n"); printf("(partial command matching valid; enter 'help' for help)\n\n"); MainLoop(&i2c); return 0; }
int main(void) { MainInit(); I2C1init(); RtcInit(); LcdInit(); DataLogInit(); StringInit(); Mct485Init(); FieldInit(); Ads1115Init(); Ads1244Init(); USBInit(); RtuInit(); AdcInit(); TC74Init(); // enable multi-vector interrupts INTEnableSystemMultiVectoredInt(); MainDelay(50); DataLogDateTime(DLOG_SFC_POWERUP); // init param after interrupts are enabled ParamInit(); // wait to init desiccant until after ParamInit DesiccantInit(); string[0].mct[0].chan[4] = 0x7FFF; // // Begin Main Loop // for (;;) { if (test == 1) { test = 0; FieldNewState((FIELD_STATE_m)t1); } USBUpdate(); // called as often as possible //sysTickEvent every ms if (sysTickEvent) { sysTickEvent = 0; sysTicks++; UsbTimeoutUpdate(); LcdUpdate(); // fill time before dropping LCD_E if (sysTicks >= 1000) { sysSec++; sysTicks = 0; mPORTDToggleBits(PD_LED_HEARTBEAT); // These Updates are // called once a second //TODO if any of these are long, we could split them on separate milliseconds. DesiccantUpdate(); AdcUpdate(); TC74Update(); }// end 1 Hz else if (sysTicks == 250) { mPORTDToggleBits(PD_LED_HEARTBEAT); } else if (sysTicks == 500) { mPORTDToggleBits(PD_LED_HEARTBEAT); } else if (sysTicks == 750) { mPORTDToggleBits(PD_LED_HEARTBEAT); } // Complete LcdUpdate() by dropping LCD_E) PORTClearBits(IOPORT_G, PG_LCD_E); // These Updates called once each millisecond RtcUpdate(); I2C1update(); StringUpdate(); Mct485Update(); FieldUpdate(); RtuUpdate(); DessicantFanPWMupdate(); } // if (sysTickEvent) } // for (;;) } // main()
/* main routine Program entry point */ int main(void) { Uint8 TxBuf[BCMsgSize]; Uint8 RxBuf[BCMsgSize]; Uint8 Address; // Address of device in bay Uint8 Destination; // Address we will reply to Uint8 Param,Param2; MainInit(); UART_TxStr("\r\nPower up\r\n"); UART_Rx(RxData, 9); // Input register setting command Address = BCAOutput + ReadPosition(); BCMessageInit(Address); // Set up the UART BCMessageReceive(RxBuf); // Kick off receive // Enter the main loop for( ; ; ) { // Run forever DelayMS(LoopRate); SettingsControl(); if (BCRXAvail) { // We have a new message if ((RxBuf[BCPAddr] & 0b1111) == Address) { // Check it is for us Destination = RxBuf[BCPAddr] >> 4; // Pre-setup assuming we will reply Destination &= 0b1111; Destination |= Address << 4; TxBuf[BCPAddr] = Destination; DelayMS(2); // Allow line turn around delay switch (RxBuf[BCPType]) { case BCTInquire: // Master request of slave ID TxBuf[BCPType] = BCTInquireAnswer; TxBuf[BCPParam1] = ReadProductID(); TxBuf[BCPParam2] = 0; BCMessageSend(TxBuf,true); // Send the reply BCMessageReceive(RxBuf); // Kick off receive of next frame break; case BCTVolume: // Volume set TxBuf[BCPType] = BCTAck; TxBuf[BCPParam1] = 0; TxBuf[BCPParam2] = 0; BCMessageSend(TxBuf,true); // Send the reply Param = RxBuf[BCPParam1]; // Save parameter so we can receive next frame while processing this request BCMessageReceive(RxBuf); // Kick off receive of next frame // Timer_Clear(); Volume_Set(Param); // UART_TxStr("Volume_Set took "); // UART_TxNum(Timer_Read()); // UART_TxStr("mS\r\n"); break; case BCTHeadphoneChGain: // Volume set TxBuf[BCPType] = BCTAck; TxBuf[BCPParam1] = 0; TxBuf[BCPParam2] = 0; BCMessageSend(TxBuf,true); // Send the reply Param = RxBuf[BCPParam1]; // Save parameter so we can receive next frame while processing this request Param2 = RxBuf[BCPParam2]; // Save parameter so we can receive next frame while processing this request BCMessageReceive(RxBuf); // Kick off receive of next frame // Timer_Clear(); SetChannelAdjust(Param,Param2); // UART_TxStr("Volume_Set took "); // UART_TxNum(Timer_Read()); // UART_TxStr("mS\r\n"); break; case BCTHeadphoneChMax: // Volume set TxBuf[BCPType] = BCTAck; TxBuf[BCPParam1] = 0; TxBuf[BCPParam2] = 0; BCMessageSend(TxBuf,true); // Send the reply Param = RxBuf[BCPParam1]; // Save parameter so we can receive next frame while processing this request Param2 = RxBuf[BCPParam2]; // Save parameter so we can receive next frame while processing this request BCMessageReceive(RxBuf); // Kick off receive of next frame SetChMaxVolume(Param, Param2); break; case BCTAudioFormat: // Audio format set TxBuf[BCPType] = BCTAck; TxBuf[BCPParam1] = 0; TxBuf[BCPParam2] = 0; BCMessageSend(TxBuf,true); // Send the reply Param = RxBuf[BCPParam1]; // Save parameter so we can receive next frame while processing this request BCMessageReceive(RxBuf); // Kick off receive of next frame // Timer_Clear(); WM8960_SetAudioFormat(Param); // UART_TxStr("WM8960_SetAudioFormat took "); // UART_TxNum(Timer_Read()); // UART_TxStr("mS\r\n"); break; default: // Unknown command TxBuf[BCPType] = BCTNAck; TxBuf[BCPParam1] = BCNUnkownType; TxBuf[BCPParam2] = RxBuf[BCPType]; BCMessageSend(TxBuf,true); // Send the reply BCMessageReceive(RxBuf); // Kick off receive of next frame break; } } } }
void TargetEpocGameL() { char buff[24]; // fps count c string struct timeval tval; // timing int thissec = 0, frames_done = 0, frames_shown = 0; int target_fps, target_frametime, too_fast, too_fast_time; int i, underflow; TRawEvent blevent; MainInit(); buff[0] = 0; // just to keep the backlight on.. blevent.Set(TRawEvent::EActive); // loop? for(;;) { if(gamestate == PGS_Running) { // prepare window and stuff CGameWindow::ConstructResourcesL(); // if the system has something to do, it should better do it now User::After(50000); //CPolledActiveScheduler::Instance()->Schedule(); // pal/ntsc might have changed, reset related stuff if(Pico.m.pal) { target_fps = 50; if(!noticeMsgTime.tv_sec) strcpy(noticeMsg, "PAL@SYSTEM@/@50@FPS"); } else { target_fps = 60; if(!noticeMsgTime.tv_sec) strcpy(noticeMsg, "NTSC@SYSTEM@/@60@FPS"); } target_frametime = 1000000/target_fps; if(!noticeMsgTime.tv_sec && pico_was_reset) gettimeofday(¬iceMsgTime, 0); pico_was_reset = too_fast = 0; reset_timing = 1; while(gamestate == PGS_Running) { gettimeofday(&tval, 0); if(reset_timing) { reset_timing = 0; thissec = tval.tv_sec; frames_done = tval.tv_usec/target_frametime; } // show notice message? char *notice = 0; if(noticeMsgTime.tv_sec) { if((tval.tv_sec*1000000+tval.tv_usec) - (noticeMsgTime.tv_sec*1000000+noticeMsgTime.tv_usec) > 2000000) // > 2.0 sec noticeMsgTime.tv_sec = noticeMsgTime.tv_usec = 0; else notice = noticeMsg; } // second changed? if(thissec != tval.tv_sec) { #ifdef BENCHMARK static int bench = 0, bench_fps = 0, bench_fps_s = 0, bfp = 0, bf[4]; if(++bench == 10) { bench = 0; bench_fps_s = bench_fps; bf[bfp++ & 3] = bench_fps; bench_fps = 0; } bench_fps += frames_shown; sprintf(buff, "%02i/%02i/%02i", frames_shown, bench_fps_s, (bf[0]+bf[1]+bf[2]+bf[3])>>2); #else if(currentConfig.iFlags & 2) sprintf(buff, "%02i/%02i", frames_shown, frames_done); #endif thissec = tval.tv_sec; if((thissec & 7) == 7) UserSvr::AddEvent(blevent); // in is quite common for this implementation to leave 1 fame unfinished // when second changes. This creates sound clicks, so it's probably better to // skip that frame and render sound if(PsndOut && frames_done < target_fps && frames_done > target_fps-5) { SkipFrame(1); frames_done++; } // try to prevent sound buffer underflows by making sure we did _exactly_ // target_fps sound updates and copying last samples over and over again if(PsndOut && frames_done < target_fps) for(; frames_done < target_fps; frames_done++) { PsndOut = gameAudio->DupeFrameL(underflow); if(!PsndOut) { // sound output problems? strcpy(noticeMsg, "SOUND@OUTPUT@ERROR;@SOUND@DISABLED"); gettimeofday(¬iceMsgTime, 0); break; } if(underflow) break; } frames_done = frames_shown = 0; } if(currentConfig.iFrameskip >= 0) { // frameskip enabled for(i = 0; i < currentConfig.iFrameskip; i++) { SkipFrame(frames_done < target_fps); frames_done++; CGameWindow::DoKeys(tval); } } else if(tval.tv_usec > (frames_done+1)*target_frametime) { // auto frameskip // no time left for this frame - skip SkipFrame(1); frames_done++; CGameWindow::DoKeys(tval); too_fast = 0; continue; } else if(tval.tv_usec < (too_fast_time=frames_done*target_frametime)) { // we are too fast if(++too_fast > 2) { User::After(too_fast_time-tval.tv_usec); too_fast = 0; }// sleep, but only if we are _really_ fast } // draw vidDrawFrame(notice, buff, frames_shown); if(PsndOut && frames_done < target_fps) { PsndOut = gameAudio->NextFrameL(); if(!PsndOut) { // sound output problems? strcpy(noticeMsg, "SOUND@OUTPUT@ERROR;@SOUND@DISABLED"); gettimeofday(¬iceMsgTime, 0); } } frames_done++; frames_shown++; CGameWindow::DoKeys(tval); } // save SRAM if((currentConfig.iFlags & 1) && SRam.changed) { saveLoadGame(0, 1); SRam.changed = 0; } CGameWindow::SendClientWsEvent(EEventGamePaused); CGameWindow::FreeResources(); } else if(gamestate == PGS_Paused) {
/* main routine Program entry point */ int main(void) { Uint8 TxBuf[BCMsgSize]; Uint8 RxBuf[BCMsgSize]; Uint8 Address; // Address of device in bay Uint8 Destination; // Address we will reply to Uint8 Param,Param2; Uint8 Volume = 0; Uint8 TempInt; #ifdef CTRL_LED Uint8 TempInt; Uint8 RceiveAddress; Uint8 i; i = 0; #endif MainInit(); UART_TxStr("\r\nPower up\r\n"); UART_Rx(RxData, 9); // Input register setting command Address = BCAOutput + ReadPosition(); BCMessageInit(Address); // Set up the UART BCMessageReceive(RxBuf); // Kick off receive if(ReadProductID()) // 1:pill 2:beats box 3:rave ChannelNumbers = 1; else ChannelNumbers = 5;//0:5 position headphone // Enter the main loop LED1_ON(); LED2_ON(); LED_GRAPHICAL_ON(); SetLamps(3); for( ; ; ) { // Run forever Timer_Clear(); DelayMS(LoopRate); TempInt++; SettingsControl(); if (BCRXAvail) { // We have a new message //send data #ifdef SecondUART #ifdef DumpComms UART_TxStr("Receive: "); for (TempInt = BCPSOH; TempInt <= BCPChecksum; TempInt++) { UART_TxUint8(RxBuf[TempInt]); UART_TxChar(' '); } UART_TxStr("\r\n"); #endif #endif if ((RxBuf[BCPAddr] & 0b1111) == Address) // Check it is for us { Destination = RxBuf[BCPAddr] >> 4; // Pre-setup assuming we will reply Destination &= 0b1111; Destination |= Address << 4; TxBuf[BCPAddr] = Destination; DelayMS(2); // Allow line turn around delay switch (RxBuf[BCPType]) { case BCTInquire: // Master request of slave ID TxBuf[BCPType] = BCTInquireAnswer; TxBuf[BCPParam1] = ReadProductID(); TxBuf[BCPParam2] = 0; BCMessageSend(TxBuf,true); // Send the reply break; case BCTLamps: // Set lamps TxBuf[BCPType] = BCTAck; TxBuf[BCPParam1] = 0; TxBuf[BCPParam2] = 0; BCMessageSend(TxBuf, true); // Send the reply Param = RxBuf[BCPParam1]; SetLamps(Param); break; case BCTVolume: // Volume set TxBuf[BCPType] = BCTAck; TxBuf[BCPParam1] = 0; TxBuf[BCPParam2] = 0; BCMessageSend(TxBuf,true); // Send the reply Volume = RxBuf[BCPParam1]; // Save parameter so we can receive next frame while processing this request Param2 = RxBuf[BCPParam2]; // Save parameter so we can receive next frame while processing this request Volume_Set(Volume,Param2); break; case BCTHeadphoneChGain: // Volume set TxBuf[BCPType] = BCTAck; TxBuf[BCPParam1] = 0; TxBuf[BCPParam2] = 0; BCMessageSend(TxBuf,true); // Send the reply Param = RxBuf[BCPParam1]; // Save parameter so we can receive next frame while processing this request Param2 = RxBuf[BCPParam2]; // Save parameter so we can receive next frame while processing this request SetChannelAdjust(Param,Param2); break; case BCTHeadphoneChMax: // Volume set TxBuf[BCPType] = BCTAck; TxBuf[BCPParam1] = 0; TxBuf[BCPParam2] = 0; BCMessageSend(TxBuf,true); // Send the reply Param = RxBuf[BCPParam1]; // Save parameter so we can receive next frame while processing this request Param2 = RxBuf[BCPParam2]; // Save parameter so we can receive next frame while processing this request SetChMaxVolume(Param, Param2); break; case BCTAudioFormat: // Audio format set TxBuf[BCPType] = BCTAck; TxBuf[BCPParam1] = 0; TxBuf[BCPParam2] = 0; BCMessageSend(TxBuf,true); // Send the reply Param = RxBuf[BCPParam1]; // Save parameter so we can receive next frame while processing this request WM8960_SetAudioFormat(Param); break; case BCTBrightness: // Set lamp brightness TxBuf[BCPType] = BCTAck; TxBuf[BCPParam1] = 0; TxBuf[BCPParam2] = 0; BCMessageSend(TxBuf, true); // Send the reply Param = RxBuf[BCPParam1]; // Save parameter so we can receive next frame while processing this request Param2 = RxBuf[BCPParam2]; // Save parameter so we can receive next frame while processing this request if (Param == 1) LED1 = Param2; else if(Param == 2) LED2 = Param2; break; case BCTReset: // Volume set TxBuf[BCPType] = BCTAck; TxBuf[BCPParam1] = 0; TxBuf[BCPParam2] = 0; BCMessageSend(TxBuf,true); // Send the reply Param = RxBuf[BCPParam1]; // Save parameter so we can receive next frame while processing this request BCMessageReceive(RxBuf); // Kick off receive of next frame asm("jmp 0x0000");//reset break; default: // Unknown command TxBuf[BCPType] = BCTNAck; TxBuf[BCPParam1] = BCNUnkownType; TxBuf[BCPParam2] = RxBuf[BCPType]; BCMessageSend(TxBuf,true); // Send the reply // BCMessageReceive(RxBuf); // Kick off receive of next frame break; } //this send command tv change to 031-517-209 board #if VideoTrackCtrl Uint8 VideoTrack; Uint8 SendVideoFlag; if(Volume > 47) { if(SendVideoFlag) { SendVideoFlag = false; if(Address == BCARightBay) { VideoTrack = 1; } else if(Address == BCALeftBay) { VideoTrack = 2; } TxBuf[BCPAddr] = Address << 4; TxBuf[BCPAddr] |= BDCLCD; TxBuf[BCPType] = BCTPlayTrack; TxBuf[BCPParam1] = VideoTrack; TxBuf[BCPParam2] = 0; BCMessageSend(TxBuf, true); // Send the reply } } else { SendVideoFlag = 1; } #endif } //this for ctrl LED it itself #ifdef CTRL_LED if(RxBuf[BCPType] == BCTVolume) { RceiveAddress = RxBuf[BCPAddr] & 0b1111; a_Volume[RceiveAddress-BCAOutput] = RxBuf[BCPParam1]; if((a_Volume[RceiveAddress-BCAOutput] > 47) && (LastVolume[RceiveAddress-BCAOutput] > 47))//have volume { if((RceiveAddress) == Address) { LED1_ON(); } else { LED1_OFF(); } } i = 0; for(TempInt = 0; TempInt < 4; ) //all volume off { if((a_Volume[TempInt] <= 47) && (LastVolume[TempInt] <= 47)) i++; TempInt++; } if(i >= TempInt) { LED1_ON(); } LastVolume[RceiveAddress-BCAOutput] = a_Volume[RceiveAddress-BCAOutput]; } #endif BCMessageReceive(RxBuf); // Kick off receive of next frame } }