mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F072RB/stm32f0xx_hal_pcd_ex.c@218:44081b78fdc2, 2014-05-30 (annotated)
- Committer:
- mbed_official
- Date:
- Fri May 30 15:30:09 2014 +0100
- Revision:
- 218:44081b78fdc2
- Parent:
- 205:c41fc65bcfb4
Synchronized with git revision d854859072d318241476ccc5f335965444d4c1d8
Full URL: https://github.com/mbedmicro/mbed/commit/d854859072d318241476ccc5f335965444d4c1d8/
[NUCLEO_F072RB] Update CubeF0 HAL driver
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 205:c41fc65bcfb4 | 1 | /** |
mbed_official | 205:c41fc65bcfb4 | 2 | ****************************************************************************** |
mbed_official | 205:c41fc65bcfb4 | 3 | * @file stm32f0xx_hal_pcd_ex.c |
mbed_official | 205:c41fc65bcfb4 | 4 | * @author MCD Application Team |
mbed_official | 205:c41fc65bcfb4 | 5 | * @version V1.0.0 |
mbed_official | 218:44081b78fdc2 | 6 | * @date 28-May-2014 |
mbed_official | 205:c41fc65bcfb4 | 7 | * @brief Extended PCD HAL module driver. |
mbed_official | 205:c41fc65bcfb4 | 8 | * This file provides firmware functions to manage the following |
mbed_official | 205:c41fc65bcfb4 | 9 | * functionalities of the USB Peripheral Controller: |
mbed_official | 205:c41fc65bcfb4 | 10 | * + Configuration of the PMA for EP |
mbed_official | 205:c41fc65bcfb4 | 11 | * |
mbed_official | 205:c41fc65bcfb4 | 12 | ****************************************************************************** |
mbed_official | 205:c41fc65bcfb4 | 13 | * @attention |
mbed_official | 205:c41fc65bcfb4 | 14 | * |
mbed_official | 205:c41fc65bcfb4 | 15 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 205:c41fc65bcfb4 | 16 | * |
mbed_official | 205:c41fc65bcfb4 | 17 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 205:c41fc65bcfb4 | 18 | * are permitted provided that the following conditions are met: |
mbed_official | 205:c41fc65bcfb4 | 19 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 205:c41fc65bcfb4 | 20 | * this list of conditions and the following disclaimer. |
mbed_official | 205:c41fc65bcfb4 | 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 205:c41fc65bcfb4 | 22 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 205:c41fc65bcfb4 | 23 | * and/or other materials provided with the distribution. |
mbed_official | 205:c41fc65bcfb4 | 24 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 205:c41fc65bcfb4 | 25 | * may be used to endorse or promote products derived from this software |
mbed_official | 205:c41fc65bcfb4 | 26 | * without specific prior written permission. |
mbed_official | 205:c41fc65bcfb4 | 27 | * |
mbed_official | 205:c41fc65bcfb4 | 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 205:c41fc65bcfb4 | 29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 205:c41fc65bcfb4 | 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 205:c41fc65bcfb4 | 31 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 205:c41fc65bcfb4 | 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 205:c41fc65bcfb4 | 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 205:c41fc65bcfb4 | 34 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 205:c41fc65bcfb4 | 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 205:c41fc65bcfb4 | 36 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 205:c41fc65bcfb4 | 37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 205:c41fc65bcfb4 | 38 | * |
mbed_official | 205:c41fc65bcfb4 | 39 | ****************************************************************************** |
mbed_official | 205:c41fc65bcfb4 | 40 | */ |
mbed_official | 205:c41fc65bcfb4 | 41 | |
mbed_official | 205:c41fc65bcfb4 | 42 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 43 | #include "stm32f0xx_hal.h" |
mbed_official | 205:c41fc65bcfb4 | 44 | |
mbed_official | 205:c41fc65bcfb4 | 45 | /** @addtogroup STM32F0xx_HAL_Driver |
mbed_official | 205:c41fc65bcfb4 | 46 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 47 | */ |
mbed_official | 205:c41fc65bcfb4 | 48 | |
mbed_official | 205:c41fc65bcfb4 | 49 | /** @defgroup PCDEx |
mbed_official | 205:c41fc65bcfb4 | 50 | * @brief PCDEx HAL module driver |
mbed_official | 205:c41fc65bcfb4 | 51 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 52 | */ |
mbed_official | 205:c41fc65bcfb4 | 53 | |
mbed_official | 205:c41fc65bcfb4 | 54 | #ifdef HAL_PCD_MODULE_ENABLED |
mbed_official | 205:c41fc65bcfb4 | 55 | |
mbed_official | 205:c41fc65bcfb4 | 56 | #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || defined(STM32F078xx) |
mbed_official | 205:c41fc65bcfb4 | 57 | |
mbed_official | 205:c41fc65bcfb4 | 58 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 59 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 60 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 61 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 62 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 63 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 64 | |
mbed_official | 205:c41fc65bcfb4 | 65 | |
mbed_official | 205:c41fc65bcfb4 | 66 | /** @defgroup PCDEx_Private_Functions |
mbed_official | 205:c41fc65bcfb4 | 67 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 68 | */ |
mbed_official | 205:c41fc65bcfb4 | 69 | |
mbed_official | 205:c41fc65bcfb4 | 70 | /** @defgroup PCDEx_Group1 Initialization and de-initialization functions |
mbed_official | 205:c41fc65bcfb4 | 71 | * @brief Initialization and Configuration functions |
mbed_official | 205:c41fc65bcfb4 | 72 | * |
mbed_official | 205:c41fc65bcfb4 | 73 | @verbatim |
mbed_official | 205:c41fc65bcfb4 | 74 | =============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 75 | ##### Peripheral extended features methods ##### |
mbed_official | 205:c41fc65bcfb4 | 76 | =============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 77 | @endverbatim |
mbed_official | 205:c41fc65bcfb4 | 78 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 79 | */ |
mbed_official | 205:c41fc65bcfb4 | 80 | |
mbed_official | 205:c41fc65bcfb4 | 81 | /** |
mbed_official | 205:c41fc65bcfb4 | 82 | * @brief Configure PMA for EP |
mbed_official | 205:c41fc65bcfb4 | 83 | * @param hpcd: PCD handle |
mbed_official | 205:c41fc65bcfb4 | 84 | * @param ep_addr: endpoint address |
mbed_official | 205:c41fc65bcfb4 | 85 | * @param ep_kind: endpoint Kind |
mbed_official | 205:c41fc65bcfb4 | 86 | * @arg USB_SNG_BUF: Single Buffer used |
mbed_official | 205:c41fc65bcfb4 | 87 | * @arg USB_DBL_BUF: Double Buffer used |
mbed_official | 205:c41fc65bcfb4 | 88 | * @param pmaadress: EP address in The PMA: In case of single buffer endpoint |
mbed_official | 205:c41fc65bcfb4 | 89 | * this parameter is 16-bit value providing the address |
mbed_official | 205:c41fc65bcfb4 | 90 | * in PMA allocated to endpoint. |
mbed_official | 205:c41fc65bcfb4 | 91 | * In case of double buffer endpoint this parameter |
mbed_official | 205:c41fc65bcfb4 | 92 | * is a 32-bit value providing the endpoint buffer 0 address |
mbed_official | 205:c41fc65bcfb4 | 93 | * in the LSB part of 32-bit value and endpoint buffer 1 address |
mbed_official | 205:c41fc65bcfb4 | 94 | * in the MSB part of 32-bit value. |
mbed_official | 205:c41fc65bcfb4 | 95 | * @retval : status |
mbed_official | 205:c41fc65bcfb4 | 96 | */ |
mbed_official | 205:c41fc65bcfb4 | 97 | |
mbed_official | 205:c41fc65bcfb4 | 98 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, |
mbed_official | 205:c41fc65bcfb4 | 99 | uint16_t ep_addr, |
mbed_official | 205:c41fc65bcfb4 | 100 | uint16_t ep_kind, |
mbed_official | 205:c41fc65bcfb4 | 101 | uint32_t pmaadress) |
mbed_official | 205:c41fc65bcfb4 | 102 | |
mbed_official | 205:c41fc65bcfb4 | 103 | { |
mbed_official | 205:c41fc65bcfb4 | 104 | PCD_EPTypeDef *ep; |
mbed_official | 205:c41fc65bcfb4 | 105 | |
mbed_official | 205:c41fc65bcfb4 | 106 | /* initialize ep structure*/ |
mbed_official | 205:c41fc65bcfb4 | 107 | if ((0x80 & ep_addr) == 0x80) |
mbed_official | 205:c41fc65bcfb4 | 108 | { |
mbed_official | 205:c41fc65bcfb4 | 109 | ep = &hpcd->IN_ep[ep_addr & 0x7F]; |
mbed_official | 205:c41fc65bcfb4 | 110 | } |
mbed_official | 205:c41fc65bcfb4 | 111 | else |
mbed_official | 205:c41fc65bcfb4 | 112 | { |
mbed_official | 205:c41fc65bcfb4 | 113 | ep = &hpcd->OUT_ep[ep_addr]; |
mbed_official | 205:c41fc65bcfb4 | 114 | } |
mbed_official | 205:c41fc65bcfb4 | 115 | |
mbed_official | 205:c41fc65bcfb4 | 116 | /* Here we check if the endpoint is single or double Buffer*/ |
mbed_official | 205:c41fc65bcfb4 | 117 | if (ep_kind == PCD_SNG_BUF) |
mbed_official | 205:c41fc65bcfb4 | 118 | { |
mbed_official | 205:c41fc65bcfb4 | 119 | /*Single Buffer*/ |
mbed_official | 205:c41fc65bcfb4 | 120 | ep->doublebuffer = 0; |
mbed_official | 205:c41fc65bcfb4 | 121 | /*Configure te PMA*/ |
mbed_official | 205:c41fc65bcfb4 | 122 | ep->pmaadress = (uint16_t)pmaadress; |
mbed_official | 205:c41fc65bcfb4 | 123 | } |
mbed_official | 205:c41fc65bcfb4 | 124 | else /*USB_DBL_BUF*/ |
mbed_official | 205:c41fc65bcfb4 | 125 | { |
mbed_official | 205:c41fc65bcfb4 | 126 | /*Double Buffer Endpoint*/ |
mbed_official | 205:c41fc65bcfb4 | 127 | ep->doublebuffer = 1; |
mbed_official | 205:c41fc65bcfb4 | 128 | /*Configure the PMA*/ |
mbed_official | 205:c41fc65bcfb4 | 129 | ep->pmaaddr0 = pmaadress & 0xFFFF; |
mbed_official | 205:c41fc65bcfb4 | 130 | ep->pmaaddr1 = (pmaadress & 0xFFFF0000) >> 16; |
mbed_official | 205:c41fc65bcfb4 | 131 | } |
mbed_official | 205:c41fc65bcfb4 | 132 | |
mbed_official | 205:c41fc65bcfb4 | 133 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 134 | } |
mbed_official | 205:c41fc65bcfb4 | 135 | /** |
mbed_official | 205:c41fc65bcfb4 | 136 | * @} |
mbed_official | 205:c41fc65bcfb4 | 137 | */ |
mbed_official | 205:c41fc65bcfb4 | 138 | |
mbed_official | 205:c41fc65bcfb4 | 139 | /** |
mbed_official | 205:c41fc65bcfb4 | 140 | * @} |
mbed_official | 205:c41fc65bcfb4 | 141 | */ |
mbed_official | 205:c41fc65bcfb4 | 142 | |
mbed_official | 205:c41fc65bcfb4 | 143 | #endif /* STM32F042x6 || STM32F072xB || STM32F078xx */ |
mbed_official | 205:c41fc65bcfb4 | 144 | |
mbed_official | 205:c41fc65bcfb4 | 145 | #endif /* HAL_PCD_MODULE_ENABLED */ |
mbed_official | 205:c41fc65bcfb4 | 146 | /** |
mbed_official | 205:c41fc65bcfb4 | 147 | * @} |
mbed_official | 205:c41fc65bcfb4 | 148 | */ |
mbed_official | 205:c41fc65bcfb4 | 149 | |
mbed_official | 205:c41fc65bcfb4 | 150 | /** |
mbed_official | 205:c41fc65bcfb4 | 151 | * @} |
mbed_official | 205:c41fc65bcfb4 | 152 | */ |
mbed_official | 205:c41fc65bcfb4 | 153 | |
mbed_official | 205:c41fc65bcfb4 | 154 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |