Rev 56 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 56 | Rev 61 | ||
|---|---|---|---|
| Line 54... | Line 54... | ||
| 54 | /* Private functions ---------------------------------------------------------*/ |
54 | /* Private functions ---------------------------------------------------------*/ |
| 55 | 55 | ||
| 56 | 56 | ||
| 57 | /** |
57 | /** |
| 58 | * @brief Initializes the USB Core |
58 | * @brief Initializes the USB Core |
| 59 | * @param USBx: USB Instance |
59 | * @param USBx USB Instance |
| 60 | * @param cfg : pointer to a USB_CfgTypeDef structure that contains |
60 | * @param cfg pointer to a USB_CfgTypeDef structure that contains |
| 61 | * the configuration information for the specified USBx peripheral. |
61 | * the configuration information for the specified USBx peripheral. |
| 62 | * @retval HAL status |
62 | * @retval HAL status |
| 63 | */ |
63 | */ |
| 64 | HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg) |
64 | HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg) |
| 65 | { |
65 | { |
| Line 76... | Line 76... | ||
| 76 | } |
76 | } |
| 77 | 77 | ||
| 78 | /** |
78 | /** |
| 79 | * @brief USB_EnableGlobalInt |
79 | * @brief USB_EnableGlobalInt |
| 80 | * Enables the controller's Global Int in the AHB Config reg |
80 | * Enables the controller's Global Int in the AHB Config reg |
| 81 | * @param USBx : Selected device |
81 | * @param USBx Selected device |
| 82 | * @retval HAL status |
82 | * @retval HAL status |
| 83 | */ |
83 | */ |
| 84 | HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx) |
84 | HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx) |
| 85 | { |
85 | { |
| 86 | uint32_t winterruptmask; |
86 | uint32_t winterruptmask; |
| Line 101... | Line 101... | ||
| 101 | } |
101 | } |
| 102 | 102 | ||
| 103 | /** |
103 | /** |
| 104 | * @brief USB_DisableGlobalInt |
104 | * @brief USB_DisableGlobalInt |
| 105 | * Disable the controller's Global Int in the AHB Config reg |
105 | * Disable the controller's Global Int in the AHB Config reg |
| 106 | * @param USBx : Selected device |
106 | * @param USBx Selected device |
| 107 | * @retval HAL status |
107 | * @retval HAL status |
| 108 | */ |
108 | */ |
| 109 | HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx) |
109 | HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx) |
| 110 | { |
110 | { |
| 111 | uint32_t winterruptmask; |
111 | uint32_t winterruptmask; |
| Line 121... | Line 121... | ||
| 121 | 121 | ||
| 122 | return HAL_OK; |
122 | return HAL_OK; |
| 123 | } |
123 | } |
| 124 | 124 | ||
| 125 | /** |
125 | /** |
| 126 | * @brief USB_SetCurrentMode : Set functional mode |
126 | * @brief USB_SetCurrentMode Set functional mode |
| 127 | * @param USBx : Selected device |
127 | * @param USBx Selected device |
| 128 | * @param mode : current core mode |
128 | * @param mode current core mode |
| 129 | * This parameter can be one of the these values: |
129 | * This parameter can be one of the these values: |
| 130 | * @arg USB_DEVICE_MODE: Peripheral mode |
130 | * @arg USB_DEVICE_MODE Peripheral mode |
| 131 | * @retval HAL status |
131 | * @retval HAL status |
| 132 | */ |
132 | */ |
| 133 | HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode) |
133 | HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode) |
| 134 | { |
134 | { |
| 135 | /* Prevent unused argument(s) compilation warning */ |
135 | /* Prevent unused argument(s) compilation warning */ |
| Line 142... | Line 142... | ||
| 142 | */ |
142 | */ |
| 143 | return HAL_OK; |
143 | return HAL_OK; |
| 144 | } |
144 | } |
| 145 | 145 | ||
| 146 | /** |
146 | /** |
| 147 | * @brief USB_DevInit : Initializes the USB controller registers |
147 | * @brief USB_DevInit Initializes the USB controller registers |
| 148 | * for device mode |
148 | * for device mode |
| 149 | * @param USBx : Selected device |
149 | * @param USBx Selected device |
| 150 | * @param cfg : pointer to a USB_CfgTypeDef structure that contains |
150 | * @param cfg pointer to a USB_CfgTypeDef structure that contains |
| 151 | * the configuration information for the specified USBx peripheral. |
151 | * the configuration information for the specified USBx peripheral. |
| 152 | * @retval HAL status |
152 | * @retval HAL status |
| 153 | */ |
153 | */ |
| 154 | HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg) |
154 | HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg) |
| 155 | { |
155 | { |
| 156 | /* Prevent unused argument(s) compilation warning */ |
156 | /* Prevent unused argument(s) compilation warning */ |
| 157 | UNUSED(cfg); |
157 | UNUSED(cfg); |
| 158 | 158 | ||
| 159 | /* Init Device */ |
159 | /* Init Device */ |
| 160 | /*CNTR_FRES = 1*/ |
160 | /* CNTR_FRES = 1 */ |
| 161 | USBx->CNTR = (uint16_t)USB_CNTR_FRES; |
161 | USBx->CNTR = (uint16_t)USB_CNTR_FRES; |
| 162 | 162 | ||
| 163 | /*CNTR_FRES = 0*/ |
163 | /* CNTR_FRES = 0 */ |
| 164 | USBx->CNTR = 0U; |
164 | USBx->CNTR = 0U; |
| 165 | 165 | ||
| 166 | /*Clear pending interrupts*/ |
166 | /* Clear pending interrupts */ |
| 167 | USBx->ISTR = 0U; |
167 | USBx->ISTR = 0U; |
| 168 | 168 | ||
| 169 | /*Set Btable Address*/ |
169 | /*Set Btable Address*/ |
| 170 | USBx->BTABLE = BTABLE_ADDRESS; |
170 | USBx->BTABLE = BTABLE_ADDRESS; |
| 171 | 171 | ||
| 172 | return HAL_OK; |
172 | return HAL_OK; |
| 173 | } |
173 | } |
| 174 | 174 | ||
| 175 | /** |
- | |
| 176 | * @brief USB_SetDevSpeed :Initializes the device speed |
- | |
| 177 | * depending on the PHY type and the enumeration speed of the device. |
- | |
| 178 | * @param USBx Selected device |
- | |
| 179 | * @param speed device speed |
- | |
| 180 | * @retval Hal status |
- | |
| 181 | */ |
- | |
| 182 | HAL_StatusTypeDef USB_SetDevSpeed(USB_TypeDef *USBx, uint8_t speed) |
- | |
| 183 | { |
- | |
| 184 | /* Prevent unused argument(s) compilation warning */ |
- | |
| 185 | UNUSED(USBx); |
- | |
| 186 | UNUSED(speed); |
- | |
| 187 | - | ||
| 188 | /* NOTE : - This function is not required by USB Device FS peripheral, it is used |
- | |
| 189 | only by USB OTG FS peripheral. |
- | |
| 190 | - This function is added to ensure compatibility across platforms. |
- | |
| 191 | */ |
- | |
| 192 | - | ||
| 193 | return HAL_OK; |
- | |
| 194 | } |
- | |
| 195 | - | ||
| 196 | /** |
- | |
| 197 | * @brief USB_FlushTxFifo : Flush a Tx FIFO |
- | |
| 198 | * @param USBx : Selected device |
- | |
| 199 | * @param num : FIFO number |
- | |
| 200 | * This parameter can be a value from 1 to 15 |
- | |
| 201 | 15 means Flush all Tx FIFOs |
- | |
| 202 | * @retval HAL status |
- | |
| 203 | */ |
- | |
| 204 | HAL_StatusTypeDef USB_FlushTxFifo(USB_TypeDef *USBx, uint32_t num) |
- | |
| 205 | { |
- | |
| 206 | /* Prevent unused argument(s) compilation warning */ |
- | |
| 207 | UNUSED(USBx); |
- | |
| 208 | UNUSED(num); |
- | |
| 209 | - | ||
| 210 | /* NOTE : - This function is not required by USB Device FS peripheral, it is used |
- | |
| 211 | only by USB OTG FS peripheral. |
- | |
| 212 | - This function is added to ensure compatibility across platforms. |
- | |
| 213 | */ |
- | |
| 214 | - | ||
| 215 | return HAL_OK; |
- | |
| 216 | } |
- | |
| 217 | - | ||
| 218 | /** |
- | |
| 219 | * @brief USB_FlushRxFifo : Flush Rx FIFO |
- | |
| 220 | * @param USBx : Selected device |
175 | #if defined (HAL_PCD_MODULE_ENABLED) |
| 221 | * @retval HAL status |
- | |
| 222 | */ |
- | |
| 223 | HAL_StatusTypeDef USB_FlushRxFifo(USB_TypeDef *USBx) |
- | |
| 224 | { |
- | |
| 225 | /* Prevent unused argument(s) compilation warning */ |
- | |
| 226 | UNUSED(USBx); |
- | |
| 227 | - | ||
| 228 | /* NOTE : - This function is not required by USB Device FS peripheral, it is used |
- | |
| 229 | only by USB OTG FS peripheral. |
- | |
| 230 | - This function is added to ensure compatibility across platforms. |
- | |
| 231 | */ |
- | |
| 232 | - | ||
| 233 | return HAL_OK; |
- | |
| 234 | } |
- | |
| 235 | - | ||
| 236 | /** |
176 | /** |
| 237 | * @brief Activate and configure an endpoint |
177 | * @brief Activate and configure an endpoint |
| 238 | * @param USBx : Selected device |
178 | * @param USBx Selected device |
| 239 | * @param ep: pointer to endpoint structure |
179 | * @param ep pointer to endpoint structure |
| 240 | * @retval HAL status |
180 | * @retval HAL status |
| 241 | */ |
181 | */ |
| 242 | HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep) |
182 | HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep) |
| 243 | { |
183 | { |
| 244 | HAL_StatusTypeDef ret = HAL_OK; |
184 | HAL_StatusTypeDef ret = HAL_OK; |
| Line 295... | Line 235... | ||
| 295 | } |
235 | } |
| 296 | else |
236 | else |
| 297 | { |
237 | { |
| 298 | /*Set the endpoint Receive buffer address */ |
238 | /*Set the endpoint Receive buffer address */ |
| 299 | PCD_SET_EP_RX_ADDRESS(USBx, ep->num, ep->pmaadress); |
239 | PCD_SET_EP_RX_ADDRESS(USBx, ep->num, ep->pmaadress); |
| - | 240 | ||
| 300 | /*Set the endpoint Receive buffer counter*/ |
241 | /*Set the endpoint Receive buffer counter*/ |
| 301 | PCD_SET_EP_RX_CNT(USBx, ep->num, ep->maxpacket); |
242 | PCD_SET_EP_RX_CNT(USBx, ep->num, ep->maxpacket); |
| 302 | PCD_CLEAR_RX_DTOG(USBx, ep->num); |
243 | PCD_CLEAR_RX_DTOG(USBx, ep->num); |
| - | 244 | ||
| 303 | /* Configure VALID status for the Endpoint*/ |
245 | /* Configure VALID status for the Endpoint*/ |
| 304 | PCD_SET_EP_RX_STATUS(USBx, ep->num, USB_EP_RX_VALID); |
246 | PCD_SET_EP_RX_STATUS(USBx, ep->num, USB_EP_RX_VALID); |
| 305 | } |
247 | } |
| 306 | } |
248 | } |
| 307 | /*Double Buffer*/ |
249 | /*Double Buffer*/ |
| 308 | else |
250 | else |
| 309 | { |
251 | { |
| 310 | /* Set the endpoint as double buffered */ |
252 | /* Set the endpoint as double buffered */ |
| 311 | PCD_SET_EP_DBUF(USBx, ep->num); |
253 | PCD_SET_EP_DBUF(USBx, ep->num); |
| - | 254 | ||
| 312 | /* Set buffer address for double buffered mode */ |
255 | /* Set buffer address for double buffered mode */ |
| 313 | PCD_SET_EP_DBUF_ADDR(USBx, ep->num, ep->pmaaddr0, ep->pmaaddr1); |
256 | PCD_SET_EP_DBUF_ADDR(USBx, ep->num, ep->pmaaddr0, ep->pmaaddr1); |
| 314 | 257 | ||
| 315 | if (ep->is_in == 0U) |
258 | if (ep->is_in == 0U) |
| 316 | { |
259 | { |
| Line 325... | Line 268... | ||
| 325 | { |
268 | { |
| 326 | /* Clear the data toggle bits for the endpoint IN/OUT */ |
269 | /* Clear the data toggle bits for the endpoint IN/OUT */ |
| 327 | PCD_CLEAR_RX_DTOG(USBx, ep->num); |
270 | PCD_CLEAR_RX_DTOG(USBx, ep->num); |
| 328 | PCD_CLEAR_TX_DTOG(USBx, ep->num); |
271 | PCD_CLEAR_TX_DTOG(USBx, ep->num); |
| 329 | 272 | ||
| 330 | - | ||
| 331 | if (ep->type != EP_TYPE_ISOC) |
273 | if (ep->type != EP_TYPE_ISOC) |
| 332 | { |
274 | { |
| 333 | /* Configure NAK status for the Endpoint */ |
275 | /* Configure NAK status for the Endpoint */ |
| 334 | PCD_SET_EP_TX_STATUS(USBx, ep->num, USB_EP_TX_NAK); |
276 | PCD_SET_EP_TX_STATUS(USBx, ep->num, USB_EP_TX_NAK); |
| 335 | } |
277 | } |
| Line 346... | Line 288... | ||
| 346 | return ret; |
288 | return ret; |
| 347 | } |
289 | } |
| 348 | 290 | ||
| 349 | /** |
291 | /** |
| 350 | * @brief De-activate and de-initialize an endpoint |
292 | * @brief De-activate and de-initialize an endpoint |
| 351 | * @param USBx : Selected device |
293 | * @param USBx Selected device |
| 352 | * @param ep: pointer to endpoint structure |
294 | * @param ep pointer to endpoint structure |
| 353 | * @retval HAL status |
295 | * @retval HAL status |
| 354 | */ |
296 | */ |
| 355 | HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep) |
297 | HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep) |
| 356 | { |
298 | { |
| 357 | if (ep->doublebuffer == 0U) |
299 | if (ep->doublebuffer == 0U) |
| 358 | { |
300 | { |
| 359 | if (ep->is_in != 0U) |
301 | if (ep->is_in != 0U) |
| 360 | { |
302 | { |
| 361 | PCD_CLEAR_TX_DTOG(USBx, ep->num); |
303 | PCD_CLEAR_TX_DTOG(USBx, ep->num); |
| - | 304 | ||
| 362 | /* Configure DISABLE status for the Endpoint*/ |
305 | /* Configure DISABLE status for the Endpoint*/ |
| 363 | PCD_SET_EP_TX_STATUS(USBx, ep->num, USB_EP_TX_DIS); |
306 | PCD_SET_EP_TX_STATUS(USBx, ep->num, USB_EP_TX_DIS); |
| 364 | } |
307 | } |
| 365 | else |
308 | else |
| 366 | { |
309 | { |
| 367 | PCD_CLEAR_RX_DTOG(USBx, ep->num); |
310 | PCD_CLEAR_RX_DTOG(USBx, ep->num); |
| - | 311 | ||
| 368 | /* Configure DISABLE status for the Endpoint*/ |
312 | /* Configure DISABLE status for the Endpoint*/ |
| 369 | PCD_SET_EP_RX_STATUS(USBx, ep->num, USB_EP_RX_DIS); |
313 | PCD_SET_EP_RX_STATUS(USBx, ep->num, USB_EP_RX_DIS); |
| 370 | } |
314 | } |
| 371 | } |
315 | } |
| 372 | /*Double Buffer*/ |
316 | /*Double Buffer*/ |
| Line 388... | Line 332... | ||
| 388 | { |
332 | { |
| 389 | /* Clear the data toggle bits for the endpoint IN/OUT*/ |
333 | /* Clear the data toggle bits for the endpoint IN/OUT*/ |
| 390 | PCD_CLEAR_RX_DTOG(USBx, ep->num); |
334 | PCD_CLEAR_RX_DTOG(USBx, ep->num); |
| 391 | PCD_CLEAR_TX_DTOG(USBx, ep->num); |
335 | PCD_CLEAR_TX_DTOG(USBx, ep->num); |
| 392 | PCD_RX_DTOG(USBx, ep->num); |
336 | PCD_RX_DTOG(USBx, ep->num); |
| - | 337 | ||
| 393 | /* Configure DISABLE status for the Endpoint*/ |
338 | /* Configure DISABLE status for the Endpoint*/ |
| 394 | PCD_SET_EP_TX_STATUS(USBx, ep->num, USB_EP_TX_DIS); |
339 | PCD_SET_EP_TX_STATUS(USBx, ep->num, USB_EP_TX_DIS); |
| 395 | PCD_SET_EP_RX_STATUS(USBx, ep->num, USB_EP_RX_DIS); |
340 | PCD_SET_EP_RX_STATUS(USBx, ep->num, USB_EP_RX_DIS); |
| 396 | } |
341 | } |
| 397 | } |
342 | } |
| 398 | 343 | ||
| 399 | return HAL_OK; |
344 | return HAL_OK; |
| 400 | } |
345 | } |
| 401 | 346 | ||
| 402 | /** |
347 | /** |
| 403 | * @brief USB_EPStartXfer : setup and starts a transfer over an EP |
348 | * @brief USB_EPStartXfer setup and starts a transfer over an EP |
| 404 | * @param USBx : Selected device |
349 | * @param USBx Selected device |
| 405 | * @param ep: pointer to endpoint structure |
350 | * @param ep pointer to endpoint structure |
| 406 | * @retval HAL status |
351 | * @retval HAL status |
| 407 | */ |
352 | */ |
| 408 | HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep) |
353 | HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep) |
| 409 | { |
354 | { |
| 410 | uint16_t pmabuffer; |
- | |
| 411 | uint32_t len; |
355 | uint32_t len; |
| - | 356 | uint16_t pmabuffer; |
|
| 412 | uint16_t wEPVal; |
357 | uint16_t wEPVal; |
| 413 | 358 | ||
| 414 | /* IN endpoint */ |
359 | /* IN endpoint */ |
| 415 | if (ep->is_in == 1U) |
360 | if (ep->is_in == 1U) |
| 416 | { |
361 | { |
| Line 430... | Line 375... | ||
| 430 | USB_WritePMA(USBx, ep->xfer_buff, ep->pmaadress, (uint16_t)len); |
375 | USB_WritePMA(USBx, ep->xfer_buff, ep->pmaadress, (uint16_t)len); |
| 431 | PCD_SET_EP_TX_CNT(USBx, ep->num, len); |
376 | PCD_SET_EP_TX_CNT(USBx, ep->num, len); |
| 432 | } |
377 | } |
| 433 | else |
378 | else |
| 434 | { |
379 | { |
| 435 | /*double buffer bulk management */ |
380 | /* double buffer bulk management */ |
| 436 | if (ep->type == EP_TYPE_BULK) |
381 | if (ep->type == EP_TYPE_BULK) |
| 437 | { |
382 | { |
| 438 | if (ep->xfer_len_db > ep->maxpacket) |
383 | if (ep->xfer_len_db > ep->maxpacket) |
| 439 | { |
384 | { |
| 440 | /*enable double buffer */ |
385 | /* enable double buffer */ |
| 441 | PCD_SET_EP_DBUF(USBx, ep->num); |
386 | PCD_SET_EP_DBUF(USBx, ep->num); |
| 442 | len = ep->maxpacket; |
- | |
| - | 387 | ||
| 443 | /*each Time to write in PMA xfer_len_db will */ |
388 | /* each Time to write in PMA xfer_len_db will */ |
| 444 | ep->xfer_len_db -= len; |
389 | ep->xfer_len_db -= len; |
| 445 | 390 | ||
| 446 | /* Fill the two first buffer in the Buffer0 & Buffer1*/ |
391 | /* Fill the two first buffer in the Buffer0 & Buffer1 */ |
| 447 | if ((PCD_GET_ENDPOINT(USBx, ep->num) & USB_EP_DTOG_TX) != 0U) |
392 | if ((PCD_GET_ENDPOINT(USBx, ep->num) & USB_EP_DTOG_TX) != 0U) |
| 448 | { |
393 | { |
| 449 | /* Set the Double buffer counter for pmabuffer1 */ |
394 | /* Set the Double buffer counter for pmabuffer1 */ |
| 450 | PCD_SET_EP_DBUF1_CNT(USBx, ep->num, ep->is_in, len); |
395 | PCD_SET_EP_DBUF1_CNT(USBx, ep->num, ep->is_in, len); |
| 451 | pmabuffer = ep->pmaaddr1; |
396 | pmabuffer = ep->pmaaddr1; |
| 452 | 397 | ||
| 453 | /*Write the user buffer to USB PMA */ |
398 | /* Write the user buffer to USB PMA */ |
| 454 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
399 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
| 455 | ep->xfer_buff += len; |
400 | ep->xfer_buff += len; |
| 456 | 401 | ||
| 457 | if (ep->xfer_len_db > ep->maxpacket) |
402 | if (ep->xfer_len_db > ep->maxpacket) |
| 458 | { |
403 | { |
| 459 | len = ep->maxpacket; |
- | |
| 460 | ep->xfer_len_db -= len; |
404 | ep->xfer_len_db -= len; |
| 461 | } |
405 | } |
| 462 | else |
406 | else |
| 463 | { |
407 | { |
| 464 | len = ep->xfer_len_db; |
408 | len = ep->xfer_len_db; |
| 465 | ep->xfer_len_db = 0; |
409 | ep->xfer_len_db = 0U; |
| 466 | } |
410 | } |
| 467 | 411 | ||
| 468 | /* Set the Double buffer counter for pmabuffer0 */ |
412 | /* Set the Double buffer counter for pmabuffer0 */ |
| 469 | PCD_SET_EP_DBUF0_CNT(USBx, ep->num, ep->is_in, len); |
413 | PCD_SET_EP_DBUF0_CNT(USBx, ep->num, ep->is_in, len); |
| 470 | pmabuffer = ep->pmaaddr0; |
414 | pmabuffer = ep->pmaaddr0; |
| - | 415 | ||
| 471 | /*Write the user buffer to USB PMA */ |
416 | /* Write the user buffer to USB PMA */ |
| 472 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
417 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
| 473 | } |
418 | } |
| 474 | else |
419 | else |
| 475 | { |
420 | { |
| 476 | /* Set the Double buffer counter for pmabuffer0 */ |
421 | /* Set the Double buffer counter for pmabuffer0 */ |
| 477 | PCD_SET_EP_DBUF0_CNT(USBx, ep->num, ep->is_in, len); |
422 | PCD_SET_EP_DBUF0_CNT(USBx, ep->num, ep->is_in, len); |
| 478 | pmabuffer = ep->pmaaddr0; |
423 | pmabuffer = ep->pmaaddr0; |
| - | 424 | ||
| 479 | /*Write the user buffer to USB PMA */ |
425 | /* Write the user buffer to USB PMA */ |
| 480 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
426 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
| 481 | ep->xfer_buff += len; |
427 | ep->xfer_buff += len; |
| 482 | 428 | ||
| 483 | if (ep->xfer_len_db > ep->maxpacket) |
429 | if (ep->xfer_len_db > ep->maxpacket) |
| 484 | { |
430 | { |
| 485 | len = ep->maxpacket; |
- | |
| 486 | ep->xfer_len_db -= len; |
431 | ep->xfer_len_db -= len; |
| 487 | } |
432 | } |
| 488 | else |
433 | else |
| 489 | { |
434 | { |
| 490 | len = ep->xfer_len_db; |
435 | len = ep->xfer_len_db; |
| 491 | ep->xfer_len_db = 0; |
436 | ep->xfer_len_db = 0U; |
| 492 | } |
437 | } |
| 493 | 438 | ||
| 494 | /* Set the Double buffer counter for pmabuffer1 */ |
439 | /* Set the Double buffer counter for pmabuffer1 */ |
| 495 | PCD_SET_EP_DBUF1_CNT(USBx, ep->num, ep->is_in, len); |
440 | PCD_SET_EP_DBUF1_CNT(USBx, ep->num, ep->is_in, len); |
| 496 | pmabuffer = ep->pmaaddr1; |
441 | pmabuffer = ep->pmaaddr1; |
| - | 442 | ||
| 497 | /*Write the user buffer to USB PMA */ |
443 | /* Write the user buffer to USB PMA */ |
| 498 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
444 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
| 499 | } |
445 | } |
| 500 | } |
446 | } |
| 501 | /*auto Switch to single buffer mode when transfer <Mps no need to manage in double buffer*/ |
447 | /* auto Switch to single buffer mode when transfer <Mps no need to manage in double buffer */ |
| 502 | else |
448 | else |
| 503 | { |
449 | { |
| 504 | len = ep->xfer_len_db; |
450 | len = ep->xfer_len_db; |
| - | 451 | ||
| 505 | /*disable double buffer mode */ |
452 | /* disable double buffer mode */ |
| 506 | PCD_CLEAR_EP_DBUF(USBx, ep->num); |
453 | PCD_CLEAR_EP_DBUF(USBx, ep->num); |
| - | 454 | ||
| 507 | /*Set Tx count with nbre of byte to be transmitted */ |
455 | /* Set Tx count with nbre of byte to be transmitted */ |
| 508 | PCD_SET_EP_TX_CNT(USBx, ep->num, len); |
456 | PCD_SET_EP_TX_CNT(USBx, ep->num, len); |
| 509 | pmabuffer = ep->pmaaddr0; |
457 | pmabuffer = ep->pmaaddr0; |
| - | 458 | ||
| 510 | /*Write the user buffer to USB PMA */ |
459 | /* Write the user buffer to USB PMA */ |
| 511 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
460 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
| 512 | } |
461 | } |
| 513 | }/*end if bulk double buffer */ |
462 | }/* end if bulk double buffer */ |
| 514 | 463 | ||
| 515 | /*mange isochronous double buffer IN mode */ |
464 | /* manage isochronous double buffer IN mode */ |
| 516 | else |
465 | else |
| 517 | { |
466 | { |
| - | 467 | /* enable double buffer */ |
|
| - | 468 | PCD_SET_EP_DBUF(USBx, ep->num); |
|
| - | 469 | ||
| - | 470 | /* each Time to write in PMA xfer_len_db will */ |
|
| - | 471 | ep->xfer_len_db -= len; |
|
| - | 472 | ||
| 518 | /* Write the data to the USB endpoint */ |
473 | /* Fill the data buffer */ |
| 519 | if ((PCD_GET_ENDPOINT(USBx, ep->num) & USB_EP_DTOG_TX) != 0U) |
474 | if ((PCD_GET_ENDPOINT(USBx, ep->num) & USB_EP_DTOG_TX) != 0U) |
| 520 | { |
475 | { |
| 521 | /* Set the Double buffer counter for pmabuffer1 */ |
476 | /* Set the Double buffer counter for pmabuffer1 */ |
| 522 | PCD_SET_EP_DBUF1_CNT(USBx, ep->num, ep->is_in, len); |
477 | PCD_SET_EP_DBUF1_CNT(USBx, ep->num, ep->is_in, len); |
| 523 | pmabuffer = ep->pmaaddr1; |
478 | pmabuffer = ep->pmaaddr1; |
| - | 479 | ||
| - | 480 | /* Write the user buffer to USB PMA */ |
|
| - | 481 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
|
| - | 482 | ep->xfer_buff += len; |
|
| - | 483 | ||
| - | 484 | if (ep->xfer_len_db > ep->maxpacket) |
|
| - | 485 | { |
|
| - | 486 | ep->xfer_len_db -= len; |
|
| - | 487 | } |
|
| - | 488 | else |
|
| - | 489 | { |
|
| - | 490 | len = ep->xfer_len_db; |
|
| - | 491 | ep->xfer_len_db = 0U; |
|
| - | 492 | } |
|
| - | 493 | ||
| - | 494 | if (len > 0U) |
|
| - | 495 | { |
|
| - | 496 | /* Set the Double buffer counter for pmabuffer0 */ |
|
| - | 497 | PCD_SET_EP_DBUF0_CNT(USBx, ep->num, ep->is_in, len); |
|
| - | 498 | pmabuffer = ep->pmaaddr0; |
|
| - | 499 | ||
| - | 500 | /* Write the user buffer to USB PMA */ |
|
| - | 501 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
|
| - | 502 | } |
|
| 524 | } |
503 | } |
| 525 | else |
504 | else |
| 526 | { |
505 | { |
| 527 | /* Set the Double buffer counter for pmabuffer0 */ |
506 | /* Set the Double buffer counter for pmabuffer0 */ |
| 528 | PCD_SET_EP_DBUF0_CNT(USBx, ep->num, ep->is_in, len); |
507 | PCD_SET_EP_DBUF0_CNT(USBx, ep->num, ep->is_in, len); |
| 529 | pmabuffer = ep->pmaaddr0; |
508 | pmabuffer = ep->pmaaddr0; |
| - | 509 | ||
| - | 510 | /* Write the user buffer to USB PMA */ |
|
| - | 511 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
|
| - | 512 | ep->xfer_buff += len; |
|
| - | 513 | ||
| - | 514 | if (ep->xfer_len_db > ep->maxpacket) |
|
| - | 515 | { |
|
| - | 516 | ep->xfer_len_db -= len; |
|
| - | 517 | } |
|
| - | 518 | else |
|
| - | 519 | { |
|
| - | 520 | len = ep->xfer_len_db; |
|
| - | 521 | ep->xfer_len_db = 0U; |
|
| - | 522 | } |
|
| - | 523 | ||
| - | 524 | if (len > 0U) |
|
| - | 525 | { |
|
| - | 526 | /* Set the Double buffer counter for pmabuffer1 */ |
|
| - | 527 | PCD_SET_EP_DBUF1_CNT(USBx, ep->num, ep->is_in, len); |
|
| - | 528 | pmabuffer = ep->pmaaddr1; |
|
| - | 529 | ||
| - | 530 | /* Write the user buffer to USB PMA */ |
|
| - | 531 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
|
| - | 532 | } |
|
| 530 | } |
533 | } |
| 531 | USB_WritePMA(USBx, ep->xfer_buff, pmabuffer, (uint16_t)len); |
- | |
| 532 | PCD_FreeUserBuffer(USBx, ep->num, ep->is_in); |
- | |
| 533 | } |
534 | } |
| 534 | } |
535 | } |
| 535 | 536 | ||
| 536 | PCD_SET_EP_TX_STATUS(USBx, ep->num, USB_EP_TX_VALID); |
537 | PCD_SET_EP_TX_STATUS(USBx, ep->num, USB_EP_TX_VALID); |
| 537 | } |
538 | } |
| 538 | else /* OUT endpoint */ |
539 | else /* OUT endpoint */ |
| 539 | { |
540 | { |
| 540 | if (ep->doublebuffer == 0U) |
541 | if (ep->doublebuffer == 0U) |
| 541 | { |
542 | { |
| 542 | /* Multi packet transfer*/ |
543 | /* Multi packet transfer */ |
| 543 | if (ep->xfer_len > ep->maxpacket) |
544 | if (ep->xfer_len > ep->maxpacket) |
| 544 | { |
545 | { |
| 545 | len = ep->maxpacket; |
546 | len = ep->maxpacket; |
| 546 | ep->xfer_len -= len; |
547 | ep->xfer_len -= len; |
| 547 | } |
548 | } |
| Line 549... | Line 550... | ||
| 549 | { |
550 | { |
| 550 | len = ep->xfer_len; |
551 | len = ep->xfer_len; |
| 551 | ep->xfer_len = 0U; |
552 | ep->xfer_len = 0U; |
| 552 | } |
553 | } |
| 553 | /* configure and validate Rx endpoint */ |
554 | /* configure and validate Rx endpoint */ |
| 554 | /*Set RX buffer count*/ |
- | |
| 555 | PCD_SET_EP_RX_CNT(USBx, ep->num, len); |
555 | PCD_SET_EP_RX_CNT(USBx, ep->num, len); |
| 556 | } |
556 | } |
| 557 | else |
557 | else |
| 558 | { |
558 | { |
| 559 | /*First Transfer Coming From HAL_PCD_EP_Receive & From ISR*/ |
559 | /* First Transfer Coming From HAL_PCD_EP_Receive & From ISR */ |
| 560 | /*Set the Double buffer counter*/ |
560 | /* Set the Double buffer counter */ |
| 561 | if (ep->type == EP_TYPE_BULK) |
561 | if (ep->type == EP_TYPE_BULK) |
| 562 | { |
562 | { |
| 563 | PCD_SET_EP_DBUF_CNT(USBx, ep->num, ep->is_in, ep->maxpacket); |
563 | PCD_SET_EP_DBUF_CNT(USBx, ep->num, ep->is_in, ep->maxpacket); |
| - | 564 | ||
| 564 | /*Coming from ISR*/ |
565 | /* Coming from ISR */ |
| 565 | if (ep->xfer_count != 0U) |
566 | if (ep->xfer_count != 0U) |
| 566 | { |
567 | { |
| 567 | /* update last value to check if there is blocking state*/ |
568 | /* update last value to check if there is blocking state */ |
| 568 | wEPVal = PCD_GET_ENDPOINT(USBx, ep->num); |
569 | wEPVal = PCD_GET_ENDPOINT(USBx, ep->num); |
| - | 570 | ||
| 569 | /*Blocking State */ |
571 | /*Blocking State */ |
| 570 | if ((((wEPVal & USB_EP_DTOG_RX) != 0U) && ((wEPVal & USB_EP_DTOG_TX) != 0U)) || |
572 | if ((((wEPVal & USB_EP_DTOG_RX) != 0U) && ((wEPVal & USB_EP_DTOG_TX) != 0U)) || |
| 571 | (((wEPVal & USB_EP_DTOG_RX) == 0U) && ((wEPVal & USB_EP_DTOG_TX) == 0U))) |
573 | (((wEPVal & USB_EP_DTOG_RX) == 0U) && ((wEPVal & USB_EP_DTOG_TX) == 0U))) |
| 572 | { |
574 | { |
| 573 | PCD_FreeUserBuffer(USBx, ep->num, 0U); |
575 | PCD_FreeUserBuffer(USBx, ep->num, 0U); |
| 574 | } |
576 | } |
| 575 | } |
577 | } |
| 576 | } |
578 | } |
| 577 | /*iso out double */ |
579 | /* iso out double */ |
| 578 | else if (ep->type == EP_TYPE_ISOC) |
580 | else if (ep->type == EP_TYPE_ISOC) |
| 579 | { |
581 | { |
| 580 | /* Multi packet transfer*/ |
582 | /* Multi packet transfer */ |
| 581 | if (ep->xfer_len > ep->maxpacket) |
583 | if (ep->xfer_len > ep->maxpacket) |
| 582 | { |
584 | { |
| 583 | len = ep->maxpacket; |
585 | len = ep->maxpacket; |
| 584 | ep->xfer_len -= len; |
586 | ep->xfer_len -= len; |
| 585 | } |
587 | } |
| Line 600... | Line 602... | ||
| 600 | } |
602 | } |
| 601 | 603 | ||
| 602 | return HAL_OK; |
604 | return HAL_OK; |
| 603 | } |
605 | } |
| 604 | 606 | ||
| 605 | /** |
- | |
| 606 | * @brief USB_WritePacket : Writes a packet into the Tx FIFO associated |
- | |
| 607 | * with the EP/channel |
- | |
| 608 | * @param USBx : Selected device |
- | |
| 609 | * @param src : pointer to source buffer |
- | |
| 610 | * @param ch_ep_num : endpoint or host channel number |
- | |
| 611 | * @param len : Number of bytes to write |
- | |
| 612 | * @retval HAL status |
- | |
| 613 | */ |
- | |
| 614 | HAL_StatusTypeDef USB_WritePacket(USB_TypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len) |
- | |
| 615 | { |
- | |
| 616 | /* Prevent unused argument(s) compilation warning */ |
- | |
| 617 | UNUSED(USBx); |
- | |
| 618 | UNUSED(src); |
- | |
| 619 | UNUSED(ch_ep_num); |
- | |
| 620 | UNUSED(len); |
- | |
| 621 | /* NOTE : - This function is not required by USB Device FS peripheral, it is used |
- | |
| 622 | only by USB OTG FS peripheral. |
- | |
| 623 | - This function is added to ensure compatibility across platforms. |
- | |
| 624 | */ |
- | |
| 625 | return HAL_OK; |
- | |
| 626 | } |
- | |
| 627 | 607 | ||
| 628 | /** |
608 | /** |
| 629 | * @brief USB_ReadPacket : read a packet from the Tx FIFO associated |
- | |
| 630 | * with the EP/channel |
- | |
| 631 | * @param USBx : Selected device |
- | |
| 632 | * @param dest : destination pointer |
- | |
| 633 | * @param len : Number of bytes to read |
- | |
| 634 | * @retval pointer to destination buffer |
- | |
| 635 | */ |
- | |
| 636 | void *USB_ReadPacket(USB_TypeDef *USBx, uint8_t *dest, uint16_t len) |
- | |
| 637 | { |
- | |
| 638 | /* Prevent unused argument(s) compilation warning */ |
- | |
| 639 | UNUSED(USBx); |
- | |
| 640 | UNUSED(dest); |
- | |
| 641 | UNUSED(len); |
- | |
| 642 | /* NOTE : - This function is not required by USB Device FS peripheral, it is used |
- | |
| 643 | only by USB OTG FS peripheral. |
- | |
| 644 | - This function is added to ensure compatibility across platforms. |
- | |
| 645 | */ |
- | |
| 646 | return ((void *)NULL); |
- | |
| 647 | } |
- | |
| 648 | - | ||
| 649 | /** |
- | |
| 650 | * @brief USB_EPSetStall : set a stall condition over an EP |
609 | * @brief USB_EPSetStall set a stall condition over an EP |
| 651 | * @param USBx : Selected device |
610 | * @param USBx Selected device |
| 652 | * @param ep: pointer to endpoint structure |
611 | * @param ep pointer to endpoint structure |
| 653 | * @retval HAL status |
612 | * @retval HAL status |
| 654 | */ |
613 | */ |
| 655 | HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx, USB_EPTypeDef *ep) |
614 | HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx, USB_EPTypeDef *ep) |
| 656 | { |
615 | { |
| 657 | if (ep->is_in != 0U) |
616 | if (ep->is_in != 0U) |
| Line 665... | Line 624... | ||
| 665 | 624 | ||
| 666 | return HAL_OK; |
625 | return HAL_OK; |
| 667 | } |
626 | } |
| 668 | 627 | ||
| 669 | /** |
628 | /** |
| 670 | * @brief USB_EPClearStall : Clear a stall condition over an EP |
629 | * @brief USB_EPClearStall Clear a stall condition over an EP |
| 671 | * @param USBx : Selected device |
630 | * @param USBx Selected device |
| 672 | * @param ep: pointer to endpoint structure |
631 | * @param ep pointer to endpoint structure |
| 673 | * @retval HAL status |
632 | * @retval HAL status |
| 674 | */ |
633 | */ |
| 675 | HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx, USB_EPTypeDef *ep) |
634 | HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx, USB_EPTypeDef *ep) |
| 676 | { |
635 | { |
| 677 | if (ep->doublebuffer == 0U) |
636 | if (ep->doublebuffer == 0U) |
| Line 688... | Line 647... | ||
| 688 | } |
647 | } |
| 689 | else |
648 | else |
| 690 | { |
649 | { |
| 691 | PCD_CLEAR_RX_DTOG(USBx, ep->num); |
650 | PCD_CLEAR_RX_DTOG(USBx, ep->num); |
| 692 | 651 | ||
| 693 | /* Configure VALID status for the Endpoint*/ |
652 | /* Configure VALID status for the Endpoint */ |
| 694 | PCD_SET_EP_RX_STATUS(USBx, ep->num, USB_EP_RX_VALID); |
653 | PCD_SET_EP_RX_STATUS(USBx, ep->num, USB_EP_RX_VALID); |
| 695 | } |
654 | } |
| 696 | } |
655 | } |
| 697 | 656 | ||
| 698 | return HAL_OK; |
657 | return HAL_OK; |
| 699 | } |
658 | } |
| - | 659 | #endif |
|
| 700 | 660 | ||
| 701 | /** |
661 | /** |
| 702 | * @brief USB_StopDevice : Stop the usb device mode |
662 | * @brief USB_StopDevice Stop the usb device mode |
| 703 | * @param USBx : Selected device |
663 | * @param USBx Selected device |
| 704 | * @retval HAL status |
664 | * @retval HAL status |
| 705 | */ |
665 | */ |
| 706 | HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx) |
666 | HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx) |
| 707 | { |
667 | { |
| 708 | /* disable all interrupts and force USB reset */ |
668 | /* disable all interrupts and force USB reset */ |
| Line 716... | Line 676... | ||
| 716 | 676 | ||
| 717 | return HAL_OK; |
677 | return HAL_OK; |
| 718 | } |
678 | } |
| 719 | 679 | ||
| 720 | /** |
680 | /** |
| 721 | * @brief USB_SetDevAddress : Stop the usb device mode |
681 | * @brief USB_SetDevAddress Stop the usb device mode |
| 722 | * @param USBx : Selected device |
682 | * @param USBx Selected device |
| 723 | * @param address : new device address to be assigned |
683 | * @param address new device address to be assigned |
| 724 | * This parameter can be a value from 0 to 255 |
684 | * This parameter can be a value from 0 to 255 |
| 725 | * @retval HAL status |
685 | * @retval HAL status |
| 726 | */ |
686 | */ |
| 727 | HAL_StatusTypeDef USB_SetDevAddress(USB_TypeDef *USBx, uint8_t address) |
687 | HAL_StatusTypeDef USB_SetDevAddress(USB_TypeDef *USBx, uint8_t address) |
| 728 | { |
688 | { |
| Line 734... | Line 694... | ||
| 734 | 694 | ||
| 735 | return HAL_OK; |
695 | return HAL_OK; |
| 736 | } |
696 | } |
| 737 | 697 | ||
| 738 | /** |
698 | /** |
| 739 | * @brief USB_DevConnect : Connect the USB device by enabling the pull-up/pull-down |
699 | * @brief USB_DevConnect Connect the USB device by enabling the pull-up/pull-down |
| 740 | * @param USBx : Selected device |
700 | * @param USBx Selected device |
| 741 | * @retval HAL status |
701 | * @retval HAL status |
| 742 | */ |
702 | */ |
| 743 | HAL_StatusTypeDef USB_DevConnect(USB_TypeDef *USBx) |
703 | HAL_StatusTypeDef USB_DevConnect(USB_TypeDef *USBx) |
| 744 | { |
704 | { |
| 745 | /* Prevent unused argument(s) compilation warning */ |
705 | /* Prevent unused argument(s) compilation warning */ |
| Line 752... | Line 712... | ||
| 752 | 712 | ||
| 753 | return HAL_OK; |
713 | return HAL_OK; |
| 754 | } |
714 | } |
| 755 | 715 | ||
| 756 | /** |
716 | /** |
| 757 | * @brief USB_DevDisconnect : Disconnect the USB device by disabling the pull-up/pull-down |
717 | * @brief USB_DevDisconnect Disconnect the USB device by disabling the pull-up/pull-down |
| 758 | * @param USBx : Selected device |
718 | * @param USBx Selected device |
| 759 | * @retval HAL status |
719 | * @retval HAL status |
| 760 | */ |
720 | */ |
| 761 | HAL_StatusTypeDef USB_DevDisconnect(USB_TypeDef *USBx) |
721 | HAL_StatusTypeDef USB_DevDisconnect(USB_TypeDef *USBx) |
| 762 | { |
722 | { |
| 763 | /* Prevent unused argument(s) compilation warning */ |
723 | /* Prevent unused argument(s) compilation warning */ |
| Line 770... | Line 730... | ||
| 770 | 730 | ||
| 771 | return HAL_OK; |
731 | return HAL_OK; |
| 772 | } |
732 | } |
| 773 | 733 | ||
| 774 | /** |
734 | /** |
| 775 | * @brief USB_ReadInterrupts: return the global USB interrupt status |
735 | * @brief USB_ReadInterrupts return the global USB interrupt status |
| 776 | * @param USBx : Selected device |
736 | * @param USBx Selected device |
| 777 | * @retval HAL status |
737 | * @retval HAL status |
| 778 | */ |
738 | */ |
| 779 | uint32_t USB_ReadInterrupts(USB_TypeDef *USBx) |
739 | uint32_t USB_ReadInterrupts(USB_TypeDef *USBx) |
| 780 | { |
740 | { |
| 781 | uint32_t tmpreg; |
741 | uint32_t tmpreg; |
| Line 783... | Line 743... | ||
| 783 | tmpreg = USBx->ISTR; |
743 | tmpreg = USBx->ISTR; |
| 784 | return tmpreg; |
744 | return tmpreg; |
| 785 | } |
745 | } |
| 786 | 746 | ||
| 787 | /** |
747 | /** |
| 788 | * @brief USB_ReadDevAllOutEpInterrupt: return the USB device OUT endpoints interrupt status |
- | |
| 789 | * @param USBx : Selected device |
- | |
| 790 | * @retval HAL status |
- | |
| 791 | */ |
- | |
| 792 | uint32_t USB_ReadDevAllOutEpInterrupt(USB_TypeDef *USBx) |
- | |
| 793 | { |
- | |
| 794 | /* Prevent unused argument(s) compilation warning */ |
- | |
| 795 | UNUSED(USBx); |
- | |
| 796 | /* NOTE : - This function is not required by USB Device FS peripheral, it is used |
- | |
| 797 | only by USB OTG FS peripheral. |
- | |
| 798 | - This function is added to ensure compatibility across platforms. |
- | |
| 799 | */ |
- | |
| 800 | return (0); |
- | |
| 801 | } |
- | |
| 802 | - | ||
| 803 | /** |
- | |
| 804 | * @brief USB_ReadDevAllInEpInterrupt: return the USB device IN endpoints interrupt status |
- | |
| 805 | * @param USBx : Selected device |
- | |
| 806 | * @retval HAL status |
- | |
| 807 | */ |
- | |
| 808 | uint32_t USB_ReadDevAllInEpInterrupt(USB_TypeDef *USBx) |
- | |
| 809 | { |
- | |
| 810 | /* Prevent unused argument(s) compilation warning */ |
- | |
| 811 | UNUSED(USBx); |
- | |
| 812 | /* NOTE : - This function is not required by USB Device FS peripheral, it is used |
- | |
| 813 | only by USB OTG FS peripheral. |
- | |
| 814 | - This function is added to ensure compatibility across platforms. |
- | |
| 815 | */ |
- | |
| 816 | return (0); |
- | |
| 817 | } |
- | |
| 818 | - | ||
| 819 | /** |
- | |
| 820 | * @brief Returns Device OUT EP Interrupt register |
- | |
| 821 | * @param USBx : Selected device |
- | |
| 822 | * @param epnum : endpoint number |
- | |
| 823 | * This parameter can be a value from 0 to 15 |
- | |
| 824 | * @retval Device OUT EP Interrupt register |
- | |
| 825 | */ |
- | |
| 826 | uint32_t USB_ReadDevOutEPInterrupt(USB_TypeDef *USBx, uint8_t epnum) |
- | |
| 827 | { |
- | |
| 828 | /* Prevent unused argument(s) compilation warning */ |
- | |
| 829 | UNUSED(USBx); |
- | |
| 830 | UNUSED(epnum); |
- | |
| 831 | /* NOTE : - This function is not required by USB Device FS peripheral, it is used |
- | |
| 832 | only by USB OTG FS peripheral. |
- | |
| 833 | - This function is added to ensure compatibility across platforms. |
- | |
| 834 | */ |
- | |
| 835 | return (0); |
- | |
| 836 | } |
- | |
| 837 | - | ||
| 838 | /** |
- | |
| 839 | * @brief Returns Device IN EP Interrupt register |
- | |
| 840 | * @param USBx : Selected device |
- | |
| 841 | * @param epnum : endpoint number |
- | |
| 842 | * This parameter can be a value from 0 to 15 |
- | |
| 843 | * @retval Device IN EP Interrupt register |
- | |
| 844 | */ |
- | |
| 845 | uint32_t USB_ReadDevInEPInterrupt(USB_TypeDef *USBx, uint8_t epnum) |
- | |
| 846 | { |
- | |
| 847 | /* Prevent unused argument(s) compilation warning */ |
- | |
| 848 | UNUSED(USBx); |
- | |
| 849 | UNUSED(epnum); |
- | |
| 850 | /* NOTE : - This function is not required by USB Device FS peripheral, it is used |
- | |
| 851 | only by USB OTG FS peripheral. |
- | |
| 852 | - This function is added to ensure compatibility across platforms. |
- | |
| 853 | */ |
- | |
| 854 | return (0); |
- | |
| 855 | } |
- | |
| 856 | - | ||
| 857 | /** |
- | |
| 858 | * @brief USB_ClearInterrupts: clear a USB interrupt |
- | |
| 859 | * @param USBx Selected device |
- | |
| 860 | * @param interrupt flag |
- | |
| 861 | * @retval None |
- | |
| 862 | */ |
- | |
| 863 | void USB_ClearInterrupts(USB_TypeDef *USBx, uint32_t interrupt) |
- | |
| 864 | { |
- | |
| 865 | /* Prevent unused argument(s) compilation warning */ |
- | |
| 866 | UNUSED(USBx); |
- | |
| 867 | UNUSED(interrupt); |
- | |
| 868 | /* NOTE : - This function is not required by USB Device FS peripheral, it is used |
- | |
| 869 | only by USB OTG FS peripheral. |
- | |
| 870 | - This function is added to ensure compatibility across platforms. |
- | |
| 871 | */ |
- | |
| 872 | } |
- | |
| 873 | - | ||
| 874 | /** |
- | |
| 875 | * @brief Prepare the EP0 to start the first control setup |
- | |
| 876 | * @param USBx Selected device |
- | |
| 877 | * @param psetup pointer to setup packet |
- | |
| 878 | * @retval HAL status |
- | |
| 879 | */ |
- | |
| 880 | HAL_StatusTypeDef USB_EP0_OutStart(USB_TypeDef *USBx, uint8_t *psetup) |
- | |
| 881 | { |
- | |
| 882 | /* Prevent unused argument(s) compilation warning */ |
- | |
| 883 | UNUSED(USBx); |
- | |
| 884 | UNUSED(psetup); |
- | |
| 885 | /* NOTE : - This function is not required by USB Device FS peripheral, it is used |
- | |
| 886 | only by USB OTG FS peripheral. |
- | |
| 887 | - This function is added to ensure compatibility across platforms. |
- | |
| 888 | */ |
- | |
| 889 | return HAL_OK; |
- | |
| 890 | } |
- | |
| 891 | - | ||
| 892 | /** |
- | |
| 893 | * @brief USB_ActivateRemoteWakeup : active remote wakeup signalling |
748 | * @brief USB_ActivateRemoteWakeup : active remote wakeup signalling |
| 894 | * @param USBx Selected device |
749 | * @param USBx Selected device |
| 895 | * @retval HAL status |
750 | * @retval HAL status |
| 896 | */ |
751 | */ |
| 897 | HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx) |
752 | HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx) |
| 898 | { |
753 | { |
| 899 | USBx->CNTR |= (uint16_t)USB_CNTR_RESUME; |
754 | USBx->CNTR |= (uint16_t)USB_CNTR_RESUME; |
| 900 | 755 | ||
| 901 | return HAL_OK; |
756 | return HAL_OK; |
| 902 | } |
757 | } |
| 903 | 758 | ||
| 904 | /** |
759 | /** |
| 905 | * @brief USB_DeActivateRemoteWakeup : de-active remote wakeup signalling |
760 | * @brief USB_DeActivateRemoteWakeup de-active remote wakeup signalling |
| 906 | * @param USBx Selected device |
761 | * @param USBx Selected device |
| 907 | * @retval HAL status |
762 | * @retval HAL status |
| 908 | */ |
763 | */ |
| 909 | HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx) |
764 | HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx) |
| 910 | { |
765 | { |
| 911 | USBx->CNTR &= (uint16_t)(~USB_CNTR_RESUME); |
766 | USBx->CNTR &= (uint16_t)(~USB_CNTR_RESUME); |
| - | 767 | ||
| 912 | return HAL_OK; |
768 | return HAL_OK; |
| 913 | } |
769 | } |
| 914 | 770 | ||
| 915 | /** |
771 | /** |
| 916 | * @brief Copy a buffer from user memory area to packet memory area (PMA) |
772 | * @brief Copy a buffer from user memory area to packet memory area (PMA) |
| 917 | * @param USBx USB peripheral instance register address. |
773 | * @param USBx USB peripheral instance register address. |
| 918 | * @param pbUsrBuf pointer to user memory area. |
774 | * @param pbUsrBuf pointer to user memory area. |
| 919 | * @param wPMABufAddr address into PMA. |
775 | * @param wPMABufAddr address into PMA. |
| 920 | * @param wNBytes: no. of bytes to be copied. |
776 | * @param wNBytes no. of bytes to be copied. |
| 921 | * @retval None |
777 | * @retval None |
| 922 | */ |
778 | */ |
| 923 | void USB_WritePMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) |
779 | void USB_WritePMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) |
| 924 | { |
780 | { |
| 925 | uint32_t n = ((uint32_t)wNBytes + 1U) >> 1; |
781 | uint32_t n = ((uint32_t)wNBytes + 1U) >> 1; |
| Line 946... | Line 802... | ||
| 946 | } |
802 | } |
| 947 | } |
803 | } |
| 948 | 804 | ||
| 949 | /** |
805 | /** |
| 950 | * @brief Copy data from packet memory area (PMA) to user memory buffer |
806 | * @brief Copy data from packet memory area (PMA) to user memory buffer |
| 951 | * @param USBx: USB peripheral instance register address. |
807 | * @param USBx USB peripheral instance register address. |
| 952 | * @param pbUsrBuf pointer to user memory area. |
808 | * @param pbUsrBuf pointer to user memory area. |
| 953 | * @param wPMABufAddr address into PMA. |
809 | * @param wPMABufAddr address into PMA. |
| 954 | * @param wNBytes: no. of bytes to be copied. |
810 | * @param wNBytes no. of bytes to be copied. |
| 955 | * @retval None |
811 | * @retval None |
| 956 | */ |
812 | */ |
| 957 | void USB_ReadPMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) |
813 | void USB_ReadPMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) |
| 958 | { |
814 | { |
| 959 | uint32_t n = (uint32_t)wNBytes >> 1; |
815 | uint32_t n = (uint32_t)wNBytes >> 1; |