Skip to content

File syn_usb_msc.h

FileList > drivers > syn_usb_msc.h

Go to the source code of this file

Zero-Heap USB 2.0 Mass Storage Class (MSC) Device Driver. More...

  • #include "syntropic/common/syn_defs.h"
  • #include "syntropic/drivers/syn_usb.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_USB_MSC
struct SYN_USB_MSC_CBW
struct SYN_USB_MSC_CSW
struct SYN_USB_MSC_Media

Public Functions

Type Name
SYN_Status syn_usb_msc_init (SYN_USB_MSC * msc)
Initialize USB MSC Instance.
SYN_Status syn_usb_msc_process_cbw (SYN_USB_MSC * msc, const uint8_t cbw_raw)
Process incoming BOT Command Block Wrapper (CBW).
SYN_Status syn_usb_msc_register (SYN_USB_Device * dev, SYN_USB_MSC * msc)
Register USB MSC class driver with USB core.
SYN_Status syn_usb_msc_set_media (SYN_USB_MSC * msc, const SYN_USB_MSC_Media * media)
Bind block storage media callbacks.

Macros

Type Name
define SYN_SCSI_INQUIRY 0x12U
define SYN_SCSI_READ_10 0x28U
define SYN_SCSI_READ_CAPACITY_10 0x25U
define SYN_SCSI_REQUEST_SENSE 0x03U
define SYN_SCSI_TEST_UNIT_READY 0x00U
define SYN_SCSI_WRITE_10 0x2AU
define SYN_USB_MSC_BLOCK_SIZE 512U
define SYN_USB_MSC_MAX_PACKET_SIZE 64U

Detailed Description

Implements USB Mass Storage Class Bulk-Only Transport (BOT) v1.0 with SCSI Transparent Command Set to expose SD Card or Flash storage as a USB drive.

Public Functions Documentation

function syn_usb_msc_init

Initialize USB MSC Instance.

SYN_Status syn_usb_msc_init (
    SYN_USB_MSC * msc
) 

Parameters:

  • msc Pointer to USB MSC instance.

Returns:

SYN_OK on success, SYN_INVALID_PARAM if NULL.


function syn_usb_msc_process_cbw

Process incoming BOT Command Block Wrapper (CBW).

SYN_Status syn_usb_msc_process_cbw (
    SYN_USB_MSC * msc,
    const uint8_t cbw_raw
) 

Parameters:

  • msc Pointer to USB MSC instance.
  • cbw_raw Pointer to 31-byte raw CBW buffer.

Returns:

SYN_OK on success, SYN_INVALID_PARAM if NULL or corrupt.


function syn_usb_msc_register

Register USB MSC class driver with USB core.

SYN_Status syn_usb_msc_register (
    SYN_USB_Device * dev,
    SYN_USB_MSC * msc
) 

Parameters:

  • dev Pointer to USB device context.
  • msc Pointer to USB MSC instance.

Returns:

SYN_OK on success, SYN_INVALID_PARAM if NULL.


function syn_usb_msc_set_media

Bind block storage media callbacks.

SYN_Status syn_usb_msc_set_media (
    SYN_USB_MSC * msc,
    const SYN_USB_MSC_Media * media
) 

Parameters:

  • msc Pointer to USB MSC instance.
  • media Pointer to storage media interface.

Returns:

SYN_OK on success, SYN_INVALID_PARAM if NULL.


Macro Definition Documentation

define SYN_SCSI_INQUIRY

#define SYN_SCSI_INQUIRY `0x12U`

SCSI Inquiry opcode (0x12)


define SYN_SCSI_READ_10

#define SYN_SCSI_READ_10 `0x28U`

SCSI Read (10) opcode (0x28)


define SYN_SCSI_READ_CAPACITY_10

#define SYN_SCSI_READ_CAPACITY_10 `0x25U`

SCSI Read Capacity (10) opcode (0x25)


define SYN_SCSI_REQUEST_SENSE

#define SYN_SCSI_REQUEST_SENSE `0x03U`

SCSI Request Sense opcode (0x03)


define SYN_SCSI_TEST_UNIT_READY

#define SYN_SCSI_TEST_UNIT_READY `0x00U`

SCSI Command Opcodes SCSI Test Unit Ready opcode (0x00)


define SYN_SCSI_WRITE_10

#define SYN_SCSI_WRITE_10 `0x2AU`

SCSI Write (10) opcode (0x2A)


define SYN_USB_MSC_BLOCK_SIZE

#define SYN_USB_MSC_BLOCK_SIZE `512U`

Standard SCSI block sector size in bytes


define SYN_USB_MSC_MAX_PACKET_SIZE

#define SYN_USB_MSC_MAX_PACKET_SIZE `64U`

Maximum USB endpoint packet size



The documentation for this class was generated from the following file src/syntropic/drivers/syn_usb_msc.h