]> git.donarmstrong.com Git - kiibohd-controller.git/blob - USB/pjrc/usb_keyboard_debug.h
ffcf129c96d06273c3e8856085ea592e5b4df532
[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 #include "usb_com.h"
6
7 void usb_init(void);                    // initialize everything
8 uint8_t usb_configured(void);           // is the USB port configured
9
10 int8_t usb_keyboard_press(uint8_t key, uint8_t modifier);
11 int8_t usb_keyboard_send(void);
12
13
14 int8_t usb_debug_putchar(uint8_t c);    // transmit a character
15 void usb_debug_flush_output(void);      // immediately transmit any buffered output
16 #define USB_DEBUG_HID
17
18
19 // Everything below this point is only intended for usb_serial.c
20 #ifdef USB_SERIAL_PRIVATE_INCLUDE
21 #include <avr/io.h>
22 #include <avr/pgmspace.h>
23 #include <avr/interrupt.h>
24
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
32
33 #define EP_SINGLE_BUFFER                0x02
34 #define EP_DOUBLE_BUFFER                0x06
35
36 #define EP_SIZE(s)      ((s) == 64 ? 0x30 :     \
37                         ((s) == 32 ? 0x20 :     \
38                         ((s) == 16 ? 0x10 :     \
39                                      0x00)))
40
41 #define MAX_ENDPOINT            4
42
43 #define LSB(n) (n & 255)
44 #define MSB(n) ((n >> 8) & 255)
45
46 #if defined(__AVR_AT90USB162__)
47 #define HW_CONFIG() 
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)))
66 #endif
67
68 // standard control endpoint request types
69 #define GET_STATUS                      0
70 #define CLEAR_FEATURE                   1
71 #define SET_FEATURE                     3
72 #define SET_ADDRESS                     5
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
89 #endif
90 #endif