USBLibAPIGuide  1.00.00.01
Data Structures | Macros | Enumerations | Functions | Variables
Msc_device_class_api

Data Structures

struct  tMSCDMedia
 Media Access functions. More...
 
struct  tMSCInstance
 
struct  tUSBDMSCDevice
 

Macros

#define USBD_FLAG_DMA_IN   0x00000001
 
#define USBD_FLAG_DMA_OUT   0x00000002
 
#define USBD_FLAG_ALLOW_REMOVAL   0x00000004
 
#define USB_RX_ERROR_FLAGS
 
#define USB_MSC_SUBCLASS_SCSI   0x6
 
#define USB_MSC_PROTO_BULKONLY   0x50
 
#define DATA_IN_ENDPOINT   USB_EP_1
 
#define DATA_OUT_ENDPOINT   USB_EP_1
 
#define DATA_IN_EP_MAX_SIZE   64
 
#define DATA_OUT_EP_MAX_SIZE   64
 
#define COMMAND_BUFFER_SIZE   64
 
#define STATE_SCSI_IDLE   0x00
 
#define STATE_SCSI_SEND_BLOCKS   0x01
 
#define STATE_SCSI_RECEIVE_BLOCKS   0x02
 
#define STATE_SCSI_SEND_STATUS   0x03
 
#define STATE_SCSI_SENT_STATUS   0x04
 
#define NUM_MSC_SECTIONS
 
#define DEVICE_BLOCK_SIZE   512
 
#define MSCINTERFACE_SIZE   (23)
 
#define COMPOSITE_DMSC_SIZE   (MSCINTERFACE_SIZE)
 
#define USBD_MSC_EVENT_IDLE   (USBD_MSC_EVENT_BASE + 0)
 
#define USBD_MSC_EVENT_READING   (USBD_MSC_EVENT_BASE + 1)
 This event indicates that the host is reading the storage media. More...
 
#define USBD_MSC_EVENT_WRITING   (USBD_MSC_EVENT_BASE + 2)
 This event indicates that the host is writing to the storage media. More...
 

Enumerations

enum  tUSBDMSCMediaStatus { eUSBDMSCMediaPresent, eUSBDMSCMediaNotPresent, eUSBDMSCMediaStopped, eUSBDMSCMediaUnknown }
 

Functions

uint32_t USBDSCSICommand (tUSBDMSCDevice *psMSCDevice, tMSCCBW *psSCSICBW)
 
void USBDMSCMediaChange (void *pvMSCDevice, tUSBDMSCMediaStatus iMediaStatus)
 
void * USBDMSCInit (uint32_t ui32Index, tUSBDMSCDevice *psMSCDevice)
 
void * USBDMSCCompositeInit (uint32_t ui32Index, tUSBDMSCDevice *psMSCDevice, tCompositeEntry *psCompEntry)
 
void USBDMSCTerm (void *pvMSCDevice)
 

Variables

const uint8_t g_pui8MSCInterface [MSCINTERFACE_SIZE]
 
const tConfigSection g_sMSCConfigSection
 
const tConfigSection g_sMSCInterfaceSection
 
const tConfigSectiong_psMSCSections []
 
const tConfigHeader g_sMSCConfigHeader
 
const tConfigHeader *const g_ppsMSCConfigDescriptors []
 
const tCustomHandlers g_sMSCHandlers
 

Detailed Description

Macro Definition Documentation

§ USBD_FLAG_DMA_IN

#define USBD_FLAG_DMA_IN   0x00000001

§ USBD_FLAG_DMA_OUT

#define USBD_FLAG_DMA_OUT   0x00000002

§ USBD_FLAG_ALLOW_REMOVAL

#define USBD_FLAG_ALLOW_REMOVAL   0x00000004

§ USB_RX_ERROR_FLAGS

#define USB_RX_ERROR_FLAGS
Value:
USBERR_DEV_RX_OVERRUN | \
USBERR_DEV_RX_FIFO_FULL)
#define USBERR_DEV_RX_DATA_ERROR
The device detected a CRC error in received data.
Definition: usblib.h:1303

§ USB_MSC_SUBCLASS_SCSI

#define USB_MSC_SUBCLASS_SCSI   0x6

§ USB_MSC_PROTO_BULKONLY

#define USB_MSC_PROTO_BULKONLY   0x50

§ DATA_IN_ENDPOINT

#define DATA_IN_ENDPOINT   USB_EP_1

§ DATA_OUT_ENDPOINT

