Prusa MINI Firmware overview
usbh_conf.c File Reference

: This file implements the board support package for the USB host library More...

#include "usbh_core.h"
#include "main.h"

Functions

void Error_Handler (void)
 This function is executed in case of error occurrence. More...
 
void HAL_HCD_MspInit (HCD_HandleTypeDef *hcdHandle)
 
void HAL_HCD_MspDeInit (HCD_HandleTypeDef *hcdHandle)
 
void HAL_HCD_SOF_Callback (HCD_HandleTypeDef *hhcd)
 SOF callback. More...
 
void HAL_HCD_Connect_Callback (HCD_HandleTypeDef *hhcd)
 SOF callback. More...
 
void HAL_HCD_Disconnect_Callback (HCD_HandleTypeDef *hhcd)
 SOF callback. More...
 
void HAL_HCD_HC_NotifyURBChange_Callback (HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state)
 Notify URB state change callback. More...
 
USBH_StatusTypeDef USBH_LL_Init (USBH_HandleTypeDef *phost)
 Initialize the low level portion of the host driver. More...
 
USBH_StatusTypeDef USBH_LL_DeInit (USBH_HandleTypeDef *phost)
 De-Initialize the low level portion of the host driver. More...
 
USBH_StatusTypeDef USBH_LL_Start (USBH_HandleTypeDef *phost)
 Start the low level portion of the host driver. More...
 
USBH_StatusTypeDef USBH_LL_Stop (USBH_HandleTypeDef *phost)
 Stop the low level portion of the host driver. More...
 
USBH_SpeedTypeDef USBH_LL_GetSpeed (USBH_HandleTypeDef *phost)
 Return the USB host speed from the low level driver. More...
 
USBH_StatusTypeDef USBH_LL_ResetPort (USBH_HandleTypeDef *phost)
 Reset the Host port of the low level driver. More...
 
uint32_t USBH_LL_GetLastXferSize (USBH_HandleTypeDef *phost, uint8_t pipe)
 Return the last transfered packet size. More...
 
USBH_StatusTypeDef USBH_LL_OpenPipe (USBH_HandleTypeDef *phost, uint8_t pipe_num, uint8_t epnum, uint8_t dev_address, uint8_t speed, uint8_t ep_type, uint16_t mps)
 Open a pipe of the low level driver. More...
 
USBH_StatusTypeDef USBH_LL_ClosePipe (USBH_HandleTypeDef *phost, uint8_t pipe)
 Close a pipe of the low level driver. More...
 
USBH_StatusTypeDef USBH_LL_SubmitURB (USBH_HandleTypeDef *phost, uint8_t pipe, uint8_t direction, uint8_t ep_type, uint8_t token, uint8_t *pbuff, uint16_t length, uint8_t do_ping)
 Submit a new URB to the low level driver. More...
 
USBH_URBStateTypeDef USBH_LL_GetURBState (USBH_HandleTypeDef *phost, uint8_t pipe)
 Get a URB state from the low level driver. More...
 
USBH_StatusTypeDef USBH_LL_DriverVBUS (USBH_HandleTypeDef *phost, uint8_t state)
 Drive VBUS. More...
 
USBH_StatusTypeDef USBH_LL_SetToggle (USBH_HandleTypeDef *phost, uint8_t pipe, uint8_t toggle)
 Set toggle for a pipe. More...
 
uint8_t USBH_LL_GetToggle (USBH_HandleTypeDef *phost, uint8_t pipe)
 Return the current toggle of a pipe. More...
 
void USBH_Delay (uint32_t Delay)
 Delay routine for the USB Host Library. More...
 

Variables

HCD_HandleTypeDef hhcd_USB_OTG_HS
 

Detailed Description

: This file implements the board support package for the USB host library

Version
: v1.0_Cube This notice applies to any and all portions of this file that are not between comment pairs USER CODE BEGIN and USER CODE END. Other portions of this file, whether inserted by the user or by software development tools are owned by their respective copyright owners.

Copyright (c) 2019 STMicroelectronics International N.V. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted, provided that the following conditions are met:

  1. Redistribution of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of other contributors to this software may be used to endorse or promote products derived from this software without specific written permission.
  4. This software, including modifications and/or derivative works of this software, must execute solely and exclusively on microcontroller or microprocessor devices manufactured by or for STMicroelectronics.
  5. Redistribution and use of this software other than as permitted under this license is void and will automatically terminate your rights under this license.

THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ Error_Handler()

void Error_Handler ( void  )

This function is executed in case of error occurrence.

