diff --git a/Examples/MAX32650/LP/main.c b/Examples/MAX32650/LP/main.c index 85b4e3c6fa..905cdb2f6d 100644 --- a/Examples/MAX32650/LP/main.c +++ b/Examples/MAX32650/LP/main.c @@ -213,6 +213,9 @@ int main(void) MXC_LP_EnableSRAM0(); // Global variables are in RAM0 + // Resets the USB block to its initial state - where the operating current is at its minimum. + MXC_LP_USBClearPONRST(); + PRINT("All unused RAMs shutdown.\n"); setTrigger(1); diff --git a/Libraries/PeriphDrivers/Include/MAX32650/lp.h b/Libraries/PeriphDrivers/Include/MAX32650/lp.h index 6a925b208e..fd12b36230 100644 --- a/Libraries/PeriphDrivers/Include/MAX32650/lp.h +++ b/Libraries/PeriphDrivers/Include/MAX32650/lp.h @@ -381,6 +381,19 @@ void MXC_LP_EnterDeepSleepMode(void); */ void MXC_LP_EnterBackupMode(void); +/** + * @brief Places the USB block into its initial state where the operating current is at its minimum. + * This function must be called when the USB block is not used in order to achieve low power + * current readings. + */ +void MXC_LP_USBClearPONRST(void); + +/** + * @brief Enables the USB (clock generator) if the USB PONRST (0x410) register was previously cleared + * to put the device into a low power mode. + */ +void MXC_LP_USBSetPONRST(void); + /**@} end of group lp */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Source/LP/lp_me10.c b/Libraries/PeriphDrivers/Source/LP/lp_me10.c index 73af54938b..2e1ab06356 100644 --- a/Libraries/PeriphDrivers/Source/LP/lp_me10.c +++ b/Libraries/PeriphDrivers/Source/LP/lp_me10.c @@ -36,6 +36,7 @@ #include "pwrseq_regs.h" #include "mxc_errors.h" #include "gcr_regs.h" +#include "usbhs_regs.h" #include "mxc_sys.h" /* **** Variable Declaration **** */ @@ -711,3 +712,21 @@ void MXC_LP_EnterBackupMode(void) MXC_GCR->pmr |= MXC_S_GCR_PMR_MODE_BACKUP; while (1) {} } + +/* ************************************************************************** */ +void MXC_LP_USBClearPONRST(void) +{ + // This register is used during the power-on stage or used as a global reset + // for the USB block. For this case, the PONRST is used as a global reset + // and setting this register to 0 will force the USB block to its initial + // state - where the operating current is at its minimum. + MXC_USBHS->m31_phy_ponrst = 0; +} + +/* ************************************************************************** */ +void MXC_LP_USBSetPONRST(void) +{ + // Re-enables the clock generator and the USB block if PONRST was used as + // a global reset for operating in low power modes. + MXC_USBHS->m31_phy_ponrst = 1; +}