![]() |
USB Component
Version 6.4
MDK-Professional Middleware for USB Device and Host
|
USB Host functions to support Mass Storage Class (MSC) USB Devices. More...
Content | |
Configuration | |
Configuration of the USB Host MSC Class in µVision. | |
Functions | |
usbStatus | USBH_MSC_GetDeviceStatus (uint8_t instance) |
Get status of Mass Storage Device. | |
usbStatus | USBH_MSC_Read (uint8_t instance, uint32_t lba, uint32_t cnt, uint8_t *buf) |
Read requested number of blocks from Mass Storage Device. | |
usbStatus | USBH_MSC_Write (uint8_t instance, uint32_t lba, uint32_t cnt, const uint8_t *buf) |
Write requested number of blocks to Mass Storage Device. | |
usbStatus | USBH_MSC_ReadCapacity (uint8_t instance, uint32_t *block_count, uint32_t *block_size) |
Read capacity of Mass Storage Device. | |
USB Host functions to support Mass Storage Class (MSC) USB Devices.
The Mass Storage Class (MSC) in the USB Host Component provides physical access to a data storage device. The USB MSC drive in the File System Component gives file I/O access to that data storage.
Software Stack
The following picture shows how the software stack is built-up for MSC device support:
Refer to:
Software Structure
The application starts the USB Host by calling USBH_Initialize. The USB Host Core will wait until an USB MSC device is attached to the system. As soon as this happens it will enumerate the device and it will be ready to be used by the application. The handling of the MSC class events is implemented in USBH_MSC_Thread.
The data functions USBH_MSC_Read and USBH_MSC_Write can be either called by the user thread directly or called indirectly when the user thread is using file system routines like fread/fwrite which use the USB MSC Device as media for data storage.
Steps to create an USB Host application with MSC support:
usbStatus USBH_MSC_GetDeviceStatus | ( | uint8_t | instance | ) |
Get status of Mass Storage Device.
[in] | instance | instance of MSC Device. |
The function USBH_MSC_GetDeviceStatus checks if a mass storage device is connected and initialized.
The argument instance specifies the MSC device instance.
Code Example
usbStatus USBH_MSC_Read | ( | uint8_t | instance, |
uint32_t | lba, | ||
uint32_t | cnt, | ||
uint8_t * | buf | ||
) |
Read requested number of blocks from Mass Storage Device.
[in] | instance | instance of MSC Device. |
[in] | lba | logical block address of first block to read. |
[in] | cnt | number of contiguous blocks to read. |
[out] | buf | data buffer in which to read data. |
The function USBH_MSC_Read reads data from physical memory blocks of a mass storage device.
The argument instance specifies the MSC device instance.
The argument lba is the physical address of the first block to be read.
The argument cnt is the number of blocks to be read.
The argument buf is a pointer to the location where the data will be stored.
Code Example
usbStatus USBH_MSC_ReadCapacity | ( | uint8_t | instance, |
uint32_t * | block_count, | ||
uint32_t * | block_size | ||
) |
Read capacity of Mass Storage Device.
[in] | instance | instance of MSC Device. |
[out] | block_count | pointer to where total number of blocks available will be read. |
[out] | block_size | pointer to where block size will be read. |
The function USBH_MSC_ReadCapacity gets information about the capacity of a mass storage device.
The argument instance specifies the MSC device instance.
The argument block_count is a pointer to a variable that stores the total number of available blocks.
The argument block_size is a pointer to a variable that stores the block size (in bytes).
Code Example
usbStatus USBH_MSC_Write | ( | uint8_t | instance, |
uint32_t | lba, | ||
uint32_t | cnt, | ||
const uint8_t * | buf | ||
) |
Write requested number of blocks to Mass Storage Device.
[in] | instance | instance of MSC Device. |
[in] | lba | logical address of first block to write. |
[in] | cnt | number of contiguous blocks to write. |
[in] | buf | data buffer containing data to write. |
The function USBH_MSC_Write writes data to physical memory blocks of the mass storage device.
The argument instance specifies the MSC device instance.
The argument lba is the physical address of the first block to be written.
The argument cnt is the number of blocks to be written.
The argument buf is a pointer to the location that contains the data to be written.
Code Example