this repository aim to make the official ST DISCO F746NG demo from STM32Cube_FW_F7_V1.2.0 working on mbed.

Dependencies:   BSP_DISCO_F746NG_patch mbed-rtos mbed

Committer:
NirT
Date:
Mon Nov 02 23:38:08 2015 +0000
Revision:
0:c00e6c923941
Error: Incomplete type is not allowed in "patch/LwIP/src/include/lwip/dhcp.h", Line: 83, Col: 4; ; and more like this.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
NirT 0:c00e6c923941 1 /**
NirT 0:c00e6c923941 2 ******************************************************************************
NirT 0:c00e6c923941 3 * @file usbh_conf.c
NirT 0:c00e6c923941 4 * @author MCD Application Team
NirT 0:c00e6c923941 5 * @version V1.1.0
NirT 0:c00e6c923941 6 * @date 21-September-2015
NirT 0:c00e6c923941 7 * @brief USB Host configuration file.
NirT 0:c00e6c923941 8 ******************************************************************************
NirT 0:c00e6c923941 9 * @attention
NirT 0:c00e6c923941 10 *
NirT 0:c00e6c923941 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
NirT 0:c00e6c923941 12 *
NirT 0:c00e6c923941 13 * Redistribution and use in source and binary forms, with or without modification,
NirT 0:c00e6c923941 14 * are permitted provided that the following conditions are met:
NirT 0:c00e6c923941 15 * 1. Redistributions of source code must retain the above copyright notice,
NirT 0:c00e6c923941 16 * this list of conditions and the following disclaimer.
NirT 0:c00e6c923941 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
NirT 0:c00e6c923941 18 * this list of conditions and the following disclaimer in the documentation
NirT 0:c00e6c923941 19 * and/or other materials provided with the distribution.
NirT 0:c00e6c923941 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
NirT 0:c00e6c923941 21 * may be used to endorse or promote products derived from this software
NirT 0:c00e6c923941 22 * without specific prior written permission.
NirT 0:c00e6c923941 23 *
NirT 0:c00e6c923941 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
NirT 0:c00e6c923941 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
NirT 0:c00e6c923941 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
NirT 0:c00e6c923941 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
NirT 0:c00e6c923941 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
NirT 0:c00e6c923941 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
NirT 0:c00e6c923941 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
NirT 0:c00e6c923941 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
NirT 0:c00e6c923941 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
NirT 0:c00e6c923941 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NirT 0:c00e6c923941 34 *
NirT 0:c00e6c923941 35 ******************************************************************************
NirT 0:c00e6c923941 36 */
NirT 0:c00e6c923941 37
NirT 0:c00e6c923941 38 /* Includes ------------------------------------------------------------------*/
NirT 0:c00e6c923941 39 #include "stm32f7xx_hal.h"
NirT 0:c00e6c923941 40 #include "usbh_core.h"
NirT 0:c00e6c923941 41
NirT 0:c00e6c923941 42 HCD_HandleTypeDef hhcd;
NirT 0:c00e6c923941 43
NirT 0:c00e6c923941 44 /*******************************************************************************
NirT 0:c00e6c923941 45 HCD BSP Routines
NirT 0:c00e6c923941 46 *******************************************************************************/
NirT 0:c00e6c923941 47 /**
NirT 0:c00e6c923941 48 * @brief Initializes the HCD MSP.
NirT 0:c00e6c923941 49 * @param hhcd: HCD handle
NirT 0:c00e6c923941 50 * @retval None
NirT 0:c00e6c923941 51 */
NirT 0:c00e6c923941 52 void HAL_HCD_MspInit(HCD_HandleTypeDef *hhcd)
NirT 0:c00e6c923941 53 {
NirT 0:c00e6c923941 54 GPIO_InitTypeDef GPIO_InitStruct;
NirT 0:c00e6c923941 55
NirT 0:c00e6c923941 56 /* Configure USB HS GPIOs */
NirT 0:c00e6c923941 57 __HAL_RCC_GPIOA_CLK_ENABLE();
NirT 0:c00e6c923941 58 __HAL_RCC_GPIOB_CLK_ENABLE();
NirT 0:c00e6c923941 59 __HAL_RCC_GPIOC_CLK_ENABLE();
NirT 0:c00e6c923941 60 __HAL_RCC_GPIOH_CLK_ENABLE();
NirT 0:c00e6c923941 61
NirT 0:c00e6c923941 62 /* CLK */
NirT 0:c00e6c923941 63 GPIO_InitStruct.Pin = GPIO_PIN_5;
NirT 0:c00e6c923941 64 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
NirT 0:c00e6c923941 65 GPIO_InitStruct.Pull = GPIO_NOPULL;
NirT 0:c00e6c923941 66 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
NirT 0:c00e6c923941 67 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
NirT 0:c00e6c923941 68 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
NirT 0:c00e6c923941 69
NirT 0:c00e6c923941 70 /* D0 */
NirT 0:c00e6c923941 71 GPIO_InitStruct.Pin = GPIO_PIN_3;
NirT 0:c00e6c923941 72 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
NirT 0:c00e6c923941 73 GPIO_InitStruct.Pull = GPIO_NOPULL;
NirT 0:c00e6c923941 74 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
NirT 0:c00e6c923941 75 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
NirT 0:c00e6c923941 76 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
NirT 0:c00e6c923941 77
NirT 0:c00e6c923941 78 /* D1 D2 D3 D4 D5 D6 D7 */
NirT 0:c00e6c923941 79 GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_5 |\
NirT 0:c00e6c923941 80 GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;
NirT 0:c00e6c923941 81 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
NirT 0:c00e6c923941 82 GPIO_InitStruct.Pull = GPIO_NOPULL;
NirT 0:c00e6c923941 83 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
NirT 0:c00e6c923941 84 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
NirT 0:c00e6c923941 85
NirT 0:c00e6c923941 86 /* STP */
NirT 0:c00e6c923941 87 GPIO_InitStruct.Pin = GPIO_PIN_0;
NirT 0:c00e6c923941 88 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
NirT 0:c00e6c923941 89 GPIO_InitStruct.Pull = GPIO_NOPULL;
NirT 0:c00e6c923941 90 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
NirT 0:c00e6c923941 91 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
NirT 0:c00e6c923941 92
NirT 0:c00e6c923941 93 /* NXT */
NirT 0:c00e6c923941 94 GPIO_InitStruct.Pin = GPIO_PIN_4;
NirT 0:c00e6c923941 95 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
NirT 0:c00e6c923941 96 GPIO_InitStruct.Pull = GPIO_NOPULL;
NirT 0:c00e6c923941 97 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
NirT 0:c00e6c923941 98 HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
NirT 0:c00e6c923941 99
NirT 0:c00e6c923941 100 /* DIR */
NirT 0:c00e6c923941 101 GPIO_InitStruct.Pin = GPIO_PIN_2;
NirT 0:c00e6c923941 102 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
NirT 0:c00e6c923941 103 GPIO_InitStruct.Pull = GPIO_NOPULL;
NirT 0:c00e6c923941 104 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
NirT 0:c00e6c923941 105 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
NirT 0:c00e6c923941 106
NirT 0:c00e6c923941 107 __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE();
NirT 0:c00e6c923941 108
NirT 0:c00e6c923941 109 /* Enable USB HS Clocks */
NirT 0:c00e6c923941 110 __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
NirT 0:c00e6c923941 111
NirT 0:c00e6c923941 112 /* Set USBHS Interrupt priority */
NirT 0:c00e6c923941 113 HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0);
NirT 0:c00e6c923941 114
NirT 0:c00e6c923941 115 /* Enable USBHS Interrupt */
NirT 0:c00e6c923941 116 HAL_NVIC_EnableIRQ(OTG_HS_IRQn);
NirT 0:c00e6c923941 117 }
NirT 0:c00e6c923941 118
NirT 0:c00e6c923941 119 /**
NirT 0:c00e6c923941 120 * @brief DeInitializes the HCD MSP.
NirT 0:c00e6c923941 121 * @param hhcd: HCD handle
NirT 0:c00e6c923941 122 * @retval None
NirT 0:c00e6c923941 123 */
NirT 0:c00e6c923941 124 void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd)
NirT 0:c00e6c923941 125 {
NirT 0:c00e6c923941 126 /* Disable USB HS Clocks */
NirT 0:c00e6c923941 127 __HAL_RCC_USB_OTG_HS_CLK_DISABLE();
NirT 0:c00e6c923941 128 __HAL_RCC_USB_OTG_HS_ULPI_CLK_DISABLE();
NirT 0:c00e6c923941 129 }
NirT 0:c00e6c923941 130
NirT 0:c00e6c923941 131 /*******************************************************************************
NirT 0:c00e6c923941 132 LL Driver Callbacks (HCD -> USB Host Library)
NirT 0:c00e6c923941 133 *******************************************************************************/
NirT 0:c00e6c923941 134
NirT 0:c00e6c923941 135 /**
NirT 0:c00e6c923941 136 * @brief SOF callback.
NirT 0:c00e6c923941 137 * @param hhcd: HCD handle
NirT 0:c00e6c923941 138 * @retval None
NirT 0:c00e6c923941 139 */
NirT 0:c00e6c923941 140 void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd)
NirT 0:c00e6c923941 141 {
NirT 0:c00e6c923941 142 USBH_LL_IncTimer(hhcd->pData);
NirT 0:c00e6c923941 143 }
NirT 0:c00e6c923941 144
NirT 0:c00e6c923941 145 /**
NirT 0:c00e6c923941 146 * @brief Connect callback.
NirT 0:c00e6c923941 147 * @param hhcd: HCD handle
NirT 0:c00e6c923941 148 * @retval None
NirT 0:c00e6c923941 149 */
NirT 0:c00e6c923941 150 void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd)
NirT 0:c00e6c923941 151 {
NirT 0:c00e6c923941 152
NirT 0:c00e6c923941 153 USBH_LL_Connect(hhcd->pData);
NirT 0:c00e6c923941 154
NirT 0:c00e6c923941 155 HAL_Delay(100);
NirT 0:c00e6c923941 156 }
NirT 0:c00e6c923941 157
NirT 0:c00e6c923941 158 /**
NirT 0:c00e6c923941 159 * @brief Disconnect callback.
NirT 0:c00e6c923941 160 * @param hhcd: HCD handle
NirT 0:c00e6c923941 161 * @retval None
NirT 0:c00e6c923941 162 */
NirT 0:c00e6c923941 163 void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd)
NirT 0:c00e6c923941 164 {
NirT 0:c00e6c923941 165 USBH_LL_Disconnect(hhcd->pData);
NirT 0:c00e6c923941 166 }
NirT 0:c00e6c923941 167
NirT 0:c00e6c923941 168
NirT 0:c00e6c923941 169 /**
NirT 0:c00e6c923941 170 * @brief Notify URB state change callback.
NirT 0:c00e6c923941 171 * @param hhcd: HCD handle
NirT 0:c00e6c923941 172 * @param chnum: Channel number
NirT 0:c00e6c923941 173 * @param urb_state: URB State
NirT 0:c00e6c923941 174 * @retval None
NirT 0:c00e6c923941 175 */
NirT 0:c00e6c923941 176 void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state)
NirT 0:c00e6c923941 177 {
NirT 0:c00e6c923941 178 #if (USBH_USE_OS == 1)
NirT 0:c00e6c923941 179 USBH_LL_NotifyURBChange(hhcd->pData);
NirT 0:c00e6c923941 180 #endif
NirT 0:c00e6c923941 181 }
NirT 0:c00e6c923941 182
NirT 0:c00e6c923941 183 /*******************************************************************************
NirT 0:c00e6c923941 184 LL Driver Interface (USB Host Library --> HCD)
NirT 0:c00e6c923941 185 *******************************************************************************/
NirT 0:c00e6c923941 186
NirT 0:c00e6c923941 187 /**
NirT 0:c00e6c923941 188 * @brief Initializes the Low Level portion of the Host driver.
NirT 0:c00e6c923941 189 * @param phost: Host handle
NirT 0:c00e6c923941 190 * @retval USBH Status
NirT 0:c00e6c923941 191 */
NirT 0:c00e6c923941 192 USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost)
NirT 0:c00e6c923941 193 {
NirT 0:c00e6c923941 194 /* Set the LL driver parameters */
NirT 0:c00e6c923941 195 hhcd.Instance = USB_OTG_HS;
NirT 0:c00e6c923941 196 hhcd.Init.Host_channels = 11;
NirT 0:c00e6c923941 197 hhcd.Init.dma_enable = 0;
NirT 0:c00e6c923941 198 hhcd.Init.low_power_enable = 0;
NirT 0:c00e6c923941 199 hhcd.Init.phy_itface = HCD_PHY_ULPI;
NirT 0:c00e6c923941 200 hhcd.Init.Sof_enable = 0;
NirT 0:c00e6c923941 201 hhcd.Init.speed = HCD_SPEED_HIGH;
NirT 0:c00e6c923941 202 hhcd.Init.vbus_sensing_enable = 1;
NirT 0:c00e6c923941 203 hhcd.Init.use_external_vbus = 1;
NirT 0:c00e6c923941 204 /* Link the driver to the stack */
NirT 0:c00e6c923941 205 hhcd.pData = phost;
NirT 0:c00e6c923941 206 phost->pData = &hhcd;
NirT 0:c00e6c923941 207 /* Initialize the LL driver */
NirT 0:c00e6c923941 208 HAL_HCD_Init(&hhcd);
NirT 0:c00e6c923941 209
NirT 0:c00e6c923941 210
NirT 0:c00e6c923941 211 USBH_LL_SetTimer(phost, HAL_HCD_GetCurrentFrame(&hhcd));
NirT 0:c00e6c923941 212
NirT 0:c00e6c923941 213 return USBH_OK;
NirT 0:c00e6c923941 214 }
NirT 0:c00e6c923941 215
NirT 0:c00e6c923941 216
NirT 0:c00e6c923941 217 /**
NirT 0:c00e6c923941 218 * @brief De-Initializes the Low Level portion of the Host driver.
NirT 0:c00e6c923941 219 * @param phost: Host handle
NirT 0:c00e6c923941 220 * @retval USBH Status
NirT 0:c00e6c923941 221 */
NirT 0:c00e6c923941 222 USBH_StatusTypeDef USBH_LL_DeInit(USBH_HandleTypeDef *phost)
NirT 0:c00e6c923941 223 {
NirT 0:c00e6c923941 224 HAL_HCD_DeInit(phost->pData);
NirT 0:c00e6c923941 225 return USBH_OK;
NirT 0:c00e6c923941 226 }
NirT 0:c00e6c923941 227
NirT 0:c00e6c923941 228 /**
NirT 0:c00e6c923941 229 * @brief Starts the Low Level portion of the Host driver.
NirT 0:c00e6c923941 230 * @param phost: Host handle
NirT 0:c00e6c923941 231 * @retval USBH Status
NirT 0:c00e6c923941 232 */
NirT 0:c00e6c923941 233 USBH_StatusTypeDef USBH_LL_Start(USBH_HandleTypeDef *phost)
NirT 0:c00e6c923941 234 {
NirT 0:c00e6c923941 235 HAL_HCD_Start(phost->pData);
NirT 0:c00e6c923941 236 return USBH_OK;
NirT 0:c00e6c923941 237 }
NirT 0:c00e6c923941 238
NirT 0:c00e6c923941 239 /**
NirT 0:c00e6c923941 240 * @brief Stops the Low Level portion of the Host driver.
NirT 0:c00e6c923941 241 * @param phost: Host handle
NirT 0:c00e6c923941 242 * @retval USBH Status
NirT 0:c00e6c923941 243 */
NirT 0:c00e6c923941 244 USBH_StatusTypeDef USBH_LL_Stop(USBH_HandleTypeDef *phost)
NirT 0:c00e6c923941 245 {
NirT 0:c00e6c923941 246 HAL_HCD_Stop(phost->pData);
NirT 0:c00e6c923941 247 return USBH_OK;
NirT 0:c00e6c923941 248 }
NirT 0:c00e6c923941 249
NirT 0:c00e6c923941 250 /**
NirT 0:c00e6c923941 251 * @brief Returns the USB Host Speed from the Low Level Driver.
NirT 0:c00e6c923941 252 * @param phost: Host handle
NirT 0:c00e6c923941 253 * @retval USBH Speeds
NirT 0:c00e6c923941 254 */
NirT 0:c00e6c923941 255 USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost)
NirT 0:c00e6c923941 256 {
NirT 0:c00e6c923941 257 USBH_SpeedTypeDef speed = USBH_SPEED_FULL;
NirT 0:c00e6c923941 258
NirT 0:c00e6c923941 259 switch (HAL_HCD_GetCurrentSpeed(phost->pData))
NirT 0:c00e6c923941 260 {
NirT 0:c00e6c923941 261 case 0:
NirT 0:c00e6c923941 262 speed = USBH_SPEED_HIGH;
NirT 0:c00e6c923941 263 break;
NirT 0:c00e6c923941 264
NirT 0:c00e6c923941 265 case 1:
NirT 0:c00e6c923941 266 speed = USBH_SPEED_FULL;
NirT 0:c00e6c923941 267 break;
NirT 0:c00e6c923941 268
NirT 0:c00e6c923941 269 case 2:
NirT 0:c00e6c923941 270 speed = USBH_SPEED_LOW;
NirT 0:c00e6c923941 271 break;
NirT 0:c00e6c923941 272
NirT 0:c00e6c923941 273 default:
NirT 0:c00e6c923941 274 speed = USBH_SPEED_FULL;
NirT 0:c00e6c923941 275 break;
NirT 0:c00e6c923941 276 }
NirT 0:c00e6c923941 277 return speed;
NirT 0:c00e6c923941 278 }
NirT 0:c00e6c923941 279
NirT 0:c00e6c923941 280 /**
NirT 0:c00e6c923941 281 * @brief Resets the Host Port of the Low Level Driver.
NirT 0:c00e6c923941 282 * @param phost: Host handle
NirT 0:c00e6c923941 283 * @retval USBH Status
NirT 0:c00e6c923941 284 */
NirT 0:c00e6c923941 285 USBH_StatusTypeDef USBH_LL_ResetPort (USBH_HandleTypeDef *phost)
NirT 0:c00e6c923941 286 {
NirT 0:c00e6c923941 287 HAL_HCD_ResetPort(phost->pData);
NirT 0:c00e6c923941 288 return USBH_OK;
NirT 0:c00e6c923941 289 }
NirT 0:c00e6c923941 290
NirT 0:c00e6c923941 291 /**
NirT 0:c00e6c923941 292 * @brief Returns the last transfered packet size.
NirT 0:c00e6c923941 293 * @param phost: Host handle
NirT 0:c00e6c923941 294 * @param pipe: Pipe index
NirT 0:c00e6c923941 295 * @retval Packet Size
NirT 0:c00e6c923941 296 */
NirT 0:c00e6c923941 297 uint32_t USBH_LL_GetLastXferSize(USBH_HandleTypeDef *phost, uint8_t pipe)
NirT 0:c00e6c923941 298 {
NirT 0:c00e6c923941 299 return HAL_HCD_HC_GetXferCount(phost->pData, pipe);
NirT 0:c00e6c923941 300 }
NirT 0:c00e6c923941 301
NirT 0:c00e6c923941 302 /**
NirT 0:c00e6c923941 303 * @brief Opens a pipe of the Low Level Driver.
NirT 0:c00e6c923941 304 * @param phost: Host handle
NirT 0:c00e6c923941 305 * @param pipe: Pipe index
NirT 0:c00e6c923941 306 * @param epnum: Endpoint Number
NirT 0:c00e6c923941 307 * @param dev_address: Device USB address
NirT 0:c00e6c923941 308 * @param speed: Device Speed
NirT 0:c00e6c923941 309 * @param ep_type: Endpoint Type
NirT 0:c00e6c923941 310 * @param mps: Endpoint Max Packet Size
NirT 0:c00e6c923941 311 * @retval USBH Status
NirT 0:c00e6c923941 312 */
NirT 0:c00e6c923941 313 USBH_StatusTypeDef USBH_LL_OpenPipe(USBH_HandleTypeDef *phost,
NirT 0:c00e6c923941 314 uint8_t pipe,
NirT 0:c00e6c923941 315 uint8_t epnum,
NirT 0:c00e6c923941 316 uint8_t dev_address,
NirT 0:c00e6c923941 317 uint8_t speed,
NirT 0:c00e6c923941 318 uint8_t ep_type,
NirT 0:c00e6c923941 319 uint16_t mps)
NirT 0:c00e6c923941 320 {
NirT 0:c00e6c923941 321 HAL_HCD_HC_Init(phost->pData,
NirT 0:c00e6c923941 322 pipe,
NirT 0:c00e6c923941 323 epnum,
NirT 0:c00e6c923941 324 dev_address,
NirT 0:c00e6c923941 325 speed,
NirT 0:c00e6c923941 326 ep_type,
NirT 0:c00e6c923941 327 mps);
NirT 0:c00e6c923941 328 return USBH_OK;
NirT 0:c00e6c923941 329 }
NirT 0:c00e6c923941 330
NirT 0:c00e6c923941 331 /**
NirT 0:c00e6c923941 332 * @brief Closes a pipe of the Low Level Driver.
NirT 0:c00e6c923941 333 * @param phost: Host handle
NirT 0:c00e6c923941 334 * @param pipe: Pipe index
NirT 0:c00e6c923941 335 * @retval USBH Status
NirT 0:c00e6c923941 336 */
NirT 0:c00e6c923941 337 USBH_StatusTypeDef USBH_LL_ClosePipe(USBH_HandleTypeDef *phost, uint8_t pipe)
NirT 0:c00e6c923941 338 {
NirT 0:c00e6c923941 339 HAL_HCD_HC_Halt(phost->pData, pipe);
NirT 0:c00e6c923941 340 return USBH_OK;
NirT 0:c00e6c923941 341 }
NirT 0:c00e6c923941 342
NirT 0:c00e6c923941 343 /**
NirT 0:c00e6c923941 344 * @brief Submits a new URB to the low level driver.
NirT 0:c00e6c923941 345 * @param phost: Host handle
NirT 0:c00e6c923941 346 * @param pipe: Pipe index
NirT 0:c00e6c923941 347 * This parameter can be a value from 1 to 15
NirT 0:c00e6c923941 348 * @param direction: Channel number
NirT 0:c00e6c923941 349 * This parameter can be one of these values:
NirT 0:c00e6c923941 350 * 0: Output
NirT 0:c00e6c923941 351 * 1: Input
NirT 0:c00e6c923941 352 * @param ep_type: Endpoint Type
NirT 0:c00e6c923941 353 * This parameter can be one of these values:
NirT 0:c00e6c923941 354 * @arg EP_TYPE_CTRL: Control type
NirT 0:c00e6c923941 355 * @arg EP_TYPE_ISOC: Isochrounous type
NirT 0:c00e6c923941 356 * @arg EP_TYPE_BULK: Bulk type
NirT 0:c00e6c923941 357 * @arg EP_TYPE_INTR: Interrupt type
NirT 0:c00e6c923941 358 * @param token: Endpoint Type
NirT 0:c00e6c923941 359 * This parameter can be one of these values:
NirT 0:c00e6c923941 360 * @arg 0: PID_SETUP
NirT 0:c00e6c923941 361 * @arg 1: PID_DATA
NirT 0:c00e6c923941 362 * @param pbuff: pointer to URB data
NirT 0:c00e6c923941 363 * @param length: length of URB data
NirT 0:c00e6c923941 364 * @param do_ping: activate do ping protocol (for high speed only)
NirT 0:c00e6c923941 365 * This parameter can be one of these values:
NirT 0:c00e6c923941 366 * 0: do ping inactive
NirT 0:c00e6c923941 367 * 1: do ping active
NirT 0:c00e6c923941 368 * @retval USBH Status
NirT 0:c00e6c923941 369 */
NirT 0:c00e6c923941 370 USBH_StatusTypeDef USBH_LL_SubmitURB(USBH_HandleTypeDef *phost,
NirT 0:c00e6c923941 371 uint8_t pipe,
NirT 0:c00e6c923941 372 uint8_t direction,
NirT 0:c00e6c923941 373 uint8_t ep_type,
NirT 0:c00e6c923941 374 uint8_t token,
NirT 0:c00e6c923941 375 uint8_t* pbuff,
NirT 0:c00e6c923941 376 uint16_t length,
NirT 0:c00e6c923941 377 uint8_t do_ping)
NirT 0:c00e6c923941 378 {
NirT 0:c00e6c923941 379 HAL_HCD_HC_SubmitRequest(phost->pData,
NirT 0:c00e6c923941 380 pipe,
NirT 0:c00e6c923941 381 direction,
NirT 0:c00e6c923941 382 ep_type,
NirT 0:c00e6c923941 383 token,
NirT 0:c00e6c923941 384 pbuff,
NirT 0:c00e6c923941 385 length,
NirT 0:c00e6c923941 386 do_ping);
NirT 0:c00e6c923941 387 return USBH_OK;
NirT 0:c00e6c923941 388 }
NirT 0:c00e6c923941 389
NirT 0:c00e6c923941 390 /**
NirT 0:c00e6c923941 391 * @brief Gets a URB state from the low level driver.
NirT 0:c00e6c923941 392 * @param phost: Host handle
NirT 0:c00e6c923941 393 * @param pipe: Pipe index
NirT 0:c00e6c923941 394 * This parameter can be a value from 1 to 15
NirT 0:c00e6c923941 395 * @retval URB state
NirT 0:c00e6c923941 396 * This parameter can be one of these values:
NirT 0:c00e6c923941 397 * @arg URB_IDLE
NirT 0:c00e6c923941 398 * @arg URB_DONE
NirT 0:c00e6c923941 399 * @arg URB_NOTREADY
NirT 0:c00e6c923941 400 * @arg URB_NYET
NirT 0:c00e6c923941 401 * @arg URB_ERROR
NirT 0:c00e6c923941 402 * @arg URB_STALL
NirT 0:c00e6c923941 403 */
NirT 0:c00e6c923941 404 USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t pipe)
NirT 0:c00e6c923941 405 {
NirT 0:c00e6c923941 406 return (USBH_URBStateTypeDef)HAL_HCD_HC_GetURBState (phost->pData, pipe);
NirT 0:c00e6c923941 407 }
NirT 0:c00e6c923941 408
NirT 0:c00e6c923941 409 /**
NirT 0:c00e6c923941 410 * @brief Drives VBUS.
NirT 0:c00e6c923941 411 * @param phost: Host handle
NirT 0:c00e6c923941 412 * @param state: VBUS state
NirT 0:c00e6c923941 413 * This parameter can be one of these values:
NirT 0:c00e6c923941 414 * 0: VBUS Active
NirT 0:c00e6c923941 415 * 1: VBUS Inactive
NirT 0:c00e6c923941 416 * @retval USBH Status
NirT 0:c00e6c923941 417 */
NirT 0:c00e6c923941 418 USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t state)
NirT 0:c00e6c923941 419 {
NirT 0:c00e6c923941 420 /* VBUS driven by ULPI interface */
NirT 0:c00e6c923941 421 HAL_Delay(200);
NirT 0:c00e6c923941 422 return USBH_OK;
NirT 0:c00e6c923941 423 }
NirT 0:c00e6c923941 424
NirT 0:c00e6c923941 425 /**
NirT 0:c00e6c923941 426 * @brief Sets toggle for a pipe.
NirT 0:c00e6c923941 427 * @param phost: Host handle
NirT 0:c00e6c923941 428 * @param pipe: Pipe index
NirT 0:c00e6c923941 429 * @param toggle: toggle (0/1)
NirT 0:c00e6c923941 430 * @retval USBH Status
NirT 0:c00e6c923941 431 */
NirT 0:c00e6c923941 432 USBH_StatusTypeDef USBH_LL_SetToggle(USBH_HandleTypeDef *phost, uint8_t pipe, uint8_t toggle)
NirT 0:c00e6c923941 433 {
NirT 0:c00e6c923941 434 if(hhcd.hc[pipe].ep_is_in)
NirT 0:c00e6c923941 435 {
NirT 0:c00e6c923941 436 hhcd.hc[pipe].toggle_in = toggle;
NirT 0:c00e6c923941 437 }
NirT 0:c00e6c923941 438 else
NirT 0:c00e6c923941 439 {
NirT 0:c00e6c923941 440 hhcd.hc[pipe].toggle_out = toggle;
NirT 0:c00e6c923941 441 }
NirT 0:c00e6c923941 442 return USBH_OK;
NirT 0:c00e6c923941 443 }
NirT 0:c00e6c923941 444
NirT 0:c00e6c923941 445 /**
NirT 0:c00e6c923941 446 * @brief Returns the current toggle of a pipe.
NirT 0:c00e6c923941 447 * @param phost: Host handle
NirT 0:c00e6c923941 448 * @param pipe: Pipe index
NirT 0:c00e6c923941 449 * @retval toggle (0/1)
NirT 0:c00e6c923941 450 */
NirT 0:c00e6c923941 451 uint8_t USBH_LL_GetToggle(USBH_HandleTypeDef *phost, uint8_t pipe)
NirT 0:c00e6c923941 452 {
NirT 0:c00e6c923941 453 uint8_t toggle = 0;
NirT 0:c00e6c923941 454
NirT 0:c00e6c923941 455 if(hhcd.hc[pipe].ep_is_in)
NirT 0:c00e6c923941 456 {
NirT 0:c00e6c923941 457 toggle = hhcd.hc[pipe].toggle_in;
NirT 0:c00e6c923941 458 }
NirT 0:c00e6c923941 459 else
NirT 0:c00e6c923941 460 {
NirT 0:c00e6c923941 461 toggle = hhcd.hc[pipe].toggle_out;
NirT 0:c00e6c923941 462 }
NirT 0:c00e6c923941 463 return toggle;
NirT 0:c00e6c923941 464 }
NirT 0:c00e6c923941 465
NirT 0:c00e6c923941 466 /**
NirT 0:c00e6c923941 467 * @brief Delay routine for the USB Host Library
NirT 0:c00e6c923941 468 * @param Delay: Delay in ms
NirT 0:c00e6c923941 469 * @retval None
NirT 0:c00e6c923941 470 */
NirT 0:c00e6c923941 471 void USBH_Delay(uint32_t Delay)
NirT 0:c00e6c923941 472 {
NirT 0:c00e6c923941 473 HAL_Delay(Delay);
NirT 0:c00e6c923941 474 }
NirT 0:c00e6c923941 475
NirT 0:c00e6c923941 476 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/