mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
fix(esp_hw_support): fix lightsleep current leakage on usb-phy controlled pad
This commit is contained in:
@@ -7,6 +7,9 @@
|
||||
// The LL layer of the USB-serial-jtag controller
|
||||
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
#include "esp_attr.h"
|
||||
#include "soc/pcr_struct.h"
|
||||
#include "soc/usb_serial_jtag_reg.h"
|
||||
#include "soc/usb_serial_jtag_struct.h"
|
||||
|
||||
@@ -169,6 +172,59 @@ static inline void usb_serial_jtag_ll_txfifo_flush(void)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Disable usb serial jtag pad during light sleep to avoid current leakage
|
||||
*
|
||||
* @return Initial configuration of usb serial jtag pad enable before light sleep
|
||||
*/
|
||||
FORCE_INLINE_ATTR bool usb_serial_jtag_ll_pad_backup_and_disable(void)
|
||||
{
|
||||
bool pad_enabled = USB_SERIAL_JTAG.conf0.usb_pad_enable;
|
||||
|
||||
// Disable USB pad function
|
||||
USB_SERIAL_JTAG.conf0.usb_pad_enable = 0;
|
||||
|
||||
return pad_enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the internal USJ PHY control to D+/D- pad
|
||||
*
|
||||
* @param enable_pad Enable the USJ PHY control to D+/D- pad
|
||||
*/
|
||||
FORCE_INLINE_ATTR void usb_serial_jtag_ll_enable_pad(bool enable_pad)
|
||||
{
|
||||
USB_SERIAL_JTAG.conf0.usb_pad_enable = enable_pad;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the bus clock for USB Serial_JTAG module
|
||||
* @param clk_en True if enable the clock of USB Serial_JTAG module
|
||||
*/
|
||||
FORCE_INLINE_ATTR void usb_serial_jtag_ll_enable_bus_clock(bool clk_en)
|
||||
{
|
||||
PCR.usb_device_conf.usb_device_clk_en = clk_en;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reset the usb serial jtag module
|
||||
*/
|
||||
FORCE_INLINE_ATTR void usb_serial_jtag_ll_reset_register(void)
|
||||
{
|
||||
PCR.usb_device_conf.usb_device_rst_en = 1;
|
||||
PCR.usb_device_conf.usb_device_rst_en = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the enable status USB Serial_JTAG module
|
||||
*
|
||||
* @return Return true if USB Serial_JTAG module is enabled
|
||||
*/
|
||||
FORCE_INLINE_ATTR bool usb_serial_jtag_ll_module_is_enabled(void)
|
||||
{
|
||||
return (PCR.usb_device_conf.usb_device_clk_en && !PCR.usb_device_conf.usb_device_rst_en);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user