CC13xx Driver Library
setup.c
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: setup.c
3 * Revised: 2016-01-07 16:01:48 +0100 (Thu, 07 Jan 2016)
4 * Revision: 45399
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  // set the RECHARGE source based upon CCFG:MODE_CONF:DCDC_RECHARGE
493  // Note: Inverse polarity
494  //
496  ((( ccfg_ModeConfReg >> CCFG_MODE_CONF_DCDC_RECHARGE_S ) & 1 ) ^ 1 );
497 
498  //
499  // set the ACTIVE source based upon CCFG:MODE_CONF:DCDC_ACTIVE
500  // Note: Inverse polarity
501  //
503  ((( ccfg_ModeConfReg >> CCFG_MODE_CONF_DCDC_ACTIVE_S ) & 1 ) ^ 1 );
504 
505  //
506  // Following sequence is required for using XOSCHF, if not included
507  // devices crashes when trying to switch to XOSCHF.
508  //
509  // Trim CAP settings. Get and set trim value for the ANABYPASS_VALUE1
510  // register
511  ui32Trim = GetTrimForAnabypassValue1( ccfg_ModeConfReg );
513 
514  // Trim RCOSC_LF. Get and set trim values for the RCOSCLF_RTUNE_TRIM and
515  // RCOSCLF_CTUNE_TRIM fields in the XOSCLF_RCOSCLF_CTRL register.
516  ui32Trim = GetTrimForRcOscLfRtuneCtuneTrim();
521  ui32Trim);
522 
523  // Trim XOSCHF IBIAS THERM. Get and set trim value for the
524  // XOSCHF IBIAS THERM bit field in the ANABYPASS_VALUE2 register. Other
525  // register bit fields are set to 0.
526  ui32Trim = GetTrimForXoscHfIbiastherm();
529 
530  // Trim AMPCOMP settings required before switch to XOSCHF
531  ui32Trim = GetTrimForAmpcompTh2();
533  ui32Trim = GetTrimForAmpcompTh1();
535  ui32Trim = GetTrimForAmpcompCtrl( ui32Fcfg1Revision );
537 
538  //
539  // Set trim for DDI_0_OSC_ADCDOUBLERNANOAMPCTL_ADC_SH_MODE_EN in accordance to FCFG1 setting
540  // This is bit[5] in the DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL register
541  // Using MASK4 write + 1 => writing to bits[7:4]
542  //
543  ui32Trim = GetTrimForAdcShModeEn( ui32Fcfg1Revision );
544  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 1 ) =
545  ( 0x20 | ( ui32Trim << 1 ));
546 
547  //
548  // Set trim for DDI_0_OSC_ADCDOUBLERNANOAMPCTL_ADC_SH_VBUF_EN in accordance to FCFG1 setting
549  // This is bit[4] in the DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL register
550  // Using MASK4 write + 1 => writing to bits[7:4]
551  //
552  ui32Trim = GetTrimForAdcShVbufEn( ui32Fcfg1Revision );
553  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 1 ) =
554  ( 0x10 | ( ui32Trim ));
555 
556  //
557  // Set trim for the PEAK_DET_ITRIM, HP_BUF_ITRIM and LP_BUF_ITRIM bit fields
558  // in the DDI0_OSC_O_XOSCHFCTL register in accordance to FCFG1 setting.
559  // Remaining register bit fields are set to their reset values of 0.
560  //
561  ui32Trim = GetTrimForXoscHfCtl(ui32Fcfg1Revision);
563 
564  //
565  // Set trim for DBLR_LOOP_FILTER_RESET_VOLTAGE in accordance to FCFG1 setting
566  // (This is bits [18:17] in DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL)
567  // (Using MASK4 write + 4 => writing to bits[19:16] => (4*4))
568  // (Assuming: DDI_0_OSC_ADCDOUBLERNANOAMPCTL_DBLR_LOOP_FILTER_RESET_VOLTAGE_S = 17 and
569  // that DDI_0_OSC_ADCDOUBLERNANOAMPCTL_DBLR_LOOP_FILTER_RESET_VOLTAGE_M = 0x00060000)
570  //
571  ui32Trim = GetTrimForDblrLoopFilterResetVoltage( ui32Fcfg1Revision );
572  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 4 ) =
573  ( 0x60 | ( ui32Trim << 1 ));
574 
575  //
576  // Update DDI_0_OSC_ATESTCTL_ATESTLF_RCOSCLF_IBIAS_TRIM with data from
578  // This is DDI_0_OSC_O_ATESTCTL bit[7]
579  // ( DDI_0_OSC_O_ATESTCTL is currently hidden (but=0x00000020))
580  // Using MASK4 write + 1 => writing to bits[7:4]
581  //
582  ui32Trim = GetTrimForRcOscLfIBiasTrim( ui32Fcfg1Revision );
583  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( 0x00000020 * 2 ) + 1 ) =
584  ( 0x80 | ( ui32Trim << 3 ));
585 
586  //
589  // This can be simplified since the registers are packed together in the same
590  // order both in FCFG1 and in the HW register.
591  // This spans DDI_0_OSC_O_LFOSCCTL bits[23:18]
592  // Using MASK8 write + 4 => writing to bits[23:16]
593  //
594  ui32Trim = GetTrimForXoscLfRegulatorAndCmirrwrRatio( ui32Fcfg1Revision );
595  HWREGH( AUX_DDI0_OSC_BASE + DDI_O_MASK8B + ( DDI_0_OSC_O_LFOSCCTL * 2 ) + 4 ) =
596  ( 0xFC00 | ( ui32Trim << 2 ));
597 
598  //
599  // Set trim the HPM_IBIAS_WAIT_CNT, LPM_IBIAS_WAIT_CNT and IDAC_STEP bit
600  // fields in the DDI0_OSC_O_RADCEXTCFG register in accordance to FCFG1 setting.
601  // Remaining register bit fields are set to their reset values of 0.
602  //
603  ui32Trim = GetTrimForRadcExtCfg(ui32Fcfg1Revision);
605 
606  // Setting FORCE_KICKSTART_EN (ref. CC26_V1_BUG00261). Should also be done for PG2
607  // (This is bit 22 in DDI_0_OSC_O_CTL0)
609 
610  //
611  // Examin the XOSC_FREQ field to select 0x1=HPOSC, 0x2=48MHz XOSC, 0x3=24MHz XOSC
612  //
613  switch (( ccfg_ModeConfReg & CCFG_MODE_CONF_XOSC_FREQ_M ) >> CCFG_MODE_CONF_XOSC_FREQ_S ) {
614  case 2 :
615  // XOSC source is a 48 MHz xtal
616  // Do nothing (since this is the reset setting)
617  break;
618  case 1 :
619  // XOSC source is HPOSC (trim the HPOSC if this is a chip with HPOSC, otherwise skip trimming and default to 24 MHz XOSC)
620 
621  fcfg1OscConf = HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF );
622 
623  if (( fcfg1OscConf & FCFG1_OSC_CONF_HPOSC_OPTION ) == 0 ) {
624  // This is a HPOSC chip, apply HPOSC settings
625  // Set bit DDI_0_OSC_CTL0_HPOSC_MODE_EN (this is bit 14 in DDI_0_OSC_O_CTL0)
627 
635 
648  break;
649  }
650  // Not a HPOSC chip - fall through to default
651  default :
652  // XOSC source is a 24 MHz xtal (default)
653  // Set bit DDI_0_OSC_CTL0_XTAL_IS_24M (this is bit 31 in DDI_0_OSC_O_CTL0)
655  break;
656  }
657 
658  // Clear DDI_0_OSC_CTL0_CLK_LOSS_EN (ClockLossEventEnable()). This is bit 9 in DDI_0_OSC_O_CTL0.
659  // This is typically already 0 except on Lizard where it is set in ROM-boot
661 
662  // Setting DDI_0_OSC_CTL1_XOSC_HF_FAST_START according to value found in FCFG1
663  ui32Trim = GetTrimForXoscHfFastStart();
664  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_CTL1 * 2 )) = ( 0x30 | ui32Trim );
665 
666  //
667  // setup the LF clock based upon CCFG:MODE_CONF:SCLK_LF_OPTION
668  //
669  switch (( ccfg_ModeConfReg & CCFG_MODE_CONF_SCLK_LF_OPTION_M ) >> CCFG_MODE_CONF_SCLK_LF_OPTION_S ) {
670  case 0 : // XOSC_HF_DLF (XOSCHF/1536) -> SCLK_LF (=31250Hz)
672  SetAonRtcSubSecInc( 0x8637BD );
673  break;
674  case 1 : // EXTERNAL signal -> SCLK_LF (frequency=2^38/CCFG_EXT_LF_CLK_RTC_INCREMENT)
675  // Set SCLK_LF to use the same source as SCLK_HF
676  // Can be simplified a bit since possible return values for HF matches LF settings
677  currentHfClock = OSCClockSourceGet( OSC_SRC_CLK_HF );
678  OSCClockSourceSet( OSC_SRC_CLK_LF, currentHfClock );
679  while( OSCClockSourceGet( OSC_SRC_CLK_LF ) != currentHfClock ) {
680  // Wait until switched
681  }
682  ccfgExtLfClk = HWREG( CCFG_BASE + CCFG_O_EXT_LF_CLK );
686  IOC_STD_INPUT | IOC_HYST_ENABLE ); // Route external clock to AON IOC w/hysteresis
687  // Set XOSC_LF in bypass mode to allow external 32k clock
689  // Fall through to set XOSC_LF as SCLK_LF source
690  case 2 : // XOSC_LF -> SLCK_LF (32768 Hz)
692  break;
693  default : // (=3) RCOSC_LF
695  break;
696  }
697 
698  //
699  // Update ADI_4_AUX_ADCREF1_VTRIM with value from FCFG1
700  //
701  HWREGB( AUX_ADI4_BASE + ADI_4_AUX_O_ADCREF1 ) =
706 
707  //
708  // Set ADI_4_AUX:ADC0.SMPL_CYCLE_EXP to it's default minimum value (=3)
709  // (Note: Using MASK8B requires that the bits to be modified must be within the same
710  // byte boundary which is the case for the ADI_4_AUX_ADC0_SMPL_CYCLE_EXP field)
711  //
712  HWREGH( AUX_ADI4_BASE + ADI_O_MASK8B + ( ADI_4_AUX_O_ADC0 * 2 )) =
714 
715  //
716  // Sync with AON
717  //
718  SysCtrlAonSync();
719 
720  //
721  // Allow AUX to power down
722  //
724 
725  //
726  // Leaving on AUX and clock for AUX_DDI0_OSC on but turn off clock for AUX_ADI4
727  //
729 
730  // Disable EFUSE clock
732 }
733 
734 //*****************************************************************************
735 //
739 //
740 //*****************************************************************************
741 int32_t
742 SignExtendVddrTrimValue( uint32_t ui32VddrTrimVal )
743 {
744  //
745  // The VDDR trim value is 5 bits representing the range from -10 to +21
746  // (where -10=0x16, -1=0x1F, 0=0x00, 1=0x01 and +21=0x15)
747  //
748  int32_t i32SignedVddrVal = ui32VddrTrimVal;
749  if ( i32SignedVddrVal > 0x15 ) {
750  i32SignedVddrVal -= 0x20;
751  }
752  return ( i32SignedVddrVal );
753 }
754 
755 //*****************************************************************************
756 //
760 //
761 //*****************************************************************************
762 static void
764 {
765  //
766  // Currently no specific trim for Cold Reset
767  //
768 }
769 
770 //*****************************************************************************
771 //
773 //
774 //*****************************************************************************
775 static uint32_t
776 GetTrimForAnabypassValue1( uint32_t ccfg_ModeConfReg )
777 {
778  uint32_t ui32Fcfg1Value ;
779  uint32_t ui32XoscHfRow ;
780  uint32_t ui32XoscHfCol ;
781  int32_t i32CustomerDeltaAdjust ;
782  uint32_t ui32TrimValue ;
783 
784  // Use device specific trim values located in factory configuration
785  // area for the XOSC_HF_COLUMN_Q12 and XOSC_HF_ROW_Q12 bit fields in
786  // the ANABYPASS_VALUE1 register. Value for the other bit fields
787  // are set to 0.
788 
789  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_OSC_TOP);
790  ui32XoscHfRow = (( ui32Fcfg1Value &
793  ui32XoscHfCol = (( ui32Fcfg1Value &
796 
797  i32CustomerDeltaAdjust = 0;
798  if (( ccfg_ModeConfReg & CCFG_MODE_CONF_XOSC_CAP_MOD ) == 0 ) {
799  // XOSC_CAP_MOD = 0 means: CAP_ARRAY_DELTA is in use -> Apply compensation
800  // XOSC_CAPARRAY_DELTA is located in bit[15:8] of ccfg_ModeConfReg
801  // Note: HW_REV_DEPENDENT_IMPLEMENTATION. Field width is not given by
802  // a define and sign extension must therefore be hardcoded.
803  // ( A small test program is created verifying the code lines below:
804  // Ref.: ..\test\small_standalone_test_programs\CapArrayDeltaAdjust_test.c)
805  i32CustomerDeltaAdjust = ((int32_t)ccfg_ModeConfReg << 16 ) >> 24;
806 
807  while ( i32CustomerDeltaAdjust < 0 ) {
808  ui32XoscHfCol >>= 1; // COL 1 step down
809  if ( ui32XoscHfCol == 0 ) { // if COL below minimum
810  ui32XoscHfCol = 0xFFFF; // Set COL to maximum
811  ui32XoscHfRow >>= 1; // ROW 1 step down
812  if ( ui32XoscHfRow == 0 ) { // if ROW below minimum
813  ui32XoscHfRow = 1; // Set both ROW and COL
814  ui32XoscHfCol = 1; // to minimum
815  }
816  }
817  i32CustomerDeltaAdjust++;
818  }
819  while ( i32CustomerDeltaAdjust > 0 ) {
820  ui32XoscHfCol = ( ui32XoscHfCol << 1 ) | 1; // COL 1 step up
821  if ( ui32XoscHfCol > 0xFFFF ) { // if COL above maximum
822  ui32XoscHfCol = 1; // Set COL to minimum
823  ui32XoscHfRow = ( ui32XoscHfRow << 1 ) | 1; // ROW 1 step up
824  if ( ui32XoscHfRow > 0xF ) { // if ROW above maximum
825  ui32XoscHfRow = 0xF; // Set both ROW and COL
826  ui32XoscHfCol = 0xFFFF; // to maximum
827  }
828  }
829  i32CustomerDeltaAdjust--;
830  }
831  }
832 
833  ui32TrimValue = (( ui32XoscHfRow << DDI_0_OSC_ANABYPASSVAL1_XOSC_HF_ROW_Q12_S ) |
834  ( ui32XoscHfCol << DDI_0_OSC_ANABYPASSVAL1_XOSC_HF_COLUMN_Q12_S ) );
835 
836  return (ui32TrimValue);
837 }
838 
839 //*****************************************************************************
840 //
843 //
844 //*****************************************************************************
845 static uint32_t
847 {
848  uint32_t ui32TrimValue;
849 
850  // Use device specific trim values located in factory configuration
851  // area
852  ui32TrimValue =
857 
858  ui32TrimValue |=
863 
864  return(ui32TrimValue);
865 }
866 
867 //*****************************************************************************
868 //
871 //
872 //*****************************************************************************
873 static uint32_t
875 {
876  uint32_t ui32TrimValue;
877 
878  // Use device specific trim value located in factory configuration
879  // area
880  ui32TrimValue =
884 
885  return(ui32TrimValue);
886 }
887 
888 //*****************************************************************************
889 //
891 //
892 //*****************************************************************************
893 static uint32_t
895 {
896  uint32_t ui32TrimValue;
897  uint32_t ui32Fcfg1Value;
898 
899  // Use device specific trim value located in factory configuration
900  // area. All defined register bit fields have corresponding trim
901  // value in the factory configuration area
902  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_AMPCOMP_TH2);
903  ui32TrimValue = ((ui32Fcfg1Value &
907  ui32TrimValue |= (((ui32Fcfg1Value &
911  ui32TrimValue |= (((ui32Fcfg1Value &
915  ui32TrimValue |= (((ui32Fcfg1Value &
919 
920  return(ui32TrimValue);
921 }
922 
923 //*****************************************************************************
924 //
926 //
927 //*****************************************************************************
928 static uint32_t
930 {
931  uint32_t ui32TrimValue;
932  uint32_t ui32Fcfg1Value;
933 
934  // Use device specific trim values located in factory configuration
935  // area. All defined register bit fields have a corresponding trim
936  // value in the factory configuration area
937  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_AMPCOMP_TH1);
938  ui32TrimValue = (((ui32Fcfg1Value &
942  ui32TrimValue |= (((ui32Fcfg1Value &
946  ui32TrimValue |= (((ui32Fcfg1Value &
950  ui32TrimValue |= (((ui32Fcfg1Value &
954 
955  return(ui32TrimValue);
956 }
957 
958 //*****************************************************************************
959 //
961 //
962 //*****************************************************************************
963 static uint32_t
964 GetTrimForAmpcompCtrl( uint32_t ui32Fcfg1Revision )
965 {
966  uint32_t ui32TrimValue ;
967  uint32_t ui32Fcfg1Value ;
968  uint32_t ibiasOffset ;
969  uint32_t ibiasInit ;
970  uint32_t modeConf1 ;
971  int32_t deltaAdjust ;
972 
973  // Use device specific trim values located in factory configuration
974  // area. Register bit fields without trim values in the factory
975  // configuration area will be set to the value of 0.
976  ui32Fcfg1Value = HWREG( FCFG1_BASE + FCFG1_O_AMPCOMP_CTRL1 );
977 
978  ibiasOffset = ( ui32Fcfg1Value &
981  ibiasInit = ( ui32Fcfg1Value &
984 
986  // Adjust with DELTA_IBIAS_OFFSET and DELTA_IBIAS_INIT from CCFG
987  modeConf1 = HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 );
988 
989  // Both fields are signed 4-bit values. This is an assumption when doing the sign extension.
990  deltaAdjust = ((int32_t)modeConf1 << ( 32 - CCFG_MODE_CONF_1_DELTA_IBIAS_OFFSET_S - 4 )) >> 28;
991  deltaAdjust += (int32_t)ibiasOffset;
992  if ( deltaAdjust < 0 ) {
993  deltaAdjust = 0;
994  }
997  }
998  ibiasOffset = (uint32_t)deltaAdjust;
999 
1000  deltaAdjust = ((int32_t)modeConf1 << ( 32 - CCFG_MODE_CONF_1_DELTA_IBIAS_INIT_S - 4 )) >> 28;
1001  deltaAdjust += (int32_t)ibiasInit;
1002  if ( deltaAdjust < 0 ) {
1003  deltaAdjust = 0;
1004  }
1007  }
1008  ibiasInit = (uint32_t)deltaAdjust;
1009  }
1010  ui32TrimValue = ( ibiasOffset << DDI_0_OSC_AMPCOMPCTL_IBIAS_OFFSET_S ) |
1011  ( ibiasInit << DDI_0_OSC_AMPCOMPCTL_IBIAS_INIT_S ) ;
1012 
1013  ui32TrimValue |= (((ui32Fcfg1Value &
1017  ui32TrimValue |= (((ui32Fcfg1Value &
1021  ui32TrimValue |= (((ui32Fcfg1Value &
1025 
1026  if ( ui32Fcfg1Revision >= 0x00000022 ) {
1027  ui32TrimValue |= ((( ui32Fcfg1Value &
1031  }
1032 
1033  return(ui32TrimValue);
1034 }
1035 
1036 //*****************************************************************************
1037 //
1039 //
1040 //*****************************************************************************
1041 static uint32_t
1042 GetTrimForDblrLoopFilterResetVoltage( uint32_t ui32Fcfg1Revision )
1043 {
1044  uint32_t dblrLoopFilterResetVoltageValue = 0; // Reset value
1045 
1046  if ( ui32Fcfg1Revision >= 0x00000020 ) {
1047  dblrLoopFilterResetVoltageValue = ( HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 ) &
1050  }
1051 
1052  return ( dblrLoopFilterResetVoltageValue );
1053 }
1054 
1055 //*****************************************************************************
1056 //
1058 //
1059 //*****************************************************************************
1060 static uint32_t
1061 GetTrimForAdcShModeEn( uint32_t ui32Fcfg1Revision )
1062 {
1063  uint32_t getTrimForAdcShModeEnValue = 1; // Recommended default setting
1064 
1065  if ( ui32Fcfg1Revision >= 0x00000022 ) {
1066  getTrimForAdcShModeEnValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1069  }
1070 
1071  return ( getTrimForAdcShModeEnValue );
1072 }
1073 
1074 //*****************************************************************************
1075 //
1077 //
1078 //*****************************************************************************
1079 static uint32_t
1080 GetTrimForAdcShVbufEn( uint32_t ui32Fcfg1Revision )
1081 {
1082  uint32_t getTrimForAdcShVbufEnValue = 1; // Recommended default setting
1083 
1084  if ( ui32Fcfg1Revision >= 0x00000022 ) {
1085  getTrimForAdcShVbufEnValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1088  }
1089 
1090  return ( getTrimForAdcShVbufEnValue );
1091 }
1092 
1093 //*****************************************************************************
1094 //
1096 //
1097 //*****************************************************************************
1098 static uint32_t
1099 GetTrimForXoscHfCtl( uint32_t ui32Fcfg1Revision )
1100 {
1101  uint32_t getTrimForXoschfCtlValue = 0; // Recommended default setting
1102  uint32_t fcfg1Data;
1103 
1104  if ( ui32Fcfg1Revision >= 0x00000020 ) {
1105  fcfg1Data = HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 );
1106  getTrimForXoschfCtlValue =
1107  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_PEAK_DET_ITRIM_M ) >>
1110 
1111  getTrimForXoschfCtlValue |=
1112  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_HP_BUF_ITRIM_M ) >>
1115 
1116  getTrimForXoschfCtlValue |=
1117  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_LP_BUF_ITRIM_M ) >>
1120  }
1121 
1122  return ( getTrimForXoschfCtlValue );
1123 }
1124 
1125 //*****************************************************************************
1126 //
1128 //
1129 //*****************************************************************************
1130 static uint32_t
1132 {
1133  uint32_t ui32XoscHfFastStartValue ;
1134 
1135  // Get value from FCFG1
1136  ui32XoscHfFastStartValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1139 
1140  return ( ui32XoscHfFastStartValue );
1141 }
1142 
1143 //*****************************************************************************
1144 //
1146 //
1147 //*****************************************************************************
1148 static uint32_t
1149 GetTrimForRadcExtCfg( uint32_t ui32Fcfg1Revision )
1150 {
1151  uint32_t getTrimForRadcExtCfgValue = 0x403F8000; // Recommended default setting
1152  uint32_t fcfg1Data;
1153 
1154  if ( ui32Fcfg1Revision >= 0x00000020 ) {
1155  fcfg1Data = HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 );
1156  getTrimForRadcExtCfgValue =
1157  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_HPM_IBIAS_WAIT_CNT_M ) >>
1160 
1161  getTrimForRadcExtCfgValue |=
1162  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_LPM_IBIAS_WAIT_CNT_M ) >>
1165 
1166  getTrimForRadcExtCfgValue |=
1167  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_IDAC_STEP_M ) >>
1170  }
1171 
1172  return ( getTrimForRadcExtCfgValue );
1173 }
1174 
1175 //*****************************************************************************
1176 //
1178 //
1179 //*****************************************************************************
1180 static uint32_t
1181 GetTrimForRcOscLfIBiasTrim( uint32_t ui32Fcfg1Revision )
1182 {
1183  uint32_t trimForRcOscLfIBiasTrimValue = 0; // Default value
1184 
1185  if ( ui32Fcfg1Revision >= 0x00000022 ) {
1186  trimForRcOscLfIBiasTrimValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1189  }
1190 
1191  return ( trimForRcOscLfIBiasTrimValue );
1192 }
1193 
1194 //*****************************************************************************
1195 //
1198 //
1199 //*****************************************************************************
1200 static uint32_t
1201 GetTrimForXoscLfRegulatorAndCmirrwrRatio( uint32_t ui32Fcfg1Revision )
1202 {
1203  uint32_t trimForXoscLfRegulatorAndCmirrwrRatioValue = 0; // Default value for both fields
1204 
1205  if ( ui32Fcfg1Revision >= 0x00000022 ) {
1206  trimForXoscLfRegulatorAndCmirrwrRatioValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
1210  }
1211 
1212  return ( trimForXoscLfRegulatorAndCmirrwrRatioValue );
1213 }
1214 
1215 
1216 //*****************************************************************************
1217 //
1218 // SetVddrLevel()
1219 // Set VDDR boost mode (by setting VDDR_TRIM to FCFG1..VDDR_TRIM_HH and setting VDDS_BOD to max)
1220 //
1221 //*****************************************************************************
1222 void
1223 SetVddrLevel( uint32_t ccfg_ModeConfReg )
1224 {
1225  uint32_t newTrimRaw ;
1226  int32_t targetTrim ;
1227  int32_t currentTrim ;
1228  int32_t deltaTrim ;
1229 
1230 // if ( ccfg_ModeConfReg & CCFG_MODE_CONF_VDDS_BOD_LEVEL ) {
1231  //
1232  // VDDS_BOD_LEVEL = 1 means that boost mode is selected
1233  // - Step up VDDR_TRIM to FCFG1..VDDR_TRIM_HH
1234  //
1235  newTrimRaw = (( HWREG( FCFG1_BASE + FCFG1_O_VOLT_TRIM ) &
1238 // } else {
1239 // //
1240 // // VDDS_BOD_LEVEL = 0
1241 // // - Step up VDDR_TRIM to FCFG1..VDDR_TRIM_H
1242 // //
1243 // newTrimRaw = (( HWREG( FCFG1_BASE + FCFG1_O_VOLT_TRIM ) &
1246 // }
1247  targetTrim = SignExtendVddrTrimValue( newTrimRaw );
1248  currentTrim = SignExtendVddrTrimValue((
1249  HWREGB( ADI3_BASE + ADI_3_REFSYS_O_DCDCCTL0 ) &
1252 
1253  if ( currentTrim != targetTrim ) {
1254  // Disable VDDR BOD
1256 
1257  while ( currentTrim != targetTrim ) {
1258  deltaTrim = targetTrim - currentTrim;
1259  if ( deltaTrim > 2 ) deltaTrim = 2;
1260  if ( deltaTrim < -2 ) deltaTrim = -2;
1261  currentTrim += deltaTrim;
1262 
1263  HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ); // Wait one SCLK_LF period
1264 
1265  HWREGH( ADI3_BASE + ADI_O_MASK8B + ( ADI_3_REFSYS_O_DCDCCTL0 * 2 )) =
1266  ( ADI_3_REFSYS_DCDCCTL0_VDDR_TRIM_M << 8 ) | (( currentTrim <<
1269 
1270  HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ) = 1; // Force SCLK_LF period wait on next read
1271  }
1272 
1273  HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ); // Wait one SCLK_LF period
1274  HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ) = 1; // Force SCLK_LF period wait on next read
1275  HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ); // Wait one more SCLK_LF period before re-enabling VDDR BOD
1277  HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ); // And finally wait for VDDR_LOSS_EN setting to propagate
1278  }
1279 }
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:1149
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:846
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:742
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:1181
#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:1201
#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:894
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:776
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:1042
static void HapiTrimDeviceColdReset(void)
Trims to be applied when coming from PIN_RESET.
Definition: setup.c:763
static uint32_t GetTrimForXoscHfFastStart(void)
Returns the trim value to be used as OSC_DIG:CTL1.XOSC_HF_FAST_START.
Definition: setup.c:1131
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:1080
#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:1099
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:1061
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:874
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:929
void SetVddrLevel(uint32_t ccfg_ModeConfReg)
Definition: setup.c:1223
#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:964
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