CC26xx Driver Library
setup.c
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: setup.c
3 * Revised: 2016-06-03 14:23:26 +0200 (Fri, 03 Jun 2016)
4 * Revision: 46593
5 *
6 * Description: Setup file for CC13xx/CC26xx devices.
7 *
8 * Copyright (c) 2015 - 2016, Texas Instruments Incorporated
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1) Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2) Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
22 * be used to endorse or promote products derived from this software without
23 * specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************/
38 
39 // Hardware headers
40 #include <inc/hw_types.h>
41 #include <driverlib/setup.h>
42 // ##### INCLUDE IN ROM BEGIN #####
43 // We need intrinsic functions for IAR (if used in source code)
44 #ifdef __IAR_SYSTEMS_ICC__
45 #include <intrinsics.h>
46 #endif
47 // ##### INCLUDE IN ROM END #####
48 
49 //*****************************************************************************
50 //
51 // Handle support for DriverLib in ROM:
52 // This section will undo prototype renaming made in the header file
53 //
54 //*****************************************************************************
55 #if !defined(DOXYGEN)
56  #undef SetupTrimDevice
57  #define SetupTrimDevice NOROM_SetupTrimDevice
58  #undef SetupAfterColdResetWakeupFromShutDownCfg1
59  #define SetupAfterColdResetWakeupFromShutDownCfg1 NOROM_SetupAfterColdResetWakeupFromShutDownCfg1
60  #undef SetupAfterColdResetWakeupFromShutDownCfg2
61  #define SetupAfterColdResetWakeupFromShutDownCfg2 NOROM_SetupAfterColdResetWakeupFromShutDownCfg2
62  #undef SetupAfterColdResetWakeupFromShutDownCfg3
63  #define SetupAfterColdResetWakeupFromShutDownCfg3 NOROM_SetupAfterColdResetWakeupFromShutDownCfg3
64  #undef SetupGetTrimForAdcShModeEn
65  #define SetupGetTrimForAdcShModeEn NOROM_SetupGetTrimForAdcShModeEn
66  #undef SetupGetTrimForAdcShVbufEn
67  #define SetupGetTrimForAdcShVbufEn NOROM_SetupGetTrimForAdcShVbufEn
68  #undef SetupGetTrimForAmpcompCtrl
69  #define SetupGetTrimForAmpcompCtrl NOROM_SetupGetTrimForAmpcompCtrl
70  #undef SetupGetTrimForAmpcompTh1
71  #define SetupGetTrimForAmpcompTh1 NOROM_SetupGetTrimForAmpcompTh1
72  #undef SetupGetTrimForAmpcompTh2
73  #define SetupGetTrimForAmpcompTh2 NOROM_SetupGetTrimForAmpcompTh2
74  #undef SetupGetTrimForAnabypassValue1
75  #define SetupGetTrimForAnabypassValue1 NOROM_SetupGetTrimForAnabypassValue1
76  #undef SetupGetTrimForDblrLoopFilterResetVoltage
77  #define SetupGetTrimForDblrLoopFilterResetVoltage NOROM_SetupGetTrimForDblrLoopFilterResetVoltage
78  #undef SetupGetTrimForRadcExtCfg
79  #define SetupGetTrimForRadcExtCfg NOROM_SetupGetTrimForRadcExtCfg
80  #undef SetupGetTrimForRcOscLfIBiasTrim
81  #define SetupGetTrimForRcOscLfIBiasTrim NOROM_SetupGetTrimForRcOscLfIBiasTrim
82  #undef SetupGetTrimForRcOscLfRtuneCtuneTrim
83  #define SetupGetTrimForRcOscLfRtuneCtuneTrim NOROM_SetupGetTrimForRcOscLfRtuneCtuneTrim
84  #undef SetupGetTrimForXoscHfCtl
85  #define SetupGetTrimForXoscHfCtl NOROM_SetupGetTrimForXoscHfCtl
86  #undef SetupGetTrimForXoscHfFastStart
87  #define SetupGetTrimForXoscHfFastStart NOROM_SetupGetTrimForXoscHfFastStart
88  #undef SetupGetTrimForXoscHfIbiastherm
89  #define SetupGetTrimForXoscHfIbiastherm NOROM_SetupGetTrimForXoscHfIbiastherm
90  #undef SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio
91  #define SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio NOROM_SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio
92  #undef SetupSignExtendVddrTrimValue
93  #define SetupSignExtendVddrTrimValue NOROM_SetupSignExtendVddrTrimValue
94  #undef SetupSetCacheModeAccordingToCcfgSetting
95  #define SetupSetCacheModeAccordingToCcfgSetting NOROM_SetupSetCacheModeAccordingToCcfgSetting
96  #undef SetupSetAonRtcSubSecInc
97  #define SetupSetAonRtcSubSecInc NOROM_SetupSetAonRtcSubSecInc
98 #endif
99 
100 
101 
102 //*****************************************************************************
103 //
105 //
106 //*****************************************************************************
107 #define DELAY_20_USEC 0x140
108 
109 
110 //*****************************************************************************
111 //
112 // Defined CPU delay macro with microseconds as input
113 // Quick check shows: (To be further investigated)
114 // At 48 MHz RCOSC and VIMS.CONTROL.PREFETCH = 0, there is 5 cycles
115 // At 48 MHz RCOSC and VIMS.CONTROL.PREFETCH = 1, there is 4 cycles
116 // At 24 MHz RCOSC and VIMS.CONTROL.PREFETCH = 0, there is 3 cycles
117 //
118 //*****************************************************************************
119 #define CPU_DELAY_MICRO_SECONDS( x ) \
120  CPUdelay(((uint32_t)((( x ) * 48.0 ) / 5.0 )) - 1 )
121 
122 
123 //*****************************************************************************
124 //
125 // Function declarations
126 //
127 //*****************************************************************************
128 static void TrimAfterColdReset( void );
129 static void TrimAfterColdResetWakeupFromShutDown( uint32_t ui32Fcfg1Revision );
131 
132 //*****************************************************************************
133 //
134 // Perform the necessary trim of the device which is not done in boot code
135 //
136 // This function should only execute coming from ROM boot. The current
137 // implementation does not take soft reset into account. However, it does no
138 // damage to execute it again. It only consumes time.
139 //
140 //*****************************************************************************
141 void
143 {
144  uint32_t ui32Fcfg1Revision;
145  uint32_t ui32AonSysResetctl;
146 
147  //
148  // Get layout revision of the factory configuration area
149  // (Handle undefined revision as revision = 0)
150  //
151  ui32Fcfg1Revision = HWREG(FCFG1_BASE + FCFG1_O_FCFG1_REVISION);
152  if ( ui32Fcfg1Revision == 0xFFFFFFFF ) {
153  ui32Fcfg1Revision = 0;
154  }
155 
156  //
157  // This driverlib version and setup file is for CC26xx PG2.2 and later
158  // Halt if violated
159  //
161 
162  //
163  // Enable standby in flash bank
164  //
166 
167  //
168  // Clock must always be enabled for the semaphore module (due to ADI/DDI HW workaround)
169  //
171 
172  //
173  // Warm resets on CC26XX complicates software design as much of our software
174  // expect that initialization is done from a full system reset.
175  // This includes RTC setup, oscillator configuration and AUX setup.
176  // To ensure a full reset of the device is done when customers get e.g. a Watchdog
177  // reset, the following is set here:
178  //
180 
181  //
182  // Select correct CACHE mode and set correct CACHE configuration
183  //
185 
186  // 1. Check for powerdown
187  // 2. Check for shutdown
188  // 3. Assume cold reset if none of the above.
189  //
190  // It is always assumed that the application will freeze the latches in
191  // AON_IOC when going to powerdown in order to retain the values on the IOs.
192  //
193  // NB. If this bit is not cleared before proceeding to powerdown, the IOs
194  // will all default to the reset configuration when restarting.
196  {
197  //
198  // NB. This should be calling a ROM implementation of required trim and
199  // compensation
200  // e.g. TrimAfterColdResetWakeupFromShutDownWakeupFromPowerDown()
202  }
203  // Check for shutdown
204  //
205  // When device is going to shutdown the hardware will automatically clear
206  // the SLEEPDIS bit in the SLEEP register in the AON_SYSCTRL12 module.
207  // It is left for the application to assert this bit when waking back up,
208  // but not before the desired IO configuration has been re-established.
210  {
211  //
212  // NB. This should be calling a ROM implementation of required trim and
213  // compensation
214  // e.g. TrimAfterColdResetWakeupFromShutDown() -->
215  // TrimAfterColdResetWakeupFromShutDownWakeupFromPowerDown();
216  TrimAfterColdResetWakeupFromShutDown(ui32Fcfg1Revision);
218  }
219  else
220  {
221  // Consider adding a check for soft reset to allow debugging to skip
222  // this section!!!
223  //
224  // NB. This should be calling a ROM implementation of required trim and
225  // compensation
226  // e.g. TrimAfterColdReset() -->
227  // TrimAfterColdResetWakeupFromShutDown() -->
228  // TrimAfterColdResetWakeupFromShutDownWakeupFromPowerDown()
230  TrimAfterColdResetWakeupFromShutDown(ui32Fcfg1Revision);
232 
233  }
234 
235  //
236  // Set VIMS power domain control.
237  // PDCTL1VIMS = 0 ==> VIMS power domain is only powered when CPU power domain is powered
238  //
239  HWREG( PRCM_BASE + PRCM_O_PDCTL1VIMS ) = 0;
240 
241  //
242  // Configure optimal wait time for flash FSM in cases where flash pump
243  // wakes up from sleep
244  //
245  HWREG(FLASH_BASE + FLASH_O_FPAC1) = (HWREG(FLASH_BASE + FLASH_O_FPAC1) &
247  (0x139<<FLASH_FPAC1_PSLEEPTDIS_S);
248 
249  //
250  // And finally at the end of the flash boot process:
251  // SET BOOT_DET bits in AON_SYSCTL to 3 if already found to be 1
252  // Note: The BOOT_DET_x_CLR/SET bits must be manually cleared
253  //
254  if ((( HWREG( AON_SYSCTL_BASE + AON_SYSCTL_O_RESETCTL ) &
257  {
258  ui32AonSysResetctl = ( HWREG( AON_SYSCTL_BASE + AON_SYSCTL_O_RESETCTL ) &
262  HWREG( AON_SYSCTL_BASE + AON_SYSCTL_O_RESETCTL ) = ui32AonSysResetctl;
263  }
264 
265  //
266  // Make sure there are no ongoing VIMS mode change when leaving SetupTrimDevice()
267  // (There should typically be no wait time here, but need to be sure)
268  //
269  while ( HWREGBITW( VIMS_BASE + VIMS_O_STAT, VIMS_STAT_MODE_CHANGING_BITN )) {
270  // Do nothing - wait for an eventual ongoing mode change to complete.
271  }
272 }
273 
274 //*****************************************************************************
275 //
280 //
281 //*****************************************************************************
282 static void
284 {
285  //
286  // Currently no specific trim for Powerdown
287  //
288 }
289 
290 //*****************************************************************************
291 //
296 //
297 //*****************************************************************************
298 static void
299 TrimAfterColdResetWakeupFromShutDown(uint32_t ui32Fcfg1Revision)
300 {
301  uint32_t ccfg_ModeConfReg ;
302  uint32_t mp1rev ;
303 
304  //
305  // Force AUX on and enable clocks
306  //
307  // No need to save the current status of the power/clock registers.
308  // At this point both AUX and AON should have been reset to 0x0.
309  //
311 
312  //
313  // Wait for power on on the AUX domain
314  //
316 
317  //
318  // Enable the clocks for AUX_DDI0_OSC and AUX_ADI4
319  //
322 
323  //
324  // It's found to be optimal to override the FCFG1..DCDC_IPEAK setting as follows:
325  // if ( alternative DCDC setting in CCFG is enabled ) ADI3..IPEAK = CCFG..DCDC_IPEAK
326  // else ADI3..IPEAK = 2
327  //
329  //
330  // ADI_3_REFSYS:DCDCCTL5[3] (=DITHER_EN) = CCFG_MODE_CONF_1[19] (=ALT_DCDC_DITHER_EN)
331  // ADI_3_REFSYS:DCDCCTL5[2:0](=IPEAK ) = CCFG_MODE_CONF_1[18:16](=ALT_DCDC_IPEAK )
332  // Using a single 4-bit masked write since layout is equal for both source and destination
333  //
334  HWREGB( ADI3_BASE + ADI_O_MASK4B + ( ADI_3_REFSYS_O_DCDCCTL5 * 2 )) = ( 0xF0 |
336 
337  } else {
338  HWREGB( ADI3_BASE + ADI_O_MASK4B + ( ADI_3_REFSYS_O_DCDCCTL5 * 2 )) = 0x72;
339  }
340 
341  //
342  // Enable for JTAG to be powered down (will still be powered on if debugger is connected)
343  //
345 
346  //
347  // read the MODE_CONF register in CCFG
348  //
349  ccfg_ModeConfReg = HWREG( CCFG_BASE + CCFG_O_MODE_CONF );
350 
351  //
352  // First part of trim done after cold reset and wakeup from shutdown:
353  // -Adjust the VDDR_TRIM_SLEEP value.
354  // -Configure DCDC.
355  //
356  SetupAfterColdResetWakeupFromShutDownCfg1( ccfg_ModeConfReg );
357 
358  //
359  // Second part of trim done after cold reset and wakeup from shutdown:
360  // -Configure XOSC.
361  //
362  SetupAfterColdResetWakeupFromShutDownCfg2( ui32Fcfg1Revision, ccfg_ModeConfReg );
363 
364  //
365  // Increased margin between digital supply voltage and VDD BOD during standby.
366  // VTRIM_UDIG: signed 4 bits value to be incremented by 2 (max = 7)
367  // VTRIM_BOD: unsigned 4 bits value to be decremented by 1 (min = 0)
368  // This applies to chips with mp1rev < 542 for cc13xx and for mp1rev < 527 for cc26xx
369  //
370  mp1rev = ( HWREG( FCFG1_BASE + 0x00000314 ) & 0x0000FFFF );
371  if ( mp1rev < 527 ) {
372  uint32_t vtrim_bod = (( HWREG( FCFG1_BASE + 0x000002BC ) >> 24 ) & 0xF ); // bit[27:24] unsigned
373  uint32_t vtrim_udig = (( HWREG( FCFG1_BASE + 0x000002BC ) >> 16 ) & 0xF ); // bit[19:16] signed
374  if ( vtrim_bod > 0 ) {
375  vtrim_bod -= 1;
376  }
377  if ( vtrim_udig != 7 ) {
378  if ( vtrim_udig == 6 ) {
379  vtrim_udig = 7;
380  } else {
381  vtrim_udig = (( vtrim_udig + 2 ) & 0xF );
382  }
383  }
385  ( vtrim_udig << ADI_2_REFSYS_SOCLDOCTL0_VTRIM_UDIG_S ) |
386  ( vtrim_bod << ADI_2_REFSYS_SOCLDOCTL0_VTRIM_BOD_S ) ;
387  }
388 
389  //
390  // Third part of trim done after cold reset and wakeup from shutdown:
391  // -Configure HPOSC.
392  // -Setup the LF clock.
393  //
394  SetupAfterColdResetWakeupFromShutDownCfg3( ccfg_ModeConfReg );
395 
396  //
397  // Allow AUX to power down
398  //
400 
401  //
402  // Leaving on AUX and clock for AUX_DDI0_OSC on but turn off clock for AUX_ADI4
403  //
405 
406  // Disable EFUSE clock
408 }
409 
410 
411 //*****************************************************************************
412 //
416 //
417 //*****************************************************************************
418 static void
420 {
421  //
422  // Currently no specific trim for Cold Reset
423  //
424 }
425 
426 //*****************************************************************************
427 //
429 //
430 //*****************************************************************************
431 void
432 SetupAfterColdResetWakeupFromShutDownCfg1( uint32_t ccfg_ModeConfReg )
433 {
434  int32_t i32VddrSleepTrim;
435  int32_t i32VddrSleepDelta;
436 
437  {
438  i32VddrSleepTrim = SetupSignExtendVddrTrimValue((
439  HWREG( FCFG1_BASE + FCFG1_O_LDO_TRIM ) &
442  }
443 
444  //
445  // Adjust the VDDR_TRIM_SLEEP value with value adjustable by customer (CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA)
446  // Read and sign extend VddrSleepDelta (in range -8 to +7)
447  //
448  i32VddrSleepDelta = ((((int32_t)ccfg_ModeConfReg )
449  << ( 32 - CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_W - CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_S ))
450  >> ( 32 - CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_W ));
451  // Calculate new VDDR sleep trim
452  i32VddrSleepTrim = ( i32VddrSleepTrim + i32VddrSleepDelta + 1 );
453  if ( i32VddrSleepTrim > 21 ) i32VddrSleepTrim = 21;
454  if ( i32VddrSleepTrim < -10 ) i32VddrSleepTrim = -10;
455  // Write adjusted value using MASKED write (MASK8)
456  HWREGH( ADI3_BASE + ADI_O_MASK8B + ( ADI_3_REFSYS_O_DCDCCTL1 * 2 )) = (( ADI_3_REFSYS_DCDCCTL1_VDDR_TRIM_SLEEP_M << 8 ) |
458 
459  //
460  // 1.
461  // Do not allow DCDC to be enabled if in external regulator mode.
462  // Preventing this by setting both the RECHARGE and the ACTIVE bits bit in the CCFG_MODE_CONF copy register (ccfg_ModeConfReg).
463  //
464  // 2.
465  // Adjusted battery monitor low limit in internal regulator mode.
466  // This is done by setting AON_BATMON_FLASHPUMPP0_LOWLIM=0 in internal regulator mode.
467  //
470  } else {
472  }
473 
474  //
475  // set the RECHARGE source based upon CCFG:MODE_CONF:DCDC_RECHARGE
476  // Note: Inverse polarity
477  //
479  ((( ccfg_ModeConfReg >> CCFG_MODE_CONF_DCDC_RECHARGE_S ) & 1 ) ^ 1 );
480 
481  //
482  // set the ACTIVE source based upon CCFG:MODE_CONF:DCDC_ACTIVE
483  // Note: Inverse polarity
484  //
486  ((( ccfg_ModeConfReg >> CCFG_MODE_CONF_DCDC_ACTIVE_S ) & 1 ) ^ 1 );
487 }
488 
489 //*****************************************************************************
490 //
492 //
493 //*****************************************************************************
494 void
495 SetupAfterColdResetWakeupFromShutDownCfg2( uint32_t ui32Fcfg1Revision, uint32_t ccfg_ModeConfReg )
496 {
497  uint32_t ui32Trim;
498 
499  //
500  // Following sequence is required for using XOSCHF, if not included
501  // devices crashes when trying to switch to XOSCHF.
502  //
503  // Trim CAP settings. Get and set trim value for the ANABYPASS_VALUE1
504  // register
505  ui32Trim = SetupGetTrimForAnabypassValue1( ccfg_ModeConfReg );
507 
508  // Trim RCOSC_LF. Get and set trim values for the RCOSCLF_RTUNE_TRIM and
509  // RCOSCLF_CTUNE_TRIM fields in the XOSCLF_RCOSCLF_CTRL register.
515  ui32Trim);
516 
517  // Trim XOSCHF IBIAS THERM. Get and set trim value for the
518  // XOSCHF IBIAS THERM bit field in the ANABYPASS_VALUE2 register. Other
519  // register bit fields are set to 0.
520  ui32Trim = SetupGetTrimForXoscHfIbiastherm();
523 
524  // Trim AMPCOMP settings required before switch to XOSCHF
525  ui32Trim = SetupGetTrimForAmpcompTh2();
527  ui32Trim = SetupGetTrimForAmpcompTh1();
529  ui32Trim = SetupGetTrimForAmpcompCtrl( ui32Fcfg1Revision );
531 
532  //
533  // Set trim for DDI_0_OSC_ADCDOUBLERNANOAMPCTL_ADC_SH_MODE_EN in accordance to FCFG1 setting
534  // This is bit[5] in the DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL register
535  // Using MASK4 write + 1 => writing to bits[7:4]
536  //
537  ui32Trim = SetupGetTrimForAdcShModeEn( ui32Fcfg1Revision );
538  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 1 ) =
539  ( 0x20 | ( ui32Trim << 1 ));
540 
541  //
542  // Set trim for DDI_0_OSC_ADCDOUBLERNANOAMPCTL_ADC_SH_VBUF_EN in accordance to FCFG1 setting
543  // This is bit[4] in the DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL register
544  // Using MASK4 write + 1 => writing to bits[7:4]
545  //
546  ui32Trim = SetupGetTrimForAdcShVbufEn( ui32Fcfg1Revision );
547  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 1 ) =
548  ( 0x10 | ( ui32Trim ));
549 
550  //
551  // Set trim for the PEAK_DET_ITRIM, HP_BUF_ITRIM and LP_BUF_ITRIM bit fields
552  // in the DDI0_OSC_O_XOSCHFCTL register in accordance to FCFG1 setting.
553  // Remaining register bit fields are set to their reset values of 0.
554  //
555  ui32Trim = SetupGetTrimForXoscHfCtl(ui32Fcfg1Revision);
557 
558  //
559  // Set trim for DBLR_LOOP_FILTER_RESET_VOLTAGE in accordance to FCFG1 setting
560  // (This is bits [18:17] in DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL)
561  // (Using MASK4 write + 4 => writing to bits[19:16] => (4*4))
562  // (Assuming: DDI_0_OSC_ADCDOUBLERNANOAMPCTL_DBLR_LOOP_FILTER_RESET_VOLTAGE_S = 17 and
563  // that DDI_0_OSC_ADCDOUBLERNANOAMPCTL_DBLR_LOOP_FILTER_RESET_VOLTAGE_M = 0x00060000)
564  //
565  ui32Trim = SetupGetTrimForDblrLoopFilterResetVoltage( ui32Fcfg1Revision );
566  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 4 ) =
567  ( 0x60 | ( ui32Trim << 1 ));
568 
569  //
570  // Update DDI_0_OSC_ATESTCTL_ATESTLF_RCOSCLF_IBIAS_TRIM with data from
572  // This is DDI_0_OSC_O_ATESTCTL bit[7]
573  // ( DDI_0_OSC_O_ATESTCTL is currently hidden (but=0x00000020))
574  // Using MASK4 write + 1 => writing to bits[7:4]
575  //
576  ui32Trim = SetupGetTrimForRcOscLfIBiasTrim( ui32Fcfg1Revision );
577  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( 0x00000020 * 2 ) + 1 ) =
578  ( 0x80 | ( ui32Trim << 3 ));
579 
580  //
583  // This can be simplified since the registers are packed together in the same
584  // order both in FCFG1 and in the HW register.
585  // This spans DDI_0_OSC_O_LFOSCCTL bits[23:18]
586  // Using MASK8 write + 4 => writing to bits[23:16]
587  //
588  ui32Trim = SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio( ui32Fcfg1Revision );
589  HWREGH( AUX_DDI0_OSC_BASE + DDI_O_MASK8B + ( DDI_0_OSC_O_LFOSCCTL * 2 ) + 4 ) =
590  ( 0xFC00 | ( ui32Trim << 2 ));
591 
592  //
593  // Set trim the HPM_IBIAS_WAIT_CNT, LPM_IBIAS_WAIT_CNT and IDAC_STEP bit
594  // fields in the DDI0_OSC_O_RADCEXTCFG register in accordance to FCFG1 setting.
595  // Remaining register bit fields are set to their reset values of 0.
596  //
597  ui32Trim = SetupGetTrimForRadcExtCfg(ui32Fcfg1Revision);
599 
600  // Setting FORCE_KICKSTART_EN (ref. CC26_V1_BUG00261). Should also be done for PG2
601  // (This is bit 22 in DDI_0_OSC_O_CTL0)
603 }
604 
605 //*****************************************************************************
606 //
608 //
609 //*****************************************************************************
610 void
611 SetupAfterColdResetWakeupFromShutDownCfg3( uint32_t ccfg_ModeConfReg )
612 {
613  uint32_t fcfg1OscConf;
614  uint32_t ui32Trim;
615  uint32_t currentHfClock;
616  uint32_t ccfgExtLfClk;
617 
618  //
619  // Examin the XOSC_FREQ field to select 0x1=HPOSC, 0x2=48MHz XOSC, 0x3=24MHz XOSC
620  //
621  switch (( ccfg_ModeConfReg & CCFG_MODE_CONF_XOSC_FREQ_M ) >> CCFG_MODE_CONF_XOSC_FREQ_S ) {
622  case 2 :
623  // XOSC source is a 48 MHz xtal
624  // Do nothing (since this is the reset setting)
625  break;
626  case 1 :
627  // XOSC source is HPOSC (trim the HPOSC if this is a chip with HPOSC, otherwise skip trimming and default to 24 MHz XOSC)
628 
629  fcfg1OscConf = HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF );
630 
631  if (( fcfg1OscConf & FCFG1_OSC_CONF_HPOSC_OPTION ) == 0 ) {
632  // This is a HPOSC chip, apply HPOSC settings
633  // Set bit DDI_0_OSC_CTL0_HPOSC_MODE_EN (this is bit 14 in DDI_0_OSC_O_CTL0)
635 
643 
656  break;
657  }
658  // Not a HPOSC chip - fall through to default
659  default :
660  // XOSC source is a 24 MHz xtal (default)
661  // Set bit DDI_0_OSC_CTL0_XTAL_IS_24M (this is bit 31 in DDI_0_OSC_O_CTL0)
663  break;
664  }
665 
666  //
667  // Set XOSC_HF in bypass mode if CCFG is configured for external TCXO
668  // Please note that it is up to the custommer to make sure that the external clock source is up and running before XOSC_HF can be used.
669  //
672  }
673 
674  // Clear DDI_0_OSC_CTL0_CLK_LOSS_EN (ClockLossEventEnable()). This is bit 9 in DDI_0_OSC_O_CTL0.
675  // This is typically already 0 except on Lizard where it is set in ROM-boot
677 
678  // Setting DDI_0_OSC_CTL1_XOSC_HF_FAST_START according to value found in FCFG1
679  ui32Trim = SetupGetTrimForXoscHfFastStart();
680  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_CTL1 * 2 )) = ( 0x30 | ui32Trim );
681 
682  //
683  // setup the LF clock based upon CCFG:MODE_CONF:SCLK_LF_OPTION
684  //
685  switch (( ccfg_ModeConfReg & CCFG_MODE_CONF_SCLK_LF_OPTION_M ) >> CCFG_MODE_CONF_SCLK_LF_OPTION_S ) {
686  case 0 : // XOSC_HF_DLF (XOSCHF/1536) -> SCLK_LF (=31250Hz)
688  SetupSetAonRtcSubSecInc( 0x8637BD );
689  break;
690  case 1 : // EXTERNAL signal -> SCLK_LF (frequency=2^38/CCFG_EXT_LF_CLK_RTC_INCREMENT)
691  // Set SCLK_LF to use the same source as SCLK_HF
692  // Can be simplified a bit since possible return values for HF matches LF settings
693  currentHfClock = OSCClockSourceGet( OSC_SRC_CLK_HF );
694  OSCClockSourceSet( OSC_SRC_CLK_LF, currentHfClock );
695  while( OSCClockSourceGet( OSC_SRC_CLK_LF ) != currentHfClock ) {
696  // Wait until switched
697  }
698  ccfgExtLfClk = HWREG( CCFG_BASE + CCFG_O_EXT_LF_CLK );
702  IOC_STD_INPUT | IOC_HYST_ENABLE ); // Route external clock to AON IOC w/hysteresis
703  // Set XOSC_LF in bypass mode to allow external 32k clock
705  // Fall through to set XOSC_LF as SCLK_LF source
706  case 2 : // XOSC_LF -> SLCK_LF (32768 Hz)
708  break;
709  default : // (=3) RCOSC_LF
711  break;
712  }
713 
714  //
715  // Update ADI_4_AUX_ADCREF1_VTRIM with value from FCFG1
716  //
717  HWREGB( AUX_ADI4_BASE + ADI_4_AUX_O_ADCREF1 ) =
722 
723  //
724  // Set ADI_4_AUX:ADC0.SMPL_CYCLE_EXP to it's default minimum value (=3)
725  // (Note: Using MASK8B requires that the bits to be modified must be within the same
726  // byte boundary which is the case for the ADI_4_AUX_ADC0_SMPL_CYCLE_EXP field)
727  //
728  HWREGH( AUX_ADI4_BASE + ADI_O_MASK8B + ( ADI_4_AUX_O_ADC0 * 2 )) =
730 
731  //
732  // Sync with AON
733  //
734  SysCtrlAonSync();
735 }
736 
737 //*****************************************************************************
738 //
740 //
741 //*****************************************************************************
742 uint32_t
743 SetupGetTrimForAnabypassValue1( uint32_t ccfg_ModeConfReg )
744 {
745  uint32_t ui32Fcfg1Value ;
746  uint32_t ui32XoscHfRow ;
747  uint32_t ui32XoscHfCol ;
748  int32_t i32CustomerDeltaAdjust ;
749  uint32_t ui32TrimValue ;
750 
751  // Use device specific trim values located in factory configuration
752  // area for the XOSC_HF_COLUMN_Q12 and XOSC_HF_ROW_Q12 bit fields in
753  // the ANABYPASS_VALUE1 register. Value for the other bit fields
754  // are set to 0.
755 
756  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_OSC_TOP);
757  ui32XoscHfRow = (( ui32Fcfg1Value &
760  ui32XoscHfCol = (( ui32Fcfg1Value &
763 
764  i32CustomerDeltaAdjust = 0;
765  if (( ccfg_ModeConfReg & CCFG_MODE_CONF_XOSC_CAP_MOD ) == 0 ) {
766  // XOSC_CAP_MOD = 0 means: CAP_ARRAY_DELTA is in use -> Apply compensation
767  // XOSC_CAPARRAY_DELTA is located in bit[15:8] of ccfg_ModeConfReg
768  // Note: HW_REV_DEPENDENT_IMPLEMENTATION. Field width is not given by
769  // a define and sign extension must therefore be hardcoded.
770  // ( A small test program is created verifying the code lines below:
771  // Ref.: ..\test\small_standalone_test_programs\CapArrayDeltaAdjust_test.c)
772  i32CustomerDeltaAdjust = ((int32_t)ccfg_ModeConfReg << 16 ) >> 24;
773 
774  while ( i32CustomerDeltaAdjust < 0 ) {
775  ui32XoscHfCol >>= 1; // COL 1 step down
776  if ( ui32XoscHfCol == 0 ) { // if COL below minimum
777  ui32XoscHfCol = 0xFFFF; // Set COL to maximum
778  ui32XoscHfRow >>= 1; // ROW 1 step down
779  if ( ui32XoscHfRow == 0 ) { // if ROW below minimum
780  ui32XoscHfRow = 1; // Set both ROW and COL
781  ui32XoscHfCol = 1; // to minimum
782  }
783  }
784  i32CustomerDeltaAdjust++;
785  }
786  while ( i32CustomerDeltaAdjust > 0 ) {
787  ui32XoscHfCol = ( ui32XoscHfCol << 1 ) | 1; // COL 1 step up
788  if ( ui32XoscHfCol > 0xFFFF ) { // if COL above maximum
789  ui32XoscHfCol = 1; // Set COL to minimum
790  ui32XoscHfRow = ( ui32XoscHfRow << 1 ) | 1; // ROW 1 step up
791  if ( ui32XoscHfRow > 0xF ) { // if ROW above maximum
792  ui32XoscHfRow = 0xF; // Set both ROW and COL
793  ui32XoscHfCol = 0xFFFF; // to maximum
794  }
795  }
796  i32CustomerDeltaAdjust--;
797  }
798  }
799 
800  ui32TrimValue = (( ui32XoscHfRow << DDI_0_OSC_ANABYPASSVAL1_XOSC_HF_ROW_Q12_S ) |
801  ( ui32XoscHfCol << DDI_0_OSC_ANABYPASSVAL1_XOSC_HF_COLUMN_Q12_S ) );
802 
803  return (ui32TrimValue);
804 }
805 
806 //*****************************************************************************
807 //
810 //
811 //*****************************************************************************
812 uint32_t
814 {
815  uint32_t ui32TrimValue;
816 
817  // Use device specific trim values located in factory configuration
818  // area
819  ui32TrimValue =
824 
825  ui32TrimValue |=
830 
831  return(ui32TrimValue);
832 }
833 
834 //*****************************************************************************
835 //
838 //
839 //*****************************************************************************
840 uint32_t
842 {
843  uint32_t ui32TrimValue;
844 
845  // Use device specific trim value located in factory configuration
846  // area
847  ui32TrimValue =
851 
852  return(ui32TrimValue);
853 }
854 
855 //*****************************************************************************
856 //
858 //
859 //*****************************************************************************
860 uint32_t
862 {
863  uint32_t ui32TrimValue;
864  uint32_t ui32Fcfg1Value;
865 
866  // Use device specific trim value located in factory configuration
867  // area. All defined register bit fields have corresponding trim
868  // value in the factory configuration area
869  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_AMPCOMP_TH2);
870  ui32TrimValue = ((ui32Fcfg1Value &
874  ui32TrimValue |= (((ui32Fcfg1Value &
878  ui32TrimValue |= (((ui32Fcfg1Value &
882  ui32TrimValue |= (((ui32Fcfg1Value &
886 
887  return(ui32TrimValue);
888 }
889 
890 //*****************************************************************************
891 //
893 //
894 //*****************************************************************************
895 uint32_t
897 {
898  uint32_t ui32TrimValue;
899  uint32_t ui32Fcfg1Value;
900 
901  // Use device specific trim values located in factory configuration
902  // area. All defined register bit fields have a corresponding trim
903  // value in the factory configuration area
904  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_AMPCOMP_TH1);
905  ui32TrimValue = (((ui32Fcfg1Value &
909  ui32TrimValue |= (((ui32Fcfg1Value &
913  ui32TrimValue |= (((ui32Fcfg1Value &
917  ui32TrimValue |= (((ui32Fcfg1Value &
921 
922  return(ui32TrimValue);
923 }
924 
925 //*****************************************************************************
926 //
928 //
929 //*****************************************************************************
930 uint32_t
931 SetupGetTrimForAmpcompCtrl( uint32_t ui32Fcfg1Revision )
932 {
933  uint32_t ui32TrimValue ;
934  uint32_t ui32Fcfg1Value ;
935  uint32_t ibiasOffset ;
936  uint32_t ibiasInit ;
937  uint32_t modeConf1 ;
938  int32_t deltaAdjust ;
939 
940  // Use device specific trim values located in factory configuration
941  // area. Register bit fields without trim values in the factory
942  // configuration area will be set to the value of 0.
943  ui32Fcfg1Value = HWREG( FCFG1_BASE + FCFG1_O_AMPCOMP_CTRL1 );
944 
945  ibiasOffset = ( ui32Fcfg1Value &
948  ibiasInit = ( ui32Fcfg1Value &
951 
953  // Adjust with DELTA_IBIAS_OFFSET and DELTA_IBIAS_INIT from CCFG
954  modeConf1 = HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 );
955 
956  // Both fields are signed 4-bit values. This is an assumption when doing the sign extension.
957  deltaAdjust = ((int32_t)modeConf1 << ( 32 - CCFG_MODE_CONF_1_DELTA_IBIAS_OFFSET_S - 4 )) >> 28;
958  deltaAdjust += (int32_t)ibiasOffset;
959  if ( deltaAdjust < 0 ) {
960  deltaAdjust = 0;
961  }
964  }
965  ibiasOffset = (uint32_t)deltaAdjust;
966 
967  deltaAdjust = ((int32_t)modeConf1 << ( 32 - CCFG_MODE_CONF_1_DELTA_IBIAS_INIT_S - 4 )) >> 28;
968  deltaAdjust += (int32_t)ibiasInit;
969  if ( deltaAdjust < 0 ) {
970  deltaAdjust = 0;
971  }
974  }
975  ibiasInit = (uint32_t)deltaAdjust;
976  }
977  ui32TrimValue = ( ibiasOffset << DDI_0_OSC_AMPCOMPCTL_IBIAS_OFFSET_S ) |
978  ( ibiasInit << DDI_0_OSC_AMPCOMPCTL_IBIAS_INIT_S ) ;
979 
980  ui32TrimValue |= (((ui32Fcfg1Value &
984  ui32TrimValue |= (((ui32Fcfg1Value &
988  ui32TrimValue |= (((ui32Fcfg1Value &
992 
993  if ( ui32Fcfg1Revision >= 0x00000022 ) {
994  ui32TrimValue |= ((( ui32Fcfg1Value &
998  }
999 
1000  return(ui32TrimValue);
1001 }
1002 
1003 //*****************************************************************************
1004 //
1006 //
1007 //*****************************************************************************
1008 uint32_t
1009 SetupGetTrimForDblrLoopFilterResetVoltage( uint32_t ui32Fcfg1Revision )
1010 {
1011  uint32_t dblrLoopFilterResetVoltageValue = 0; // Reset value
1012 
1013  if ( ui32Fcfg1Revision >= 0x00000020 ) {
1014  dblrLoopFilterResetVoltageValue = ( HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 ) &
1017  }
1018 
1019  return ( dblrLoopFilterResetVoltageValue );
1020 }
1021 
1022 //*****************************************************************************
1023 //
1025 //
1026 //*****************************************************************************
1027 uint32_t
1028 SetupGetTrimForAdcShModeEn( uint32_t ui32Fcfg1Revision )
1029 {
1030  uint32_t getTrimForAdcShModeEnValue = 1; // Recommended default setting
1031 
1032  if ( ui32Fcfg1Revision >= 0x00000022 ) {
1033  getTrimForAdcShModeEnValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1036  }
1037 
1038  return ( getTrimForAdcShModeEnValue );
1039 }
1040 
1041 //*****************************************************************************
1042 //
1044 //
1045 //*****************************************************************************
1046 uint32_t
1047 SetupGetTrimForAdcShVbufEn( uint32_t ui32Fcfg1Revision )
1048 {
1049  uint32_t getTrimForAdcShVbufEnValue = 1; // Recommended default setting
1050 
1051  if ( ui32Fcfg1Revision >= 0x00000022 ) {
1052  getTrimForAdcShVbufEnValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1055  }
1056 
1057  return ( getTrimForAdcShVbufEnValue );
1058 }
1059 
1060 //*****************************************************************************
1061 //
1063 //
1064 //*****************************************************************************
1065 uint32_t
1066 SetupGetTrimForXoscHfCtl( uint32_t ui32Fcfg1Revision )
1067 {
1068  uint32_t getTrimForXoschfCtlValue = 0; // Recommended default setting
1069  uint32_t fcfg1Data;
1070 
1071  if ( ui32Fcfg1Revision >= 0x00000020 ) {
1072  fcfg1Data = HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 );
1073  getTrimForXoschfCtlValue =
1074  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_PEAK_DET_ITRIM_M ) >>
1077 
1078  getTrimForXoschfCtlValue |=
1079  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_HP_BUF_ITRIM_M ) >>
1082 
1083  getTrimForXoschfCtlValue |=
1084  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_LP_BUF_ITRIM_M ) >>
1087  }
1088 
1089  return ( getTrimForXoschfCtlValue );
1090 }
1091 
1092 //*****************************************************************************
1093 //
1095 //
1096 //*****************************************************************************
1097 uint32_t
1099 {
1100  uint32_t ui32XoscHfFastStartValue ;
1101 
1102  // Get value from FCFG1
1103  ui32XoscHfFastStartValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1106 
1107  return ( ui32XoscHfFastStartValue );
1108 }
1109 
1110 //*****************************************************************************
1111 //
1113 //
1114 //*****************************************************************************
1115 uint32_t
1116 SetupGetTrimForRadcExtCfg( uint32_t ui32Fcfg1Revision )
1117 {
1118  uint32_t getTrimForRadcExtCfgValue = 0x403F8000; // Recommended default setting
1119  uint32_t fcfg1Data;
1120 
1121  if ( ui32Fcfg1Revision >= 0x00000020 ) {
1122  fcfg1Data = HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 );
1123  getTrimForRadcExtCfgValue =
1124  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_HPM_IBIAS_WAIT_CNT_M ) >>
1127 
1128  getTrimForRadcExtCfgValue |=
1129  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_LPM_IBIAS_WAIT_CNT_M ) >>
1132 
1133  getTrimForRadcExtCfgValue |=
1134  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_IDAC_STEP_M ) >>
1137  }
1138 
1139  return ( getTrimForRadcExtCfgValue );
1140 }
1141 
1142 //*****************************************************************************
1143 //
1145 //
1146 //*****************************************************************************
1147 uint32_t
1148 SetupGetTrimForRcOscLfIBiasTrim( uint32_t ui32Fcfg1Revision )
1149 {
1150  uint32_t trimForRcOscLfIBiasTrimValue = 0; // Default value
1151 
1152  if ( ui32Fcfg1Revision >= 0x00000022 ) {
1153  trimForRcOscLfIBiasTrimValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1156  }
1157 
1158  return ( trimForRcOscLfIBiasTrimValue );
1159 }
1160 
1161 //*****************************************************************************
1162 //
1165 //
1166 //*****************************************************************************
1167 uint32_t
1169 {
1170  uint32_t trimForXoscLfRegulatorAndCmirrwrRatioValue = 0; // Default value for both fields
1171 
1172  if ( ui32Fcfg1Revision >= 0x00000022 ) {
1173  trimForXoscLfRegulatorAndCmirrwrRatioValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1177  }
1178 
1179  return ( trimForXoscLfRegulatorAndCmirrwrRatioValue );
1180 }
1181 
1182 //*****************************************************************************
1183 //
1187 //
1188 //*****************************************************************************
1189 int32_t
1190 SetupSignExtendVddrTrimValue( uint32_t ui32VddrTrimVal )
1191 {
1192  //
1193  // The VDDR trim value is 5 bits representing the range from -10 to +21
1194  // (where -10=0x16, -1=0x1F, 0=0x00, 1=0x01 and +21=0x15)
1195  //
1196  int32_t i32SignedVddrVal = ui32VddrTrimVal;
1197  if ( i32SignedVddrVal > 0x15 ) {
1198  i32SignedVddrVal -= 0x20;
1199  }
1200  return ( i32SignedVddrVal );
1201 }
1202 
1203 //*****************************************************************************
1204 //
1208 //
1209 //*****************************************************************************
1210 void
1212 {
1213  //
1214  // - Make sure to enable aggressive VIMS clock gating for power optimization
1215  // Only for PG2 devices.
1216  // - Enable cache prefetch enable as default setting
1217  // (Slightly higher power consumption, but higher CPU performance)
1218  // - IF ( CCFG_..._DIS_GPRAM == 1 )
1219  // then: Enable cache (set cache mode = 1), even if set by ROM boot code
1220  // (This is done because it's not set by boot code when running inside
1221  // a debugger supporting the Halt In Boot (HIB) functionality).
1222  // else: Set MODE_GPRAM if not already set (see inline comments as well)
1223  //
1224  uint32_t vimsCtlMode0 ;
1225 
1226  while ( HWREGBITW( VIMS_BASE + VIMS_O_STAT, VIMS_STAT_MODE_CHANGING_BITN )) {
1227  // Do nothing - wait for an eventual ongoing mode change to complete.
1228  // (There should typically be no wait time here, but need to be sure)
1229  }
1230 
1231  //
1232  // Note that Mode=0 is equal to MODE_GPRAM
1233  //
1234  vimsCtlMode0 = (( HWREG( VIMS_BASE + VIMS_O_CTL ) & ~VIMS_CTL_MODE_M ) | VIMS_CTL_DYN_CG_EN_M | VIMS_CTL_PREF_EN_M );
1235 
1236 
1238  // Enable cache (and hence disable GPRAM)
1239  HWREG( VIMS_BASE + VIMS_O_CTL ) = ( vimsCtlMode0 | VIMS_CTL_MODE_CACHE );
1240  } else if (( HWREG( VIMS_BASE + VIMS_O_STAT ) & VIMS_STAT_MODE_M ) != VIMS_STAT_MODE_GPRAM ) {
1241  //
1242  // GPRAM is enabled in CCFG but not selected
1243  // Note: It is recommended to go via MODE_OFF when switching to MODE_GPRAM
1244  //
1245  HWREG( VIMS_BASE + VIMS_O_CTL ) = ( vimsCtlMode0 | VIMS_CTL_MODE_OFF );
1246  while (( HWREG( VIMS_BASE + VIMS_O_STAT ) & VIMS_STAT_MODE_M ) != VIMS_STAT_MODE_OFF ) {
1247  // Do nothing - wait for an eventual mode change to complete (This goes fast).
1248  }
1249  HWREG( VIMS_BASE + VIMS_O_CTL ) = vimsCtlMode0;
1250  } else {
1251  // Correct mode, but make sure PREF_EN and DYN_CG_EN always are set
1252  HWREG( VIMS_BASE + VIMS_O_CTL ) = vimsCtlMode0;
1253  }
1254 }
1255 
1256 //*****************************************************************************
1257 //
1261 //
1262 //*****************************************************************************
1263 void
1264 SetupSetAonRtcSubSecInc( uint32_t subSecInc )
1265 {
1266  //
1267  // Loading a new RTCSUBSECINC value is done in 5 steps:
1268  // 1. Write bit[15:0] of new SUBSECINC value to AUX_WUC_O_RTCSUBSECINC0
1269  // 2. Write bit[23:16] of new SUBSECINC value to AUX_WUC_O_RTCSUBSECINC1
1271  // 4. Wait for AUX_WUC_RTCSUBSECINCCTL_UPD_ACK
1273  //
1275  HWREG( AUX_WUC_BASE + AUX_WUC_O_RTCSUBSECINC1 ) = (( subSecInc >> 16 ) & AUX_WUC_RTCSUBSECINC1_INC23_16_M );
1276 
1279  HWREG( AUX_WUC_BASE + AUX_WUC_O_RTCSUBSECINCCTL ) = 0;
1280 }
static void SysCtrlAonSync(void)
Sync all accesses to the AON register interface.
Definition: sys_ctrl.h:196
#define IOC_PORT_AON_CLK32K
Definition: ioc.h:169
uint32_t SetupGetTrimForAmpcompTh1(void)
Returns the trim value to be used for the AMPCOMP_TH1 register in OSC_DIG.
Definition: setup.c:896
uint32_t SetupGetTrimForRcOscLfRtuneCtuneTrim(void)
Returns the trim value to be used for the RCOSCLF_RTUNE_TRIM and the RCOSCLF_CTUNE_TRIM bit fields in...
Definition: setup.c:813
uint32_t SetupGetTrimForAmpcompTh2(void)
Returns the trim value to be used for the AMPCOMP_TH2 register in OSC_DIG.
Definition: setup.c:861
uint32_t SetupGetTrimForDblrLoopFilterResetVoltage(uint32_t ui32Fcfg1Revision)
Returns the trim value from FCFG1 to be used as DBLR_LOOP_FILTER_RESET_VOLTAGE setting.
Definition: setup.c:1009
void SetupAfterColdResetWakeupFromShutDownCfg3(uint32_t ccfg_ModeConfReg)
Third part of configuration required when waking up from shutdown.
Definition: setup.c:611
uint32_t SetupGetTrimForAdcShVbufEn(uint32_t ui32Fcfg1Revision)
Returns the trim value from FCFG1 to be used as ADC_SH_VBUF_EN setting.
Definition: setup.c:1047
#define AUX_WUC_POWER_DOWN
Definition: aux_wuc.h:95
void AUXWUCPowerCtrl(uint32_t ui32PowerMode)
Control the power to the AUX domain.
Definition: aux_wuc.c:274
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:160
void DDI16BitfieldWrite(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32Shift, uint16_t ui32Data)
Write a bitfield via the DDI using 16-bit maskable write.
Definition: ddi.c:131
#define IOC_STD_INPUT
Definition: ioc.h:292
uint32_t SetupGetTrimForRadcExtCfg(uint32_t ui32Fcfg1Revision)
Returns the trim value to be used for the RADCEXTCFG register in OSC_DIG.
Definition: setup.c:1116
void SetupSetAonRtcSubSecInc(uint32_t subSecInc)
Doing the tricky stuff needed to enter new RTCSUBSECINC value.
Definition: setup.c:1264
uint32_t SetupGetTrimForRcOscLfIBiasTrim(uint32_t ui32Fcfg1Revision)
Returns the FCFG1 OSC_CONF_ATESTLF_RCOSCLF_IBIAS_TRIM.
Definition: setup.c:1148
void SetupTrimDevice(void)
Performs the necessary trim of the device which is not done in boot code.
Definition: setup.c:142
void ThisCodeIsBuiltForCC26xxHwRev22AndLater_HaltIfViolated(void)
Verifies that current chip is built for CC26xx HwRev 2.2 or later and never returns if violated...
Definition: chipinfo.c:236
void SetupAfterColdResetWakeupFromShutDownCfg1(uint32_t ccfg_ModeConfReg)
First part of configuration required when waking up from shutdown.
Definition: setup.c:432
#define OSC_SRC_CLK_HF
Definition: osc.h:112
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:283
#define OSC_XOSC_HF
Definition: osc.h:117
uint32_t SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio(uint32_t ui32Fcfg1Revision)
Returns XOSCLF_REGULATOR_TRIM and XOSCLF_CMIRRWR_RATIO as one packet spanning bits [5:0] in the retur...
Definition: setup.c:1168
int32_t SetupSignExtendVddrTrimValue(uint32_t ui32VddrTrimVal)
Sign extend the VDDR_TRIM setting (special format ranging from -10 to +21)
Definition: setup.c:1190
#define OSC_SRC_CLK_LF
Definition: osc.h:114
uint32_t SetupGetTrimForAnabypassValue1(uint32_t ccfg_ModeConfReg)
Returns the trim value to be used for the ANABYPASS_VALUE1 register in OSC_DIG.
Definition: setup.c:743
void SetupSetCacheModeAccordingToCcfgSetting(void)
Set correct VIMS_MODE according to CCFG setting (CACHE or GPRAM)
Definition: setup.c:1211
uint32_t SetupGetTrimForAdcShModeEn(uint32_t ui32Fcfg1Revision)
Returns the trim value from FCFG1 to be used as ADC_SH_MODE_EN setting.
Definition: setup.c:1028
uint32_t SetupGetTrimForAmpcompCtrl(uint32_t ui32Fcfg1Revision)
Returns the trim value to be used for the AMPCOMP_CTRL register in OSC_DIG.
Definition: setup.c:931
#define OSC_RCOSC_LF
Definition: osc.h:118
void IOCPortConfigureSet(uint32_t ui32IOId, uint32_t ui32PortId, uint32_t ui32IOConfig)
Set the configuration of an IO port.
Definition: ioc.c:96
static void TrimAfterColdResetWakeupFromShutDown(uint32_t ui32Fcfg1Revision)
Trims to be applied when coming from SHUTDOWN (also called when coming from PIN_RESET).
Definition: setup.c:299
#define IOC_HYST_ENABLE
Definition: ioc.h:216
void DDI32RegWrite(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Val)
Write a 32 bit value to a register in the DDI slave.
Definition: ddi.c:66
uint32_t SetupGetTrimForXoscHfFastStart(void)
Returns the trim value to be used as OSC_DIG:CTL1.XOSC_HF_FAST_START.
Definition: setup.c:1098
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
Definition: osc.c:101
void SetupAfterColdResetWakeupFromShutDownCfg2(uint32_t ui32Fcfg1Revision, uint32_t ccfg_ModeConfReg)
Second part of configuration required when waking up from shutdown.
Definition: setup.c:495
uint32_t SetupGetTrimForXoscHfCtl(uint32_t ui32Fcfg1Revision)
Returns the trim value to be used for the XOSCHFCTL register in OSC_DIG.
Definition: setup.c:1066
static void TrimAfterColdReset(void)
Trims to be applied when coming from PIN_RESET.
Definition: setup.c:419
#define OSC_XOSC_LF
Definition: osc.h:119
uint32_t SetupGetTrimForXoscHfIbiastherm(void)
Returns the trim value to be used for the XOSC_HF_IBIASTHERM bit field in the ANABYPASS_VALUE2 regist...
Definition: setup.c:841
static void AONWUCJtagPowerOff(void)
Request power off of the JTAG domain.
Definition: aon_wuc.h:816