]> git.donarmstrong.com Git - kiibohd-controller.git/blob - USB/pjrc/usb_keyboard_debug.h
Reorganization for use with the CMake "Modules"
[kiibohd-controller.git] / USB / pjrc / 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
20 // Everything below this point is only intended for usb_serial.c
21 #ifdef USB_SERIAL_PRIVATE_INCLUDE
22 #include <avr/io.h>
23 #include <avr/pgmspace.h>
24 #include <avr/interrupt.h>
25
26 #define EP_TYPE_CONTROL                 0x00
27 #define EP_TYPE_BULK_IN                 0x81
28 #define EP_TYPE_BULK_OUT                0x80
29 #define EP_TYPE_INTERRUPT_IN            0xC1
30 #define EP_TYPE_INTERRUPT_OUT           0xC0
31 #define EP_TYPE_ISOCHRONOUS_IN          0x41
32 #define EP_TYPE_ISOCHRONOUS_OUT         0x40
33
34 #define EP_SINGLE_BUFFER                0x02
35 #define EP_DOUBLE_BUFFER                0x06
36
37 #define EP_SIZE(s)      ((s) == 64 ? 0x30 :     \
38                         ((s) == 32 ? 0x20 :     \
39                         ((s) == 16 ? 0x10 :     \
40                                      0x00)))
41
42 #define MAX_ENDPOINT            4
43
44 #define LSB(n) (n & 255)
45 #define MSB(n) ((n >> 8) & 255)
46
47 #if defined(__AVR_AT90USB162__)
48 #define HW_CONFIG() 
49 #define PLL_CONFIG() (PLLCSR = ((1<<PLLE)|(1<<PLLP0)))
50 #define USB_CONFIG() (USBCON = (1<<USBE))
51 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
52 #elif defined(__AVR_ATmega32U4__)
53 #define HW_CONFIG() (UHWCON = 0x01)
54 #define PLL_CONFIG() (PLLCSR = 0x12)
55 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
56 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
57 #elif defined(__AVR_AT90USB646__)
58 #define HW_CONFIG() (UHWCON = 0x81)
59 #define PLL_CONFIG() (PLLCSR = 0x1A)
60 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
61 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
62 #elif defined(__AVR_AT90USB1286__)
63 #define HW_CONFIG() (UHWCON = 0x81)
64 #define PLL_CONFIG() (PLLCSR = 0x16)
65 #define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
66 #define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
67 #endif
68
69 // standard control endpoint request types
70 #define GET_STATUS                      0
71 #define CLEAR_FEATURE                   1
72 #define SET_FEATURE                     3
73 #define SET_ADDRESS                     5
74 #define GET_DESCRIPTOR                  6
75 #define GET_CONFIGURATION               8
76 #define SET_CONFIGURATION               9
77 #define GET_INTERFACE                   10
78 #define SET_INTERFACE                   11
79 // HID (human interface device)
80 #define HID_GET_REPORT                  1
81 #define HID_GET_IDLE                    2
82 #define HID_GET_PROTOCOL                3
83 #define HID_SET_REPORT                  9
84 #define HID_SET_IDLE                    10
85 #define HID_SET_PROTOCOL                11
86 // CDC (communication class device)
87 #define CDC_SET_LINE_CODING             0x20
88 #define CDC_GET_LINE_CODING             0x21
89 #define CDC_SET_CONTROL_LINE_STATE      0x22
90 #endif
91 #endif