libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
msc.h
Go to the documentation of this file.
1/** @defgroup usb_msc_defines USB MSC Type Definitions
2
3@brief <b>Defined Constants and Types for the USB MSC Type Definitions</b>
4
5@ingroup USB_defines
6
7@version 1.0.0
8
9@author @htmlonly &copy; @endhtmlonly 2013
10Weston Schmidt <weston_schmidt@alumni.purdue.edu>
11Pavol Rusnak <stick@gk2.sk>
12
13@date 27 June 2013
14
15LGPL License Terms @ref lgpl_license
16*/
17
18/*
19 * This file is part of the libopencm3 project.
20 *
21 * Copyright (C) 2013 Weston Schmidt <weston_schmidt@alumni.purdue.edu>
22 * Copyright (C) 2013 Pavol Rusnak <stick@gk2.sk>
23 *
24 * This library is free software: you can redistribute it and/or modify
25 * it under the terms of the GNU Lesser General Public License as published by
26 * the Free Software Foundation, either version 3 of the License, or
27 * (at your option) any later version.
28 *
29 * This library is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU Lesser General Public License for more details.
33 *
34 * You should have received a copy of the GNU Lesser General Public License
35 * along with this library. If not, see <http://www.gnu.org/licenses/>.
36 */
37
38/**@{*/
39
40#ifndef __MSC_H
41#define __MSC_H
42
43#include <stdint.h>
44#include <libopencm3/usb/usbd.h>
45
47
48/* Definitions of Mass Storage Class from:
49 *
50 * (A) "Universal Serial Bus Mass Storage Class Bulk-Only Transport
51 * Revision 1.0"
52 *
53 * (B) "Universal Serial Bus Mass Storage Class Specification Overview
54 * Revision 1.0"
55 */
56
57/* (A) Table 4.5: Mass Storage Device Class Code */
58#define USB_CLASS_MSC 0x08
59
60/* (B) Table 2.1: Class Subclass Code */
61#define USB_MSC_SUBCLASS_RBC 0x01
62#define USB_MSC_SUBCLASS_ATAPI 0x02
63#define USB_MSC_SUBCLASS_UFI 0x04
64#define USB_MSC_SUBCLASS_SCSI 0x06
65#define USB_MSC_SUBCLASS_LOCKABLE 0x07
66#define USB_MSC_SUBCLASS_IEEE1667 0x08
67
68/* (B) Table 3.1 Mass Storage Interface Class Control Protocol Codes */
69#define USB_MSC_PROTOCOL_CBI 0x00
70#define USB_MSC_PROTOCOL_CBI_ALT 0x01
71#define USB_MSC_PROTOCOL_BBB 0x50
72
73/* (B) Table 4.1 Mass Storage Request Codes */
74#define USB_MSC_REQ_CODES_ADSC 0x00
75#define USB_MSC_REQ_CODES_GET 0xFC
76#define USB_MSC_REQ_CODES_PUT 0xFD
77#define USB_MSC_REQ_CODES_GML 0xFE
78#define USB_MSC_REQ_CODES_BOMSR 0xFF
79
80/* (A) Table 3.1/3.2 Class-Specific Request Codes */
81#define USB_MSC_REQ_BULK_ONLY_RESET 0xFF
82#define USB_MSC_REQ_GET_MAX_LUN 0xFE
83
85 uint8_t ep_in, uint8_t ep_in_size,
86 uint8_t ep_out, uint8_t ep_out_size,
87 const char *vendor_id,
88 const char *product_id,
89 const char *product_revision_level,
90 const uint32_t block_count,
91 int (*read_block)(uint32_t lba, uint8_t *copy_to),
92 int (*write_block)(uint32_t lba, const uint8_t *copy_from));
93
94#endif
95
96/**@}*/
struct _usbd_device usbd_device
Definition: usbd.h:53
usbd_mass_storage * usb_msc_init(usbd_device *usbd_dev, uint8_t ep_in, uint8_t ep_in_size, uint8_t ep_out, uint8_t ep_out_size, const char *vendor_id, const char *product_id, const char *product_revision_level, const uint32_t block_count, int(*read_block)(uint32_t lba, uint8_t *copy_to), int(*write_block)(uint32_t lba, const uint8_t *copy_from))
Initializes the USB Mass Storage subsystem.
Definition: usb_msc.c:801
uint8_t ep_in_size
Definition: usb_msc.c:176
uint8_t ep_out
Definition: usb_msc.c:177
uint8_t ep_out_size
Definition: usb_msc.c:178
const char * vendor_id
Definition: usb_msc.c:180
int(* write_block)(uint32_t lba, const uint8_t *copy_from)
Definition: usb_msc.c:186
uint32_t block_count
Definition: usb_msc.c:183
usbd_device * usbd_dev
Definition: usb_msc.c:174
const char * product_revision_level
Definition: usb_msc.c:182
int(* read_block)(uint32_t lba, uint8_t *copy_to)
Definition: usb_msc.c:185
const char * product_id
Definition: usb_msc.c:181