19 #define VDD_VOLTAGE_MV 3150
24 RCC_ClocksTypeDef RCC_ClockFreq;
48 bool UTIL_isBackupRegisterConfigured(
void )
52 for ( i = 1 ; i <= 11 ; i++ )
77 void SetBitTimingAnalysis( u8 set )
111 for ( i = 0; i < ADC_NB_SAMPLES; i++ )
113 vbat += ADC_ConvertedValue[0 + i * ADC_NB_CHANNELS];
115 vbat = vbat / ADC_NB_SAMPLES;
118 vbat = ( vbat * VDD_VOLTAGE_MV ) / 0x1000;
128 VBat = ( VBat >> 1 ) + ( vbat >> 1 );
153 for ( i = 0; i < ADC_NB_SAMPLES; i++ )
155 temp += ADC_ConvertedValue[1 + i*ADC_NB_CHANNELS];
157 temp = temp / ADC_NB_SAMPLES;
160 temp = ( temp * VDD_VOLTAGE_MV ) / 0x1000;
161 temp = ((( 1430 - temp ) * 100000 ) / 4300 ) + 25000;
164 if ( fTemperatureInFahrenheit )
166 temp = 32000 + ( 9 * temp ) / 5 ;
192 RCC_SYSCLKConfig( RCC_SYSCLKSource_HSI );
195 RCC_PLLCmd( DISABLE );
197 RCC_PLL2Cmd( DISABLE );
213 RCC->CFGR2 &= ( uint32_t )~( RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL |
214 RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC );
215 RCC->CFGR2 |= ( uint32_t )( RCC_CFGR2_PREDIV2_DIV4 | RCC_CFGR2_PLL2MUL12 |
216 RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV16 | RCC_CFGR2_I2S2SRC );
218 RCC->CFGR &= ( uint32_t )~( RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL );
219 RCC->CFGR |= ( uint32_t )( RCC_CFGR_PLLSRC_PREDIV1 | RCC_CFGR_PLLMULL6_5 );
222 RCC_PLLConfig( RCC_PLLSource_HSE_Div2, RCC_PLLMul_3 );
230 RCC->CFGR2 &= ( uint32_t )~( RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL |
231 RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC );
232 RCC->CFGR2 |= ( uint32_t )( RCC_CFGR2_PREDIV2_DIV4 | RCC_CFGR2_PLL2MUL12 |
233 RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV9 | RCC_CFGR2_I2S2SRC );
235 RCC->CFGR &= ( uint32_t )~( RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL );
236 RCC->CFGR |= ( uint32_t )( RCC_CFGR_PLLSRC_PREDIV1 | RCC_CFGR_PLLMULL5 );
239 RCC_PLLConfig( RCC_PLLSource_HSE_Div1, RCC_PLLMul_2 );
249 RCC->CFGR2 &= ( uint32_t )~( RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL |
250 RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC );
251 RCC->CFGR2 |= ( uint32_t )( RCC_CFGR2_PREDIV2_DIV4 | RCC_CFGR2_PLL2MUL12 |
252 RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV8 | RCC_CFGR2_I2S2SRC );
254 RCC->CFGR &= ( uint32_t )~( RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL );
255 RCC->CFGR |= ( uint32_t )( RCC_CFGR_PLLSRC_PREDIV1 | RCC_CFGR_PLLMULL6_5 );
258 RCC_PLLConfig( RCC_PLLSource_HSE_Div1, RCC_PLLMul_3 );
266 RCC->CFGR2 &= ( uint32_t )~( RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL |
267 RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC );
268 RCC->CFGR2 |= ( uint32_t )( RCC_CFGR2_PREDIV2_DIV4 | RCC_CFGR2_PLL2MUL12 |
269 RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV8 | RCC_CFGR2_I2S2SRC );
271 RCC->CFGR &= ( uint32_t )~( RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL );
272 RCC->CFGR |= ( uint32_t )( RCC_CFGR_PLLSRC_PREDIV1 | RCC_CFGR_PLLMULL9 );
275 RCC_PLLConfig( RCC_PLLSource_HSE_Div1, RCC_PLLMul_4 );
283 RCC->CFGR2 &= ( uint32_t )~( RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL |
284 RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC );
285 RCC->CFGR2 |= ( uint32_t )( RCC_CFGR2_PREDIV2_DIV4 | RCC_CFGR2_PLL2MUL12 |
286 RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV4 | RCC_CFGR2_I2S2SRC );
288 RCC->CFGR &= ( uint32_t )~( RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL );
289 RCC->CFGR |= ( uint32_t )( RCC_CFGR_PLLSRC_PREDIV1 | RCC_CFGR_PLLMULL6_5 );
292 RCC_PLLConfig( RCC_PLLSource_HSE_Div1, RCC_PLLMul_6 );
299 RCC_PLL2Cmd( ENABLE );
302 while (( RCC->CR & RCC_CR_PLL2RDY ) == 0 )
308 RCC_PLLCmd( ENABLE );
311 while (( RCC->CR & RCC_CR_PLLRDY ) == 0 )
316 RCC_SYSCLKConfig( RCC_SYSCLKSource_PLLCLK );
319 while (( RCC->CFGR & ( uint32_t )RCC_CFGR_SWS ) != ( uint32_t )0x08 )
325 RCC_GetClocksFreq( &RCC_ClockFreq );
329 extern const u16 I2S_PrescalerVal[];
331 *( u16* )AUDIO_I2SPR = I2S_PrescalerVal[speed-1];
356 return ( *( vu16* )( BKP_BASE + 4 * BKP_DR ) );
358 else if ( BKP_DR < 43 )
360 return ( *( vu16* )( BKP_BASE + 4 * ( BKP_DR + 5 ) ) );
384 *( vu16* )( BKP_BASE + 4 * BKP_DR ) = Data;
386 else if ( BKP_DR < 43 )
388 *( vu16* )( BKP_BASE + 4 *( BKP_DR + 5 ) ) = Data;