Kiibohd Controller
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

usb_keyboard_debug.h 2.5KB

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