mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
184:08ed48f1de7f
mbed library release version 165

Who changed what in which revision?

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