/******************************************************************************* * Function Name: main ******************************************************************************** * * Summary: * Main function. * * Parameters: * None * * Return: * None * *******************************************************************************/ int main() { /* Setup the system initially */ InitializeSystem(); /* Three simple APIs that showcases dynamic ADV payload update */ for(;;) { /* Single API call to service all the BLE stack events. Must be * called at least once in a BLE connection interval */ CyBle_ProcessEvents(); /* Configure the system in lowest possible power modes during and between BLE ADV events */ EnterLowPowerMode(); /* LOW_POWER_NOTE - If you like to measure the current consumed by this project, following changes are to be done to achieve lowest possible current number: 1. Set the "Debug Select" option under Dynamic Broadcaster.cydwr -> System -> Programming/Debugging to GPIO 2. Comment out Advertising_LED_Write(LED_ON); line of code in StackEventHandler routine */ #if ENABLE_DYNAMIC_ADV DynamicADVPayloadUpdate(); #endif } }
void main(void) { InitializeSystem(); while (1) { // Comprueba el terminal que indica la conexión USB al inicio o al reset if (PORTBbits.RB4 == 1) { // Si no se ha activado el USB, lo activa if ((USBGetDeviceState() == DETACHED_STATE)) { USBDeviceAttach(); } else { // Si ya se ha activado, realiza las tareas USB // USB Tasks blinkUSBStatus(); processUSBData(); } } else { // Si no está conectado el terminal USB, entra en modo de bajo consumo USBDeviceDetach(); LATCbits.LATC0 = 0; OSCCONbits.IDLEN = 0; Sleep(); Nop(); } }//end while }//end main
void Main() { // Initialize the system: sys_init(); InitializeSystem(); // Initialize the output: TurnOnLCD(); Set8Led(0); // Initialize the data: InitializeGame(); // Initialize the input: SetOnKeyboardDown(OnKeyboardDown); InitializeKeyboardInterrupts(); SetOnButtonDown(OnButtonDown); SetOnButtonUp(OnButtonUp); InitializeButtonsInterrupts(); // Initialize the timers: SimpleInitializeTimerInterrupts(TIMER_ID0, MAX_TIME_COUNT, (unsigned)UpdateOnTimer); // Initialize the UART1: InitializeUART(BAUDS_115200); //ActivateInterruptsUART1((unsigned)OnReceiveUART); // Call the main loop: MainLoopWithPolling(); }
int main() { // Do some basic initialization tasks InitializeSystem(); // Initialize pins for LEDs InitializeLEDs(); // Enable printf via trace macrocell (get output with 'make trace') EnableDebugOutput(DEBUG_ITM); //printf("step\n %d"); //Turn on all LEDs _Bool isOn = 0; int val = 1 | 2 | 4 | 8; while (1) { if (isOn == 0) { val = (val<<1) | (val<0); SetLEDs(val); isOn = 1; } else { SetLEDs(0 | 0 | 0 | 0); isOn = 0; iprintf("test\r\n"); } Delay( 10 ); } }
CPSSpawnEffect::CPSSpawnEffect(int maxParticles, const Vector &origin, float scale, float scaledelta, float radius, float radiusdelta, float velocity, int sprindex, int r_mode, byte r, byte g, byte b, float a, float adelta, float timetolive) { index = 0;// the only good place for this removenow = false; ResetParameters(); if (!InitTexture(sprindex)) { removenow = true; return; } m_iMaxParticles = maxParticles; VectorCopy(origin, m_vecOrigin); m_fScale = scale; m_fScaleDelta = scaledelta; m_fRadius = radius; m_fRadiusDelta = radiusdelta; m_color.r = r; m_color.g = g; m_color.b = b; m_fBrightness = a; m_fBrightnessDelta = adelta; m_iRenderMode = r_mode; if (timetolive <= 0.0f) m_fDieTime = -1.0f; else m_fDieTime = gEngfuncs.GetClientTime() + timetolive; InitializeSystem(); m_iNumParticles = m_iMaxParticles;// all particles are present at start for (int i = 0; i < m_iNumParticles; ++i) InitializeParticle(i); }
CPSBubbles::CPSBubbles(int maxParticles, const Vector &origin, const Vector &direction, const Vector &spread, float partvelocity, float size, int sprindex, int frame, float PartEmitterLife) { index = 0; removenow = false; ResetParameters(); if (!InitTexture(sprindex)) { removenow = true; return; } m_iMaxParticles = maxParticles; VectorCopy(origin, m_vecOrigin); if (VectorCompare(origin, direction)) { VectorClear(m_vecDirection); m_flRandomDir = true; } else { VectorCopy(direction, m_vecDirection); m_flRandomDir = false; } VectorCopy(spread, m_vecSpread); m_fParticleVelocity = partvelocity; m_iRenderMode = kRenderTransAdd; m_iFrame = frame; m_fScale = size; if (PartEmitterLife <= 0) m_fDieTime = -1; else m_fDieTime = gEngfuncs.GetClientTime() + PartEmitterLife; InitializeSystem(); }
int main(void) #endif { InitializeSystem(); #if defined(USB_INTERRUPT) USBDeviceAttach(); #endif while(1) { #if defined(USB_POLLING) // Check bus status and service USB interrupts. USBDeviceTasks(); // Interrupt or polling method. If using polling, must call // this function periodically. This function will take care // of processing and responding to SETUP transactions // (such as during the enumeration process when you first // plug in). USB hosts require that USB devices should accept // and process SETUP packets in a timely fashion. Therefore, // when using polling, this function should be called // frequently (such as once about every 100 microseconds) at any // time that a SETUP packet might reasonably be expected to // be sent by the host to your device. In most cases, the // USBDeviceTasks() function does not take very long to // execute (~50 instruction cycles) before it returns. #endif // Application-specific tasks. // Application related code may be added here, or in the ProcessIO() function. ProcessIO(); }//end while }//end main
int main ( void ) { // Initialize the processor and peripherals. if ( InitializeSystem() != TRUE ) { UART2PrintString( "\r\n\r\nCould not initialize USB Custom Demo App - system. Halting.\r\n\r\n" ); while (1); } if ( USBHostInit(0) == TRUE ) { UART2PrintString( "\r\n\r\n***** USB Custom Demo App Initialized *****\r\n\r\n" ); } else { UART2PrintString( "\r\n\r\nCould not initialize USB Custom Demo App - USB. Halting.\r\n\r\n" ); while (1); } // Main Processing Loop while (1) { // This demo does not check for overcurrent conditions. See the // USB Host - Data Logger for an example of overcurrent detection // with the PIC24F and the USB PICtail Plus. // Maintain USB Host State USBHostTasks(); // Maintain Demo Application State ManageDemoState(); } return 0; } // main
/****************************************************************************** * Function: void main(void) * * PreCondition: None * * Input: None * * Output: None * * Side Effects: None * * Overview: Main program entry point. * * Note: None *****************************************************************************/ int main(void) { InitializeSystem(); #if defined(USB_INTERRUPT) USBDeviceAttach(); #endif while(1) { #if defined(USB_POLLING) // Check bus status and service USB interrupts. USBDeviceTasks(); // Interrupt or polling method. If using polling, must call // this function periodically. This function will take care // of processing and responding to SETUP transactions // (such as during the enumeration process when you first // plug in). USB hosts require that USB devices should accept // and process SETUP packets in a timely fashion. Therefore, // when using polling, this function should be called // regularly (such as once every 1.8ms or faster** [see // inline code comments in usb_device.c for explanation when // "or faster" applies]) In most cases, the USBDeviceTasks() // function does not take very long to execute (ex: <100 // instruction cycles) before it returns. #endif // Application-specific tasks. // Application related code may be added here, or in the ProcessIO() function. ProcessIO(); }//end while }//end main
int main(void) { InitializeSystem(); // Wait for reset button to be released while (_PORT(PIO_BTN1) == HIGH) { } //ADCInitialize(); PWMInitialize(); PWMEnable(); USBDeviceInit(); //ADCStartCapture(); _LAT(PIO_LED1) = HIGH; ColourEngine::Initialize(); //ColourEngine::PowerOn(1000); // Fade in ColourEngine::SetPower(power, 0); //_LAT(PIO_LED2) = HIGH; while (1) { USBDeviceTasks(); USBUserProcess(); } return 0; }
int main(void) { InitializeSystem(); initADCDMA(); #if defined(USB_INTERRUPT) if(USB_BUS_SENSE && (USBGetDeviceState() == DETACHED_STATE)) { USBDeviceAttach(); } #endif #if defined(USB_POLLING) // Check bus status and service USB interrupts. USBDeviceTasks(); #endif while(1) { if (!ADC_DATA_READY) continue; ADC_DATA_READY = 0; RunFFT(); putrsUSBUSART((char*)&fftOut[0].real); ProcessIO(); } return (EXIT_SUCCESS); }
void BootMain(void) #endif { //NOTE: The c018.o file is not included in the linker script for this project. //The C initialization code in the c018.c (comes with C18 compiler in the src directory) //file is instead modified and included here manually. This is done so as to provide //a more convenient entry method into the bootloader firmware. Ordinarily the _entry_scn //program code section starts at 0x00 and is created by the code of c018.o. However, //the linker will not work if there is more than one section of code trying to occupy 0x00. //Therefore, must not use the c018.o code, must instead manually include the useful code //here instead. //Make sure interrupts are disabled for this code (could still be on, //if the application firmware jumped into the bootloader via software methods) INTCON = 0x00; //Initialize the C stack pointer, and other compiler managed items as //normally done in the c018.c file (applicable when using C18 compiler) #ifndef __XC8__ _asm lfsr 1, _stack lfsr 2, _stack clrf TBLPTRU, 0 _endasm #endif //Clear the stack pointer, in case the user application jumped into //bootloader mode with excessive junk on the call stack STKPTR = 0x00; // End of the important parts of the C initializer. This bootloader firmware does not use // any C initialized user variables (idata memory sections). Therefore, the above is all // the initialization that is required. //Call other initialization code and (re)enable the USB module InitializeSystem(); //Some USB, I/O pins, and other initialization //Execute main loop while(1) { ClrWdt(); //Need to call USBDeviceTasks() periodically. This function takes care of //processing non-USB application related USB packets (ex: "Chapter 9" //packets associated with USB enumeration) USBDeviceTasks(); BlinkUSBStatus(); //When enabled, blinks LEDs on the board, based on USB bus state LowVoltageCheck(); //Regularly monitor voltage to make sure it is sufficient //for safe operation at full frequency and for erase/write //operations. ProcessIO(); //This is where all the actual bootloader related data transfer/self programming takes //place see ProcessIO() function in the BootPIC[xxxx].c file. }//end while }
int main(void) { InitializeSystem(); USBDeviceAttach(); while(1) { } }
/******************************************************************** * メイン関数 ******************************************************************** */ void main(void) { InitializeSystem(); while(1){ USBtask(); // LED2_blink(); } }
/****************************************************************************** * Function: void main(void) * * PreCondition: None * * Input: None * * Output: None * * Side Effects: None * * Overview: Main program entry point. * * Note: None *****************************************************************************/ void main(void) { InitializeSystem(); while(1) { USBTasks(); // USB Tasks ProcessIO(); // See user\user.c & .h }//end while }//end main
int main(void) #endif { InitializeSystem(); while(1) { ProcessIO(); } }
bool GMainWindow::LoadROM(const std::string& filename) { std::unique_ptr<Loader::AppLoader> app_loader = Loader::GetLoader(filename); if (!app_loader) { LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filename.c_str()); QMessageBox::critical(this, tr("Error while loading ROM!"), tr("The ROM format is not supported.")); return false; } boost::optional<u32> system_mode = app_loader->LoadKernelSystemMode(); if (!system_mode) { LOG_CRITICAL(Frontend, "Failed to load ROM!"); QMessageBox::critical(this, tr("Error while loading ROM!"), tr("Could not determine the system mode.")); return false; } if (!InitializeSystem(system_mode.get())) return false; Loader::ResultStatus result = app_loader->Load(); if (Loader::ResultStatus::Success != result) { System::Shutdown(); LOG_CRITICAL(Frontend, "Failed to load ROM!"); switch (result) { case Loader::ResultStatus::ErrorEncrypted: { // Build the MessageBox ourselves to have clickable link QMessageBox popup_error; popup_error.setTextFormat(Qt::RichText); popup_error.setWindowTitle(tr("Error while loading ROM!")); popup_error.setText( tr("The game that you are trying to load must be decrypted before being used with " "Citra.<br/><br/>" "For more information on dumping and decrypting games, please see: <a " "href='https://citra-emu.org/wiki/Dumping-Game-Cartridges'>https://" "citra-emu.org/wiki/Dumping-Game-Cartridges</a>")); popup_error.setIcon(QMessageBox::Critical); popup_error.exec(); break; } case Loader::ResultStatus::ErrorInvalidFormat: QMessageBox::critical(this, tr("Error while loading ROM!"), tr("The ROM format is not supported.")); break; case Loader::ResultStatus::Error: default: QMessageBox::critical(this, tr("Error while loading ROM!"), tr("Unknown error!")); break; } return false; } return true; }
/*************************************************** * Function: void Init(void) * * OverView: All calling related to Initialized functions. * * Note: None ***************************************************/ void Init(void) { InitializeSystem(); // Initialize Related to connect usb port. InitializeUser(); // Initialize for User Variables. InitializeDevice(); // Initialize PICF4550 LED, PWM, ADC Ports USBDeviceInit(); // Initialize USB Module. #if defined(USB_INTERRUPT) USBDeviceAttach(); // Enable to find USB Device #endif }
void main(void) { InitializeSystem(); // If the switch is pressed on boot, enter system config mode. g_config_mode = (sw == 0); while (1) { USBDeviceTasks(); ProcessIO(); } }
int main(void) { struct BadgeState *game_state; char sample_i = 0, sample_val = 0; InitializeSystem(); #if defined(USB_INTERRUPT) USBDeviceAttach(); #endif #if defined(GAME_MODE) game_state = Init_Game(); #endif while(1) { if((play_count & 0x0fff) && play_count & 0x8000) { //LATBbits.LATB2 = 1; //LATBbits.LATB3 = 1; getNextSample( &sample_i, &sample_val); LATAbits.LATA9 = sample_val; play_count++; } else play_count = play_count & 0x8000; #if defined(USB_POLLING) // Check bus status and service USB interrupts. USBDeviceTasks(); // Interrupt or polling method. If using polling, must call // this function periodically. This function will take care // of processing and responding to SETUP transactions // (such as during the enumeration process when you first // plug in). USB hosts require that USB devices should accept // and process SETUP packets in a timely fashion. Therefore, // when using polling, this function should be called // regularly (such as once every 1.8ms or faster** [see // inline code comments in usb_device.c for explanation when // "or faster" applies]) In most cases, the USBDeviceTasks() // function does not take very long to execute (ex: <100 // instruction cycles) before it returns. #endif // Application-specific tasks. // Application related code may be added here, or in the ProcessIO() function. ProcessIO(); #if defined(GAME_MODE) Run_Game(&game_state); //welcome(game_state); #endif }//end while }//end main
int main ( void ) { // Initialize the processor and peripherals. if ( InitializeSystem() != TRUE ) { UART2PrintString( "\r\n\r\nCould not initialize USB Custom Demo App - system. Halting.\r\n\r\n" ); while (1); } if ( USBHostInit(0) == TRUE ) { UART2PrintString( "\r\n\r\n***** USB Custom Demo App Initialized *****\r\n\r\n" ); } else { UART2PrintString( "\r\n\r\nCould not initialize USB Custom Demo App - USB. Halting.\r\n\r\n" ); while (1); } btClientData.State = BT_STATE_IDLE; btClientData.Initialized = FALSE; mPORTAOutputConfig(0x3); mPORTAWrite(0x0); mPORTBOutputConfig(0x10); // OC 1 PPSOutput(PPS_RP4, PPS_OC1); //Enable Interrupt SetPriorityIntOC1(4); EnableIntOC1; OpenTimer2(T2_ON | T2_PS_1_8 ,0xffff); // OpenOC1(OC_IDLE_CON | OC_TIMER2_SRC | OC_PWM_EDGE_ALIGN ,OC_SYNC_TRIG_IN_TMR2,0,0); SetDCOC1PWM(0xc00,0); // Main Processing Loop while (1) { BTClientTasks(); // Maintain USB Host State USBHostTasks(); DelayMs(1); } return 0; } // main
// TODO: fix particle rotation!! CPSDrips::CPSDrips(int maxParticles, const Vector &origin, const Vector &mins, const Vector &maxs, const Vector &dir, int sprindex, int sprindex_splash, int r_mode, float sizex, float sizey, float scaledelta, float timetolive) { index = 0;// the only good place for this removenow = false; ResetParameters(); // m_pTexture = NULL; if (!InitTexture(sprindex)) { removenow = true; return; } // m_iSplashTexture = sprindex_splash; if (sprindex_splash > 0) { m_pTexture2 = IEngineStudio.GetModelByIndex(sprindex_splash); if (!m_pTexture2 || m_pTexture2->type != mod_sprite) m_pTexture2 = NULL; } else m_pTexture2 = NULL; m_iMaxParticles = maxParticles; VectorCopy(mins, m_vecMinS); VectorCopy(maxs, m_vecMaxS); m_vecMinS[2] += 1.0f; // m_vecDirection = dir.Normalize(); // m_fSpeed = dir.Length(); VectorCopy(origin, m_vecOrigin); VectorCopy(dir, m_vecDirection); m_fSpeed = VectorNormalize(m_vecDirection); m_fScale = -0.1f;// XDM3035: this prevents CRenderSystem::InitializeSystem() from modifying sizes m_fScaleDelta = scaledelta; m_fSizeX = m_pTexture->maxs[1] - m_pTexture->mins[1]; m_fSizeY = m_pTexture->maxs[2] - m_pTexture->mins[2]; if (sizex > 0.0f) m_fSizeX *= sizex; if (sizey > 0.0f) m_fSizeY *= sizey; // m_pParticleList = NULL; // m_iFollowEntity = -1; m_iRenderMode = r_mode; if (timetolive <= 0.0f) m_fDieTime = -1; else m_fDieTime = gEngfuncs.GetClientTime() + timetolive; // CON_PRINTF("CPSDrips: size: %f %f\n", m_fSizeX, m_fSizeY); InitializeSystem(); }
// **************************************************************************** // main // int main(void) { InitializeSystem(); USBDeviceAttach(); while (1) { updateState(); handleKeys(); CLRWDT(); // tickle watchdog } } //end main
int main(void) #endif { InitializeSystem(); USBDeviceInit(); while(1) { USBDeviceTasks(); ProcessIO(); } }
/* The CANbus card must be initialized and called from a realtime thread. * The rt_thread is spun off from main() to handle the initial communications. */ void can_thd_function(void *thd) { int err; /* Probe and initialize the robot actuators */ err = InitializeSystem(); if(err) { syslog(LOG_ERR, "InitializeSystem returned err = %d", err); exit(1); } /* Initialize and get a handle to the robot on the first bus */ if (ignore_calibration) wam = OpenWAM("*../../wam.conf", 0); else wam = OpenWAM("../../wam.conf", 0); if(!wam) { syslog(LOG_ERR, "OpenWAM failed"); exit(1); } /* setSafetyLimits(bus, joint rad/s, tip m/s, elbow m/s); * For now, the joint and tip velocities are ignored and * the elbow velocity provided is used for all three limits. */ setSafetyLimits(0, 1.5, 1.5, 1.5); // Limit to 1.5 m/s /* Set the puck torque safety limits (TL1 = Warning, TL2 = Critical). * Note: The pucks are limited internally to 3441 (see 'MT' in btsystem.c) * Note: btsystem.c bounds the outbound torque to 8191, so entering a * value of 9000 for TL2 would tell the safety system to never register a * critical fault. */ setProperty(0, SAFETY_MODULE, TL2, FALSE, 4700); setProperty(0, SAFETY_MODULE, TL1, FALSE, 1800); /* Notify main() thread that the initialization is complete */ startDone = 1; /* Spin until we are told to exit */ while (!btrt_thread_done((btrt_thread_struct*)thd)) usleep(10000); /* Close the system */ CloseSystem(); /* Remove this thread from the realtime scheduler */ btrt_thread_exit((btrt_thread_struct*)thd); }
/******************************************************************************* * Function Name: main ******************************************************************************** * Summary: * System entrance point. This calls the initializing function and * continuously process BLE and CapSense events. * * Parameters: * void * * Return: * int * *******************************************************************************/ int main() { uint8 lpmSel = DEEPSLEEP; /* This function will initialize the system resources such as BLE and CapSense */ InitializeSystem(); for(;;) { /*Process event callback to handle BLE events. The events generated and * used for this application are inside the 'CustomEventHandler' routine*/ CyBle_ProcessEvents(); /* Updated LED for status during BLE active states */ HandleStatusLED(); if(TRUE == deviceConnected) { /* After the connection, send new connection parameter to the Client device * to run the BLE communication on desired interval. This affects the data rate * and power consumption. High connection interval will have lower data rate but * lower power consumption. Low connection interval will have higher data rate at * expense of higher power. This function is called only once per connection. */ UpdateConnectionParam(); /* When the Client Characteristic Configuration descriptor (CCCD) is written * by Central device for enabling/disabling notifications, then the same * descriptor value has to be explicitly updated in application so that * it reflects the correct value when the descriptor is read */ UpdateNotificationCCCD(); lpmSel = LPMselData; } #ifdef ENABLE_LOW_POWER_MODE /* Put system to Deep sleep, including BLESS, and wakeup on interrupt. * The source of the interrupt can be either BLESS Link Layer in case of * BLE advertisement and connection or by User Button press during BLE * disconnection */ HandleLowPowerMode(lpmSel); #endif if(restartAdvertisement) { /* Reset 'restartAdvertisement' flag*/ restartAdvertisement = FALSE; /* Start Advertisement and enter Discoverable mode*/ CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST); } } /* End of for(;;) */ }
/** * Main function * Main program entry point. * */ void main(void) { InitializeSystem(); tickInit(); while(1) { USBTasks(); BlinkUSBStatus(); if (!((usb_device_state < CONFIGURED_STATE)||(UCONbits.SUSPND==1))) ProcessIO(); // See user\user.c & .h } }
int main() { InitializeSystem(); SysTick_Config(HCLKFrequency()/100); InitializeLEDs(); InitializeAccelerometer(); InitializeLEDFlow(); while(1) { RunLEDFlow(); Delay(5); } }
void main(void) { InitializeSystem(); #if defined(USB_INTERRUPT) USBDeviceAttach(); #endif while(1) { #if defined(USB_POLLING) USBDeviceTasks(); // Interrupt or polling method. If using polling, must call #endif ProcessIO(); }//end while }//end main
int main(void) { InitializeSystem(); while(1) { #if defined(USB_INTERRUPT) //if(USB_BUS_SENSE && (USBGetDeviceState() == DETACHED_STATE)) //{ USBDeviceAttach(); //} #endif /*if(USBDeviceState < CONFIGURED_STATE) { if(!I2CState.Slave) InitI2CSlave(); } else if(!I2CState.Master) InitI2CMaster();*/ #if defined(USB_POLLING) // Check bus status and service USB interrupts. USBDeviceTasks(); // Interrupt or polling method. If using polling, must call // this function periodically. This function will take care // of processing and responding to SETUP transactions // (such as during the enumeration process when you first // plug in). USB hosts require that USB devices should accept // and process SETUP packets in a timely fashion. Therefore, // when using polling, this function should be called // regularly (such as once every 1.8ms or faster** [see // inline code comments in usb_device.c for explanation when // "or faster" applies]) In most cases, the USBDeviceTasks() // function does not take very long to execute (ex: <100 // instruction cycles) before it returns. #endif if(TMR0IF) WorkTick(); if(Status.State == 'P'){ AsicPushWork(); } ProcessIO(); }//end while }//end main