void main() { uint32 f; /* frequency in hz */ f = 200; systemInit(); usbInit(); /* PWM duty cycle */ T1CC1L = 0x40; T1CC1H = 0x00; /* setup Timer 1, alt location 2 and prescaler 128*/ t1Init(IO_LOC_ALT_2, PRESCALER_128); /* setup Channel 1, compare mode, clear on compare up and peripheral*/ t1ChannelInit(CHANNEL1, COMPARE_MODE, CLR_ON_COMP_UP, PERIPHERAL); /* start Timer 1 by setting it's mode to modulo */ t1Mode(MODE_MODULO); /* set Timer 1 frequency */ setT1Frequency(f); while(1) { boardService(); updateLeds(); usbComService(); } }
void main(void) { uint16 speed = param_speed; uint8 port = param_port, pin=param_pin; uint8 ServoPos = 120; uint8 dir=1; systemInit(); usbInit(); InitServos(); EA=1; // Global interrupt enabled SetPin(0, port, pin); SetPin(1, 0, 1); SetPin(2, 0, 3); while (1) { delayMs(speed); usbComService(); if (dir==1) { ++ServoPos; } else { --ServoPos; } if (ServoPos > 253 || ServoPos < 2) { dir ^=1; } SetPos(0,ServoPos); SetPos(1,128); SetPos(2,64); } }
int main() { systemInit(); platformInit(); delay_ms(100); DEBUG_PRINT("init successfully\n"); while(1){ uint32_t systick = timerGetRun(); mpu9150Get(); // result = dmp_read_quat(quat, &more); // result = mpu_get_compass_reg(compass,&sensor_timestamp); while(timerGetRun() < systick + 49) { } sbn1HandleReceived(); } }
int main(int argc, char **argv) { ChickpeaWindow window; systemInit(&window, "Hello Chickpea", X_RES, Y_RES, 0, 0, 0); TexturedShader shader; loadShaderTextured(&shader, "textured_vertex.glsl", "textured_fragment.glsl"); int emojiTexture = loadTexture("emoji.png", 0, 0); MVPMatrices mvp; initMVP(&mvp); float aspect = (float)X_RES/(float)Y_RES; matrixSetOrthoProjection(mvp.projectionMatrix, -aspect, aspect, -1.0, 1.0, -1.0, 1.0); setShaderMVP(&mvp, shader.programID, shader.modelMatrixUniform, shader.viewMatrixUniform, shader.projectionMatrixUniform); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); int done = 0; SystemEvent event; while (!done) { while (systemPollEvent(&window, &event)) { if (event.type == EVENT_QUIT) { done = 1; } } glClear(GL_COLOR_BUFFER_BIT); drawTexture(emojiTexture, 0.8, 0.8, 0.0, 0.0, shader.positionAttribute, shader.texCoordAttribute); systemShowFrame(&window); } systemShutdown(); }
int main(void) { // Configure cpu and mandatory peripherals systemInit(); // Make sure that projectconfig.h is properly configured for this example #if !defined CFG_CHIBI #error "CFG_CHIBI must be enabled in projectconfig.h for this example" #endif #if CFG_CHIBI_PROMISCUOUS != 0 #error "CFG_CHIBI_PROMISCUOUS must be set to 0 in projectconfig.h for this example" #endif #ifdef CFG_CHIBI uint32_t counter = 0; chb_pcb_t *pcb = chb_get_pcb(); while(1) { // Enable LED gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_ON); // Create and send the message char text[10]; counter++; itoa(counter, text, 10); chb_write(0xFFFF, text, strlen(text) + 1); // Disable LED gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF); systickDelay(250); } #endif return 0; }
int main(void) { // Configure cpu and mandatory peripherals systemInit(); uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; while (1) { // Toggle LED once per second ... rollover = 136 years :) currentSecond = systickGetSecondsActive(); if (currentSecond != lastSecond) { lastSecond = currentSecond; if (gpioGetValue(CFG_LED_PORT, CFG_LED_PIN) == CFG_LED_OFF) { gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_ON); } else { gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF); } } // Poll for CLI input if CFG_INTERFACE is enabled in projectconfig.h #ifdef CFG_INTERFACE cmdPoll(); #endif } return 0; }
int main(void) { // Configure cpu and mandatory peripherals systemInit(); uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; // uartInit(115200); prt(); while (1) { // Toggle LED once per second currentSecond = systickGetSecondsActive(); if (currentSecond != lastSecond) { lastSecond = currentSecond; gpioSetValue(CFG_LED_PORT, CFG_LED_PIN, !(gpioGetValue(CFG_LED_PORT, CFG_LED_PIN))); uartSendByte('*'); } // Poll for CLI input if CFG_INTERFACE is enabled in projectconfig.h #ifdef CFG_INTERFACE cmdPoll(); #endif } return 0; }
/** Configures the USB and radio communication then calls the processBytesFromUsb and * processBytesFromRadio functions. **/ void main() { // required by wixel api: // http://pololu.github.io/wixel-sdk/group__libraries.html systemInit(); usbInit(); radioLinkInit(); // wait for a wireless pairing // between two wixels // blink yellow LED while connection is being established while(!radioLinkConnected()) { yellowLedOn ^= 1; updateLeds(); delayMs(DELAY_MS); } // turn off LED yellowLedOn = 0; // process bytes while(1) { boardService(); updateLeds(); usbComService(); processBytesFromUsb(); processBytesFromRadio(); } }
void main() { uint32 last_ms; systemInit(); //configure the P1_2 and P1_3 IO pins makeAllOutputs(LOW); //initialise Anlogue Input 0 P0INP = 0x1; //initialise the USB port usbInit(); usbComRequestLineStateChangeNotification(LineStateChangeCallback); last_ms = getMs(); while (1) { boardService(); usbComService(); if((getMs()-last_ms) >=5000){ LED_YELLOW_TOGGLE(); printf("batteryPercent: %i\r\n", batteryPercent(adcRead(0 | ADC_REFERENCE_INTERNAL))); last_ms=getMs(); } } }
int main(void) { systemInit(); behaviorSystemInit(behaviorTask, 4096); osTaskStartScheduler(); return 0; }
void main() { systemInit(); applicationInit(); while (1) { applicationTask(); } }
GGAudioManager::GGAudioManager() { systemInit(); interrupted_ = false; soundManager_ = new GGSoundManager(); createBackgroundMusicInterface(); gevent_AddCallback(tick_s, this); }
int main(void) { // Configure cpu and mandatory peripherals systemInit(); // Check if projectconfig.h is properly configured for this example #if !defined CFG_CHIBI #error "CFG_CHIBI must be enabled in projectconfig.h for this example" #endif #if CFG_CHIBI_PROMISCUOUS == 0 #error "CFG_CHIBI_PROMISCUOUS must set to 1 in projectconfig.h for this example" #endif #if !defined CFG_PRINTF_UART #error "CFG_PRINTF_UART must be enabled in projectconfig.h for this example" #endif #if defined CFG_INTERFACE #error "CFG_INTERFACE must be disabled in projectconfig.h for this example" #endif #if defined CFG_CHIBI && CFG_CHIBI_PROMISCUOUS != 0 // Get a reference to the Chibi peripheral control block chb_pcb_t *pcb = chb_get_pcb(); // Wait for incoming frames and transmit the raw data over uart while(1) { // Check for incoming messages while (pcb->data_rcv) { // get the length of the data rx_data.len = chb_read(&rx_data); // make sure the length is nonzero if (rx_data.len) { // Enable LED to indicate message reception gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_ON); // Send raw data to UART for processing on // the PC (requires WSBridge - www.freaklabs.org) uint8_t i; for (i=0; i<rx_data.len; i++) { // Send output to UART uartSendByte(rx_data.data[i]); } // Disable LED gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF); } } } #endif return 0; }
void systemTask(void *arg) { bool pass = true; //Init the high-levels modules systemInit(); #ifndef USE_UART_CRTP #ifdef UART_OUTPUT_TRACE_DATA debugInitTrace(); #endif #ifdef HAS_UART uartInit(); #endif #endif //ndef USE_UART_CRTP commInit(); DEBUG_PRINT("Crazyflie is up and running!\n"); DEBUG_PRINT("Build %s:%s (%s) %s\n", V_SLOCAL_REVISION, V_SREVISION, V_STAG, (V_MODIFIED) ? "MODIFIED" : "CLEAN"); DEBUG_PRINT("I am 0x%X%X%X and I have %dKB of flash!\n", *((int* )(0x1FFFF7E8 + 8)), *((int* )(0x1FFFF7E8 + 4)), *((int* )(0x1FFFF7E8 + 0)), *((short* )(0x1FFFF7E0))); commanderInit(); stabilizerInit(); //Test the modules pass &= systemTest(); pass &= commTest(); pass &= commanderTest(); pass &= stabilizerTest(); //Start the firmware if (pass) { systemStart(); ledseqRun(LED_RED, seq_alive); ledseqRun(LED_GREEN, seq_testPassed); } else { if (systemTest()) { while (1) { ledseqRun(LED_RED, seq_testPassed); //Red passed == not passed! vTaskDelay(M2T(2000) ); } } else { ledInit(); ledSet(LED_RED, true); } } workerLoop(); //Should never reach this point! while (1) vTaskDelay(portMAX_DELAY); }
int main(void) { // init the rone hardware and roneos services systemInit(); // init the behavior system and start the behavior thread behaviorSystemInit(behaviorTask, 4096); // Start the scheduler osTaskStartScheduler(); // should never get here. If so, you have a bad memory problem in the scheduler return 0; }
int main(void) { // Configure clock, this figures out HSE for hardware autodetect SetSysClock(0); systemInit(); Serial1 = uartOpen(USART1, &receive_cb, 115200, MODE_RXTX); init_printf( NULL, _putc); while (1); }
void main() { systemInit(); usbInit(); while(1) { boardService(); updateLeds(); usbComService(); processBytesFromUsb(); } }
int main(void) { #ifndef CFG_PWM #ERROR "CFG_PWM must be enabled in projectconfig.h for this example." #endif // Configure cpu and mandatory peripherals // PWM is initialised in systemInit and defaults to using P1.9 systemInit(); // Set duty cycle to 50% for square wave output pwmSetDutyCycle(50); // Frequency can be set anywhere from 2khz and 10khz (4khz is loudest) // Note: Since this is a 16-bit timer, make sure the delay is not // greater than 0xFFFF (65535), though anything 2khz and higher // is within an acceptable range // The piezo buzzer used for this example is the PS1240, available at // http://www.adafruit.com/index.php?main_page=product_info&cPath=35&products_id=160 pwmSetFrequencyInTicks(CFG_CPU_CCLK / 2000); uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; while (1) { // Beep the piezo buzzer very briefly once per second, toggling the LED at the same time currentSecond = systickGetSecondsActive(); // Make sure that at least one second has passed if (currentSecond != lastSecond) { // Update the second tracker lastSecond = currentSecond; // Set the LED state and buzzer loudness depending on the current LED state if (gpioGetValue(CFG_LED_PORT, CFG_LED_PIN) == CFG_LED_OFF) { pwmSetFrequencyInTicks(CFG_CPU_CCLK / 4000); // 4khz (louder) pwmStartFixed(200); // 2x as long as @ 2khz since it's 2x faster gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_ON); // Turn the LED on } else { pwmSetFrequencyInTicks(CFG_CPU_CCLK / 2000); // 2khz (softer) pwmStartFixed(100); gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF); // Turn the LED off } } } return 0; }
int main(void) { // init the rone hardware and roneos services systemInit(); // init the behavior system and start the behavior thread behaviorSystemInit(behaviorTask, 4096); osTaskCreate(backgroundTask, "background", 1536, NULL, BACKGROUND_TASK_PRIORITY); // Start the scheduler osTaskStartScheduler(); // should never get here. If so, you have a bad memory problem in the scheduler return 0; }
void main() { systemInit(); usbInit(); analogInputsInit(); while(1) { boardService(); updateLeds(); usbComService(); sendReportIfNeeded(); } }
void main() { systemInit(); usbInit(); setup_DS1820(); while(1) { boardService(); updateLeds(); usbComService(); handleOneWire(); } }
void main() { systemInit(); //Among other things, allocates byte arrays for sending commands. dynamixel_init(); // Oooh. what's this? setDigitalOutput(param_arduino_DTR_pin, LOW); ioTxSignals(0); //usbInit(); uart1Init(); uart1SetBaudRate(param_baud_rate); // Initial setting of serial mode updateSerialMode(); // Set up P1_5 to be the radio's TX debug signal. // P1DIR |= (1<<5); // IOCFG0 = 0b011011; // P1_5 = PA_PD (TX mode) // P1DIR |= 0x20; //Enable pin P1_5 while(1) { uint32 ms; uint16 now; uint16 speed; updateSerialMode(); boardService(); updateLeds(); errorService(); // Code for oscillating a servo back and forth ms = getMs(); // Get current time in ms now = ms % (uint32)10000; // 10 sec for a full swing if(now >= (uint16)5000){ // Goes from 0ms...5000ms now = (uint16)10000 - now; // then 5000ms...0ms } speed = interpolate(now, 0, 5000, 100, 900); // speed is really the position. ax12SetGOAL_POSITION(32, speed); delayMs(30); } }
void main() { systemInit(); usbInit(); perTestTxInit(); while(1) { boardService(); updateLeds(); usbComService(); sendRadioBursts(); } }
int init(void *handle) { MAIN *m = handle; m->var.state = STATE_DUMMY; m->var.newstate = STATE_INVENTORY; /* TODO: Måste fixas när menysystem och allt det där implementeras */ // m->var.newstate = STATE_OVERWORLD; if (cameraInit(m) != 0); else if (systemInit(m) != 0); else if (mapInit(m) != 0); else if (textboxInit(m) != 0); else if (npcInit(m) != 0); else return 0; return -1; }
//************************************************************************************************* // Main program to initialize hardware and execute Tasks. //************************************************************************************************* void main() { // Initialize system counters systemInit(); // Initialize tasks OLEDInit(); LEDInit(); speakerInit(); // Execute tasks repeatedly while(true){ OLEDExec(); LEDExec(); speakerExec(); } }
int main(void) { void SetSysClock(bool overclock); void systemInit(void); // Configure clock, this figures out HSE for hardware autodetect SetSysClock(0); systemInit(); setup(); while (1) { loop(); } }
void systemTask(void *arg) { bool pass = true; /* Init the high-levels modules */ systemInit(); uartInit(); commInit(); stabilizerInit(); //Test the modules pass &= systemTest(); pass &= commTest(); // pass &= commanderTest(); pass &= stabilizerTest(); if (pass) { systemStart(); ledseqRun(LED_RED, seq_alive); ledseqRun(LED_GREEN, seq_testPassed); } else { if (systemTest()) { while(1) { ledseqRun(LED_RED, seq_testPassed); //Red passed == not passed! vTaskDelay(M2T(2000)); } } else { ledInit(); ledSet(LED_RED, true); } } pmSetChargeState(charge500mA); //Should never reach this point! while(1) vTaskDelay(portMAX_DELAY); }
//************************************************************************************************* // Main program to initialize hardware and execute Tasks. //************************************************************************************************* void main(void) { // Create the tasks, the definitions are passed to the scheduler xTaskCreate(OLEDTask, "OLEDTask", 256, NULL, 2, NULL); xTaskCreate(LEDTask, "LEDTask", 32, NULL, 1, NULL); xTaskCreate(FIBTask, "FIBTask", 64, NULL, 1, NULL); // Initialize system systemInit(); // Display the initial image startScreen(); // Start the FreeRTOS Scheduler vTaskStartScheduler(); // The infinite loop is necessary for the FreeRTOS Scheduler while(true); }
void main() { systemInit(); usbInit(); usbComLineCodingChangeHandler = &lineCodingChanged; uart1Init(); lineCodingChanged(); while(1) { boardService(); updateLeds(); usbComService(); usbToUartService(); } }
int main(void){ // the watchdog WDT->WDT_MR = WDT_MR_WDDIS; // Set the clock up systemInit(); //84 MHZ presentation(); runGame(); while (1){ } // WHILE(1) } //main