| 1 |
/** |
| 2 |
****************************************************************************** |
| 3 |
* @file usbh_msc_bot.h |
| 4 |
* @author MCD Application Team |
| 5 |
* @version V3.0.0 |
| 6 |
* @date 18-February-2014 |
| 7 |
* @brief Header file for usbh_msc_bot.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_BOT_H__ |
| 30 |
#define __USBH_MSC_BOT_H__ |
| 31 |
|
| 32 |
/* Includes ------------------------------------------------------------------*/ |
| 33 |
#include "usbh_core.h" |
| 34 |
#include "usbh_msc_bot.h" |
| 35 |
|
| 36 |
/** @addtogroup USBH_LIB |
| 37 |
* @{ |
| 38 |
*/ |
| 39 |
|
| 40 |
/** @addtogroup USBH_CLASS |
| 41 |
* @{ |
| 42 |
*/ |
| 43 |
|
| 44 |
/** @addtogroup USBH_MSC_CLASS |
| 45 |
* @{ |
| 46 |
*/ |
| 47 |
|
| 48 |
/** @defgroup USBH_MSC_BOT |
| 49 |
* @brief This file is the Header file for usbh_msc_core.c |
| 50 |
* @{ |
| 51 |
*/ |
| 52 |
|
| 53 |
|
| 54 |
/** @defgroup USBH_MSC_BOT_Exported_Types |
| 55 |
* @{ |
| 56 |
*/ |
| 57 |
|
| 58 |
typedef enum { |
| 59 |
BOT_OK = 0, |
| 60 |
BOT_FAIL = 1, |
| 61 |
BOT_PHASE_ERROR = 2, |
| 62 |
BOT_BUSY = 3 |
| 63 |
} |
| 64 |
BOT_StatusTypeDef; |
| 65 |
|
| 66 |
typedef enum { |
| 67 |
BOT_CMD_IDLE = 0, |
| 68 |
BOT_CMD_SEND, |
| 69 |
BOT_CMD_WAIT, |
| 70 |
} |
| 71 |
BOT_CMDStateTypeDef; |
| 72 |
|
| 73 |
/* CSW Status Definitions */ |
| 74 |
typedef enum |
| 75 |
{ |
| 76 |
|
| 77 |
BOT_CSW_CMD_PASSED = 0x00, |
| 78 |
BOT_CSW_CMD_FAILED = 0x01, |
| 79 |
BOT_CSW_PHASE_ERROR = 0x02, |
| 80 |
} |
| 81 |
BOT_CSWStatusTypeDef; |
| 82 |
|
| 83 |
typedef enum { |
| 84 |
BOT_SEND_CBW = 1, |
| 85 |
BOT_SEND_CBW_WAIT, |
| 86 |
BOT_DATA_IN, |
| 87 |
BOT_DATA_IN_WAIT, |
| 88 |
BOT_DATA_OUT, |
| 89 |
BOT_DATA_OUT_WAIT, |
| 90 |
BOT_RECEIVE_CSW, |
| 91 |
BOT_RECEIVE_CSW_WAIT, |
| 92 |
BOT_ERROR_IN, |
| 93 |
BOT_ERROR_OUT, |
| 94 |
BOT_UNRECOVERED_ERROR |
| 95 |
} |
| 96 |
BOT_StateTypeDef; |
| 97 |
|
| 98 |
typedef union |
| 99 |
{ |
| 100 |
struct __CBW |
| 101 |
{ |
| 102 |
uint32_t Signature; |
| 103 |
uint32_t Tag; |
| 104 |
uint32_t DataTransferLength; |
| 105 |
uint8_t Flags; |
| 106 |
uint8_t LUN; |
| 107 |
uint8_t CBLength; |
| 108 |
uint8_t CB[16]; |
| 109 |
}field; |
| 110 |
uint8_t data[31]; |
| 111 |
} |
| 112 |
BOT_CBWTypeDef; |
| 113 |
|
| 114 |
typedef union |
| 115 |
{ |
| 116 |
struct __CSW |
| 117 |
{ |
| 118 |
uint32_t Signature; |
| 119 |
uint32_t Tag; |
| 120 |
uint32_t DataResidue; |
| 121 |
uint8_t Status; |
| 122 |
}field; |
| 123 |
uint8_t data[13]; |
| 124 |
} |
| 125 |
BOT_CSWTypeDef; |
| 126 |
|
| 127 |
typedef struct |
| 128 |
{ |
| 129 |
uint32_t data[16]; |
| 130 |
BOT_StateTypeDef state; |
| 131 |
BOT_StateTypeDef prev_state; |
| 132 |
BOT_CMDStateTypeDef cmd_state; |
| 133 |
BOT_CBWTypeDef cbw; |
| 134 |
uint8_t Reserved1; |
| 135 |
BOT_CSWTypeDef csw; |
| 136 |
uint8_t Reserved2[3]; |
| 137 |
uint8_t *pbuf; |
| 138 |
} |
| 139 |
BOT_HandleTypeDef; |
| 140 |
|
| 141 |
/** |
| 142 |
* @} |
| 143 |
*/ |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
/** @defgroup USBH_MSC_BOT_Exported_Defines |
| 148 |
* @{ |
| 149 |
*/ |
| 150 |
#define BOT_CBW_SIGNATURE 0x43425355 |
| 151 |
#define BOT_CBW_TAG 0x20304050 |
| 152 |
#define BOT_CSW_SIGNATURE 0x53425355 |
| 153 |
#define BOT_CBW_LENGTH 31 |
| 154 |
#define BOT_CSW_LENGTH 13 |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
#define BOT_SEND_CSW_DISABLE 0 |
| 159 |
#define BOT_SEND_CSW_ENABLE 1 |
| 160 |
|
| 161 |
#define BOT_DIR_IN 0 |
| 162 |
#define BOT_DIR_OUT 1 |
| 163 |
#define BOT_DIR_BOTH 2 |
| 164 |
|
| 165 |
#define BOT_PAGE_LENGTH 512 |
| 166 |
|
| 167 |
|
| 168 |
#define BOT_CBW_CB_LENGTH 16 |
| 169 |
|
| 170 |
|
| 171 |
#define USB_REQ_BOT_RESET 0xFF |
| 172 |
#define USB_REQ_GET_MAX_LUN 0xFE |
| 173 |
|
| 174 |
#define MAX_BULK_STALL_COUNT_LIMIT 0x04 /* If STALL is seen on Bulk |
| 175 |
Endpoint continously, this means |
| 176 |
that device and Host has phase error |
| 177 |
Hence a Reset is needed */ |
| 178 |
|
| 179 |
/** |
| 180 |
* @} |
| 181 |
*/ |
| 182 |
|
| 183 |
/** @defgroup USBH_MSC_BOT_Exported_Macros |
| 184 |
* @{ |
| 185 |
*/ |
| 186 |
/** |
| 187 |
* @} |
| 188 |
*/ |
| 189 |
|
| 190 |
/** @defgroup USBH_MSC_BOT_Exported_Variables |
| 191 |
* @{ |
| 192 |
*/ |
| 193 |
|
| 194 |
/** |
| 195 |
* @} |
| 196 |
*/ |
| 197 |
|
| 198 |
/** @defgroup USBH_MSC_BOT_Exported_FunctionsPrototype |
| 199 |
* @{ |
| 200 |
*/ |
| 201 |
USBH_StatusTypeDef USBH_MSC_BOT_REQ_Reset(USBH_HandleTypeDef *phost); |
| 202 |
USBH_StatusTypeDef USBH_MSC_BOT_REQ_GetMaxLUN(USBH_HandleTypeDef *phost, uint8_t *Maxlun); |
| 203 |
|
| 204 |
USBH_StatusTypeDef USBH_MSC_BOT_Init(USBH_HandleTypeDef *phost); |
| 205 |
USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun); |
| 206 |
USBH_StatusTypeDef USBH_MSC_BOT_Error(USBH_HandleTypeDef *phost, uint8_t lun); |
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
/** |
| 211 |
* @} |
| 212 |
*/ |
| 213 |
|
| 214 |
#endif //__USBH_MSC_BOT_H__ |
| 215 |
|
| 216 |
|
| 217 |
/** |
| 218 |
* @} |
| 219 |
*/ |
| 220 |
|
| 221 |
/** |
| 222 |
* @} |
| 223 |
*/ |
| 224 |
|
| 225 |
/** |
| 226 |
* @} |
| 227 |
*/ |
| 228 |
|
| 229 |
/** |
| 230 |
* @} |
| 231 |
*/ |
| 232 |
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
| 233 |
|