CC26xx Driver Library
[setup.h] Setup

Functions

void SetupTrimDevice (void)
 Performs the necessary trim of the device which is not done in ROM boot code. More...
 

Detailed Description

This module contains functions for device setup which is not done in boot code.

Function Documentation

§ SetupTrimDevice()

void SetupTrimDevice ( void  )

Performs the necessary trim of the device which is not done in ROM boot code.

This function should only execute coming from ROM boot.

The following is handled by this function:

  • Checks if the driverlib variant used by the application is supported by the device. Execution is halted in case of unsupported driverlib variant.
  • Configures VIMS cache mode based on setting in CCFG.
  • Configures functionalities like DCDC and XOSC dependent on startup modes like cold reset, wakeup from shutdown and wakeup from from powerdown.
  • Configures VIMS power domain control.
  • Configures optimal wait time for flash FSM in cases where flash pump wakes up from sleep.
Note
The current implementation does not take soft reset into account. However, it does no damage to execute it again. It only consumes time.
This function is called by the compiler specific device startup codes that are integrated in the SimpleLink SDKs for CC13xx/CC26XX devices.
Returns
None
125 {
126  uint32_t ui32Fcfg1Revision;
127  uint32_t ui32AonSysResetctl;
128 
129  // Get layout revision of the factory configuration area
130  // (Handle undefined revision as revision = 0)
131  ui32Fcfg1Revision = HWREG(FCFG1_BASE + FCFG1_O_FCFG1_REVISION);
132  if ( ui32Fcfg1Revision == 0xFFFFFFFF ) {
133  ui32Fcfg1Revision = 0;
134  }
135 
136  // This driverlib version and setup file is for the CC13x2, CC26x2 PG2.0 or later chips.
137  // Halt if violated
139 
140  // Enable standby in flash bank
141  HWREGBITW( FLASH_BASE + FLASH_O_CFG, FLASH_CFG_DIS_STANDBY_BITN ) = 0;
142 
143  // Select correct CACHE mode and set correct CACHE configuration
144 #if ( CCFG_BASE == CCFG_BASE_DEFAULT )
146 #else
147  NOROM_SetupSetCacheModeAccordingToCcfgSetting();
148 #endif
149 
150  // 1. Check for powerdown
151  // 2. Check for shutdown
152  // 3. Assume cold reset if none of the above.
153  //
154  // It is always assumed that the application will freeze the latches in
155  // AON_IOC when going to powerdown in order to retain the values on the IOs.
156  //
157  // NB. If this bit is not cleared before proceeding to powerdown, the IOs
158  // will all default to the reset configuration when restarting.
159  if( ! ( HWREGBITW( AON_IOC_BASE + AON_IOC_O_IOCLATCH, AON_IOC_IOCLATCH_EN_BITN )))
160  {
161  // NB. This should be calling a ROM implementation of required trim and
162  // compensation
163  // e.g. TrimAfterColdResetWakeupFromShutDownWakeupFromPowerDown()
165  }
166  // Check for shutdown
167  //
168  // When device is going to shutdown the hardware will automatically clear
169  // the SLEEPDIS bit in the SLEEP register in the AON_PMCTL module.
170  // It is left for the application to assert this bit when waking back up,
171  // but not before the desired IO configuration has been re-established.
172  else if( ! ( HWREGBITW( AON_PMCTL_BASE + AON_PMCTL_O_SLEEPCTL, AON_PMCTL_SLEEPCTL_IO_PAD_SLEEP_DIS_BITN )))
173  {
174  // NB. This should be calling a ROM implementation of required trim and
175  // compensation
176  // e.g. TrimAfterColdResetWakeupFromShutDown() -->
177  // TrimAfterColdResetWakeupFromShutDownWakeupFromPowerDown();
178  TrimAfterColdResetWakeupFromShutDown(ui32Fcfg1Revision);
180  }
181  else
182  {
183  // Consider adding a check for soft reset to allow debugging to skip
184  // this section!!!
185  //
186  // NB. This should be calling a ROM implementation of required trim and
187  // compensation
188  // e.g. TrimAfterColdReset() -->
189  // TrimAfterColdResetWakeupFromShutDown() -->
190  // TrimAfterColdResetWakeupFromShutDownWakeupFromPowerDown()
192  TrimAfterColdResetWakeupFromShutDown(ui32Fcfg1Revision);
194 
195  }
196 
197  // Set VIMS power domain control.
198  // PDCTL1VIMS = 0 ==> VIMS power domain is only powered when CPU power domain is powered
199  HWREG( PRCM_BASE + PRCM_O_PDCTL1VIMS ) = 0;
200 
201  // Configure optimal wait time for flash FSM in cases where flash pump
202  // wakes up from sleep
203  HWREG(FLASH_BASE + FLASH_O_FPAC1) = (HWREG(FLASH_BASE + FLASH_O_FPAC1) &
204  ~FLASH_FPAC1_PSLEEPTDIS_M) |
205  (0x139<<FLASH_FPAC1_PSLEEPTDIS_S);
206 
207  // And finally at the end of the flash boot process:
208  // SET BOOT_DET bits in AON_PMCTL to 3 if already found to be 1
209  // Note: The BOOT_DET_x_CLR/SET bits must be manually cleared
210  if ((( HWREG( AON_PMCTL_BASE + AON_PMCTL_O_RESETCTL ) &
211  ( AON_PMCTL_RESETCTL_BOOT_DET_1_M | AON_PMCTL_RESETCTL_BOOT_DET_0_M )) >>
212  AON_PMCTL_RESETCTL_BOOT_DET_0_S ) == 1 )
213  {
214  ui32AonSysResetctl = ( HWREG( AON_PMCTL_BASE + AON_PMCTL_O_RESETCTL ) &
215  ~( AON_PMCTL_RESETCTL_BOOT_DET_1_CLR_M | AON_PMCTL_RESETCTL_BOOT_DET_0_CLR_M |
216  AON_PMCTL_RESETCTL_BOOT_DET_1_SET_M | AON_PMCTL_RESETCTL_BOOT_DET_0_SET_M | AON_PMCTL_RESETCTL_MCU_WARM_RESET_M ));
217  HWREG( AON_PMCTL_BASE + AON_PMCTL_O_RESETCTL ) = ui32AonSysResetctl | AON_PMCTL_RESETCTL_BOOT_DET_1_SET_M;
218  HWREG( AON_PMCTL_BASE + AON_PMCTL_O_RESETCTL ) = ui32AonSysResetctl;
219  }
220 
221  // Reset the RTC
222  AONRTCReset();
223  // Configure the combined event
224  IntPendClear(INT_AON_RTC_COMB);
226  // Start the RTC
227  AONRTCEnable();
228 
230  {
231  /* Set SubSecInc to 31.250 kHz since we start up on RCOSC_HF_DLF. The
232  * rom startup code leaves this at the default 32.768 kHz but that is
233  * only accurate once we actually switch to XOSC_LF. Once the
234  * oscillator combined interrupt triggers after we switch to the target
235  * clock, we will configure SubSecInc back to 32.768 kHz.
236  *
237  * There is no need to update SubSecInc dynamically for other LF clock
238  * sources.
239  * - RCOSC_LF starts on RCOSC_HF-derived but switches fast enough that
240  * we do not accumulate any real-time clock drift before switching.
241  * - External LF is correctly set and requires no switching.
242  * - XOSC_HF-derived does not change LF clock frequencies.
243  */
245  }
246 
247  // Make sure there are no ongoing VIMS mode change when leaving SetupTrimDevice()
248  // (There should typically be no wait time here, but need to be sure)
249  while ( HWREGBITW( VIMS_BASE + VIMS_O_STAT, VIMS_STAT_MODE_CHANGING_BITN )) {
250  // Do nothing - wait for an eventual ongoing mode change to complete.
251  }
252 
253 }
#define AON_RTC_CH1
Definition: aon_rtc.h:93
void IntPendClear(uint32_t ui32Interrupt)
Unpends an interrupt.
Definition: interrupt.c:441
#define AON_RTC_CH2
Definition: aon_rtc.h:94
#define CCFGREAD_SCLK_LF_OPTION_XOSC_LF
Definition: ccfgread.h:116
static void AONRTCCombinedEventConfig(uint32_t ui32Channels)
Configure the source of the combined event.
Definition: aon_rtc.h:335
static void TrimAfterColdResetWakeupFromShutDownWakeupFromPowerDown(void)
Trims to be applied when coming from POWER_DOWN (also called when coming from SHUTDOWN and PIN_RESET)...
Definition: setup.c:264
static void AONRTCReset(void)
Reset the RTC.
Definition: aon_rtc.h:209
#define AON_RTC_CH0
Definition: aon_rtc.h:92
static uint32_t CCFGRead_SCLK_LF_OPTION(void)
Read SCLK_LF_OPTION from CCFG.
Definition: ccfgread.h:132
void SetupSetAonRtcSubSecInc(uint32_t subSecInc)
Doing the tricky stuff needed to enter new RTCSUBSECINC value.
Definition: setup_rom.c:927
static void TrimAfterColdResetWakeupFromShutDown(uint32_t ui32Fcfg1Revision)
Trims to be applied when coming from SHUTDOWN (also called when coming from PIN_RESET).
Definition: setup.c:280
static void AONRTCEnable(void)
Enable the RTC.
Definition: aon_rtc.h:172
void SetupSetCacheModeAccordingToCcfgSetting(void)
Set correct VIMS_MODE according to CCFG setting (CACHE or GPRAM)
Definition: setup_rom.c:882
void ThisLibraryIsFor_CC13x2_CC26x2_HwRev20AndLater_HaltIfViolated(void)
Verifies that current chip is CC13x2 or CC26x2 PG2.0 or later and never returns if violated...
Definition: chipinfo.c:212
#define SUBSECINC_31250_HZ
Definition: setup.c:102
static void TrimAfterColdReset(void)
Trims to be applied when coming from PIN_RESET.
Definition: setup.c:384
Here is the call graph for this function: