# usb_msd

USB Mass Storage Device.

Author | Matthew Schinkel - borntechi.com, copyright © 2009, all rights reserved.
Adapted-by |
Compiler | >=2.4q2

Description

    Library for USB MSD (Mass Storage Device) with SD card,
                 hard disk, or jallib supported storage device.

Sources

    http://www.usb.org/developers/devclass_docs/usbmassbulk_10.pdf
    http://www.usb.org/developers/devclass_docs/usbmass-ufi10.pdf
    http://direction.scene-double.com/2008/07/08/usb-msd-bootloader-for-pic-microcontrollers.aspx

Dependencies

- usb_drv
- storage_drivers
- usb_defs
- usb_drv_core

## Summary

### Global variables/contants

- `var bit*7 usb_msd_sense_response_code at usb_msd_sense_response_valid : 0`
- `var byte usb_msd_csw_tag_[4] at usb_msd_cbw_tag`
- `var bit usb_msd_sense_filemark at usb_msd_sense_filemark_eom_ili_reserved_key : 7`
- `const byte USB_STRING2_SIZE = 0x34`
- `const byte USB_MSD_SENSE_ASC_READ_ERROR = 0x11`
- `const bit USB_EP0 = ENABLED`
- `const byte USB_STRING3_SIZE = 0x1A`
- `var byte usb_msd_data_residue_[4] at usb_msd_data_residue`
- `var word usb_msd_step64_ = 0`
- `const byte USB_MSD_READ_CAPACITY = 0x25`
- `var byte usb_msd_sense_add_sense_len`
- `var volatile bit usb_msd_sae_owns_bit_in at usb_bd1in_stat : USB_BDSTATUS_UOWN`
- `var byte usb_msd_cbw_tag_[4] at usb_msd_cbw_tag`
- `var bit usb_msd_sense_reserved at usb_msd_sense_filemark_eom_ili_reserved_key : 4`
- `const byte USB_MSD_WRITE_10 = 0x2a`
- `const byte USB_MSD_SENSE_ASC_LOGICAL_BLOCK_OUT_OF_RANGE = 0x21`
- `const byte USB_MSD_SENSE_ILLEGAL_REQUEST = 0x05`
- `const byte USB_MSD_SENSE_NOT_READY = 0x02`
- `var byte usb_msd_sense_key_specific[3]`
- `const byte USB_STRING0_SIZE = 0x04`
- `const byte USB_MSD_INQUIRY = 0x12`
- `const bit USB_EP1 = ENABLED`
- `var dword usb_msd_address`
- `var bit usb_msd_sense_key_specific_sksv at usb_msd_sense_key_specific[0] : 7`
- `var byte usb_msd_sense_response_valid`
- `const byte USB_EP0_IN_SIZE = 64`
- `const byte USB_MSD_MODE_SENSE = 0x1a`
- `const byte USB_EP0_OUT_SIZE = 64`
- `const byte USB_MSD_READ_FORMAT_CAPACITY = 0x23`
- `const USB_MSD_STATE_DATA_IN = 1`
- `const byte USB_WRITE_NORMAL_SPEED = 3`
- `const byte USB_WRITE_SUPER_SPEED = 1`
- `const byte USB_STRING1_SIZE = 0x34`
- `const byte USB_MSD_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1e`
- `const byte USB_MSD_SENSE_ASCQ_DEVICE_WRITE_FAULT = 0x00`
- `const byte USB_CONFIGURATION_DESCRIPTOR[USB_CONFIGURATION_DESCRIPTOR_SIZE] =`
- `var byte usb_msd_sense_ascq`
- `const byte USB_MSD_REQUEST_SENSE = 0x03`
- `var volatile byte usb_ep1out_buf[USB_EP1_OUT_SIZE] at USB_EP1_OUT_ADDR`
- `const dword USB_MSD_CBW = 0x43425355`
- `var dword usb_msd_data_residue = 0`
- `var volatile byte usb_msd_cbw_cbw_lun = 0`
- `const byte USB_EP1_IN_SIZE = 64`
- `var byte usb_msd_csw_status = 0`
- `const USB_HOST_DIRECTION_SEND = FALSE`
- `const byte USB_MSD_READ_10 = 0x28`
- `var byte usb_msd_sense_asc`
- `var volatile byte usb_msd_cbw_length = 0`
- `var volatile byte usb_ep0out_buf[USB_EP0_OUT_SIZE] at USB_EP0_OUT_ADDR`
- `var dword usb_msd_num_of_blocks = storage_number_of_sectors`
- `var byte usb_msd_step_byte_ = 0`
- `var bit usb_msd_sense_valid at usb_msd_sense_response_code : 7`
- `var byte usb_msd_sense_fruc`
- `var byte usb_msd_sense_obsolete`
- `var volatile bit usb_msd_sae_owns_bit_out at usb_bd1out_stat : USB_BDSTATUS_UOWN`
- `const USB_MSD_CSW_STATUS_FAIL = 0x01`
- `const bit USB_EP3 = DISABLED`
- `const byte USB_MSD_SENSE_ASCQ_INVALID_COMMAND_OPCODE = 0x00`
- `var dword usb_msd_cbw_signature = 0`
- `const USB_MSD_STATE_DATA_OUT = 2`
- `var dword usb_msd_sector_step_`
- `const word USB_EP0_OUT_ADDR = (USB_BASE_ADDRESS + 0x0010)`
- `var byte usb_msd_sense_command_spacific_[4] at usb_msd_sense_command_spacific`
- `var byte usb_msd_cbw_data_transfer_length_[4] at usb_msd_cbw_data_transfer_length`
- `const byte USB_MSD_SENSE_MEDIUM_ERROR = 0x03`
- `var volatile byte usb_msd_cbw_flags = 0`
- `var dword usb_msd_cbw_tag = 0`
- `var byte usb_msd_sense_information_[4] at usb_msd_sense_information`
- `const byte USB_WRITE_EXTRA_SPEED = 2`
- `var byte usb_msd_csw_signature_[4] at usb_msd_csw_signature`
- `const byte USB_READ_SUPER_SPEED = 1`
- `var dword usb_msd_sense_command_spacific`
- `const byte USB_MSD_VERIFY = 0x2f`
- `var dword usb_msd_csw_tag = 0`
- `var dword usb_msd_csw_signature = 0`
- `const USB_MSD_CSW_STATUS_SUCCESS = 0x00`
- `const byte USB_MSD_SENSE_ASCQ_WRITE_PROTECTED = 0x00`
- `const USB_CONFIGURATION_DESCRIPTOR_SIZE = 0x09 + 0x09 + 0x07 + 0x07`
- `const byte USB_MSD_TEST_UNIT_READY = 0x00`
- `const word USB_EP0_IN_ADDR = (USB_EP0_OUT_ADDR + USB_EP0_OUT_SIZE )`
- `const word USB_EP1_IN_ADDR = (USB_EP1_OUT_ADDR + USB_EP1_OUT_SIZE) + 0x30`
- `const byte USB_MSD_SENSE_ASCQ_MEDIUM_NOT_PRESENT = 0x00`
- `const byte USB_MSD_SENSE_ASC_INVALID_COMMAND_OPCODE = 0x20`
- `var bit usb_msd_sense_ili at usb_msd_sense_filemark_eom_ili_reserved_key : 5`
- `const byte USB_MSD_SENSE_UNIT_ATTENTION = 0x06`
- `var byte usb_msd_cbw_command_[16] at usb_msd_cbw_command`
- `const byte USB_MSD_SENSE_ASCQ_READ_ERROR = 0x00`
- `var volatile byte usb_ep0in_buf[USB_EP0_IN_SIZE] at USB_EP0_IN_ADDR`
- `const byte USB_STRING2[USB_STRING2_SIZE] =`
- `const byte USB_READ_EXTRA_SPEED = 2`
- `const USB_MSD_CSW = 0x53425355`
- `var bit usb_host_direction at usb_msd_cbw_flags : 7`
- `const byte USB_READ_NORMAL_SPEED = 3`
- `const word USB_EP1_OUT_ADDR = (USB_EP0_IN_ADDR + USB_EP0_IN_SIZE)`
- `const byte USB_MSD_STOP_START = 0x1b`
- `const byte USB_EP1_OUT_SIZE = 64`
- `const byte USB_MSD_SENSE_ASCQ_LOGICAL_BLOCK_OUT_OF_RANGE = 0x00`
- `var byte usb_msd_num_of_blocks_[4] at usb_msd_num_of_blocks`
- `var dword usb_msd_cbw_data_transfer_length = 0`
- `const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] =`
- `var byte msd_tx_buffer[USB_EP1_IN_SIZE] at { 0x600 }`
- `var volatile byte usb_ep1in_buf[USB_EP1_IN_SIZE] at USB_EP1_IN_ADDR`
- `const byte USB_STRING3[USB_STRING3_SIZE] =`
- `const bit USB_EP2 = DISABLED`
- `const USB_MSD_STATE_WAIT = 0`
- `var byte*16 usb_msd_cbw_command = 0`
- `var byte usb_msd_address_[4] at usb_msd_address`
- `const USB_HOST_DIRECTION_RECEIVE = TRUE`
- `var byte usb_msd_cbw_signature_[4] at usb_msd_cbw_signature`
- `const byte USB_MSD_SENSE_ASC_MEDIUM_NOT_PRESENT = 0x3A`
- `var bit*4 usb_msd_sense_key at usb_msd_sense_filemark_eom_ili_reserved_key : 0`
- `var byte usb_msd_sense_filemark_eom_ili_reserved_key`
- `const byte USB_STRING0[USB_STRING0_SIZE] =`
- `const byte USB_MSD_SENSE_ASC_WRITE_PROTECTED = 0x27`
- `var bit usb_msd_sense_eom at usb_msd_sense_filemark_eom_ili_reserved_key : 6`
- `var dword usb_msd_sense_information`
- `var byte usb_msd_state = USB_MSD_STATE_WAIT`
- `const byte USB_MSD_SENSE_ASC_DEVICE_WRITE_FAULT = 0x03`
- `const byte USB_STRING1[USB_STRING1_SIZE] =`

### Procedures

- `usb_msd_wait_configured()`
- `usb_handle_class_request_callback()`
- `usb_msd_reset_sense_data()`
- `usb_print_speeds()`
- `usb_msd_process_data(byte in do_copy)`
- `usb_read_callback()`
- `msd_send_data(byte in size, bit in do_copy, bit in wait_own)`
- `usb_msd_init()`
- `msd_wait_own_tx()`
- `usb_write_callback()`
- `usb_ep_data_in_callback(byte in end_point, word in buffer_addr, byte in byte_count)`
- `usb_msd_read(dword in address)`
- `usb_msd_tasks()`
- `usb_ep_data_out_callback(byte in end_point, word in buffer_addr, byte in byte_count)`
- `usb_msd_write(dword in address)`
- `usb_send_csw()`
- `usb_reset_callback()`
- `msd_wait_own_rx()`
- `usb_msd_command_received()`

### Functions

- `msd_cbw_is_valid() return bit`

## API details

### Global variables/contants

- `var bit*7 usb_msd_sense_response_code at usb_msd_sense_response_valid : 0`

      bits 0..6

- `var byte usb_msd_csw_tag_[4] at usb_msd_cbw_tag`

  No documentation found

- `var bit usb_msd_sense_filemark at usb_msd_sense_filemark_eom_ili_reserved_key : 7`

  No documentation found

- `const byte USB_STRING2_SIZE = 0x34`

      String descriptor describing this product

- `const byte USB_MSD_SENSE_ASC_READ_ERROR = 0x11`

  No documentation found

- `const bit USB_EP0 = ENABLED`

      Setup USB endpoints, endpoint 0 and 1 are required for a MSD class
      If possible, don't define accross banks

- `const byte USB_STRING3_SIZE = 0x1A`

      String descriptor describing the device serial number

- `var byte usb_msd_data_residue_[4] at usb_msd_data_residue`

  No documentation found

- `var word usb_msd_step64_ = 0`

  No documentation found

- `const byte USB_MSD_READ_CAPACITY = 0x25`

  No documentation found

- `var byte usb_msd_sense_add_sense_len`

  No documentation found

- `var volatile bit usb_msd_sae_owns_bit_in at usb_bd1in_stat : USB_BDSTATUS_UOWN`

      UOWN bit
      When SAE owns, we cannot use the endpoint. SAE is the usb module or  output interface.
      When CPU owns, we can use the endpoint to write or send data.
      We must give ownership back to SAE when we're done with it.

- `var byte usb_msd_cbw_tag_[4] at usb_msd_cbw_tag`

  No documentation found

- `var bit usb_msd_sense_reserved at usb_msd_sense_filemark_eom_ili_reserved_key : 4`

  No documentation found

- `const byte USB_MSD_WRITE_10 = 0x2a`

  No documentation found

- `const byte USB_MSD_SENSE_ASC_LOGICAL_BLOCK_OUT_OF_RANGE = 0x21`

  No documentation found

- `const byte USB_MSD_SENSE_ILLEGAL_REQUEST = 0x05`

  No documentation found

- `const byte USB_MSD_SENSE_NOT_READY = 0x02`

      sense codes

- `var byte usb_msd_sense_key_specific[3]`

  No documentation found

- `const byte USB_STRING0_SIZE = 0x04`

      STRING 0
      note: there may be bad packets till the host requests with wLength 4, but host will retry.

- `const byte USB_MSD_INQUIRY = 0x12`

      MSD commands we may get from host

- `const bit USB_EP1 = ENABLED`

  No documentation found

- `var dword usb_msd_address`

  No documentation found

- `var bit usb_msd_sense_key_specific_sksv at usb_msd_sense_key_specific[0] : 7`

  No documentation found

- `var byte usb_msd_sense_response_valid`

      Request Sense variables

- `const byte USB_EP0_IN_SIZE = 64`

  No documentation found

- `const byte USB_MSD_MODE_SENSE = 0x1a`

  No documentation found

- `const byte USB_EP0_OUT_SIZE = 64`

  No documentation found

- `const byte USB_MSD_READ_FORMAT_CAPACITY = 0x23`

  No documentation found

- `const USB_MSD_STATE_DATA_IN = 1`

      data in state (time for device to send data to host)

- `const byte USB_WRITE_NORMAL_SPEED = 3`

      uses normal storage device routines

- `const byte USB_WRITE_SUPER_SPEED = 1`

      Select Write Speed. Extra speed may use more code space.
      Only for devices that support it.

- `const byte USB_STRING1_SIZE = 0x34`

      String descriptor describing the manufacturer

- `const byte USB_MSD_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1e`

  No documentation found

- `const byte USB_MSD_SENSE_ASCQ_DEVICE_WRITE_FAULT = 0x00`

  No documentation found

- `const byte USB_CONFIGURATION_DESCRIPTOR[USB_CONFIGURATION_DESCRIPTOR_SIZE] =`

  No documentation found

- `var byte usb_msd_sense_ascq`

  No documentation found

- `const byte USB_MSD_REQUEST_SENSE = 0x03`

  No documentation found

- `var volatile byte usb_ep1out_buf[USB_EP1_OUT_SIZE] at USB_EP1_OUT_ADDR`

  No documentation found

- `const dword USB_MSD_CBW = 0x43425355`

      CBW variables

- `var dword usb_msd_data_residue = 0`

  No documentation found

- `var volatile byte usb_msd_cbw_cbw_lun = 0`

      must be volatile otherwise compiler throws it away

- `const byte USB_EP1_IN_SIZE = 64`

  No documentation found

- `var byte usb_msd_csw_status = 0`

      status of the command excecuted

- `const USB_HOST_DIRECTION_SEND = FALSE`

  No documentation found

- `const byte USB_MSD_READ_10 = 0x28`

  No documentation found

- `var byte usb_msd_sense_asc`

  No documentation found

- `var volatile byte usb_msd_cbw_length = 0`

      must be volatile otherwise compiler throws it away

- `var volatile byte usb_ep0out_buf[USB_EP0_OUT_SIZE] at USB_EP0_OUT_ADDR`

  No documentation found

- `var dword usb_msd_num_of_blocks = storage_number_of_sectors`

      size of the storage device

- `var byte usb_msd_step_byte_ = 0`

  No documentation found

- `var bit usb_msd_sense_valid at usb_msd_sense_response_code : 7`

      bit 7

- `var byte usb_msd_sense_fruc`

  No documentation found

- `var byte usb_msd_sense_obsolete`

  No documentation found

- `var volatile bit usb_msd_sae_owns_bit_out at usb_bd1out_stat : USB_BDSTATUS_UOWN`

  No documentation found

- `const USB_MSD_CSW_STATUS_FAIL = 0x01`

      status values for usb_msd_csw_status

- `const bit USB_EP3 = DISABLED`

  No documentation found

- `const byte USB_MSD_SENSE_ASCQ_INVALID_COMMAND_OPCODE = 0x00`

  No documentation found

- `var dword usb_msd_cbw_signature = 0`

      variable to receive a CBW signature before checking

- `const USB_MSD_STATE_DATA_OUT = 2`

      data out state (time for device to receive from host)

- `var dword usb_msd_sector_step_`

      variables

- `const word USB_EP0_OUT_ADDR = (USB_BASE_ADDRESS + 0x0010)`

  No documentation found

- `var byte usb_msd_sense_command_spacific_[4] at usb_msd_sense_command_spacific`

  No documentation found

- `var byte usb_msd_cbw_data_transfer_length_[4] at usb_msd_cbw_data_transfer_length`

  No documentation found

- `const byte USB_MSD_SENSE_MEDIUM_ERROR = 0x03`

  No documentation found

- `var volatile byte usb_msd_cbw_flags = 0`

      must be volatile otherwise compiler throws it away

- `var dword usb_msd_cbw_tag = 0`

      relat a SBW with a CSW at end of packet

- `var byte usb_msd_sense_information_[4] at usb_msd_sense_information`

  No documentation found

- `const byte USB_WRITE_EXTRA_SPEED = 2`

      uses storage device extra speed routines,

- `var byte usb_msd_csw_signature_[4] at usb_msd_csw_signature`

  No documentation found

- `const byte USB_READ_SUPER_SPEED = 1`

      Select Read Speed. Extra speed may use more code space.
      Only for devices that support it.

- `var dword usb_msd_sense_command_spacific`

  No documentation found

- `const byte USB_MSD_VERIFY = 0x2f`

  No documentation found

- `var dword usb_msd_csw_tag = 0`

  No documentation found

- `var dword usb_msd_csw_signature = 0`

      relate CSW with a SBW at the end of packet

- `const USB_MSD_CSW_STATUS_SUCCESS = 0x00`

      command success

- `const byte USB_MSD_SENSE_ASCQ_WRITE_PROTECTED = 0x00`

  No documentation found

- `const USB_CONFIGURATION_DESCRIPTOR_SIZE = 0x09 + 0x09 + 0x07 + 0x07`

      Default USB_CONFIGURATION_DESCRIPTOR

- `const byte USB_MSD_TEST_UNIT_READY = 0x00`

  No documentation found

- `const word USB_EP0_IN_ADDR = (USB_EP0_OUT_ADDR + USB_EP0_OUT_SIZE )`

  No documentation found

- `const word USB_EP1_IN_ADDR = (USB_EP1_OUT_ADDR + USB_EP1_OUT_SIZE) + 0x30`

  No documentation found

- `const byte USB_MSD_SENSE_ASCQ_MEDIUM_NOT_PRESENT = 0x00`

  No documentation found

- `const byte USB_MSD_SENSE_ASC_INVALID_COMMAND_OPCODE = 0x20`

  No documentation found

- `var bit usb_msd_sense_ili at usb_msd_sense_filemark_eom_ili_reserved_key : 5`

  No documentation found

- `const byte USB_MSD_SENSE_UNIT_ATTENTION = 0x06`

  No documentation found

- `var byte usb_msd_cbw_command_[16] at usb_msd_cbw_command`

  No documentation found

- `const byte USB_MSD_SENSE_ASCQ_READ_ERROR = 0x00`

  No documentation found

- `var volatile byte usb_ep0in_buf[USB_EP0_IN_SIZE] at USB_EP0_IN_ADDR`

  No documentation found

- `const byte USB_STRING2[USB_STRING2_SIZE] =`

  No documentation found

- `const byte USB_READ_EXTRA_SPEED = 2`

      uses storage device extra speed routines,

- `const USB_MSD_CSW = 0x53425355`

      CSW variables

- `var bit usb_host_direction at usb_msd_cbw_flags : 7`

      direction the host wishes to transefer

- `const byte USB_READ_NORMAL_SPEED = 3`

      uses normal storage device routines

- `const word USB_EP1_OUT_ADDR = (USB_EP0_IN_ADDR + USB_EP0_IN_SIZE)`

  No documentation found

- `const byte USB_MSD_STOP_START = 0x1b`

  No documentation found

- `const byte USB_EP1_OUT_SIZE = 64`

  No documentation found

- `const byte USB_MSD_SENSE_ASCQ_LOGICAL_BLOCK_OUT_OF_RANGE = 0x00`

  No documentation found

- `var byte usb_msd_num_of_blocks_[4] at usb_msd_num_of_blocks`

  No documentation found

- `var dword usb_msd_cbw_data_transfer_length = 0`

      # of bytes of data that the host expects to transfer on the Bulk-In or Bulk-Out endpoint 1

- `const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] =`

      Default USB_DEVICE_DESCRIPTOR

