CC13xx Driver Library
setup.c
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: setup.c
3 * Revised: 2016-04-07 15:04:05 +0200 (Thu, 07 Apr 2016)
4 * Revision: 46052
5 *
6 * Description: Setup file for CC13xx/CC26xx devices.
7 *
8 * Copyright (c) 2015, 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_memmap.h>
41 #include <inc/hw_types.h>
42 #include <inc/hw_adi.h>
43 #include <inc/hw_adi_0_rf.h>
44 #include <inc/hw_adi_1_synth.h>
45 #include <inc/hw_adi_2_refsys.h>
46 #include <inc/hw_adi_3_refsys.h>
47 #include <inc/hw_adi_4_aux.h>
48 #include <inc/hw_aon_ioc.h>
49 #include <inc/hw_aon_sysctl.h>
50 #include <inc/hw_aon_wuc.h>
51 #include <inc/hw_aux_wuc.h>
52 #include <inc/hw_ccfg.h>
53 #include <inc/hw_chip_def.h>
54 #include <inc/hw_ddi.h>
55 #include <inc/hw_flash.h>
56 #include <inc/hw_fcfg1.h>
57 #include <inc/hw_ddi_0_osc.h>
58 #include <inc/hw_prcm.h>
59 #include <inc/hw_vims.h>
60 #include <inc/hw_aon_batmon.h>
61 #include <inc/hw_aon_rtc.h>
62 // Driverlib headers
63 #include <driverlib/adi.h>
64 #include <driverlib/aon_batmon.h>
65 #include <driverlib/cpu.h>
66 #include <driverlib/chipinfo.h>
67 #include <driverlib/ddi.h>
68 #include <driverlib/ioc.h>
69 #include <driverlib/prcm.h>
70 #include <driverlib/setup.h>
71 #include <driverlib/sys_ctrl.h>
72 
73 // We need intrinsic functions for IAR (if used in source code)
74 #ifdef __IAR_SYSTEMS_ICC__
75 #include <intrinsics.h>
76 #endif
77 
78 //*****************************************************************************
79 //
80 // Function declarations
81 //
82 //*****************************************************************************
83 static uint32_t GetTrimForAdcShModeEn( uint32_t ui32Fcfg1Revision );
84 static uint32_t GetTrimForAdcShVbufEn( uint32_t ui32Fcfg1Revision );
85 static uint32_t GetTrimForAmpcompCtrl( uint32_t ui32Fcfg1Revision );
86 static uint32_t GetTrimForAmpcompTh1( void );
87 static uint32_t GetTrimForAmpcompTh2( void );
88 static uint32_t GetTrimForAnabypassValue1( uint32_t ccfg_ModeConfReg );
89 static uint32_t GetTrimForDblrLoopFilterResetVoltage( uint32_t ui32Fcfg1Revision );
90 static uint32_t GetTrimForRadcExtCfg( uint32_t ui32Fcfg1Revision );
91 static uint32_t GetTrimForRcOscLfIBiasTrim( uint32_t ui32Fcfg1Revision );
92 static uint32_t GetTrimForRcOscLfRtuneCtuneTrim( void );
93 static uint32_t GetTrimForXoscHfCtl( uint32_t ui32Fcfg1Revision );
94 static uint32_t GetTrimForXoscHfFastStart( void );
95 static uint32_t GetTrimForXoscHfIbiastherm( void );
96 static uint32_t GetTrimForXoscLfRegulatorAndCmirrwrRatio( uint32_t ui32Fcfg1Revision );
97 
98 int32_t SignExtendVddrTrimValue( uint32_t ui32VddrTrimVal );
99 static void HapiTrimDeviceColdReset( void );
100 static void HapiTrimDeviceShutDown( uint32_t ui32Fcfg1Revision );
101 static void HapiTrimDevicePowerDown( void );
102 
103 void SetVddrLevel( uint32_t ccfg_ModeConfReg );
104 
105 
106 //*****************************************************************************
107 //
109 //
110 //*****************************************************************************
111 #define DELAY_20_USEC 0x140
112 
113 
114 //*****************************************************************************
115 //
116 // Defined CPU delay macro with microseconds as input
117 // Quick check shows: (To be further investigated)
118 // At 48 MHz RCOSC and VIMS.CONTROL.PREFETCH = 0, there is 5 cycles
119 // At 48 MHz RCOSC and VIMS.CONTROL.PREFETCH = 1, there is 4 cycles
120 // At 24 MHz RCOSC and VIMS.CONTROL.PREFETCH = 0, there is 3 cycles
121 //
122 //*****************************************************************************
123 #define CPU_DELAY_MICRO_SECONDS( x ) \
124  CPUdelay(((uint32_t)((( x ) * 48.0 ) / 5.0 )) - 1 )
125 
126 
127 //*****************************************************************************
128 //
132 //
133 //*****************************************************************************
134 static void
136 {
137  //
138  // - Make sure to enable aggressive VIMS clock gating for power optimization
139  // Only for PG2 devices.
140  // - Enable cache prefetch enable as default setting
141  // (Slightly higher power consumption, but higher CPU performance)
142  // - IF ( CCFG_..._DIS_GPRAM == 1 )
143  // then: Enable cache (set cache mode = 1), even if set by ROM boot code
144  // (This is done because it's not set by boot code when running inside
145  // a debugger supporting the Halt In Boot (HIB) functionality).
146  // else: Set MODE_GPRAM if not already set (see inline comments as well)
147  //
148  uint32_t vimsCtlMode0 ;
149 
150  while ( HWREGBITW( VIMS_BASE + VIMS_O_STAT, VIMS_STAT_MODE_CHANGING_BITN )) {
151  // Do nothing - wait for an eventual ongoing mode change to complete.
152  // (There should typically be no wait time here, but need to be sure)
153  }
154 
155  //
156  // Note that Mode=0 is equal to MODE_GPRAM
157  //
158  vimsCtlMode0 = (( HWREG( VIMS_BASE + VIMS_O_CTL ) & ~VIMS_CTL_MODE_M ) | VIMS_CTL_DYN_CG_EN_M | VIMS_CTL_PREF_EN_M );
159 
160 
162  // Enable cache (and hence disable GPRAM)
163  HWREG( VIMS_BASE + VIMS_O_CTL ) = ( vimsCtlMode0 | VIMS_CTL_MODE_CACHE );
164  } else if (( HWREG( VIMS_BASE + VIMS_O_STAT ) & VIMS_STAT_MODE_M ) != VIMS_STAT_MODE_GPRAM ) {
165  //
166  // GPRAM is enabled in CCFG but not selected
167  // Note: It is recommended to go via MODE_OFF when switching to MODE_GPRAM
168  //
169  HWREG( VIMS_BASE + VIMS_O_CTL ) = ( vimsCtlMode0 | VIMS_CTL_MODE_OFF );
170  while (( HWREG( VIMS_BASE + VIMS_O_STAT ) & VIMS_STAT_MODE_M ) != VIMS_STAT_MODE_OFF ) {
171  // Do nothing - wait for an eventual mode change to complete (This goes fast).
172  }
173  HWREG( VIMS_BASE + VIMS_O_CTL ) = vimsCtlMode0;
174  } else {
175  // Correct mode, but make sure PREF_EN and DYN_CG_EN always are set
176  HWREG( VIMS_BASE + VIMS_O_CTL ) = vimsCtlMode0;
177  }
178 }
179 
180 
181 //*****************************************************************************
182 //
183 // Perform the necessary trim of the device which is not done in boot code
184 //
185 // This function should only execute coming from ROM boot. The current
186 // implementation does not take soft reset into account. However, it does no
187 // damage to execute it again. It only consumes time.
188 //
189 //*****************************************************************************
190 void
192 {
193  uint32_t ui32Fcfg1Revision;
194  uint32_t ui32AonSysResetctl;
195 
196  //
197  // Get layout revision of the factory configuration area
198  // (Handle undefined revision as revision = 0)
199  //
200  ui32Fcfg1Revision = HWREG(FCFG1_BASE + FCFG1_O_FCFG1_REVISION);
201  if ( ui32Fcfg1Revision == 0xFFFFFFFF ) {
202  ui32Fcfg1Revision = 0;
203  }
204 
205 
206  //
207  // This driverlib version and setup file is for CC13xx PG2.0 and later.
208  // Halt if violated
209  //
211 
212  //
213  // Enable standby in flash bank
214  //
216 
217  //
218  // Clock must always be enabled for the semaphore module (due to ADI/DDI HW workaround)
219  //
221 
222  //
223  // Warm resets on CC26XX complicates software design as much of our software
224  // expect that initialization is done from a full system reset.
225  // This includes RTC setup, oscillator configuration and AUX setup.
226  // To ensure a full reset of the device is done when customers get e.g. a Watchdog
227  // reset, the following is set here:
228  //
230 
231  //
232  // Select correct CACHE mode and set correct CACHE configuration
233  //
235 
236  // 1. Check for powerdown
237  // 2. Check for shutdown
238  // 3. Assume cold reset if none of the above.
239  //
240  // It is always assumed that the application will freeze the latches in
241  // AON_IOC when going to powerdown in order to retain the values on the IOs.
242  //
243  // NB. If this bit is not cleared before proceeding to powerdown, the IOs
244  // will all default to the reset configuration when restarting.
246  {
247  //
248  // NB. This should be calling a ROM implementation of required trim and
249  // compensation
250  // e.g. HapiTrimDevicePowerDown()
252  }
253  // Check for shutdown
254  //
255  // When device is going to shutdown the hardware will automatically clear
256  // the SLEEPDIS bit in the SLEEP register in the AON_SYSCTRL12 module.
257  // It is left for the application to assert this bit when waking back up,
258  // but not before the desired IO configuration has been re-established.
260  {
261  //
262  // NB. This should be calling a ROM implementation of required trim and
263  // compensation
264  // e.g. HapiTrimDeviceShutDown() -->
265  // HapiTrimDevicePowerDown();
266  HapiTrimDeviceShutDown(ui32Fcfg1Revision);
268  }
269  else
270  {
271  // Consider adding a check for soft reset to allow debugging to skip
272  // this section!!!
273  //
274  // NB. This should be calling a ROM implementation of required trim and
275  // compensation
276  // e.g. HapiTrimDeviceColdReset() -->
277  // HapiTrimDeviceShutDown() -->
278  // HapiTrimDevicePowerDown()
280  HapiTrimDeviceShutDown(ui32Fcfg1Revision);
282 
283  }
284 
285  //
286  // Set VIMS power domain control.
287  // PDCTL1VIMS = 0 ==> VIMS power domain is only powered when CPU power domain is powered
288  //
289  HWREG( PRCM_BASE + PRCM_O_PDCTL1VIMS ) = 0;
290 
291  //
292  // Configure optimal wait time for flash FSM in cases where flash pump
293  // wakes up from sleep
294  //
295  HWREG(FLASH_BASE + FLASH_O_FPAC1) = (HWREG(FLASH_BASE + FLASH_O_FPAC1) &
297  (0x139<<FLASH_FPAC1_PSLEEPTDIS_S);
298 
299  //
300  // And finally at the end of the flash boot process:
301  // SET BOOT_DET bits in AON_SYSCTL to 3 if already found to be 1
302  // Note: The BOOT_DET_x_CLR/SET bits must be manually cleared
303  //
304  if ((( HWREG( AON_SYSCTL_BASE + AON_SYSCTL_O_RESETCTL ) &
307  {
308  ui32AonSysResetctl = ( HWREG( AON_SYSCTL_BASE + AON_SYSCTL_O_RESETCTL ) &
312  HWREG( AON_SYSCTL_BASE + AON_SYSCTL_O_RESETCTL ) = ui32AonSysResetctl;
313  }
314 
315  //
316  // Make sure there are no ongoing VIMS mode change when leaving trimDevice()
317  // (There should typically be no wait time here, but need to be sure)
318  //
319  while ( HWREGBITW( VIMS_BASE + VIMS_O_STAT, VIMS_STAT_MODE_CHANGING_BITN )) {
320  // Do nothing - wait for an eventual ongoing mode change to complete.
321  }
322 }
323 
324 //*****************************************************************************
325 //
330 //
331 //*****************************************************************************
332 static void
334 {
335  //
336  // Currently no specific trim for Powerdown
337  //
338 }
339 
340 //*****************************************************************************
341 //
345 //
346 //*****************************************************************************
347 static void
348 SetAonRtcSubSecInc( uint32_t subSecInc )
349 {
350  //
351  // Loading a new RTCSUBSECINC value is done in 5 steps:
352  // 1. Write bit[15:0] of new SUBSECINC value to AUX_WUC_O_RTCSUBSECINC0
353  // 2. Write bit[23:16] of new SUBSECINC value to AUX_WUC_O_RTCSUBSECINC1
355  // 4. Wait for AUX_WUC_RTCSUBSECINCCTL_UPD_ACK
357  //
359  HWREG( AUX_WUC_BASE + AUX_WUC_O_RTCSUBSECINC1 ) = (( subSecInc >> 16 ) & AUX_WUC_RTCSUBSECINC1_INC23_16_M );
360 
364 }
365 
366 //*****************************************************************************
367 //
372 //
373 //*****************************************************************************
374 static void
375 HapiTrimDeviceShutDown(uint32_t ui32Fcfg1Revision)
376 {
377  uint32_t ui32Trim ;
378  uint32_t ccfg_ModeConfReg ;
379  uint32_t currentHfClock ;
380  uint32_t ccfgExtLfClk ;
381  int32_t i32VddrSleepTrim ;
382  int32_t i32VddrSleepDelta ;
383  uint32_t fcfg1OscConf ;
384 
385  //
386  // Force AUX on and enable clocks
387  //
388  // No need to save the current status of the power/clock registers.
389  // At this point both AUX and AON should have been reset to 0x0.
390  //
392 
393  //
394  // Wait for power on on the AUX domain
395  //
397 
398  //
399  // Enable the clocks for AUX_DDI0_OSC and AUX_ADI4
400  //
403 
404  //
405  // Check in CCFG for alternative DCDC setting
406  //
408  //
409  // ADI_3_REFSYS:DCDCCTL5[3] (=DITHER_EN) = CCFG_MODE_CONF_1[19] (=ALT_DCDC_DITHER_EN)
410  // ADI_3_REFSYS:DCDCCTL5[2:0](=IPEAK ) = CCFG_MODE_CONF_1[18:16](=ALT_DCDC_IPEAK )
411  // Using a single 4-bit masked write since layout is equal for both source and destination
412  //
413  HWREGB( ADI3_BASE + ADI_O_MASK4B + ( ADI_3_REFSYS_O_DCDCCTL5 * 2 )) = ( 0xF0 |
415 
416  }
417 
418  //
419  // Enable for JTAG to be powered down (will still be powered on if debugger is connected)
420  //
422 
423  //
424  // read the MODE_CONF register in CCFG
425  //
426  ccfg_ModeConfReg = HWREG( CCFG_BASE + CCFG_O_MODE_CONF );
427 
428  //
429  // Check for CC13xx boost mode
430  // The combination VDDR_EXT_LOAD=0 and VDDS_BOD_LEVEL=1 is defined to selct boost mode
431  //
432  if ((( ccfg_ModeConfReg & CCFG_MODE_CONF_VDDR_EXT_LOAD ) == 0 ) &&
433  (( ccfg_ModeConfReg & CCFG_MODE_CONF_VDDS_BOD_LEVEL ) != 0 ) ) {
434  //
435  // Set VDDS_BOD trim - using masked write {MASK8:DATA8}
436  // - TRIM_VDDS_BOD is bits[7:3] of ADI3..REFSYSCTL1
437  // - Needs a positive transition on BOD_BG_TRIM_EN (bit[7] of REFSYSCTL3) to
438  // latch new VDDS BOD. Set to 0 first to guarantee a positive transition.
439  //
441 // if ( ccfg_ModeConfReg & CCFG_MODE_CONF_VDDS_BOD_LEVEL ) {
442  //
443  // VDDS_BOD_LEVEL = 1 means that boost mode is selected
444  // - Max out the VDDS_BOD trim (=VDDS_BOD_POS_31)
445  //
446  HWREGH( ADI3_BASE + ADI_O_MASK8B + ( ADI_3_REFSYS_O_REFSYSCTL1 * 2 )) =
449 // } else {
450 // //
451 // // VDDS_BOD_LEVEL = 0
452 // // - Set VDDS_BOD to FCFG1..TRIMBOD_H
453 // //
454 // HWREGH( ADI3_BASE + ADI_O_MASK8B + ( ADI_3_REFSYS_O_REFSYSCTL1 * 2 )) =
456 // ((( HWREG( FCFG1_BASE + FCFG1_O_VOLT_TRIM ) &
459 // }
461 
462  SetVddrLevel( ccfg_ModeConfReg );
463 
464  i32VddrSleepTrim = SignExtendVddrTrimValue((
465  HWREG( FCFG1_BASE + FCFG1_O_VOLT_TRIM ) &
468  } else
469  {
470  i32VddrSleepTrim = SignExtendVddrTrimValue((
471  HWREG( FCFG1_BASE + FCFG1_O_LDO_TRIM ) &
474  }
475 
476  //
477  // Adjust the VDDR_TRIM_SLEEP value with value adjustable by customer (CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA)
478  // Read and sign extend VddrSleepDelta (in range -8 to +7)
479  //
480  i32VddrSleepDelta = ((((int32_t)ccfg_ModeConfReg )
481  << ( 32 - CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_W - CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_S ))
482  >> ( 32 - CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_W ));
483  // Calculate new VDDR sleep trim
484  i32VddrSleepTrim = ( i32VddrSleepTrim + i32VddrSleepDelta + 1 );
485  if ( i32VddrSleepTrim > 21 ) i32VddrSleepTrim = 21;
486  if ( i32VddrSleepTrim < -10 ) i32VddrSleepTrim = -10;
487  // Write adjusted value using MASKED write (MASK8)
488  HWREGH( ADI3_BASE + ADI_O_MASK8B + ( ADI_3_REFSYS_O_DCDCCTL1 * 2 )) = (( ADI_3_REFSYS_DCDCCTL1_VDDR_TRIM_SLEEP_M << 8 ) |
490 
491  //
492  // Do not allow DCDC to be enabled if in external regulator mode.
493  // Preventing this by setting both the RECHARGE and the ACTIVE bits bit in the CCFG_MODE_CONF copy register (ccfg_ModeConfReg).
494  //
497  }
498 
499  //
500  // set the RECHARGE source based upon CCFG:MODE_CONF:DCDC_RECHARGE
501  // Note: Inverse polarity
502  //
504  ((( ccfg_ModeConfReg >> CCFG_MODE_CONF_DCDC_RECHARGE_S ) & 1 ) ^ 1 );
505 
506  //
507  // set the ACTIVE source based upon CCFG:MODE_CONF:DCDC_ACTIVE
508  // Note: Inverse polarity
509  //
511  ((( ccfg_ModeConfReg >> CCFG_MODE_CONF_DCDC_ACTIVE_S ) & 1 ) ^ 1 );
512 
513  //
514  // Following sequence is required for using XOSCHF, if not included
515  // devices crashes when trying to switch to XOSCHF.
516  //
517  // Trim CAP settings. Get and set trim value for the ANABYPASS_VALUE1
518  // register
519  ui32Trim = GetTrimForAnabypassValue1( ccfg_ModeConfReg );
521 
522  // Trim RCOSC_LF. Get and set trim values for the RCOSCLF_RTUNE_TRIM and
523  // RCOSCLF_CTUNE_TRIM fields in the XOSCLF_RCOSCLF_CTRL register.
524  ui32Trim = GetTrimForRcOscLfRtuneCtuneTrim();
529  ui32Trim);
530 
531  // Trim XOSCHF IBIAS THERM. Get and set trim value for the
532  // XOSCHF IBIAS THERM bit field in the ANABYPASS_VALUE2 register. Other
533  // register bit fields are set to 0.
534  ui32Trim = GetTrimForXoscHfIbiastherm();
537 
538  // Trim AMPCOMP settings required before switch to XOSCHF
539  ui32Trim = GetTrimForAmpcompTh2();
541  ui32Trim = GetTrimForAmpcompTh1();
543  ui32Trim = GetTrimForAmpcompCtrl( ui32Fcfg1Revision );
545 
546  //
547  // Set trim for DDI_0_OSC_ADCDOUBLERNANOAMPCTL_ADC_SH_MODE_EN in accordance to FCFG1 setting
548  // This is bit[5] in the DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL register
549  // Using MASK4 write + 1 => writing to bits[7:4]
550  //
551  ui32Trim = GetTrimForAdcShModeEn( ui32Fcfg1Revision );
552  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 1 ) =
553  ( 0x20 | ( ui32Trim << 1 ));
554 
555  //
556  // Set trim for DDI_0_OSC_ADCDOUBLERNANOAMPCTL_ADC_SH_VBUF_EN in accordance to FCFG1 setting
557  // This is bit[4] in the DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL register
558  // Using MASK4 write + 1 => writing to bits[7:4]
559  //
560  ui32Trim = GetTrimForAdcShVbufEn( ui32Fcfg1Revision );
561  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 1 ) =
562  ( 0x10 | ( ui32Trim ));
563 
564  //
565  // Set trim for the PEAK_DET_ITRIM, HP_BUF_ITRIM and LP_BUF_ITRIM bit fields
566  // in the DDI0_OSC_O_XOSCHFCTL register in accordance to FCFG1 setting.
567  // Remaining register bit fields are set to their reset values of 0.
568  //
569  ui32Trim = GetTrimForXoscHfCtl(ui32Fcfg1Revision);
571 
572  //
573  // Set trim for DBLR_LOOP_FILTER_RESET_VOLTAGE in accordance to FCFG1 setting
574  // (This is bits [18:17] in DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL)
575  // (Using MASK4 write + 4 => writing to bits[19:16] => (4*4))
576  // (Assuming: DDI_0_OSC_ADCDOUBLERNANOAMPCTL_DBLR_LOOP_FILTER_RESET_VOLTAGE_S = 17 and
577  // that DDI_0_OSC_ADCDOUBLERNANOAMPCTL_DBLR_LOOP_FILTER_RESET_VOLTAGE_M = 0x00060000)
578  //
579  ui32Trim = GetTrimForDblrLoopFilterResetVoltage( ui32Fcfg1Revision );
580  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 4 ) =
581  ( 0x60 | ( ui32Trim << 1 ));
582 
583  //
584  // Update DDI_0_OSC_ATESTCTL_ATESTLF_RCOSCLF_IBIAS_TRIM with data from
586  // This is DDI_0_OSC_O_ATESTCTL bit[7]
587  // ( DDI_0_OSC_O_ATESTCTL is currently hidden (but=0x00000020))
588  // Using MASK4 write + 1 => writing to bits[7:4]
589  //
590  ui32Trim = GetTrimForRcOscLfIBiasTrim( ui32Fcfg1Revision );
591  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( 0x00000020 * 2 ) + 1 ) =
592  ( 0x80 | ( ui32Trim << 3 ));
593 
594  //
597  // This can be simplified since the registers are packed together in the same
598  // order both in FCFG1 and in the HW register.
599  // This spans DDI_0_OSC_O_LFOSCCTL bits[23:18]
600  // Using MASK8 write + 4 => writing to bits[23:16]
601  //
602  ui32Trim = GetTrimForXoscLfRegulatorAndCmirrwrRatio( ui32Fcfg1Revision );
603  HWREGH( AUX_DDI0_OSC_BASE + DDI_O_MASK8B + ( DDI_0_OSC_O_LFOSCCTL * 2 ) + 4 ) =
604  ( 0xFC00 | ( ui32Trim << 2 ));
605 
606  //
607  // Set trim the HPM_IBIAS_WAIT_CNT, LPM_IBIAS_WAIT_CNT and IDAC_STEP bit
608  // fields in the DDI0_OSC_O_RADCEXTCFG register in accordance to FCFG1 setting.
609  // Remaining register bit fields are set to their reset values of 0.
610  //
611  ui32Trim = GetTrimForRadcExtCfg(ui32Fcfg1Revision);
613 
614  // Setting FORCE_KICKSTART_EN (ref. CC26_V1_BUG00261). Should also be done for PG2
615  // (This is bit 22 in DDI_0_OSC_O_CTL0)
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  // Clear DDI_0_OSC_CTL0_CLK_LOSS_EN (ClockLossEventEnable()). This is bit 9 in DDI_0_OSC_O_CTL0.
667  // This is typically already 0 except on Lizard where it is set in ROM-boot
669 
670  // Setting DDI_0_OSC_CTL1_XOSC_HF_FAST_START according to value found in FCFG1
671  ui32Trim = GetTrimForXoscHfFastStart();
672  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_CTL1 * 2 )) = ( 0x30 | ui32Trim );
673 
674  //
675  // setup the LF clock based upon CCFG:MODE_CONF:SCLK_LF_OPTION
676  //
677  switch (( ccfg_ModeConfReg & CCFG_MODE_CONF_SCLK_LF_OPTION_M ) >> CCFG_MODE_CONF_SCLK_LF_OPTION_S ) {
678  case 0 : // XOSC_HF_DLF (XOSCHF/1536) -> SCLK_LF (=31250Hz)
680  SetAonRtcSubSecInc( 0x8637BD );
681  break;
682  case 1 : // EXTERNAL signal -> SCLK_LF (frequency=2^38/CCFG_EXT_LF_CLK_RTC_INCREMENT)
683  // Set SCLK_LF to use the same source as SCLK_HF
684  // Can be simplified a bit since possible return values for HF matches LF settings
685  currentHfClock = OSCClockSourceGet( OSC_SRC_CLK_HF );
686  OSCClockSourceSet( OSC_SRC_CLK_LF, currentHfClock );
687  while( OSCClockSourceGet( OSC_SRC_CLK_LF ) != currentHfClock ) {
688  // Wait until switched
689  }
690  ccfgExtLfClk = HWREG( CCFG_BASE + CCFG_O_EXT_LF_CLK );
694  IOC_STD_INPUT | IOC_HYST_ENABLE ); // Route external clock to AON IOC w/hysteresis
695  // Set XOSC_LF in bypass mode to allow external 32k clock
697  // Fall through to set XOSC_LF as SCLK_LF source
698  case 2 : // XOSC_LF -> SLCK_LF (32768 Hz)
700  break;
701  default : // (=3) RCOSC_LF
703  break;
704  }
705 
706  //
707  // Update ADI_4_AUX_ADCREF1_VTRIM with value from FCFG1
708  //
709  HWREGB( AUX_ADI4_BASE + ADI_4_AUX_O_ADCREF1 ) =
714 
715  //
716  // Set ADI_4_AUX:ADC0.SMPL_CYCLE_EXP to it's default minimum value (=3)
717  // (Note: Using MASK8B requires that the bits to be modified must be within the same
718  // byte boundary which is the case for the ADI_4_AUX_ADC0_SMPL_CYCLE_EXP field)
719  //
720  HWREGH( AUX_ADI4_BASE + ADI_O_MASK8B + ( ADI_4_AUX_O_ADC0 * 2 )) =
722 
723  //
724  // Sync with AON
725  //
726  SysCtrlAonSync();
727 
728  //
729  // Allow AUX to power down
730  //
732 
733  //
734  // Leaving on AUX and clock for AUX_DDI0_OSC on but turn off clock for AUX_ADI4
735  //
737 
738  // Disable EFUSE clock
740 }
741 
742 //*****************************************************************************
743 //
747 //
748 //*****************************************************************************
749 int32_t
750 SignExtendVddrTrimValue( uint32_t ui32VddrTrimVal )
751 {
752  //
753  // The VDDR trim value is 5 bits representing the range from -10 to +21
754  // (where -10=0x16, -1=0x1F, 0=0x00, 1=0x01 and +21=0x15)
755  //
756  int32_t i32SignedVddrVal = ui32VddrTrimVal;
757  if ( i32SignedVddrVal > 0x15 ) {
758  i32SignedVddrVal -= 0x20;
759  }
760  return ( i32SignedVddrVal );
761 }
762 
763 //*****************************************************************************
764 //
768 //
769 //*****************************************************************************
770 static void
772 {
773  //
774  // Currently no specific trim for Cold Reset
775  //
776 }
777 
778 //*****************************************************************************
779 //
781 //
782 //*****************************************************************************
783 static uint32_t
784 GetTrimForAnabypassValue1( uint32_t ccfg_ModeConfReg )
785 {
786  uint32_t ui32Fcfg1Value ;
787  uint32_t ui32XoscHfRow ;
788  uint32_t ui32XoscHfCol ;
789  int32_t i32CustomerDeltaAdjust ;
790  uint32_t ui32TrimValue ;
791 
792  // Use device specific trim values located in factory configuration
793  // area for the XOSC_HF_COLUMN_Q12 and XOSC_HF_ROW_Q12 bit fields in
794  // the ANABYPASS_VALUE1 register. Value for the other bit fields
795  // are set to 0.
796 
797  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_OSC_TOP);
798  ui32XoscHfRow = (( ui32Fcfg1Value &
801  ui32XoscHfCol = (( ui32Fcfg1Value &
804 
805  i32CustomerDeltaAdjust = 0;
806  if (( ccfg_ModeConfReg & CCFG_MODE_CONF_XOSC_CAP_MOD ) == 0 ) {
807  // XOSC_CAP_MOD = 0 means: CAP_ARRAY_DELTA is in use -> Apply compensation
808  // XOSC_CAPARRAY_DELTA is located in bit[15:8] of ccfg_ModeConfReg
809  // Note: HW_REV_DEPENDENT_IMPLEMENTATION. Field width is not given by
810  // a define and sign extension must therefore be hardcoded.
811  // ( A small test program is created verifying the code lines below:
812  // Ref.: ..\test\small_standalone_test_programs\CapArrayDeltaAdjust_test.c)
813  i32CustomerDeltaAdjust = ((int32_t)ccfg_ModeConfReg << 16 ) >> 24;
814 
815  while ( i32CustomerDeltaAdjust < 0 ) {
816  ui32XoscHfCol >>= 1; // COL 1 step down
817  if ( ui32XoscHfCol == 0 ) { // if COL below minimum
818  ui32XoscHfCol = 0xFFFF; // Set COL to maximum
819  ui32XoscHfRow >>= 1; // ROW 1 step down
820  if ( ui32XoscHfRow == 0 ) { // if ROW below minimum
821  ui32XoscHfRow = 1; // Set both ROW and COL
822  ui32XoscHfCol = 1; // to minimum
823  }
824  }
825  i32CustomerDeltaAdjust++;
826  }
827  while ( i32CustomerDeltaAdjust > 0 ) {
828  ui32XoscHfCol = ( ui32XoscHfCol << 1 ) | 1; // COL 1 step up
829  if ( ui32XoscHfCol > 0xFFFF ) { // if COL above maximum
830  ui32XoscHfCol = 1; // Set COL to minimum
831  ui32XoscHfRow = ( ui32XoscHfRow << 1 ) | 1; // ROW 1 step up
832  if ( ui32XoscHfRow > 0xF ) { // if ROW above maximum
833  ui32XoscHfRow = 0xF; // Set both ROW and COL
834  ui32XoscHfCol = 0xFFFF; // to maximum
835  }
836  }
837  i32CustomerDeltaAdjust--;
838  }
839  }
840 
841  ui32TrimValue = (( ui32XoscHfRow << DDI_0_OSC_ANABYPASSVAL1_XOSC_HF_ROW_Q12_S ) |
842  ( ui32XoscHfCol << DDI_0_OSC_ANABYPASSVAL1_XOSC_HF_COLUMN_Q12_S ) );
843 
844  return (ui32TrimValue);
845 }
846 
847 //*****************************************************************************
848 //
851 //
852 //*****************************************************************************
853 static uint32_t
855 {
856  uint32_t ui32TrimValue;
857 
858  // Use device specific trim values located in factory configuration
859  // area
860  ui32TrimValue =
865 
866  ui32TrimValue |=
871 
872  return(ui32TrimValue);
873 }
874 
875 //*****************************************************************************
876 //
879 //
880 //*****************************************************************************
881 static uint32_t
883 {
884  uint32_t ui32TrimValue;
885 
886  // Use device specific trim value located in factory configuration
887  // area
888  ui32TrimValue =
892 
893  return(ui32TrimValue);
894 }
895 
896 //*****************************************************************************
897 //
899 //
900 //*****************************************************************************
901 static uint32_t
903 {
904  uint32_t ui32TrimValue;
905  uint32_t ui32Fcfg1Value;
906 
907  // Use device specific trim value located in factory configuration
908  // area. All defined register bit fields have corresponding trim
909  // value in the factory configuration area
910  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_AMPCOMP_TH2);
911  ui32TrimValue = ((ui32Fcfg1Value &
915  ui32TrimValue |= (((ui32Fcfg1Value &
919  ui32TrimValue |= (((ui32Fcfg1Value &
923  ui32TrimValue |= (((ui32Fcfg1Value &
927 
928  return(ui32TrimValue);
929 }
930 
931 //*****************************************************************************
932 //
934 //
935 //*****************************************************************************
936 static uint32_t
938 {
939  uint32_t ui32TrimValue;
940  uint32_t ui32Fcfg1Value;
941 
942  // Use device specific trim values located in factory configuration
943  // area. All defined register bit fields have a corresponding trim
944  // value in the factory configuration area
945  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_AMPCOMP_TH1);
946  ui32TrimValue = (((ui32Fcfg1Value &
950  ui32TrimValue |= (((ui32Fcfg1Value &
954  ui32TrimValue |= (((ui32Fcfg1Value &
958  ui32TrimValue |= (((ui32Fcfg1Value &
962 
963  return(ui32TrimValue);
964 }
965 
966 //*****************************************************************************
967 //
969 //
970 //*****************************************************************************
971 static uint32_t
972 GetTrimForAmpcompCtrl( uint32_t ui32Fcfg1Revision )
973 {
974  uint32_t ui32TrimValue ;
975  uint32_t ui32Fcfg1Value ;
976  uint32_t ibiasOffset ;
977  uint32_t ibiasInit ;
978  uint32_t modeConf1 ;
979  int32_t deltaAdjust ;
980 
981  // Use device specific trim values located in factory configuration
982  // area. Register bit fields without trim values in the factory
983  // configuration area will be set to the value of 0.
984  ui32Fcfg1Value = HWREG( FCFG1_BASE + FCFG1_O_AMPCOMP_CTRL1 );
985 
986  ibiasOffset = ( ui32Fcfg1Value &
989  ibiasInit = ( ui32Fcfg1Value &
992 
994  // Adjust with DELTA_IBIAS_OFFSET and DELTA_IBIAS_INIT from CCFG
995  modeConf1 = HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 );
996 
997  // Both fields are signed 4-bit values. This is an assumption when doing the sign extension.
998  deltaAdjust = ((int32_t)modeConf1 << ( 32 - CCFG_MODE_CONF_1_DELTA_IBIAS_OFFSET_S - 4 )) >> 28;
999  deltaAdjust += (int32_t)ibiasOffset;
1000  if ( deltaAdjust < 0 ) {
1001  deltaAdjust = 0;
1002  }
1005  }
1006  ibiasOffset = (uint32_t)deltaAdjust;
1007 
1008  deltaAdjust = ((int32_t)modeConf1 << ( 32 - CCFG_MODE_CONF_1_DELTA_IBIAS_INIT_S - 4 )) >> 28;
1009  deltaAdjust += (int32_t)ibiasInit;
1010  if ( deltaAdjust < 0 ) {
1011  deltaAdjust = 0;
1012  }
1015  }
1016  ibiasInit = (uint32_t)deltaAdjust;
1017  }
1018  ui32TrimValue = ( ibiasOffset << DDI_0_OSC_AMPCOMPCTL_IBIAS_OFFSET_S ) |
1019  ( ibiasInit << DDI_0_OSC_AMPCOMPCTL_IBIAS_INIT_S ) ;
1020 
1021  ui32TrimValue |= (((ui32Fcfg1Value &
1025  ui32TrimValue |= (((ui32Fcfg1Value &
1029  ui32TrimValue |= (((ui32Fcfg1Value &
1033 
1034  if ( ui32Fcfg1Revision >= 0x00000022 ) {
1035  ui32TrimValue |= ((( ui32Fcfg1Value &
1039  }
1040 
1041  return(ui32TrimValue);
1042 }
1043 
1044 //*****************************************************************************
1045 //
1047 //
1048 //*****************************************************************************
1049 static uint32_t
1050 GetTrimForDblrLoopFilterResetVoltage( uint32_t ui32Fcfg1Revision )
1051 {
1052  uint32_t dblrLoopFilterResetVoltageValue = 0; // Reset value
1053 
1054  if ( ui32Fcfg1Revision >= 0x00000020 ) {
1055  dblrLoopFilterResetVoltageValue = ( HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 ) &
1058  }
1059 
1060  return ( dblrLoopFilterResetVoltageValue );
1061 }
1062 
1063 //*****************************************************************************
1064 //
1066 //
1067 //*****************************************************************************
1068 static uint32_t
1069 GetTrimForAdcShModeEn( uint32_t ui32Fcfg1Revision )
1070 {
1071  uint32_t getTrimForAdcShModeEnValue = 1; // Recommended default setting
1072 
1073  if ( ui32Fcfg1Revision >= 0x00000022 ) {
1074  getTrimForAdcShModeEnValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1077  }
1078 
1079  return ( getTrimForAdcShModeEnValue );
1080 }
1081 
1082 //*****************************************************************************
1083 //
1085 //
1086 //*****************************************************************************
1087 static uint32_t
1088 GetTrimForAdcShVbufEn( uint32_t ui32Fcfg1Revision )
1089 {
1090  uint32_t getTrimForAdcShVbufEnValue = 1; // Recommended default setting
1091 
1092  if ( ui32Fcfg1Revision >= 0x00000022 ) {
1093  getTrimForAdcShVbufEnValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1096  }
1097 
1098  return ( getTrimForAdcShVbufEnValue );
1099 }
1100 
1101 //*****************************************************************************
1102 //
1104 //
1105 //*****************************************************************************
1106 static uint32_t
1107 GetTrimForXoscHfCtl( uint32_t ui32Fcfg1Revision )
1108 {
1109  uint32_t getTrimForXoschfCtlValue = 0; // Recommended default setting
1110  uint32_t fcfg1Data;
1111 
1112  if ( ui32Fcfg1Revision >= 0x00000020 ) {
1113  fcfg1Data = HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 );
1114  getTrimForXoschfCtlValue =
1115  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_PEAK_DET_ITRIM_M ) >>
1118 
1119  getTrimForXoschfCtlValue |=
1120  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_HP_BUF_ITRIM_M ) >>
1123 
1124  getTrimForXoschfCtlValue |=
1125  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_LP_BUF_ITRIM_M ) >>
1128  }
1129 
1130  return ( getTrimForXoschfCtlValue );
1131 }
1132 
1133 //*****************************************************************************
1134 //
1136 //
1137 //*****************************************************************************
1138 static uint32_t
1140 {
1141  uint32_t ui32XoscHfFastStartValue ;
1142 
1143  // Get value from FCFG1
1144  ui32XoscHfFastStartValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1147 
1148  return ( ui32XoscHfFastStartValue );
1149 }
1150 
1151 //*****************************************************************************
1152 //
1154 //
1155 //*****************************************************************************
1156 static uint32_t
1157 GetTrimForRadcExtCfg( uint32_t ui32Fcfg1Revision )
1158 {
1159  uint32_t getTrimForRadcExtCfgValue = 0x403F8000; // Recommended default setting
1160  uint32_t fcfg1Data;
1161 
1162  if ( ui32Fcfg1Revision >= 0x00000020 ) {
1163  fcfg1Data = HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 );
1164  getTrimForRadcExtCfgValue =
1165  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_HPM_IBIAS_WAIT_CNT_M ) >>
1168 
1169  getTrimForRadcExtCfgValue |=
1170  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_LPM_IBIAS_WAIT_CNT_M ) >>
1173 
1174  getTrimForRadcExtCfgValue |=
1175  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_IDAC_STEP_M ) >>
1178  }
1179 
1180  return ( getTrimForRadcExtCfgValue );
1181 }
1182 
1183 //*****************************************************************************
1184 //
1186 //
1187 //*****************************************************************************
1188 static uint32_t
1189 GetTrimForRcOscLfIBiasTrim( uint32_t ui32Fcfg1Revision )
1190 {
1191  uint32_t trimForRcOscLfIBiasTrimValue = 0; // Default value
1192 
1193  if ( ui32Fcfg1Revision >= 0x00000022 ) {
1194  trimForRcOscLfIBiasTrimValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1197  }
1198 
1199  return ( trimForRcOscLfIBiasTrimValue );
1200 }
1201 
1202 //*****************************************************************************
1203 //
1206 //
1207 //*****************************************************************************
1208 static uint32_t
1209 GetTrimForXoscLfRegulatorAndCmirrwrRatio( uint32_t ui32Fcfg1Revision )
1210 {
1211  uint32_t trimForXoscLfRegulatorAndCmirrwrRatioValue = 0; // Default value for both fields
1212 
1213  if ( ui32Fcfg1Revision >= 0x00000022 ) {
1214  trimForXoscLfRegulatorAndCmirrwrRatioValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1218  }
1219 
1220  return ( trimForXoscLfRegulatorAndCmirrwrRatioValue );
1221 }
1222 
1223 
1224 //*****************************************************************************
1225 //
1226 // SetVddrLevel()
1227 // Set VDDR boost mode (by setting VDDR_TRIM to FCFG1..VDDR_TRIM_HH and setting VDDS_BOD to max)
1228 //
1229 //*****************************************************************************
1230 void
1231 SetVddrLevel( uint32_t ccfg_ModeConfReg )
1232 {
1233  uint32_t newTrimRaw ;
1234  int32_t targetTrim ;
1235  int32_t currentTrim ;
1236  int32_t deltaTrim ;
1237 
1238 // if ( ccfg_ModeConfReg & CCFG_MODE_CONF_VDDS_BOD_LEVEL ) {
1239  //
1240  // VDDS_BOD_LEVEL = 1 means that boost mode is selected
1241  // - Step up VDDR_TRIM to FCFG1..VDDR_TRIM_HH
1242  //
1243  newTrimRaw = (( HWREG( FCFG1_BASE + FCFG1_O_VOLT_TRIM ) &
1246 // } else {
1247 // //
1248 // // VDDS_BOD_LEVEL = 0
1249 // // - Step up VDDR_TRIM to FCFG1..VDDR_TRIM_H
1250 // //
1251 // newTrimRaw = (( HWREG( FCFG1_BASE + FCFG1_O_VOLT_TRIM ) &
1254 // }
1255  targetTrim = SignExtendVddrTrimValue( newTrimRaw );
1256  currentTrim = SignExtendVddrTrimValue((
1257  HWREGB( ADI3_BASE + ADI_3_REFSYS_O_DCDCCTL0 ) &
1260 
1261  if ( currentTrim != targetTrim ) {
1262  // Disable VDDR BOD
1264 
1265  while ( currentTrim != targetTrim ) {
1266  deltaTrim = targetTrim - currentTrim;
1267  if ( deltaTrim > 2 ) deltaTrim = 2;
1268  if ( deltaTrim < -2 ) deltaTrim = -2;
1269  currentTrim += deltaTrim;
1270 
1271  HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ); // Wait one SCLK_LF period
1272 
1273  HWREGH( ADI3_BASE + ADI_O_MASK8B + ( ADI_3_REFSYS_O_DCDCCTL0 * 2 )) =
1274  ( ADI_3_REFSYS_DCDCCTL0_VDDR_TRIM_M << 8 ) | (( currentTrim <<
1277 
1278  HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ) = 1; // Force SCLK_LF period wait on next read
1279  }
1280 
1281  HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ); // Wait one SCLK_LF period
1282  HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ) = 1; // Force SCLK_LF period wait on next read
1283  HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ); // Wait one more SCLK_LF period before re-enabling VDDR BOD
1285  HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ); // And finally wait for VDDR_LOSS_EN setting to propagate
1286  }
1287 }
static void SysCtrlAonSync(void)
Sync all accesses to the AON register interface.
Definition: sys_ctrl.h:244
#define IOC_PORT_AON_CLK32K
Definition: ioc.h:169
static 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.h:235
#define AUX_WUC_POWER_DOWN
Definition: aux_wuc.h:95
static void HapiTrimDevicePowerDown(void)
Trims to be applied when coming from POWER_DOWN (also called when coming from SHUTDOWN and PIN_RESET)...
Definition: setup.c:333
static void HapiTrimDeviceShutDown(uint32_t ui32Fcfg1Revision)
Trims to be applied when coming from SHUTDOWN (also called when coming from PIN_RESET).
Definition: setup.c:375
static uint32_t GetTrimForRadcExtCfg(uint32_t ui32Fcfg1Revision)
Returns the trim value to be used for the RADCEXTCFG register in OSC_DIG.
Definition: setup.c:1157
void AUXWUCPowerCtrl(uint32_t ui32PowerMode)
Control the power to the AUX domain.
Definition: aux_wuc.c:274
static uint32_t GetTrimForRcOscLfRtuneCtuneTrim(void)
Returns the trim value to be used for the RCOSCLF_RTUNE_TRIM and the RCOSCLF_CTUNE_TRIM bit fields in...
Definition: setup.c:854
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:145
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:108
#define IOC_STD_INPUT
Definition: ioc.h:292
int32_t SignExtendVddrTrimValue(uint32_t ui32VddrTrimVal)
Sign extend the VDDR_TRIM setting (special format ranging from -10 to +21)
Definition: setup.c:750
void ThisCodeIsBuiltForCC13xxHwRev20AndLater_HaltIfViolated(void)
Verifies that curent chip is built for CC13xx HwRev 2.0 or later and never returns if violated...
Definition: chipinfo.c:169
static uint32_t GetTrimForRcOscLfIBiasTrim(uint32_t ui32Fcfg1Revision)
Returns the FCFG1 OSC_CONF_ATESTLF_RCOSCLF_IBIAS_TRIM.
Definition: setup.c:1189
#define OSC_SRC_CLK_HF
Definition: osc.h:106
static uint32_t GetTrimForXoscLfRegulatorAndCmirrwrRatio(uint32_t ui32Fcfg1Revision)
Returns XOSCLF_REGULATOR_TRIM and XOSCLF_CMIRRWR_RATIO as one packet spanning bits [5:0] in the retur...
Definition: setup.c:1209
#define OSC_XOSC_HF
Definition: osc.h:111
#define OSC_SRC_CLK_LF
Definition: osc.h:108
static uint32_t GetTrimForAmpcompTh2(void)
Returns the trim value to be used for the AMPCOMP_TH2 register in OSC_DIG.
Definition: setup.c:902
static uint32_t GetTrimForAnabypassValue1(uint32_t ccfg_ModeConfReg)
Returns the trim value to be used for the ANABYPASS_VALUE1 register in OSC_DIG.
Definition: setup.c:784
static uint32_t GetTrimForDblrLoopFilterResetVoltage(uint32_t ui32Fcfg1Revision)
Returns the trim value from FCFG1 to be used as DBLR_LOOP_FILTER_RESET_VOLTAGE setting.
Definition: setup.c:1050
static void HapiTrimDeviceColdReset(void)
Trims to be applied when coming from PIN_RESET.
Definition: setup.c:771
static uint32_t GetTrimForXoscHfFastStart(void)
Returns the trim value to be used as OSC_DIG:CTL1.XOSC_HF_FAST_START.
Definition: setup.c:1139
static uint32_t GetTrimForAdcShVbufEn(uint32_t ui32Fcfg1Revision)
Returns the trim value from FCFG1 to be used as ADC_SH_VBUF_EN setting.
Definition: setup.c:1088
#define OSC_RCOSC_LF
Definition: osc.h:112
void IOCPortConfigureSet(uint32_t ui32IOId, uint32_t ui32PortId, uint32_t ui32IOConfig)
Set the configuration of an IO port.
Definition: ioc.c:96
#define IOC_HYST_ENABLE
Definition: ioc.h:216
static uint32_t GetTrimForXoscHfCtl(uint32_t ui32Fcfg1Revision)
Returns the trim value to be used for the XOSCHFCTL register in OSC_DIG.
Definition: setup.c:1107
static uint32_t GetTrimForAdcShModeEn(uint32_t ui32Fcfg1Revision)
Returns the trim value from FCFG1 to be used as ADC_SH_MODE_EN setting.
Definition: setup.c:1069
static void SetAonRtcSubSecInc(uint32_t subSecInc)
Doing the tricky stuff needed to enter new RTCSUBSECINC value.
Definition: setup.c:348
static uint32_t GetTrimForXoscHfIbiastherm(void)
Returns the trim value to be used for the XOSC_HF_IBIASTHERM bit field in the ANABYPASS_VALUE2 regist...
Definition: setup.c:882
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
Definition: osc.c:86
static void SetupCacheModeAccordingToCcfgSetting(void)
Set correct VIMS_MODE according to CCFG setting (CACHE or GPRAM)
Definition: setup.c:135
static uint32_t GetTrimForAmpcompTh1(void)
Returns the trim value to be used for the AMPCOMP_TH1 register in OSC_DIG.
Definition: setup.c:937
void SetVddrLevel(uint32_t ccfg_ModeConfReg)
Definition: setup.c:1231
#define OSC_XOSC_LF
Definition: osc.h:113
static uint32_t GetTrimForAmpcompCtrl(uint32_t ui32Fcfg1Revision)
Returns the trim value to be used for the AMPCOMP_CTRL register in OSC_DIG.
Definition: setup.c:972
void trimDevice(void)
Performs the necessary trim of the device which is not done in boot code.
Definition: setup.c:191
static void AONWUCJtagPowerOff(void)
Request power off of the JTAG domain.
Definition: aon_wuc.h:816