2 ******************************************************************************
4 * @author MCD Application Team
7 * @brief This file provides the IO requests APIs for control endpoints.
8 ******************************************************************************
11 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
19 ******************************************************************************
22 /* Includes ------------------------------------------------------------------*/
23 #include "usbd_ioreq.h"
24 /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
29 /** @defgroup USBD_IOREQ
30 * @brief control I/O requests module
34 /** @defgroup USBD_IOREQ_Private_TypesDefinitions
42 /** @defgroup USBD_IOREQ_Private_Defines
51 /** @defgroup USBD_IOREQ_Private_Macros
59 /** @defgroup USBD_IOREQ_Private_Variables
68 /** @defgroup USBD_IOREQ_Private_FunctionPrototypes
76 /** @defgroup USBD_IOREQ_Private_Functions
81 * @brief USBD_CtlSendData
82 * send data on the ctl pipe
83 * @param pdev: device instance
84 * @param buff: pointer to data buffer
85 * @param len: length of data to be sent
88 USBD_Status USBD_CtlSendData (USB_OTG_CORE_HANDLE *pdev,
92 USBD_Status ret = USBD_OK;
94 pdev->dev.in_ep[0].total_data_len = len;
95 pdev->dev.in_ep[0].rem_data_len = len;
96 pdev->dev.device_state = USB_OTG_EP0_DATA_IN;
98 DCD_EP_Tx (pdev, 0, pbuf, len);
104 * @brief USBD_CtlContinueSendData
105 * continue sending data on the ctl pipe
106 * @param pdev: device instance
107 * @param buff: pointer to data buffer
108 * @param len: length of data to be sent
111 USBD_Status USBD_CtlContinueSendData (USB_OTG_CORE_HANDLE *pdev,
115 USBD_Status ret = USBD_OK;
117 DCD_EP_Tx (pdev, 0, pbuf, len);
124 * @brief USBD_CtlPrepareRx
125 * receive data on the ctl pipe
126 * @param pdev: USB OTG device instance
127 * @param buff: pointer to data buffer
128 * @param len: length of data to be received
131 USBD_Status USBD_CtlPrepareRx (USB_OTG_CORE_HANDLE *pdev,
135 USBD_Status ret = USBD_OK;
137 pdev->dev.out_ep[0].total_data_len = len;
138 pdev->dev.out_ep[0].rem_data_len = len;
139 pdev->dev.device_state = USB_OTG_EP0_DATA_OUT;
141 DCD_EP_PrepareRx (pdev,
151 * @brief USBD_CtlContinueRx
152 * continue receive data on the ctl pipe
153 * @param pdev: USB OTG device instance
154 * @param buff: pointer to data buffer
155 * @param len: length of data to be received
158 USBD_Status USBD_CtlContinueRx (USB_OTG_CORE_HANDLE *pdev,
162 USBD_Status ret = USBD_OK;
164 DCD_EP_PrepareRx (pdev,
171 * @brief USBD_CtlSendStatus
172 * send zero lzngth packet on the ctl pipe
173 * @param pdev: USB OTG device instance
176 USBD_Status USBD_CtlSendStatus (USB_OTG_CORE_HANDLE *pdev)
178 USBD_Status ret = USBD_OK;
179 pdev->dev.device_state = USB_OTG_EP0_STATUS_IN;
185 USB_OTG_EP0_OutStart(pdev);
191 * @brief USBD_CtlReceiveStatus
192 * receive zero lzngth packet on the ctl pipe
193 * @param pdev: USB OTG device instance
196 USBD_Status USBD_CtlReceiveStatus (USB_OTG_CORE_HANDLE *pdev)
198 USBD_Status ret = USBD_OK;
199 pdev->dev.device_state = USB_OTG_EP0_STATUS_OUT;
200 DCD_EP_PrepareRx ( pdev,
205 USB_OTG_EP0_OutStart(pdev);
212 * @brief USBD_GetRxCount
213 * returns the received data length
214 * @param pdev: USB OTG device instance
215 * epnum: endpoint index
216 * @retval Rx Data blength
218 uint16_t USBD_GetRxCount (USB_OTG_CORE_HANDLE *pdev , uint8_t epnum)
220 return pdev->dev.out_ep[epnum].xfer_count;
237 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/