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_ll_usb.h |
3 | * @file stm32l1xx_ll_usb.h |
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @brief Header file of USB Low Layer HAL module. |
5 | * @brief Header file of USB Low Layer HAL module. |
6 | ****************************************************************************** |
6 | ****************************************************************************** |
7 | * @attention |
7 | * @attention |
8 | * |
8 | * |
9 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
9 | * Copyright (c) 2016 STMicroelectronics. |
10 | * All rights reserved.</center></h2> |
10 | * All rights reserved. |
11 | * |
11 | * |
12 | * This software component is licensed by ST under BSD 3-Clause license, |
12 | * This software is licensed under terms that can be found in the LICENSE file |
13 | * the "License"; You may not use this file except in compliance with the |
13 | * in the root directory of this software component. |
14 | * License. You may obtain a copy of the License at: |
14 | * If no LICENSE file comes with this software, it is provided AS-IS. |
15 | * opensource.org/licenses/BSD-3-Clause |
15 | * |
16 | * |
16 | ****************************************************************************** |
17 | ****************************************************************************** |
17 | */ |
18 | */ |
18 | |
19 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ |
|
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
20 | #ifndef STM32L1xx_LL_USB_H |
21 | #ifndef STM32L1xx_LL_USB_H |
21 | #define STM32L1xx_LL_USB_H |
22 | #define STM32L1xx_LL_USB_H |
22 | |
23 | 23 | #ifdef __cplusplus |
|
24 | #ifdef __cplusplus |
24 | extern "C" { |
25 | extern "C" { |
25 | #endif /* __cplusplus */ |
26 | #endif |
26 | |
27 | 27 | /* Includes ------------------------------------------------------------------*/ |
|
28 | /* Includes ------------------------------------------------------------------*/ |
28 | #include "stm32l1xx_hal_def.h" |
29 | #include "stm32l1xx_hal_def.h" |
29 | |
30 | 30 | #if defined (USB) |
|
31 | #if defined (USB) |
31 | /** @addtogroup STM32L1xx_HAL_Driver |
32 | /** @addtogroup STM32L1xx_HAL_Driver |
32 | * @{ |
33 | * @{ |
33 | */ |
34 | */ |
34 | |
35 | 35 | /** @addtogroup USB_LL |
|
36 | /** @addtogroup USB_LL |
36 | * @{ |
37 | * @{ |
37 | */ |
38 | */ |
38 | |
39 | 39 | /* Exported types ------------------------------------------------------------*/ |
|
40 | /* Exported types ------------------------------------------------------------*/ |
40 | |
41 | 41 | /** |
|
42 | /** |
42 | * @brief USB Mode definition |
43 | * @brief USB Mode definition |
43 | */ |
44 | */ |
44 | |
45 | 45 | typedef enum |
|
46 | 46 | { |
|
47 | 47 | USB_DEVICE_MODE = 0 |
|
48 | typedef enum |
48 | } USB_ModeTypeDef; |
49 | { |
49 | |
50 | USB_DEVICE_MODE = 0 |
50 | |
51 | } USB_ModeTypeDef; |
51 | /** |
52 | 52 | * @brief USB Instance Initialization Structure definition |
|
53 | /** |
53 | */ |
54 | * @brief USB Initialization Structure definition |
54 | typedef struct |
55 | */ |
55 | { |
56 | typedef struct |
56 | uint32_t dev_endpoints; /*!< Device Endpoints number. |
57 | { |
57 | This parameter depends on the used USB core. |
58 | uint32_t dev_endpoints; /*!< Device Endpoints number. |
58 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
59 | This parameter depends on the used USB core. |
59 | |
60 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
60 | uint32_t speed; /*!< USB Core speed. |
61 | 61 | This parameter can be any value of @ref PCD_Speed/HCD_Speed |
|
62 | uint32_t speed; /*!< USB Core speed. |
62 | (HCD_SPEED_xxx, HCD_SPEED_xxx) */ |
63 | This parameter can be any value of @ref PCD_Speed/HCD_Speed |
63 | |
64 | (HCD_SPEED_xxx, HCD_SPEED_xxx) */ |
64 | uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. */ |
65 | 65 | ||
66 | uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. */ |
66 | uint32_t phy_itface; /*!< Select the used PHY interface. |
67 | 67 | This parameter can be any value of @ref PCD_PHY_Module/HCD_PHY_Module */ |
|
68 | uint32_t phy_itface; /*!< Select the used PHY interface. |
68 | |
69 | This parameter can be any value of @ref PCD_PHY_Module/HCD_PHY_Module */ |
69 | uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */ |
70 | 70 | ||
71 | uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */ |
71 | uint32_t low_power_enable; /*!< Enable or disable the low Power Mode. */ |
72 | 72 | ||
73 | uint32_t low_power_enable; /*!< Enable or disable Low Power mode */ |
73 | uint32_t lpm_enable; /*!< Enable or disable Link Power Management. */ |
74 | 74 | ||
75 | uint32_t lpm_enable; /*!< Enable or disable Battery charging. */ |
75 | uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. */ |
76 | 76 | } USB_CfgTypeDef; |
|
77 | uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. */ |
77 | |
78 | } USB_CfgTypeDef; |
78 | typedef struct |
79 | 79 | { |
|
80 | typedef struct |
80 | uint8_t num; /*!< Endpoint number |
81 | { |
81 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
82 | uint8_t num; /*!< Endpoint number |
82 | |
83 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
83 | uint8_t is_in; /*!< Endpoint direction |
84 | 84 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
|
85 | uint8_t is_in; /*!< Endpoint direction |
85 | |
86 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
86 | uint8_t is_stall; /*!< Endpoint stall condition |
87 | 87 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
|
88 | uint8_t is_stall; /*!< Endpoint stall condition |
88 | |
89 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
89 | uint8_t type; /*!< Endpoint type |
90 | 90 | This parameter can be any value of @ref USB_LL_EP_Type */ |
|
91 | uint8_t type; /*!< Endpoint type |
91 | |
92 | This parameter can be any value of @ref USB_EP_Type */ |
92 | uint8_t data_pid_start; /*!< Initial data PID |
93 | 93 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
|
94 | uint8_t data_pid_start; /*!< Initial data PID |
94 | |
95 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
95 | |
96 | 96 | uint16_t pmaadress; /*!< PMA Address |
|
97 | uint16_t pmaadress; /*!< PMA Address |
97 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
98 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
98 | |
99 | 99 | uint16_t pmaaddr0; /*!< PMA Address0 |
|
100 | uint16_t pmaaddr0; /*!< PMA Address0 |
100 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
101 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
101 | |
102 | 102 | uint16_t pmaaddr1; /*!< PMA Address1 |
|
103 | uint16_t pmaaddr1; /*!< PMA Address1 |
103 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
104 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
104 | |
105 | 105 | uint8_t doublebuffer; /*!< Double buffer enable |
|
106 | uint8_t doublebuffer; /*!< Double buffer enable |
106 | This parameter can be 0 or 1 */ |
107 | This parameter can be 0 or 1 */ |
107 | |
108 | 108 | ||
109 | uint16_t tx_fifo_num; /*!< This parameter is not required by USB Device FS peripheral, it is used |
109 | uint32_t maxpacket; /*!< Endpoint Max packet size |
110 | only by USB OTG FS peripheral |
110 | This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ |
111 | This parameter is added to ensure compatibility across USB peripherals */ |
111 | |
112 | 112 | uint8_t *xfer_buff; /*!< Pointer to transfer buffer */ |
|
113 | uint32_t maxpacket; /*!< Endpoint Max packet size |
113 | |
114 | This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ |
114 | uint32_t xfer_len; /*!< Current transfer length */ |
115 | 115 | ||
116 | uint8_t *xfer_buff; /*!< Pointer to transfer buffer */ |
116 | uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */ |
117 | 117 | ||
118 | uint32_t xfer_len; /*!< Current transfer length */ |
118 | uint32_t xfer_len_db; /*!< double buffer transfer length used with bulk double buffer in */ |
119 | 119 | ||
120 | uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */ |
120 | uint8_t xfer_fill_db; /*!< double buffer Need to Fill new buffer used with bulk_in */ |
121 | 121 | } USB_EPTypeDef; |
|
122 | uint32_t xfer_len_db; /*!< double buffer transfer length used with bulk double buffer in */ |
122 | |
123 | 123 | /* Exported constants --------------------------------------------------------*/ |
|
124 | uint8_t xfer_fill_db; /*!< double buffer Need to Fill new buffer used with bulk_in */ |
124 | |
125 | 125 | /** @defgroup PCD_Exported_Constants PCD Exported Constants |
|
126 | } USB_EPTypeDef; |
126 | * @{ |
127 | 127 | */ |
|
128 | 128 | /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS |
|
129 | /* Exported constants --------------------------------------------------------*/ |
129 | * @{ |
130 | 130 | */ |
|
131 | /** @defgroup PCD_Exported_Constants PCD Exported Constants |
131 | #define EP_MPS_64 0U |
132 | * @{ |
132 | #define EP_MPS_32 1U |
133 | */ |
133 | #define EP_MPS_16 2U |
134 | 134 | #define EP_MPS_8 3U |
|
135 | 135 | /** |
|
136 | /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS |
136 | * @} |
137 | * @{ |
137 | */ |
138 | */ |
138 | |
139 | #define EP_MPS_64 0U |
139 | /** @defgroup USB_LL_EP_Type USB Low Layer EP Type |
140 | #define EP_MPS_32 1U |
140 | * @{ |
141 | #define EP_MPS_16 2U |
141 | */ |
142 | #define EP_MPS_8 3U |
142 | #define EP_TYPE_CTRL 0U |
143 | /** |
143 | #define EP_TYPE_ISOC 1U |
144 | * @} |
144 | #define EP_TYPE_BULK 2U |
145 | */ |
145 | #define EP_TYPE_INTR 3U |
146 | 146 | #define EP_TYPE_MSK 3U |
|
147 | /** @defgroup USB_LL_EP_Type USB Low Layer EP Type |
147 | /** |
148 | * @{ |
148 | * @} |
149 | */ |
149 | */ |
150 | #define EP_TYPE_CTRL 0U |
150 | |
151 | #define EP_TYPE_ISOC 1U |
151 | /** @defgroup USB_LL Device Speed |
152 | #define EP_TYPE_BULK 2U |
152 | * @{ |
153 | #define EP_TYPE_INTR 3U |
153 | */ |
154 | #define EP_TYPE_MSK 3U |
154 | #define USBD_FS_SPEED 2U |
155 | /** |
155 | /** |
156 | * @} |
156 | * @} |
157 | */ |
157 | */ |
158 | 158 | ||
159 | /** @defgroup USB_LL Device Speed |
159 | |
160 | * @{ |
160 | #define BTABLE_ADDRESS 0x000U |
161 | */ |
161 | #define PMA_ACCESS 2U |
162 | #define USBD_FS_SPEED 2U |
162 | |
163 | /** |
163 | #ifndef USB_EP_RX_STRX |
164 | * @} |
164 | #define USB_EP_RX_STRX (0x3U << 12) |
165 | */ |
165 | #endif /* USB_EP_RX_STRX */ |
166 | 166 | ||
167 | #define BTABLE_ADDRESS 0x000U |
167 | #define EP_ADDR_MSK 0x7U |
168 | #define PMA_ACCESS 2U |
168 | |
169 | 169 | #ifndef USE_USB_DOUBLE_BUFFER |
|
170 | #define EP_ADDR_MSK 0x7U |
170 | #define USE_USB_DOUBLE_BUFFER 1U |
171 | /** |
171 | #endif /* USE_USB_DOUBLE_BUFFER */ |
172 | * @} |
172 | |
173 | */ |
173 | |
174 | 174 | /** |
|
175 | /* Exported macro ------------------------------------------------------------*/ |
175 | * @} |
176 | /** |
176 | */ |
177 | * @} |
177 | |
178 | */ |
178 | /* Exported macro ------------------------------------------------------------*/ |
179 | 179 | /** |
|
180 | /* Exported functions --------------------------------------------------------*/ |
180 | * @} |
181 | /** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions |
181 | */ |
182 | * @{ |
182 | |
183 | */ |
183 | /* Exported functions --------------------------------------------------------*/ |
184 | 184 | /** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions |
|
185 | 185 | * @{ |
|
186 | HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg); |
186 | */ |
187 | HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg); |
187 | |
188 | HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx); |
188 | |
189 | HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx); |
189 | HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg); |
190 | HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode); |
190 | HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg); |
191 | 191 | HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx); |
|
192 | #if defined (HAL_PCD_MODULE_ENABLED) |
192 | HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx); |
193 | HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
193 | HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode); |
194 | HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
194 | |
195 | HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
195 | HAL_StatusTypeDef USB_FlushRxFifo(USB_TypeDef const *USBx); |
196 | HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
196 | HAL_StatusTypeDef USB_FlushTxFifo(USB_TypeDef const *USBx, uint32_t num); |
197 | HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
197 | |
198 | #endif |
198 | #if defined (HAL_PCD_MODULE_ENABLED) |
199 | 199 | HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
|
200 | HAL_StatusTypeDef USB_SetDevAddress(USB_TypeDef *USBx, uint8_t address); |
200 | HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
201 | HAL_StatusTypeDef USB_DevConnect(USB_TypeDef *USBx); |
201 | HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
202 | HAL_StatusTypeDef USB_DevDisconnect(USB_TypeDef *USBx); |
202 | HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
203 | HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx); |
203 | HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
204 | uint32_t USB_ReadInterrupts(USB_TypeDef *USBx); |
204 | HAL_StatusTypeDef USB_EPStopXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
205 | HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx); |
205 | #endif /* defined (HAL_PCD_MODULE_ENABLED) */ |
206 | HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx); |
206 | |
207 | 207 | HAL_StatusTypeDef USB_SetDevAddress(USB_TypeDef *USBx, uint8_t address); |
|
208 | void USB_WritePMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, |
208 | HAL_StatusTypeDef USB_DevConnect(USB_TypeDef *USBx); |
209 | uint16_t wPMABufAddr, uint16_t wNBytes); |
209 | HAL_StatusTypeDef USB_DevDisconnect(USB_TypeDef *USBx); |
210 | 210 | HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx); |
|
211 | void USB_ReadPMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, |
211 | uint32_t USB_ReadInterrupts(USB_TypeDef const *USBx); |
212 | uint16_t wPMABufAddr, uint16_t wNBytes); |
212 | HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx); |
213 | 213 | HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx); |
|
214 | /** |
214 | |
215 | * @} |
215 | void USB_WritePMA(USB_TypeDef const *USBx, uint8_t *pbUsrBuf, |
216 | */ |
216 | uint16_t wPMABufAddr, uint16_t wNBytes); |
217 | 217 | ||
218 | /** |
218 | void USB_ReadPMA(USB_TypeDef const *USBx, uint8_t *pbUsrBuf, |
219 | * @} |
219 | uint16_t wPMABufAddr, uint16_t wNBytes); |
220 | */ |
220 | |
221 | 221 | /** |
|
222 | /** |
222 | * @} |
223 | * @} |
223 | */ |
224 | */ |
224 | |
225 | 225 | /** |
|
226 | /** |
226 | * @} |
227 | * @} |
227 | */ |
228 | */ |
228 | |
229 | #endif /* defined (USB) */ |
229 | /** |
230 | 230 | * @} |
|
231 | #ifdef __cplusplus |
231 | */ |
232 | } |
232 | |
233 | #endif |
233 | /** |
234 | 234 | * @} |
|
235 | 235 | */ |
|
236 | #endif /* STM32L1xx_LL_USB_H */ |
236 | #endif /* defined (USB) */ |
237 | 237 | ||
238 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
238 | #ifdef __cplusplus |
- | 239 | } |
|
- | 240 | #endif /* __cplusplus */ |
|
- | 241 | ||
- | 242 | ||
- | 243 | #endif /* STM32L1xx_LL_USB_H */ |