Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | /** |
2 | ****************************************************************************** |
||
3 | * @file usbd_ioreq.c |
||
4 | * @author MCD Application Team |
||
5 | * @version V2.4.2 |
||
6 | * @date 11-December-2015 |
||
7 | * @brief This file provides the IO requests APIs for control endpoints. |
||
8 | ****************************************************************************** |
||
9 | * @attention |
||
10 | * |
||
11 | * <h2><center>© COPYRIGHT 2015 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 | /* Includes ------------------------------------------------------------------*/ |
||
29 | #include "usbd_ioreq.h" |
||
30 | |||
31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY |
||
32 | * @{ |
||
33 | */ |
||
34 | |||
35 | |||
36 | /** @defgroup USBD_IOREQ |
||
37 | * @brief control I/O requests module |
||
38 | * @{ |
||
39 | */ |
||
40 | |||
41 | /** @defgroup USBD_IOREQ_Private_TypesDefinitions |
||
42 | * @{ |
||
43 | */ |
||
44 | /** |
||
45 | * @} |
||
46 | */ |
||
47 | |||
48 | |||
49 | /** @defgroup USBD_IOREQ_Private_Defines |
||
50 | * @{ |
||
51 | */ |
||
52 | |||
53 | /** |
||
54 | * @} |
||
55 | */ |
||
56 | |||
57 | |||
58 | /** @defgroup USBD_IOREQ_Private_Macros |
||
59 | * @{ |
||
60 | */ |
||
61 | /** |
||
62 | * @} |
||
63 | */ |
||
64 | |||
65 | |||
66 | /** @defgroup USBD_IOREQ_Private_Variables |
||
67 | * @{ |
||
68 | */ |
||
69 | |||
70 | /** |
||
71 | * @} |
||
72 | */ |
||
73 | |||
74 | |||
75 | /** @defgroup USBD_IOREQ_Private_FunctionPrototypes |
||
76 | * @{ |
||
77 | */ |
||
78 | /** |
||
79 | * @} |
||
80 | */ |
||
81 | |||
82 | |||
83 | /** @defgroup USBD_IOREQ_Private_Functions |
||
84 | * @{ |
||
85 | */ |
||
86 | |||
87 | /** |
||
88 | * @brief USBD_CtlSendData |
||
89 | * send data on the ctl pipe |
||
90 | * @param pdev: device instance |
||
91 | * @param buff: pointer to data buffer |
||
92 | * @param len: length of data to be sent |
||
93 | * @retval status |
||
94 | */ |
||
95 | USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, |
||
96 | uint8_t *pbuf, |
||
97 | uint16_t len) |
||
98 | { |
||
99 | /* Set EP0 State */ |
||
100 | pdev->ep0_state = USBD_EP0_DATA_IN; |
||
101 | pdev->ep_in[0].total_length = len; |
||
102 | pdev->ep_in[0].rem_length = len; |
||
103 | /* Start the transfer */ |
||
104 | USBD_LL_Transmit (pdev, 0x00, pbuf, len); |
||
105 | |||
106 | return USBD_OK; |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * @brief USBD_CtlContinueSendData |
||
111 | * continue sending data on the ctl pipe |
||
112 | * @param pdev: device instance |
||
113 | * @param buff: pointer to data buffer |
||
114 | * @param len: length of data to be sent |
||
115 | * @retval status |
||
116 | */ |
||
117 | USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev, |
||
118 | uint8_t *pbuf, |
||
119 | uint16_t len) |
||
120 | { |
||
121 | /* Start the next transfer */ |
||
122 | USBD_LL_Transmit (pdev, 0x00, pbuf, len); |
||
123 | |||
124 | return USBD_OK; |
||
125 | } |
||
126 | |||
127 | /** |
||
128 | * @brief USBD_CtlPrepareRx |
||
129 | * receive data on the ctl pipe |
||
130 | * @param pdev: device instance |
||
131 | * @param buff: pointer to data buffer |
||
132 | * @param len: length of data to be received |
||
133 | * @retval status |
||
134 | */ |
||
135 | USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, |
||
136 | uint8_t *pbuf, |
||
137 | uint16_t len) |
||
138 | { |
||
139 | /* Set EP0 State */ |
||
140 | pdev->ep0_state = USBD_EP0_DATA_OUT; |
||
141 | pdev->ep_out[0].total_length = len; |
||
142 | pdev->ep_out[0].rem_length = len; |
||
143 | /* Start the transfer */ |
||
144 | USBD_LL_PrepareReceive (pdev, |
||
145 | 0, |
||
146 | pbuf, |
||
147 | len); |
||
148 | |||
149 | return USBD_OK; |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * @brief USBD_CtlContinueRx |
||
154 | * continue receive data on the ctl pipe |
||
155 | * @param pdev: device instance |
||
156 | * @param buff: pointer to data buffer |
||
157 | * @param len: length of data to be received |
||
158 | * @retval status |
||
159 | */ |
||
160 | USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, |
||
161 | uint8_t *pbuf, |
||
162 | uint16_t len) |
||
163 | { |
||
164 | |||
165 | USBD_LL_PrepareReceive (pdev, |
||
166 | 0, |
||
167 | pbuf, |
||
168 | len); |
||
169 | return USBD_OK; |
||
170 | } |
||
171 | /** |
||
172 | * @brief USBD_CtlSendStatus |
||
173 | * send zero lzngth packet on the ctl pipe |
||
174 | * @param pdev: device instance |
||
175 | * @retval status |
||
176 | */ |
||
177 | USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev) |
||
178 | { |
||
179 | |||
180 | /* Set EP0 State */ |
||
181 | pdev->ep0_state = USBD_EP0_STATUS_IN; |
||
182 | |||
183 | /* Start the transfer */ |
||
184 | USBD_LL_Transmit (pdev, 0x00, NULL, 0); |
||
185 | |||
186 | return USBD_OK; |
||
187 | } |
||
188 | |||
189 | /** |
||
190 | * @brief USBD_CtlReceiveStatus |
||
191 | * receive zero lzngth packet on the ctl pipe |
||
192 | * @param pdev: device instance |
||
193 | * @retval status |
||
194 | */ |
||
195 | USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev) |
||
196 | { |
||
197 | /* Set EP0 State */ |
||
198 | pdev->ep0_state = USBD_EP0_STATUS_OUT; |
||
199 | |||
200 | /* Start the transfer */ |
||
201 | USBD_LL_PrepareReceive ( pdev, |
||
202 | 0, |
||
203 | NULL, |
||
204 | 0); |
||
205 | |||
206 | return USBD_OK; |
||
207 | } |
||
208 | |||
209 | |||
210 | /** |
||
211 | * @brief USBD_GetRxCount |
||
212 | * returns the received data length |
||
213 | * @param pdev: device instance |
||
214 | * @param ep_addr: endpoint address |
||
215 | * @retval Rx Data blength |
||
216 | */ |
||
217 | uint16_t USBD_GetRxCount (USBD_HandleTypeDef *pdev , uint8_t ep_addr) |
||
218 | { |
||
219 | return USBD_LL_GetRxDataSize(pdev, ep_addr); |
||
220 | } |
||
221 | |||
222 | /** |
||
223 | * @} |
||
224 | */ |
||
225 | |||
226 | |||
227 | /** |
||
228 | * @} |
||
229 | */ |
||
230 | |||
231 | |||
232 | /** |
||
233 | * @} |
||
234 | */ |
||
235 | |||
236 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |