Skip to content

Commit

Permalink
perf(Examples,PeriphDrivers): Reset USB block when operating in low p…
Browse files Browse the repository at this point in the history
…ower modes for MAX32650 (#728)
  • Loading branch information
sihyung-maxim authored and EricB-ADI committed Oct 26, 2023
1 parent 6a09801 commit cf16465
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Examples/MAX32650/LP/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 13 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX32650/lp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions Libraries/PeriphDrivers/Source/LP/lp_me10.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 **** */
Expand Down Expand Up @@ -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;
}

0 comments on commit cf16465

Please sign in to comment.