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,130 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    usbd_msc.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header for the usbd_msc.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_H
21
+#define __USBD_MSC_H
22
+
23
+#ifdef __cplusplus
24
+extern "C" {
25
+#endif
26
+
27
+/* Includes ------------------------------------------------------------------*/
28
+#include  "usbd_msc_bot.h"
29
+#include  "usbd_msc_scsi.h"
30
+#include  "usbd_ioreq.h"
31
+
32
+/** @addtogroup USBD_MSC_BOT
33
+  * @{
34
+  */
35
+
36
+/** @defgroup USBD_MSC
37
+  * @brief This file is the Header file for usbd_msc.c
38
+  * @{
39
+  */
40
+
41
+
42
+/** @defgroup USBD_BOT_Exported_Defines
43
+  * @{
44
+  */
45
+/* MSC Class Config */
46
+#ifndef MSC_MEDIA_PACKET
47
+#define MSC_MEDIA_PACKET             512U
48
+#endif /* MSC_MEDIA_PACKET */
49
+
50
+#define MSC_MAX_FS_PACKET            0x40U
51
+#define MSC_MAX_HS_PACKET            0x200U
52
+
53
+#define BOT_GET_MAX_LUN              0xFE
54
+#define BOT_RESET                    0xFF
55
+#define USB_MSC_CONFIG_DESC_SIZ      32
56
+
57
+#ifndef MSC_EPIN_ADDR
58
+#define MSC_EPIN_ADDR                0x81U
59
+#endif /* MSC_EPIN_ADDR */
60
+
61
+#ifndef MSC_EPOUT_ADDR
62
+#define MSC_EPOUT_ADDR               0x01U
63
+#endif /* MSC_EPOUT_ADDR */
64
+
65
+/**
66
+  * @}
67
+  */
68
+
69
+/** @defgroup USB_CORE_Exported_Types
70
+  * @{
71
+  */
72
+typedef struct _USBD_STORAGE
73
+{
74
+  int8_t (* Init)(uint8_t lun);
75
+  int8_t (* GetCapacity)(uint8_t lun, uint32_t *block_num, uint16_t *block_size);
76
+  int8_t (* IsReady)(uint8_t lun);
77
+  int8_t (* IsWriteProtected)(uint8_t lun);
78
+  int8_t (* Read)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
79
+  int8_t (* Write)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
80
+  int8_t (* GetMaxLun)(void);
81
+  int8_t *pInquiry;
82
+
83
+} USBD_StorageTypeDef;
84
+
85
+
86
+typedef struct
87
+{
88
+  uint32_t                 max_lun;
89
+  uint32_t                 interface;
90
+  uint8_t                  bot_state;
91
+  uint8_t                  bot_status;
92
+  uint32_t                 bot_data_length;
93
+  uint8_t                  bot_data[MSC_MEDIA_PACKET];
94
+  USBD_MSC_BOT_CBWTypeDef  cbw;
95
+  USBD_MSC_BOT_CSWTypeDef  csw;
96
+
97
+  USBD_SCSI_SenseTypeDef   scsi_sense [SENSE_LIST_DEEPTH];
98
+  uint8_t                  scsi_sense_head;
99
+  uint8_t                  scsi_sense_tail;
100
+  uint8_t                  scsi_medium_state;
101
+
102
+  uint16_t                 scsi_blk_size;
103
+  uint32_t                 scsi_blk_nbr;
104
+
105
+  uint32_t                 scsi_blk_addr;
106
+  uint32_t                 scsi_blk_len;
107
+} USBD_MSC_BOT_HandleTypeDef;
108
+
109
+/* Structure for MSC process */
110
+extern USBD_ClassTypeDef  USBD_MSC;
111
+#define USBD_MSC_CLASS    &USBD_MSC
112
+
113
+uint8_t  USBD_MSC_RegisterStorage(USBD_HandleTypeDef   *pdev,
114
+                                  USBD_StorageTypeDef *fops);
115
+/**
116
+  * @}
117
+  */
118
+
119
+/**
120
+  * @}
121
+  */
122
+
123
+#ifdef __cplusplus
124
+}
125
+#endif
126
+
127
+#endif  /* __USBD_MSC_H */
128
+/**
129
+  * @}
130
+  */