libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
USB MSC Type Definitions

Defined Constants and Types for the USB MSC Type Definitions More...

Macros

#define USB_CLASS_MSC   0x08
 
#define USB_MSC_SUBCLASS_RBC   0x01
 
#define USB_MSC_SUBCLASS_ATAPI   0x02
 
#define USB_MSC_SUBCLASS_UFI   0x04
 
#define USB_MSC_SUBCLASS_SCSI   0x06
 
#define USB_MSC_SUBCLASS_LOCKABLE   0x07
 
#define USB_MSC_SUBCLASS_IEEE1667   0x08
 
#define USB_MSC_PROTOCOL_CBI   0x00
 
#define USB_MSC_PROTOCOL_CBI_ALT   0x01
 
#define USB_MSC_PROTOCOL_BBB   0x50
 
#define USB_MSC_REQ_CODES_ADSC   0x00
 
#define USB_MSC_REQ_CODES_GET   0xFC
 
#define USB_MSC_REQ_CODES_PUT   0xFD
 
#define USB_MSC_REQ_CODES_GML   0xFE
 
#define USB_MSC_REQ_CODES_BOMSR   0xFF
 
#define USB_MSC_REQ_BULK_ONLY_RESET   0xFF
 
#define USB_MSC_REQ_GET_MAX_LUN   0xFE
 

Typedefs

typedef struct _usbd_mass_storage usbd_mass_storage
 

Functions

usbd_mass_storageusb_msc_init (usbd_device *usbd_dev, uint8_t ep_in, uint8_t ep_in_size, uint8_t ep_out, uint8_t ep_out_size, const char *vendor_id, const char *product_id, const char *product_revision_level, const uint32_t block_count, int(*read_block)(uint32_t lba, uint8_t *copy_to), int(*write_block)(uint32_t lba, const uint8_t *copy_from))
 Initializes the USB Mass Storage subsystem. More...
 

Detailed Description

Defined Constants and Types for the USB MSC Type Definitions

Version
1.0.0
Author
© 2013 Weston Schmidt westo.nosp@m.n_sc.nosp@m.hmidt.nosp@m.@alu.nosp@m.mni.p.nosp@m.urdu.nosp@m.e.edu Pavol Rusnak stick.nosp@m.@gk2.nosp@m..sk
Date
27 June 2013

LGPL License Terms libopencm3 License

Macro Definition Documentation

◆ USB_CLASS_MSC

#define USB_CLASS_MSC   0x08

Definition at line 58 of file msc.h.

◆ USB_MSC_PROTOCOL_BBB

#define USB_MSC_PROTOCOL_BBB   0x50

Definition at line 71 of file msc.h.

◆ USB_MSC_PROTOCOL_CBI

#define USB_MSC_PROTOCOL_CBI   0x00

Definition at line 69 of file msc.h.

◆ USB_MSC_PROTOCOL_CBI_ALT

#define USB_MSC_PROTOCOL_CBI_ALT   0x01

Definition at line 70 of file msc.h.

◆ USB_MSC_REQ_BULK_ONLY_RESET

#define USB_MSC_REQ_BULK_ONLY_RESET   0xFF

Definition at line 81 of file msc.h.

◆ USB_MSC_REQ_CODES_ADSC

#define USB_MSC_REQ_CODES_ADSC   0x00

Definition at line 74 of file msc.h.

◆ USB_MSC_REQ_CODES_BOMSR

#define USB_MSC_REQ_CODES_BOMSR   0xFF

Definition at line 78 of file msc.h.

◆ USB_MSC_REQ_CODES_GET

#define USB_MSC_REQ_CODES_GET   0xFC

Definition at line 75 of file msc.h.

◆ USB_MSC_REQ_CODES_GML

#define USB_MSC_REQ_CODES_GML   0xFE

Definition at line 77 of file msc.h.

◆ USB_MSC_REQ_CODES_PUT

#define USB_MSC_REQ_CODES_PUT   0xFD

Definition at line 76 of file msc.h.

◆ USB_MSC_REQ_GET_MAX_LUN

#define USB_MSC_REQ_GET_MAX_LUN   0xFE

Definition at line 82 of file msc.h.

◆ USB_MSC_SUBCLASS_ATAPI

#define USB_MSC_SUBCLASS_ATAPI   0x02

Definition at line 62 of file msc.h.

◆ USB_MSC_SUBCLASS_IEEE1667

#define USB_MSC_SUBCLASS_IEEE1667   0x08

Definition at line 66 of file msc.h.

◆ USB_MSC_SUBCLASS_LOCKABLE

#define USB_MSC_SUBCLASS_LOCKABLE   0x07

Definition at line 65 of file msc.h.

◆ USB_MSC_SUBCLASS_RBC

#define USB_MSC_SUBCLASS_RBC   0x01

Definition at line 61 of file msc.h.

◆ USB_MSC_SUBCLASS_SCSI

#define USB_MSC_SUBCLASS_SCSI   0x06

Definition at line 64 of file msc.h.

◆ USB_MSC_SUBCLASS_UFI

#define USB_MSC_SUBCLASS_UFI   0x04

Definition at line 63 of file msc.h.

Typedef Documentation

◆ usbd_mass_storage

Definition at line 46 of file msc.h.

Function Documentation

◆ usb_msc_init()

usbd_mass_storage * usb_msc_init ( usbd_device usbd_dev,
uint8_t  ep_in,
uint8_t  ep_in_size,
uint8_t  ep_out,
uint8_t  ep_out_size,
const char *  vendor_id,
const char *  product_id,
const char *  product_revision_level,
const uint32_t  block_count,
int(*)(uint32_t lba, uint8_t *copy_to)  read_block,
int(*)(uint32_t lba, const uint8_t *copy_from)  write_block 
)

Initializes the USB Mass Storage subsystem.

Note
Currently you can only have this profile active.
Parameters
[in]usbd_devThe USB device to associate the Mass Storage with.
[in]ep_inThe USB 'IN' endpoint.
[in]ep_in_sizeThe maximum endpoint size. Valid values: 8, 16, 32 or 64
[in]ep_outThe USB 'OUT' endpoint.
[in]ep_out_sizeThe maximum endpoint size. Valid values: 8, 16, 32 or 64
[in]vendor_idThe SCSI vendor ID to return. Maximum used length is 8.
[in]product_idThe SCSI product ID to return. Maximum used length is 16.
[in]product_revision_levelThe SCSI product revision level to return. Maximum used length is 4.
[in]block_countThe number of 512-byte blocks available.
[in]read_blockThe function called when the host requests to read a LBA block. Must NOT be NULL.
[in]write_blockThe function called when the host requests to write a LBA block. Must NOT be NULL.
Returns
Pointer to the usbd_mass_storage struct.

Definition at line 801 of file usb_msc.c.

References _mass_storage, usb_msc_trans::block_count, _usbd_mass_storage::block_count, usb_msc_trans::byte_count, usb_msc_trans::bytes_to_read, usb_msc_trans::bytes_to_write, usb_msc_trans::cbw_cnt, usb_msc_trans::csw_sent, usb_msc_trans::csw_valid, usb_msc_trans::current_block, _usbd_mass_storage::ep_in, _usbd_mass_storage::ep_in_size, _usbd_mass_storage::ep_out, _usbd_mass_storage::ep_out_size, usb_msc_trans::lba_start, _usbd_mass_storage::lock, msc_set_config(), _usbd_mass_storage::product_id, _usbd_mass_storage::product_revision_level, _usbd_mass_storage::read_block, set_sbc_status_good(), _usbd_mass_storage::trans, _usbd_mass_storage::unlock, _usbd_mass_storage::usbd_dev, usbd_register_set_config_callback(), _usbd_mass_storage::vendor_id, and _usbd_mass_storage::write_block.

Here is the call graph for this function: