int main (void) { char msg[30]; unsigned char c; int i=0; int counter[3]; ioinit(); //initTimer(); initTimer2(); initPWM(); initLCD(); //initPWM(); USART_Transmit_String("Restarting..\r\n"); wait(10); //LCD_gotoXY(1,0); //LCD_Write("Out-PWM-BC1"); while (1) { unsigned int en, en1; asm("nop"); cli(); en = topup_timer2; en1 = timestamp[0]; sei(); sprintf(msg, "%04x,%04x", en, en1); USART_Transmit_String(msg); LCD_gotoXY(0,0); LCD_Write(msg); } return 0; }
/********************************************************* Main Code *********************************************************/ int main (void) { ioinit (); //Initialize the I/O and the SPI port sei(); //Enable Global Interrupts while(1) { if (PINB & (1<<0)) //If CS goes high, SPI com is complete, SS is PB0 { new_frame=1; } //New frame is set when enough bytes have been received for the whole system if(new_frame==1){ new_frame=0; //Reset the frame flag. //do work with mybuffer here } //do more here } return (0); }
int main (void) { unsigned char key; unsigned int delay = 500; unsigned int step = 100; ioinit (); // SET__LED_RED(1); // delay_ms(3000); mixing_blinking(7, 100); /* for (;;) { // led on, pin=0 SET__LED_RED(1); // buzzer off SET__BUZZER(0); delay_ms(delay); // led off, pin=1 SET__LED_RED(0); // buzzer on SET__BUZZER(1); delay_ms(delay); } */ return (0); }
void main(void) { memset(edata, 0, (ulong)end-(ulong)edata); conf.nmach = 1; machinit(); ioinit(); i8250console(); quotefmtinstall(); print("\nPlan 9\n"); confinit(); xinit(); raveninit(); trapinit(); printinit(); cpuidprint(); mmuinit(); hwintrinit(); clockinit(); kbdinit(); procinit0(); initseg(); timersinit(); links(); chandevreset(); pageinit(); swapinit(); fpsave(&initfp); initfp.fpscr = 0; userinit(); schedinit(); }
int main(void) { ioinit(); timer_init(); /* all devices initialize themselves as slaves */ USI_TWI_Slave_Initialise(TWI_BROADCAST_ADDRESS); #if WE_NEED_TO_TEST_UART /* for debugging only */ uint8_t counter = 0; while (true) { ++counter; sendUart('a' + (counter % 26)); _delay_ms(1000); } #endif /* #if WE_NEED_TO_TEST_UART */ /* loop forever */ for (;; ) { uint8_t byte = USI_TWI_Receive_Byte(); sendUart(byte); } /* we will never come here. */ return (0); }
int main (void) { int i; char testIntStr[20]; ioinit (); //USART_Transmit_String2("This is a test.."); USART_Transmit_String("How are you???"); itoa(0x23,testIntStr,16); USART_Transmit_String2(testIntStr); USART_Transmit_String2("Very well, thank you???"); USART_Transmit_String2("Very well, thank you7???"); LCD_gotoXY(0,0); LCD_Write("hello world"); //USART_Receive_String(); USART_Transmit_String2("This is what is typed in .."); USART_Transmit_String2(USART_Receive_String()); #if STATS_ENABLED USART_PrintStats(); #endif USART_Transmit_String2("Very well, thank you8???"); /* this probably is taken care of by gcc main program exit */ while(1) { asm("nop"); } return (0); }
int main(void){ char message[MAX_MESSAGE_LENGTH]; //Buffer for UART messages int uart_recv; char uart_err; char uart_char; ioinit(); sleep_enable(); set_sleep_mode(SLEEP_MODE_IDLE); sei(); message_index = 0; while(1){ uart_recv = uart_getc(); uart_err = (uart_recv & 0xff00) >> 8; uart_char = uart_recv & 0x00ff; if(!(uart_err) && message_index < MAX_MESSAGE_LENGTH && uart_char != '\r') { message[message_index++] = uart_char; } if(uart_char == '\n') { message[message_index-1]='\0'; message_index = 0; interpret_message(message); } sleep_cpu(); // we wake up when we receive a character, right? } return 0; }
int main(void) { ioinit(); for(;;) { unsigned char c = uart_getchar(); uart_putchar(c); switch(c) { case 0xfe: c = uart_getchar(); switch(c) { case 0x01: sbi(PORTB, OUT_RELAY); uart_putchar(0x11); break; case 0x02: cbi(PORTB, OUT_RELAY); uart_putchar(0x11); break; default: uart_putchar(0xee); } break; default: uart_putchar(0xee); } } return 0; }
int main() { uint8_t i = 0; uint8_t p = 0; /* initialize ports, timers, serial, and IRQ */ ioinit(); for (;;) { /* wait until OCF0A in TIFR0 enabled */ if ((TIFR0 & 0x02) == 0) { continue; } /* Clear the OCF0A flag in TIFR0 */ TIFR0 |= 0x02; /* put 2 bits from the top */ p = p >> 2; p |= (PIND & 0xc0); i++; /* print accumulated value */ if (i > 3) { putchr(p); /* clear counter */ i = 0; } } /* NOTREACHED */ return 0; }
/********************************************************* Main Code *********************************************************/ int main(void) { ioinit(); // Make sure all the pixels are working splash_screen(); // Enable Global Interrupts sei(); while (1) { if (PINB & (1 << CS)) { // If CS goes high, SPI com is complete. frame_index = 0; // Reset the frame index. } post_frames(); // Update display with current frame data. // Check to see if there is a new frame to parse. if (new_frame == 1) { parse_frame(); } // Increment clicks to determine LED brightness levels. timer_ticks = (timer_ticks + 1) & 0x07; // Circular 0 to 7 } return 0; }
void main(void) { eeprom_read_block(&config, &stored_config.config, sizeof(config_t)); ioinit(); PWM_ON(); mode_id = 0; for(;;) { switch(state) { case STATE_MENU: // Show the menu menu(); break; case STATE_NORMAL: // Run a standard function modes[mode_id].run(); break; case STATE_SLEEPING: // Go to sleep enter_sleep(); state = STATE_SLEEPY; break; case STATE_SLEEPY: // Wait to enter STATE_SLEEPING or STATE_NORMAL break; case STATE_SLAVE: // Just refresh the display break; } } }
int main (void) { ioinit(); //Boot up defaults uint8_t my_ch, x = 0; //Blinky! for(x = 0 ; x < 10 ; x++) { sbi(PORTB, STATUS_LED); delay_ms(200); cbi(PORTB, STATUS_LED); delay_ms(200); } printf("\n\r FOTAA \n\r"); while(1) { my_ch = getch(); if(my_ch == 'r'){ printf("Request auto reset \n"); } else printf("You pressed: %c\n\r", my_ch); } return(0); }
int main(void) { ioinit(); for (;;) { if (intbits.pwm_received) { intbits.pwm_received = 0; #if defined(__AVR_ATtiny13__) if (pwm_incoming < MIN_PWM_VAL) pwm_incoming = MIN_PWM_VAL; else if (pwm_incoming > MAX_PWM_VAL) pwm_incoming = MAX_PWM_VAL; OCR0B = (pwm_incoming - MIN_PWM_VAL) * 255ul / (MAX_PWM_VAL - MIN_PWM_VAL); #else OCR0B = (pwm_incoming - MIN_PWM_VAL) * 255u / (MAX_PWM_VAL - MIN_PWM_VAL); #endif GIFR = (1 << PCIF); GIMSK |= (1 << PCIE); } sleep_mode(); } }
void main(void) { cgapost(0); mach0init(); options(); ioinit(); i8250console(); quotefmtinstall(); screeninit(); print("\nPlan 9\n"); trapinit0(); mmuinit0(); kbdinit(); i8253init(); cpuidentify(); meminit(); confinit(); archinit(); if(!isa20on()) panic("bootstrap didn't leave a20 address line enabled"); xinit(); if(i8237alloc != nil) i8237alloc(); trapinit(); printinit(); cpuidprint(); mmuinit(); fpsavealloc(); if(arch->intrinit) /* launches other processors on an mp */ arch->intrinit(); timersinit(); mathinit(); kbdenable(); if(arch->clockenable) arch->clockenable(); procinit0(); initseg(); if(delaylink){ bootlinks(); pcimatch(0, 0, 0); }else links(); conf.monitor = 1; chandevreset(); cgapost(0xcd); pageinit(); i8253link(); swapinit(); userinit(); active.thunderbirdsarego = 1; cgapost(0x99); schedinit(); }
void main(void) { ioinit(); PWM_ON(); while(1) sleep_mode(); }
int main (void) { ioinit (); /* loop forever, the interrupts are doing the rest */ for (;;) /* Note [7] */ sleep_mode(); return (0); }
int main(void) { _delay_ms(500); uint8_t data_buf[8]; ioinit(); uartinit(); can_init(0); pwm16Init2(); adcInit(1); st_cmd_t rpm_msg; counter0Init(); _delay_ms(500); sei(); sendtekst("\n\rUnicorn Gearnode v1.0 \n\r"); //rpm_msg.pt_data = rpm_response_buffer; //rpm_msg.status = 0; //can_update_rx_msg(&rpm_msg, rpm_msgid, 8); can_update_rx_msg(&rpm_msg, gear_msgid, 8); Can_sei(); Can_set_tx_int(); Can_set_rx_int(); while(1) { _delay_ms(100); data_buf[0] = GearNeutral; data_buf[1] = GEARNEUTRALMEAS; data_buf[2] = 0; can_send_non_blocking(gear_msgid, data_buf, 3); data_buf[0] = GearEst; data_buf[1] = 0; data_buf[2] = GearEst_val; can_send_non_blocking(rpm_msgid, data_buf, 3); /* gearUp(); gearUp(); gearUp(); gearUp(); gearDown(); gearDown(); gearDown(); gearDown(); */ } return 0; }
void kernel_init(void) { /* call ioinit to initialize io package/possibly kernel_init */ ioinit(); /* call trap gate with correct parameters to initialize trap */ set_trap_gate(0x80, &syscall); /* call main, ref to suggested steps in hw2 eventually ustart */ ustart(); return; }
int main(void) { unsigned char i, chksum; ioinit(); init_SPI(); sbi(CSPORT,CS); printf("********RFM22 Communication Test********\n"); //====================// //Communications Test printf("Reading DTYPE register, should be 0x08: %d", read(DTYPE)); printf("\n*****************************************\n\n"); init_RFM22(); // Initialize all RFM22 registers printf("Entering RX Mode...\n"); to_rx_mode(); while(1) { if((PIND & (1<<NIRQ)) == 0) //Interrupt will be generated if data is recieved { // Read 18-byte packet into RF_RXBUF[]: for(i=0; i<17; i++) { RF_RXBUF[i] = read(0x7F); } // Check that the checksum matches up: chksum = 0; for(i=0; i<16; i++) chksum += RF_RXBUF[i]; // If checksum is good, print out what was received into the terminal if(chksum == RF_RXBUF[16]) { write(0x07, 0x01); // To ready mode printf("Received: "); for(i=0; i<17; i++) printf("%c", RF_RXBUF[i]); // Print characters if passed the checksum printf("\n"); //printf("To Ready mode\n"); } // otherwise reset and start listening again else { rx_reset(); //printf("Bad checksum RX RESET...Listening again\n"); } delay_ms(50); } } }
//! Initialize the STM32F4xx ports and USB. void stm32f4xx_init() { int i=20; SystemInit(); ioinit(); usartinit(); while(i--) stmdelay(); return; }
int main (void) { uint32_t x = 0; ioinit(); //Setup IO pins and defaults printf("Tests Starting.\r\n"); return(0); }
int main() { ioinit(); timer2_init(); timer2_overflow_hook = timer2_hook; timer1_init(); _delay_ms(100); spi_init(); sound_reset(); usart_init(1);// usart_init(23); // 9600bps spdif_configure(); ad1955_configure(); ad1955_mute(); #define NO_NOISE_MEASURE #ifdef NOISE_MEASURE ad1955_unmute(); cli(); set_sleep_mode(SLEEP_MODE_PWR_DOWN); for(;;) { sleep_mode(); } #endif spdif_selectChannel(1); spdif_dumpRegisters(); printf("\n\nSVODAC V%s\n", idstring); for (;;) { if (main_state_machine() == STATE_READY) { if ((REQUEST_STATUS & _BV(REQUEST_MUTE)) != 0) { ad1955_mute(); } else if ((REQUEST_STATUS & _BV(REQUEST_UNMUTE)) != 0) { ad1955_unmute(); } if ((REQUEST_STATUS & _BV(REQUEST_STOP)) != 0) { //printf("STOP"); spdif_stop(); } else if ((REQUEST_STATUS & _BV(REQUEST_RUN)) != 0) { //printf("RUN"); spdif_run(); } REQUEST_STATUS = 0; sleep_mode(); } } return 0; // make happy }
int main (void) { ioinit(); //Boot up defaults while(1) { check_buttons(); //See if we need to set the time or snooze check_alarm(); //See if the current time is equal to the alarm time } return(0); }
int main(void) { ioinit(); data_init(); timer_init(); usart_init(); sei(); for (;;) { uint8_t command = data_buffer.read_w(); switch (command & 0xf0) { case 0xA0: // fade with a given timeout to new values fade( command & 0x03 , data_buffer.read_w()); break; case 0xB0: // program startup values for a spot set_initial_values( command & 0x01); break; case 0xC0: // hold all transitions. hold_transitions = true; break; case 0xD0: // resume transitions pwm_cycle_counter = 255; // make sure there is a transition shortly after enabling them. hold_transitions = false; break; case 0xE0: // set new color fade( command & 0x03, 0); break; case 0xF0: // program a new device address set_address(); break; case 0x90: // wait for a fader to complete wait_for_fader( command & 0x01); break; default: // ignore anything else break; } } return 0; }
int main(void) { uint8_t i; char buf[20], s[20]; ioinit(); stdout = stdin = &uart_str; stderr = &lcd_str; fprintf(stderr, "Hello world!\n"); for (;;) { printf_P(PSTR("Enter command: ")); if (fgets(buf, sizeof buf - 1, stdin) == NULL) break; if (tolower(buf[0]) == 'q') break; switch (tolower(buf[0])) { default: printf("Unknown command: %s\n", buf); break; case 'l': if (sscanf(buf, "%*s %s", s) > 0) { fprintf(&lcd_str, "Got %s\n", s); printf("OK\n"); } else { printf("sscanf() failed\n"); } break; case 'u': if (sscanf(buf, "%*s %s", s) > 0) { fprintf(&uart_str, "Got %s\n", s); printf("OK\n"); } else { printf("sscanf() failed\n"); } break; } } fprintf(stderr, "Bye-bye"); delay_1s(); for (i = 0; i < 3; i++) { putc('.', stderr); delay_1s(); } fprintf(stderr, "\n "); return 0; }
int main(void) { ioinit(); /* stderr = stdout = stdin = &uart_str; */ uart_puts_p(PSTR("Welcome to the DR - CLI\n\rType help!\n\r")); /* everything should be triggered by Timer0 */ for (;;) ; return 0; }
int main (void) { ioinit(); //Setup IO pins and defaults // seven_seg_diags(); do_launch_program(); // launch_diags(); // launch_cfg_diags(); return (0); }
int main (void) { char current_message=0; //Indicates which string we should be displaying char change_message=1; //Flag to notify firmware we've finished displaying the current message and we need to get the next one char *message='\0'; //Pointer to the string we want to display ioinit(); //Boot up defaults and configure Bluetooth connection while(1){ //Check to see if we need to get a new message to display if(change_message){ change_message=0; //Reset the flag //Grab the appropriate message if(current_message==0)message=&message_1[0]; if(current_message==1)message=&message_2[0]; if(current_message==2)message=&message_3[0]; } //Each time through this loop, we'll send an image to the RGB backpack. The scroll index will tell put_char() the row index of character start position on the matrix //After running through the entirety of this loop, the current message character will have scrolled across the RGB matrix one row at a time, and the //next character will currently be on the matrix. for(int scroll_index=-1; scroll_index >=-8; scroll_index--){ //Put the current character, offset by scroll_index, into the frame_data[] buffer putchar_frame(message, scroll_index, text_color); cbi(PORTB, CS); //Putting the CS line low will start the communication sequence for(int LED=0; LED<64; LED++){ //Send 64 bytes to the RGB serial backpack. One byte is sent for each LED. The format of the byte is RRRGGGBB. spi_exch(frame_data[LED]); //*See ioinit() for SPI Hardware Setup } sbi(PORTB, CS); //Setting the CS line high will terminate the communication sequence. delay_ms(10); //Pause before sending the next set of data } //If we've reached the end of the current message, it's time to get the next one if(*(message+1)=='\0'){ current_message+=1; if(current_message==3)current_message=0; change_message=1; } //If we haven't reached the end of the current message, increment to get the next character else message+=1; } while(1); return (0); }
//====================== int main (void) { ioinit(); //Setup IO pins and defaults while (1) { if(bit_is_set(PINC,4)) // Check IR module is sensed or not { _delay_ms(1000); led_on(); //turn on the led _delay_ms(20000);//wait a while led_off(); //turn on the led } } }
int main (void) { uint8_t i = 0; uint8_t j = 0; char read = 0; char command[COMMAND_LENGTH]; uint8_t commandPosition = 0; uint8_t checksum = 0; for (i = 0; i < SERVO_COUNT; i++) { servopos[i] = 100; } sei(); servo_init(); ioinit(); while (1) { read = uart_getchar(); command[commandPosition] = read; checksum += read; if (read == 0) { if (checksum == 0) { // Handle command switch (command[0]) { case 0x01: setServo(command[1], command[2]); break; case 0x02: getServo(command[1]); break; } } else { // Command error uart_putchar(0xFF); } checksum = 0; commandPosition = 0; } else { commandPosition++; } } return 0; }