| 1 |
/** |
| 2 |
****************************************************************************** |
| 3 |
* @file usbh_msc.h |
| 4 |
* @author MCD Application Team |
| 5 |
* @version V3.0.0 |
| 6 |
* @date 18-February-2014 |
| 7 |
* @brief This file contains all the prototypes for the usbh_msc_core.c |
| 8 |
****************************************************************************** |
| 9 |
* @attention |
| 10 |
* |
| 11 |
* <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2> |
| 12 |
* |
| 13 |
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); |
| 14 |
* You may not use this file except in compliance with the License. |
| 15 |
* You may obtain a copy of the License at: |
| 16 |
* |
| 17 |
* http://www.st.com/software_license_agreement_liberty_v2 |
| 18 |
* |
| 19 |
* Unless required by applicable law or agreed to in writing, software |
| 20 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 21 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 22 |
* See the License for the specific language governing permissions and |
| 23 |
* limitations under the License. |
| 24 |
* |
| 25 |
****************************************************************************** |
| 26 |
*/ |
| 27 |
|
| 28 |
/* Define to prevent recursive ----------------------------------------------*/ |
| 29 |
#ifndef __USBH_MSC_H |
| 30 |
#define __USBH_MSC_H |
| 31 |
|
| 32 |
/* Includes ------------------------------------------------------------------*/ |
| 33 |
#include "usbh_core.h" |
| 34 |
#include "usbh_msc_bot.h" |
| 35 |
#include "usbh_msc_scsi.h" |
| 36 |
|
| 37 |
/** @addtogroup USBH_LIB |
| 38 |
* @{ |
| 39 |
*/ |
| 40 |
|
| 41 |
/** @addtogroup USBH_CLASS |
| 42 |
* @{ |
| 43 |
*/ |
| 44 |
|
| 45 |
/** @addtogroup USBH_MSC_CLASS |
| 46 |
* @{ |
| 47 |
*/ |
| 48 |
|
| 49 |
/** @defgroup USBH_MSC_CORE |
| 50 |
* @brief This file is the Header file for usbh_msc_core.c |
| 51 |
* @{ |
| 52 |
*/ |
| 53 |
|
| 54 |
|
| 55 |
/** @defgroup USBH_MSC_CORE_Exported_Types |
| 56 |
* @{ |
| 57 |
*/ |
| 58 |
|
| 59 |
typedef enum |
| 60 |
{ |
| 61 |
MSC_INIT = 0, |
| 62 |
MSC_IDLE, |
| 63 |
MSC_TEST_UNIT_READY, |
| 64 |
MSC_READ_CAPACITY10, |
| 65 |
MSC_READ_INQUIRY, |
| 66 |
MSC_REQUEST_SENSE, |
| 67 |
MSC_READ, |
| 68 |
MSC_WRITE, |
| 69 |
MSC_UNRECOVERED_ERROR, |
| 70 |
MSC_PERIODIC_CHECK, |
| 71 |
} |
| 72 |
MSC_StateTypeDef; |
| 73 |
|
| 74 |
typedef enum |
| 75 |
{ |
| 76 |
MSC_OK, |
| 77 |
MSC_NOT_READY, |
| 78 |
MSC_ERROR, |
| 79 |
|
| 80 |
} |
| 81 |
MSC_ErrorTypeDef; |
| 82 |
|
| 83 |
typedef enum |
| 84 |
{ |
| 85 |
MSC_REQ_IDLE = 0, |
| 86 |
MSC_REQ_RESET, |
| 87 |
MSC_REQ_GET_MAX_LUN, |
| 88 |
MSC_REQ_ERROR, |
| 89 |
} |
| 90 |
MSC_ReqStateTypeDef; |
| 91 |
|
| 92 |
#define MAX_SUPPORTED_LUN 2 |
| 93 |
|
| 94 |
/* Structure for LUN */ |
| 95 |
typedef struct |
| 96 |
{ |
| 97 |
MSC_StateTypeDef state; |
| 98 |
MSC_ErrorTypeDef error; |
| 99 |
USBH_StatusTypeDef prev_ready_state; |
| 100 |
SCSI_CapacityTypeDef capacity; |
| 101 |
SCSI_SenseTypeDef sense; |
| 102 |
SCSI_StdInquiryDataTypeDef inquiry; |
| 103 |
uint8_t state_changed; |
| 104 |
|
| 105 |
} |
| 106 |
MSC_LUNTypeDef; |
| 107 |
|
| 108 |
/* Structure for MSC process */ |
| 109 |
typedef struct _MSC_Process |
| 110 |
{ |
| 111 |
uint32_t max_lun; |
| 112 |
uint8_t InPipe; |
| 113 |
uint8_t OutPipe; |
| 114 |
uint8_t OutEp; |
| 115 |
uint8_t InEp; |
| 116 |
uint16_t OutEpSize; |
| 117 |
uint16_t InEpSize; |
| 118 |
MSC_StateTypeDef state; |
| 119 |
MSC_ErrorTypeDef error; |
| 120 |
MSC_ReqStateTypeDef req_state; |
| 121 |
MSC_ReqStateTypeDef prev_req_state; |
| 122 |
BOT_HandleTypeDef hbot; |
| 123 |
MSC_LUNTypeDef unit[MAX_SUPPORTED_LUN]; |
| 124 |
uint16_t current_lun; |
| 125 |
uint16_t rw_lun; |
| 126 |
uint32_t timer; |
| 127 |
} |
| 128 |
MSC_HandleTypeDef; |
| 129 |
|
| 130 |
|
| 131 |
/** |
| 132 |
* @} |
| 133 |
*/ |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
/** @defgroup USBH_MSC_CORE_Exported_Defines |
| 138 |
* @{ |
| 139 |
*/ |
| 140 |
|
| 141 |
#define USB_REQ_BOT_RESET 0xFF |
| 142 |
#define USB_REQ_GET_MAX_LUN 0xFE |
| 143 |
|
| 144 |
|
| 145 |
/* MSC Class Codes */ |
| 146 |
#define USB_MSC_CLASS 0x08 |
| 147 |
|
| 148 |
/* Interface Descriptor field values for HID Boot Protocol */ |
| 149 |
#define MSC_BOT 0x50 |
| 150 |
#define MSC_TRANSPARENT 0x06 |
| 151 |
/** |
| 152 |
* @} |
| 153 |
*/ |
| 154 |
|
| 155 |
/** @defgroup USBH_MSC_CORE_Exported_Macros |
| 156 |
* @{ |
| 157 |
*/ |
| 158 |
/** |
| 159 |
* @} |
| 160 |
*/ |
| 161 |
|
| 162 |
/** @defgroup USBH_MSC_CORE_Exported_Variables |
| 163 |
* @{ |
| 164 |
*/ |
| 165 |
extern USBH_ClassTypeDef USBH_msc; |
| 166 |
#define USBH_MSC_CLASS &USBH_msc |
| 167 |
|
| 168 |
/** |
| 169 |
* @} |
| 170 |
*/ |
| 171 |
|
| 172 |
/** @defgroup USBH_MSC_CORE_Exported_FunctionsPrototype |
| 173 |
* @{ |
| 174 |
*/ |
| 175 |
|
| 176 |
/* Common APIs */ |
| 177 |
uint8_t USBH_MSC_IsReady (USBH_HandleTypeDef *phost); |
| 178 |
|
| 179 |
/* APIs for LUN */ |
| 180 |
int8_t USBH_MSC_GetMaxLUN (USBH_HandleTypeDef *phost); |
| 181 |
|
| 182 |
uint8_t USBH_MSC_UnitIsReady (USBH_HandleTypeDef *phost, uint8_t lun); |
| 183 |
|
| 184 |
USBH_StatusTypeDef USBH_MSC_GetLUNInfo(USBH_HandleTypeDef *phost, uint8_t lun, MSC_LUNTypeDef *info); |
| 185 |
|
| 186 |
USBH_StatusTypeDef USBH_MSC_Read(USBH_HandleTypeDef *phost, |
| 187 |
uint8_t lun, |
| 188 |
uint32_t address, |
| 189 |
uint8_t *pbuf, |
| 190 |
uint32_t length); |
| 191 |
|
| 192 |
USBH_StatusTypeDef USBH_MSC_Write(USBH_HandleTypeDef *phost, |
| 193 |
uint8_t lun, |
| 194 |
uint32_t address, |
| 195 |
uint8_t *pbuf, |
| 196 |
uint32_t length); |
| 197 |
/** |
| 198 |
* @} |
| 199 |
*/ |
| 200 |
|
| 201 |
#endif /* __USBH_MSC_H */ |
| 202 |
|
| 203 |
|
| 204 |
/** |
| 205 |
* @} |
| 206 |
*/ |
| 207 |
|
| 208 |
/** |
| 209 |
* @} |
| 210 |
*/ |
| 211 |
|
| 212 |
/** |
| 213 |
* @} |
| 214 |
*/ |
| 215 |
|
| 216 |
/** |
| 217 |
* @} |
| 218 |
*/ |
| 219 |
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
| 220 |
|
| 221 |
|
| 222 |
|