#define DATA_OUT_ENDPOINT   USB_EP_1

§ DATA_IN_EP_MAX_SIZE

#define DATA_IN_EP_MAX_SIZE   64

§ DATA_OUT_EP_MAX_SIZE

#define DATA_OUT_EP_MAX_SIZE   64

§ COMMAND_BUFFER_SIZE

#define COMMAND_BUFFER_SIZE   64

§ STATE_SCSI_IDLE

#define STATE_SCSI_IDLE   0x00

§ STATE_SCSI_SEND_BLOCKS

#define STATE_SCSI_SEND_BLOCKS   0x01

§ STATE_SCSI_RECEIVE_BLOCKS

#define STATE_SCSI_RECEIVE_BLOCKS   0x02

§ STATE_SCSI_SEND_STATUS

#define STATE_SCSI_SEND_STATUS   0x03

§ STATE_SCSI_SENT_STATUS

#define STATE_SCSI_SENT_STATUS   0x04

§ NUM_MSC_SECTIONS

#define NUM_MSC_SECTIONS
Value:
(sizeof(g_psMSCSections) / \
sizeof(g_psMSCSections[0]))
const tConfigSection * g_psMSCSections[]
Definition: usbdmsc.c:273

§ DEVICE_BLOCK_SIZE

#define DEVICE_BLOCK_SIZE   512

§ MSCINTERFACE_SIZE

#define MSCINTERFACE_SIZE   (23)

§ COMPOSITE_DMSC_SIZE

#define COMPOSITE_DMSC_SIZE   (MSCINTERFACE_SIZE)

The size of the memory that should be allocated to create a configuration descriptor for a single instance of the USB Audio Device. This does not include the configuration descriptor which is automatically ignored by the composite device class.

§ USBD_MSC_EVENT_IDLE

#define USBD_MSC_EVENT_IDLE   (USBD_MSC_EVENT_BASE + 0)

This event indicates that the host has completed other operations and is no longer accessing the device.

§ USBD_MSC_EVENT_READING

#define USBD_MSC_EVENT_READING   (USBD_MSC_EVENT_BASE + 1)

This event indicates that the host is reading the storage media.

§ USBD_MSC_EVENT_WRITING

#define USBD_MSC_EVENT_WRITING   (USBD_MSC_EVENT_BASE + 2)

This event indicates that the host is writing to the storage media.

Enumeration Type Documentation

§ tUSBDMSCMediaStatus

Enumerator
eUSBDMSCMediaPresent 
eUSBDMSCMediaNotPresent 
eUSBDMSCMediaStopped 
eUSBDMSCMediaUnknown 

Function Documentation

§ USBDSCSICommand()

uint32_t USBDSCSICommand ( tUSBDMSCDevice psMSCDevice,
tMSCCBW *  psSCSICBW 
)

§ USBDMSCMediaChange()

void USBDMSCMediaChange ( void *  pvMSCDevice,
tUSBDMSCMediaStatus  iMediaStatus 
)

This function is used by an application if it can detect insertion or removal of the media.

Parameters
pvMSCDeviceis the mass storage device instance that had a media change.
iMediaStatusis the updated status for the media.

This function should be called by an application when it detects a change in the status of the media in use by the USB mass storage class. The iMediaStatus parameter will indicate the new status of the media and can also indicate that the application has no knowledge of the media state.

There are currently the three following values for the iMediaStatus parameter:

  • eUSBDMSCMediaPresent indicates that the media is present or has been added.
  • eUSBDMSCMediaNotPresent indicates that the media is not present or was removed.
  • eUSBDMSCMediaUnknown indicates that the application has no knowledge of the media state and the USB mass storage class.

It will be left up to the application to call this function whenever it detects a change or simply call it once with eUSBDMSCMediaUnknown and allow the mass storage class to infer the state from the remaining device APIs.

Note
It is recommended that the application use this function to inform the mass storage class of media state changes as it will lead to a more responsive system.
Returns
None.

References tMSCInstance::iMediaStatus, and tUSBDMSCDevice::sPrivateData.

§ USBDMSCInit()

void * USBDMSCInit ( uint32_t  ui32Index,
tUSBDMSCDevice psMSCDevice 
)

This function should be called once for the mass storage class device to initialized basic operation and prepare for enumeration.

Parameters
ui32Indexis the index of the USB controller to initialize for mass storage class device operation.
psMSCDevicepoints to a structure containing parameters customizing the operation of the mass storage device.

