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