Prusa MINI Firmware overview
usbh_msc_scsi.h
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  * @file usbh_msc_scsi.h
4  * @author MCD Application Team
5  * @version V3.2.2
6  * @date 07-July-2015
7  * @brief Header file for usbh_msc_scsi.c
8  ******************************************************************************
9  * @attention
10  *
11  * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
12  *
13  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14  * You may not use this file except in compliance with the License.
15  * You may obtain a copy of the License at:
16  *
17  * http://www.st.com/software_license_agreement_liberty_v2
18  *
19  * Unless required by applicable law or agreed to in writing, software
20  * distributed under the License is distributed on an "AS IS" BASIS,
21  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22  * See the License for the specific language governing permissions and
23  * limitations under the License.
24  *
25  ******************************************************************************
26  */
27 
28 /* Define to prevent recursive ----------------------------------------------*/
29 #ifndef __USBH_MSC_SCSI_H
30 #define __USBH_MSC_SCSI_H
31 
32 #ifdef __cplusplus
33  extern "C" {
34 #endif
35 
36 /* Includes ------------------------------------------------------------------*/
37 #include "usbh_core.h"
38 
39 
40 /** @addtogroup USBH_LIB
41  * @{
42  */
43 
44 /** @addtogroup USBH_CLASS
45  * @{
46  */
47 
48 /** @addtogroup USBH_MSC_CLASS
49  * @{
50  */
51 
52 /** @defgroup USBH_MSC_SCSI
53  * @brief This file is the Header file for usbh_msc_scsi.c
54  * @{
55  */
56 
57 
58 // Capacity data.
59 typedef struct
60 {
61  uint32_t block_nbr;
62  uint16_t block_size;
64 
65 
66 // Sense data.
67 typedef struct
68 {
73 
74 // INQUIRY data.
75 typedef struct
76 {
80  uint8_t vendor_id[9];
81  uint8_t product_id[17];
82  uint8_t revision_id[5];
84 
85 /** @defgroup USBH_MSC_SCSI_Exported_Defines
86  * @{
87  */
88 #define OPCODE_TEST_UNIT_READY 0x00
89 #define OPCODE_READ_CAPACITY10 0x25
90 #define OPCODE_READ10 0x28
91 #define OPCODE_WRITE10 0x2A
92 #define OPCODE_REQUEST_SENSE 0x03
93 #define OPCODE_INQUIRY 0x12
94 
95 #define DATA_LEN_MODE_TEST_UNIT_READY 0
96 #define DATA_LEN_READ_CAPACITY10 8
97 #define DATA_LEN_INQUIRY 36
98 #define DATA_LEN_REQUEST_SENSE 14
99 
100 #define CBW_CB_LENGTH 16
101 #define CBW_LENGTH 10
102 
103 /** @defgroup USBH_MSC_SCSI_Exported_Defines
104  * @{
105  */
106 #define SCSI_SENSE_KEY_NO_SENSE 0x00
107 #define SCSI_SENSE_KEY_RECOVERED_ERROR 0x01
108 #define SCSI_SENSE_KEY_NOT_READY 0x02
109 #define SCSI_SENSE_KEY_MEDIUM_ERROR 0x03
110 #define SCSI_SENSE_KEY_HARDWARE_ERROR 0x04
111 #define SCSI_SENSE_KEY_ILLEGAL_REQUEST 0x05
112 #define SCSI_SENSE_KEY_UNIT_ATTENTION 0x06
113 #define SCSI_SENSE_KEY_DATA_PROTECT 0x07
114 #define SCSI_SENSE_KEY_BLANK_CHECK 0x08
115 #define SCSI_SENSE_KEY_VENDOR_SPECIFIC 0x09
116 #define SCSI_SENSE_KEY_COPY_ABORTED 0x0A
117 #define SCSI_SENSE_KEY_ABORTED_COMMAND 0x0B
118 #define SCSI_SENSE_KEY_VOLUME_OVERFLOW 0x0D
119 #define SCSI_SENSE_KEY_MISCOMPARE 0x0E
120 /**
121  * @}
122  */
123 
124 
125 /** @defgroup USBH_MSC_SCSI_Exported_Defines
126  * @{
127  */
128 #define SCSI_ASC_NO_ADDITIONAL_SENSE_INFORMATION 0x00
129 #define SCSI_ASC_LOGICAL_UNIT_NOT_READY 0x04
130 #define SCSI_ASC_INVALID_FIELD_IN_CDB 0x24
131 #define SCSI_ASC_WRITE_PROTECTED 0x27
132 #define SCSI_ASC_FORMAT_ERROR 0x31
133 #define SCSI_ASC_INVALID_COMMAND_OPERATION_CODE 0x20
134 #define SCSI_ASC_NOT_READY_TO_READY_CHANGE 0x28
135 #define SCSI_ASC_MEDIUM_NOT_PRESENT 0x3A
136 /**
137  * @}
138  */
139 
140 
141 /** @defgroup USBH_MSC_SCSI_Exported_Defines
142  * @{
143  */
144 #define SCSI_ASCQ_FORMAT_COMMAND_FAILED 0x01
145 #define SCSI_ASCQ_INITIALIZING_COMMAND_REQUIRED 0x02
146 #define SCSI_ASCQ_OPERATION_IN_PROGRESS 0x07
147 
148 /**
149  * @}
150  */
151 
152 /** @defgroup USBH_MSC_SCSI_Exported_Macros
153  * @{
154  */
155 /**
156  * @}
157  */
158 
159 /** @defgroup _Exported_Variables
160  * @{
161  */
162 
163 /**
164  * @}
165  */
166 
167 /** @defgroup USBH_MSC_SCSI_Exported_FunctionsPrototype
168  * @{
169  */
171  uint8_t lun);
172 
174  uint8_t lun,
175  SCSI_CapacityTypeDef *capacity);
176 
178  uint8_t lun,
179  SCSI_StdInquiryDataTypeDef *inquiry);
180 
182  uint8_t lun,
183  SCSI_SenseTypeDef *sense_data);
184 
186  uint8_t lun,
187  uint32_t address,
188  uint8_t *pbuf,
189  uint32_t length);
190 
192  uint8_t lun,
193  uint32_t address,
194  uint8_t *pbuf,
195  uint32_t length);
196 
197 
198 /**
199  * @}
200  */
201 
202 #ifdef __cplusplus
203 }
204 #endif
205 
206 #endif /* __USBH_MSC_SCSI_H */
207 
208 
209 /**
210  * @}
211  */
212 
213 /**
214  * @}
215  */
216 
217 /**
218  * @}
219  */
220 
221 /**
222  * @}
223  */
224 
225 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
USBH_MSC_SCSI_Read
USBH_StatusTypeDef USBH_MSC_SCSI_Read(USBH_HandleTypeDef *phost, uint8_t lun, uint32_t address, uint8_t *pbuf, uint32_t length)
USBH_MSC_SCSI_Read Issue Read10 command.
Definition: usbh_msc_scsi.c:384
usbh_core.h
Header file for usbh_core.c.
USBH_MSC_SCSI_ReadCapacity
USBH_StatusTypeDef USBH_MSC_SCSI_ReadCapacity(USBH_HandleTypeDef *phost, uint8_t lun, SCSI_CapacityTypeDef *capacity)
USBH_MSC_SCSI_ReadCapacity Issue Read Capacity command.
Definition: usbh_msc_scsi.c:146
SCSI_CapacityTypeDef
Definition: usbh_msc_scsi.h:59
SCSI_SenseTypeDef::key
uint8_t key
Definition: usbh_msc_scsi.h:69
USBH_MSC_SCSI_TestUnitReady
USBH_StatusTypeDef USBH_MSC_SCSI_TestUnitReady(USBH_HandleTypeDef *phost, uint8_t lun)
USBH_MSC_SCSI_TestUnitReady Issue TestUnitReady command.
Definition: usbh_msc_scsi.c:104
_USBH_HandleTypeDef
Definition: usbh_def.h:450
SCSI_SenseTypeDef::asc
uint8_t asc
Definition: usbh_msc_scsi.h:70
SCSI_SenseTypeDef
Definition: usbh_msc_scsi.h:67
SCSI_SenseTypeDef::ascq
uint8_t ascq
Definition: usbh_msc_scsi.h:71
USBH_MSC_SCSI_Inquiry
USBH_StatusTypeDef USBH_MSC_SCSI_Inquiry(USBH_HandleTypeDef *phost, uint8_t lun, SCSI_StdInquiryDataTypeDef *inquiry)
USBH_MSC_SCSI_Inquiry Issue Inquiry command.
Definition: usbh_msc_scsi.c:202
SCSI_CapacityTypeDef::block_nbr
uint32_t block_nbr
Definition: usbh_msc_scsi.h:61
SCSI_StdInquiryDataTypeDef::PeripheralQualifier
uint8_t PeripheralQualifier
Definition: usbh_msc_scsi.h:77
SCSI_StdInquiryDataTypeDef
Definition: usbh_msc_scsi.h:75
uint8_t
const uint8_t[]
Definition: 404_html.c:3
address
UsbDeviceAddress address
Definition: address.h:202
USBH_StatusTypeDef
USBH_StatusTypeDef
Definition: usbh_def.h:302
USBH_MSC_SCSI_RequestSense
USBH_StatusTypeDef USBH_MSC_SCSI_RequestSense(USBH_HandleTypeDef *phost, uint8_t lun, SCSI_SenseTypeDef *sense_data)
USBH_MSC_SCSI_RequestSense Issue RequestSense command.
Definition: usbh_msc_scsi.c:264
USBH_MSC_SCSI_Write
USBH_StatusTypeDef USBH_MSC_SCSI_Write(USBH_HandleTypeDef *phost, uint8_t lun, uint32_t address, uint8_t *pbuf, uint32_t length)
USBH_MSC_SCSI_Write Issue write10 command.
Definition: usbh_msc_scsi.c:323
SCSI_StdInquiryDataTypeDef::RemovableMedia
uint8_t RemovableMedia
Definition: usbh_msc_scsi.h:79
SCSI_StdInquiryDataTypeDef::DeviceType
uint8_t DeviceType
Definition: usbh_msc_scsi.h:78
length
png_uint_32 length
Definition: png.c:2247
pbuf
Definition: pbuf.h:142
SCSI_CapacityTypeDef::block_size
uint16_t block_size
Definition: usbh_msc_scsi.h:62