In order for an application to initialize the USB device mass storage class, it must first call this function with the a valid mass storage device class structure in the psMSCDevice parameter. This allows this function to initialize the USB controller and device code to be prepared to enumerate and function as a USB mass storage device.

This function returns a void pointer that must be passed in to all other APIs used by the mass storage class.

See the documentation on the tUSBDMSCDevice structure for more information on how to properly fill the structure members.

Returns
Returns 0 on failure or a non-zero void pointer on success.

References tUSBDMSCDevice::ppui8StringDescriptors, and USBDMSCCompositeInit().

§ USBDMSCCompositeInit()

void * USBDMSCCompositeInit ( uint32_t  ui32Index,
tUSBDMSCDevice psMSCDevice,
tCompositeEntry psCompEntry 
)

This function should be called once for the mass storage class device to initialized basic operation and prepare for enumeration.

Parameters
ui32Indexis the index of the USB controller to initialize for mass storage class device operation.
psMSCDevicepoints to a structure containing parameters customizing the operation of the mass storage device.
psCompEntryis the composite device entry to initialize when creating a composite device.

In order for an application to initialize the USB device mass storage class, it must first call this function with the a valid mass storage device class structure in the psMSCDevice parameter. This allows this function to initialize the USB controller and device code to be prepared to enumerate and function as a USB mass storage device. If this mass storage device is part of a composite device, then the psCompEntry should point to the composite device entry to initialize. This is part of the array that is passed to the USBDCompositeInit() function.

This function returns a void pointer that must be passed in to all other APIs used by the mass storage class.

See the documentation on the tUSBDMSCDevice structure for more information on how to properly fill the structure members.

Returns
Returns zero on failure or a non-zero instance value that should be used with the remaining USB mass storage APIs.

References tMSCInstance::bConnected, eUSBDMSCMediaUnknown, g_sMSCHandlers, tMSCInstance::iMediaStatus, tUSBDMSCDevice::ppui8StringDescriptors, tDeviceInfo::psCallbacks, tCompositeEntry::psDevInfo, tDeviceInfo::pui8DeviceDescriptor, tCompositeEntry::pvInstance, tMSCInstance::sDevInfo, tUSBDMSCDevice::sPrivateData, and tMSCInstance::ui32USBBase.

Referenced by USBDMSCInit().

§ USBDMSCTerm()

void USBDMSCTerm ( void *  pvMSCDevice)

Shuts down the mass storage device.

Parameters
pvMSCDeviceis the pointer to the device instance structure as returned by USBDMSCInit() or USBDMSCCompositeInit().

This function terminates mass storage operation for the instance supplied and removes the device from the USB bus. Following this call, the pvMSCDevice instance may not me used in any other call to the mass storage device other than USBDMSCInit() or USBDMSCCompositeInit().

Returns
None.

References tMSCDMedia::pfnClose, tMSCInstance::pvMedia, tUSBDMSCDevice::sMediaFunctions, tUSBDMSCDevice::sPrivateData, and USBDCDTerm().

Variable Documentation

§ g_pui8MSCInterface

const uint8_t g_pui8MSCInterface[MSCINTERFACE_SIZE]

§ g_sMSCConfigSection

const tConfigSection g_sMSCConfigSection
Initial value:
=
{
sizeof(g_pui8MSCDescriptor),
g_pui8MSCDescriptor
}

§ g_sMSCInterfaceSection

const tConfigSection g_sMSCInterfaceSection
Initial value:
=
{
}
const uint8_t g_pui8MSCInterface[MSCINTERFACE_SIZE]
Definition: usbdmsc.c:209

§ g_psMSCSections

const tConfigSection* g_psMSCSections[]
Initial value:
=
{
}
const tConfigSection g_sMSCConfigSection
Definition: usbdmsc.c:255
const tConfigSection g_sMSCInterfaceSection
Definition: usbdmsc.c:261

§ g_sMSCConfigHeader

const tConfigHeader g_sMSCConfigHeader
Initial value:
=
{
}
const tConfigSection * g_psMSCSections[]
Definition: usbdmsc.c:273
#define NUM_MSC_SECTIONS
Definition: usbdmsc.c:279

§ g_ppsMSCConfigDescriptors

const tConfigHeader* const g_ppsMSCConfigDescriptors[]
Initial value:
=
{
}
const tConfigHeader g_sMSCConfigHeader
Definition: usbdmsc.c:289

§ g_sMSCHandlers

const tCustomHandlers g_sMSCHandlers

Referenced by USBDMSCCompositeInit().

© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale