]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32L0/stm32l0xx_hal_pcd_ex.c
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32L0 / stm32l0xx_hal_pcd_ex.c
1 /**
2   ******************************************************************************
3   * @file    stm32l0xx_hal_pcd_ex.c
4   * @author  MCD Application Team
5   * @version V1.2.0
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
11   *         
12   ******************************************************************************
13   * @attention
14   *
15   * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
16   *
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.
27   *
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.
38   *
39   ******************************************************************************
40   */ 
41
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
47   * @{
48   */
49
50 /** @defgroup PCDEx 
51   * @brief PCDEx HAL module driver
52   * @{
53   */
54
55
56
57 /* Private typedef -----------------------------------------------------------*/
58 /* Private define ------------------------------------------------------------*/
59 /* Private macro -------------------------------------------------------------*/
60 /* Private variables ---------------------------------------------------------*/
61 /* Private function prototypes -----------------------------------------------*/
62 /* Private functions ---------------------------------------------------------*/
63
64
65 /** @defgroup PCDEx_Private_Functions
66   * @{
67   */
68
69 /** @defgroup PCDEx_Group1 Initialization and de-initialization functions 
70  *  @brief    Initialization and Configuration functions 
71  *
72 @verbatim    
73  ===============================================================================
74                  ##### Peripheral extended features functions #####
75  ===============================================================================
76 @endverbatim
77   * @{
78   */
79
80 /**
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.
94   * @retval : status
95   */
96
97 HAL_StatusTypeDef  HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 
98                         uint16_t ep_addr,
99                         uint16_t ep_kind,
100                         uint32_t pmaadress)
101
102 {
103   PCD_EPTypeDef *ep;
104   
105   /* initialize ep structure*/
106   if ((0x80 & ep_addr) == 0x80)
107   {
108     ep = &hpcd->IN_ep[ep_addr & 0x7F];
109   }
110   else
111   {
112     ep = &hpcd->OUT_ep[ep_addr];
113   }
114   
115   /* Here we check if the endpoint is single or double Buffer*/
116   if (ep_kind == PCD_SNG_BUF)
117   {
118     /*Single Buffer*/
119     ep->doublebuffer = 0;
120     /*Configure te PMA*/
121     ep->pmaadress = (uint16_t)pmaadress;
122   }
123   else /*USB_DBL_BUF*/
124   {
125     /*Double Buffer Endpoint*/
126     ep->doublebuffer = 1;
127     /*Configure the PMA*/
128     ep->pmaaddr0 =  pmaadress & 0xFFFF;
129     ep->pmaaddr1 =  (pmaadress & 0xFFFF0000) >> 16;
130   }
131   
132   return HAL_OK; 
133 }
134 /**
135   * @}
136   */
137
138
139 /**
140   * @}
141   */
142
143 /**
144   * @}
145   */
146
147 /**
148   * @}
149   */
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****/