1 /* 2 * Copyright (c) 2022, sakumisu 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #ifndef USBH_MSC_H 7 #define USBH_MSC_H 8 9 #include "usb_msc.h" 10 #include "usb_scsi.h" 11 12 struct usbh_msc { 13 struct usbh_hubport *hport; 14 15 uint8_t intf; /* Data interface number */ 16 uint8_t sdchar; 17 usbh_pipe_t bulkin; /* Bulk IN endpoint */ 18 usbh_pipe_t bulkout; /* Bulk OUT endpoint */ 19 struct usbh_urb bulkin_urb; /* Bulk IN urb */ 20 struct usbh_urb bulkout_urb; /* Bulk OUT urb */ 21 uint32_t blocknum; /* Number of blocks on the USB mass storage device */ 22 uint16_t blocksize; /* Block size of USB mass storage device */ 23 }; 24 25 struct usbh_msc_modeswitch_config { 26 const char *name; 27 uint16_t vid; /* Vendor ID (for vendor/product specific devices) */ 28 uint16_t pid; /* Product ID (for vendor/product specific devices) */ 29 const uint8_t *message_content; 30 }; 31 32 void usbh_msc_modeswitch_enable(struct usbh_msc_modeswitch_config *config); 33 int usbh_msc_scsi_write10(struct usbh_msc *msc_class, uint32_t start_sector, const uint8_t *buffer, uint32_t nsectors); 34 int usbh_msc_scsi_read10(struct usbh_msc *msc_class, uint32_t start_sector, const uint8_t *buffer, uint32_t nsectors); 35 36 void usbh_msc_run(struct usbh_msc *msc_class); 37 void usbh_msc_stop(struct usbh_msc *msc_class); 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 #ifdef __cplusplus 44 } 45 #endif 46 47 #endif /* USBH_MSC_H */ 48