Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "main.h"
HAL_RTC_MspInit(RTC_HandleTypeDef *)
HAL_RTC_MspDeInit(RTC_HandleTypeDef *)
Files
loading...
CodeScopeSTM32 Libraries and SamplesRTC_CalendarSrc/stm32f4xx_hal_msp.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file RTC/RTC_Calendar/Src/stm32f4xx_hal_msp.c * @author MCD Application Team * @brief HAL MSP module. ****************************************************************************** * @attention * * Copyright (c) 2017 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F4xx_HAL_Examples * @{ *//* ... */ /** @defgroup RTC_Calendar * @{ *//* ... */ Includes /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** @defgroup HAL_MSP_Private_Functions * @{ *//* ... */ /** * @brief RTC MSP Initialization * This function configures the hardware resources used in this example * @param hrtc RTC handle pointer * * @note Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select * the RTC clock source; in this case the Backup domain will be reset in * order to modify the RTC Clock source, as consequence RTC registers (including * the backup registers) and RCC_BDCR register are set to their reset values. * * @retval None *//* ... */ void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc) { RCC_OscInitTypeDef RCC_OscInitStruct; RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; /*##-1- Enables the PWR Clock and Enables access to the backup domain ###################################*/ /* To change the source clock of the RTC feature (LSE, LSI), You have to: - Enable the power clock using __HAL_RCC_PWR_CLK_ENABLE() - Enable write access using HAL_PWR_EnableBkUpAccess() function before to configure the RTC clock source (to be done once after reset). - Reset the Back up Domain using __HAL_RCC_BACKUPRESET_FORCE() and __HAL_RCC_BACKUPRESET_RELEASE(). - Configure the needed RTc clock source *//* ... */ __HAL_RCC_PWR_CLK_ENABLE(); HAL_PWR_EnableBkUpAccess(); /*##-2- Configure LSE as RTC clock source ###################################*/ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; RCC_OscInitStruct.LSEState = RCC_LSE_ON; if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); }if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { ... } PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC; PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); }if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { ... } /*##-3- Enable RTC peripheral Clocks #######################################*/ /* Enable RTC Clock */ __HAL_RCC_RTC_ENABLE(); }{ ... } /** * @brief RTC MSP De-Initialization * This function frees the hardware resources used in this example: * - Disable the Peripheral's clock * @param hrtc: RTC handle pointer * @retval None *//* ... */ void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc) { /*##-1- Reset peripherals ##################################################*/ __HAL_RCC_RTC_DISABLE(); /*##-2- Disables the PWR Clock and Disables access to the backup domain ###################################*/ HAL_PWR_DisableBkUpAccess(); __HAL_RCC_PWR_CLK_DISABLE(); }{ ... } /** * @} *//* ... */ /** * @} *//* ... */ /** * @} *//* ... */