USB CDC library for MBED on STM32
Embed:
(wiki syntax)
Show/hide line numbers
usbd_ioreq.c
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file usbd_ioreq.c 00004 * @author MCD Application Team 00005 * @version V2.4.2 00006 * @date 11-December-2015 00007 * @brief This file provides the IO requests APIs for control endpoints. 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 00028 /* Includes ------------------------------------------------------------------*/ 00029 #include "usbd_ioreq.h" 00030 00031 /** @addtogroup STM32_USB_DEVICE_LIBRARY 00032 * @{ 00033 */ 00034 00035 00036 /** @defgroup USBD_IOREQ 00037 * @brief control I/O requests module 00038 * @{ 00039 */ 00040 00041 /** @defgroup USBD_IOREQ_Private_TypesDefinitions 00042 * @{ 00043 */ 00044 /** 00045 * @} 00046 */ 00047 00048 00049 /** @defgroup USBD_IOREQ_Private_Defines 00050 * @{ 00051 */ 00052 00053 /** 00054 * @} 00055 */ 00056 00057 00058 /** @defgroup USBD_IOREQ_Private_Macros 00059 * @{ 00060 */ 00061 /** 00062 * @} 00063 */ 00064 00065 00066 /** @defgroup USBD_IOREQ_Private_Variables 00067 * @{ 00068 */ 00069 00070 /** 00071 * @} 00072 */ 00073 00074 00075 /** @defgroup USBD_IOREQ_Private_FunctionPrototypes 00076 * @{ 00077 */ 00078 /** 00079 * @} 00080 */ 00081 00082 00083 /** @defgroup USBD_IOREQ_Private_Functions 00084 * @{ 00085 */ 00086 00087 /** 00088 * @brief USBD_CtlSendData 00089 * send data on the ctl pipe 00090 * @param pdev: device instance 00091 * @param buff: pointer to data buffer 00092 * @param len: length of data to be sent 00093 * @retval status 00094 */ 00095 USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, 00096 uint8_t *pbuf, 00097 uint16_t len) 00098 { 00099 /* Set EP0 State */ 00100 pdev->ep0_state = USBD_EP0_DATA_IN; 00101 pdev->ep_in[0].total_length = len; 00102 pdev->ep_in[0].rem_length = len; 00103 /* Start the transfer */ 00104 USBD_LL_Transmit (pdev, 0x00, pbuf, len); 00105 00106 return USBD_OK; 00107 } 00108 00109 /** 00110 * @brief USBD_CtlContinueSendData 00111 * continue sending data on the ctl pipe 00112 * @param pdev: device instance 00113 * @param buff: pointer to data buffer 00114 * @param len: length of data to be sent 00115 * @retval status 00116 */ 00117 USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev, 00118 uint8_t *pbuf, 00119 uint16_t len) 00120 { 00121 /* Start the next transfer */ 00122 USBD_LL_Transmit (pdev, 0x00, pbuf, len); 00123 00124 return USBD_OK; 00125 } 00126 00127 /** 00128 * @brief USBD_CtlPrepareRx 00129 * receive data on the ctl pipe 00130 * @param pdev: device instance 00131 * @param buff: pointer to data buffer 00132 * @param len: length of data to be received 00133 * @retval status 00134 */ 00135 USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, 00136 uint8_t *pbuf, 00137 uint16_t len) 00138 { 00139 /* Set EP0 State */ 00140 pdev->ep0_state = USBD_EP0_DATA_OUT; 00141 pdev->ep_out[0].total_length = len; 00142 pdev->ep_out[0].rem_length = len; 00143 /* Start the transfer */ 00144 USBD_LL_PrepareReceive (pdev, 00145 0, 00146 pbuf, 00147 len); 00148 00149 return USBD_OK; 00150 } 00151 00152 /** 00153 * @brief USBD_CtlContinueRx 00154 * continue receive data on the ctl pipe 00155 * @param pdev: device instance 00156 * @param buff: pointer to data buffer 00157 * @param len: length of data to be received 00158 * @retval status 00159 */ 00160 USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, 00161 uint8_t *pbuf, 00162 uint16_t len) 00163 { 00164 00165 USBD_LL_PrepareReceive (pdev, 00166 0, 00167 pbuf, 00168 len); 00169 return USBD_OK; 00170 } 00171 /** 00172 * @brief USBD_CtlSendStatus 00173 * send zero lzngth packet on the ctl pipe 00174 * @param pdev: device instance 00175 * @retval status 00176 */ 00177 USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev) 00178 { 00179 00180 /* Set EP0 State */ 00181 pdev->ep0_state = USBD_EP0_STATUS_IN; 00182 00183 /* Start the transfer */ 00184 USBD_LL_Transmit (pdev, 0x00, NULL, 0); 00185 00186 return USBD_OK; 00187 } 00188 00189 /** 00190 * @brief USBD_CtlReceiveStatus 00191 * receive zero lzngth packet on the ctl pipe 00192 * @param pdev: device instance 00193 * @retval status 00194 */ 00195 USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev) 00196 { 00197 /* Set EP0 State */ 00198 pdev->ep0_state = USBD_EP0_STATUS_OUT; 00199 00200 /* Start the transfer */ 00201 USBD_LL_PrepareReceive ( pdev, 00202 0, 00203 NULL, 00204 0); 00205 00206 return USBD_OK; 00207 } 00208 00209 00210 /** 00211 * @brief USBD_GetRxCount 00212 * returns the received data length 00213 * @param pdev: device instance 00214 * @param ep_addr: endpoint address 00215 * @retval Rx Data blength 00216 */ 00217 uint16_t USBD_GetRxCount (USBD_HandleTypeDef *pdev , uint8_t ep_addr) 00218 { 00219 return USBD_LL_GetRxDataSize(pdev, ep_addr); 00220 } 00221 00222 /** 00223 * @} 00224 */ 00225 00226 00227 /** 00228 * @} 00229 */ 00230 00231 00232 /** 00233 * @} 00234 */ 00235 00236 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00237
Generated on Thu Jul 14 2022 15:47:45 by 1.7.2