39 #include <inc/hw_types.h>
40 #include <inc/hw_ccfg.h>
41 #include <inc/hw_fcfg1.h>
53 #undef OSCClockSourceSet
54 #define OSCClockSourceSet NOROM_OSCClockSourceSet
55 #undef OSCClockSourceGet
56 #define OSCClockSourceGet NOROM_OSCClockSourceGet
57 #undef OSCInterfaceEnable
58 #define OSCInterfaceEnable NOROM_OSCInterfaceEnable
67 #define RTC_CV_TO_MS(x) (( 1000 * ( x )) >> 16 )
68 #define RTC_CV_TO_US(x) (( 1000000 * ( x )) >> 16 )
102 if(ui32SrcClk & OSC_SRC_CLK_HF)
116 if(ui32SrcClk & OSC_SRC_CLK_MF)
127 if(ui32SrcClk & OSC_SRC_CLK_LF)
147 uint32_t ui32ClockSource;
158 if(ui32SrcClk == OSC_SRC_CLK_LF)
170 return (ui32ClockSource);
205 uint32_t deltaTimeSinceXoscOnInMs ;
206 int32_t deltaTempSinceXoscOn ;
207 uint32_t newStartupTimeInUs ;
212 if ( deltaTempSinceXoscOn < 0 ) {
213 deltaTempSinceXoscOn = -deltaTempSinceXoscOn;
216 if ( (( timeUntilWakeupInMs + deltaTimeSinceXoscOnInMs ) > 3000 ) ||
217 ( deltaTempSinceXoscOn > 5 ) ||
221 newStartupTimeInUs = 2000;
230 newStartupTimeInUs += ( newStartupTimeInUs >> 2 );
236 if ( newStartupTimeInUs < 200 ) {
237 newStartupTimeInUs = 200;
239 if ( newStartupTimeInUs > 4000 ) {
240 newStartupTimeInUs = 4000;
242 return ( newStartupTimeInUs );
267 uint32_t startupTimeInUs;
268 uint32_t prevLimmit25InUs;
283 prevLimmit25InUs -= ( prevLimmit25InUs >> 2 );
285 if ( prevLimmit25InUs > startupTimeInUs ) {
331 >> (32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P0_W));
333 >> (32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P1_W));
335 >> (32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P2_W));
338 >> (32 - FCFG1_MISC_CONF_2_HPOSC_COMP_P3_W));
351 int32_t tempDelta = (tempDegC - 27);
352 int32_t tempDeltaX2 = tempDelta * tempDelta;
353 int32_t d = paramP0 + ((tempDelta*paramP1)>>3) + ((tempDeltaX2*paramP2)>>10) + ((tempDeltaX2*tempDelta*paramP3)>>18);
398 int32_t rfCoreFreqOffset = -HPOSC_RelFreqOffset + (( HPOSC_RelFreqOffset * HPOSC_RelFreqOffset ) >> 22 );
400 return ( rfCoreFreqOffset );
static void AONWUCAuxWakeupEvent(uint32_t ui32Mode)
Control the wake up procedure of the AUX domain.
static uint32_t AONWUCPowerStatusGet(void)
Get the power status of the device.
static void OSCHfSourceSwitch(void)
Switch the high frequency clock.
void AUXWUCClockEnable(uint32_t ui32Clocks)
Enable clocks for peripherals in the AUX domain.
#define AUX_WUC_OSCCTRL_CLOCK
uint32_t AUXWUCClockStatus(uint32_t ui32Clocks)
Get the status of a clock.
uint32_t timeXoscStable_CV
int32_t AONBatMonTemperatureGetDegC(void)
Get the current temperature measurement as a signed value in Deg Celsius.
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
#define AUX_WUC_CLOCK_READY
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.
void OSCInterfaceEnable(void)
Enable System CPU access to the OSC_DIG module.
uint32_t OSCHF_GetStartupTime(uint32_t timeUntilWakeupInMs)
Returns maximum startup time (in microseconds) of XOSC_HF.
#define AONWUC_AUX_POWER_ON
bool OSCHF_AttemptToSwitchToXosc(void)
Switch to XOSC_HF if XOSC_HF is ready.
static bool OSCHfSourceReady(void)
Check if the HF clock source is ready to be switched.
#define AONWUC_AUX_WAKEUP
uint32_t previousStartupTimeInUs
uint16_t DDI16BitfieldRead(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32Shift)
Read a bitfield via the DDI using 16-bit read.
static OscHfGlobals_t oscHfGlobals
int32_t OSC_HPOSCRelativeFrequencyOffsetGet(int32_t tempDegC)
Calculate the temperature dependent relative frequency offset of HPOSC.
void OSCHF_SwitchToRcOscTurnOffXosc(void)
Switch to RCOSC_HF and turn off XOSC_HF.
uint32_t AONRTCCurrentCompareValueGet(void)
Get the current value of the RTC counter in a format that matches RTC compare values.
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
void OSCHF_TurnOnXosc(void)
Turns on XOSC_HF (but without switching to XOSC_HF).
int16_t OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert(int32_t HPOSC_RelFreqOffset)
Converts the relative frequency offset of HPOSC to the RF Core parameter format.