1 /******************************************************************************
2 * Filename: setup_rom.h
3 *
4 * Description: Prototypes and defines for the setup API.
5 *
6 * Copyright (c) 2015 - 2022, Texas Instruments Incorporated
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * 1) Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * 2) Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 *
35 ******************************************************************************/
36
37 //*****************************************************************************
38 //
39 //! \addtogroup system_control_group
40 //! @{
41 //! \addtogroup setup_rom_api
42 //! @{
43 //
44 //*****************************************************************************
45
46 #ifndef __SETUP_ROM_H__
47 #define __SETUP_ROM_H__
48
49 //*****************************************************************************
50 //
51 // If building with a C++ compiler, make all of the definitions in this header
52 // have a C binding.
53 //
54 //*****************************************************************************
55 #ifdef __cplusplus
56 extern "C"
57 {
58 #endif
59
60 // Hardware headers
61 #include "../inc/hw_types.h"
62 // Driverlib headers
63 // - None needed
64
65 //*****************************************************************************
66 //
67 // Support for DriverLib in ROM:
68 // This section renames all functions that are not "static inline", so that
69 // calling these functions will default to implementation in flash. At the end
70 // of this file a second renaming will change the defaults to implementation in
71 // ROM for available functions.
72 //
73 // To force use of the implementation in flash, e.g. for debugging:
74 // - Globally: Define DRIVERLIB_NOROM at project level
75 // - Per function: Use prefix "NOROM_" when calling the function
76 //
77 //*****************************************************************************
78 #if !defined(DOXYGEN)
79 #define SetupAfterColdResetWakeupFromShutDownCfg1 NOROM_SetupAfterColdResetWakeupFromShutDownCfg1
80 #define SetupAfterColdResetWakeupFromShutDownCfg2 NOROM_SetupAfterColdResetWakeupFromShutDownCfg2
81 #define SetupAfterColdResetWakeupFromShutDownCfg3 NOROM_SetupAfterColdResetWakeupFromShutDownCfg3
82 #define SetupGetTrimForAdcShModeEn NOROM_SetupGetTrimForAdcShModeEn
83 #define SetupGetTrimForAdcShVbufEn NOROM_SetupGetTrimForAdcShVbufEn
84 #define SetupGetTrimForAmpcompCtrl NOROM_SetupGetTrimForAmpcompCtrl
85 #define SetupGetTrimForAmpcompTh1 NOROM_SetupGetTrimForAmpcompTh1
86 #define SetupGetTrimForAmpcompTh2 NOROM_SetupGetTrimForAmpcompTh2
87 #define SetupGetTrimForAnabypassValue1 NOROM_SetupGetTrimForAnabypassValue1
88 #define SetupGetTrimForDblrLoopFilterResetVoltage NOROM_SetupGetTrimForDblrLoopFilterResetVoltage
89 #define SetupGetTrimForRadcExtCfg NOROM_SetupGetTrimForRadcExtCfg
90 #define SetupGetTrimForRcOscLfIBiasTrim NOROM_SetupGetTrimForRcOscLfIBiasTrim
91 #define SetupGetTrimForRcOscLfRtuneCtuneTrim NOROM_SetupGetTrimForRcOscLfRtuneCtuneTrim
92 #define SetupGetTrimForXoscHfCtl NOROM_SetupGetTrimForXoscHfCtl
93 #define SetupGetTrimForXoscHfFastStart NOROM_SetupGetTrimForXoscHfFastStart
94 #define SetupGetTrimForXoscHfIbiastherm NOROM_SetupGetTrimForXoscHfIbiastherm
95 #define SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio NOROM_SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio
96 #define SetupSetCacheModeAccordingToCcfgSetting NOROM_SetupSetCacheModeAccordingToCcfgSetting
97 #define SetupSetAonRtcSubSecInc NOROM_SetupSetAonRtcSubSecInc
98 #define SetupStepVddrTrimTo NOROM_SetupStepVddrTrimTo
99 #endif
100
101 //*****************************************************************************
102 //
103 //! \brief First part of configuration required after cold reset and when waking up from shutdown.
104 //!
105 //! Configures the following based on settings in CCFG (Customer Configuration area:
106 //! - Boost mode for CC13xx devices
107 //! - Minimal VDDR voltage threshold used during sleep mode
108 //! - DCDC functionality:
109 //! - Selects if DCDC or GLDO regulator will be used for VDDR in active mode
110 //! - Selects if DCDC or GLDO regulator will be used for VDDR in sleep mode
111 //!
112 //! In addition the battery monitor low limit for internal regulator mode is set
113 //! to a hard coded value.
114 //!
115 //! \param ccfg_ModeConfReg is the value of the CCFG_O_MODE_CONF_1 register
116 //!
117 //! \return None
118 //
119 //*****************************************************************************
120 extern void SetupAfterColdResetWakeupFromShutDownCfg1( uint32_t ccfg_ModeConfReg );
121
122 //*****************************************************************************
123 //
124 //! \brief Second part of configuration required after cold reset and when waking up from shutdown.
125 //!
126 //! Configures and trims functionalites required for use of XOSC_HF.
127 //! The configurations and trimmings are based on settings in FCFG1 (Factory
128 //! Configuration area) and partly on \c ccfg_ModeConfReg.
129 //!
130 //! \param ui32Fcfg1Revision is the value of the FCFG1_O_FCFG1_REVISION register
131 //! \param ccfg_ModeConfReg is the value of the CCFG_O_MODE_CONF_1 register
132 //!
133 //! \return None
134 //
135 //*****************************************************************************
136 extern void SetupAfterColdResetWakeupFromShutDownCfg2( uint32_t ui32Fcfg1Revision, uint32_t ccfg_ModeConfReg );
137
138 //*****************************************************************************
139 //
140 //! \brief Third part of configuration required after cold reset and when waking up from shutdown.
141 //!
142 //! Configures the following:
143 //! - XOSC source selection based on \c ccfg_ModeConfReg. If HPOSC is selected on a
144 //! HPOSC device the oscillator is configured based on settings in FCFG1 (Factory
145 //! Configuration area).
146 //! - Clock loss detection is disabled. Will be re-enabled by TIRTOS power driver.
147 //! - Duration of the XOSC_HF fast startup mode based on FCFG1 setting.
148 //! - SCLK_LF based on \c ccfg_ModeConfReg.
149 //! - Output voltage of ADC fixed reference based on FCFG1 setting.
150 //!
151 //! \param ccfg_ModeConfReg is the value of the CCFG_O_MODE_CONF_1 register
152 //!
153 //! \return None
154 //
155 //*****************************************************************************
156 extern void SetupAfterColdResetWakeupFromShutDownCfg3( uint32_t ccfg_ModeConfReg );
157
158 //*****************************************************************************
159 //
160 //! \brief Returns the trim value from FCFG1 to be used as ADC_SH_MODE_EN setting.
161 //!
162 //! \param ui32Fcfg1Revision is the value of the FCFG1_O_FCFG1_REVISION register
163 //!
164 //! \return Returns the trim value from FCFG1.
165 //
166 //*****************************************************************************
167 extern uint32_t SetupGetTrimForAdcShModeEn( uint32_t ui32Fcfg1Revision );
168
169 //*****************************************************************************
170 //
171 //! \brief Returns the trim value from FCFG1 to be used as ADC_SH_VBUF_EN setting.
172 //!
173 //! \param ui32Fcfg1Revision is the value of the FCFG1_O_FCFG1_REVISION register
174 //!
175 //! \return Returns the trim value from FCFG1.
176 //
177 //*****************************************************************************
178 extern uint32_t SetupGetTrimForAdcShVbufEn( uint32_t ui32Fcfg1Revision );
179
180 //*****************************************************************************
181 //
182 //! \brief Returns the trim value to be used for the AMPCOMP_CTRL register in OSC_DIG.
183 //!
184 //! \param ui32Fcfg1Revision is the value of the FCFG1_O_FCFG1_REVISION register
185 //!
186 //! \return Returns the trim value.
187 //
188 //*****************************************************************************
189 extern uint32_t SetupGetTrimForAmpcompCtrl( uint32_t ui32Fcfg1Revision );
190
191 //*****************************************************************************
192 //
193 //! \brief Returns the trim value to be used for the AMPCOMP_TH1 register in OSC_DIG.
194 //!
195 //! \return Returns the trim value.
196 //
197 //*****************************************************************************
198 extern uint32_t SetupGetTrimForAmpcompTh1( void );
199
200 //*****************************************************************************
201 //
202 //! \brief Returns the trim value to be used for the AMPCOMP_TH2 register in OSC_DIG.
203 //!
204 //! \return Returns the trim value.
205 //
206 //*****************************************************************************
207 extern uint32_t SetupGetTrimForAmpcompTh2( void );
208
209 //*****************************************************************************
210 //
211 //! \brief Returns the trim value to be used for the ANABYPASS_VALUE1 register in OSC_DIG.
212 //!
213 //! \param ccfg_ModeConfReg is the value of the CCFG_O_MODE_CONF_1 register
214 //!
215 //! \return Returns the trim value.
216 //
217 //*****************************************************************************
218 extern uint32_t SetupGetTrimForAnabypassValue1( uint32_t ccfg_ModeConfReg );
219
220 //*****************************************************************************
221 //
222 //! \brief Returns the trim value from FCFG1 to be used as DBLR_LOOP_FILTER_RESET_VOLTAGE setting.
223 //!
224 //! \param ui32Fcfg1Revision is the value of the FCFG1_O_FCFG1_REVISION register
225 //!
226 //! \return Returns the trim value from FCFG1.
227 //
228 //*****************************************************************************
229 extern uint32_t SetupGetTrimForDblrLoopFilterResetVoltage( uint32_t ui32Fcfg1Revision );
230
231 //*****************************************************************************
232 //
233 //! \brief Returns the trim value to be used for the RADCEXTCFG register in OSC_DIG.
234 //!
235 //! \param ui32Fcfg1Revision is the value of the FCFG1_O_FCFG1_REVISION register
236 //!
237 //! \return Returns the trim value.
238 //
239 //*****************************************************************************
240 extern uint32_t SetupGetTrimForRadcExtCfg( uint32_t ui32Fcfg1Revision );
241
242 //*****************************************************************************
243 //
244 //! \brief Returns the FCFG1 OSC_CONF_ATESTLF_RCOSCLF_IBIAS_TRIM.
245 //!
246 //! \param ui32Fcfg1Revision is the value of the FCFG1_O_FCFG1_REVISION register
247 //!
248 //! \return Returns the trim value from FCFG1.
249 //
250 //*****************************************************************************
251 extern uint32_t SetupGetTrimForRcOscLfIBiasTrim( uint32_t ui32Fcfg1Revision );
252
253 //*****************************************************************************
254 //
255 //! \brief Returns the trim value to be used for the RCOSCLF_RTUNE_TRIM and the
256 //! RCOSCLF_CTUNE_TRIM bit fields in the XOSCLF_RCOSCLF_CTRL register in OSC_DIG.
257 //!
258 //! \return Returns the trim value.
259 //
260 //*****************************************************************************
261 extern uint32_t SetupGetTrimForRcOscLfRtuneCtuneTrim( void );
262
263 //*****************************************************************************
264 //
265 //! \brief Returns the trim value to be used for the XOSCHFCTL register in OSC_DIG.
266 //!
267 //! \param ui32Fcfg1Revision is the value of the FCFG1_O_FCFG1_REVISION register
268 //!
269 //! \return Returns the trim value.
270 //
271 //*****************************************************************************
272 extern uint32_t SetupGetTrimForXoscHfCtl( uint32_t ui32Fcfg1Revision );
273
274 //*****************************************************************************
275 //
276 //! \brief Returns the trim value to be used as OSC_DIG:CTL1.XOSC_HF_FAST_START.
277 //!
278 //! \return Returns the trim value.
279 //
280 //*****************************************************************************
281 extern uint32_t SetupGetTrimForXoscHfFastStart( void );
282
283 //*****************************************************************************
284 //
285 //! \brief Returns the trim value to be used for the XOSC_HF_IBIASTHERM bit field in
286 //! the ANABYPASS_VALUE2 register in OSC_DIG.
287 //!
288 //! \return Returns the trim value.
289 //
290 //*****************************************************************************
291 extern uint32_t SetupGetTrimForXoscHfIbiastherm( void );
292
293 //*****************************************************************************
294 //
295 //! \brief Returns XOSCLF_REGULATOR_TRIM and XOSCLF_CMIRRWR_RATIO as one packet
296 //! spanning bits [5:0] in the returned value.
297 //!
298 //! \param ui32Fcfg1Revision is the value of the FCFG1_O_FCFG1_REVISION register
299 //!
300 //! \return Returns XOSCLF_REGULATOR_TRIM and XOSCLF_CMIRRWR_RATIO as one packet.
301 //
302 //*****************************************************************************
303 extern uint32_t SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio( uint32_t ui32Fcfg1Revision );
304
305 //*****************************************************************************
306 //
307 //! \brief Sign extend the VDDR_TRIM setting (special format ranging from -10 to +21)
308 //!
309 //! \param ui32VddrTrimVal
310 //!
311 //! \return Returns Sign extended VDDR_TRIM setting.
312 //
313 //*****************************************************************************
314 __STATIC_INLINE int32_t
SetupSignExtendVddrTrimValue(uint32_t ui32VddrTrimVal)315 SetupSignExtendVddrTrimValue( uint32_t ui32VddrTrimVal )
316 {
317 // The VDDR trim value is 5 bits representing the range from -10 to +21
318 // (where -10=0x16, -1=0x1F, 0=0x00, 1=0x01 and +21=0x15)
319 int32_t i32SignedVddrVal = ui32VddrTrimVal;
320 if ( i32SignedVddrVal > 0x15 ) {
321 i32SignedVddrVal -= 0x20;
322 }
323 return ( i32SignedVddrVal );
324 }
325
326 //*****************************************************************************
327 //
328 //! \brief Set correct VIMS_MODE according to CCFG setting (CACHE or GPRAM)
329 //!
330 //! \return None
331 //
332 //*****************************************************************************
333 extern void SetupSetCacheModeAccordingToCcfgSetting( void );
334
335 //*****************************************************************************
336 //
337 //! \brief Doing the tricky stuff needed to enter new RTCSUBSECINC value
338 //!
339 //! \param subSecInc
340 //!
341 //! \return None
342 //
343 //*****************************************************************************
344 extern void SetupSetAonRtcSubSecInc( uint32_t subSecInc );
345
346
347 //*****************************************************************************
348 //
349 //! \brief Set VDDR boost mode (by setting VDDR_TRIM to FCFG1..VDDR_TRIM_HH and
350 //! setting VDDS_BOD to max)
351 //!
352 //! \param toCode specifies the target VDDR trim value.
353 //! The input parameter \c toCode can be either the signed extended
354 //! trim value or holding the trim code bits only.
355 //!
356 //! \return None
357 //
358 //*****************************************************************************
359 extern void SetupStepVddrTrimTo( uint32_t toCode );
360
361 //*****************************************************************************
362 //
363 // Support for DriverLib in ROM:
364 // Redirect to implementation in ROM when available.
365 //
366 //*****************************************************************************
367 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
368 #include "../driverlib/rom.h"
369 #ifdef ROM_SetupAfterColdResetWakeupFromShutDownCfg1
370 #undef SetupAfterColdResetWakeupFromShutDownCfg1
371 #define SetupAfterColdResetWakeupFromShutDownCfg1 ROM_SetupAfterColdResetWakeupFromShutDownCfg1
372 #endif
373 #ifdef ROM_SetupAfterColdResetWakeupFromShutDownCfg2
374 #undef SetupAfterColdResetWakeupFromShutDownCfg2
375 #define SetupAfterColdResetWakeupFromShutDownCfg2 ROM_SetupAfterColdResetWakeupFromShutDownCfg2
376 #endif
377 #ifdef ROM_SetupAfterColdResetWakeupFromShutDownCfg3
378 #undef SetupAfterColdResetWakeupFromShutDownCfg3
379 #define SetupAfterColdResetWakeupFromShutDownCfg3 ROM_SetupAfterColdResetWakeupFromShutDownCfg3
380 #endif
381 #ifdef ROM_SetupGetTrimForAdcShModeEn
382 #undef SetupGetTrimForAdcShModeEn
383 #define SetupGetTrimForAdcShModeEn ROM_SetupGetTrimForAdcShModeEn
384 #endif
385 #ifdef ROM_SetupGetTrimForAdcShVbufEn
386 #undef SetupGetTrimForAdcShVbufEn
387 #define SetupGetTrimForAdcShVbufEn ROM_SetupGetTrimForAdcShVbufEn
388 #endif
389 #ifdef ROM_SetupGetTrimForAmpcompCtrl
390 #undef SetupGetTrimForAmpcompCtrl
391 #define SetupGetTrimForAmpcompCtrl ROM_SetupGetTrimForAmpcompCtrl
392 #endif
393 #ifdef ROM_SetupGetTrimForAmpcompTh1
394 #undef SetupGetTrimForAmpcompTh1
395 #define SetupGetTrimForAmpcompTh1 ROM_SetupGetTrimForAmpcompTh1
396 #endif
397 #ifdef ROM_SetupGetTrimForAmpcompTh2
398 #undef SetupGetTrimForAmpcompTh2
399 #define SetupGetTrimForAmpcompTh2 ROM_SetupGetTrimForAmpcompTh2
400 #endif
401 #ifdef ROM_SetupGetTrimForAnabypassValue1
402 #undef SetupGetTrimForAnabypassValue1
403 #define SetupGetTrimForAnabypassValue1 ROM_SetupGetTrimForAnabypassValue1
404 #endif
405 #ifdef ROM_SetupGetTrimForDblrLoopFilterResetVoltage
406 #undef SetupGetTrimForDblrLoopFilterResetVoltage
407 #define SetupGetTrimForDblrLoopFilterResetVoltage ROM_SetupGetTrimForDblrLoopFilterResetVoltage
408 #endif
409 #ifdef ROM_SetupGetTrimForRadcExtCfg
410 #undef SetupGetTrimForRadcExtCfg
411 #define SetupGetTrimForRadcExtCfg ROM_SetupGetTrimForRadcExtCfg
412 #endif
413 #ifdef ROM_SetupGetTrimForRcOscLfIBiasTrim
414 #undef SetupGetTrimForRcOscLfIBiasTrim
415 #define SetupGetTrimForRcOscLfIBiasTrim ROM_SetupGetTrimForRcOscLfIBiasTrim
416 #endif
417 #ifdef ROM_SetupGetTrimForRcOscLfRtuneCtuneTrim
418 #undef SetupGetTrimForRcOscLfRtuneCtuneTrim
419 #define SetupGetTrimForRcOscLfRtuneCtuneTrim ROM_SetupGetTrimForRcOscLfRtuneCtuneTrim
420 #endif
421 #ifdef ROM_SetupGetTrimForXoscHfCtl
422 #undef SetupGetTrimForXoscHfCtl
423 #define SetupGetTrimForXoscHfCtl ROM_SetupGetTrimForXoscHfCtl
424 #endif
425 #ifdef ROM_SetupGetTrimForXoscHfFastStart
426 #undef SetupGetTrimForXoscHfFastStart
427 #define SetupGetTrimForXoscHfFastStart ROM_SetupGetTrimForXoscHfFastStart
428 #endif
429 #ifdef ROM_SetupGetTrimForXoscHfIbiastherm
430 #undef SetupGetTrimForXoscHfIbiastherm
431 #define SetupGetTrimForXoscHfIbiastherm ROM_SetupGetTrimForXoscHfIbiastherm
432 #endif
433 #ifdef ROM_SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio
434 #undef SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio
435 #define SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio ROM_SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio
436 #endif
437 #ifdef ROM_SetupSetCacheModeAccordingToCcfgSetting
438 #undef SetupSetCacheModeAccordingToCcfgSetting
439 #define SetupSetCacheModeAccordingToCcfgSetting ROM_SetupSetCacheModeAccordingToCcfgSetting
440 #endif
441 #ifdef ROM_SetupSetAonRtcSubSecInc
442 #undef SetupSetAonRtcSubSecInc
443 #define SetupSetAonRtcSubSecInc ROM_SetupSetAonRtcSubSecInc
444 #endif
445 #ifdef ROM_SetupStepVddrTrimTo
446 #undef SetupStepVddrTrimTo
447 #define SetupStepVddrTrimTo ROM_SetupStepVddrTrimTo
448 #endif
449 #endif
450
451 //*****************************************************************************
452 //
453 // Mark the end of the C bindings section for C++ compilers.
454 //
455 //*****************************************************************************
456 #ifdef __cplusplus
457 }
458 #endif
459
460 #endif // __SETUP_ROM_H__
461
462 //*****************************************************************************
463 //
464 //! Close the Doxygen group.
465 //! @}
466 //! @}
467 //
468 //*****************************************************************************
469