CC26xx Driver Library
[sys_ctrl.h] System Control

Functions

void SysCtrlIdle (uint32_t vimsPdMode)
 Force the system into idle mode. More...
 
void SysCtrlShutdownWithAbort (void)
 Try to enter shutdown but abort if wakeup event happened before shutdown. More...
 
void SysCtrlShutdown (void)
 Enable shutdown of the device. More...
 
void SysCtrlStandby (bool retainCache, uint32_t vimsPdMode, uint32_t rechargeMode)
 Force the system into standby mode. More...
 
static uint32_t SysCtrlClockGet (void)
 Get the CPU core clock frequency. More...
 
static void SysCtrlAonSync (void)
 Sync all accesses to the AON register interface. More...
 
static void SysCtrlAonUpdate (void)
 Update all interfaces to AON. More...
 
void SysCtrlSetRechargeBeforePowerDown (uint32_t xoscPowerMode)
 Set Recharge values before entering Power Down. More...
 
void SysCtrlAdjustRechargeAfterPowerDown (uint32_t vddrRechargeMargin)
 Adjust Recharge calculations to be used next. More...
 
void SysCtrl_DCDC_VoltageConditionalControl (void)
 Turns DCDC on or off depending of what is considered to be optimal usage. More...
 
uint32_t SysCtrlResetSourceGet (void)
 Returns the reset source (including "wakeup from shutdown"). More...
 
static void SysCtrlSystemReset (void)
 Perform a full system reset. More...
 
static void SysCtrlClockLossResetEnable (void)
 Enables reset if OSC clock loss event is asserted. More...
 
static void SysCtrlClockLossResetDisable (void)
 Disables reset due to OSC clock loss event. More...
 
#define RSTSRC_PWR_ON   (( AON_PMCTL_RESETCTL_RESET_SRC_PWR_ON ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S ))
 
#define RSTSRC_PIN_RESET   (( AON_PMCTL_RESETCTL_RESET_SRC_PIN_RESET ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S ))
 
#define RSTSRC_VDDS_LOSS   (( AON_PMCTL_RESETCTL_RESET_SRC_VDDS_LOSS ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S ))
 
#define RSTSRC_VDDR_LOSS   (( AON_PMCTL_RESETCTL_RESET_SRC_VDDR_LOSS ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S ))
 
#define RSTSRC_CLK_LOSS   (( AON_PMCTL_RESETCTL_RESET_SRC_CLK_LOSS ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S ))
 
#define RSTSRC_SYSRESET   (( AON_PMCTL_RESETCTL_RESET_SRC_SYSRESET ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S ))
 
#define RSTSRC_WARMRESET   (( AON_PMCTL_RESETCTL_RESET_SRC_WARMRESET ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S ))
 
#define RSTSRC_WAKEUP_FROM_SHUTDOWN   ((( AON_PMCTL_RESETCTL_RESET_SRC_M ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S )) + 1 )
 
#define RSTSRC_WAKEUP_FROM_TCK_NOISE   ((( AON_PMCTL_RESETCTL_RESET_SRC_M ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S )) + 2 )
 

Detailed Description

Function Documentation

§ SysCtrl_DCDC_VoltageConditionalControl()

void SysCtrl_DCDC_VoltageConditionalControl ( void  )

Turns DCDC on or off depending of what is considered to be optimal usage.

This function controls the DCDC only if both the following CCFG settings are true:

  • DCDC is configured to be used.
  • Alternative DCDC settings are defined and enabled.

The DCDC is configured in accordance to the CCFG settings when turned on.

This function should be called periodically.

Returns
None

Referenced by SysCtrlAonUpdate().

