Advertisement
Guest User

VUSBissuemain

a guest
Oct 21st, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <avr/interrupt.h>
  3. #include <avr/wdt.h>
  4.  
  5. #include "usbdrv.h"
  6.  
  7. #define F_CPU 16000000L
  8. #include <util/delay.h>
  9.  
  10. USB_PUBLIC uchar usbFunctionSetup(uchar data[8]) {
  11.         return 0; // do nothing for now
  12. }
  13.  
  14. int main() {
  15.         uchar i;
  16.  
  17.     wdt_enable(WDTO_1S); // enable 1s watchdog timer
  18.  
  19.     usbInit();
  20.  
  21.     usbDeviceDisconnect(); // enforce re-enumeration
  22.     for(i = 0; i<250; i++) { // wait 500 ms
  23.         wdt_reset(); // keep the watchdog happy
  24.         _delay_ms(2);
  25.     }
  26.     usbDeviceConnect();
  27.  
  28.     sei(); // Enable interrupts after re-enumeration
  29.  
  30.     while(1) {
  31.         wdt_reset(); // keep the watchdog happy
  32.         usbPoll();
  33.     }
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement