USB Device MSC SCSI API#

USB Device MSC SCSI API.

Modules#

sl_usbd_msc_scsi_callbacks_t

sl_usbd_msc_scsi_lun_api

sl_usbd_msc_scsi_lun_info

sl_usbd_msc_scsi_lun

Typedefs#

typedef uint32_t
typedef uint32_t

Functions#

sl_status_t

FUNCTION PROTOTYPES.

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.

Typedef Documentation#

sl_usbd_msc_scsi_lb_qty_t#

typedef uint32_t sl_usbd_msc_scsi_lb_qty_t

MODULE.

INCLUDE FILES DATA TYPES SCSI LBA Types


Definition at line 67 of file protocol/usb/inc/sl_usbd_class_msc_scsi.h

sl_usbd_msc_scsi_lba_t#

typedef uint32_t sl_usbd_msc_scsi_lba_t

Definition at line 68 of file protocol/usb/inc/sl_usbd_class_msc_scsi.h

Function Documentation#

sl_usbd_msc_scsi_init#

sl_status_t sl_usbd_msc_scsi_init (void )

FUNCTION PROTOTYPES.

Parameters
N/A

MSC FUNCTIONS

Initialize internal tables, variables and the storage layer.

Returns

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


Definition at line 161 of file protocol/usb/inc/sl_usbd_class_msc_scsi.h

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
N/Amsc_task_stack_size

The 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.

N/Amsc_task_priority

The USB stack creates a task to handle the events of each MSC instance. This parameter specifies the CMSIS priority of that task.

N/Ap_scsi_callbacks

Pointer to MSC SCSI callback structure. [Content MUST be persistent]

N/Ap_class_nbr

Pointer 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.


Definition at line 182 of file protocol/usb/inc/sl_usbd_class_msc_scsi.h

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
N/Aclass_nbr

MSC instance number.

N/Aconfig_nbr

Configuration index to which to add the existing MSC interface.

Returns

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


Definition at line 196 of file protocol/usb/inc/sl_usbd_class_msc_scsi.h

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
N/Aclass_nbr

MSC SCSI instance number.

N/Ap_lu_info

Pointer to logical unit information structure.

N/Ap_scsi_lun_ptr

Pointer 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.


Definition at line 210 of file protocol/usb/inc/sl_usbd_class_msc_scsi.h

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
N/Ap_scsi_lun

Pointer 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


Definition at line 233 of file protocol/usb/inc/sl_usbd_class_msc_scsi.h

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
N/Ap_scsi_lun

Pointer 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


Definition at line 254 of file protocol/usb/inc/sl_usbd_class_msc_scsi.h

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
N/Ap_scsi_lun

Pointer to Logical Unit structure returned by sl_usbd_msc_scsi_lun_add().

N/Ap_lb_qty

Pointer to a variable that will receive LB quantity.

N/Ap_blk_size

Pointer to a variable that will receive block size.

Returns

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


Definition at line 267 of file protocol/usb/inc/sl_usbd_class_msc_scsi.h

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
N/Aclass_nbr

MSC SCSI instance number.

N/Ap_enabled

Pointer 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.


Definition at line 282 of file protocol/usb/inc/sl_usbd_class_msc_scsi.h