annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_pcd_ex.c @ 75:2b3f8ed4a0b8

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