USB Device MSC SCSI API

Description

USB Device MSC SCSI API.

Data Structures

struct  sl_usbd_msc_scsi_callbacks_t
 SCSI Callback Functions.
 
struct  sl_usbd_msc_scsi_lun_api_t
 SCSI Logical Unit Driver API.
 
struct  sl_usbd_msc_scsi_lun_info_t
 SCSI Logical Unit Info.
 
struct  sl_usbd_msc_scsi_lun_t
 SCSI Logical Unit.

Functions

sl_status_t sl_usbd_msc_scsi_init (void)
 Initialize internal tables, variables and the storage layer.
 
sl_status_t sl_usbd_msc_scsi_create_instance (uint32_t msc_task_stack_size, osPriority_t msc_task_priority, sl_usbd_msc_scsi_callbacks_t *p_scsi_callbacks, uint8_t *p_class_nbr)
 Add a new instance of SCSI Mass Storage Class.
 
sl_status_t sl_usbd_msc_scsi_add_to_configuration (uint8_t class_nbr, uint8_t config_nbr)
 Add an existing MSC SCSI instance to the specified configuration.
 
sl_status_t sl_usbd_msc_scsi_lun_add (uint8_t class_nbr, sl_usbd_msc_scsi_lun_info_t *p_lu_info, sl_usbd_msc_scsi_lun_t **p_scsi_lun_ptr)
 Initialize the specified logical unit.
 
sl_status_t sl_usbd_msc_scsi_lun_attach (sl_usbd_msc_scsi_lun_t *p_scsi_lun)
 Attach a storage medium to the given SCSI logical unit.
 
sl_status_t sl_usbd_msc_scsi_lun_detach (sl_usbd_msc_scsi_lun_t *p_scsi_lun)
 Detach a storage medium from the given SCSI logical unit.
 
sl_status_t sl_usbd_msc_scsi_lun_get_capacity (sl_usbd_msc_scsi_lun_t *p_scsi_lun, sl_usbd_msc_scsi_lb_qty_t *p_lb_qty, uint32_t *p_blk_size)
 Retrieve capacity of logical unit.
 
sl_status_t sl_usbd_msc_scsi_is_enabled (uint8_t class_nbr, bool *p_enabled)
 Get the MSC enable state of the SCSI interface.

Typedefs

typedef uint32_t sl_usbd_msc_scsi_lb_qty_t
 SCSI LBA Types.
 
typedef uint32_t sl_usbd_msc_scsi_lba_t

Function Documentation

◆ sl_usbd_msc_scsi_init()

sl_status_t sl_usbd_msc_scsi_init ( void  )

Initialize internal tables, variables and the storage layer.

Returns
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

◆ sl_usbd_msc_scsi_create_instance()

sl_status_t sl_usbd_msc_scsi_create_instance ( uint32_t  msc_task_stack_size,
osPriority_t  msc_task_priority,
sl_usbd_msc_scsi_callbacks_t p_scsi_callbacks,
uint8_t *  p_class_nbr 
)

Add a new instance of SCSI Mass Storage Class.

Parameters
msc_task_stack_sizeThe USB stack creates a task to handle the events of each MSC instance. This parameter specifies the stack size to be used for the newly created task for this instance.
msc_task_priorityThe USB stack creates a task to handle the events of each MSC instance. This parameter specifies the CMSIS priority of that task.
p_scsi_callbacksPointer to MSC SCSI callback structure. [Content MUST be persistent]
p_class_nbrPointer to a variable that will receive the instance number for the created class instance, if no errors are returned. Otherwise, the variable is set to SL_USBD_CLASS_NBR_NONE.
Returns
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

◆ sl_usbd_msc_scsi_add_to_configuration()

sl_status_t sl_usbd_msc_scsi_add_to_configuration ( uint8_t  class_nbr,
uint8_t  config_nbr 
)

Add an existing MSC SCSI instance to the specified configuration.

Parameters
class_nbrMSC instance number.
config_nbrConfiguration index to which to add the existing MSC interface.
Returns
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

◆ sl_usbd_msc_scsi_lun_add()

sl_status_t sl_usbd_msc_scsi_lun_add ( uint8_t  class_nbr,
sl_usbd_msc_scsi_lun_info_t *  p_lu_info,
sl_usbd_msc_scsi_lun_t **  p_scsi_lun_ptr 
)

Initialize the specified logical unit.

Parameters
class_nbrMSC SCSI instance number.
p_lu_infoPointer to logical unit information structure.
p_scsi_lun_ptrPointer to a void pointer that will be set to point to SCSI-related logical unit data.
Returns
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

◆ sl_usbd_msc_scsi_lun_attach()

sl_status_t sl_usbd_msc_scsi_lun_attach ( sl_usbd_msc_scsi_lun_t *  p_scsi_lun)

Attach a storage medium to the given SCSI logical unit.

Parameters
p_scsi_lunPointer to Logical Unit structure returned by sl_usbd_msc_scsi_lun_add().
Returns
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.
Note
(1) If the logical unit has been ejected from the host, calling sl_usbd_msc_scsi_lun_detach() and sl_usbd_msc_scsi_lun_attach() will make it re-appear.
(2) Use this function with care as ejecting a logical unit in the middle of a transfer may corrupt the file system. The only scenarios where the usage of this function is safe are:
  • (a) Host: Read, Embedded app: Read
  • (b) Host: Read, Embedded app: Write The following scenarios are not considered safe. Use at your own risk.
  • (a) Host: Write, Embedded app: Read
  • (b) Host: Write, Embedded app: Write

◆ sl_usbd_msc_scsi_lun_detach()

sl_status_t sl_usbd_msc_scsi_lun_detach ( sl_usbd_msc_scsi_lun_t *  p_scsi_lun)

Detach a storage medium from the given SCSI logical unit.

Parameters
p_scsi_lunPointer to Logical Unit structure returned by sl_usbd_msc_scsi_lun_add().
Returns
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.
Note
(1) After a call to this function, the media will be available to the embedded application. The standard file API can be used.
(2) Use this function with care as ejecting a logical unit in the middle of a transfer may corrupt the file system. The only scenarios where the usage of this function is considered safe are:
  • (a) Host: Read, Embedded app: Read
  • (b) Host: Read, Embedded app: Write The following scenarios are not considered safe. Use at your own risk.
  • (a) Host: Write, Embedded app: Read
  • (b) Host: Write, Embedded app: Write

◆ sl_usbd_msc_scsi_lun_get_capacity()

sl_status_t sl_usbd_msc_scsi_lun_get_capacity ( sl_usbd_msc_scsi_lun_t *  p_scsi_lun,
sl_usbd_msc_scsi_lb_qty_t p_lb_qty,
uint32_t *  p_blk_size 
)

Retrieve capacity of logical unit.

Parameters
p_scsi_lunPointer to Logical Unit structure returned by sl_usbd_msc_scsi_lun_add().
p_lb_qtyPointer to a variable that will receive LB quantity.
p_blk_sizePointer to a variable that will receive block size.
Returns
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

◆ sl_usbd_msc_scsi_is_enabled()

sl_status_t sl_usbd_msc_scsi_is_enabled ( uint8_t  class_nbr,
bool *  p_enabled 
)

Get the MSC enable state of the SCSI interface.

Parameters
class_nbrMSC SCSI instance number.
p_enabledPointer to a boolean variable that will receive enable state. The variable is set to true if MSC class is enabled. The variable is set to false if the MSC class is not enabled.
Returns
Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

Typedef Documentation

◆ sl_usbd_msc_scsi_lb_qty_t

typedef uint32_t sl_usbd_msc_scsi_lb_qty_t

SCSI LBA Types.