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 // This file does not include the HID debug functions, so these empty
16 // macros replace them with nothing, so users can compile code that
17 // has calls to these functions.
18 #define usb_debug_putchar(c)
19 #define usb_debug_flush_output()
23 #define KEY_SHIFT 0x02
26 #define KEY_LEFT_CTRL 0x01
27 #define KEY_LEFT_SHIFT 0x02
28 #define KEY_LEFT_ALT 0x04
29 #define KEY_LEFT_GUI 0x08
30 #define KEY_RIGHT_CTRL 0x10
31 #define KEY_RIGHT_SHIFT 0x20
32 #define KEY_RIGHT_ALT 0x40
33 #define KEY_RIGHT_GUI 0x80
73 #define KEY_BACKSPACE 42
78 #define KEY_LEFT_BRACE 47
79 #define KEY_RIGHT_BRACE 48
80 #define KEY_BACKSLASH 49
82 #define KEY_SEMICOLON 51
88 #define KEY_CAPS_LOCK 57
101 #define KEY_PRINTSCREEN 70
102 #define KEY_SCROLL_LOCK 71
104 #define KEY_INSERT 73
106 #define KEY_PAGE_UP 75
107 #define KEY_DELETE 76
109 #define KEY_PAGE_DOWN 78
114 #define KEY_NUM_LOCK 83
115 #define KEYPAD_SLASH 84
116 #define KEYPAD_ASTERIX 85
117 #define KEYPAD_MINUS 86
118 #define KEYPAD_PLUS 87
119 #define KEYPAD_ENTER 88
130 #define KEYPAD_PERIOD 99
135 // Everything below this point is only intended for usb_serial.c
136 #ifdef USB_SERIAL_PRIVATE_INCLUDE
138 #include <avr/pgmspace.h>
139 #include <avr/interrupt.h>
141 #define EP_TYPE_CONTROL 0x00
142 #define EP_TYPE_BULK_IN 0x81
143 #define EP_TYPE_BULK_OUT 0x80
144 #define EP_TYPE_INTERRUPT_IN 0xC1
145 #define EP_TYPE_INTERRUPT_OUT 0xC0
146 #define EP_TYPE_ISOCHRONOUS_IN 0x41
147 #define EP_TYPE_ISOCHRONOUS_OUT 0x40
149 #define EP_SINGLE_BUFFER 0x02
150 #define EP_DOUBLE_BUFFER 0x06
152 #define EP_SIZE(s) ((s) == 64 ? 0x30 : \
153 ((s) == 32 ? 0x20 : \
154 ((s) == 16 ? 0x10 : \
157 #define MAX_ENDPOINT 4
159 #define LSB(n) (n & 255)
160 #define MSB(n) ((n >> 8) & 255)
162 #if defined(__AVR_AT90USB162__)
164 #define PLL_CONFIG() (PLLCSR = ((1<<PLLE)|(1<<PLLP0)))
165 #define USB_CONFIG() (USBCON = (1<<USBE))
166 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
167 #elif defined(__AVR_ATmega32U4__)
168 #define HW_CONFIG() (UHWCON = 0x01)
169 #define PLL_CONFIG() (PLLCSR = 0x12)
170 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
171 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
172 #elif defined(__AVR_AT90USB646__)
173 #define HW_CONFIG() (UHWCON = 0x81)
174 #define PLL_CONFIG() (PLLCSR = 0x1A)
175 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
176 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
177 #elif defined(__AVR_AT90USB1286__)
178 #define HW_CONFIG() (UHWCON = 0x81)
179 #define PLL_CONFIG() (PLLCSR = 0x16)
180 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
181 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
184 // standard control endpoint request types
186 #define CLEAR_FEATURE 1
187 #define SET_FEATURE 3
188 #define SET_ADDRESS 5
189 #define GET_DESCRIPTOR 6
190 #define GET_CONFIGURATION 8
191 #define SET_CONFIGURATION 9
192 #define GET_INTERFACE 10
193 #define SET_INTERFACE 11
194 // HID (human interface device)
195 #define HID_GET_REPORT 1
196 #define HID_GET_IDLE 2
197 #define HID_GET_PROTOCOL 3
198 #define HID_SET_REPORT 9
199 #define HID_SET_IDLE 10
200 #define HID_SET_PROTOCOL 11
201 // CDC (communication class device)
202 #define CDC_SET_LINE_CODING 0x20
203 #define CDC_GET_LINE_CODING 0x21
204 #define CDC_SET_CONTROL_LINE_STATE 0x22