Functions
Peripheral State and Errors functions
Peripheral Driver » HAL Driver » USB » Functions

USB control functions. More...

Collaboration diagram for Peripheral State and Errors functions:

## Functions
hal_usb_state_t | hal_usb_get_state (usb_handle_t *p_usb)
| Return the USB handle state. More...
uint32_t | hal_usb_get_error (usb_handle_t *p_usb)
| Return the USB error code. More...
hal_status_t | hal_usb_suspend_reg (usb_handle_t *p_usb)
| Suspend some registers related to USB configuration before sleep. More...
hal_status_t | hal_usb_resume_reg (usb_handle_t *p_usb)
| Restore some registers related to USB configuration after sleep. More...

## Detailed Description

USB control functions.

     ===============================================================================
                          ##### Peripheral State and Errors functions #####
     ===============================================================================
        [..]
        This subsection provides a set of functions allowing to control the USB.
         (+) hal_usb_get_state() API can be helpful to check in run-time the state of the USB peripheral
         (+) hal_usb_get_error() check in run-time Errors occurring during communication
         (+) hal_usb_set_timeout() set the timeout during internal process

## Function Documentation

## ◆ hal_usb_get_error()

uint32_t hal_usb_get_error | ( | usb_handle_t * | p_usb | ) |

Return the USB error code.

Parameters

  [in] | p_usb | Pointer to an USB handle which contains the configuration information for the specified USB module.

Returns
  USB error code in bitmap format

## ◆ hal_usb_get_state()

hal_usb_state_t hal_usb_get_state | ( | usb_handle_t * | p_usb | ) |

Return the USB handle state.

Parameters

  [in] | p_usb | Pointer to an USB handle which contains the configuration information for the specified USB module.

Return values

  HAL_USB_STATE_RESET | Peripheral not initialized.
  HAL_USB_STATE_READY | Peripheral initialized and ready for use.
  HAL_USB_STATE_BUSY | An internal process is ongoing.
  HAL_USB_STATE_BUSY_HOST_REST | USB in host rest state during enumeration
  HAL_USB_STATE_BUSY_ADDR | USB in adress state during enumeration
  HAL_USB_STATE_BUSY_CFG | USB in configure state during enumeration
  HAL_USB_STATE_ABORT | Peripheral with abort request ongoing.
  HAL_USB_STATE_ERROR | Peripheral in error.

## ◆ hal_usb_resume_reg()

hal_status_t hal_usb_resume_reg | ( | usb_handle_t * | p_usb | ) |

Restore some registers related to USB configuration after sleep.

This function must be used in conjunction with the hal_usb_suspend_reg().

Parameters

  [in] | p_usb | Pointer to a USB handle which contains the configuration information for the specified USB module.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_usb_suspend_reg()

hal_status_t hal_usb_suspend_reg | ( | usb_handle_t * | p_usb | ) |

Suspend some registers related to USB configuration before sleep.

Parameters

  [in] | p_usb | Pointer to a USB handle which contains the configuration information for the specified USB module.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.