Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "rtc.h"
Private defines
#define RTC_ASYNCH_PREDIV
#define RTC_SYNCH_PREDIV
RtcHandle
RTC_Init()
HAL_RTC_MspInit(RTC_HandleTypeDef *)
HAL_RTC_MspDeInit(RTC_HandleTypeDef *)
BACKUP_SaveParameter(uint32_t, uint32_t)
BACKUP_RestoreParameter(uint32_t)
Files
loading...
SourceVuSTM32 Libraries and SamplesSTemWin_SampleDemoSTemWin/Target/rtc.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
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file rtc.c * @author MCD Application Team * @brief <Add here what does this driver do> ****************************************************************************** * @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 "rtc.h" /** @addtogroup MAIN_GROUP< OPTIONAL > * @{ *//* ... */ /** @defgroup SUB_GROUP< OPTIONAL > * @brief * @{ *//* ... */ Includes /* External variables --------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/ #define RTC_ASYNCH_PREDIV 0x7F /* LSE as RTC clock */ #define RTC_SYNCH_PREDIV 0x00FF /* LSE as RTC clock */ Private defines/* Private macros ------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ RTC_HandleTypeDef RtcHandle; /** * @brief Configure the current time and date. * @param None * @retval None *//* ... */ void RTC_Init(void) { /*##-1- Configure the RTC peripheral #######################################*/ /* Configure RTC prescaler and RTC data registers */ /* RTC configured as follow: - Hour Format = Format 24 - Asynch Prediv = Value according to source clock - Synch Prediv = Value according to source clock - OutPut = Output Disable - OutPutPolarity = High Polarity - OutPutType = Open Drain *//* ... */ RtcHandle.Instance = RTC; RtcHandle.Init.HourFormat = RTC_HOURFORMAT_24; RtcHandle.Init.AsynchPrediv = RTC_ASYNCH_PREDIV; RtcHandle.Init.SynchPrediv = RTC_SYNCH_PREDIV; RtcHandle.Init.OutPut = RTC_OUTPUT_DISABLE; RtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; RtcHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; if(HAL_RTC_Init(&RtcHandle) != HAL_OK) { }if (HAL_RTC_Init(&RtcHandle) != HAL_OK) { ... } }{ ... } /** * @brief RTC MSP Initialization * This function configures the hardware resources used in this application: * - Peripheral's clock enable * @param hrtc: RTC handle pointer * @retval None *//* ... */ void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc) { RCC_OscInitTypeDef Osc; /*##-1- Configure LSE as RTC clock source ###################################*/ Osc.OscillatorType = RCC_OSCILLATORTYPE_LSE; Osc.LSEState = RCC_LSE_ON; Osc.HSIState = RCC_HSI_OFF; Osc.HSICalibrationValue = 0; Osc.LSIState = RCC_LSI_OFF; Osc.PLL.PLLState = RCC_PLL_NONE; HAL_RCC_OscConfig(&Osc); __HAL_RCC_RTC_CLKPRESCALER(RCC_RTCCLKSOURCE_LSE); __HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE); /*##-2- 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 application: * - 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(); }{ ... } /** * @brief RTC MSP De-Initialization * This function frees the hardware resources used in this application: * - Disable the Peripheral's clock * @param hrtc: RTC handle pointer * @retval None *//* ... */ void BACKUP_SaveParameter(uint32_t address, uint32_t data) { HAL_RTCEx_BKUPWrite(&RtcHandle,address,data); }{ ... } /** * @brief RTC MSP De-Initialization * This function frees the hardware resources used in this application: * - Disable the Peripheral's clock * @param hrtc: RTC handle pointer * @retval None *//* ... */ uint32_t BACKUP_RestoreParameter(uint32_t address) { return HAL_RTCEx_BKUPRead(&RtcHandle,address); }{ ... } /** * @} *//* ... */ /** * @} *//* ... */
Details