- `var byte msd_tx_buffer[USB_EP1_IN_SIZE] at { 0x600 }`

  No documentation found

- `var volatile byte usb_ep1in_buf[USB_EP1_IN_SIZE] at USB_EP1_IN_ADDR`

  No documentation found

- `const byte USB_STRING3[USB_STRING3_SIZE] =`

  No documentation found

- `const bit USB_EP2 = DISABLED`

  No documentation found

- `const USB_MSD_STATE_WAIT = 0`

      msd status

- `var byte*16 usb_msd_cbw_command = 0`

      command and parameters for a received CBW

- `var byte usb_msd_address_[4] at usb_msd_address`

  No documentation found

- `const USB_HOST_DIRECTION_RECEIVE = TRUE`

  No documentation found

- `var byte usb_msd_cbw_signature_[4] at usb_msd_cbw_signature`

  No documentation found

- `const byte USB_MSD_SENSE_ASC_MEDIUM_NOT_PRESENT = 0x3A`

  No documentation found

- `var bit*4 usb_msd_sense_key at usb_msd_sense_filemark_eom_ili_reserved_key : 0`

  No documentation found

- `var byte usb_msd_sense_filemark_eom_ili_reserved_key`

  No documentation found

- `const byte USB_STRING0[USB_STRING0_SIZE] =`

  No documentation found

- `const byte USB_MSD_SENSE_ASC_WRITE_PROTECTED = 0x27`

  No documentation found

- `var bit usb_msd_sense_eom at usb_msd_sense_filemark_eom_ili_reserved_key : 6`

  No documentation found

- `var dword usb_msd_sense_information`

  No documentation found

- `var byte usb_msd_state = USB_MSD_STATE_WAIT`

  No documentation found

- `const byte USB_MSD_SENSE_ASC_DEVICE_WRITE_FAULT = 0x03`

  No documentation found

- `const byte USB_STRING1[USB_STRING1_SIZE] =`

  No documentation found

### Procedures

- `usb_msd_wait_configured()`

      Wait till msd is configured

- `usb_handle_class_request_callback()`

      Respond to class specific requests

- `usb_msd_reset_sense_data()`

      reset sense data. used for request sense command to
      report our status

- `usb_print_speeds()`

  No documentation found

- `usb_msd_process_data(byte in do_copy)`

      set the amount of data to be sent to the host through msd_send_data
      and update the amount of data left to be sent.

- `usb_read_callback()`

      USB read procedure, a callback from your chosen storage library.
      also see storage_read_callback() below.
      Gets run by a call to storage_read_sector_address_with_callback()

- `msd_send_data(byte in size, bit in do_copy, bit in wait_own)`

      send data to the host

- `usb_msd_init()`

      init procedure

- `msd_wait_own_tx()`

      DELAY must be checked -----------------------------------------------------------------------

- `usb_write_callback()`

      Callback from your storage device library. The fastest way to write data.

- `usb_ep_data_in_callback(byte in end_point, word in buffer_addr, byte in byte_count)`

      Handeles data going out from PIC and into the host.

- `usb_msd_read(dword in address)`

      Read from the storage device into USB_EP1 for output to the host.

- `usb_msd_tasks()`

      Poll USB MSD for tasks

- `usb_ep_data_out_callback(byte in end_point, word in buffer_addr, byte in byte_count)`

      Handeles data going out of host to the PIC.

- `usb_msd_write(dword in address)`

  No documentation found

- `usb_send_csw()`

      send command status wrapper.
      basically sends the status of a command that
      was completed by the PIC.

- `usb_reset_callback()`

      Reset Callback. Must add the following lines to USB_DRV reset procedure
      if defined (usb_reset_callback) then
      usb_reset_callback()
      end if
      with good code, you should not receive any resets from USB. You
      will get a reset if you are slow to respond to a command

- `msd_wait_own_rx()`

  No documentation found

- `usb_msd_command_received()`

      Do whatever needs to be done with a command received.

### Functions

- `msd_cbw_is_valid() return bit`

      Check if the CBW received is valid.

## Related samples

Here are the list of samples which use this library:

18f67j50 | 18f67j50_usb_msd_pata_hard_disk.jal
18f67j50 | 18f67j50_fat32_usb_msd_pata_hard_disk.jal
18f67j50 | 18f67j50_fat32_usb_msd_sd_card.jal
18f67j50 | 18f67j50_usb_msd_sd_card.jal