2 ******************************************************************************
3 * @file stm32l0xx_hal_pcd_ex.c
4 * @author MCD Application Team
6 * @date 06-February-2015
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 * + Configururation of the PMA for EP
12 ******************************************************************************
15 * <h2><center>© COPYRIGHT(c) 2015 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 #if !defined (STM32L031xx) && !defined (STM32L041xx) && !defined (STM32L051xx) && !defined (STM32L061xx) && !defined (STM32L071xx) && !defined (STM32L081xx)
43 /* Includes ------------------------------------------------------------------*/
44 #include "stm32l0xx_hal.h"
45 #ifdef HAL_PCD_MODULE_ENABLED
46 /** @addtogroup STM32L0xx_HAL_Driver
51 * @brief PCDEx HAL module driver
57 /* Private typedef -----------------------------------------------------------*/
58 /* Private define ------------------------------------------------------------*/
59 /* Private macro -------------------------------------------------------------*/
60 /* Private variables ---------------------------------------------------------*/
61 /* Private function prototypes -----------------------------------------------*/
62 /* Private functions ---------------------------------------------------------*/
65 /** @defgroup PCDEx_Private_Functions
69 /** @defgroup PCDEx_Group1 Initialization and de-initialization functions
70 * @brief Initialization and Configuration functions
73 ===============================================================================
74 ##### Peripheral extended features functions #####
75 ===============================================================================
81 * @brief Configure PMA for EP
82 * @param pdev : Device instance
83 * @param ep_addr: endpoint address
84 * @param ep_Kind: endpoint Kind
85 * USB_SNG_BUF: Single Buffer used
86 * USB_DBL_BUF: Double Buffer used
87 * @param pmaadress: EP address in The PMA: In case of single buffer endpoint
88 * this parameter is 16-bit value providing the address
89 * in PMA allocated to endpoint.
90 * In case of double buffer endpoint this parameter
91 * is a 32-bit value providing the endpoint buffer 0 address
92 * in the LSB part of 32-bit value and endpoint buffer 1 address
93 * in the MSB part of 32-bit value.
97 HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd,
105 /* initialize ep structure*/
106 if ((0x80 & ep_addr) == 0x80)
108 ep = &hpcd->IN_ep[ep_addr & 0x7F];
112 ep = &hpcd->OUT_ep[ep_addr];
115 /* Here we check if the endpoint is single or double Buffer*/
116 if (ep_kind == PCD_SNG_BUF)
119 ep->doublebuffer = 0;
121 ep->pmaadress = (uint16_t)pmaadress;
125 /*Double Buffer Endpoint*/
126 ep->doublebuffer = 1;
127 /*Configure the PMA*/
128 ep->pmaaddr0 = pmaadress & 0xFFFF;
129 ep->pmaaddr1 = (pmaadress & 0xFFFF0000) >> 16;
150 #endif /* HAL_PCD_MODULE_ENABLED */
151 #endif /* #if !defined (STM32L031xx) && !defined (STM32L041xx) && !defined (STM32L051xx) && !defined (STM32L061xx) && !defined (STM32L071xx) && !defined (STM32L081xx) */
152 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/