Browse code

Add source code of the firmware for the IO Board

Pawel Jablonski authored on 05/06/2023 17:01:27
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,182 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    usbd_msc_scsi.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header for the usbd_msc_scsi.c file
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * Copyright (c) 2015 STMicroelectronics.
10
+  * All rights reserved.
11
+  *
12
+  * This software is licensed under terms that can be found in the LICENSE file
13
+  * in the root directory of this software component.
14
+  * If no LICENSE file comes with this software, it is provided AS-IS.
15
+  *
16
+  ******************************************************************************
17
+  */
18
+
19
+/* Define to prevent recursive inclusion -------------------------------------*/
20
+#ifndef __USBD_MSC_SCSI_H
21
+#define __USBD_MSC_SCSI_H
22
+
23
+#ifdef __cplusplus
24
+extern "C" {
25
+#endif
26
+
27
+/* Includes ------------------------------------------------------------------*/
28
+#include "usbd_def.h"
29
+
30
+/** @addtogroup STM32_USB_DEVICE_LIBRARY
31
+  * @{
32
+  */
33
+
34
+/** @defgroup USBD_SCSI
35
+  * @brief header file for the storage disk file
36
+  * @{
37
+  */
38
+
39
+/** @defgroup USBD_SCSI_Exported_Defines
40
+  * @{
41
+  */
42
+
43
+#define SENSE_LIST_DEEPTH                           4U
44
+
45
+/* SCSI Commands */
46
+#define SCSI_FORMAT_UNIT                            0x04U
47
+#define SCSI_INQUIRY                                0x12U
48
+#define SCSI_MODE_SELECT6                           0x15U
49
+#define SCSI_MODE_SELECT10                          0x55U
50
+#define SCSI_MODE_SENSE6                            0x1AU
51
+#define SCSI_MODE_SENSE10                           0x5AU
52
+#define SCSI_ALLOW_MEDIUM_REMOVAL                   0x1EU
53
+#define SCSI_READ6                                  0x08U
54
+#define SCSI_READ10                                 0x28U
55
+#define SCSI_READ12                                 0xA8U
56
+#define SCSI_READ16                                 0x88U
57
+
58
+#define SCSI_READ_CAPACITY10                        0x25U
59
+#define SCSI_READ_CAPACITY16                        0x9EU
60
+
61
+#define SCSI_REQUEST_SENSE                          0x03U
62
+#define SCSI_START_STOP_UNIT                        0x1BU
63
+#define SCSI_TEST_UNIT_READY                        0x00U
64
+#define SCSI_WRITE6                                 0x0AU
65
+#define SCSI_WRITE10                                0x2AU
66
+#define SCSI_WRITE12                                0xAAU
67
+#define SCSI_WRITE16                                0x8AU
68
+
69
+#define SCSI_VERIFY10                               0x2FU
70
+#define SCSI_VERIFY12                               0xAFU
71
+#define SCSI_VERIFY16                               0x8FU
72
+
73
+#define SCSI_SEND_DIAGNOSTIC                        0x1DU
74
+#define SCSI_READ_FORMAT_CAPACITIES                 0x23U
75
+
76
+#define NO_SENSE                                    0U
77
+#define RECOVERED_ERROR                             1U
78
+#define NOT_READY                                   2U
79
+#define MEDIUM_ERROR                                3U
80
+#define HARDWARE_ERROR                              4U
81
+#define ILLEGAL_REQUEST                             5U
82
+#define UNIT_ATTENTION                              6U
83
+#define DATA_PROTECT                                7U
84
+#define BLANK_CHECK                                 8U
85
+#define MSC_VENDOR_SPECIFIC                         9U
86
+#define COPY_ABORTED                                10U
87
+#define ABORTED_COMMAND                             11U
88
+#define VOLUME_OVERFLOW                             13U
89
+#define MISCOMPARE                                  14U
90
+
91
+
92
+#define INVALID_CDB                                 0x20U
93
+#define INVALID_FIELED_IN_COMMAND                   0x24U
94
+#define PARAMETER_LIST_LENGTH_ERROR                 0x1AU
95
+#define INVALID_FIELD_IN_PARAMETER_LIST             0x26U
96
+#define ADDRESS_OUT_OF_RANGE                        0x21U
97
+#define MEDIUM_NOT_PRESENT                          0x3AU
98
+#define MEDIUM_HAVE_CHANGED                         0x28U
99
+#define WRITE_PROTECTED                             0x27U
100
+#define UNRECOVERED_READ_ERROR                      0x11U
101
+#define WRITE_FAULT                                 0x03U
102
+
103
+#define READ_FORMAT_CAPACITY_DATA_LEN               0x0CU
104
+#define READ_CAPACITY10_DATA_LEN                    0x08U
105
+#define REQUEST_SENSE_DATA_LEN                      0x12U
106
+#define STANDARD_INQUIRY_DATA_LEN                   0x24U
107
+#define BLKVFY                                      0x04U
108
+
109
+#define SCSI_MEDIUM_UNLOCKED                        0x00U
110
+#define SCSI_MEDIUM_LOCKED                          0x01U
111
+#define SCSI_MEDIUM_EJECTED                         0x02U
112
+/**
113
+  * @}
114
+  */
115
+
116
+
117
+/** @defgroup USBD_SCSI_Exported_TypesDefinitions
118
+  * @{
119
+  */
120
+
121
+typedef struct _SENSE_ITEM
122
+{
123
+  uint8_t Skey;
124
+  union
125
+  {
126
+    struct _ASCs
127
+    {
128
+      uint8_t ASC;
129
+      uint8_t ASCQ;
130
+    } b;
131
+    uint8_t ASC;
132
+    uint8_t *pData;
133
+  } w;
134
+} USBD_SCSI_SenseTypeDef;
135
+/**
136
+  * @}
137
+  */
138
+
139
+/** @defgroup USBD_SCSI_Exported_Macros
140
+  * @{
141
+  */
142
+
143
+/**
144
+  * @}
145
+  */
146
+
147
+/** @defgroup USBD_SCSI_Exported_Variables
148
+  * @{
149
+  */
150
+
151
+/**
152
+  * @}
153
+  */
154
+/** @defgroup USBD_SCSI_Exported_FunctionsPrototype
155
+  * @{
156
+  */
157
+int8_t SCSI_ProcessCmd(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *cmd);
158
+
159
+void SCSI_SenseCode(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t sKey,
160
+                    uint8_t ASC);
161
+
162
+/**
163
+  * @}
164
+  */
165
+
166
+#ifdef __cplusplus
167
+}
168
+#endif
169
+
170
+#endif /* __USBD_MSC_SCSI_H */
171
+/**
172
+  * @}
173
+  */
174
+
175
+/**
176
+  * @}
177
+  */
178
+
179
+/**
180
+  * @}
181
+  */
182
+