#include "usb.h" #include "SPIPrinting.h" #include "usbconfig.h" #include #include #define NOOP asm volatile("nop" ::) //unsigned char USB_Initialized; volatile char USBInitState; // zero when we are not configured, non-zero when enumerated static volatile uint8_t usb_configuration=0; void USB_ZeroPrescaler() { CLKPR=0x80; CLKPR=0x00; } //Hacky mcHackerson: //Reroute PC5, PCINT9, OC.1B to itself. //Alternatively: OC.0B to itself. //volatile register uint8_t speedytail asm("r4"); /* ISR( PCINT1_vect, ISR_NAKED ) { speedytail++; reti(); } */ /* ISR( INT0_vect, ISR_NAKED ) { speedytail++; reti(); } */ void USB_Init() { USBInitState = -1; USBCON = (1<= NUM_DESC_LIST) { UECONX = (1< desc_length) len = desc_length; do { // wait for host ready for IN packet do { i = UEINTX; } while (!(i & ((1<Host { // wait for host ready for IN packet do { i = UEINTX; } while (!(i & ((1<>=1; } if( (i & 63) == 0 ) _delay_us(4); } */ //wLength = 1537? #define SEND_WS( var ) \ mask = 0x80; \ v = var; \ while( mask ) \ { \ if( mask & v ) \ { \ PORTD |= _BV(3); mask>>=1; \ NOOP; NOOP; NOOP; NOOP; \ NOOP; NOOP; NOOP; NOOP; \ PORTD &= ~_BV(3); \ } \ else \ { \ PORTD |= _BV(3); NOOP; \ PORTD &= ~_BV(3); \ mask>>=1; NOOP; \ } \ \ } uint8_t s2, s3, s4, s5, s6, s7; volatile register uint8_t s1 asm("r4"); volatile register uint8_t s8 asm("r5"); // volatile register uint8_t mask asm("r6"); // volatile register uint8_t mask asm("r7"); l = wLength>>3; int remainder = wLength & 7; for( i = 0; i < l; i++ ) { s1 = UEDATX; s2 = UEDATX; s3 = UEDATX; s4 = UEDATX; s5 = UEDATX; s6 = UEDATX; s7 = UEDATX; s8 = UEDATX; usb_ack_out(); SEND_WS(s1); SEND_WS(s2); SEND_WS(s3); SEND_WS(s4); SEND_WS(s5); SEND_WS(s6); SEND_WS(s7); SEND_WS(s8); usb_wait_receive_out(); // while (!(UEINTX & (1<