Ermanno Brusadin / mbed-src
Committer:
ebrus
Date:
Wed Jul 27 18:35:32 2016 +0000
Revision:
0:0a673c671a56
4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ebrus 0:0a673c671a56 1 /**
ebrus 0:0a673c671a56 2 ******************************************************************************
ebrus 0:0a673c671a56 3 * @file stm32f4xx_hal_pcd_ex.c
ebrus 0:0a673c671a56 4 * @author MCD Application Team
ebrus 0:0a673c671a56 5 * @version V1.1.0
ebrus 0:0a673c671a56 6 * @date 19-June-2014
ebrus 0:0a673c671a56 7 * @brief PCD HAL module driver.
ebrus 0:0a673c671a56 8 * This file provides firmware functions to manage the following
ebrus 0:0a673c671a56 9 * functionalities of the USB Peripheral Controller:
ebrus 0:0a673c671a56 10 * + Extended features functions
ebrus 0:0a673c671a56 11 *
ebrus 0:0a673c671a56 12 ******************************************************************************
ebrus 0:0a673c671a56 13 * @attention
ebrus 0:0a673c671a56 14 *
ebrus 0:0a673c671a56 15 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
ebrus 0:0a673c671a56 16 *
ebrus 0:0a673c671a56 17 * Redistribution and use in source and binary forms, with or without modification,
ebrus 0:0a673c671a56 18 * are permitted provided that the following conditions are met:
ebrus 0:0a673c671a56 19 * 1. Redistributions of source code must retain the above copyright notice,
ebrus 0:0a673c671a56 20 * this list of conditions and the following disclaimer.
ebrus 0:0a673c671a56 21 * 2. Redistributions in binary form must reproduce the above copyright notice,
ebrus 0:0a673c671a56 22 * this list of conditions and the following disclaimer in the documentation
ebrus 0:0a673c671a56 23 * and/or other materials provided with the distribution.
ebrus 0:0a673c671a56 24 * 3. Neither the name of STMicroelectronics nor the names of its contributors
ebrus 0:0a673c671a56 25 * may be used to endorse or promote products derived from this software
ebrus 0:0a673c671a56 26 * without specific prior written permission.
ebrus 0:0a673c671a56 27 *
ebrus 0:0a673c671a56 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
ebrus 0:0a673c671a56 29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
ebrus 0:0a673c671a56 30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
ebrus 0:0a673c671a56 31 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
ebrus 0:0a673c671a56 32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
ebrus 0:0a673c671a56 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
ebrus 0:0a673c671a56 34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
ebrus 0:0a673c671a56 35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
ebrus 0:0a673c671a56 36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
ebrus 0:0a673c671a56 37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ebrus 0:0a673c671a56 38 *
ebrus 0:0a673c671a56 39 ******************************************************************************
ebrus 0:0a673c671a56 40 */
ebrus 0:0a673c671a56 41
ebrus 0:0a673c671a56 42 /* Includes ------------------------------------------------------------------*/
ebrus 0:0a673c671a56 43 #include "stm32f4xx_hal.h"
ebrus 0:0a673c671a56 44
ebrus 0:0a673c671a56 45 /** @addtogroup STM32F4xx_HAL_Driver
ebrus 0:0a673c671a56 46 * @{
ebrus 0:0a673c671a56 47 */
ebrus 0:0a673c671a56 48
ebrus 0:0a673c671a56 49 /** @defgroup PCDEx
ebrus 0:0a673c671a56 50 * @brief PCD Extended HAL module driver
ebrus 0:0a673c671a56 51 * @{
ebrus 0:0a673c671a56 52 */
ebrus 0:0a673c671a56 53
ebrus 0:0a673c671a56 54 #ifdef HAL_PCD_MODULE_ENABLED
ebrus 0:0a673c671a56 55
ebrus 0:0a673c671a56 56 /* Private typedef -----------------------------------------------------------*/
ebrus 0:0a673c671a56 57 /* Private define ------------------------------------------------------------*/
ebrus 0:0a673c671a56 58 /* Private macro -------------------------------------------------------------*/
ebrus 0:0a673c671a56 59 /* Private variables ---------------------------------------------------------*/
ebrus 0:0a673c671a56 60 /* Private function prototypes -----------------------------------------------*/
ebrus 0:0a673c671a56 61 /* Private functions ---------------------------------------------------------*/
ebrus 0:0a673c671a56 62
ebrus 0:0a673c671a56 63 /** @defgroup PCDEx_Private_Functions
ebrus 0:0a673c671a56 64 * @{
ebrus 0:0a673c671a56 65 */
ebrus 0:0a673c671a56 66
ebrus 0:0a673c671a56 67
ebrus 0:0a673c671a56 68 /** @defgroup PCDEx_Group1 Extended features functions
ebrus 0:0a673c671a56 69 * @brief Extended features functions
ebrus 0:0a673c671a56 70 *
ebrus 0:0a673c671a56 71 @verbatim
ebrus 0:0a673c671a56 72 ===============================================================================
ebrus 0:0a673c671a56 73 ##### Extended features functions #####
ebrus 0:0a673c671a56 74 ===============================================================================
ebrus 0:0a673c671a56 75 [..] This section provides functions allowing to:
ebrus 0:0a673c671a56 76 (+) Update FIFO configuration
ebrus 0:0a673c671a56 77
ebrus 0:0a673c671a56 78 @endverbatim
ebrus 0:0a673c671a56 79 * @{
ebrus 0:0a673c671a56 80 */
ebrus 0:0a673c671a56 81
ebrus 0:0a673c671a56 82 /**
ebrus 0:0a673c671a56 83 * @brief Update FIFO configuration
ebrus 0:0a673c671a56 84 * @param hpcd: PCD handle
ebrus 0:0a673c671a56 85 * @retval HAL status
ebrus 0:0a673c671a56 86 */
ebrus 0:0a673c671a56 87 HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size)
ebrus 0:0a673c671a56 88 {
ebrus 0:0a673c671a56 89 uint8_t i = 0;
ebrus 0:0a673c671a56 90 uint32_t Tx_Offset = 0;
ebrus 0:0a673c671a56 91
ebrus 0:0a673c671a56 92 /* TXn min size = 16 words. (n : Transmit FIFO index)
ebrus 0:0a673c671a56 93 When a TxFIFO is not used, the Configuration should be as follows:
ebrus 0:0a673c671a56 94 case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes)
ebrus 0:0a673c671a56 95 --> Txm can use the space allocated for Txn.
ebrus 0:0a673c671a56 96 case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes)
ebrus 0:0a673c671a56 97 --> Txn should be configured with the minimum space of 16 words
ebrus 0:0a673c671a56 98 The FIFO is used optimally when used TxFIFOs are allocated in the top
ebrus 0:0a673c671a56 99 of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones.
ebrus 0:0a673c671a56 100 When DMA is used 3n * FIFO locations should be reserved for internal DMA registers */
ebrus 0:0a673c671a56 101
ebrus 0:0a673c671a56 102 Tx_Offset = hpcd->Instance->GRXFSIZ;
ebrus 0:0a673c671a56 103
ebrus 0:0a673c671a56 104 if(fifo == 0)
ebrus 0:0a673c671a56 105 {
ebrus 0:0a673c671a56 106 hpcd->Instance->DIEPTXF0_HNPTXFSIZ = (size << 16) | Tx_Offset;
ebrus 0:0a673c671a56 107 }
ebrus 0:0a673c671a56 108 else
ebrus 0:0a673c671a56 109 {
ebrus 0:0a673c671a56 110 Tx_Offset += (hpcd->Instance->DIEPTXF0_HNPTXFSIZ) >> 16;
ebrus 0:0a673c671a56 111 for (i = 0; i < (fifo - 1); i++)
ebrus 0:0a673c671a56 112 {
ebrus 0:0a673c671a56 113 Tx_Offset += (hpcd->Instance->DIEPTXF[i] >> 16);
ebrus 0:0a673c671a56 114 }
ebrus 0:0a673c671a56 115
ebrus 0:0a673c671a56 116 /* Multiply Tx_Size by 2 to get higher performance */
ebrus 0:0a673c671a56 117 hpcd->Instance->DIEPTXF[fifo - 1] = (size << 16) | Tx_Offset;
ebrus 0:0a673c671a56 118
ebrus 0:0a673c671a56 119 }
ebrus 0:0a673c671a56 120
ebrus 0:0a673c671a56 121 return HAL_OK;
ebrus 0:0a673c671a56 122 }
ebrus 0:0a673c671a56 123
ebrus 0:0a673c671a56 124 /**
ebrus 0:0a673c671a56 125 * @brief Update FIFO configuration
ebrus 0:0a673c671a56 126 * @param hpcd: PCD handle
ebrus 0:0a673c671a56 127 * @retval HAL status
ebrus 0:0a673c671a56 128 */
ebrus 0:0a673c671a56 129 HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size)
ebrus 0:0a673c671a56 130 {
ebrus 0:0a673c671a56 131
ebrus 0:0a673c671a56 132 hpcd->Instance->GRXFSIZ = size;
ebrus 0:0a673c671a56 133
ebrus 0:0a673c671a56 134 return HAL_OK;
ebrus 0:0a673c671a56 135 }
ebrus 0:0a673c671a56 136
ebrus 0:0a673c671a56 137 /**
ebrus 0:0a673c671a56 138 * @}
ebrus 0:0a673c671a56 139 */
ebrus 0:0a673c671a56 140
ebrus 0:0a673c671a56 141 /**
ebrus 0:0a673c671a56 142 * @}
ebrus 0:0a673c671a56 143 */
ebrus 0:0a673c671a56 144
ebrus 0:0a673c671a56 145 #endif /* HAL_PCD_MODULE_ENABLED */
ebrus 0:0a673c671a56 146 /**
ebrus 0:0a673c671a56 147 * @}
ebrus 0:0a673c671a56 148 */
ebrus 0:0a673c671a56 149
ebrus 0:0a673c671a56 150 /**
ebrus 0:0a673c671a56 151 * @}
ebrus 0:0a673c671a56 152 */
ebrus 0:0a673c671a56 153
ebrus 0:0a673c671a56 154 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/