2 ******************************************************************************
3 * @file stm32f0xx_hal_pcd_ex.c
4 * @author MCD Application Team
6 * @date 11-December-2014
7 * @brief Extended PCD HAL module driver.
8 * This file provides firmware functions to manage the following
9 * functionalities of the USB Peripheral Controller:
10 * + Configuration of the PMA for EP
12 ******************************************************************************
15 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
17 * Redistribution and use in source and binary forms, with or without modification,
18 * are permitted provided that the following conditions are met:
19 * 1. Redistributions of source code must retain the above copyright notice,
20 * this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright notice,
22 * this list of conditions and the following disclaimer in the documentation
23 * and/or other materials provided with the distribution.
24 * 3. Neither the name of STMicroelectronics nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ******************************************************************************
42 /* Includes ------------------------------------------------------------------*/
43 #include "stm32f0xx_hal.h"
45 #ifdef HAL_PCD_MODULE_ENABLED
47 #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)|| defined(STM32F070x6)
49 /** @addtogroup STM32F0xx_HAL_Driver
53 /** @defgroup PCDEx PCDEx Extended HAL module driver
54 * @brief PCDEx PCDEx Extended HAL module driver
57 /* Private typedef -----------------------------------------------------------*/
58 /* Private define ------------------------------------------------------------*/
59 /* Private macro -------------------------------------------------------------*/
60 /* Private variables ---------------------------------------------------------*/
61 /* Private function prototypes -----------------------------------------------*/
62 /* Exported functions ---------------------------------------------------------*/
64 /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions
68 /** @defgroup PCDEx_Exported_Functions_Group2 Initialization and de-initialization functions
69 * @brief Initialization and Configuration functions
72 ===============================================================================
73 ##### Peripheral extended features methods #####
74 ===============================================================================
80 * @brief Configure PMA for EP
81 * @param hpcd: PCD handle
82 * @param ep_addr: endpoint address
83 * @param ep_kind: endpoint Kind
84 * @arg USB_SNG_BUF: Single Buffer used
85 * @arg USB_DBL_BUF: Double Buffer used
86 * @param pmaadress: EP address in The PMA: In case of single buffer endpoint
87 * this parameter is 16-bit value providing the address
88 * in PMA allocated to endpoint.
89 * In case of double buffer endpoint this parameter
90 * is a 32-bit value providing the endpoint buffer 0 address
91 * in the LSB part of 32-bit value and endpoint buffer 1 address
92 * in the MSB part of 32-bit value.
96 HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd,
104 /* initialize ep structure*/
105 if ((0x80 & ep_addr) == 0x80)
107 ep = &hpcd->IN_ep[ep_addr & 0x7F];
111 ep = &hpcd->OUT_ep[ep_addr];
114 /* Here we check if the endpoint is single or double Buffer*/
115 if (ep_kind == PCD_SNG_BUF)
118 ep->doublebuffer = 0;
120 ep->pmaadress = (uint16_t)pmaadress;
124 /*Double Buffer Endpoint*/
125 ep->doublebuffer = 1;
126 /*Configure the PMA*/
127 ep->pmaaddr0 = pmaadress & 0xFFFF;
128 ep->pmaaddr1 = (pmaadress & 0xFFFF0000) >> 16;
149 #endif /* STM32F042x6 || STM32F072xB || STM32F078xx || STM32F070xB || STM32F070x6 */
151 #endif /* HAL_PCD_MODULE_ENABLED */
153 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/