My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

usb_protocol_msc.h 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**
  2. * \file
  3. *
  4. * \brief USB Mass Storage Class (MSC) protocol definitions.
  5. *
  6. * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
  7. *
  8. * \asf_license_start
  9. *
  10. * \page License
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions are met:
  14. *
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. *
  18. * 2. Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. *
  22. * 3. The name of Atmel may not be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * 4. This software may only be redistributed and used in connection with an
  26. * Atmel microcontroller product.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  29. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  30. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  31. * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  32. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  34. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  36. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  37. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38. * POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. * \asf_license_stop
  41. *
  42. */
  43. /*
  44. * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
  45. */
  46. #ifndef _USB_PROTOCOL_MSC_H_
  47. #define _USB_PROTOCOL_MSC_H_
  48. /**
  49. * \ingroup usb_protocol_group
  50. * \defgroup usb_msc_protocol USB Mass Storage Class (MSC) protocol definitions
  51. *
  52. * @{
  53. */
  54. /**
  55. * \name Possible Class value
  56. */
  57. //@{
  58. #define MSC_CLASS 0x08
  59. //@}
  60. /**
  61. * \name Possible SubClass value
  62. * \note In practise, most devices should use
  63. * #MSC_SUBCLASS_TRANSPARENT and specify the actual command set in
  64. * the standard INQUIRY data block, even if the MSC spec indicates
  65. * otherwise. In particular, RBC is not supported by certain major
  66. * operating systems like Windows XP.
  67. */
  68. //@{
  69. #define MSC_SUBCLASS_RBC 0x01 //!< Reduced Block Commands
  70. #define MSC_SUBCLASS_ATAPI 0x02 //!< CD/DVD devices
  71. #define MSC_SUBCLASS_QIC_157 0x03 //!< Tape devices
  72. #define MSC_SUBCLASS_UFI 0x04 //!< Floppy disk drives
  73. #define MSC_SUBCLASS_SFF_8070I 0x05 //!< Floppy disk drives
  74. #define MSC_SUBCLASS_TRANSPARENT 0x06 //!< Determined by INQUIRY
  75. //@}
  76. /**
  77. * \name Possible protocol value
  78. * \note Only the BULK protocol should be used in new designs.
  79. */
  80. //@{
  81. #define MSC_PROTOCOL_CBI 0x00 //!< Command/Bulk/Interrupt
  82. #define MSC_PROTOCOL_CBI_ALT 0x01 //!< W/o command completion
  83. #define MSC_PROTOCOL_BULK 0x50 //!< Bulk-only
  84. //@}
  85. /**
  86. * \brief MSC USB requests (bRequest)
  87. */
  88. enum usb_reqid_msc {
  89. USB_REQ_MSC_BULK_RESET = 0xFF, //!< Mass Storage Reset
  90. USB_REQ_MSC_GET_MAX_LUN = 0xFE //!< Get Max LUN
  91. };
  92. COMPILER_PACK_SET(1)
  93. /**
  94. * \name A Command Block Wrapper (CBW).
  95. */
  96. //@{
  97. struct usb_msc_cbw {
  98. le32_t dCBWSignature; //!< Must contain 'USBC'
  99. le32_t dCBWTag; //!< Unique command ID
  100. le32_t dCBWDataTransferLength; //!< Number of bytes to transfer
  101. uint8_t bmCBWFlags; //!< Direction in bit 7
  102. uint8_t bCBWLUN; //!< Logical Unit Number
  103. uint8_t bCBWCBLength; //!< Number of valid CDB bytes
  104. uint8_t CDB[16]; //!< SCSI Command Descriptor Block
  105. };
  106. #define USB_CBW_SIGNATURE 0x55534243 //!< dCBWSignature value
  107. #define USB_CBW_DIRECTION_IN (1<<7) //!< Data from device to host
  108. #define USB_CBW_DIRECTION_OUT (0<<7) //!< Data from host to device
  109. #define USB_CBW_LUN_MASK 0x0F //!< Valid bits in bCBWLUN
  110. #define USB_CBW_LEN_MASK 0x1F //!< Valid bits in bCBWCBLength
  111. //@}
  112. /**
  113. * \name A Command Status Wrapper (CSW).
  114. */
  115. //@{
  116. struct usb_msc_csw {
  117. le32_t dCSWSignature; //!< Must contain 'USBS'
  118. le32_t dCSWTag; //!< Same as dCBWTag
  119. le32_t dCSWDataResidue; //!< Number of bytes not transfered
  120. uint8_t bCSWStatus; //!< Status code
  121. };
  122. #define USB_CSW_SIGNATURE 0x55534253 //!< dCSWSignature value
  123. #define USB_CSW_STATUS_PASS 0x00 //!< Command Passed
  124. #define USB_CSW_STATUS_FAIL 0x01 //!< Command Failed
  125. #define USB_CSW_STATUS_PE 0x02 //!< Phase Error
  126. //@}
  127. COMPILER_PACK_RESET()
  128. //@}
  129. #endif // _USB_PROTOCOL_MSC_H_