9 void usb_init(void); // initialize everything
10 uint8_t usb_configured(void); // is the USB port configured
11 void usb_remote_wakeup(void);
16 #define EP_TYPE_CONTROL 0x00
17 #define EP_TYPE_BULK_IN 0x81
18 #define EP_TYPE_BULK_OUT 0x80
19 #define EP_TYPE_INTERRUPT_IN 0xC1
20 #define EP_TYPE_INTERRUPT_OUT 0xC0
21 #define EP_TYPE_ISOCHRONOUS_IN 0x41
22 #define EP_TYPE_ISOCHRONOUS_OUT 0x40
24 #define EP_SINGLE_BUFFER 0x02
25 #define EP_DOUBLE_BUFFER 0x06
27 #define EP_SIZE(s) ((s) == 64 ? 0x30 : \
32 #define MAX_ENDPOINT 4
34 #define LSB(n) (n & 255)
35 #define MSB(n) ((n >> 8) & 255)
37 #if defined(__AVR_AT90USB162__)
39 #define PLL_CONFIG() (PLLCSR = ((1<<PLLE)|(1<<PLLP0)))
40 #define USB_CONFIG() (USBCON = (1<<USBE))
41 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
42 #elif defined(__AVR_ATmega32U4__)
43 #define HW_CONFIG() (UHWCON = 0x01)
44 #define PLL_CONFIG() (PLLCSR = 0x12)
45 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
46 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
47 #elif defined(__AVR_AT90USB646__)
48 #define HW_CONFIG() (UHWCON = 0x81)
49 #define PLL_CONFIG() (PLLCSR = 0x1A)
50 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
51 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
52 #elif defined(__AVR_AT90USB1286__)
53 #define HW_CONFIG() (UHWCON = 0x81)
54 #define PLL_CONFIG() (PLLCSR = 0x16)
55 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
56 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
59 // standard control endpoint request types
61 #define CLEAR_FEATURE 1
64 #define GET_DESCRIPTOR 6
65 #define GET_CONFIGURATION 8
66 #define SET_CONFIGURATION 9
67 #define GET_INTERFACE 10
68 #define SET_INTERFACE 11
69 // HID (human interface device)
70 #define HID_GET_REPORT 1
71 #define HID_GET_IDLE 2
72 #define HID_GET_PROTOCOL 3
73 #define HID_SET_REPORT 9
74 #define HID_SET_IDLE 10
75 #define HID_SET_PROTOCOL 11
76 #define HID_REPORT_INPUT 1
77 #define HID_REPORT_OUTPUT 2
78 #define HID_REPORT_FEATURE 3
79 // CDC (communication class device)
80 #define CDC_SET_LINE_CODING 0x20
81 #define CDC_GET_LINE_CODING 0x21
82 #define CDC_SET_CONTROL_LINE_STATE 0x22
83 // HID feature selectors
84 #define DEVICE_REMOTE_WAKEUP 1
85 #define ENDPOINT_HALT 0
89 extern bool remote_wakeup;