/** Main program entry point. This routine contains the overall program flow, including initial * setup of all components and the main program loop. */ int main(void) { SetupHardware(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); sei(); for (;;) { HID_Device_USBTask(&Keyboard_HID_Interface); USB_USBTask(); } }
/** Main program entry point. This routine contains the overall program flow, including initial * setup of all components and the main program loop. */ int main(void) { SetupHardware(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) { HID_Device_USBTask(&Generic_HID_Interface); USB_USBTask(); } }
/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously * runs the bootloader processing routine until it times out or is instructed to exit. */ int main(void) { /* Save the value of the boot key memory before it is overwritten */ uint16_t bootKeyPtrVal = *bootKeyPtr; *bootKeyPtr = 0; /* Check the reason for the reset so we can act accordingly */ uint8_t mcusr_state = MCUSR; // store the initial state of the Status register MCUSR = 0; // clear all reset flags /* Watchdog may be configured with a 15 ms period so must disable it before going any further */ wdt_disable(); if (mcusr_state & (1<<EXTRF)) { // External reset - we should continue to self-programming mode. } else if ((mcusr_state & (1<<PORF)) && (pgm_read_word(0) != 0xFFFF)) { // After a power-on reset skip the bootloader and jump straight to sketch // if one exists. StartSketch(); } else if ((mcusr_state & (1<<WDRF)) && (bootKeyPtrVal != bootKey) && (pgm_read_word(0) != 0xFFFF)) { // If it looks like an "accidental" watchdog reset then start the sketch. StartSketch(); } _delay_ms(250); /* Setup hardware required for the bootloader */ SetupHardware(); /* Enable global interrupts so that the USB stack can function */ sei(); Timeout = 0; while (RunBootloader) { CDC_Task(); USB_USBTask(); /* Time out and start the sketch if one is present */ if (Timeout > TIMEOUT_PERIOD) RunBootloader = false; LEDPulse(); } /* Disconnect from the host - USB interface will be reset later along with the AVR */ USB_Detach(); /* Jump to beginning of application space to run the sketch - do not reset */ StartSketch(); }
/** Main program entry point. This routine contains the overall program flow, including initial * setup of all components and the main program loop. */ int main(void) { SetupHardware(); /* Create a regular character stream for the interface so that it can be used with the stdio.h functions */ CDC_Device_CreateStream(&VirtualSerial_CDC_Interface, &USBSerialStream); sei(); DDRB |= (1 << 4); PORTB |= (1 << 4); for (;;) { int16_t c = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); if (c > 0){ switch (c) { case '1': // this will eventually be to strobe the modem on pin of a telit module // set port to output mode and low state // stall for 1000 ms // set port back to high impedance CDC_Device_SendString(&VirtualSerial_CDC_Interface, "received 1\r\n"); DDRD |= (1 << 0); PORTD &= ~(1 << 0); _delay_ms(1000); DDRD &= ~(1 << 0); PORTD |= (1 << 0); break; case 'r': // this will be to strobe the reset pin of a telit module CDC_Device_SendString(&VirtualSerial_CDC_Interface, "received r\r\n"); PORTB &= ~(1 << 4); _delay_ms(200); PORTB |= (1 << 4); break; case '?': // this wil be to inquire abouth the powermon pin of a telit module CDC_Device_SendString(&VirtualSerial_CDC_Interface, "received ?\r\n"); PORTB |= ~(1 << 4); break; default: CDC_Device_SendString(&VirtualSerial_CDC_Interface, "unrecognized input\r\n"); } } CDC_Device_USBTask(&VirtualSerial_CDC_Interface); USB_USBTask(); } }
int main(void) { SetupHardware(); TCCR1B |= (1 << CS10); sei(); memset(inputs, 0, sizeof(inputs)); unsigned long tick = 0; for (;;) { if (TCNT1 >= 1000) { tick++; } //MIDI_EventPacket_t ReceivedMIDIEvent; /*while (MIDI_Device_ReceiveEventPacket(&Keyboard_MIDI_Interface, &ReceivedMIDIEvent)) { }*/ int inputPins[4] = { 0b00000010, 0b00001000, 0b00100000, 0b10000000 }; int port; int current; unsigned long currentTime; for (int i=0; i<8; i++) { port = (i<4) ? PIND : PINB; current = i%4; if (port & inputPins[current]) { if (!inputs[i].pressed && tick > inputs[i].lastOn) { inputs[i].pressed = true; inputs[i].on = !inputs[i].on; inputs[i].lastOn = tick; // Send midi stuff sendMidiNote(i, inputs[i].on); } } else { inputs[i].pressed = false; //sendMidiNote(i, false); } } MIDI_Device_USBTask(&tbase8_MIDI_Interface); USB_USBTask(); } return 0; }
int main(void) { MCUSR &= ~(1 << WDRF); wdt_disable(); clock_prescale_set(clock_div_1); USB_Init(); PORTD |= _BV(PORTD5) | _BV(PORTD6) | _BV(PORTD7); // pull up sei(); for (;;) { HID_Device_USBTask(&stateMachine); USB_USBTask(); } }
int main(void) { hardwareInit(); initLEDs(); setOutputBit(&kOrangeLED, 1); sei(); USB_Init(); while (1) { HID_Device_USBTask(&mouseHIDInterface); USB_USBTask(); } }
int main(int argc, const char *argv[]) { clock_prescale_set(clock_div_1); MCUSR &= ~(1 << WDRF); wdt_disable(); timer_init(); RFID_Init(); USB_Init(); sei(); while (1) { RFID_Task(); USB_USBTask(); } }
int main (void) { uint32_t tmp_bulk_reset; MCUSR &= ~(1u << WDRF); wdt_disable(); clock_prescale_set(clock_div_1); board_init(); USB_Init(); vue_write_address_full(VUE_CART_READER_nSTATUS | VUE_nROM_CE | VUE_nRAM_CS | VUE_nES); sei(); while (true) { USB_USBTask(); tmp_bulk_reset = bulk_reset; VUE_Task(); if (tmp_bulk_reset) { /* write default state */ VUE_CTRL->out |= VUE_nOE | VUE_nUWR | VUE_nLWR; VUE_CTRL->out &= ~VUE_CART_READER_PL; vue_write_address_full(VUE_CART_READER_nSTATUS | VUE_nROM_CE | VUE_nRAM_CS | VUE_nES); /* Reset FSM */ cur_vue_state = IDLE; /* Clear Endpoints */ Endpoint_ResetEndpoint(VUE_CART_READER_OUT_EP_ADDR); Endpoint_ResetEndpoint(VUE_CART_READER_IN_EP_ADDR); Endpoint_SelectEndpoint(VUE_CART_READER_OUT_EP_ADDR); Endpoint_ClearStall(); Endpoint_ResetDataToggle(); Endpoint_SelectEndpoint(VUE_CART_READER_IN_EP_ADDR); Endpoint_ClearStall(); Endpoint_ResetDataToggle(); Endpoint_AbortPendingIN(); bulk_reset = 0x00000000ul; } } }
/** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ int main(void) { SetupHardware(); puts_P(PSTR(ESC_FG_CYAN "RNDIS Host Demo running.\r\n" ESC_FG_WHITE)); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); for (;;) { RNDIS_Host_Task(); USB_USBTask(); } }
/** Main program entry point. This routine contains the overall program flow, including initial * setup of all components and the main program loop. */ int main(void) { SetupHardware(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) { MS_Device_USBTask(&Disk_MS_Interface); HID_Device_USBTask(&Keyboard_HID_Interface); USB_USBTask(); } }
/** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ char keyboard(void) { char tecla; SetupHardwareKeyboard(); do { tecla = KeyboardHost_Task(); HID_Host_USBTask(&Keyboard_Host_HID_Interface); USB_USBTask(); } while (tecla != 'D'); return tecla; }
/** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ int main(void) { SetupHardware(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); sei(); for (;;) { Keyboard_HID_Task(); Mouse_HID_Task(); USB_USBTask(); } }
/** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ int main(void) { SetupHardware(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) { Keyboard_HID_Task(); Mouse_HID_Task(); USB_USBTask(); } }
/** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ int main(void) { SetupHardware(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); sei(); for (;;) { CDC1_Task(); CDC2_Task(); USB_USBTask(); } }
/** Main program entry point. This routine contains the overall program flow, including initial * setup of all components and the main program loop. */ int main(void) { HidApp_Init(); GlobalInterruptEnable(); for (;;) { HID_Device_USBTask(&Generic_HID_Interface); USB_USBTask(); Encoder_Task(); Leds_Task(); } }
/** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ int main(void) { SetupHardware(); puts_P(PSTR(ESC_FG_CYAN "Audio Output Host Demo running.\r\n" ESC_FG_WHITE)); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); sei(); for (;;) { USB_USBTask(); } }
/** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ int main(void) { SetupHardware(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) { CDC1_Task(); CDC2_Task(); USB_USBTask(); } }
static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) { Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address); while (Endpoint_IsStalled()) { #if !defined(INTERRUPT_CONTROL_ENDPOINT) USB_USBTask(); #endif if (MSInterfaceInfo->State.IsMassStoreReset) return; } Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address); while (Endpoint_IsStalled()) { #if !defined(INTERRUPT_CONTROL_ENDPOINT) USB_USBTask(); #endif if (MSInterfaceInfo->State.IsMassStoreReset) return; } uint16_t BytesProcessed = 0; while (Endpoint_Write_Stream_LE(&MSInterfaceInfo->State.CommandStatus, sizeof(MS_CommandStatusWrapper_t), &BytesProcessed) == ENDPOINT_RWSTREAM_IncompleteTransfer) { if (MSInterfaceInfo->State.IsMassStoreReset) return; } Endpoint_ClearIN(); }
int main() { // Initialize ADC Interrupts lastTimeInterruptLeft = avr_time_now(); lastTimeInterruptRight = avr_time_now(); out_msg.deltaUmLeft = 0; out_msg.deltaUmRight = 0; // Initialize ROS nh.initNode(); nh.advertise(io_board_out); ros::Subscriber<io_to_board> sub("to_ioboard", &ioboard_cb); nh.subscribe(sub); // Do timed/repeated stuff uint32_t lastTimeOdometry = 0UL; uint32_t lastTimeRake = 0UL; while(1) { // Stop engines and raise rake, if last recieved message is older then 2s // %TODO raise rake if ((lastTimeMessage != 0) && (avr_time_now() - lastTimeMessage > 1000)) { lastTimeMessage = 0; OCR1A = 0x8000; OCR1B = 0x8000; } // Publish odometry all 40ms if (avr_time_now() - lastTimeOdometry > 40) { out_msg.timestamp = avr_time_now(); io_board_out.publish(&out_msg); out_msg.deltaUmLeft = 0; out_msg.deltaUmRight = 0; lastTimeOdometry = avr_time_now(); } nh.spinOnce(); // LUFA functions that need to be called frequently to keep USB alive CDC_Device_USBTask(&Atmega32u4Hardware::VirtualSerial_CDC_Interface); USB_USBTask(); } return 0; }
/** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ int main(void) { SetupHardware(); puts_P(PSTR(ESC_FG_CYAN "Keyboard HID Host Demo running.\r\n" ESC_FG_WHITE)); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); sei(); for (;;) { Keyboard_HID_Task(); USB_USBTask(); } }
static int CDC_Device_getchar_Blocking(FILE* Stream) { int16_t ReceivedByte; while ((ReceivedByte = CDC_Device_ReceiveByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream))) < 0) { if (USB_DeviceState == DEVICE_STATE_Unattached) return _FDEV_EOF; CDC_Device_USBTask((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream)); USB_USBTask(); } return ReceivedByte; }
/** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ int main(void) { SetupHardware(); puts_P(PSTR(ESC_FG_CYAN "Android Accessory Host Demo running.\r\n" ESC_FG_WHITE)); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); sei(); for (;;) { AndroidHost_Task(); USB_USBTask(); } }
void sendCDCbyte(uint8_t b){ //TODO improve this // try to send until sucess while (CDC_Device_SendByte(&VirtualSerial_CDC_Interface, b) != ENDPOINT_READYWAIT_NoError){ CDC_Device_USBTask(&VirtualSerial_CDC_Interface); USB_USBTask(); while (1){ // TODO remove this freezing loop! LEDs_TurnOnLEDs(LEDS_ERR); _delay_ms(100); LEDs_TurnOnLEDs(LEDS_ERR); _delay_ms(100); } } }
/** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ int main(void) { SetupHardware(); puts_P(PSTR(ESC_FG_CYAN "Audio Input Host Demo running.\r\n" ESC_FG_WHITE)); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) { Audio_Host_USBTask(&Microphone_Audio_Interface); USB_USBTask(); } }
static int AOA_Host_getchar_Blocking(FILE* Stream) { int16_t ReceivedByte; while ((ReceivedByte = AOA_Host_ReceiveByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream))) < 0) { if (USB_HostState == HOST_STATE_Unattached) return _FDEV_EOF; AOA_Host_USBTask((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream)); USB_USBTask(); } return ReceivedByte; }
/** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ int main(void) { SetupHardware(); puts_P(PSTR(ESC_FG_CYAN "Joystick HID Parser Host Demo running.\r\n" ESC_FG_WHITE)); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); sei(); for (;;) { Joystick_HID_Task(); USB_USBTask(); } }
/** ISR for the general Pipe/Endpoint interrupt vector. This ISR fires when a control request has been issued to the control endpoint, * so that the request can be processed. As several elements of the Mass Storage implementation require asynchronous control requests * (such as endpoint stall clearing and Mass Storage Reset requests during data transfers) this is done via interrupts rather than * polling. */ ISR(ENDPOINT_PIPE_vect, ISR_BLOCK) { /* Check if the control endpoint has received a request */ if (Endpoint_HasEndpointInterrupted(ENDPOINT_CONTROLEP)) { /* Clear the endpoint interrupt */ Endpoint_ClearEndpointInterrupt(ENDPOINT_CONTROLEP); /* Process the control request */ USB_USBTask(); /* Handshake the endpoint setup interrupt - must be after the call to USB_USBTask() */ USB_INT_Clear(ENDPOINT_INT_SETUP); } }
/********************************************************** * Main function **********************************************************/ int main(void){ //initialize initialize(); //main loop while (1) { /**LUFA usb related tasks*/ HID_Device_USBTask(&Keyboard_HID_Interface); USB_USBTask(); } return 0; }
void usb_task(void) { //CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); // uint16_t got = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); // if (got > 0) { // CDC_Device_SendByte(&VirtualSerial_CDC_Interface, got &0xFF); // CDC_Device_Flush(&VirtualSerial_CDC_Interface); // } // CDC_Device_USBTask(&serial_device); MS_Device_USBTask(&ms_device); HID_Device_USBTask(&keyboard_device); USB_USBTask(); }