| 1 |
/** |
| 2 |
****************************************************************************** |
| 3 |
* @file usbh_mtp.c |
| 4 |
* @author MCD Application Team |
| 5 |
* @version V3.0.0 |
| 6 |
* @date 18-February-2014 |
| 7 |
* @brief This file is the MTP Layer Handlers for USB Host MTP class. |
| 8 |
* |
| 9 |
* |
| 10 |
****************************************************************************** |
| 11 |
* @attention |
| 12 |
* |
| 13 |
* <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2> |
| 14 |
* |
| 15 |
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); |
| 16 |
* You may not use this file except in compliance with the License. |
| 17 |
* You may obtain a copy of the License at: |
| 18 |
* |
| 19 |
* http://www.st.com/software_license_agreement_liberty_v2 |
| 20 |
* |
| 21 |
* Unless required by applicable law or agreed to in writing, software |
| 22 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 23 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 24 |
* See the License for the specific language governing permissions and |
| 25 |
* limitations under the License. |
| 26 |
* |
| 27 |
****************************************************************************** |
| 28 |
*/ |
| 29 |
|
| 30 |
/* Includes ------------------------------------------------------------------*/ |
| 31 |
#include "usbh_template.h" |
| 32 |
|
| 33 |
/** @addtogroup USBH_LIB |
| 34 |
* @{ |
| 35 |
*/ |
| 36 |
|
| 37 |
/** @addtogroup USBH_CLASS |
| 38 |
* @{ |
| 39 |
*/ |
| 40 |
|
| 41 |
/** @addtogroup USBH_TEMPLATE_CLASS |
| 42 |
* @{ |
| 43 |
*/ |
| 44 |
|
| 45 |
/** @defgroup USBH_TEMPLATE_CORE |
| 46 |
* @brief This file includes TEMPLATE Layer Handlers for USB Host TEMPLATE class. |
| 47 |
* @{ |
| 48 |
*/ |
| 49 |
|
| 50 |
/** @defgroup USBH_TEMPLATE_CORE_Private_TypesDefinitions |
| 51 |
* @{ |
| 52 |
*/ |
| 53 |
/** |
| 54 |
* @} |
| 55 |
*/ |
| 56 |
|
| 57 |
|
| 58 |
/** @defgroup USBH_TEMPLATE_CORE_Private_Defines |
| 59 |
* @{ |
| 60 |
*/ |
| 61 |
/** |
| 62 |
* @} |
| 63 |
*/ |
| 64 |
|
| 65 |
|
| 66 |
/** @defgroup USBH_TEMPLATE_CORE_Private_Macros |
| 67 |
* @{ |
| 68 |
*/ |
| 69 |
/** |
| 70 |
* @} |
| 71 |
*/ |
| 72 |
|
| 73 |
|
| 74 |
/** @defgroup USBH_TEMPLATE_CORE_Private_Variables |
| 75 |
* @{ |
| 76 |
*/ |
| 77 |
/** |
| 78 |
* @} |
| 79 |
*/ |
| 80 |
|
| 81 |
|
| 82 |
/** @defgroup USBH_TEMPLATE_CORE_Private_FunctionPrototypes |
| 83 |
* @{ |
| 84 |
*/ |
| 85 |
|
| 86 |
static USBH_StatusTypeDef USBH_TEMPLATE_InterfaceInit (USBH_HandleTypeDef *phost); |
| 87 |
|
| 88 |
static USBH_StatusTypeDef USBH_TEMPLATE_InterfaceDeInit (USBH_HandleTypeDef *phost); |
| 89 |
|
| 90 |
static USBH_StatusTypeDef USBH_TEMPLATE_Process(USBH_HandleTypeDef *phost); |
| 91 |
|
| 92 |
static USBH_StatusTypeDef USBH_TEMPLATE_ClassRequest (USBH_HandleTypeDef *phost); |
| 93 |
|
| 94 |
|
| 95 |
USBH_ClassTypeDef TEMPLATE_Class = |
| 96 |
{ |
| 97 |
"TEMPLATE", |
| 98 |
USB_TEMPLATE_CLASS, |
| 99 |
USBH_TEMPLATE_InterfaceInit, |
| 100 |
USBH_TEMPLATE_InterfaceDeInit, |
| 101 |
USBH_TEMPLATE_ClassRequest, |
| 102 |
USBH_TEMPLATE_Process |
| 103 |
}; |
| 104 |
/** |
| 105 |
* @} |
| 106 |
*/ |
| 107 |
|
| 108 |
|
| 109 |
/** @defgroup USBH_TEMPLATE_CORE_Private_Functions |
| 110 |
* @{ |
| 111 |
*/ |
| 112 |
|
| 113 |
/** |
| 114 |
* @brief USBH_TEMPLATE_InterfaceInit |
| 115 |
* The function init the TEMPLATE class. |
| 116 |
* @param phost: Host handle |
| 117 |
* @retval USBH Status |
| 118 |
*/ |
| 119 |
static USBH_StatusTypeDef USBH_TEMPLATE_InterfaceInit (USBH_HandleTypeDef *phost) |
| 120 |
{ |
| 121 |
|
| 122 |
return USBH_OK; |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
/** |
| 128 |
* @brief USBH_TEMPLATE_InterfaceDeInit |
| 129 |
* The function DeInit the Pipes used for the TEMPLATE class. |
| 130 |
* @param phost: Host handle |
| 131 |
* @retval USBH Status |
| 132 |
*/ |
| 133 |
USBH_StatusTypeDef USBH_TEMPLATE_InterfaceDeInit (USBH_HandleTypeDef *phost) |
| 134 |
{ |
| 135 |
|
| 136 |
return USBH_OK; |
| 137 |
} |
| 138 |
|
| 139 |
/** |
| 140 |
* @brief USBH_TEMPLATE_ClassRequest |
| 141 |
* The function is responsible for handling Standard requests |
| 142 |
* for TEMPLATE class. |
| 143 |
* @param phost: Host handle |
| 144 |
* @retval USBH Status |
| 145 |
*/ |
| 146 |
static USBH_StatusTypeDef USBH_TEMPLATE_ClassRequest (USBH_HandleTypeDef *phost) |
| 147 |
{ |
| 148 |
|
| 149 |
return USBH_OK; |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
/** |
| 154 |
* @brief USBH_TEMPLATE_Process |
| 155 |
* The function is for managing state machine for TEMPLATE data transfers |
| 156 |
* @param phost: Host handle |
| 157 |
* @retval USBH Status |
| 158 |
*/ |
| 159 |
static USBH_StatusTypeDef USBH_TEMPLATE_Process (USBH_HandleTypeDef *phost) |
| 160 |
{ |
| 161 |
|
| 162 |
return USBH_OK; |
| 163 |
} |
| 164 |
|
| 165 |
|
| 166 |
/** |
| 167 |
* @brief USBH_TEMPLATE_Init |
| 168 |
* The function Initialize the TEMPLATE function |
| 169 |
* @param phost: Host handle |
| 170 |
* @retval USBH Status |
| 171 |
*/ |
| 172 |
USBH_StatusTypeDef USBH_TEMPLATE_Init (USBH_HandleTypeDef *phost) |
| 173 |
{ |
| 174 |
USBH_StatusTypeDef Status = USBH_BUSY; |
| 175 |
#if (USBH_USE_OS == 1) |
| 176 |
osEvent event; |
| 177 |
|
| 178 |
event = osMessageGet( phost->class_ready_event, osWaitForever ); |
| 179 |
|
| 180 |
if( event.status == osEventMessage ) |
| 181 |
{ |
| 182 |
if(event.value.v == USBH_CLASS_EVENT) |
| 183 |
{ |
| 184 |
#else |
| 185 |
|
| 186 |
while ((Status == USBH_BUSY) || (Status == USBH_FAIL)) |
| 187 |
{ |
| 188 |
/* Host background process */ |
| 189 |
USBH_Process(phost); |
| 190 |
if(phost->gState == HOST_CLASS) |
| 191 |
{ |
| 192 |
#endif |
| 193 |
Status = USBH_OK; |
| 194 |
} |
| 195 |
} |
| 196 |
return Status; |
| 197 |
} |
| 198 |
|
| 199 |
/** |
| 200 |
* @brief USBH_TEMPLATE_IOProcess |
| 201 |
* TEMPLATE TEMPLATE process |
| 202 |
* @param phost: Host handle |
| 203 |
* @retval USBH Status |
| 204 |
*/ |
| 205 |
USBH_StatusTypeDef USBH_TEMPLATE_IOProcess (USBH_HandleTypeDef *phost) |
| 206 |
{ |
| 207 |
if (phost->device.is_connected == 1) |
| 208 |
{ |
| 209 |
if(phost->gState == HOST_CLASS) |
| 210 |
{ |
| 211 |
USBH_TEMPLATE_Process(phost); |
| 212 |
} |
| 213 |
} |
| 214 |
|
| 215 |
return USBH_OK; |
| 216 |
} |
| 217 |
|
| 218 |
/** |
| 219 |
* @} |
| 220 |
*/ |
| 221 |
|
| 222 |
/** |
| 223 |
* @} |
| 224 |
*/ |
| 225 |
|
| 226 |
/** |
| 227 |
* @} |
| 228 |
*/ |
| 229 |
|
| 230 |
|
| 231 |
/** |
| 232 |
* @} |
| 233 |
*/ |
| 234 |
|
| 235 |
|
| 236 |
/** |
| 237 |
* @} |
| 238 |
*/ |
| 239 |
|
| 240 |
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |