7 void usb_init(void); // initialize everything
8 uint8_t usb_configured(void); // is the USB port configured
10 int8_t usb_keyboard_press(uint8_t key, uint8_t modifier);
11 int8_t usb_keyboard_send(void);
14 int8_t usb_debug_putchar(uint8_t c); // transmit a character
15 void usb_debug_flush_output(void); // immediately transmit any buffered output
19 // Everything below this point is only intended for usb_serial.c
20 #ifdef USB_SERIAL_PRIVATE_INCLUDE
22 #include <avr/pgmspace.h>
23 #include <avr/interrupt.h>
25 #define EP_TYPE_CONTROL 0x00
26 #define EP_TYPE_BULK_IN 0x81
27 #define EP_TYPE_BULK_OUT 0x80
28 #define EP_TYPE_INTERRUPT_IN 0xC1
29 #define EP_TYPE_INTERRUPT_OUT 0xC0
30 #define EP_TYPE_ISOCHRONOUS_IN 0x41
31 #define EP_TYPE_ISOCHRONOUS_OUT 0x40
33 #define EP_SINGLE_BUFFER 0x02
34 #define EP_DOUBLE_BUFFER 0x06
36 #define EP_SIZE(s) ((s) == 64 ? 0x30 : \
41 #define MAX_ENDPOINT 4
43 #define LSB(n) (n & 255)
44 #define MSB(n) ((n >> 8) & 255)
46 #if defined(__AVR_AT90USB162__)
48 #define PLL_CONFIG() (PLLCSR = ((1<<PLLE)|(1<<PLLP0)))
49 #define USB_CONFIG() (USBCON = (1<<USBE))
50 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
51 #elif defined(__AVR_ATmega32U4__)
52 #define HW_CONFIG() (UHWCON = 0x01)
53 #define PLL_CONFIG() (PLLCSR = 0x12)
54 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
55 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
56 #elif defined(__AVR_AT90USB646__)
57 #define HW_CONFIG() (UHWCON = 0x81)
58 #define PLL_CONFIG() (PLLCSR = 0x1A)
59 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
60 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
61 #elif defined(__AVR_AT90USB1286__)
62 #define HW_CONFIG() (UHWCON = 0x81)
63 #define PLL_CONFIG() (PLLCSR = 0x16)
64 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
65 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
68 // standard control endpoint request types
70 #define CLEAR_FEATURE 1
73 #define GET_DESCRIPTOR 6
74 #define GET_CONFIGURATION 8
75 #define SET_CONFIGURATION 9
76 #define GET_INTERFACE 10
77 #define SET_INTERFACE 11
78 // HID (human interface device)
79 #define HID_GET_REPORT 1
80 #define HID_GET_IDLE 2
81 #define HID_GET_PROTOCOL 3
82 #define HID_SET_REPORT 9
83 #define HID_SET_IDLE 10
84 #define HID_SET_PROTOCOL 11
85 // CDC (communication class device)
86 #define CDC_SET_LINE_CODING 0x20
87 #define CDC_GET_LINE_CODING 0x21
88 #define CDC_SET_CONTROL_LINE_STATE 0x22