Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mbed-dev/targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_hal_pcd_ex.c@29:ec2c5a69acd6, 2017-05-24 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Wed May 24 01:57:01 2017 +0000
- Revision:
- 29:ec2c5a69acd6
- Parent:
- 18:6a4db94011d3
Need to change ir2-ir3 to now be ir1 - ir4
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| sahilmgandhi | 18:6a4db94011d3 | 1 | /** |
| sahilmgandhi | 18:6a4db94011d3 | 2 | ****************************************************************************** |
| sahilmgandhi | 18:6a4db94011d3 | 3 | * @file stm32f0xx_hal_pcd_ex.c |
| sahilmgandhi | 18:6a4db94011d3 | 4 | * @author MCD Application Team |
| sahilmgandhi | 18:6a4db94011d3 | 5 | * @version V1.5.0 |
| sahilmgandhi | 18:6a4db94011d3 | 6 | * @date 04-November-2016 |
| sahilmgandhi | 18:6a4db94011d3 | 7 | * @brief Extended PCD HAL module driver. |
| sahilmgandhi | 18:6a4db94011d3 | 8 | * This file provides firmware functions to manage the following |
| sahilmgandhi | 18:6a4db94011d3 | 9 | * functionalities of the USB Peripheral Controller: |
| sahilmgandhi | 18:6a4db94011d3 | 10 | * + Configuration of the PMA for EP |
| sahilmgandhi | 18:6a4db94011d3 | 11 | * |
| sahilmgandhi | 18:6a4db94011d3 | 12 | ****************************************************************************** |
| sahilmgandhi | 18:6a4db94011d3 | 13 | * @attention |
| sahilmgandhi | 18:6a4db94011d3 | 14 | * |
| sahilmgandhi | 18:6a4db94011d3 | 15 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
| sahilmgandhi | 18:6a4db94011d3 | 16 | * |
| sahilmgandhi | 18:6a4db94011d3 | 17 | * Redistribution and use in source and binary forms, with or without modification, |
| sahilmgandhi | 18:6a4db94011d3 | 18 | * are permitted provided that the following conditions are met: |
| sahilmgandhi | 18:6a4db94011d3 | 19 | * 1. Redistributions of source code must retain the above copyright notice, |
| sahilmgandhi | 18:6a4db94011d3 | 20 | * this list of conditions and the following disclaimer. |
| sahilmgandhi | 18:6a4db94011d3 | 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| sahilmgandhi | 18:6a4db94011d3 | 22 | * this list of conditions and the following disclaimer in the documentation |
| sahilmgandhi | 18:6a4db94011d3 | 23 | * and/or other materials provided with the distribution. |
| sahilmgandhi | 18:6a4db94011d3 | 24 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| sahilmgandhi | 18:6a4db94011d3 | 25 | * may be used to endorse or promote products derived from this software |
| sahilmgandhi | 18:6a4db94011d3 | 26 | * without specific prior written permission. |
| sahilmgandhi | 18:6a4db94011d3 | 27 | * |
| sahilmgandhi | 18:6a4db94011d3 | 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| sahilmgandhi | 18:6a4db94011d3 | 29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| sahilmgandhi | 18:6a4db94011d3 | 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| sahilmgandhi | 18:6a4db94011d3 | 31 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| sahilmgandhi | 18:6a4db94011d3 | 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| sahilmgandhi | 18:6a4db94011d3 | 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| sahilmgandhi | 18:6a4db94011d3 | 34 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| sahilmgandhi | 18:6a4db94011d3 | 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| sahilmgandhi | 18:6a4db94011d3 | 36 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| sahilmgandhi | 18:6a4db94011d3 | 37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| sahilmgandhi | 18:6a4db94011d3 | 38 | * |
| sahilmgandhi | 18:6a4db94011d3 | 39 | ****************************************************************************** |
| sahilmgandhi | 18:6a4db94011d3 | 40 | */ |
| sahilmgandhi | 18:6a4db94011d3 | 41 | |
| sahilmgandhi | 18:6a4db94011d3 | 42 | /* Includes ------------------------------------------------------------------*/ |
| sahilmgandhi | 18:6a4db94011d3 | 43 | #include "stm32f0xx_hal.h" |
| sahilmgandhi | 18:6a4db94011d3 | 44 | |
| sahilmgandhi | 18:6a4db94011d3 | 45 | #ifdef HAL_PCD_MODULE_ENABLED |
| sahilmgandhi | 18:6a4db94011d3 | 46 | |
| sahilmgandhi | 18:6a4db94011d3 | 47 | #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)|| defined(STM32F070x6) |
| sahilmgandhi | 18:6a4db94011d3 | 48 | |
| sahilmgandhi | 18:6a4db94011d3 | 49 | /** @addtogroup STM32F0xx_HAL_Driver |
| sahilmgandhi | 18:6a4db94011d3 | 50 | * @{ |
| sahilmgandhi | 18:6a4db94011d3 | 51 | */ |
| sahilmgandhi | 18:6a4db94011d3 | 52 | |
| sahilmgandhi | 18:6a4db94011d3 | 53 | /** @defgroup PCDEx PCDEx |
| sahilmgandhi | 18:6a4db94011d3 | 54 | * @brief PCD Extended HAL module driver |
| sahilmgandhi | 18:6a4db94011d3 | 55 | * @{ |
| sahilmgandhi | 18:6a4db94011d3 | 56 | */ |
| sahilmgandhi | 18:6a4db94011d3 | 57 | |
| sahilmgandhi | 18:6a4db94011d3 | 58 | /* Private typedef -----------------------------------------------------------*/ |
| sahilmgandhi | 18:6a4db94011d3 | 59 | /* Private define ------------------------------------------------------------*/ |
| sahilmgandhi | 18:6a4db94011d3 | 60 | /* Private macro -------------------------------------------------------------*/ |
| sahilmgandhi | 18:6a4db94011d3 | 61 | /* Private variables ---------------------------------------------------------*/ |
| sahilmgandhi | 18:6a4db94011d3 | 62 | /* Private function prototypes -----------------------------------------------*/ |
| sahilmgandhi | 18:6a4db94011d3 | 63 | /* Exported functions ---------------------------------------------------------*/ |
| sahilmgandhi | 18:6a4db94011d3 | 64 | /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions |
| sahilmgandhi | 18:6a4db94011d3 | 65 | * @{ |
| sahilmgandhi | 18:6a4db94011d3 | 66 | */ |
| sahilmgandhi | 18:6a4db94011d3 | 67 | |
| sahilmgandhi | 18:6a4db94011d3 | 68 | /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions |
| sahilmgandhi | 18:6a4db94011d3 | 69 | * @brief PCDEx control functions |
| sahilmgandhi | 18:6a4db94011d3 | 70 | * |
| sahilmgandhi | 18:6a4db94011d3 | 71 | @verbatim |
| sahilmgandhi | 18:6a4db94011d3 | 72 | =============================================================================== |
| sahilmgandhi | 18:6a4db94011d3 | 73 | ##### Extended Peripheral Control functions ##### |
| sahilmgandhi | 18:6a4db94011d3 | 74 | =============================================================================== |
| sahilmgandhi | 18:6a4db94011d3 | 75 | [..] This section provides functions allowing to: |
| sahilmgandhi | 18:6a4db94011d3 | 76 | (+) Update PMA configuration |
| sahilmgandhi | 18:6a4db94011d3 | 77 | |
| sahilmgandhi | 18:6a4db94011d3 | 78 | @endverbatim |
| sahilmgandhi | 18:6a4db94011d3 | 79 | * @{ |
| sahilmgandhi | 18:6a4db94011d3 | 80 | */ |
| sahilmgandhi | 18:6a4db94011d3 | 81 | |
| sahilmgandhi | 18:6a4db94011d3 | 82 | /** |
| sahilmgandhi | 18:6a4db94011d3 | 83 | * @brief Configure PMA for EP |
| sahilmgandhi | 18:6a4db94011d3 | 84 | * @param hpcd: PCD handle |
| sahilmgandhi | 18:6a4db94011d3 | 85 | * @param ep_addr: endpoint address |
| sahilmgandhi | 18:6a4db94011d3 | 86 | * @param ep_kind: endpoint Kind |
| sahilmgandhi | 18:6a4db94011d3 | 87 | * @arg USB_SNG_BUF: Single Buffer used |
| sahilmgandhi | 18:6a4db94011d3 | 88 | * @arg USB_DBL_BUF: Double Buffer used |
| sahilmgandhi | 18:6a4db94011d3 | 89 | * @param pmaadress: EP address in The PMA: In case of single buffer endpoint |
| sahilmgandhi | 18:6a4db94011d3 | 90 | * this parameter is 16-bit value providing the address |
| sahilmgandhi | 18:6a4db94011d3 | 91 | * in PMA allocated to endpoint. |
| sahilmgandhi | 18:6a4db94011d3 | 92 | * In case of double buffer endpoint this parameter |
| sahilmgandhi | 18:6a4db94011d3 | 93 | * is a 32-bit value providing the endpoint buffer 0 address |
| sahilmgandhi | 18:6a4db94011d3 | 94 | * in the LSB part of 32-bit value and endpoint buffer 1 address |
| sahilmgandhi | 18:6a4db94011d3 | 95 | * in the MSB part of 32-bit value. |
| sahilmgandhi | 18:6a4db94011d3 | 96 | * @retval : status |
| sahilmgandhi | 18:6a4db94011d3 | 97 | */ |
| sahilmgandhi | 18:6a4db94011d3 | 98 | |
| sahilmgandhi | 18:6a4db94011d3 | 99 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, |
| sahilmgandhi | 18:6a4db94011d3 | 100 | uint16_t ep_addr, |
| sahilmgandhi | 18:6a4db94011d3 | 101 | uint16_t ep_kind, |
| sahilmgandhi | 18:6a4db94011d3 | 102 | uint32_t pmaadress) |
| sahilmgandhi | 18:6a4db94011d3 | 103 | |
| sahilmgandhi | 18:6a4db94011d3 | 104 | { |
| sahilmgandhi | 18:6a4db94011d3 | 105 | PCD_EPTypeDef *ep; |
| sahilmgandhi | 18:6a4db94011d3 | 106 | |
| sahilmgandhi | 18:6a4db94011d3 | 107 | /* initialize ep structure*/ |
| sahilmgandhi | 18:6a4db94011d3 | 108 | if ((0x80U & ep_addr) == 0x80U) |
| sahilmgandhi | 18:6a4db94011d3 | 109 | { |
| sahilmgandhi | 18:6a4db94011d3 | 110 | ep = &hpcd->IN_ep[ep_addr & 0x7FU]; |
| sahilmgandhi | 18:6a4db94011d3 | 111 | } |
| sahilmgandhi | 18:6a4db94011d3 | 112 | else |
| sahilmgandhi | 18:6a4db94011d3 | 113 | { |
| sahilmgandhi | 18:6a4db94011d3 | 114 | ep = &hpcd->OUT_ep[ep_addr]; |
| sahilmgandhi | 18:6a4db94011d3 | 115 | } |
| sahilmgandhi | 18:6a4db94011d3 | 116 | |
| sahilmgandhi | 18:6a4db94011d3 | 117 | /* Here we check if the endpoint is single or double Buffer*/ |
| sahilmgandhi | 18:6a4db94011d3 | 118 | if (ep_kind == PCD_SNG_BUF) |
| sahilmgandhi | 18:6a4db94011d3 | 119 | { |
| sahilmgandhi | 18:6a4db94011d3 | 120 | /*Single Buffer*/ |
| sahilmgandhi | 18:6a4db94011d3 | 121 | ep->doublebuffer = 0U; |
| sahilmgandhi | 18:6a4db94011d3 | 122 | /*Configure the PMA*/ |
| sahilmgandhi | 18:6a4db94011d3 | 123 | ep->pmaadress = (uint16_t)pmaadress; |
| sahilmgandhi | 18:6a4db94011d3 | 124 | } |
| sahilmgandhi | 18:6a4db94011d3 | 125 | else /*USB_DBL_BUF*/ |
| sahilmgandhi | 18:6a4db94011d3 | 126 | { |
| sahilmgandhi | 18:6a4db94011d3 | 127 | /*Double Buffer Endpoint*/ |
| sahilmgandhi | 18:6a4db94011d3 | 128 | ep->doublebuffer = 1U; |
| sahilmgandhi | 18:6a4db94011d3 | 129 | /*Configure the PMA*/ |
| sahilmgandhi | 18:6a4db94011d3 | 130 | ep->pmaaddr0 = pmaadress & 0xFFFFU; |
| sahilmgandhi | 18:6a4db94011d3 | 131 | ep->pmaaddr1 = (pmaadress & 0xFFFF0000U) >> 16U; |
| sahilmgandhi | 18:6a4db94011d3 | 132 | } |
| sahilmgandhi | 18:6a4db94011d3 | 133 | |
| sahilmgandhi | 18:6a4db94011d3 | 134 | return HAL_OK; |
| sahilmgandhi | 18:6a4db94011d3 | 135 | } |
| sahilmgandhi | 18:6a4db94011d3 | 136 | /** |
| sahilmgandhi | 18:6a4db94011d3 | 137 | * @} |
| sahilmgandhi | 18:6a4db94011d3 | 138 | */ |
| sahilmgandhi | 18:6a4db94011d3 | 139 | |
| sahilmgandhi | 18:6a4db94011d3 | 140 | /** |
| sahilmgandhi | 18:6a4db94011d3 | 141 | * @} |
| sahilmgandhi | 18:6a4db94011d3 | 142 | */ |
| sahilmgandhi | 18:6a4db94011d3 | 143 | |
| sahilmgandhi | 18:6a4db94011d3 | 144 | /** |
| sahilmgandhi | 18:6a4db94011d3 | 145 | * @} |
| sahilmgandhi | 18:6a4db94011d3 | 146 | */ |
| sahilmgandhi | 18:6a4db94011d3 | 147 | |
| sahilmgandhi | 18:6a4db94011d3 | 148 | /** |
| sahilmgandhi | 18:6a4db94011d3 | 149 | * @} |
| sahilmgandhi | 18:6a4db94011d3 | 150 | */ |
| sahilmgandhi | 18:6a4db94011d3 | 151 | |
| sahilmgandhi | 18:6a4db94011d3 | 152 | #endif /* STM32F042x6 || STM32F072xB || STM32F078xx || STM32F070xB || STM32F070x6 */ |
| sahilmgandhi | 18:6a4db94011d3 | 153 | |
| sahilmgandhi | 18:6a4db94011d3 | 154 | #endif /* HAL_PCD_MODULE_ENABLED */ |
| sahilmgandhi | 18:6a4db94011d3 | 155 | |
| sahilmgandhi | 18:6a4db94011d3 | 156 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |