-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
STM32F4 USB OTG Host msc #20299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
bigtreetech
wants to merge
10
commits into
MarlinFirmware:bugfix-2.0.x
from
bigtreetech:stm32f4-usb-host-msc
Closed
STM32F4 USB OTG Host msc #20299
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
758a2af
support stm32f4 usb otg host msc feature
Msq001 99d455c
reset default config
Msq001 f98e885
detailed description for USB host msc
Msq001 c26a1aa
cleanup
Msq001 03fbe2d
Fix other stm32 platform compilation errors
Msq001 63b539f
Update platformio.ini
thinkyhead e31f5e6
basic cleanups
thinkyhead 0f01641
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/20299
thinkyhead b2e7d6c
Wrap HAL sources
thinkyhead c698ba0
C plus plus
thinkyhead File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
216 changes: 216 additions & 0 deletions
216
Marlin/src/HAL/STM32/usb_hostlib/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
/** | ||
****************************************************************************** | ||
* @file usbh_msc.h | ||
* @author MCD Application Team | ||
* @brief This file contains all the prototypes for the usbh_msc.c | ||
****************************************************************************** | ||
* @attention | ||
* | ||
* Copyright (c) 2015 STMicroelectronics. | ||
* All rights reserved. | ||
* | ||
* This software component is licensed by ST under Ultimate Liberty license | ||
* SLA0044, the "License"; You may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at: | ||
* www.st.com/SLA0044 | ||
* | ||
****************************************************************************** | ||
*/ | ||
|
||
/* Define to prevent recursive ----------------------------------------------*/ | ||
#ifndef __USBH_MSC_H | ||
#define __USBH_MSC_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* Includes ------------------------------------------------------------------*/ | ||
#include "../../../Core/Inc/usbh_core.h" | ||
#include "usbh_msc_bot.h" | ||
#include "usbh_msc_scsi.h" | ||
|
||
/** @addtogroup USBH_LIB | ||
* @{ | ||
*/ | ||
|
||
/** @addtogroup USBH_CLASS | ||
* @{ | ||
*/ | ||
|
||
/** @addtogroup USBH_MSC_CLASS | ||
* @{ | ||
*/ | ||
|
||
/** @defgroup USBH_MSC_CORE | ||
* @brief This file is the Header file for usbh_msc.c | ||
* @{ | ||
*/ | ||
|
||
|
||
/** @defgroup USBH_MSC_CORE_Exported_Types | ||
* @{ | ||
*/ | ||
|
||
typedef enum | ||
{ | ||
MSC_INIT = 0, | ||
MSC_IDLE, | ||
MSC_TEST_UNIT_READY, | ||
MSC_READ_CAPACITY10, | ||
MSC_READ_INQUIRY, | ||
MSC_REQUEST_SENSE, | ||
MSC_READ, | ||
MSC_WRITE, | ||
MSC_UNRECOVERED_ERROR, | ||
MSC_PERIODIC_CHECK, | ||
} | ||
MSC_StateTypeDef; | ||
|
||
typedef enum | ||
{ | ||
MSC_OK, | ||
MSC_NOT_READY, | ||
MSC_ERROR, | ||
|
||
} | ||
MSC_ErrorTypeDef; | ||
|
||
typedef enum | ||
{ | ||
MSC_REQ_IDLE = 0, | ||
MSC_REQ_RESET, | ||
MSC_REQ_GET_MAX_LUN, | ||
MSC_REQ_ERROR, | ||
} | ||
MSC_ReqStateTypeDef; | ||
|
||
#ifndef MAX_SUPPORTED_LUN | ||
#define MAX_SUPPORTED_LUN 2U | ||
#endif | ||
|
||
|
||
/* Structure for LUN */ | ||
typedef struct | ||
{ | ||
MSC_StateTypeDef state; | ||
MSC_ErrorTypeDef error; | ||
USBH_StatusTypeDef prev_ready_state; | ||
SCSI_CapacityTypeDef capacity; | ||
SCSI_SenseTypeDef sense; | ||
SCSI_StdInquiryDataTypeDef inquiry; | ||
uint8_t state_changed; | ||
|
||
} | ||
MSC_LUNTypeDef; | ||
|
||
/* Structure for MSC process */ | ||
typedef struct _MSC_Process | ||
{ | ||
uint8_t max_lun; | ||
uint8_t Reserved[3]; | ||
uint8_t InPipe; | ||
uint8_t OutPipe; | ||
uint8_t OutEp; | ||
uint8_t InEp; | ||
uint16_t OutEpSize; | ||
uint16_t InEpSize; | ||
MSC_StateTypeDef state; | ||
MSC_ErrorTypeDef error; | ||
MSC_ReqStateTypeDef req_state; | ||
MSC_ReqStateTypeDef prev_req_state; | ||
BOT_HandleTypeDef hbot; | ||
MSC_LUNTypeDef unit[MAX_SUPPORTED_LUN]; | ||
uint16_t current_lun; | ||
uint16_t rw_lun; | ||
uint32_t timer; | ||
} | ||
MSC_HandleTypeDef; | ||
|
||
|
||
/** | ||
* @} | ||
*/ | ||
|
||
|
||
|
||
/** @defgroup USBH_MSC_CORE_Exported_Defines | ||
* @{ | ||
*/ | ||
|
||
#define USB_REQ_BOT_RESET 0xFFU | ||
#define USB_REQ_GET_MAX_LUN 0xFEU | ||
|
||
|
||
/* MSC Class Codes */ | ||
#define USB_MSC_CLASS 0x08U | ||
|
||
/* Interface Descriptor field values for HID Boot Protocol */ | ||
#define MSC_BOT 0x50U | ||
#define MSC_TRANSPARENT 0x06U | ||
/** | ||
* @} | ||
*/ | ||
|
||
/** @defgroup USBH_MSC_CORE_Exported_Macros | ||
* @{ | ||
*/ | ||
/** | ||
* @} | ||
*/ | ||
|
||
/** @defgroup USBH_MSC_CORE_Exported_Variables | ||
* @{ | ||
*/ | ||
extern USBH_ClassTypeDef USBH_msc; | ||
#define USBH_MSC_CLASS &USBH_msc | ||
|
||
/** | ||
* @} | ||
*/ | ||
|
||
/** @defgroup USBH_MSC_CORE_Exported_FunctionsPrototype | ||
* @{ | ||
*/ | ||
uint8_t USBH_MSC_IsReady(USBH_HandleTypeDef *phost); | ||
uint8_t USBH_MSC_GetMaxLUN(USBH_HandleTypeDef *phost); | ||
uint8_t USBH_MSC_UnitIsReady(USBH_HandleTypeDef *phost, uint8_t lun); | ||
|
||
USBH_StatusTypeDef USBH_MSC_GetLUNInfo(USBH_HandleTypeDef *phost, uint8_t lun, | ||
MSC_LUNTypeDef *info); | ||
|
||
USBH_StatusTypeDef USBH_MSC_Read(USBH_HandleTypeDef *phost, uint8_t lun, | ||
uint32_t address, uint8_t *pbuf, uint32_t length); | ||
|
||
USBH_StatusTypeDef USBH_MSC_Write(USBH_HandleTypeDef *phost, uint8_t lun, | ||
uint32_t address, uint8_t *pbuf, uint32_t length); | ||
/** | ||
* @} | ||
*/ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __USBH_MSC_H */ | ||
|
||
|
||
/** | ||
* @} | ||
*/ | ||
|
||
/** | ||
* @} | ||
*/ | ||
|
||
/** | ||
* @} | ||
*/ | ||
|
||
/** | ||
* @} | ||
*/ | ||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | ||
|
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than leave it up to the user to set this, it would be better to enable it automatically when it is required.