USB Component
Version 6.17.0
MDK Middleware for USB Device and Host Communication
|
User API reference of the Mass Storage Class. More...
Functions | |
void | USBD_MSCn_Initialize (void) |
Callback function called during USBD_Initialize to initialize all Logical Units of the USB MSC class instance. More... | |
void | USBD_MSCn_Uninitialize (void) |
Callback function called during USBD_Uninitialize to de-initialize all Logical Units of the USB MSC class instance. More... | |
bool | USBD_MSCn_GetCacheInfo (uint32_t *buffer, uint32_t *size) |
Callback function called to get cache information. More... | |
bool | USBD_MSCn_GetMediaCapacity (uint32_t *block_count, uint32_t *block_size) |
Callback function called to get media capacity. More... | |
bool | USBD_MSCn_Read (uint32_t lba, uint32_t cnt, uint8_t *buf) |
Callback function called to read data from media. More... | |
bool | USBD_MSCn_Write (uint32_t lba, uint32_t cnt, const uint8_t *buf) |
Callback function called to write data to media. More... | |
uint32_t | USBD_MSCn_CheckMedia (void) |
Callback function called to check media presence and write protect status. More... | |
uint8_t | USBD_MSCn_GetMaxLUN (void) |
Callback function called to get maximum number of logical units. More... | |
bool | USBD_MSCn_LUN_GetMediaCapacity (uint8_t lun, uint32_t *block_count, uint32_t *block_size) |
Callback function called to get media capacity of a logical unit. More... | |
bool | USBD_MSCn_LUN_Read (uint8_t lun, uint32_t lba, uint32_t cnt, uint8_t *buf) |
Callback function called to read data from media of a logical unit. More... | |
bool | USBD_MSCn_LUN_Write (uint8_t lun, uint32_t lba, uint32_t cnt, const uint8_t *buf) |
Callback function called to write data to media of a logical unit. More... | |
uint32_t | USBD_MSCn_LUN_CheckMedia (uint8_t lun) |
Callback function called to check media presence and write protect status of a logical unit. More... | |
int32_t | USBD_MSCn_SetMediaOwnerUSB (void) |
Set USB as media owner. More... | |
int32_t | USBD_MSCn_SetMediaOwnerFS (void) |
Set File System as media owner. More... | |
User API reference of the Mass Storage Class.
void USBD_MSCn_Initialize | ( | void | ) |
Callback function called during USBD_Initialize to initialize all Logical Units of the USB MSC class instance.
The function USBD_MSCn_Initialize is called automatically upon initialization of a Mass Storage Class Device and needs no invocation in the user code.
Modify this function to the application's needs to allocate resources and initialize additional peripherals.
Code Example
void USBD_MSCn_Uninitialize | ( | void | ) |
Callback function called during USBD_Uninitialize to de-initialize all Logical Units of the USB MSC class instance.
The function USBD_MSCn_Uninitialize is called automatically upon de-initialization of a Mass Storage Class Device and needs no invocation in the user code. If USBD_MSCn_Initialize has been adapted to the application, USBD_MSCn_Uninitialize should release resources and should de-initialize peripherals.
Code Example
bool USBD_MSCn_GetCacheInfo | ( | uint32_t * | buffer, |
uint32_t * | size | ||
) |
Callback function called to get cache information.
[out] | buffer | cache buffer address. |
[out] | size | cache buffer size. operation execution status :
|
The function USBD_MSCn_GetCacheInfo enables an MSC device to reuse RAM used by the File System for caching purposes as USB cache. This is required when a USB Host has control over the media so that it cannot be accessed by File System.
The argument buffer returns the cache buffer address, while the argument size returns the size of the cache buffer.
Code Example
bool USBD_MSCn_GetMediaCapacity | ( | uint32_t * | block_count, |
uint32_t * | block_size | ||
) |
Callback function called to get media capacity.
[out] | block_count | total number of blocks on media. |
[out] | block_size | media block size. operation execution status :
|
The function USBD_MSCn_GetMediaCapacity can be used to determine the geometry of the attached storage media.
The argument block_count returns the total number of blocks on the media, while the argument block_size returns the block size of the media.
Code Example
bool USBD_MSCn_Read | ( | uint32_t | lba, |
uint32_t | cnt, | ||
uint8_t * | buf | ||
) |
Callback function called to read data from media.
[in] | lba | logical address of first block to read. |
[in] | cnt | number of contiguous blocks to read from media. |
[out] | buf | data buffer for data read from media. operation execution status :
|
The function USBD_MSCn_Read reads the data that should be returned to the USB Host that requested it.
The argument lba specifies the logical address of the first block that is to be read.
The argument cnt specifies the number of contiguous blocks to be read from the media.
The argument buf is pointing to the buffer where the read data should be stored.
Modify this function to the application's needs.
Code Example
bool USBD_MSCn_Write | ( | uint32_t | lba, |
uint32_t | cnt, | ||
const uint8_t * | buf | ||
) |
Callback function called to write data to media.
[in] | lba | logical address of first block to write. |
[in] | cnt | number of contiguous blocks to write to media. |
[in] | buf | data buffer containing data to write to media. operation execution status :
|
The function USBD_MSCn_Write writes data received from the USB Host.
The argument lba specifies the logical address of the first block that is to be written.
The argument cnt specifies the number of contiguous blocks to be written to the media.
The argument buf is pointing to the buffer containing the data to be written.
Modify this function to the application's needs.
Code Example
uint32_t USBD_MSCn_CheckMedia | ( | void | ) |
Callback function called to check media presence and write protect status.
The function USBD_MSCn_CheckMedia is called automatically upon specific USB Host requests (like Test Unit Ready) to check if media is ready for read/write operations. It needs no invocation in the user code. If media check is not available in hardware this function can be omitted.
Modify this function to the application's needs.
Code Example
uint8_t USBD_MSCn_GetMaxLUN | ( | void | ) |
Callback function called to get maximum number of logical units.
The callback function USBD_MSCn_GetMaxLUN returns maximum logical units (LUN) that device contains.
Code Example
bool USBD_MSCn_LUN_GetMediaCapacity | ( | uint8_t | lun, |
uint32_t * | block_count, | ||
uint32_t * | block_size | ||
) |
Callback function called to get media capacity of a logical unit.
[in] | lun | logical unit number. |
[out] | block_count | total number of blocks on media. |
[out] | block_size | media block size. operation execution status :
|
The callback function USBD_MSCn_LUN_GetMediaCapacity retrieves the capacity of a logical unit (LUN).
The argument lun specifies the number of the logical unit.
The argument block_count specifies the number of available blocks on the media.
The argument block_size specifies the block size of the media.
Code Example
bool USBD_MSCn_LUN_Read | ( | uint8_t | lun, |
uint32_t | lba, | ||
uint32_t | cnt, | ||
uint8_t * | buf | ||
) |
Callback function called to read data from media of a logical unit.
[in] | lun | logical unit number. |
[in] | lba | logical address of first block to read. |
[in] | cnt | number of contiguous blocks to read from media. |
[out] | buf | data buffer for data read from media. operation execution status :
|
The callback function USBD_MSCn_LUN_Read reads data from a logical unit (LUN).
The argument lun specifies the number of the logical unit.
The argument lba specifies the logical address of the first block on the media to be read.
The argument cnt specifies the number of contiguous blocks to read from media.
The argument buf specifies the buffer for storing the data that is read from the media.
Code Example
bool USBD_MSCn_LUN_Write | ( | uint8_t | lun, |
uint32_t | lba, | ||
uint32_t | cnt, | ||
const uint8_t * | buf | ||
) |
Callback function called to write data to media of a logical unit.
[in] | lun | logical unit number. |
[in] | lba | logical address of first block to write. |
[in] | cnt | number of contiguous blocks to write to media. |
[in] | buf | data buffer containing data to write to media. operation execution status :
|
The callback function USBD_MSCn_LUN_Write writes data to a logical unit (LUN).
The argument lun specifies the number of the logical unit.
The argument lba specifies the logical address of the first block on the media to be written.
The argument cnt specifies the number of contiguous blocks to be written to the media.
The argument buf specifies the buffer storing the data that is to be written to the media.
Code Example
uint32_t USBD_MSCn_LUN_CheckMedia | ( | uint8_t | lun | ) |
Callback function called to check media presence and write protect status of a logical unit.
[in] | lun | logical unit number. |
The callback function USBD_MSCn_LUN_CheckMedia checks the media presence and write protection status of a logical unit (LUN).
The argument lun specifies the number of the logical unit.
Code Example
int32_t USBD_MSCn_SetMediaOwnerUSB | ( | void | ) |
Set USB as media owner.
The function USBD_MSCn_SetMediaOwnerUSB sets the USB Bus to the media owner of the attached media (drive). This will make the media unavailable to the File System Component. Use USBD_MSCn_SetMediaOwnerFS to enable ownership of the media for the File System Component.
Code Example
This function can be modified in the user code template file USBD_MSC_n.c.
int32_t USBD_MSCn_SetMediaOwnerFS | ( | void | ) |
Set File System as media owner.
The function USBD_MSCn_SetMediaOwnerFS sets the File System Component to the media owner of the attached media (drive). This will make the media unavailable to the USB Bus. Use USBD_MSCn_SetMediaOwnerUSB to enable ownership of the media for the USB Bus.
Code Example
This function can be modified in the user code template file USBD_MSC_n.c.