EFM32 Wonder Gecko Software Documentation  efm32wg-doc-5.1.2
msdscsi.h
Go to the documentation of this file.
1 /***************************************************************************/
17 #ifndef __MSDSCSI_H
18 #define __MSDSCSI_H
19 
20 /***************************************************************************/
25 /***************************************************************************/
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #define SCSI_TESTUNIT_READY 0x00
35 #define SCSI_REQUESTSENSE 0x03
36 #define SCSI_INQUIRY 0x12
37 #define SCSI_STARTSTOP_UNIT 0x1B
38 #define SCSI_READCAPACITY 0x25
39 #define SCSI_READ10 0x28
40 #define SCSI_WRITE10 0x2A
41 #define SCSI_VERIFY10 0x2F
43 #define SCSI_READ10_LEN 10U
44 #define SCSI_WRITE10_LEN 10U
45 #define SCSI_VERIFY10_LEN 10U
46 #define SCSI_INQUIRYDATA_LEN 36U
47 #define SCSI_STARTSTOPUNIT_LEN 6U
48 #define SCSI_REQUESTSENSE_LEN 6U
49 #define SCSI_REQUESTSENSEDATA_LEN 18U
50 #define SCSI_READCAPACITY_LEN 10U
51 #define SCSI_READCAPACITYDATA_LEN 8U
53 /**************************************************************************/
56 SL_PACK_START(1)
57 typedef struct
58 {
59  uint8_t OpCode;
60  struct
61  {
62  uint8_t Evpd : 1;
63  uint8_t Obsolete : 1;
64  uint8_t Reserved : 6;
65  };
66  uint8_t PageCode;
67  uint16_t AllocationLength;
68  uint8_t Control;
71 
72 /**************************************************************************/
76 typedef struct
77 {
78  struct
79  {
80  uint8_t PeripheralDeviceType : 5;
81  uint8_t PeripheralQualifier : 3;
82  };
83  struct
84  {
85  uint8_t Reserved1 : 7;
86  uint8_t Removable : 1;
87  };
88  uint8_t Version;
89  struct
90  {
91  uint8_t ResponseDataFormat : 4;
92  uint8_t HiSup : 1;
93  uint8_t NormACA : 1;
94  uint8_t Obsolete1 : 2;
95  };
96  uint8_t AdditionalLength;
97  struct
98  {
99  uint8_t Protect : 1;
100  uint8_t Reserved2 : 2;
101  uint8_t ThirdPartyCode : 1;
102  uint8_t Tpgs : 2;
103  uint8_t Acc : 1;
104  uint8_t Sccs : 1;
105  };
106  struct
107  {
108  uint8_t Addr16 : 1;
109  uint8_t Obsolete2 : 2;
110  uint8_t MChngr : 1;
111  uint8_t MultiP : 1;
112  uint8_t Vs1 : 1;
113  uint8_t EncServ : 1;
114  uint8_t BQue : 1;
115  };
116  struct
117  {
118  uint8_t Vs2 : 1;
119  uint8_t CmdQue : 1;
120  uint8_t Obsolete3 : 1;
121  uint8_t Linked : 1;
122  uint8_t Sync : 1;
123  uint8_t Wbus16 : 1;
124  uint8_t Obsolete4 : 2;
125  };
126  uint8_t T10VendorId[ 8 ];
127  uint8_t ProductId[ 16 ];
128  uint8_t ProductRevisionLevel[ 4 ];
130 SL_PACK_END()
131 
132 /**************************************************************************/
135 SL_PACK_START(1)
136 typedef struct
137 {
138  uint8_t OpCode;
139  struct
140  {
141  uint8_t Desc : 1;
142  uint8_t Reserved1 : 7;
143  };
144  uint8_t Reserved2;
145  uint8_t Reserved3;
147  uint8_t Control;
149 SL_PACK_END()
150 
151 /**************************************************************************/
154 SL_PACK_START(1)
155 typedef struct
156 {
157  struct
158  {
159  uint8_t ResponseCode : 7;
160  uint8_t Valid : 1;
161  };
162  uint8_t Obsolete;
163  struct
164  {
165  uint8_t SenseKey : 4;
166  uint8_t Reserved : 1;
167  uint8_t Ili : 1;
168  uint8_t Eom : 1;
169  uint8_t FileMark : 1;
170  };
171  uint32_t Information;
173  uint32_t CmdSpecificInfo;
174  uint8_t Asc;
175  uint8_t Ascq;
176  uint8_t Fruc;
177  struct
178  {
179  uint8_t SenseKeySpecific1 : 7;
180  uint8_t Sksv : 1;
181  };
185 SL_PACK_END()
186 
187 /**************************************************************************/
190 SL_PACK_START(1)
191 typedef struct
192 {
193  uint8_t OpCode;
194  struct
195  {
196  uint8_t Obsolete : 1;
197  uint8_t Reserved1 : 7;
198  };
199  uint32_t Lba;
200  uint16_t Reserved2;
201  struct
202  {
203  uint8_t Pmi : 1;
204  uint8_t Reserved3 : 7;
205  };
206  uint8_t Control;
208 SL_PACK_END()
209 
210 /**************************************************************************/
213 SL_PACK_START(1)
214 typedef struct
215 {
219 SL_PACK_END()
220 
221 /**************************************************************************/
224 SL_PACK_START(1)
225 typedef struct
226 {
227  uint8_t OpCode;
228  struct
229  {
230  uint8_t Obsolete : 1;
231  uint8_t FuaNv : 1;
232  uint8_t Reserved1 : 1;
233  uint8_t Fua : 1;
234  uint8_t Dpo : 1;
235  uint8_t RdProtect : 3;
236  };
237  uint32_t Lba;
238  struct
239  {
240  uint8_t GroupNumber : 5;
241  uint8_t Reserved2 : 3;
242  };
243  uint16_t TransferLength;
244  uint8_t Control;
246 SL_PACK_END()
247 
248 /**************************************************************************/
251 SL_PACK_START(1)
252 typedef struct
253 {
254  uint8_t OpCode;
255  struct
256  {
257  uint8_t Obsolete : 1;
258  uint8_t FuaNv : 1;
259  uint8_t Reserved1 : 1;
260  uint8_t Fua : 1;
261  uint8_t Dpo : 1;
262  uint8_t WrProtect : 3;
263  };
264  uint32_t Lba;
265  struct
266  {
267  uint8_t GroupNumber : 5;
268  uint8_t Reserved2 : 3;
269  };
270  uint16_t TransferLength;
271  uint8_t Control;
273 SL_PACK_END()
274 
275 /**************************************************************************/
278 SL_PACK_START(1)
279 typedef struct
280 {
281  uint8_t OpCode;
282  struct
283  {
284  uint8_t Obsolete : 1;
285  uint8_t BytChk : 1;
286  uint8_t Reserved1 : 2;
287  uint8_t Dpo : 1;
288  uint8_t VrProtect : 3;
289  };
290  uint32_t Lba;
291  struct
292  {
293  uint8_t GroupNumber : 5;
294  uint8_t Reserved2 : 2;
295  uint8_t Restricted : 1;
296  };
297  uint16_t Verification;
298  uint8_t Control;
300 SL_PACK_END()
301 
302 /**************************************************************************/
305 SL_PACK_START(1)
306 typedef struct
307 {
308  uint8_t OpCode;
309  struct
310  {
311  uint8_t Immed : 1;
312  uint8_t Reserved1 : 7;
313  };
314  uint8_t Reserved2;
315  struct
316  {
317  uint8_t PowerConditionModifier : 4;
318  uint8_t Reserved3 : 4;
319  };
320  struct
321  {
322  uint8_t Start : 1;
323  uint8_t LoEj : 1;
324  uint8_t No_Flush : 1;
325  uint8_t Reserved4 : 1;
326  uint8_t PowerCondition : 4;
327  };
328  uint8_t Control;
330 SL_PACK_END()
331 
332 /*** MSDSCSI Function prototypes ***/
333 
334 #if defined(USB_HOST)
335 
337 bool MSDSCSI_Inquiry(MSDSCSI_InquiryData_TypeDef *data);
338 bool MSDSCSI_Read10(uint32_t lba, uint16_t sectors, void *data);
339 bool MSDSCSI_ReadCapacity(MSDSCSI_ReadCapacityData_TypeDef *data);
340 bool MSDSCSI_RequestSense(MSDSCSI_RequestSenseData_TypeDef *data);
341 bool MSDSCSI_TestUnitReady(void);
342 bool MSDSCSI_Write10(uint32_t lba, uint16_t sectors, const void *data);
343 
344 #endif
345 
346 #ifdef __cplusplus
347 }
348 #endif
349 
353 #endif /* __MSDSCSI_H */
SCSI Inquiry response data typedef.
Definition: msdscsi.h:76
bool MSDSCSI_Init(USBH_Ep_TypeDef *out, USBH_Ep_TypeDef *in)
MSDSCSI module initialization.
Definition: msdscsi.c:157
bool MSDSCSI_RequestSense(MSDSCSI_RequestSenseData_TypeDef *data)
Issue a SCSI Request Sense command.
Definition: msdscsi.c:267
#define SL_PACK_END()
Macro for handling packed structs. Use this macro after the struct definition. With GCC...
Definition: em_common.h:157
SCSI Request Sense response data typedef.
Definition: msdscsi.h:155
SCSI Read Capacity Command Descriptor Block (CDB) typedef.
Definition: msdscsi.h:191
bool MSDSCSI_TestUnitReady(void)
Issue a SCSI Test Unit Ready command.
Definition: msdscsi.c:283
SCSI Read Capacity response data typedef.
Definition: msdscsi.h:214
SCSI Inquiry Command Descriptor Block (CDB) typedef.
Definition: msdscsi.h:57
uint16_t TransferLength
Definition: msdscsi.h:243
#define SL_PACK_START(x)
Macro for handling packed structs. Use this macro before the struct definition. X denotes the max...
Definition: em_common.h:150
SCSI Verify 10 Command Descriptor Block (CDB) typedef.
Definition: msdscsi.h:279
SCSI Start Stop Unit Command Descriptor Block (CDB) typedef.
Definition: msdscsi.h:306
bool MSDSCSI_Read10(uint32_t lba, uint16_t sectors, void *data)
Issue a SCSI Read(10) command.
Definition: msdscsi.c:213
SCSI Read 10 Command Descriptor Block (CDB) typedef.
Definition: msdscsi.h:225
bool MSDSCSI_ReadCapacity(MSDSCSI_ReadCapacityData_TypeDef *data)
Issue a SCSI Read Capacity command.
Definition: msdscsi.c:240
SCSI Request Sense Command Descriptor Block (CDB) typedef.
Definition: msdscsi.h:136
bool MSDSCSI_Write10(uint32_t lba, uint16_t sectors, const void *data)
Perform a SCSI Write(10) command.
Definition: msdscsi.c:307
bool MSDSCSI_Inquiry(MSDSCSI_InquiryData_TypeDef *data)
Issue a SCSI Inquiry command.
Definition: msdscsi.c:189
SCSI Write 10 Command Descriptor Block (CDB) typedef.
Definition: msdscsi.h:252
#define SL_ATTRIBUTE_PACKED
GCC style macro for handling packed structs.
Definition: em_common.h:143
USB HOST endpoint status data.
Definition: em_usb.h:861
uint16_t AllocationLength
Definition: msdscsi.h:67
uint16_t TransferLength
Definition: msdscsi.h:270