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