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_AlarmSrc/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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file RTC/RTC_Alarm/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_Alarm * @{ *//* ... */ 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/LSI as RTC clock source ###############################*/ #ifdef RTC_CLOCK_SOURCE_LSE RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; RCC_OscInitStruct.LSEState = RCC_LSE_ON; RCC_OscInitStruct.LSIState = RCC_LSI_OFF; 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) { ... } /* ... */#elif defined (RTC_CLOCK_SOURCE_LSI) RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; RCC_OscInitStruct.LSIState = RCC_LSI_ON; RCC_OscInitStruct.LSEState = RCC_LSE_OFF; 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_LSI; if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); }if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { ... } /* ... */#else #error Please select the RTC Clock source inside the main.h file #endif /*RTC_CLOCK_SOURCE_LSE*/ /*##-2- Enable RTC peripheral Clocks #######################################*/ /* Enable RTC Clock */ __HAL_RCC_RTC_ENABLE(); /*##-4- Configure the NVIC for RTC Alarm ###################################*/ HAL_NVIC_SetPriority(RTC_Alarm_IRQn, 0x0F, 0); HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn); }{ ... } /** * @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(); }{ ... } /** * @} *//* ... */ /** * @} *//* ... */ /** * @} *//* ... */