1 /*!
2     \file    msc_bbb.h
3     \brief   definitions for the USB MSC BBB(bulk/bulk/bulk) protocol
4 
5     \version 2020-08-04, V1.1.0, firmware for GD32VF103
6 */
7 
8 /*
9     Copyright (c) 2020, GigaDevice Semiconductor Inc.
10 
11     Redistribution and use in source and binary forms, with or without modification,
12 are permitted provided that the following conditions are met:
13 
14     1. Redistributions of source code must retain the above copyright notice, this
15        list of conditions and the following disclaimer.
16     2. Redistributions in binary form must reproduce the above copyright notice,
17        this list of conditions and the following disclaimer in the documentation
18        and/or other materials provided with the distribution.
19     3. Neither the name of the copyright holder nor the names of its contributors
20        may be used to endorse or promote products derived from this software without
21        specific prior written permission.
22 
23     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32 OF SUCH DAMAGE.
33 */
34 
35 #ifndef __MSC_BBB_H
36 #define __MSC_BBB_H
37 
38 #include "usb_ch9_std.h"
39 
40 #define BBB_CBW_SIGNATURE                 0x43425355U
41 #define BBB_CSW_SIGNATURE                 0x53425355U
42 #define BBB_CBW_LENGTH                    31U
43 #define BBB_CSW_LENGTH                    13U
44 
45 typedef struct {
46     uint32_t dCBWSignature;
47     uint32_t dCBWTag;
48     uint32_t dCBWDataTransferLength;
49     uint8_t  bmCBWFlags;
50     uint8_t  bCBWLUN;
51     uint8_t  bCBWCBLength;
52     uint8_t  CBWCB[16];
53 }msc_bbb_cbw;
54 
55 typedef struct {
56     uint32_t dCSWSignature;
57     uint32_t dCSWTag;
58     uint32_t dCSWDataResidue;
59     uint8_t  bCSWStatus;
60 }msc_bbb_csw;
61 
62 /* CSW command status */
63 enum msc_csw_status {
64     CSW_CMD_PASSED = 0,
65     CSW_CMD_FAILED,
66     CSW_PHASE_ERROR
67 };
68 
69 #endif /* __MSC_BBB_H */
70