Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AVRISPDescriptors.h 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. LUFA Library
  3. Copyright (C) Dean Camera, 2014.
  4. dean [at] fourwalledcubicle [dot] com
  5. www.lufa-lib.org
  6. */
  7. /*
  8. Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  9. Permission to use, copy, modify, distribute, and sell this
  10. software and its documentation for any purpose is hereby granted
  11. without fee, provided that the above copyright notice appear in
  12. all copies and that both that the copyright notice and this
  13. permission notice and warranty disclaimer appear in supporting
  14. documentation, and that the name of the author not be used in
  15. advertising or publicity pertaining to distribution of the
  16. software without specific, written prior permission.
  17. The author disclaims all warranties with regard to this
  18. software, including all implied warranties of merchantability
  19. and fitness. In no event shall the author be liable for any
  20. special, indirect or consequential damages or any damages
  21. whatsoever resulting from loss of use, data or profits, whether
  22. in an action of contract, negligence or other tortious action,
  23. arising out of or in connection with the use or performance of
  24. this software.
  25. */
  26. /** \file
  27. *
  28. * Header file for Descriptors.c.
  29. */
  30. #ifndef _DESCRIPTORS_H_
  31. #define _DESCRIPTORS_H_
  32. /* Includes: */
  33. #include <avr/pgmspace.h>
  34. #include <LUFA/Drivers/USB/USB.h>
  35. #include <LUFA/Drivers/Board/LEDs.h>
  36. #include "Config/AppConfig.h"
  37. /* Preprocessor Checks: */
  38. #if defined(LIBUSB_DRIVER_COMPAT) && defined(RESET_TOGGLES_LIBUSB_COMPAT)
  39. #error LIBUSB_DRIVER_COMPAT and RESET_TOGGLES_LIBUSB_COMPAT are mutually exclusive.
  40. #endif
  41. /* Macros: */
  42. /** Endpoint address of the AVRISP data OUT endpoint. */
  43. #define AVRISP_DATA_OUT_EPADDR (ENDPOINT_DIR_OUT | 2)
  44. /** Endpoint address of the AVRISP data IN endpoint, when in Jungo driver compatibility mode. */
  45. #define AVRISP_DATA_IN_EPADDR_JUNGO (ENDPOINT_DIR_IN | 2)
  46. /** Endpoint address of the AVRISP data IN endpoint, when in LibUSB driver compatibility mode. */
  47. #define AVRISP_DATA_IN_EPADDR_LIBUSB (ENDPOINT_DIR_IN | 3)
  48. #if defined(RESET_TOGGLES_LIBUSB_COMPAT)
  49. #define AVRISP_DATA_IN_EPADDR AVRISP_CurrDataINEndpointAddress
  50. #elif defined(LIBUSB_DRIVER_COMPAT)
  51. #define AVRISP_DATA_IN_EPADDR AVRISP_DATA_IN_EPADDR_LIBUSB
  52. #else
  53. /** Endpoint address of the AVRISP data IN endpoint. */
  54. #define AVRISP_DATA_IN_EPADDR AVRISP_DATA_IN_EPADDR_JUNGO
  55. #endif
  56. /** Size in bytes of the AVRISP data endpoint. */
  57. #define AVRISP_DATA_EPSIZE 64
  58. /* Type Defines: */
  59. /** Type define for the device configuration descriptor structure. This must be defined in the
  60. * application code, as the configuration descriptor contains several sub-descriptors which
  61. * vary between devices, and which describe the device's usage to the host.
  62. */
  63. typedef struct
  64. {
  65. USB_Descriptor_Configuration_Header_t Config;
  66. // Atmel AVRISP-MKII Interface
  67. USB_Descriptor_Interface_t AVRISP_Interface;
  68. USB_Descriptor_Endpoint_t AVRISP_DataInEndpoint;
  69. USB_Descriptor_Endpoint_t AVRISP_DataOutEndpoint;
  70. } AVRISP_USB_Descriptor_Configuration_t;
  71. /** Enum for the device interface descriptor IDs within the device. Each interface descriptor
  72. * should have a unique ID index associated with it, which can be used to refer to the
  73. * interface from other descriptors.
  74. */
  75. enum InterfaceDescriptors_t
  76. {
  77. INTERFACE_ID_AVRISP = 0, /**< AVRISP interface descriptor ID */
  78. };
  79. /** Enum for the device string descriptor IDs within the device. Each string descriptor should
  80. * have a unique ID index associated with it, which can be used to refer to the string from
  81. * other descriptors.
  82. */
  83. enum AVRISP_StringDescriptors_t
  84. {
  85. AVRISP_STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */
  86. AVRISP_STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
  87. AVRISP_STRING_ID_Product = 2, /**< Product string ID */
  88. AVRISP_STRING_ID_Serial = 3, /**< Serial number string ID */
  89. };
  90. /* External Variables: */
  91. #if defined(RESET_TOGGLES_LIBUSB_COMPAT)
  92. extern uint8_t AVRISP_CurrDataINEndpointAddress;
  93. #endif
  94. /* Function Prototypes: */
  95. uint16_t AVRISP_GetDescriptor(const uint16_t wValue,
  96. const uint8_t wIndex,
  97. const void** const DescriptorAddress,
  98. uint8_t* const DescriptorMemorySpace)
  99. ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3) ATTR_NON_NULL_PTR_ARG(4);
  100. #if defined(RESET_TOGGLES_LIBUSB_COMPAT)
  101. void CheckExternalReset(void) ATTR_NAKED ATTR_INIT_SECTION(3);
  102. void UpdateCurrentCompatibilityMode(void);
  103. #endif
  104. #endif