Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_F746NG_patch mbed-rtos mbed
usbh_ioreq.c
00001 /** 00002 ****************************************************************************** 00003 * @file usbh_ioreq.c 00004 * @author MCD Application Team 00005 * @version V3.2.2 00006 * @date 07-July-2015 00007 * @brief This file handles the issuing of the USB transactions 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT 2015 STMicroelectronics</center></h2> 00012 * 00013 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 00014 * You may not use this file except in compliance with the License. 00015 * You may obtain a copy of the License at: 00016 * 00017 * http://www.st.com/software_license_agreement_liberty_v2 00018 * 00019 * Unless required by applicable law or agreed to in writing, software 00020 * distributed under the License is distributed on an "AS IS" BASIS, 00021 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00022 * See the License for the specific language governing permissions and 00023 * limitations under the License. 00024 * 00025 ****************************************************************************** 00026 */ 00027 /* Includes ------------------------------------------------------------------*/ 00028 00029 #include "usbh_ioreq.h" 00030 00031 /** @addtogroup USBH_LIB 00032 * @{ 00033 */ 00034 00035 /** @addtogroup USBH_LIB_CORE 00036 * @{ 00037 */ 00038 00039 /** @defgroup USBH_IOREQ 00040 * @brief This file handles the standard protocol processing (USB v2.0) 00041 * @{ 00042 */ 00043 00044 00045 /** @defgroup USBH_IOREQ_Private_Defines 00046 * @{ 00047 */ 00048 00049 /** 00050 * @} 00051 */ 00052 00053 00054 /** @defgroup USBH_IOREQ_Private_TypesDefinitions 00055 * @{ 00056 */ 00057 /** 00058 * @} 00059 */ 00060 00061 00062 00063 /** @defgroup USBH_IOREQ_Private_Macros 00064 * @{ 00065 */ 00066 /** 00067 * @} 00068 */ 00069 00070 00071 /** @defgroup USBH_IOREQ_Private_Variables 00072 * @{ 00073 */ 00074 /** 00075 * @} 00076 */ 00077 /** @defgroup USBH_IOREQ_Private_FunctionPrototypes 00078 * @{ 00079 */ 00080 00081 /** 00082 * @} 00083 */ 00084 00085 00086 /** @defgroup USBH_IOREQ_Private_Functions 00087 * @{ 00088 */ 00089 00090 00091 00092 /** 00093 * @brief USBH_CtlSendSetup 00094 * Sends the Setup Packet to the Device 00095 * @param phost: Host Handle 00096 * @param buff: Buffer pointer from which the Data will be send to Device 00097 * @param pipe_num: Pipe Number 00098 * @retval USBH Status 00099 */ 00100 USBH_StatusTypeDef USBH_CtlSendSetup (USBH_HandleTypeDef *phost, 00101 uint8_t *buff, 00102 uint8_t pipe_num) 00103 { 00104 00105 USBH_LL_SubmitURB (phost, /* Driver handle */ 00106 pipe_num, /* Pipe index */ 00107 0, /* Direction : OUT */ 00108 USBH_EP_CONTROL, /* EP type */ 00109 USBH_PID_SETUP, /* Type setup */ 00110 buff, /* data buffer */ 00111 USBH_SETUP_PKT_SIZE, /* data length */ 00112 0); 00113 return USBH_OK; 00114 } 00115 00116 00117 /** 00118 * @brief USBH_CtlSendData 00119 * Sends a data Packet to the Device 00120 * @param phost: Host Handle 00121 * @param buff: Buffer pointer from which the Data will be sent to Device 00122 * @param length: Length of the data to be sent 00123 * @param pipe_num: Pipe Number 00124 * @retval USBH Status 00125 */ 00126 USBH_StatusTypeDef USBH_CtlSendData (USBH_HandleTypeDef *phost, 00127 uint8_t *buff, 00128 uint16_t length, 00129 uint8_t pipe_num, 00130 uint8_t do_ping ) 00131 { 00132 if(phost->device.speed != USBH_SPEED_HIGH) 00133 { 00134 do_ping = 0; 00135 } 00136 00137 USBH_LL_SubmitURB (phost, /* Driver handle */ 00138 pipe_num, /* Pipe index */ 00139 0, /* Direction : OUT */ 00140 USBH_EP_CONTROL, /* EP type */ 00141 USBH_PID_DATA, /* Type Data */ 00142 buff, /* data buffer */ 00143 length, /* data length */ 00144 do_ping); /* do ping (HS Only)*/ 00145 00146 return USBH_OK; 00147 } 00148 00149 00150 /** 00151 * @brief USBH_CtlReceiveData 00152 * Receives the Device Response to the Setup Packet 00153 * @param phost: Host Handle 00154 * @param buff: Buffer pointer in which the response needs to be copied 00155 * @param length: Length of the data to be received 00156 * @param pipe_num: Pipe Number 00157 * @retval USBH Status. 00158 */ 00159 USBH_StatusTypeDef USBH_CtlReceiveData(USBH_HandleTypeDef *phost, 00160 uint8_t* buff, 00161 uint16_t length, 00162 uint8_t pipe_num) 00163 { 00164 USBH_LL_SubmitURB (phost, /* Driver handle */ 00165 pipe_num, /* Pipe index */ 00166 1, /* Direction : IN */ 00167 USBH_EP_CONTROL, /* EP type */ 00168 USBH_PID_DATA, /* Type Data */ 00169 buff, /* data buffer */ 00170 length, /* data length */ 00171 0); 00172 return USBH_OK; 00173 00174 } 00175 00176 00177 /** 00178 * @brief USBH_BulkSendData 00179 * Sends the Bulk Packet to the device 00180 * @param phost: Host Handle 00181 * @param buff: Buffer pointer from which the Data will be sent to Device 00182 * @param length: Length of the data to be sent 00183 * @param pipe_num: Pipe Number 00184 * @retval USBH Status 00185 */ 00186 USBH_StatusTypeDef USBH_BulkSendData (USBH_HandleTypeDef *phost, 00187 uint8_t *buff, 00188 uint16_t length, 00189 uint8_t pipe_num, 00190 uint8_t do_ping ) 00191 { 00192 if(phost->device.speed != USBH_SPEED_HIGH) 00193 { 00194 do_ping = 0; 00195 } 00196 00197 USBH_LL_SubmitURB (phost, /* Driver handle */ 00198 pipe_num, /* Pipe index */ 00199 0, /* Direction : IN */ 00200 USBH_EP_BULK, /* EP type */ 00201 USBH_PID_DATA, /* Type Data */ 00202 buff, /* data buffer */ 00203 length, /* data length */ 00204 do_ping); /* do ping (HS Only)*/ 00205 return USBH_OK; 00206 } 00207 00208 00209 /** 00210 * @brief USBH_BulkReceiveData 00211 * Receives IN bulk packet from device 00212 * @param phost: Host Handle 00213 * @param buff: Buffer pointer in which the received data packet to be copied 00214 * @param length: Length of the data to be received 00215 * @param pipe_num: Pipe Number 00216 * @retval USBH Status. 00217 */ 00218 USBH_StatusTypeDef USBH_BulkReceiveData(USBH_HandleTypeDef *phost, 00219 uint8_t *buff, 00220 uint16_t length, 00221 uint8_t pipe_num) 00222 { 00223 USBH_LL_SubmitURB (phost, /* Driver handle */ 00224 pipe_num, /* Pipe index */ 00225 1, /* Direction : IN */ 00226 USBH_EP_BULK, /* EP type */ 00227 USBH_PID_DATA, /* Type Data */ 00228 buff, /* data buffer */ 00229 length, /* data length */ 00230 0); 00231 return USBH_OK; 00232 } 00233 00234 00235 /** 00236 * @brief USBH_InterruptReceiveData 00237 * Receives the Device Response to the Interrupt IN token 00238 * @param phost: Host Handle 00239 * @param buff: Buffer pointer in which the response needs to be copied 00240 * @param length: Length of the data to be received 00241 * @param pipe_num: Pipe Number 00242 * @retval USBH Status. 00243 */ 00244 USBH_StatusTypeDef USBH_InterruptReceiveData(USBH_HandleTypeDef *phost, 00245 uint8_t *buff, 00246 uint8_t length, 00247 uint8_t pipe_num) 00248 { 00249 USBH_LL_SubmitURB (phost, /* Driver handle */ 00250 pipe_num, /* Pipe index */ 00251 1, /* Direction : IN */ 00252 USBH_EP_INTERRUPT, /* EP type */ 00253 USBH_PID_DATA, /* Type Data */ 00254 buff, /* data buffer */ 00255 length, /* data length */ 00256 0); 00257 00258 return USBH_OK; 00259 } 00260 00261 /** 00262 * @brief USBH_InterruptSendData 00263 * Sends the data on Interrupt OUT Endpoint 00264 * @param phost: Host Handle 00265 * @param buff: Buffer pointer from where the data needs to be copied 00266 * @param length: Length of the data to be sent 00267 * @param pipe_num: Pipe Number 00268 * @retval USBH Status. 00269 */ 00270 USBH_StatusTypeDef USBH_InterruptSendData(USBH_HandleTypeDef *phost, 00271 uint8_t *buff, 00272 uint8_t length, 00273 uint8_t pipe_num) 00274 { 00275 USBH_LL_SubmitURB (phost, /* Driver handle */ 00276 pipe_num, /* Pipe index */ 00277 0, /* Direction : OUT */ 00278 USBH_EP_INTERRUPT, /* EP type */ 00279 USBH_PID_DATA, /* Type Data */ 00280 buff, /* data buffer */ 00281 length, /* data length */ 00282 0); 00283 00284 return USBH_OK; 00285 } 00286 00287 /** 00288 * @brief USBH_IsocReceiveData 00289 * Receives the Device Response to the Isochronous IN token 00290 * @param phost: Host Handle 00291 * @param buff: Buffer pointer in which the response needs to be copied 00292 * @param length: Length of the data to be received 00293 * @param pipe_num: Pipe Number 00294 * @retval USBH Status. 00295 */ 00296 USBH_StatusTypeDef USBH_IsocReceiveData(USBH_HandleTypeDef *phost, 00297 uint8_t *buff, 00298 uint32_t length, 00299 uint8_t pipe_num) 00300 { 00301 USBH_LL_SubmitURB (phost, /* Driver handle */ 00302 pipe_num, /* Pipe index */ 00303 1, /* Direction : IN */ 00304 USBH_EP_ISO, /* EP type */ 00305 USBH_PID_DATA, /* Type Data */ 00306 buff, /* data buffer */ 00307 length, /* data length */ 00308 0); 00309 00310 00311 return USBH_OK; 00312 } 00313 00314 /** 00315 * @brief USBH_IsocSendData 00316 * Sends the data on Isochronous OUT Endpoint 00317 * @param phost: Host Handle 00318 * @param buff: Buffer pointer from where the data needs to be copied 00319 * @param length: Length of the data to be sent 00320 * @param pipe_num: Pipe Number 00321 * @retval USBH Status. 00322 */ 00323 USBH_StatusTypeDef USBH_IsocSendData(USBH_HandleTypeDef *phost, 00324 uint8_t *buff, 00325 uint32_t length, 00326 uint8_t pipe_num) 00327 { 00328 USBH_LL_SubmitURB (phost, /* Driver handle */ 00329 pipe_num, /* Pipe index */ 00330 0, /* Direction : OUT */ 00331 USBH_EP_ISO, /* EP type */ 00332 USBH_PID_DATA, /* Type Data */ 00333 buff, /* data buffer */ 00334 length, /* data length */ 00335 0); 00336 00337 return USBH_OK; 00338 } 00339 /** 00340 * @} 00341 */ 00342 00343 /** 00344 * @} 00345 */ 00346 00347 /** 00348 * @} 00349 */ 00350 00351 /** 00352 * @} 00353 */ 00354 00355 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00356 00357 00358
Generated on Tue Jul 12 2022 14:58:24 by
1.7.2