// Check to see if a usb cable has been plugged in
// XXX Not tested (also, not currently needed) -HaaTa
//if ( USB0_STAT & (1 << 1)
- // return 0;
+ // return 0;
HW_CONFIG();
- USB_FREEZE(); // enable USB
- PLL_CONFIG(); // config PLL
- while (!(PLLCSR & (1<<PLOCK))) ; // wait for PLL lock
- USB_CONFIG(); // start USB clock
- UDCON = 0; // enable attach resistor
+ USB_FREEZE(); // enable USB
+ PLL_CONFIG(); // config PLL
+ while (!(PLLCSR & (1<<PLOCK))) ; // wait for PLL lock
+ USB_CONFIG(); // start USB clock
+ UDCON = 0; // enable attach resistor
usb_configuration = 0;
- UDIEN = (1<<EORSTE) | (1<<SOFE);
+ UDIEN = (1<<EORSTE) | (1<<SOFE);
sei();
// Disable watchdog timer after possible software reset
{
uint8_t intbits, t_cdc;
- intbits = UDINT;
- UDINT = 0;
- if ( intbits & (1 << EORSTI) )
+ intbits = UDINT;
+ UDINT = 0;
+ if ( intbits & (1 << EORSTI) )
{
UENUM = 0;
UECONX = 1;
UEIENX = (1 << RXSTPE);
usb_configuration = 0;
cdc_line_rtsdtr = 0;
- }
+ }
if ( (intbits & (1 << SOFI)) && usb_configuration )
{
t_cdc = transmit_flush_timer;
//
ISR( USB_COM_vect )
{
- uint8_t intbits;
+ uint8_t intbits;
const uint8_t *list;
- const uint8_t *cfg;
+ const uint8_t *cfg;
uint8_t i, n, len, en;
uint8_t *p;
uint8_t bmRequestType;
uint16_t wLength;
uint16_t desc_val;
const uint8_t *desc_addr;
- uint8_t desc_length;
+ uint8_t desc_length;
- UENUM = 0;
+ UENUM = 0;
intbits = UEINTX;
if (intbits & (1<<RXSTPI))
{
- bmRequestType = UEDATX;
- bRequest = UEDATX;
- wValue = UEDATX;
- wValue |= (UEDATX << 8);
- wIndex = UEDATX;
- wIndex |= (UEDATX << 8);
- wLength = UEDATX;
- wLength |= (UEDATX << 8);
- UEINTX = ~((1<<RXSTPI) | (1<<RXOUTI) | (1<<TXINI));
-
- if ( bRequest == GET_DESCRIPTOR )
+ bmRequestType = UEDATX;
+ bRequest = UEDATX;
+ wValue = UEDATX;
+ wValue |= (UEDATX << 8);
+ wIndex = UEDATX;
+ wIndex |= (UEDATX << 8);
+ wLength = UEDATX;
+ wLength |= (UEDATX << 8);
+ UEINTX = ~((1<<RXSTPI) | (1<<RXOUTI) | (1<<TXINI));
+
+ if ( bRequest == GET_DESCRIPTOR )
{
list = (const uint8_t *)descriptor_list;
for ( i = 0; ; i++ )
do {
i = UEINTX;
} while (!(i & ((1<<TXINI)|(1<<RXOUTI))));
- if (i & (1<<RXOUTI)) return; // abort
+ if (i & (1<<RXOUTI)) return; // abort
// send IN packet
n = len < ENDPOINT0_SIZE ? len : ENDPOINT0_SIZE;
for (i = n; i; i--) {
usb_send_in();
} while (len || n == ENDPOINT0_SIZE);
return;
- }
+ }
if (bRequest == SET_ADDRESS) {
usb_send_in();
UECFG1X = pgm_read_byte(cfg++);
}
}
- UERST = 0x7E;
- UERST = 0;
+ UERST = 0x7E;
+ UERST = 0;
return;
}
}
}
}
- UECONX = (1 << STALLRQ) | (1 << EPEN); // stall
+ UECONX = (1 << STALLRQ) | (1 << EPEN); // stall
}