325 {
326  uint32_t batThreshold ; // Fractional format with 8 fractional bits.
327  uint32_t aonBatmonBat ; // Fractional format with 8 fractional bits.
328  uint32_t ccfg_ModeConfReg ; // Holds a copy of the CCFG_O_MODE_CONF register.
329  uint32_t aonPmctlPwrctl ; // Reflect whats read/written to the AON_PMCTL_O_PWRCTL register.
330 
331  // We could potentially call this function before any battery voltage measurement
332  // is made/available. In that case we must make sure that we do not turn off the DCDC.
333  // This can be done by doing nothing as long as the battery voltage is 0 (Since the
334  // reset value of the battery voltage register is 0).
335  aonBatmonBat = HWREG( AON_BATMON_BASE + AON_BATMON_O_BAT );
336  if ( aonBatmonBat != 0 ) {
337  // Check if Voltage Conditional Control is enabled
338  // It is enabled if all the following are true:
339  // - DCDC in use (either in active or recharge mode), (in use if one of the corresponding CCFG bits are zero).
340  // - Alternative DCDC settings are enabled ( DIS_ALT_DCDC_SETTING == 0 )
341  // - Not in external regulator mode ( EXT_REG_MODE == 0 )
342  ccfg_ModeConfReg = HWREG( CCFG_BASE + CCFG_O_MODE_CONF );
343 
344  if (((( ccfg_ModeConfReg & CCFG_MODE_CONF_DCDC_RECHARGE_M ) == 0 ) ||
345  (( ccfg_ModeConfReg & CCFG_MODE_CONF_DCDC_ACTIVE_M ) == 0 ) ) &&
346  (( HWREG( AON_PMCTL_BASE + AON_PMCTL_O_PWRCTL ) & AON_PMCTL_PWRCTL_EXT_REG_MODE ) == 0 ) &&
347  (( HWREG( CCFG_BASE + CCFG_O_SIZE_AND_DIS_FLAGS ) & CCFG_SIZE_AND_DIS_FLAGS_DIS_ALT_DCDC_SETTING ) == 0 ) )
348  {
349  aonPmctlPwrctl = HWREG( AON_PMCTL_BASE + AON_PMCTL_O_PWRCTL );
350  batThreshold = (((( HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 ) &
351  CCFG_MODE_CONF_1_ALT_DCDC_VMIN_M ) >>
352  CCFG_MODE_CONF_1_ALT_DCDC_VMIN_S ) + 28 ) << 4 );
353 
354  if ( aonPmctlPwrctl & ( AON_PMCTL_PWRCTL_DCDC_EN_M | AON_PMCTL_PWRCTL_DCDC_ACTIVE_M )) {
355  // DCDC is ON, check if it should be switched off
356  if ( aonBatmonBat < batThreshold ) {
357  aonPmctlPwrctl &= ~( AON_PMCTL_PWRCTL_DCDC_EN_M | AON_PMCTL_PWRCTL_DCDC_ACTIVE_M );
358 
359  HWREG( AON_PMCTL_BASE + AON_PMCTL_O_PWRCTL ) = aonPmctlPwrctl;
360  }
361  } else {
362  // DCDC is OFF, check if it should be switched on
363  if ( aonBatmonBat > batThreshold ) {
364  if (( ccfg_ModeConfReg & CCFG_MODE_CONF_DCDC_RECHARGE_M ) == 0 ) aonPmctlPwrctl |= AON_PMCTL_PWRCTL_DCDC_EN_M ;
365  if (( ccfg_ModeConfReg & CCFG_MODE_CONF_DCDC_ACTIVE_M ) == 0 ) aonPmctlPwrctl |= AON_PMCTL_PWRCTL_DCDC_ACTIVE_M ;
366 
367  HWREG( AON_PMCTL_BASE + AON_PMCTL_O_PWRCTL ) = aonPmctlPwrctl;
368  }
369  }
370  }
371  }
372 }

§ SysCtrlAdjustRechargeAfterPowerDown()

void SysCtrlAdjustRechargeAfterPowerDown ( uint32_t  vddrRechargeMargin)

Adjust Recharge calculations to be used next.

Nothing to be done but keeping this function for platform compatibility.

Returns
None

Referenced by SysCtrlAonUpdate().

313 {
314  // Nothing to be done but keeping this function for platform compatibility.
315 }

§ SysCtrlAonSync()

static void SysCtrlAonSync ( void  )
inlinestatic

Sync all accesses to the AON register interface.

When this function returns, all writes to the AON register interface are guaranteed to have propagated to hardware. The function will return immediately if no AON writes are pending; otherwise, it will wait for the next AON clock before returning.

Returns
None
See also
SysCtrlAonUpdate()

Referenced by SetupAfterColdResetWakeupFromShutDownCfg3(), SysCtrlIdle(), and SysCtrlStandby().

337 {
338  // Sync the AON interface
339  HWREG(AON_RTC_BASE + NONSECURE_OFFSET + AON_RTC_O_SYNC);
340 }

§ SysCtrlAonUpdate()

static void SysCtrlAonUpdate ( void  )
inlinestatic

Update all interfaces to AON.

When this function returns, at least 1 clock cycle has progressed on the AON domain, so that any outstanding updates to and from the AON interface is guaranteed to be in sync.

