]> git.gir.st - tmk_keyboard.git/blob - usb_keyboard_debug.h
change file name.
[tmk_keyboard.git] / usb_keyboard_debug.h
1 #ifndef usb_serial_h__
2 #define usb_serial_h__
3
4 #include <stdint.h>
5
6 void usb_init(void); // initialize everything
7 uint8_t usb_configured(void); // is the USB port configured
8
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;
14
15 int8_t usb_debug_putchar(uint8_t c); // transmit a character
16 void usb_debug_flush_output(void); // immediately transmit any buffered output
17 #define USB_DEBUG_HID
18
19 #define KEY_CTRL 0x01
20 #define KEY_SHIFT 0x02
21 #define KEY_ALT 0x04
22 #define KEY_GUI 0x08
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
31
32 #define KEY_A 4
33 #define KEY_B 5
34 #define KEY_C 6
35 #define KEY_D 7
36 #define KEY_E 8
37 #define KEY_F 9
38 #define KEY_G 10
39 #define KEY_H 11
40 #define KEY_I 12
41 #define KEY_J 13
42 #define KEY_K 14
43 #define KEY_L 15
44 #define KEY_M 16
45 #define KEY_N 17
46 #define KEY_O 18
47 #define KEY_P 19
48 #define KEY_Q 20
49 #define KEY_R 21
50 #define KEY_S 22
51 #define KEY_T 23
52 #define KEY_U 24
53 #define KEY_V 25
54 #define KEY_W 26
55 #define KEY_X 27
56 #define KEY_Y 28
57 #define KEY_Z 29
58 #define KEY_1 30
59 #define KEY_2 31
60 #define KEY_3 32
61 #define KEY_4 33
62 #define KEY_5 34
63 #define KEY_6 35
64 #define KEY_7 36
65 #define KEY_8 37
66 #define KEY_9 38
67 #define KEY_0 39
68 #define KEY_ENTER 40
69 #define KEY_ESC 41
70 #define KEY_BACKSPACE 42
71 #define KEY_TAB 43
72 #define KEY_SPACE 44
73 #define KEY_MINUS 45
74 #define KEY_EQUAL 46
75 #define KEY_LEFT_BRACE 47
76 #define KEY_RIGHT_BRACE 48
77 #define KEY_BACKSLASH 49
78 #define KEY_NUMBER 50
79 #define KEY_SEMICOLON 51
80 #define KEY_QUOTE 52
81 #define KEY_TILDE 53
82 #define KEY_COMMA 54
83 #define KEY_PERIOD 55
84 #define KEY_SLASH 56
85 #define KEY_CAPS_LOCK 57
86 #define KEY_F1 58
87 #define KEY_F2 59
88 #define KEY_F3 60
89 #define KEY_F4 61
90 #define KEY_F5 62
91 #define KEY_F6 63
92 #define KEY_F7 64
93 #define KEY_F8 65
94 #define KEY_F9 66
95 #define KEY_F10 67
96 #define KEY_F11 68
97 #define KEY_F12 69
98 #define KEY_PRINTSCREEN 70
99 #define KEY_SCROLL_LOCK 71
100 #define KEY_PAUSE 72
101 #define KEY_INSERT 73
102 #define KEY_HOME 74
103 #define KEY_PAGE_UP 75
104 #define KEY_DELETE 76
105 #define KEY_END 77
106 #define KEY_PAGE_DOWN 78
107 #define KEY_RIGHT 79
108 #define KEY_LEFT 80
109 #define KEY_DOWN 81
110 #define KEY_UP 82
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
117 #define KEYPAD_1 89
118 #define KEYPAD_2 90
119 #define KEYPAD_3 91
120 #define KEYPAD_4 92
121 #define KEYPAD_5 93
122 #define KEYPAD_6 94
123 #define KEYPAD_7 95
124 #define KEYPAD_8 96
125 #define KEYPAD_9 97
126 #define KEYPAD_0 98
127 #define KEYPAD_PERIOD 99
128
129
130
131
132 // Everything below this point is only intended for usb_serial.c
133 #ifdef USB_SERIAL_PRIVATE_INCLUDE
134 #include <avr/io.h>
135 #include <avr/pgmspace.h>
136 #include <avr/interrupt.h>
137
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
145
146 #define EP_SINGLE_BUFFER 0x02
147 #define EP_DOUBLE_BUFFER 0x06
148
149 #define EP_SIZE(s) ((s) == 64 ? 0x30 : \
150 ((s) == 32 ? 0x20 : \
151 ((s) == 16 ? 0x10 : \
152 0x00)))
153
154 #define MAX_ENDPOINT 4
155
156 #define LSB(n) (n & 255)
157 #define MSB(n) ((n >> 8) & 255)
158
159 #if defined(__AVR_AT90USB162__)
160 #define HW_CONFIG()
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)))
179 #endif
180
181 // standard control endpoint request types
182 #define GET_STATUS 0
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
202 #endif
203 #endif
Imprint / Impressum