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