Note
This function should primarily be used after wakeup from sleep modes, as it will guarantee that all shadow registers on the AON interface are updated before reading any AON registers from the MCU domain. If a write has been done to the AON interface it is sufficient to call the SysCtrlAonSync().
Returns
None
See also
SysCtrlAonSync()

Referenced by SysCtrlShutdownWithAbort().

362 {
363  // Force a clock cycle on the AON interface to guarantee all registers are
364  // in sync.
365  HWREG(AON_RTC_BASE + NONSECURE_OFFSET + AON_RTC_O_SYNC) = 1;
366  HWREG(AON_RTC_BASE + NONSECURE_OFFSET + AON_RTC_O_SYNC);
367 }
Here is the call graph for this function:

§ SysCtrlClockGet()

static uint32_t SysCtrlClockGet ( void  )
inlinestatic

Get the CPU core clock frequency.

Use this function to get the current clock frequency for the CPU.

The CPU can run from 48 MHz and down to 750kHz. The frequency is defined by the combined division factor of the SYSBUS and the CPU clock divider.

Returns
Returns the current CPU core clock frequency.
316 {
317  // Return fixed clock speed
318  return( GET_MCU_CLOCK );
319 }

§ SysCtrlClockLossResetDisable()

static void SysCtrlClockLossResetDisable ( void  )
inlinestatic

Disables reset due to OSC clock loss event.

Note
This function shall typically not be called because the clock loss reset functionality is controlled by the boot code (a factory configuration defines whether it is set or not).
Returns
None
See also
SysCtrlClockLossResetEnable()
512 {
513  // Clear clock loss enable bit in AON_SYSCTRL
514  HWREGBITW(AON_PMCTL_BASE + AON_PMCTL_O_RESETCTL, AON_PMCTL_RESETCTL_CLK_LOSS_EN_BITN) = 0;
515 }

§ SysCtrlClockLossResetEnable()

static void SysCtrlClockLossResetEnable ( void  )
inlinestatic

Enables reset if OSC clock loss event is asserted.

Clock loss circuit in analog domain must be enabled as well in order to actually enable for a clock loss reset to occur OSCClockLossEventEnable().

Note
This function shall typically not be called because the clock loss reset functionality is controlled by the boot code (a factory configuration defines whether it is set or not).
Returns
None
See also
SysCtrlClockLossResetDisable(), OSCClockLossEventEnable()
492 {
493  // Set clock loss enable bit in AON_SYSCTRL
494  HWREGBITW(AON_PMCTL_BASE + AON_PMCTL_O_RESETCTL, AON_PMCTL_RESETCTL_CLK_LOSS_EN_BITN) = 1;
495 }

§ SysCtrlIdle()

void SysCtrlIdle ( uint32_t  vimsPdMode)

Force the system into idle mode.

This function forces the system into IDLE mode by configuring the requested VIMS mode, enabling cache retention and powering off the CPU power domain.

Parameters
vimsPdModeselects the requested VIMS power domain mode The parameter must be one of the following:
Returns
None
81 {
82  // Configure the VIMS mode
83  HWREG(PRCM_BASE + NONSECURE_OFFSET + PRCM_O_PDCTL1VIMS) = vimsPdMode;
84 
85  // Always keep cache retention ON in IDLE
87 
88  // Turn off the CPU power domain, will take effect when PRCMDeepSleep() executes
90 
91  // Ensure any possible outstanding AON writes complete
93 
94  // Invoke deep sleep to go to IDLE
95  PRCMDeepSleep();
96 }
static void SysCtrlAonSync(void)
Sync all accesses to the AON register interface.
Definition: sys_ctrl.h:336
void PRCMDeepSleep(void)
Put the processor into deep-sleep mode.
Definition: prcm.c:680
static void PRCMCacheRetentionEnable(void)
Enable CACHE RAM retention.
Definition: prcm.h:1143
#define PRCM_DOMAIN_CPU
Definition: prcm.h:151
void PRCMPowerDomainOff(uint32_t ui32Domains)
Turn off a specific power domain.
Definition: prcm.c:461
Here is the call graph for this function:

§ SysCtrlResetSourceGet()

uint32_t SysCtrlResetSourceGet ( void  )

Returns the reset source (including "wakeup from shutdown").

In case of RSTSRC_WAKEUP_FROM_SHUTDOWN the application is responsible for unlatching the outputs (disable pad sleep). See PowerCtrlPadSleepDisable() for more information.

Returns
Returns the reset source.
382 {
383  uint32_t aonPmctlResetCtl = HWREG( AON_PMCTL_BASE + AON_PMCTL_O_RESETCTL );
384 
385  if ( aonPmctlResetCtl & AON_PMCTL_RESETCTL_WU_FROM_SD_M ) {
386  if ( aonPmctlResetCtl & AON_PMCTL_RESETCTL_GPIO_WU_FROM_SD_M ) {
387  return ( RSTSRC_WAKEUP_FROM_SHUTDOWN );
388  } else {
389  return ( RSTSRC_WAKEUP_FROM_TCK_NOISE );
390  }
391  } else {
392  return (( aonPmctlResetCtl & AON_PMCTL_RESETCTL_RESET_SRC_M ) >> AON_PMCTL_RESETCTL_RESET_SRC_S );
393  }
394 }
#define RSTSRC_WAKEUP_FROM_TCK_NOISE
Definition: sys_ctrl.h:428
#define RSTSRC_WAKEUP_FROM_SHUTDOWN
Definition: sys_ctrl.h:427

§ SysCtrlSetRechargeBeforePowerDown()

void SysCtrlSetRechargeBeforePowerDown ( uint32_t  xoscPowerMode)

Set Recharge values before entering Power Down.

This function shall be called just before entering Power Down. This function typically does nothing (default setting), but if temperature compensated recharge level are enabled (by setting CCFG_MODE_CONF_VDDR_TRIM_SLEEP_TC = 0) it adds temperature compensation to the recharge level.

Parameters
xoscPowerMode(typically running in XOSC_IN_HIGH_POWER_MODE all the time).
Returns
None

Referenced by SysCtrlAonUpdate(), and SysCtrlStandby().

260 {
261  uint32_t ccfg_ModeConfReg ;
262 
263  // If external regulator mode we shall:
264  // - Set static recharge timing in AON_PMCTL_RECHARGECFG (MODE_STATIC)
265  // - Set recharge period to approximately 500 mS (perM=31, perE=5 => 0xFD)
266  if ( HWREG( AON_PMCTL_BASE + AON_PMCTL_O_PWRCTL ) & AON_PMCTL_PWRCTL_EXT_REG_MODE ) {
267  HWREG( AON_PMCTL_BASE + AON_PMCTL_O_RECHARGECFG ) = ( AON_PMCTL_RECHARGECFG_MODE_STATIC | 0x000000FD );
268  return;
269  }
270 
271  // read the MODE_CONF register in CCFG
272  ccfg_ModeConfReg = HWREG( CCFG_BASE + CCFG_O_MODE_CONF );
273  // Do temperature compensation if enabled
274  if (( ccfg_ModeConfReg & CCFG_MODE_CONF_VDDR_TRIM_SLEEP_TC ) == 0 ) {
275  int32_t vddrSleepDelta ;
276  int32_t curTemp ;
277  int32_t tcDelta ;
278  int32_t vddrSleepTrim ;
279 
280  // Get VDDR_TRIM_SLEEP_DELTA + 1 (sign extended) ==> vddrSleepDelta = -7..+8
281  vddrSleepDelta = (((int32_t)( ccfg_ModeConfReg << ( 32 - CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_W - CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_S )))
282  >> ( 32 - CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_W )) + 1 ;
283  curTemp = AONBatMonTemperatureGetDegC();
284  tcDelta = ( 62 - curTemp ) >> 3;
285  if ( tcDelta > 7 ) {
286  tcDelta = 7 ;
287  }
288  if ( tcDelta > vddrSleepDelta ) {
289  vddrSleepDelta = tcDelta ;
290  }
291  vddrSleepTrim = (( HWREG( FCFG1_BASE + FCFG1_O_MISC_TRIM ) & FCFG1_MISC_TRIM_TRIM_RECHARGE_COMP_REFLEVEL_M ) >>
292  FCFG1_MISC_TRIM_TRIM_RECHARGE_COMP_REFLEVEL_S ) ;
293 
294  vddrSleepTrim -= vddrSleepDelta ;
295  if ( vddrSleepTrim > 15 ) vddrSleepTrim = 15 ;
296  if ( vddrSleepTrim < 1 ) vddrSleepTrim = 1 ;
297  // Write adjusted value using MASKED write (MASK8)
298  HWREGB( ADI3_BASE + ADI_O_MASK4B + ( ADI_3_REFSYS_O_CTL_RECHARGE_CMP0 * 2 )) = (( ADI_3_REFSYS_CTL_RECHARGE_CMP0_TRIM_RECHARGE_COMP_REFLEVEL_M << 4 ) |
299  (( vddrSleepTrim << ADI_3_REFSYS_CTL_RECHARGE_CMP0_TRIM_RECHARGE_COMP_REFLEVEL_S ) & ADI_3_REFSYS_CTL_RECHARGE_CMP0_TRIM_RECHARGE_COMP_REFLEVEL_M ) );
300  // Make a dummy read in order to make sure the write above is done before going into standby
301  HWREGB( ADI3_BASE + ADI_3_REFSYS_O_CTL_RECHARGE_CMP0 );
302  }
303 }
int32_t AONBatMonTemperatureGetDegC(void)
Get the current temperature measurement as a signed value in Deg Celsius.
Definition: aon_batmon.c:58
Here is the call graph for this function:

