Rev 61 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 61 | Rev 77 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | /** |
1 | /** |
| 2 | ****************************************************************************** |
2 | ****************************************************************************** |
| 3 | * @file stm32l1xx_hal_pcd_ex.c |
3 | * @file stm32l1xx_hal_pcd_ex.c |
| 4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
| 5 | * @brief PCD Extended HAL module driver. |
5 | * @brief PCD Extended HAL module driver. |
| 6 | * This file provides firmware functions to manage the following |
6 | * This file provides firmware functions to manage the following |
| 7 | * functionalities of the USB Peripheral Controller: |
7 | * functionalities of the USB Peripheral Controller: |
| 8 | * + Extended features functions |
8 | * + Extended features functions |
| 9 | * |
9 | * |
| 10 | ****************************************************************************** |
10 | ****************************************************************************** |
| 11 | * @attention |
11 | * @attention |
| 12 | * |
12 | * |
| 13 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
13 | * Copyright (c) 2016 STMicroelectronics. |
| 14 | * All rights reserved.</center></h2> |
14 | * All rights reserved. |
| 15 | * |
15 | * |
| 16 | * This software component is licensed by ST under BSD 3-Clause license, |
16 | * This software is licensed under terms that can be found in the LICENSE file |
| 17 | * the "License"; You may not use this file except in compliance with the |
17 | * in the root directory of this software component. |
| 18 | * License. You may obtain a copy of the License at: |
18 | * If no LICENSE file comes with this software, it is provided AS-IS. |
| 19 | * opensource.org/licenses/BSD-3-Clause |
19 | * |
| 20 | * |
20 | ****************************************************************************** |
| 21 | ****************************************************************************** |
21 | */ |
| 22 | */ |
22 | |
| 23 | 23 | /* Includes ------------------------------------------------------------------*/ |
|
| 24 | /* Includes ------------------------------------------------------------------*/ |
24 | #include "stm32l1xx_hal.h" |
| 25 | #include "stm32l1xx_hal.h" |
25 | |
| 26 | 26 | /** @addtogroup STM32L1xx_HAL_Driver |
|
| 27 | /** @addtogroup STM32L1xx_HAL_Driver |
27 | * @{ |
| 28 | * @{ |
28 | */ |
| 29 | */ |
29 | |
| 30 | 30 | /** @defgroup PCDEx PCDEx |
|
| 31 | /** @defgroup PCDEx PCDEx |
31 | * @brief PCD Extended HAL module driver |
| 32 | * @brief PCD Extended HAL module driver |
32 | * @{ |
| 33 | * @{ |
33 | */ |
| 34 | */ |
34 | |
| 35 | 35 | #ifdef HAL_PCD_MODULE_ENABLED |
|
| 36 | #ifdef HAL_PCD_MODULE_ENABLED |
36 | |
| 37 | 37 | #if defined (USB) |
|
| 38 | #if defined (USB) |
38 | /* Private types -------------------------------------------------------------*/ |
| 39 | /* Private types -------------------------------------------------------------*/ |
39 | /* Private variables ---------------------------------------------------------*/ |
| 40 | /* Private variables ---------------------------------------------------------*/ |
40 | /* Private constants ---------------------------------------------------------*/ |
| 41 | /* Private constants ---------------------------------------------------------*/ |
41 | /* Private macros ------------------------------------------------------------*/ |
| 42 | /* Private macros ------------------------------------------------------------*/ |
42 | /* Private functions ---------------------------------------------------------*/ |
| 43 | /* Private functions ---------------------------------------------------------*/ |
43 | /* Exported functions --------------------------------------------------------*/ |
| 44 | /* Exported functions --------------------------------------------------------*/ |
44 | |
| 45 | 45 | /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions |
|
| 46 | /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions |
46 | * @{ |
| 47 | * @{ |
47 | */ |
| 48 | */ |
48 | |
| 49 | 49 | /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions |
|
| 50 | /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions |
50 | * @brief PCDEx control functions |
| 51 | * @brief PCDEx control functions |
51 | * |
| 52 | * |
52 | @verbatim |
| 53 | @verbatim |
53 | =============================================================================== |
| 54 | =============================================================================== |
54 | ##### Extended features functions ##### |
| 55 | ##### Extended features functions ##### |
55 | =============================================================================== |
| 56 | =============================================================================== |
56 | [..] This section provides functions allowing to: |
| 57 | [..] This section provides functions allowing to: |
57 | (+) Update FIFO configuration |
| 58 | (+) Update FIFO configuration |
58 | |
| 59 | 59 | @endverbatim |
|
| 60 | @endverbatim |
60 | * @{ |
| 61 | * @{ |
61 | */ |
| 62 | */ |
62 | |
| 63 | 63 | /** |
|
| 64 | /** |
64 | * @brief Configure PMA for EP |
| 65 | * @brief Configure PMA for EP |
65 | * @param hpcd Device instance |
| 66 | * @param hpcd Device instance |
66 | * @param ep_addr endpoint address |
| 67 | * @param ep_addr endpoint address |
67 | * @param ep_kind endpoint Kind |
| 68 | * @param ep_kind endpoint Kind |
68 | * USB_SNG_BUF: Single Buffer used |
| 69 | * USB_SNG_BUF: Single Buffer used |
69 | * USB_DBL_BUF: Double Buffer used |
| 70 | * USB_DBL_BUF: Double Buffer used |
70 | * @param pmaadress: EP address in The PMA: In case of single buffer endpoint |
| 71 | * @param pmaadress: EP address in The PMA: In case of single buffer endpoint |
71 | * this parameter is 16-bit value providing the address |
| 72 | * this parameter is 16-bit value providing the address |
72 | * in PMA allocated to endpoint. |
| 73 | * in PMA allocated to endpoint. |
73 | * In case of double buffer endpoint this parameter |
| 74 | * In case of double buffer endpoint this parameter |
74 | * is a 32-bit value providing the endpoint buffer 0 address |
| 75 | * is a 32-bit value providing the endpoint buffer 0 address |
75 | * in the LSB part of 32-bit value and endpoint buffer 1 address |
| 76 | * in the LSB part of 32-bit value and endpoint buffer 1 address |
76 | * in the MSB part of 32-bit value. |
| 77 | * in the MSB part of 32-bit value. |
77 | * @retval HAL status |
| 78 | * @retval HAL status |
78 | */ |
| 79 | */ |
79 | |
| 80 | 80 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, uint16_t ep_addr, |
|
| 81 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, uint16_t ep_addr, |
81 | uint16_t ep_kind, uint32_t pmaadress) |
| 82 | uint16_t ep_kind, uint32_t pmaadress) |
82 | { |
| 83 | { |
83 | PCD_EPTypeDef *ep; |
| 84 | PCD_EPTypeDef *ep; |
84 | |
| 85 | 85 | /* initialize ep structure*/ |
|
| 86 | /* initialize ep structure*/ |
86 | if ((0x80U & ep_addr) == 0x80U) |
| 87 | if ((0x80U & ep_addr) == 0x80U) |
87 | { |
| 88 | { |
88 | ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK]; |
| 89 | ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK]; |
89 | } |
| 90 | } |
90 | else |
| 91 | else |
91 | { |
| 92 | { |
92 | ep = &hpcd->OUT_ep[ep_addr]; |
| 93 | ep = &hpcd->OUT_ep[ep_addr]; |
93 | } |
| 94 | } |
94 | |
| 95 | 95 | /* Here we check if the endpoint is single or double Buffer*/ |
|
| 96 | /* Here we check if the endpoint is single or double Buffer*/ |
96 | if (ep_kind == PCD_SNG_BUF) |
| 97 | if (ep_kind == PCD_SNG_BUF) |
97 | { |
| 98 | { |
98 | /* Single Buffer */ |
| 99 | /* Single Buffer */ |
99 | ep->doublebuffer = 0U; |
| 100 | ep->doublebuffer = 0U; |
100 | /* Configure the PMA */ |
| 101 | /* Configure the PMA */ |
101 | ep->pmaadress = (uint16_t)pmaadress; |
| 102 | ep->pmaadress = (uint16_t)pmaadress; |
102 | } |
| 103 | } |
103 | #if (USE_USB_DOUBLE_BUFFER == 1U) |
| 104 | else /* USB_DBL_BUF */ |
104 | else /* USB_DBL_BUF */ |
| 105 | { |
105 | { |
| 106 | /* Double Buffer Endpoint */ |
106 | /* Double Buffer Endpoint */ |
| 107 | ep->doublebuffer = 1U; |
107 | ep->doublebuffer = 1U; |
| 108 | /* Configure the PMA */ |
108 | /* Configure the PMA */ |
| 109 | ep->pmaaddr0 = (uint16_t)(pmaadress & 0xFFFFU); |
109 | ep->pmaaddr0 = (uint16_t)(pmaadress & 0xFFFFU); |
| 110 | ep->pmaaddr1 = (uint16_t)((pmaadress & 0xFFFF0000U) >> 16); |
110 | ep->pmaaddr1 = (uint16_t)((pmaadress & 0xFFFF0000U) >> 16); |
| 111 | } |
111 | } |
| 112 | 112 | #endif /* (USE_USB_DOUBLE_BUFFER == 1U) */ |
|
| 113 | return HAL_OK; |
113 | |
| 114 | } |
114 | return HAL_OK; |
| 115 | 115 | } |
|
| 116 | /** |
116 | |
| 117 | * @brief Software Device Connection, |
117 | /** |
| 118 | * this function is not required by USB OTG FS peripheral, it is used |
118 | * @brief Software Device Connection, |
| 119 | * only by USB Device FS peripheral. |
119 | * this function is not required by USB OTG FS peripheral, it is used |
| 120 | * @param hpcd PCD handle |
120 | * only by USB Device FS peripheral. |
| 121 | * @param state connection state (0 : disconnected / 1: connected) |
121 | * @param hpcd PCD handle |
| 122 | * @retval None |
122 | * @param state connection state (0 : disconnected / 1: connected) |
| 123 | */ |
123 | * @retval None |
| 124 | __weak void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state) |
124 | */ |
| 125 | { |
125 | __weak void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state) |
| 126 | /* Prevent unused argument(s) compilation warning */ |
126 | { |
| 127 | UNUSED(hpcd); |
127 | /* Prevent unused argument(s) compilation warning */ |
| 128 | UNUSED(state); |
128 | UNUSED(hpcd); |
| 129 | /* NOTE : This function Should not be modified, when the callback is needed, |
129 | UNUSED(state); |
| 130 | the HAL_PCDEx_SetConnectionState could be implemented in the user file |
130 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 131 | */ |
131 | the HAL_PCDEx_SetConnectionState could be implemented in the user file |
| 132 | } |
132 | */ |
| 133 | 133 | } |
|
| 134 | 134 | ||
| 135 | /** |
135 | |
| 136 | * @brief Send LPM message to user layer callback. |
136 | /** |
| 137 | * @param hpcd PCD handle |
137 | * @brief Send LPM message to user layer callback. |
| 138 | * @param msg LPM message |
138 | * @param hpcd PCD handle |
| 139 | * @retval HAL status |
139 | * @param msg LPM message |
| 140 | */ |
140 | * @retval HAL status |
| 141 | __weak void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg) |
141 | */ |
| 142 | { |
142 | __weak void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg) |
| 143 | /* Prevent unused argument(s) compilation warning */ |
143 | { |
| 144 | UNUSED(hpcd); |
144 | /* Prevent unused argument(s) compilation warning */ |
| 145 | UNUSED(msg); |
145 | UNUSED(hpcd); |
| 146 | 146 | UNUSED(msg); |
|
| 147 | /* NOTE : This function should not be modified, when the callback is needed, |
147 | |
| 148 | the HAL_PCDEx_LPM_Callback could be implemented in the user file |
148 | /* NOTE : This function should not be modified, when the callback is needed, |
| 149 | */ |
149 | the HAL_PCDEx_LPM_Callback could be implemented in the user file |
| 150 | } |
150 | */ |
| 151 | 151 | } |
|
| 152 | /** |
152 | |
| 153 | * @brief Send BatteryCharging message to user layer callback. |
153 | /** |
| 154 | * @param hpcd PCD handle |
154 | * @brief Send BatteryCharging message to user layer callback. |
| 155 | * @param msg LPM message |
155 | * @param hpcd PCD handle |
| 156 | * @retval HAL status |
156 | * @param msg LPM message |
| 157 | */ |
157 | * @retval HAL status |
| 158 | __weak void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg) |
158 | */ |
| 159 | { |
159 | __weak void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg) |
| 160 | /* Prevent unused argument(s) compilation warning */ |
160 | { |
| 161 | UNUSED(hpcd); |
161 | /* Prevent unused argument(s) compilation warning */ |
| 162 | UNUSED(msg); |
162 | UNUSED(hpcd); |
| 163 | 163 | UNUSED(msg); |
|
| 164 | /* NOTE : This function should not be modified, when the callback is needed, |
164 | |
| 165 | the HAL_PCDEx_BCD_Callback could be implemented in the user file |
165 | /* NOTE : This function should not be modified, when the callback is needed, |
| 166 | */ |
166 | the HAL_PCDEx_BCD_Callback could be implemented in the user file |
| 167 | } |
167 | */ |
| 168 | 168 | } |
|
| 169 | /** |
169 | |
| 170 | * @} |
170 | /** |
| 171 | */ |
171 | * @} |
| 172 | 172 | */ |
|
| 173 | /** |
173 | |
| 174 | * @} |
174 | /** |
| 175 | */ |
175 | * @} |
| 176 | #endif /* defined (USB) */ |
176 | */ |
| 177 | #endif /* HAL_PCD_MODULE_ENABLED */ |
177 | #endif /* defined (USB) */ |
| 178 | 178 | #endif /* HAL_PCD_MODULE_ENABLED */ |
|
| 179 | /** |
179 | |
| 180 | * @} |
180 | /** |
| 181 | */ |
181 | * @} |
| 182 | 182 | */ |
|
| 183 | /** |
183 | |
| 184 | * @} |
184 | /** |
| 185 | */ |
185 | * @} |
| 186 | 186 | */ |
|
| 187 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
- | |