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