§ SysCtrlShutdown()

void SysCtrlShutdown ( void  )

Enable shutdown of the device.

This function puts the device in shutdown state. The device automatically latches all outputs (pads in sleep) before it turns off all internal power supplies.

JTAG must be disconnected and JTAG power domain must be off before device can enter shutdown. This function waits until the device satisfies all shutdown conditions before it enters shutdown.

Note
The application must unlatch the outputs when the device wakes up from shutdown. It is recommended that any outputs that need to be restored after a wakeup from shutdown are restored before outputs are unlatched in order to avoid glitches.

See PowerCtrlPadSleepDisable() for information about how to unlatch outputs (disable pad sleep) after wakeup from shutdown.

Note
Wakeup events are only detected after the device enters shutdown.

See IOCIOShutdownSet() for information about how to enable wakeup from shutdown.

See SysCtrlResetSourceGet() for information about how to detect wakeup from shutdown.

It is recommended to disable interrupts before calling this function. Shutdown happens immediately when the device satisfies all shutdown conditions thus interrupt routines triggered after this function is called might be aborted.

Returns
This function does not return.

Referenced by SysCtrlShutdownWithAbort().

149 {
150  // Request shutdown mode
151  HWREG(AON_PMCTL_BASE + AON_PMCTL_O_SHUTDOWN) = AON_PMCTL_SHUTDOWN_EN;
152 
153  // Make sure System CPU does not continue beyond this point.
154  // Shutdown happens when all shutdown conditions are met.
155  while(1);
156 }

§ SysCtrlShutdownWithAbort()

void SysCtrlShutdownWithAbort ( void  )

Try to enter shutdown but abort if wakeup event happened before shutdown.

This function puts the device in shutdown state if no wakeup events are detected before shutdown.

Compared to the basic SysCtrlShutdown() function this function makes sure that wakeup events that happen before actual shutdown are also detected. This function either enters shutdown with a guaranteed wakeup detection or returns to the caller function due to a pre-shutdown wakeup event.

See SysCtrlShutdown() for basic information about how to configure the device before shutdown and how to wakeup from shutdown.

This function uses IO edge detection in addition to the mandatory wakeup configuration. Additional requirements to the application for this function are:

  • Before :
    • When the application configures an IO for wakeup (see IOCIOShutdownSet()) the application must also configure the same IO for edge detection (see IOCIOIntSet()).
    • Edge detection must use the same polarity as the wakeup configuration.
    • Application must enable peripheral power domain (see PRCMPowerDomainOn()) and enable GPIO module in the peripheral power domain (see PRCMPeripheralRunEnable()).
  • After :
    • An edge, with same polarity as a wakeup event, was detected on a wakeup enabled IO before shutdown, and the shutdown was aborted. The application must clear the event generated by the edge detect (see GPIO_clearEventDio()) and decide what happens next.

Useful functions related to shutdown:

It is recommended to disable interrupts before calling this function because:

  • Pads are in sleep mode while this function runs.
  • An interrupt routine might be terminated if it is triggered after the decision to enter shutdown.
