mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Wed Sep 30 17:00:09 2015 +0100
Revision:
636:a11c0372f0ba
Parent:
490:119543c9f674
Synchronized with git revision d29c98dae61be0946ddf3a3c641c7726056f9452

Full URL: https://github.com/mbedmicro/mbed/commit/d29c98dae61be0946ddf3a3c641c7726056f9452/

Added support for SAMW25

Who changed what in which revision?

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