[STM32L4] Change LSI_VALUE to 32 kHz (#1662)

* Add DEVICE_RTC_LSI=0

* Change LSI value to 32 kHz

This is the value written in the device datasheet.

* Replace tabulations with spaces
pull/1674/head
bcostm 2016-04-15 11:48:47 +02:00 committed by Martin Kojtal
parent ffcdd68d7d
commit 9b277ae859
1 changed files with 19 additions and 19 deletions

View File

@ -65,7 +65,7 @@ void rtc_init(void)
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
rtc_freq = LSE_VALUE; rtc_freq = LSE_VALUE;
} else { } else {
error("Cannot initialize RTC with LSE\n"); error("Cannot initialize RTC with LSE\n");
} }
#else #else
// Enable Power clock // Enable Power clock
@ -78,22 +78,22 @@ void rtc_init(void)
__HAL_RCC_BACKUPRESET_FORCE(); __HAL_RCC_BACKUPRESET_FORCE();
__HAL_RCC_BACKUPRESET_RELEASE(); __HAL_RCC_BACKUPRESET_RELEASE();
// Enable LSI clock // Enable LSI clock
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE; RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured! RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured!
RCC_OscInitStruct.LSEState = RCC_LSE_OFF; RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
RCC_OscInitStruct.LSIState = RCC_LSI_ON; RCC_OscInitStruct.LSIState = RCC_LSI_ON;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
error("Cannot initialize RTC with LSI\n"); error("Cannot initialize RTC with LSI\n");
} }
// Connect LSI to RTC // Connect LSI to RTC
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC; PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
error("Cannot initialize RTC with LSI\n"); error("Cannot initialize RTC with LSI\n");
} }
// This value is LSI typical value. To be measured precisely using a timer input capture for example. // This value is LSI typical value (see device datasheet)
rtc_freq = 40000; rtc_freq = 32000;
#endif #endif
// Check if RTC is already initialized // Check if RTC is already initialized