Returns
None
104 {
105  uint32_t wakeupDetected = 0;
106  uint32_t ioIndex = 0;
107 
108  uint32_t ioCount = (( HWREG( FCFG1_BASE + FCFG1_O_IOCONF ) &
109  FCFG1_IOCONF_GPIO_CNT_M ) >> FCFG1_IOCONF_GPIO_CNT_S ) ;
110 
111  // Wakeup events are detected when pads are in sleep mode
113 
114  // Make sure all potential events have propagated before checking event flags
117 
118  // For all IO CFG registers check if wakeup detect is enabled
119  for(ioIndex = 0; ioIndex < ioCount; ioIndex++)
120  {
121  // Read MSB from WU_CFG bit field
122  if( HWREG(IOC_BASE + IOC_O_IOCFG0 + (ioIndex * 4) ) & (1 << (IOC_IOCFG0_WU_CFG_S + IOC_IOCFG0_WU_CFG_W - 1)) )
123  {
124  if (GPIO_getEventDio(ioIndex))
125  {
126  wakeupDetected = 1;
127  break;
128  }
129  }
130  }
131 
132  // If no edge detect flags for wakeup enabled IOs are set then shut down the device
133  if( wakeupDetected == 0 )
134  {
135  SysCtrlShutdown();
136  }
137  else
138  {
140  }
141 }
static uint32_t GPIO_getEventDio(uint32_t dioNumber)
Gets the event status of a specific DIO.
Definition: gpio.h:285
static void SysCtrlAonUpdate(void)
Update all interfaces to AON.
Definition: sys_ctrl.h:361
static void PowerCtrlPadSleepDisable(void)
Disables pad sleep in order to unlatch device outputs after wakeup from shutdown. ...
Definition: pwr_ctrl.h:262
void SysCtrlShutdown(void)
Enable shutdown of the device.
Definition: sys_ctrl.c:148
static void PowerCtrlPadSleepEnable(void)
Enables pad sleep in order to latch device outputs before shutdown.
Definition: pwr_ctrl.h:240
Here is the call graph for this function:

§ SysCtrlStandby()

void SysCtrlStandby ( bool  retainCache,
uint32_t  vimsPdMode,
uint32_t  rechargeMode 
)

Force the system into standby mode.

This function forces all power domains (RFCORE, SERIAL, PERIPHERAL) off. The VIMS and CPU power domains are turned off by the HW when the PRCMDeepSleep() function is called. The IOs are latched (frozen) before the power domains are turned off to avoid glitches. The VIMS retention (cache) and VIMS module are turned off if requested. The deep-sleep clock for the crypto and DMA modules are turned off, as they must be off in order to enter standby. This function assumes that the LF clock has already been switched to and that the LF clock qualifiers must have been disabled/bypassed.

In internal regulator mode the adaptive recharge functionality is enabled with fixed parameter values. In external regulator mode the recharge functionality is disabled.

Note
This function is optimized to execute with TI-RTOS. There might be application specific prerequisites you would want to do before entering standby which deviate from this specific implementation.
Parameters
retainCacheselects if VIMS cache shall be retained or not.
  • false : VIMS cache is not retained
  • true : VIMS cache is retained
