1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
30
31
32
33
34
35
36
37
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
67
68
69
70
75
76
77
78
79
80
81
82
83
84
85
92
97
98
101
102
105
106
/* ... */
#include "main.h"
/* ... */
/* ... */
Includes
/* ... */
/* ... */
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSIState = RCC_LSI_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_LSI;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { ... }
__HAL_RCC_RTC_ENABLE();
HAL_NVIC_SetPriority(RTC_WKUP_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(RTC_WKUP_IRQn);
}{ ... }
/* ... */
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
{
__HAL_RCC_RTC_DISABLE();
}{ ... }
/* ... */
/* ... */
/* ... */