mirror of
https://github.com/espressif/esp-idf.git
synced 2024-09-19 14:26:01 -04:00
feat(usb): Add usb_host_lib_set_root_port_power()
This commit adds the usb_host_lib_set_root_port_power() function. This provides a public API for users to power the root port OFF or ON at runtime, thus trigger a disconnection or allow connections respectively. In addition, the usb_host_config_t.root_port_unpowered install configuration is provided to allow users to install the USB Host Library without automatically powering ON the root port.
This commit is contained in:
parent
59e1838270
commit
54db1cda8b
@ -101,10 +101,13 @@ typedef void (*usb_host_client_event_cb_t)(const usb_host_client_event_msg_t *ev
|
||||
* Configuration structure of the USB Host Library. Provided in the usb_host_install() function
|
||||
*/
|
||||
typedef struct {
|
||||
bool skip_phy_setup; /**< If set, the USB Host Library will not configure the USB PHY thus allowing the user
|
||||
to manually configure the USB PHY before calling usb_host_install(). Users should
|
||||
set this if they want to use an external USB PHY. Otherwise, the USB Host Library
|
||||
will automatically configure the internal USB PHY */
|
||||
bool skip_phy_setup; /**< If set, the USB Host Library will not configure the USB PHY thus allowing
|
||||
the user to manually configure the USB PHY before calling usb_host_install().
|
||||
Users should set this if they want to use an external USB PHY. Otherwise,
|
||||
the USB Host Library will automatically configure the internal USB PHY */
|
||||
bool root_port_unpowered; /**< If set, the USB Host Library will not power on the root port on installation.
|
||||
This allows users to power on the root port manually by calling
|
||||
usb_host_lib_set_root_port_power(). */
|
||||
int intr_flags; /**< Interrupt flags for the underlying ISR used by the USB Host stack */
|
||||
usb_host_enum_filter_cb_t enum_filter_cb; /**< Enumeration filter callback. Enable CONFIG_USB_HOST_ENABLE_ENUM_FILTER_CALLBACK
|
||||
to use this feature. Set to NULL otherwise. */
|
||||
@ -206,6 +209,21 @@ esp_err_t usb_host_lib_unblock(void);
|
||||
*/
|
||||
esp_err_t usb_host_lib_info(usb_host_lib_info_t *info_ret);
|
||||
|
||||
/**
|
||||
* @brief Power the root port ON or OFF
|
||||
*
|
||||
* - Powering ON the root port will allow device connections to occur
|
||||
* - Powering OFF the root port will disconnect all devices downstream off the root port and prevent
|
||||
* any further device connections.
|
||||
*
|
||||
* @note If 'usb_host_config_t.root_port_unpowered' was set on USB Host Library installation, users must call this
|
||||
* function to power ON the root port before any device connections can occur.
|
||||
*
|
||||
* @param enable True to power the root port ON, false to power OFF
|
||||
* @return esp_err_t
|
||||
*/
|
||||
esp_err_t usb_host_lib_set_root_port_power(bool enable);
|
||||
|
||||
// ------------------------------------------------ Client Functions ---------------------------------------------------
|
||||
|
||||
/**
|
||||
|
@ -545,8 +545,11 @@ esp_err_t usb_host_install(const usb_host_config_t *config)
|
||||
p_host_lib_obj = host_lib_obj;
|
||||
HOST_EXIT_CRITICAL();
|
||||
|
||||
if (!config->root_port_unpowered) {
|
||||
// Start the root hub
|
||||
ESP_ERROR_CHECK(hub_root_start());
|
||||
}
|
||||
|
||||
ret = ESP_OK;
|
||||
return ret;
|
||||
|
||||
@ -699,6 +702,18 @@ esp_err_t usb_host_lib_info(usb_host_lib_info_t *info_ret)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t usb_host_lib_set_root_port_power(bool enable)
|
||||
{
|
||||
esp_err_t ret;
|
||||
if (enable) {
|
||||
ret = hub_root_start();
|
||||
} else {
|
||||
ret = hub_root_stop();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ------------------------------------------------ Client Functions ---------------------------------------------------
|
||||
|
||||
// ----------------------- Private -------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user