vimsPdModeselects the VIMS power domain mode. The parameter must be one of the following:
rechargeModespecifies the requested recharge mode. The parameter must be one of the following:
Returns
None
164 {
165  uint32_t modeVIMS;
166 
167  // In external regulator mode:
168  // Set static recharge timing to approximately 500 milliseconds
169  // Else:
170  // Handle compensation for improving RCOSC_LF stability at low temperatures
171  // as configured in CCFG
173 
174  // Freeze the IOs on the boundary between MCU and AON
176 
177  // Ensure any possible outstanding AON writes complete before turning off the power domains
178  SysCtrlAonSync();
179 
180  // Request power off of domains in the MCU voltage domain
182 
183  // Ensure that no clocks are forced on in any modes for Crypto, DMA and I2S
184  HWREG(PRCM_BASE + PRCM_O_SECDMACLKGR) &= (~PRCM_SECDMACLKGR_CRYPTO_AM_CLK_EN & ~PRCM_SECDMACLKGR_DMA_AM_CLK_EN);
185  HWREG(PRCM_BASE + PRCM_O_I2SCLKGR) &= ~PRCM_I2SCLKGR_AM_CLK_EN;
186 
187  // Gate running deep sleep clocks for Crypto, DMA and I2S
191 
192  // Load the new clock settings
193  PRCMLoadSet();
194 
195  // Configure the VIMS power domain mode
196  HWREG(PRCM_BASE + PRCM_O_PDCTL1VIMS) = vimsPdMode;
197 
198  // Request uLDO during standby
200 
201  // In external regulator mode:
202  // - Setting the AON_PMCTL_O_RECHARGECFG register is already handled above.
203  // (in function SysCtrlSetRechargeBeforePowerDown() )
204  // Else:
205  // - Set the AON_PMCTL_O_RECHARGECFG register as described below.
206  if ((HWREG(AON_PMCTL_BASE + AON_PMCTL_O_PWRCTL) & AON_PMCTL_PWRCTL_EXT_REG_MODE)==0)
207  {
208  // In internal regulator mode the recharge functionality is set up with
209  // adaptive recharge mode and fixed parameter values
210  if(rechargeMode == SYSCTRL_PREFERRED_RECHARGE_MODE)
211  {
212  // Enable the Recharge Comparator
213  HWREG(AON_PMCTL_BASE + AON_PMCTL_O_RECHARGECFG) = AON_PMCTL_RECHARGECFG_MODE_COMPARATOR;
214  }
215  else
216  {
217  // Set requested recharge mode
218  HWREG(AON_PMCTL_BASE + AON_PMCTL_O_RECHARGECFG) = rechargeMode;
219  }
220  }
221 
222  // Ensure all writes have taken effect
223  SysCtrlAonSync();
224 
225  // Ensure UDMA, Crypto and I2C clocks are turned off
226  while (!PRCMLoadGet()) {;}
227 
228  // Ensure power domains have been turned off.
229  // CPU power domain will power down when PRCMDeepSleep() executes.
231 
232  // Turn off cache retention if requested
233  if (retainCache == false) {
234 
235  // Get the current VIMS mode
236  do {
237  modeVIMS = VIMSModeGet(VIMS_BASE);
238  } while (modeVIMS == VIMS_MODE_CHANGING);
239 
240  // If in a cache mode, turn VIMS off
241  if (modeVIMS == VIMS_MODE_ENABLED) {
242  VIMSModeSet(VIMS_BASE, VIMS_MODE_OFF);
243  }
244 
245  // Disable retention of cache RAM
247  }
248 
249  // Invoke deep sleep to go to STANDBY
250  PRCMDeepSleep();
251 }
static void SysCtrlAonSync(void)
Sync all accesses to the AON register interface.
Definition: sys_ctrl.h:336
void VIMSModeSet(uint32_t ui32Base, uint32_t ui32Mode)
Set the operational mode of the VIMS.
Definition: vims.c:90
#define XOSC_IN_HIGH_POWER_MODE
Definition: sys_ctrl.h:132
static void AONIOCFreezeEnable(void)
Freeze the IOs.
Definition: aon_ioc.h:206
#define PRCM_PERIPH_I2S
Definition: prcm.h:208
#define VIMS_MODE_ENABLED
Definition: vims.h:96
#define PRCM_DOMAIN_PERIPH
Definition: prcm.h:141
static bool PRCMLoadGet(void)
Check if any of the load sensitive register has been updated.
Definition: prcm.h:605
static void PRCMMcuUldoConfigure(uint32_t ui32Enable)
Assert or de-assert a request for the uLDO.
Definition: prcm.h:331
static void PRCMCacheRetentionDisable(void)
Disable CACHE RAM retention.
Definition: prcm.h:1158
uint32_t VIMSModeGet(uint32_t ui32Base)
Get the current operational mode of the VIMS.
Definition: vims.c:115
#define SYSCTRL_PREFERRED_RECHARGE_MODE
Definition: sys_ctrl.h:149
#define PRCM_PERIPH_CRYPTO
Definition: prcm.h:203
#define PRCM_PERIPH_UDMA
Definition: prcm.h:206
void SysCtrlSetRechargeBeforePowerDown(uint32_t xoscPowerMode)
Set Recharge values before entering Power Down.
Definition: sys_ctrl.c:259
#define VIMS_MODE_CHANGING
Definition: vims.h:93
void PRCMDeepSleep(void)
Put the processor into deep-sleep mode.
Definition: prcm.c:680
#define VIMS_MODE_OFF
Definition: vims.h:97
#define PRCM_DOMAIN_SERIAL
Definition: prcm.h:139
#define PRCM_DOMAIN_RFCORE
Definition: prcm.h:137
static void PRCMLoadSet(void)
Use this function to synchronize the load settings.
Definition: prcm.h:587
#define PRCM_DOMAIN_CPU
Definition: prcm.h:151
void PRCMPowerDomainOff(uint32_t ui32Domains)
Turn off a specific power domain.
Definition: prcm.c:461
void PRCMPeripheralDeepSleepDisable(uint32_t ui32Peripheral)
Disables a peripheral in deep-sleep mode.
Definition: prcm.c:582
uint32_t PRCMPowerDomainsAllOff(uint32_t ui32Domains)
Get the status for a specific power domain.
Definition: prcm.c:598
#define PRCM_DOMAIN_POWER_OFF
Definition: prcm.h:159
Here is the call graph for this function:

