Loading...
Searching...
No Matches

USBUS Mass Storage Class functions definitions. More...

Detailed Description

USBUS Mass Storage Class functions definitions.

Author
Dylan Laduranty dylan.nosp@m..lad.nosp@m.urant.nosp@m.y@me.nosp@m.sotic.nosp@m..com

Definition in file msc.h.

#include <stdint.h>
#include "usb/usbus.h"
#include "usb/usbus/msc/scsi.h"
#include "mtd.h"
+ Include dependency graph for msc.h:

Go to the source code of this file.

Data Structures

struct  usbus_msc_lun
 USBUS MSC Logical Unit descriptor. More...
 
struct  usbus_msc_device
 USBUS MSC device interface context. More...
 
#define USBUS_MSC_EP_DATA_SIZE   64
 USBUS MSC bulk data endpoint size.
 
#define USBUS_MSC_EP_IN_REQUIRED_NUMOF   1
 Number of IN EPs required for the MSC interface.
 
#define USBUS_MSC_EP_OUT_REQUIRED_NUMOF   1
 Number of Out EPs required for the MSC interface.
 
enum  usbus_msc_state_t {
  WAITING , WAIT_FOR_TRANSFER , DATA_TRANSFER_IN , DATA_TRANSFER_OUT ,
  GEN_CSW
}
 USBUS MSC internal state machine enum. More...
 
typedef struct usbus_msc_lun usbus_msc_lun_t
 USBUS MSC Logical Unit descriptor.
 
typedef struct usbus_msc_device usbus_msc_device_t
 USBUS MSC device interface context.
 
int usbus_msc_init (usbus_t *usbus, usbus_msc_device_t *handler)
 MSC initialization function.
 
int usbus_msc_add_lun (usbus_t *usbus, mtd_dev_t *dev)
 Register a MTD device as a MSC LUN (Logical Unit Number)
 
int usbus_msc_remove_lun (usbus_t *usbus, mtd_dev_t *dev)
 Unregister a MTD device as a MSC LUN.
 

Macro Definition Documentation

◆ USBUS_MSC_EP_DATA_SIZE

#define USBUS_MSC_EP_DATA_SIZE   64

USBUS MSC bulk data endpoint size.

Definition at line 40 of file msc.h.

◆ USBUS_MSC_EP_IN_REQUIRED_NUMOF

#define USBUS_MSC_EP_IN_REQUIRED_NUMOF   1

Number of IN EPs required for the MSC interface.

Definition at line 46 of file msc.h.

◆ USBUS_MSC_EP_OUT_REQUIRED_NUMOF

#define USBUS_MSC_EP_OUT_REQUIRED_NUMOF   1

Number of Out EPs required for the MSC interface.

Definition at line 51 of file msc.h.

Enumeration Type Documentation

◆ usbus_msc_state_t

USBUS MSC internal state machine enum.

Enumerator
WAITING 

Initial state, wait for USB setup.

WAIT_FOR_TRANSFER 

Wait for a single packet transfer before sending CSW.

DATA_TRANSFER_IN 

Ongoing transfer on USB MSC IN endpoint.

DATA_TRANSFER_OUT 

Ongoing transfer on USB MSC OUT endpoint.

GEN_CSW 

Generate CSW response to host w/ the current transfer status.

Definition at line 56 of file msc.h.

Function Documentation

◆ usbus_msc_add_lun()

int usbus_msc_add_lun ( usbus_t usbus,
mtd_dev_t dev 
)

Register a MTD device as a MSC LUN (Logical Unit Number)

Parameters
[in]usbusUSBUS context
[in]devpointer to the MTD device to export
Returns
0 on success -ENOMEM, if the selected MTD device doesn't have enough memory -EAGAIN, if no more MTD devices can be exported -EBUSY, if the MTD device is already exported

◆ usbus_msc_init()

int usbus_msc_init ( usbus_t usbus,
usbus_msc_device_t handler 
)

MSC initialization function.

Parameters
usbusUSBUS thread to use
handlerMSC device struct

◆ usbus_msc_remove_lun()

int usbus_msc_remove_lun ( usbus_t usbus,
mtd_dev_t dev 
)

Unregister a MTD device as a MSC LUN.

Parameters
[in]usbusUSBUS context
[in]devpointer to the MTD device to export
Returns
0 on success -ENODEV, if no matching MTD device was found