annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_hcd.c @ 162:ad98da7e74f8 linux-build

OSTC4pack_V4: do not hard code output filename for fonts ... and be a bit more polite. When called without parameters, the packer simply crashed. Now, print a trivial usage line. But the real change is, not hard coding the fonts output file name. This is simply not flexible and inconvenient. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Thu, 21 Feb 2019 10:29:26 +0100
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_hcd.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 HCD 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 * + Initialization and de-initialization functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 * + IO operation functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 * + Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 * + Peripheral State functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 ##### How to use this driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 (#)Declare a HCD_HandleTypeDef handle structure, for example:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 HCD_HandleTypeDef hhcd;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 (#)Fill parameters of Init structure in HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 (#)Call HAL_HCD_Init() API to initialize the HCD peripheral (Core, Host core, ...)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 (#)Initialize the HCD low level resources through the HAL_HCD_MspInit() API:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 (##) Enable the HCD/USB Low Level interface clock using the following macros
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 (+++) __OTGFS-OTG_CLK_ENABLE() or __OTGHS-OTG_CLK_ENABLE()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 (+++) __OTGHSULPI_CLK_ENABLE() For High Speed Mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 (##) Initialize the related GPIO clocks
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 (##) Configure HCD pin-out
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 (##) Configure HCD NVIC interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 (#)Associate the Upper USB Host stack to the HAL HCD Driver:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 (##) hhcd.pData = phost;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 (#)Enable HCD transmission and reception:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 (##) HAL_HCD_Start();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 * Redistribution and use in source and binary forms, with or without modification,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 * are permitted provided that the following conditions are met:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 * 1. Redistributions of source code must retain the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 * this list of conditions and the following disclaimer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 * 2. Redistributions in binary form must reproduce the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 * this list of conditions and the following disclaimer in the documentation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 * and/or other materials provided with the distribution.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 * 3. Neither the name of STMicroelectronics nor the names of its contributors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 * may be used to endorse or promote products derived from this software
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 * without specific prior written permission.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 /** @addtogroup STM32F4xx_HAL_Driver
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 /** @addtogroup HCD
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 #ifdef HAL_HCD_MODULE_ENABLED
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 /* Private typedef -----------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 /* Private define ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 /* Private macro -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 /* Private function ----------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 /** @addtogroup HCD_Private_Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 static void HCD_HC_IN_IRQHandler(HCD_HandleTypeDef *hhcd, uint8_t chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 static void HCD_HC_OUT_IRQHandler(HCD_HandleTypeDef *hhcd, uint8_t chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 static void HCD_RXQLVL_IRQHandler(HCD_HandleTypeDef *hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 static void HCD_Port_IRQHandler(HCD_HandleTypeDef *hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 /** @addtogroup HCD_Exported_Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 /** @addtogroup HCD_Exported_Functions_Group1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 * @brief Initialization and de-initialization functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 ##### Initialization and de-initialization functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 [..] This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 * @{
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 * @brief Initialize the host driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 HAL_StatusTypeDef HAL_HCD_Init(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 /* Check the HCD handle allocation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 if(hhcd == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 assert_param(IS_HCD_ALL_INSTANCE(hhcd->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 hhcd->State = HAL_HCD_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 /* Init the low level hardware : GPIO, CLOCK, NVIC... */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 HAL_HCD_MspInit(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 /* Disable the Interrupts */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 __HAL_HCD_DISABLE(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 /* Init the Core (common init.) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 USB_CoreInit(hhcd->Instance, hhcd->Init);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 /* Force Host Mode*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 USB_SetCurrentMode(hhcd->Instance , USB_OTG_HOST_MODE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 /* Init Host */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 USB_HostInit(hhcd->Instance, hhcd->Init);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 hhcd->State= HAL_HCD_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 * @brief Initialize a host channel
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 * @param ch_num: Channel number.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 * This parameter can be a value from 1 to 15
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 * @param epnum: Endpoint number.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 * This parameter can be a value from 1 to 15
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 * @param dev_address : Current device address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 * This parameter can be a value from 0 to 255
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 * @param speed: Current device speed.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 * This parameter can be one of these values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 * HCD_SPEED_HIGH: High speed mode,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 * HCD_SPEED_FULL: Full speed mode,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 * HCD_SPEED_LOW: Low speed mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 * @param ep_type: Endpoint Type.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 * This parameter can be one of these values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 * EP_TYPE_CTRL: Control type,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 * EP_TYPE_ISOC: Isochronous type,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 * EP_TYPE_BULK: Bulk type,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 * EP_TYPE_INTR: Interrupt type
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 * @param mps: Max Packet Size.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 * This parameter can be a value from 0 to32K
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 HAL_StatusTypeDef HAL_HCD_HC_Init(HCD_HandleTypeDef *hhcd,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 uint8_t ch_num,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 uint8_t epnum,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 uint8_t dev_address,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 uint8_t speed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 uint8_t ep_type,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 uint16_t mps)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 HAL_StatusTypeDef status = HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 __HAL_LOCK(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 hhcd->hc[ch_num].dev_addr = dev_address;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 hhcd->hc[ch_num].max_packet = mps;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 hhcd->hc[ch_num].ch_num = ch_num;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 hhcd->hc[ch_num].ep_type = ep_type;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 hhcd->hc[ch_num].ep_num = epnum & 0x7F;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 hhcd->hc[ch_num].ep_is_in = ((epnum & 0x80) == 0x80);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 hhcd->hc[ch_num].speed = speed;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 status = USB_HC_Init(hhcd->Instance,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 ch_num,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 epnum,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 dev_address,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 speed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 ep_type,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 mps);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 __HAL_UNLOCK(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 return status;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 * @brief Halt a host channel
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 * @param ch_num: Channel number.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 * This parameter can be a value from 1 to 15
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 HAL_StatusTypeDef HAL_HCD_HC_Halt(HCD_HandleTypeDef *hhcd, uint8_t ch_num)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 HAL_StatusTypeDef status = HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 __HAL_LOCK(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 USB_HC_Halt(hhcd->Instance, ch_num);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 __HAL_UNLOCK(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 return status;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 * @brief DeInitialize the host driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 HAL_StatusTypeDef HAL_HCD_DeInit(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 /* Check the HCD handle allocation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 if(hhcd == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 hhcd->State = HAL_HCD_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 /* DeInit the low level hardware */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 HAL_HCD_MspDeInit(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 __HAL_HCD_DISABLE(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 hhcd->State = HAL_HCD_STATE_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 * @brief Initializes the HCD MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 __weak void HAL_HCD_MspInit(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 the HAL_PCD_MspInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 * @brief DeInitializes HCD MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 __weak void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 the HAL_PCD_MspDeInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 /** @addtogroup HCD_Exported_Functions_Group2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 * @brief HCD IO operation functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 ##### IO operation functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 This subsection provides a set of functions allowing to manage the USB Host Data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 Transfer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 * @brief Submit a new URB for processing
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 * @param ch_num: Channel number.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 * This parameter can be a value from 1 to 15
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 * @param direction: Channel number.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 * This parameter can be one of these values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 * 0 : Output / 1 : Input
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 * @param ep_type: Endpoint Type.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 * This parameter can be one of these values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 * EP_TYPE_CTRL: Control type/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 * EP_TYPE_ISOC: Isochronous type/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 * EP_TYPE_BULK: Bulk type/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 * EP_TYPE_INTR: Interrupt type/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 * @param token: Endpoint Type.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 * This parameter can be one of these values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 * 0: HC_PID_SETUP / 1: HC_PID_DATA1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 * @param pbuff: pointer to URB data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 * @param length: Length of URB data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 * @param do_ping: activate do ping protocol (for high speed only).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 * This parameter can be one of these values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 * 0 : do ping inactive / 1 : do ping active
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 HAL_StatusTypeDef HAL_HCD_HC_SubmitRequest(HCD_HandleTypeDef *hhcd,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 uint8_t ch_num,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 uint8_t direction,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 uint8_t ep_type,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 uint8_t token,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 uint8_t* pbuff,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 uint16_t length,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 uint8_t do_ping)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 hhcd->hc[ch_num].ep_is_in = direction;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 hhcd->hc[ch_num].ep_type = ep_type;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 if(token == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 hhcd->hc[ch_num].data_pid = HC_PID_SETUP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 hhcd->hc[ch_num].data_pid = HC_PID_DATA1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 /* Manage Data Toggle */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 switch(ep_type)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 case EP_TYPE_CTRL:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 if((token == 1) && (direction == 0)) /*send data */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 if ( length == 0 )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 { /* For Status OUT stage, Length==0, Status Out PID = 1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 hhcd->hc[ch_num].toggle_out = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 /* Set the Data Toggle bit as per the Flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 if ( hhcd->hc[ch_num].toggle_out == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 { /* Put the PID 0 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 hhcd->hc[ch_num].data_pid = HC_PID_DATA0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 { /* Put the PID 1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 hhcd->hc[ch_num].data_pid = HC_PID_DATA1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 if(hhcd->hc[ch_num].urb_state != URB_NOTREADY)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 hhcd->hc[ch_num].do_ping = do_ping;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 case EP_TYPE_BULK:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 if(direction == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 /* Set the Data Toggle bit as per the Flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 if ( hhcd->hc[ch_num].toggle_out == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 { /* Put the PID 0 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 hhcd->hc[ch_num].data_pid = HC_PID_DATA0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 { /* Put the PID 1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 hhcd->hc[ch_num].data_pid = HC_PID_DATA1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 if(hhcd->hc[ch_num].urb_state != URB_NOTREADY)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 hhcd->hc[ch_num].do_ping = do_ping;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 if( hhcd->hc[ch_num].toggle_in == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 hhcd->hc[ch_num].data_pid = HC_PID_DATA0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 hhcd->hc[ch_num].data_pid = HC_PID_DATA1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 case EP_TYPE_INTR:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 if(direction == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 /* Set the Data Toggle bit as per the Flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 if ( hhcd->hc[ch_num].toggle_out == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 { /* Put the PID 0 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 hhcd->hc[ch_num].data_pid = HC_PID_DATA0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 { /* Put the PID 1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 hhcd->hc[ch_num].data_pid = HC_PID_DATA1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 if( hhcd->hc[ch_num].toggle_in == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 hhcd->hc[ch_num].data_pid = HC_PID_DATA0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 hhcd->hc[ch_num].data_pid = HC_PID_DATA1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 case EP_TYPE_ISOC:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 hhcd->hc[ch_num].data_pid = HC_PID_DATA0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 hhcd->hc[ch_num].xfer_buff = pbuff;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 hhcd->hc[ch_num].xfer_len = length;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 hhcd->hc[ch_num].urb_state = URB_IDLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 hhcd->hc[ch_num].xfer_count = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 hhcd->hc[ch_num].ch_num = ch_num;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 hhcd->hc[ch_num].state = HC_IDLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 return USB_HC_StartXfer(hhcd->Instance, &(hhcd->hc[ch_num]), hhcd->Init.dma_enable);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 * @brief This function handles HCD interrupt request.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 void HAL_HCD_IRQHandler(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 USB_OTG_GlobalTypeDef *USBx = hhcd->Instance;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 uint32_t i = 0 , interrupt = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 /* Ensure that we are in device mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 if (USB_GetMode(hhcd->Instance) == USB_OTG_MODE_HOST)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 /* Avoid spurious interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 if(__HAL_HCD_IS_INVALID_INTERRUPT(hhcd))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 if(__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_PXFR_INCOMPISOOUT))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 /* Incorrect mode, acknowledge the interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 __HAL_HCD_CLEAR_FLAG(hhcd, USB_OTG_GINTSTS_PXFR_INCOMPISOOUT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 if(__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_IISOIXFR))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 /* Incorrect mode, acknowledge the interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 __HAL_HCD_CLEAR_FLAG(hhcd, USB_OTG_GINTSTS_IISOIXFR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 if(__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_PTXFE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 /* Incorrect mode, acknowledge the interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 __HAL_HCD_CLEAR_FLAG(hhcd, USB_OTG_GINTSTS_PTXFE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 if(__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_MMIS))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 /* Incorrect mode, acknowledge the interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 __HAL_HCD_CLEAR_FLAG(hhcd, USB_OTG_GINTSTS_MMIS);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 /* Handle Host Disconnect Interrupts */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 if(__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_DISCINT))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 /* Cleanup HPRT */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 USBx_HPRT0 &= ~(USB_OTG_HPRT_PENA | USB_OTG_HPRT_PCDET |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 USB_OTG_HPRT_PENCHNG | USB_OTG_HPRT_POCCHNG );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 /* Handle Host Port Interrupts */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 HAL_HCD_Disconnect_Callback(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 USB_InitFSLSPClkSel(hhcd->Instance ,HCFG_48_MHZ );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 __HAL_HCD_CLEAR_FLAG(hhcd, USB_OTG_GINTSTS_DISCINT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 /* Handle Host Port Interrupts */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 if(__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_HPRTINT))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 HCD_Port_IRQHandler (hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 /* Handle Host SOF Interrupts */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 if(__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_SOF))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 HAL_HCD_SOF_Callback(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 __HAL_HCD_CLEAR_FLAG(hhcd, USB_OTG_GINTSTS_SOF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 /* Handle Host channel Interrupts */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 if(__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_HCINT))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 interrupt = USB_HC_ReadInterrupt(hhcd->Instance);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 for (i = 0; i < hhcd->Init.Host_channels; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518 if (interrupt & (1 << i))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 if ((USBx_HC(i)->HCCHAR) & USB_OTG_HCCHAR_EPDIR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522 HCD_HC_IN_IRQHandler(hhcd, i);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 HCD_HC_OUT_IRQHandler (hhcd, i);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 __HAL_HCD_CLEAR_FLAG(hhcd, USB_OTG_GINTSTS_HCINT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 /* Handle Rx Queue Level Interrupts */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 if(__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_RXFLVL))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 USB_MASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_RXFLVL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 HCD_RXQLVL_IRQHandler (hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 USB_UNMASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_RXFLVL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 * @brief SOF callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 __weak void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 the HAL_HCD_SOF_Callback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 * @brief Connexion Event callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562 __weak void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565 the HAL_HCD_Connect_Callback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 * @brief Disconnexion Event callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 __weak void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 the HAL_HCD_Disconnect_Callback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582 * @brief Notify URB state change callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 * @param chnum: Channel number.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585 * This parameter can be a value from 1 to 15
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586 * @param urb_state:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587 * This parameter can be one of these values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588 * URB_IDLE/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589 * URB_DONE/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 * URB_NOTREADY/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 * URB_NYET/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592 * URB_ERROR/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593 * URB_STALL/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596 __weak void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
598 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599 the HAL_HCD_HC_NotifyURBChange_Callback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
600 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
601 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
602
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607 /** @addtogroup HCD_Exported_Functions_Group3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 * @brief Peripheral State functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
609 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612 ##### Peripheral Control functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
614 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615 This subsection provides a set of functions allowing to control the HCD data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616 transfers.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
620 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
621
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623 * @brief Start the host driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627 HAL_StatusTypeDef HAL_HCD_Start(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
628 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
629 __HAL_LOCK(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
630 __HAL_HCD_ENABLE(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
631 USB_DriveVbus(hhcd->Instance, 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
632 __HAL_UNLOCK(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
633 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
636 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
637 * @brief Stop the host driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
638 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
639 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
640 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
641
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
642 HAL_StatusTypeDef HAL_HCD_Stop(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
643 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
644 __HAL_LOCK(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
645 USB_StopHost(hhcd->Instance);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
646 __HAL_UNLOCK(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
647 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
648 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
649
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
650 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
651 * @brief Reset the host port
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
652 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
653 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
655 HAL_StatusTypeDef HAL_HCD_ResetPort(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
656 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
657 return (USB_ResetPort(hhcd->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
658 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
659
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
660 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
661 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
662 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
663
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
664 /** @addtogroup HCD_Exported_Functions_Group4
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
665 * @brief Peripheral State functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
666 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
667 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
668 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
669 ##### Peripheral State functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
670 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
671 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
672 This subsection permits to get in run-time the status of the peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
673 and the data flow.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
674
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
676 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
677 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
679 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
680 * @brief Return the HCD state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
681 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
682 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
683 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
684 HCD_StateTypeDef HAL_HCD_GetState(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
685 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
686 return hhcd->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
687 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
688
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
689 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
690 * @brief Return URB state for a channel
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
691 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
692 * @param chnum: Channel number.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
693 * This parameter can be a value from 1 to 15
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
694 * @retval URB state.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
695 * This parameter can be one of these values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
696 * URB_IDLE/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
697 * URB_DONE/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
698 * URB_NOTREADY/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
699 * URB_NYET/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
700 * URB_ERROR/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
701 * URB_STALL/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
702 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
703 HCD_URBStateTypeDef HAL_HCD_HC_GetURBState(HCD_HandleTypeDef *hhcd, uint8_t chnum)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
704 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
705 return hhcd->hc[chnum].urb_state;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
706 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
707
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
708
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
709 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
710 * @brief Return the last host transfer size
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
711 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
712 * @param chnum: Channel number.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
713 * This parameter can be a value from 1 to 15
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
714 * @retval last transfer size in byte
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
715 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
716 uint32_t HAL_HCD_HC_GetXferCount(HCD_HandleTypeDef *hhcd, uint8_t chnum)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
717 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
718 return hhcd->hc[chnum].xfer_count;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
719 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
720
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
721 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
722 * @brief Return the Host Channel state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
723 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
724 * @param chnum: Channel number.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
725 * This parameter can be a value from 1 to 15
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
726 * @retval Host channel state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
727 * This parameter can be one of the these values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
728 * HC_IDLE/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
729 * HC_XFRC/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
730 * HC_HALTED/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
731 * HC_NYET/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
732 * HC_NAK/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
733 * HC_STALL/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
734 * HC_XACTERR/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
735 * HC_BBLERR/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
736 * HC_DATATGLERR/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
737 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
738 HCD_HCStateTypeDef HAL_HCD_HC_GetState(HCD_HandleTypeDef *hhcd, uint8_t chnum)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
739 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
740 return hhcd->hc[chnum].state;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
741 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
742
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
743 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
744 * @brief Return the current Host frame number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
745 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
746 * @retval Current Host frame number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
747 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
748 uint32_t HAL_HCD_GetCurrentFrame(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
749 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
750 return (USB_GetCurrentFrame(hhcd->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
751 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
752
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
753 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
754 * @brief Return the Host enumeration speed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
755 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
756 * @retval Enumeration speed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
757 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
758 uint32_t HAL_HCD_GetCurrentSpeed(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
759 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
760 return (USB_GetHostSpeed(hhcd->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
761 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
762 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
763 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
764 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
765
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
766 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
767 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
768 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
769
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
770 /** @addtogroup HCD_Private_Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
771 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
772 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
773 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
774 * @brief This function handles Host Channel IN interrupt requests.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
775 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
776 * @param chnum: Channel number.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
777 * This parameter can be a value from 1 to 15
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
778 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
779 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
780 static void HCD_HC_IN_IRQHandler(HCD_HandleTypeDef *hhcd, uint8_t chnum)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
781 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
782 USB_OTG_GlobalTypeDef *USBx = hhcd->Instance;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
783
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
784 if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_AHBERR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
785 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
786 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_AHBERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
787 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
788 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
789 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_ACK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
790 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
791 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_ACK);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
792 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
793
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
794 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_STALL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
795 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
796 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
797 hhcd->hc[chnum].state = HC_STALL;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
798 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_NAK);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
799 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_STALL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
800 USB_HC_Halt(hhcd->Instance, chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
801 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
802 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_DTERR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
803 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
804 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
805 USB_HC_Halt(hhcd->Instance, chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
806 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_NAK);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
807 hhcd->hc[chnum].state = HC_DATATGLERR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
808 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_DTERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
809 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
810
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
811 if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_FRMOR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
812 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
813 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
814 USB_HC_Halt(hhcd->Instance, chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
815 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_FRMOR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
816 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
817
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
818 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_XFRC)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
819 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
820
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
821 if (hhcd->Init.dma_enable)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
822 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
823 hhcd->hc[chnum].xfer_count = hhcd->hc[chnum].xfer_len - \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
824 (USBx_HC(chnum)->HCTSIZ & USB_OTG_HCTSIZ_XFRSIZ);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
825 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
826
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
827 hhcd->hc[chnum].state = HC_XFRC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
828 hhcd->hc[chnum].ErrCnt = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
829 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_XFRC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
830
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
831
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
832 if ((hhcd->hc[chnum].ep_type == EP_TYPE_CTRL)||
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
833 (hhcd->hc[chnum].ep_type == EP_TYPE_BULK))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
834 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
835 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
836 USB_HC_Halt(hhcd->Instance, chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
837 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_NAK);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
838
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
839 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
840 else if(hhcd->hc[chnum].ep_type == EP_TYPE_INTR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
841 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
842 USBx_HC(chnum)->HCCHAR |= USB_OTG_HCCHAR_ODDFRM;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
843 hhcd->hc[chnum].urb_state = URB_DONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
844 HAL_HCD_HC_NotifyURBChange_Callback(hhcd, chnum, hhcd->hc[chnum].urb_state);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
845 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
846 hhcd->hc[chnum].toggle_in ^= 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
847
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
848 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
849 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_CHH)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
850 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
851 __HAL_HCD_MASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
852
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
853 if(hhcd->hc[chnum].state == HC_XFRC)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
854 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
855 hhcd->hc[chnum].urb_state = URB_DONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
856 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
857
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
858 else if (hhcd->hc[chnum].state == HC_STALL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
859 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
860 hhcd->hc[chnum].urb_state = URB_STALL;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
861 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
862
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
863 else if((hhcd->hc[chnum].state == HC_XACTERR) ||
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
864 (hhcd->hc[chnum].state == HC_DATATGLERR))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
865 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
866 if(hhcd->hc[chnum].ErrCnt++ > 3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
867 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
868 hhcd->hc[chnum].ErrCnt = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
869 hhcd->hc[chnum].urb_state = URB_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
870 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
871 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
872 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
873 hhcd->hc[chnum].urb_state = URB_NOTREADY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
874 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
875
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
876 /* re-activate the channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
877 USBx_HC(chnum)->HCCHAR &= ~USB_OTG_HCCHAR_CHDIS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
878 USBx_HC(chnum)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
879 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
880 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_CHH);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
881 HAL_HCD_HC_NotifyURBChange_Callback(hhcd, chnum, hhcd->hc[chnum].urb_state);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
882 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
883
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
884 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_TXERR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
885 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
886 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
887 hhcd->hc[chnum].ErrCnt++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
888 hhcd->hc[chnum].state = HC_XACTERR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
889 USB_HC_Halt(hhcd->Instance, chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
890 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_TXERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
891 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
892 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_NAK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
893 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
894 if(hhcd->hc[chnum].ep_type == EP_TYPE_INTR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
895 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
896 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
897 USB_HC_Halt(hhcd->Instance, chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
898 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
899 else if ((hhcd->hc[chnum].ep_type == EP_TYPE_CTRL)||
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
900 (hhcd->hc[chnum].ep_type == EP_TYPE_BULK))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
901 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
902 /* re-activate the channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
903 USBx_HC(chnum)->HCCHAR &= ~USB_OTG_HCCHAR_CHDIS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
904 USBx_HC(chnum)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
905
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
906 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
907 hhcd->hc[chnum].state = HC_NAK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
908 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_NAK);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
909 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
910 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
911
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
912 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
913 * @brief This function handles Host Channel OUT interrupt requests.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
914 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
915 * @param chnum: Channel number.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
916 * This parameter can be a value from 1 to 15
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
917 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
918 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
919 static void HCD_HC_OUT_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
920 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
921 USB_OTG_GlobalTypeDef *USBx = hhcd->Instance;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
922
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
923 if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_AHBERR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
924 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
925 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_AHBERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
926 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
927 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
928 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_ACK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
929 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
930 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_ACK);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
931
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
932 if( hhcd->hc[chnum].do_ping == 1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
933 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
934 hhcd->hc[chnum].state = HC_NYET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
935 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
936 USB_HC_Halt(hhcd->Instance, chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
937 hhcd->hc[chnum].urb_state = URB_NOTREADY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
938 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
939 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
940
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
941 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_NYET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
942 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
943 hhcd->hc[chnum].state = HC_NYET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
944 hhcd->hc[chnum].ErrCnt= 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
945 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
946 USB_HC_Halt(hhcd->Instance, chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
947 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_NYET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
948
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
949 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
950
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
951 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_FRMOR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
952 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
953 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
954 USB_HC_Halt(hhcd->Instance, chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
955 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_FRMOR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
956 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
957
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
958 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_XFRC)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
959 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
960 hhcd->hc[chnum].ErrCnt = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
961 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
962 USB_HC_Halt(hhcd->Instance, chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
963 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_XFRC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
964 hhcd->hc[chnum].state = HC_XFRC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
965
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
966 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
967
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
968 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_STALL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
969 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
970 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_STALL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
971 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
972 USB_HC_Halt(hhcd->Instance, chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
973 hhcd->hc[chnum].state = HC_STALL;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
974 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
975
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
976 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_NAK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
977 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
978 hhcd->hc[chnum].ErrCnt = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
979 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
980 USB_HC_Halt(hhcd->Instance, chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
981 hhcd->hc[chnum].state = HC_NAK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
982 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_NAK);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
983 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
984
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
985 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_TXERR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
986 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
987 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
988 USB_HC_Halt(hhcd->Instance, chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
989 hhcd->hc[chnum].state = HC_XACTERR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
990 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_TXERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
991 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
992
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
993 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_DTERR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
994 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
995 __HAL_HCD_UNMASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
996 USB_HC_Halt(hhcd->Instance, chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
997 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_NAK);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
998 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_DTERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
999 hhcd->hc[chnum].state = HC_DATATGLERR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1000 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1001
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1002
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1003 else if ((USBx_HC(chnum)->HCINT) & USB_OTG_HCINT_CHH)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1004 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1005 __HAL_HCD_MASK_HALT_HC_INT(chnum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1006
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1007 if(hhcd->hc[chnum].state == HC_XFRC)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1008 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1009 hhcd->hc[chnum].urb_state = URB_DONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1010 if (hhcd->hc[chnum].ep_type == EP_TYPE_BULK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1011 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1012 hhcd->hc[chnum].toggle_out ^= 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1013 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1014 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1015 else if (hhcd->hc[chnum].state == HC_NAK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1016 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1017 hhcd->hc[chnum].urb_state = URB_NOTREADY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1018 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1019
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1020 else if (hhcd->hc[chnum].state == HC_NYET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1021 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1022 hhcd->hc[chnum].urb_state = URB_NOTREADY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1023 hhcd->hc[chnum].do_ping = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1024 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1025
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1026 else if (hhcd->hc[chnum].state == HC_STALL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1027 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1028 hhcd->hc[chnum].urb_state = URB_STALL;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1029 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1030
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1031 else if((hhcd->hc[chnum].state == HC_XACTERR) ||
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1032 (hhcd->hc[chnum].state == HC_DATATGLERR))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1033 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1034 if(hhcd->hc[chnum].ErrCnt++ > 3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1035 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1036 hhcd->hc[chnum].ErrCnt = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1037 hhcd->hc[chnum].urb_state = URB_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1038 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1039 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1040 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1041 hhcd->hc[chnum].urb_state = URB_NOTREADY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1042 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1043
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1044 /* re-activate the channel */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1045 USBx_HC(chnum)->HCCHAR &= ~USB_OTG_HCCHAR_CHDIS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1046 USBx_HC(chnum)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1047 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1048
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1049 __HAL_HCD_CLEAR_HC_INT(chnum, USB_OTG_HCINT_CHH);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1050 HAL_HCD_HC_NotifyURBChange_Callback(hhcd, chnum, hhcd->hc[chnum].urb_state);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1051 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1052 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1053
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1054 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1055 * @brief This function handles Rx Queue Level interrupt requests.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1056 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1057 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1058 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1059 static void HCD_RXQLVL_IRQHandler(HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1060 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1061 USB_OTG_GlobalTypeDef *USBx = hhcd->Instance;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1062 uint8_t channelnum = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1063 uint32_t pktsts;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1064 uint32_t pktcnt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1065 uint32_t temp = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1066
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1067 temp = hhcd->Instance->GRXSTSP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1068 channelnum = temp & USB_OTG_GRXSTSP_EPNUM;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1069 pktsts = (temp & USB_OTG_GRXSTSP_PKTSTS) >> 17;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1070 pktcnt = (temp & USB_OTG_GRXSTSP_BCNT) >> 4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1071
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1072 switch (pktsts)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1073 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1074 case GRXSTS_PKTSTS_IN:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1075 /* Read the data into the host buffer. */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1076 if ((pktcnt > 0) && (hhcd->hc[channelnum].xfer_buff != (void *)0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1077 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1078
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1079 USB_ReadPacket(hhcd->Instance, hhcd->hc[channelnum].xfer_buff, pktcnt);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1080
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1081 /*manage multiple Xfer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1082 hhcd->hc[channelnum].xfer_buff += pktcnt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1083 hhcd->hc[channelnum].xfer_count += pktcnt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1084
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1085 if((USBx_HC(channelnum)->HCTSIZ & USB_OTG_HCTSIZ_PKTCNT) > 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1086 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1087 /* re-activate the channel when more packets are expected */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1088 USBx_HC(channelnum)->HCCHAR &= ~USB_OTG_HCCHAR_CHDIS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1089 USBx_HC(channelnum)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1090 hhcd->hc[channelnum].toggle_in ^= 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1091 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1092 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1093 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1094
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1095 case GRXSTS_PKTSTS_DATA_TOGGLE_ERR:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1096 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1097 case GRXSTS_PKTSTS_IN_XFER_COMP:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1098 case GRXSTS_PKTSTS_CH_HALTED:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1099 default:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1100 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1101 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1102 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1103
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1104 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1105 * @brief This function handles Host Port interrupt requests.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1106 * @param hhcd: HCD handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1107 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1108 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1109 static void HCD_Port_IRQHandler (HCD_HandleTypeDef *hhcd)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1110 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1111 USB_OTG_GlobalTypeDef *USBx = hhcd->Instance;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1112 __IO uint32_t hprt0, hprt0_dup;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1113
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1114 /* Handle Host Port Interrupts */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1115 hprt0 = USBx_HPRT0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1116 hprt0_dup = USBx_HPRT0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1117
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1118 hprt0_dup &= ~(USB_OTG_HPRT_PENA | USB_OTG_HPRT_PCDET |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1119 USB_OTG_HPRT_PENCHNG | USB_OTG_HPRT_POCCHNG );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1120
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1121 /* Check whether Port Connect Detected */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1122 if((hprt0 & USB_OTG_HPRT_PCDET) == USB_OTG_HPRT_PCDET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1123 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1124 if((hprt0 & USB_OTG_HPRT_PCSTS) == USB_OTG_HPRT_PCSTS)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1125 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1126 USB_MASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_DISCINT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1127 HAL_HCD_Connect_Callback(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1128 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1129 hprt0_dup |= USB_OTG_HPRT_PCDET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1130
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1131 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1132
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1133 /* Check whether Port Enable Changed */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1134 if((hprt0 & USB_OTG_HPRT_PENCHNG) == USB_OTG_HPRT_PENCHNG)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1135 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1136 hprt0_dup |= USB_OTG_HPRT_PENCHNG;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1137
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1138 if((hprt0 & USB_OTG_HPRT_PENA) == USB_OTG_HPRT_PENA)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1139 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1140 if(hhcd->Init.phy_itface == USB_OTG_EMBEDDED_PHY)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1141 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1142 if ((hprt0 & USB_OTG_HPRT_PSPD) == (HPRT0_PRTSPD_LOW_SPEED << 17))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1143 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1144 USB_InitFSLSPClkSel(hhcd->Instance ,HCFG_6_MHZ );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1145 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1146 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1147 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1148 USB_InitFSLSPClkSel(hhcd->Instance ,HCFG_48_MHZ );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1149 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1150 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1151 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1152 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1153 if(hhcd->Init.speed == HCD_SPEED_FULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1154 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1155 USBx_HOST->HFIR = (uint32_t)60000;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1156 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1157 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1158 HAL_HCD_Connect_Callback(hhcd);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1159
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1160 if(hhcd->Init.speed == HCD_SPEED_HIGH)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1161 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1162 USB_UNMASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_DISCINT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1163 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1164 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1165 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1166 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1167 /* Cleanup HPRT */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1168 USBx_HPRT0 &= ~(USB_OTG_HPRT_PENA | USB_OTG_HPRT_PCDET |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1169 USB_OTG_HPRT_PENCHNG | USB_OTG_HPRT_POCCHNG );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1170
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1171 USB_UNMASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_DISCINT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1172 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1173 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1174
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1175 /* Check for an overcurrent */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1176 if((hprt0 & USB_OTG_HPRT_POCCHNG) == USB_OTG_HPRT_POCCHNG)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1177 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1178 hprt0_dup |= USB_OTG_HPRT_POCCHNG;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1179 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1180
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1181 /* Clear Port Interrupts */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1182 USBx_HPRT0 = hprt0_dup;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1183 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1184
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1185 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1186 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1187 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1188
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1189 #endif /* HAL_HCD_MODULE_ENABLED */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1190 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1191 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1192 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1193
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1194 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1195 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1196 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1197
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1198 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/