§ SysCtrlSystemReset()

static void SysCtrlSystemReset ( void  )
inlinestatic

Perform a full system reset.

Returns
The chip will reset and hence never return from this call.
462 {
463  // Disable CPU interrupts
464  CPUcpsid();
465  // Write reset register
466  HWREGBITW( AON_PMCTL_BASE + AON_PMCTL_O_RESETCTL, AON_PMCTL_RESETCTL_SYSRESET_BITN ) = 1;
467  // Finally, wait until the above write propagates
468  while ( 1 ) {
469  // Do nothing, just wait for the reset (and never return from here)
470  }
471 }
uint32_t CPUcpsid(void)
Disable all external interrupts.
Definition: cpu.c:66
Here is the call graph for this function:

Macro Definition Documentation

§ CPU_DEEP_SLEEP

#define CPU_DEEP_SLEEP   0x00000002

§ CPU_RUN

#define CPU_RUN   0x00000000

§ CPU_SLEEP

#define CPU_SLEEP   0x00000001

§ RSTSRC_CLK_LOSS

#define RSTSRC_CLK_LOSS   (( AON_PMCTL_RESETCTL_RESET_SRC_CLK_LOSS ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S ))

§ RSTSRC_PIN_RESET

#define RSTSRC_PIN_RESET   (( AON_PMCTL_RESETCTL_RESET_SRC_PIN_RESET ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S ))

§ RSTSRC_PWR_ON

#define RSTSRC_PWR_ON   (( AON_PMCTL_RESETCTL_RESET_SRC_PWR_ON ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S ))

§ RSTSRC_SYSRESET

#define RSTSRC_SYSRESET   (( AON_PMCTL_RESETCTL_RESET_SRC_SYSRESET ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S ))

§ RSTSRC_VDDR_LOSS

#define RSTSRC_VDDR_LOSS   (( AON_PMCTL_RESETCTL_RESET_SRC_VDDR_LOSS ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S ))

§ RSTSRC_VDDS_LOSS

#define RSTSRC_VDDS_LOSS   (( AON_PMCTL_RESETCTL_RESET_SRC_VDDS_LOSS ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S ))

§ RSTSRC_WAKEUP_FROM_SHUTDOWN

#define RSTSRC_WAKEUP_FROM_SHUTDOWN   ((( AON_PMCTL_RESETCTL_RESET_SRC_M ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S )) + 1 )

Referenced by SysCtrlResetSourceGet().

§ RSTSRC_WAKEUP_FROM_TCK_NOISE

#define RSTSRC_WAKEUP_FROM_TCK_NOISE   ((( AON_PMCTL_RESETCTL_RESET_SRC_M ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S )) + 2 )

Referenced by SysCtrlResetSourceGet().

§ RSTSRC_WARMRESET

#define RSTSRC_WARMRESET   (( AON_PMCTL_RESETCTL_RESET_SRC_WARMRESET ) >> ( AON_PMCTL_RESETCTL_RESET_SRC_S ))

§ SYSCTRL_PREFERRED_RECHARGE_MODE

#define SYSCTRL_PREFERRED_RECHARGE_MODE   0xFFFFFFFF

Referenced by SysCtrlStandby().

§ SYSCTRL_SYSBUS_OFF

#define SYSCTRL_SYSBUS_OFF   0x00000000

§ SYSCTRL_SYSBUS_ON

#define SYSCTRL_SYSBUS_ON   0x00000001

§ VIMS_NO_PWR_UP_MODE

#define VIMS_NO_PWR_UP_MODE   2

§ VIMS_ON_BUS_ON_MODE

#define VIMS_ON_BUS_ON_MODE   1

§ VIMS_ON_CPU_ON_MODE

#define VIMS_ON_CPU_ON_MODE   0

§ XOSC_IN_HIGH_POWER_MODE

#define XOSC_IN_HIGH_POWER_MODE   0

Referenced by SysCtrlStandby().

§ XOSC_IN_LOW_POWER_MODE

#define XOSC_IN_LOW_POWER_MODE   1