Loading...
Searching...
No Matches
msc.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019-2021 Mesotic SAS
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser General
5 * Public License v2.1. See the file LICENSE in the top level directory for
6 * more details.
7 *
8 *
9 */
10
22#ifndef USB_USBUS_MSC_H
23#define USB_USBUS_MSC_H
24
25#include <stdint.h>
26#include "usb/usbus.h"
27#include "usb/usbus/msc/scsi.h"
28#include "mtd.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
37#if defined(MODULE_PERIPH_USBDEV_HS_UTMI) || defined(MODULE_PERIPH_USBDEV_HS_ULPI)
38#define USBUS_MSC_EP_DATA_SIZE 512
39#else
40#define USBUS_MSC_EP_DATA_SIZE 64
41#endif
42
46#define USBUS_MSC_EP_IN_REQUIRED_NUMOF 1
47
51#define USBUS_MSC_EP_OUT_REQUIRED_NUMOF 1
52
63
72
96
105
118
129
130#ifdef __cplusplus
131}
132#endif
133
134#endif /* USB_USBUS_MSC_H */
SCSI protocol definitions for USBUS.
USBUS Command Block Wrapper information.
Definition scsi.h:264
event structure
Definition event.h:148
MTD device descriptor.
Definition mtd.h:112
USBUS descriptor generator.
Definition usbus.h:298
USBUS endpoint context.
Definition usbus.h:308
USBUS handler struct.
Definition usbus.h:436
USBUS interface.
Definition usbus.h:353
USBUS MSC device interface context.
Definition msc.h:76
uint32_t buffer_size
Size of the internal buffer used for data transfer.
Definition msc.h:89
usbus_t * usbus
Pointer to the USBUS context.
Definition msc.h:84
uint8_t * in_buf
Pointer to internal in endpoint buffer.
Definition msc.h:82
usbus_endpoint_t * ep_out
Data endpoint out.
Definition msc.h:80
cbw_info_t cmd
Command Block Wrapper information.
Definition msc.h:85
uint16_t block_offset
Internal offset for endpoint size chunk transfer.
Definition msc.h:93
event_t rx_event
Transmit ready event.
Definition msc.h:86
uint32_t block
First block to transfer data from/to.
Definition msc.h:90
usbus_handler_t handler_ctrl
Control interface handler.
Definition msc.h:77
usbus_msc_lun_t * lun_dev
Array holding exported logical unit descriptor.
Definition msc.h:94
uint8_t * buffer
Pointer to the current data transfer buffer.
Definition msc.h:88
usbus_interface_t iface
MSC interface.
Definition msc.h:78
usbus_descr_gen_t msc_descr
MSC descriptor generator.
Definition msc.h:83
usbus_msc_state_t state
Internal state machine for msc.
Definition msc.h:87
uint16_t block_nb
Number of block to transfer for READ and WRITE operations.
Definition msc.h:91
usbus_endpoint_t * ep_in
Data endpoint in.
Definition msc.h:79
uint8_t * out_buf
Pointer to internal out endpoint buffer.
Definition msc.h:81
USBUS MSC Logical Unit descriptor.
Definition msc.h:67
uint32_t block_size
Reported USB block size.
Definition msc.h:70
mtd_dev_t * mtd
Pointer to the current mtd device used.
Definition msc.h:68
uint32_t block_nb
Reported USB block number.
Definition msc.h:69
USBUS context struct.
Definition usbus.h:448
struct usbus_msc_device usbus_msc_device_t
USBUS MSC device interface context.
int usbus_msc_remove_lun(usbus_t *usbus, mtd_dev_t *dev)
Unregister a MTD device as a MSC LUN.
int usbus_msc_init(usbus_t *usbus, usbus_msc_device_t *handler)
MSC initialization function.
usbus_msc_state_t
USBUS MSC internal state machine enum.
Definition msc.h:56
@ GEN_CSW
Generate CSW response to host w/ the current transfer status.
Definition msc.h:61
@ DATA_TRANSFER_OUT
Ongoing transfer on USB MSC OUT endpoint.
Definition msc.h:60
@ WAIT_FOR_TRANSFER
Wait for a single packet transfer before sending CSW.
Definition msc.h:58
@ WAITING
Initial state, wait for USB setup.
Definition msc.h:57
@ DATA_TRANSFER_IN
Ongoing transfer on USB MSC IN endpoint.
Definition msc.h:59
int usbus_msc_add_lun(usbus_t *usbus, mtd_dev_t *dev)
Register a MTD device as a MSC LUN (Logical Unit Number)
struct usbus_msc_lun usbus_msc_lun_t
USBUS MSC Logical Unit descriptor.
USBUS basic interface.