summaryrefslogtreecommitdiff
path: root/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc
diff options
context:
space:
mode:
authorozpv <39195175+ozpv@users.noreply.github.com>2026-08-15 17:18:25 -0500
committerozpv <39195175+ozpv@users.noreply.github.com>2026-08-15 17:18:25 -0500
commit091a130d655e75bb4d5f24a15883206869e43aa7 (patch)
treec7b86f285560851c89b240e2194695e1ef662d67 /Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc
parent8ca3415eff99aaadd0c555053fd6c03e6a3cb9b1 (diff)
Add files via git push
Diffstat (limited to 'Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc')
-rwxr-xr-xMiddlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc.h137
-rwxr-xr-xMiddlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_bot.h146
-rwxr-xr-xMiddlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_data.h106
-rwxr-xr-xMiddlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_scsi.h183
4 files changed, 572 insertions, 0 deletions
diff --git a/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc.h b/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc.h
new file mode 100755
index 0000000..c9c26cb
--- /dev/null
+++ b/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc.h
@@ -0,0 +1,137 @@
+/**
+ ******************************************************************************
+ * @file usbd_msc.h
+ * @author MCD Application Team
+ * @brief Header for the usbd_msc.c file
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USBD_MSC_H
+#define __USBD_MSC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_msc_bot.h"
+#include "usbd_msc_scsi.h"
+#include "usbd_ioreq.h"
+
+/** @addtogroup USBD_MSC_BOT
+ * @{
+ */
+
+/** @defgroup USBD_MSC
+ * @brief This file is the Header file for usbd_msc.c
+ * @{
+ */
+
+
+/** @defgroup USBD_BOT_Exported_Defines
+ * @{
+ */
+/* MSC Class Config */
+#ifndef MSC_MEDIA_PACKET
+#define MSC_MEDIA_PACKET 512U
+#endif /* MSC_MEDIA_PACKET */
+
+#define MSC_MAX_FS_PACKET 0x40U
+#define MSC_MAX_HS_PACKET 0x200U
+
+#define BOT_GET_MAX_LUN 0xFE
+#define BOT_RESET 0xFF
+#define USB_MSC_CONFIG_DESC_SIZ 32
+
+#ifndef MSC_EPIN_ADDR
+#define MSC_EPIN_ADDR 0x81U
+#endif /* MSC_EPIN_ADDR */
+
+#ifndef MSC_EPOUT_ADDR
+#define MSC_EPOUT_ADDR 0x01U
+#endif /* MSC_EPOUT_ADDR */
+
+#ifndef MSC_BOT_MAX_LUN
+#define MSC_BOT_MAX_LUN 0x2U
+#endif /* MSC_BOT_MAX_LUN */
+
+/**
+ * @}
+ */
+
+/** @defgroup USB_CORE_Exported_Types
+ * @{
+ */
+typedef struct _USBD_STORAGE
+{
+ int8_t (* Init)(uint8_t lun);
+ int8_t (* GetCapacity)(uint8_t lun, uint32_t *block_num, uint16_t *block_size);
+ int8_t (* IsReady)(uint8_t lun);
+ int8_t (* IsWriteProtected)(uint8_t lun);
+ int8_t (* Read)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
+ int8_t (* Write)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
+ int8_t (* GetMaxLun)(void);
+ int8_t *pInquiry;
+
+} USBD_StorageTypeDef;
+
+typedef struct
+{
+ uint16_t size;
+ uint32_t nbr;
+ uint32_t addr;
+ uint32_t len;
+} USBD_MSC_BOT_LUN_TypeDef;
+
+typedef struct
+{
+ uint32_t max_lun;
+ uint32_t interface;
+ uint8_t bot_state;
+ uint8_t bot_status;
+ uint32_t bot_data_length;
+ uint8_t bot_data[MSC_MEDIA_PACKET];
+ USBD_MSC_BOT_CBWTypeDef cbw;
+ USBD_MSC_BOT_CSWTypeDef csw;
+
+ USBD_SCSI_SenseTypeDef scsi_sense [SENSE_LIST_DEEPTH];
+ uint8_t scsi_sense_head;
+ uint8_t scsi_sense_tail;
+ uint8_t scsi_medium_state;
+
+ USBD_MSC_BOT_LUN_TypeDef scsi_blk[MSC_BOT_MAX_LUN];
+} USBD_MSC_BOT_HandleTypeDef;
+
+/* Structure for MSC process */
+extern USBD_ClassTypeDef USBD_MSC;
+#define USBD_MSC_CLASS &USBD_MSC
+
+uint8_t USBD_MSC_RegisterStorage(USBD_HandleTypeDef *pdev,
+ USBD_StorageTypeDef *fops);
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __USBD_MSC_H */
+/**
+ * @}
+ */
diff --git a/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_bot.h b/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_bot.h
new file mode 100755
index 0000000..8550a39
--- /dev/null
+++ b/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_bot.h
@@ -0,0 +1,146 @@
+/**
+ ******************************************************************************
+ * @file usbd_msc_bot.h
+ * @author MCD Application Team
+ * @brief Header for the usbd_msc_bot.c file
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USBD_MSC_BOT_H
+#define __USBD_MSC_BOT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_core.h"
+
+/** @addtogroup STM32_USB_DEVICE_LIBRARY
+ * @{
+ */
+
+/** @defgroup MSC_BOT
+ * @brief This file is the Header file for usbd_msc_bot.c
+ * @{
+ */
+
+
+/** @defgroup USBD_CORE_Exported_Defines
+ * @{
+ */
+#define USBD_BOT_IDLE 0U /* Idle state */
+#define USBD_BOT_DATA_OUT 1U /* Data Out state */
+#define USBD_BOT_DATA_IN 2U /* Data In state */
+#define USBD_BOT_LAST_DATA_IN 3U /* Last Data In Last */
+#define USBD_BOT_SEND_DATA 4U /* Send Immediate data */
+#define USBD_BOT_NO_DATA 5U /* No data Stage */
+
+#define USBD_BOT_CBW_SIGNATURE 0x43425355U
+#define USBD_BOT_CSW_SIGNATURE 0x53425355U
+#define USBD_BOT_CBW_LENGTH 31U
+#define USBD_BOT_CSW_LENGTH 13U
+#define USBD_BOT_MAX_DATA 256U
+
+/* CSW Status Definitions */
+#define USBD_CSW_CMD_PASSED 0x00U
+#define USBD_CSW_CMD_FAILED 0x01U
+#define USBD_CSW_PHASE_ERROR 0x02U
+
+/* BOT Status */
+#define USBD_BOT_STATUS_NORMAL 0U
+#define USBD_BOT_STATUS_RECOVERY 1U
+#define USBD_BOT_STATUS_ERROR 2U
+
+
+#define USBD_DIR_IN 0U
+#define USBD_DIR_OUT 1U
+#define USBD_BOTH_DIR 2U
+
+/**
+ * @}
+ */
+
+/** @defgroup MSC_CORE_Private_TypesDefinitions
+ * @{
+ */
+
+typedef struct
+{
+ uint32_t dSignature;
+ uint32_t dTag;
+ uint32_t dDataLength;
+ uint8_t bmFlags;
+ uint8_t bLUN;
+ uint8_t bCBLength;
+ uint8_t CB[16];
+ uint8_t ReservedForAlign;
+} USBD_MSC_BOT_CBWTypeDef;
+
+
+typedef struct
+{
+ uint32_t dSignature;
+ uint32_t dTag;
+ uint32_t dDataResidue;
+ uint8_t bStatus;
+ uint8_t ReservedForAlign[3];
+} USBD_MSC_BOT_CSWTypeDef;
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_CORE_Exported_Types
+ * @{
+ */
+
+/**
+ * @}
+ */
+/** @defgroup USBD_CORE_Exported_FunctionsPrototypes
+ * @{
+ */
+void MSC_BOT_Init(USBD_HandleTypeDef *pdev);
+void MSC_BOT_Reset(USBD_HandleTypeDef *pdev);
+void MSC_BOT_DeInit(USBD_HandleTypeDef *pdev);
+void MSC_BOT_DataIn(USBD_HandleTypeDef *pdev,
+ uint8_t epnum);
+
+void MSC_BOT_DataOut(USBD_HandleTypeDef *pdev,
+ uint8_t epnum);
+
+void MSC_BOT_SendCSW(USBD_HandleTypeDef *pdev,
+ uint8_t CSW_Status);
+
+void MSC_BOT_CplClrFeature(USBD_HandleTypeDef *pdev,
+ uint8_t epnum);
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __USBD_MSC_BOT_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
diff --git a/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_data.h b/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_data.h
new file mode 100755
index 0000000..a321c91
--- /dev/null
+++ b/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_data.h
@@ -0,0 +1,106 @@
+/**
+ ******************************************************************************
+ * @file usbd_msc_data.h
+ * @author MCD Application Team
+ * @brief Header for the usbd_msc_data.c file
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USBD_MSC_DATA_H
+#define __USBD_MSC_DATA_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_conf.h"
+
+/** @addtogroup STM32_USB_DEVICE_LIBRARY
+ * @{
+ */
+
+/** @defgroup USB_INFO
+ * @brief general defines for the usb device library file
+ * @{
+ */
+
+/** @defgroup USB_INFO_Exported_Defines
+ * @{
+ */
+#define MODE_SENSE6_LEN 0x04U
+#define MODE_SENSE10_LEN 0x08U
+#define LENGTH_INQUIRY_PAGE00 0x06U
+#define LENGTH_INQUIRY_PAGE80 0x08U
+#define LENGTH_FORMAT_CAPACITIES 0x14U
+#define DIAGNOSTIC_DATA_LEN 0x08U
+#define LOG_PAGE_DATA_LEN 0x10U
+
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_INFO_Exported_TypesDefinitions
+ * @{
+ */
+/**
+ * @}
+ */
+
+
+
+/** @defgroup USBD_INFO_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_INFO_Exported_Variables
+ * @{
+ */
+extern uint8_t MSC_Page00_Inquiry_Data[LENGTH_INQUIRY_PAGE00];
+extern uint8_t MSC_Page80_Inquiry_Data[LENGTH_INQUIRY_PAGE80];
+extern uint8_t MSC_Mode_Sense6_data[MODE_SENSE6_LEN];
+extern uint8_t MSC_Mode_Sense10_data[MODE_SENSE10_LEN];
+extern uint8_t MSC_Diagnostic_Data[DIAGNOSTIC_DATA_LEN];
+extern uint8_t MSC_Log_Page_Data[LOG_PAGE_DATA_LEN];
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_INFO_Exported_FunctionsPrototype
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __USBD_MSC_DATA_H */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
diff --git a/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_scsi.h b/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_scsi.h
new file mode 100755
index 0000000..6000c2b
--- /dev/null
+++ b/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc/usbd_msc_scsi.h
@@ -0,0 +1,183 @@
+/**
+ ******************************************************************************
+ * @file usbd_msc_scsi.h
+ * @author MCD Application Team
+ * @brief Header for the usbd_msc_scsi.c file
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USBD_MSC_SCSI_H
+#define __USBD_MSC_SCSI_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "usbd_def.h"
+
+/** @addtogroup STM32_USB_DEVICE_LIBRARY
+ * @{
+ */
+
+/** @defgroup USBD_SCSI
+ * @brief header file for the storage disk file
+ * @{
+ */
+
+/** @defgroup USBD_SCSI_Exported_Defines
+ * @{
+ */
+
+#define SENSE_LIST_DEEPTH 4U
+
+/* SCSI Commands */
+#define SCSI_FORMAT_UNIT 0x04U
+#define SCSI_INQUIRY 0x12U
+#define SCSI_MODE_SELECT6 0x15U
+#define SCSI_MODE_SELECT10 0x55U
+#define SCSI_MODE_SENSE6 0x1AU
+#define SCSI_MODE_SENSE10 0x5AU
+#define SCSI_ALLOW_MEDIUM_REMOVAL 0x1EU
+#define SCSI_READ6 0x08U
+#define SCSI_READ10 0x28U
+#define SCSI_READ12 0xA8U
+#define SCSI_READ16 0x88U
+
+#define SCSI_READ_CAPACITY10 0x25U
+#define SCSI_READ_CAPACITY16 0x9EU
+
+#define SCSI_REQUEST_SENSE 0x03U
+#define SCSI_START_STOP_UNIT 0x1BU
+#define SCSI_TEST_UNIT_READY 0x00U
+#define SCSI_WRITE6 0x0AU
+#define SCSI_WRITE10 0x2AU
+#define SCSI_WRITE12 0xAAU
+#define SCSI_WRITE16 0x8AU
+
+#define SCSI_VERIFY10 0x2FU
+#define SCSI_VERIFY12 0xAFU
+#define SCSI_VERIFY16 0x8FU
+
+#define SCSI_READ_FORMAT_CAPACITIES 0x23U
+#define SCSI_RECEIVE_DIAGNOSTIC_RESULTS 0x1CU
+#define SCSI_SEND_DIAGNOSTIC 0x1DU
+#define SCSI_REPORT_LUNS 0xA0U
+
+#define NO_SENSE 0U
+#define RECOVERED_ERROR 1U
+#define NOT_READY 2U
+#define MEDIUM_ERROR 3U
+#define HARDWARE_ERROR 4U
+#define ILLEGAL_REQUEST 5U
+#define UNIT_ATTENTION 6U
+#define DATA_PROTECT 7U
+#define BLANK_CHECK 8U
+#define MSC_VENDOR_SPECIFIC 9U
+#define COPY_ABORTED 10U
+#define ABORTED_COMMAND 11U
+#define VOLUME_OVERFLOW 13U
+#define MISCOMPARE 14U
+
+#define INVALID_CDB 0x20U
+#define INVALID_FIELD_IN_COMMAND 0x24U
+#define PARAMETER_LIST_LENGTH_ERROR 0x1AU
+#define INVALID_FIELD_IN_PARAMETER_LIST 0x26U
+#define ADDRESS_OUT_OF_RANGE 0x21U
+#define MEDIUM_NOT_PRESENT 0x3AU
+#define MEDIUM_HAVE_CHANGED 0x28U
+#define WRITE_PROTECTED 0x27U
+#define UNRECOVERED_READ_ERROR 0x11U
+#define WRITE_FAULT 0x03U
+
+#define READ_FORMAT_CAPACITY_DATA_LEN 0x0CU
+#define READ_CAPACITY10_DATA_LEN 0x08U
+#define REQUEST_SENSE_DATA_LEN 0x12U
+#define STANDARD_INQUIRY_DATA_LEN 0x24U
+#define BLKVFY 0x04U
+
+#define SCSI_MEDIUM_UNLOCKED 0x00U
+#define SCSI_MEDIUM_LOCKED 0x01U
+#define SCSI_MEDIUM_EJECTED 0x02U
+/**
+ * @}
+ */
+
+
+/** @defgroup USBD_SCSI_Exported_TypesDefinitions
+ * @{
+ */
+
+typedef struct _SENSE_ITEM
+{
+ uint8_t Skey;
+ union
+ {
+ struct _ASCs
+ {
+ uint8_t ASC;
+ uint8_t ASCQ;
+ } b;
+ uint8_t ASC;
+ uint8_t *pData;
+ } w;
+} USBD_SCSI_SenseTypeDef;
+/**
+ * @}
+ */
+
+/** @defgroup USBD_SCSI_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USBD_SCSI_Exported_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+/** @defgroup USBD_SCSI_Exported_FunctionsPrototype
+ * @{
+ */
+int8_t SCSI_ProcessCmd(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *cmd);
+
+void SCSI_SenseCode(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t sKey,
+ uint8_t ASC);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __USBD_MSC_SCSI_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+