//init
Code: Select all
static void usbReset(void)
{
usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */
uchar i = 0;
while(--i)
{ // USB disconnect for >250ms
_delay_ms(1);
};
usbDeviceConnect();
}
cli();
sreg = SREG;
usbInit();
usbReset();
SREG = sreg;
sei();
//main loop
makeReport();
while (!usbInterruptIsReady()){usbPoll(); } usbSetInterrupt( reportBuffer, 8);
Now I have noticed there is a bit of a rocky start, usb reset kinda bumpy, and even ( very seldom ) the usb drops out during use. It has not been a big deal but I'd like to clean it up. I have seen people use the timers and the watch dog but what is really needed here. Can anyone give me a very minimal basic usb init and loop? I'm not using the mega8 but instead the 328 so the timers are not the same.