]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/stm32f0xx_hal_pcd_ex.c
Add a qwerty layer
[max/tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F0 / stm32f0xx_hal_pcd_ex.c
1 /**
2   ******************************************************************************
3   * @file    stm32f0xx_hal_pcd_ex.c
4   * @author  MCD Application Team
5   * @version V1.2.0
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
11   *         
12   ******************************************************************************
13   * @attention
14   *
15   * <h2><center>&copy; COPYRIGHT(c) 2014 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 /* Includes ------------------------------------------------------------------*/
43 #include "stm32f0xx_hal.h"
44
45 #ifdef HAL_PCD_MODULE_ENABLED
46
47 #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)|| defined(STM32F070x6)
48
49 /** @addtogroup STM32F0xx_HAL_Driver
50   * @{
51   */
52
53 /** @defgroup PCDEx PCDEx Extended HAL module driver
54   * @brief PCDEx PCDEx Extended HAL module driver
55   * @{
56   */
57 /* Private typedef -----------------------------------------------------------*/
58 /* Private define ------------------------------------------------------------*/
59 /* Private macro -------------------------------------------------------------*/
60 /* Private variables ---------------------------------------------------------*/
61 /* Private function prototypes -----------------------------------------------*/
62 /* Exported functions ---------------------------------------------------------*/
63
64 /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions
65   * @{
66   */
67
68 /** @defgroup PCDEx_Exported_Functions_Group2 Initialization and de-initialization functions 
69  *  @brief    Initialization and Configuration functions 
70  *
71 @verbatim
72  ===============================================================================
73                  ##### Peripheral extended features methods #####
74  ===============================================================================
75 @endverbatim
76   * @{
77   */
78
79 /**
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.
93   * @retval : status
94   */
95
96 HAL_StatusTypeDef  HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 
97                         uint16_t ep_addr,
98                         uint16_t ep_kind,
99                         uint32_t pmaadress)
100
101 {
102   PCD_EPTypeDef *ep;
103   
104   /* initialize ep structure*/
105   if ((0x80 & ep_addr) == 0x80)
106   {
107     ep = &hpcd->IN_ep[ep_addr & 0x7F];
108   }
109   else
110   {
111     ep = &hpcd->OUT_ep[ep_addr];
112   }
113   
114   /* Here we check if the endpoint is single or double Buffer*/
115   if (ep_kind == PCD_SNG_BUF)
116   {
117     /*Single Buffer*/
118     ep->doublebuffer = 0;
119     /*Configure te PMA*/
120     ep->pmaadress = (uint16_t)pmaadress;
121   }
122   else /*USB_DBL_BUF*/
123   {
124     /*Double Buffer Endpoint*/
125     ep->doublebuffer = 1;
126     /*Configure the PMA*/
127     ep->pmaaddr0 =  pmaadress & 0xFFFF;
128     ep->pmaaddr1 =  (pmaadress & 0xFFFF0000) >> 16;
129   }
130   
131   return HAL_OK;
132 }
133 /**
134   * @}
135   */
136
137 /**
138   * @}
139   */
140
141 /**
142   * @}
143   */
144
145 /**
146   * @}
147   */
148
149 #endif /* STM32F042x6 || STM32F072xB || STM32F078xx || STM32F070xB || STM32F070x6 */
150
151 #endif /* HAL_PCD_MODULE_ENABLED */
152
153 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/