Return values
None
1057  {
1058  /* USER CODE BEGIN Error_Handler_Debug */
1059  /* User can add his own implementation to report the HAL error return state */
1060  app_error();
1061  /* USER CODE END Error_Handler_Debug */
1062 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HAL_HCD_MspInit()

void HAL_HCD_MspInit ( HCD_HandleTypeDef *  hcdHandle)

USB_OTG_HS GPIO Configuration PB14 ---—> USB_OTG_HS_DM PB15 ---—> USB_OTG_HS_DP

90  {
91  GPIO_InitTypeDef GPIO_InitStruct;
92  if (hcdHandle->Instance == USB_OTG_HS) {
93  /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */
94 
95  /* USER CODE END USB_OTG_HS_MspInit 0 */
96 
97  /**USB_OTG_HS GPIO Configuration
98  PB14 ------> USB_OTG_HS_DM
99  PB15 ------> USB_OTG_HS_DP
100  */
101  GPIO_InitStruct.Pin = USB_HS_N_Pin | USB_HS_P_Pin;
102  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
103  GPIO_InitStruct.Pull = GPIO_NOPULL;
104  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
105  GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS;
106  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
107 
108  /* Peripheral clock enable */
109  __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
110 
111  /* Peripheral interrupt init */
112  HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0);
113  HAL_NVIC_EnableIRQ(OTG_HS_IRQn);
114  /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */
115 
116  /* USER CODE END USB_OTG_HS_MspInit 1 */
117  }
Here is the call graph for this function:

◆ HAL_HCD_MspDeInit()

void HAL_HCD_MspDeInit ( HCD_HandleTypeDef *  hcdHandle)

USB_OTG_HS GPIO Configuration PB14 ---—> USB_OTG_HS_DM PB15 ---—> USB_OTG_HS_DP

120  {
121  if (hcdHandle->Instance == USB_OTG_HS) {
122  /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */
123 
124  /* USER CODE END USB_OTG_HS_MspDeInit 0 */
125  /* Peripheral clock disable */
126  __HAL_RCC_USB_OTG_HS_CLK_DISABLE();
127 
128  /**USB_OTG_HS GPIO Configuration
129  PB14 ------> USB_OTG_HS_DM
130  PB15 ------> USB_OTG_HS_DP
131  */
133 
134  /* Peripheral interrupt Deinit*/
135  HAL_NVIC_DisableIRQ(OTG_HS_IRQn);
136 
137  /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */
138 
139  /* USER CODE END USB_OTG_HS_MspDeInit 1 */
140  }
Here is the call graph for this function:

◆ HAL_HCD_SOF_Callback()

void HAL_HCD_SOF_Callback ( HCD_HandleTypeDef *  hhcd)

SOF callback.

Parameters
hhcdHCD handle
Return values
None
148  {
149  USBH_LL_IncTimer(hhcd->pData);
Here is the call graph for this function:

◆ HAL_HCD_Connect_Callback()

void HAL_HCD_Connect_Callback ( HCD_HandleTypeDef *  hhcd)

SOF callback.

Parameters
hhcdHCD handle
Return values
None
157  {
158  USBH_LL_Connect(hhcd->pData);
Here is the call graph for this function:

◆ HAL_HCD_Disconnect_Callback()

void HAL_HCD_Disconnect_Callback ( HCD_HandleTypeDef *  hhcd)

SOF callback.

Parameters
hhcdHCD handle
Return values
None
166  {
167  USBH_LL_Disconnect(hhcd->pData);
Here is the call graph for this function:

◆ HAL_HCD_HC_NotifyURBChange_Callback()

void HAL_HCD_HC_NotifyURBChange_Callback ( HCD_HandleTypeDef *  hhcd,
uint8_t  chnum,
HCD_URBStateTypeDef  urb_state 
)

Notify URB state change callback.

Parameters
hhcdHCD handle
chnumchannel number
urb_statestate
Return values
None
177  {
178  /* To be used with OS to sync URB state with the global state machine */
179 #if (USBH_USE_OS == 1)
180  USBH_LL_NotifyURBChange(hhcd->pData);
181 #endif

Variable Documentation

◆ hhcd_USB_OTG_HS

HCD_HandleTypeDef hhcd_USB_OTG_HS
GPIO_MODE_AF_PP
#define GPIO_MODE_AF_PP
Definition: stm32f4xx_hal_gpio.h:138
USB_HS_N_Pin
#define USB_HS_N_Pin
Definition: main.h:131
GPIO_InitTypeDef::Mode
uint32_t Mode
Definition: stm32f4xx_hal_gpio.h:68
app_error
void app_error(void)
Definition: appmain.cpp:145
GPIO_InitTypeDef::Alternate
uint32_t Alternate
Definition: stm32f4xx_hal_gpio.h:77
GPIO_InitTypeDef::Pull
uint32_t Pull
Definition: stm32f4xx_hal_gpio.h:71
HAL_GPIO_DeInit
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
USBH_LL_Disconnect
USBH_StatusTypeDef USBH_LL_Disconnect(USBH_HandleTypeDef *phost)
USBH_LL_Disconnect Handle USB Host disconnection event.
Definition: usbh_core.c:854
HAL_GPIO_Init
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
HAL_NVIC_SetPriority
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
GPIO_NOPULL
#define GPIO_NOPULL
Definition: stm32f4xx_hal_gpio.h:170
USBH_LL_IncTimer
void USBH_LL_IncTimer(USBH_HandleTypeDef *phost)
USBH_LL_IncTimer Increment Host Timer tick.
Definition: usbh_core.c:801
GPIO_SPEED_FREQ_VERY_HIGH
#define GPIO_SPEED_FREQ_VERY_HIGH
Definition: stm32f4xx_hal_gpio.h:161
HAL_NVIC_EnableIRQ
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn)
GPIO_InitTypeDef::Pin
uint32_t Pin
Definition: stm32f4xx_hal_gpio.h:65
GPIO_InitTypeDef::Speed
uint32_t Speed
Definition: stm32f4xx_hal_gpio.h:74
HAL_NVIC_DisableIRQ
void HAL_NVIC_DisableIRQ(IRQn_Type IRQn)
USBH_LL_Connect
USBH_StatusTypeDef USBH_LL_Connect(USBH_HandleTypeDef *phost)
USBH_LL_Connect Handle USB Host connexion event.
Definition: usbh_core.c:826
USB_HS_P_Pin
#define USB_HS_P_Pin
Definition: main.h:133
GPIO_InitTypeDef
GPIO Init structure definition.
Definition: stm32f4xx_hal_gpio.h:63