1 #if !defined(__MASSTORAGE_H__)
2 #define __MASSTORAGE_H__
5 #include <avr/pgmspace.h>
12 #if defined(ARDUINO) && ARDUINO >=100
24 #define SWAP(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b)))
26 #define bmREQ_MASSOUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
27 #define bmREQ_MASSIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
30 #define MASS_SUBCLASS_SCSI_NOT_REPORTED 0x00 // De facto use
31 #define MASS_SUBCLASS_RBC 0x01
32 #define MASS_SUBCLASS_ATAPI 0x02 // MMC-5 (ATAPI)
33 #define MASS_SUBCLASS_OBSOLETE1 0x03 // Was QIC-157
34 #define MASS_SUBCLASS_UFI 0x04 // Specifies how to interface Floppy Disk Drives to USB
35 #define MASS_SUBCLASS_OBSOLETE2 0x05 // Was SFF-8070i
36 #define MASS_SUBCLASS_SCSI 0x06 // SCSI Transparent Command Set
37 #define MASS_SUBCLASS_LSDFS 0x07 // Specifies how host has to negotiate access before trying SCSI
38 #define MASS_SUBCLASS_IEEE1667 0x08
41 #define MASS_PROTO_CBI 0x00 // CBI (with command completion interrupt)
42 #define MASS_PROTO_CBI_NO_INT 0x01 // CBI (without command completion interrupt)
43 #define MASS_PROTO_OBSOLETE 0x02
44 #define MASS_PROTO_BBB 0x50 // Bulk Only Transport
45 #define MASS_PROTO_UAS 0x62
48 #define MASS_REQ_ADSC 0x00
49 #define MASS_REQ_GET 0xFC
50 #define MASS_REQ_PUT 0xFD
51 #define MASS_REQ_GET_MAX_LUN 0xFE
52 #define MASS_REQ_BOMSR 0xFF // Bulk-Only Mass Storage Reset
54 #define MASS_CBW_SIGNATURE 0x43425355
55 #define MASS_CSW_SIGNATURE 0x53425355
57 #define MASS_CMD_DIR_OUT (0 << 7)
58 #define MASS_CMD_DIR_IN (1 << 7)
60 #define SCSI_CMD_INQUIRY 0x12
61 #define SCSI_CMD_REPORT_LUNS 0xA0
62 #define SCSI_CMD_REQUEST_SENSE 0x03
63 #define SCSI_CMD_FORMAT_UNIT 0x04
64 #define SCSI_CMD_READ_6 0x08
65 #define SCSI_CMD_READ_10 0x28
66 #define SCSI_CMD_READ_CAPACITY_10 0x25
67 #define SCSI_CMD_TEST_UNIT_READY 0x00
68 #define SCSI_CMD_WRITE_6 0x0A
69 #define SCSI_CMD_WRITE_10 0x2A
70 #define SCSI_CMD_MODE_SENSE_6 0x1A
71 #define SCSI_CMD_MODE_SENSE_10 0x5A
73 #define MASS_ERR_SUCCESS 0x00
74 #define MASS_ERR_PHASE_ERROR 0x01
75 #define MASS_ERR_DEVICE_DISCONNECTED 0x11
76 #define MASS_ERR_UNABLE_TO_RECOVER 0x12 // Reset recovery error
77 #define MASS_ERR_GENERAL_USB_ERROR 0xFF
79 #define MASS_TRANS_FLG_CALLBACK 0x01 // Callback is involved
80 #define MASS_TRANS_FLG_NO_STALL_CHECK 0x02 // STALL condition is not checked
81 #define MASS_TRANS_FLG_NO_PHASE_CHECK 0x04 // PHASE_ERROR is not checked
183 #define MASS_MAX_ENDPOINTS 3
235 uint8_t
Inquiry(uint8_t lun, uint16_t size, uint8_t *buf);
237 uint8_t
ReadCapacity(uint8_t lun, uint16_t size, uint8_t *buf);
238 uint8_t
RequestSense(uint8_t lun, uint16_t size, uint8_t *buf);
243 virtual uint8_t
Init(uint8_t parent, uint8_t port,
bool lowspeed);
245 virtual uint8_t
Poll();
252 #endif // __MASSTORAGE_H__