5 #include "output_com.h"
7 void usb_init(void); // initialize everything
8 uint8_t usb_configured(void); // is the USB port configured
10 int8_t usb_keyboard_send(void);
13 int8_t usb_debug_putchar(uint8_t c); // transmit a character
14 void usb_debug_flush_output(void); // immediately transmit any buffered output
18 // Everything below this point is only intended for usb_serial.c
19 #ifdef USB_SERIAL_PRIVATE_INCLUDE
21 #include <avr/pgmspace.h>
22 #include <avr/interrupt.h>
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
32 #define EP_SINGLE_BUFFER 0x02
33 #define EP_DOUBLE_BUFFER 0x06
35 #define EP_SIZE(s) ((s) == 64 ? 0x30 : \
40 #define MAX_ENDPOINT 4
42 #define LSB(n) (n & 255)
43 #define MSB(n) ((n >> 8) & 255)
45 #if defined(__AVR_AT90USB162__)
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)))
67 // standard control endpoint request types
69 #define CLEAR_FEATURE 1
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