6 void usb_init(void); // initialize everything
7 uint8_t usb_configured(void); // is the USB port configured
9 int8_t usb_keyboard_press(uint8_t key, uint8_t modifier);
10 int8_t usb_keyboard_send(void);
11 extern uint8_t keyboard_modifier_keys;
12 extern uint8_t keyboard_keys[6];
13 extern volatile uint8_t keyboard_leds;
15 int8_t usb_debug_putchar(uint8_t c); // transmit a character
16 void usb_debug_flush_output(void); // immediately transmit any buffered output
20 #define KEY_SHIFT 0x02
23 #define KEY_LEFT_CTRL 0x01
24 #define KEY_LEFT_SHIFT 0x02
25 #define KEY_LEFT_ALT 0x04
26 #define KEY_LEFT_GUI 0x08
27 #define KEY_RIGHT_CTRL 0x10
28 #define KEY_RIGHT_SHIFT 0x20
29 #define KEY_RIGHT_ALT 0x40
30 #define KEY_RIGHT_GUI 0x80
70 #define KEY_BACKSPACE 42
75 #define KEY_LEFT_BRACE 47
76 #define KEY_RIGHT_BRACE 48
77 #define KEY_BACKSLASH 49
79 #define KEY_SEMICOLON 51
85 #define KEY_CAPS_LOCK 57
98 #define KEY_PRINTSCREEN 70
99 #define KEY_SCROLL_LOCK 71
101 #define KEY_INSERT 73
103 #define KEY_PAGE_UP 75
104 #define KEY_DELETE 76
106 #define KEY_PAGE_DOWN 78
111 #define KEY_NUM_LOCK 83
112 #define KEYPAD_SLASH 84
113 #define KEYPAD_ASTERIX 85
114 #define KEYPAD_MINUS 86
115 #define KEYPAD_PLUS 87
116 #define KEYPAD_ENTER 88
127 #define KEYPAD_PERIOD 99
132 // Everything below this point is only intended for usb_serial.c
133 #ifdef USB_SERIAL_PRIVATE_INCLUDE
135 #include <avr/pgmspace.h>
136 #include <avr/interrupt.h>
138 #define EP_TYPE_CONTROL 0x00
139 #define EP_TYPE_BULK_IN 0x81
140 #define EP_TYPE_BULK_OUT 0x80
141 #define EP_TYPE_INTERRUPT_IN 0xC1
142 #define EP_TYPE_INTERRUPT_OUT 0xC0
143 #define EP_TYPE_ISOCHRONOUS_IN 0x41
144 #define EP_TYPE_ISOCHRONOUS_OUT 0x40
146 #define EP_SINGLE_BUFFER 0x02
147 #define EP_DOUBLE_BUFFER 0x06
149 #define EP_SIZE(s) ((s) == 64 ? 0x30 : \
150 ((s) == 32 ? 0x20 : \
151 ((s) == 16 ? 0x10 : \
154 #define MAX_ENDPOINT 4
156 #define LSB(n) (n & 255)
157 #define MSB(n) ((n >> 8) & 255)
159 #if defined(__AVR_AT90USB162__)
161 #define PLL_CONFIG() (PLLCSR = ((1<<PLLE)|(1<<PLLP0)))
162 #define USB_CONFIG() (USBCON = (1<<USBE))
163 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
164 #elif defined(__AVR_ATmega32U4__)
165 #define HW_CONFIG() (UHWCON = 0x01)
166 #define PLL_CONFIG() (PLLCSR = 0x12)
167 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
168 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
169 #elif defined(__AVR_AT90USB646__)
170 #define HW_CONFIG() (UHWCON = 0x81)
171 #define PLL_CONFIG() (PLLCSR = 0x1A)
172 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
173 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
174 #elif defined(__AVR_AT90USB1286__)
175 #define HW_CONFIG() (UHWCON = 0x81)
176 #define PLL_CONFIG() (PLLCSR = 0x16)
177 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
178 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
181 // standard control endpoint request types
183 #define CLEAR_FEATURE 1
184 #define SET_FEATURE 3
185 #define SET_ADDRESS 5
186 #define GET_DESCRIPTOR 6
187 #define GET_CONFIGURATION 8
188 #define SET_CONFIGURATION 9
189 #define GET_INTERFACE 10
190 #define SET_INTERFACE 11
191 // HID (human interface device)
192 #define HID_GET_REPORT 1
193 #define HID_GET_IDLE 2
194 #define HID_GET_PROTOCOL 3
195 #define HID_SET_REPORT 9
196 #define HID_SET_IDLE 10
197 #define HID_SET_PROTOCOL 11
198 // CDC (communication class device)
199 #define CDC_SET_LINE_CODING 0x20
200 #define CDC_GET_LINE_CODING 0x21
201 #define CDC_SET_CONTROL_LINE_STATE 0x22