usb_scsi.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
  2. * File Name : usb_scsi.h
  3. * Author : MCD Application Team
  4. * Version : V3.1.0
  5. * Date : 10/30/2009
  6. * Description : All processing related to the SCSI commands
  7. ********************************************************************************
  8. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  9. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
  10. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  11. * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
  12. * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
  13. * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  14. *******************************************************************************/
  15. /* Define to prevent recursive inclusion -------------------------------------*/
  16. #ifndef __USB_SCSI_H
  17. #define __USB_SCSI_H
  18. /* Includes ------------------------------------------------------------------*/
  19. #include "stm32f10x.h"
  20. /* Exported types ------------------------------------------------------------*/
  21. /* Exported constants --------------------------------------------------------*/
  22. /* SCSI Commands */
  23. #define SCSI_FORMAT_UNIT 0x04
  24. #define SCSI_INQUIRY 0x12
  25. #define SCSI_MODE_SELECT6 0x15
  26. #define SCSI_MODE_SELECT10 0x55
  27. #define SCSI_MODE_SENSE6 0x1A
  28. #define SCSI_MODE_SENSE10 0x5A
  29. #define SCSI_ALLOW_MEDIUM_REMOVAL 0x1E
  30. #define SCSI_READ6 0x08
  31. #define SCSI_READ10 0x28
  32. #define SCSI_READ12 0xA8
  33. #define SCSI_READ16 0x88
  34. #define SCSI_READ_CAPACITY10 0x25
  35. #define SCSI_READ_CAPACITY16 0x9E
  36. #define SCSI_REQUEST_SENSE 0x03
  37. #define SCSI_START_STOP_UNIT 0x1B
  38. #define SCSI_TEST_UNIT_READY 0x00
  39. #define SCSI_WRITE6 0x0A
  40. #define SCSI_WRITE10 0x2A
  41. #define SCSI_WRITE12 0xAA
  42. #define SCSI_WRITE16 0x8A
  43. #define SCSI_VERIFY10 0x2F
  44. #define SCSI_VERIFY12 0xAF
  45. #define SCSI_VERIFY16 0x8F
  46. #define SCSI_SEND_DIAGNOSTIC 0x1D
  47. #define SCSI_READ_FORMAT_CAPACITIES 0x23
  48. #define NO_SENSE 0
  49. #define RECOVERED_ERROR 1
  50. #define NOT_READY 2
  51. #define MEDIUM_ERROR 3
  52. #define HARDWARE_ERROR 4
  53. #define ILLEGAL_REQUEST 5
  54. #define UNIT_ATTENTION 6
  55. #define DATA_PROTECT 7
  56. #define BLANK_CHECK 8
  57. #define VENDOR_SPECIFIC 9
  58. #define COPY_ABORTED 10
  59. #define ABORTED_COMMAND 11
  60. #define VOLUME_OVERFLOW 13
  61. #define MISCOMPARE 14
  62. #define INVALID_COMMAND 0x20
  63. #define INVALID_FIELED_IN_COMMAND 0x24
  64. #define PARAMETER_LIST_LENGTH_ERROR 0x1A
  65. #define INVALID_FIELD_IN_PARAMETER_LIST 0x26
  66. #define ADDRESS_OUT_OF_RANGE 0x21
  67. #define MEDIUM_NOT_PRESENT 0x3A
  68. #define MEDIUM_HAVE_CHANGED 0x28
  69. #define READ_FORMAT_CAPACITY_DATA_LEN 0x0C
  70. #define READ_CAPACITY10_DATA_LEN 0x08
  71. #define MODE_SENSE10_DATA_LEN 0x08
  72. #define MODE_SENSE6_DATA_LEN 0x04
  73. #define REQUEST_SENSE_DATA_LEN 0x12
  74. #define STANDARD_INQUIRY_DATA_LEN 0x24
  75. #define BLKVFY 0x04
  76. extern uint8_t Page00_Inquiry_Data[];
  77. extern uint8_t Standard_Inquiry_Data1[];
  78. extern uint8_t Standard_Inquiry_Data2[];
  79. extern uint8_t Standard_Inquiry_Data3[];
  80. extern uint8_t Mode_Sense6_data[];
  81. extern uint8_t Mode_Sense10_data[];
  82. extern uint8_t Scsi_Sense_Data[];
  83. extern uint8_t ReadCapacity10_Data[];
  84. extern uint8_t ReadFormatCapacity_Data [];
  85. /* Exported macro ------------------------------------------------------------*/
  86. /* Exported functions ------------------------------------------------------- */
  87. void SCSI_Inquiry_Cmd(uint8_t lun);
  88. void SCSI_ReadFormatCapacity_Cmd(uint8_t lun);
  89. void SCSI_ReadCapacity10_Cmd(uint8_t lun);
  90. void SCSI_RequestSense_Cmd (uint8_t lun);
  91. void SCSI_Start_Stop_Unit_Cmd(uint8_t lun);
  92. void SCSI_ModeSense6_Cmd (uint8_t lun);
  93. void SCSI_ModeSense10_Cmd (uint8_t lun);
  94. void SCSI_Write10_Cmd(uint8_t lun , uint32_t LBA , uint32_t BlockNbr);
  95. void SCSI_Read10_Cmd(uint8_t lun , uint32_t LBA , uint32_t BlockNbr);
  96. void SCSI_Verify10_Cmd(uint8_t lun);
  97. void SCSI_Invalid_Cmd(uint8_t lun);
  98. void SCSI_Valid_Cmd(uint8_t lun);
  99. bool SCSI_Address_Management(uint8_t lun , uint8_t Cmd , uint32_t LBA , uint32_t BlockNbr);
  100. void Set_Scsi_Sense_Data(uint8_t lun , uint8_t Sens_Key, uint8_t Asc);
  101. void SCSI_TestUnitReady_Cmd (uint8_t lun);
  102. void SCSI_Format_Cmd (uint8_t lun);
  103. //#define SCSI_TestUnitReady_Cmd SCSI_Valid_Cmd
  104. #define SCSI_Prevent_Removal_Cmd SCSI_Valid_Cmd
  105. /* Invalid (Unsupported) commands */
  106. #define SCSI_READ_CAPACITY16_Cmd SCSI_Invalid_Cmd
  107. //#define SCSI_FormatUnit_Cmd SCSI_Invalid_Cmd
  108. #define SCSI_Write6_Cmd SCSI_Invalid_Cmd
  109. #define SCSI_Write16_Cmd SCSI_Invalid_Cmd
  110. #define SCSI_Write12_Cmd SCSI_Invalid_Cmd
  111. #define SCSI_Read6_Cmd SCSI_Invalid_Cmd
  112. #define SCSI_Read12_Cmd SCSI_Invalid_Cmd
  113. #define SCSI_Read16_Cmd SCSI_Invalid_Cmd
  114. #define SCSI_Send_Diagnostic_Cmd SCSI_Invalid_Cmd
  115. #define SCSI_Mode_Select6_Cmd SCSI_Invalid_Cmd
  116. #define SCSI_Mode_Select10_Cmd SCSI_Invalid_Cmd
  117. #define SCSI_Verify12_Cmd SCSI_Invalid_Cmd
  118. #define SCSI_Verify16_Cmd SCSI_Invalid_Cmd
  119. #endif /* __USB_SCSI_H */
  120. /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/