]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32L1/stm32l1xx_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_STM32L1 / stm32l1xx_hal_pcd_ex.c
1 /**
2   ******************************************************************************
3   * @file    stm32l1xx_hal_pcd_ex.c
4   * @author  MCD Application Team
5   * @version V1.0.0
6   * @date    5-September-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   *           + Configururation 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 "stm32l1xx_hal.h"
44
45 /** @addtogroup STM32L1xx_HAL_Driver
46   * @{
47   */
48
49 /** @defgroup PCDEx PCDEx
50   * @brief PCDEx HAL module driver
51   * @{
52   */
53
54 #ifdef HAL_PCD_MODULE_ENABLED
55
56 /* Private typedef -----------------------------------------------------------*/
57 /* Private define ------------------------------------------------------------*/
58 /* Private macro -------------------------------------------------------------*/
59 /* Private variables ---------------------------------------------------------*/
60 /* Private function prototypes -----------------------------------------------*/
61 /* Private functions ---------------------------------------------------------*/
62
63
64 /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions
65   * @{
66   */
67
68 /*
69 @verbatim    
70  ===============================================================================
71                  ##### Peripheral extended features functions #####
72  ===============================================================================
73 @endverbatim
74   * @{
75   */
76
77 /**
78   * @brief Configure PMA for EP
79   * @param  hpcd : Device instance
80   * @param  ep_addr: endpoint address
81   * @param  ep_kind: endpoint Kind
82   *                  USB_SNG_BUF: Single Buffer used
83   *                  USB_DBL_BUF: Double Buffer used
84   * @param  pmaadress: EP address in The PMA: In case of single buffer endpoint
85   *                   this parameter is 16-bit value providing the address
86   *                   in PMA allocated to endpoint.
87   *                   In case of double buffer endpoint this parameter
88   *                   is a 32-bit value providing the endpoint buffer 0 address
89   *                   in the LSB part of 32-bit value and endpoint buffer 1 address
90   *                   in the MSB part of 32-bit value.
91   * @retval : status
92   */
93
94 HAL_StatusTypeDef  HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 
95                         uint16_t ep_addr,
96                         uint16_t ep_kind,
97                         uint32_t pmaadress)
98
99 {
100   PCD_EPTypeDef *ep;
101   
102   /* initialize ep structure*/
103   if ((0x80 & ep_addr) == 0x80)
104   {
105     ep = &hpcd->IN_ep[ep_addr & 0x7F];
106   }
107   else
108   {
109     ep = &hpcd->OUT_ep[ep_addr];
110   }
111   
112   /* Here we check if the endpoint is single or double Buffer*/
113   if (ep_kind == PCD_SNG_BUF)
114   {
115     /*Single Buffer*/
116     ep->doublebuffer = 0;
117     /*Configure te PMA*/
118     ep->pmaadress = (uint16_t)pmaadress;
119   }
120   else /*USB_DBL_BUF*/
121   {
122     /*Double Buffer Endpoint*/
123     ep->doublebuffer = 1;
124     /*Configure the PMA*/
125     ep->pmaaddr0 =  pmaadress & 0xFFFF;
126     ep->pmaaddr1 =  (pmaadress & 0xFFFF0000) >> 16;
127   }
128   
129   return HAL_OK; 
130 }
131
132
133
134 /**
135   * @}
136   */
137
138 #endif /* HAL_PCD_MODULE_ENABLED */
139 /**
140   * @}
141   */
142
143 /**
144   * @}
145   */
146
147 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/