📄 stm32f10x_rtc.lst
字号:
###############################################################################
# #
# 30/Jul/2008 11:02:24 #
# IAR ARM ANSI C/C++ Compiler V5.11.0.20622/W32 EVALUATION #
# Copyright 1999-2007 IAR Systems. All rights reserved. #
# #
# Cpu mode = thumb #
# Endian = little #
# Source file = E:\library\src\stm32f10x_rtc.c #
# Command line = E:\library\src\stm32f10x_rtc.c -D EMB_FLASH -lcN #
# E:\ELE\yten\pro\Release\List\ -o #
# E:\ELE\yten\pro\Release\Obj\ --no_cse --no_unroll #
# --no_inline --no_code_motion --no_tbaa --no_clustering #
# --no_scheduling --debug --endian little --cpu Cortex-M3 #
# -e --fpu None --dlib_config "C:\Program Files\IAR #
# Systems\Embedded Workbench 5.0 #
# Evaluation\ARM\INC\DLib_Config_Normal.h" -I #
# E:\ELE\yten\pro\ -I E:\ELE\yten\pro\..\LIBRARY\INC\ -I #
# "C:\Program Files\IAR Systems\Embedded Workbench 5.0 #
# Evaluation\ARM\INC\" -On #
# List file = E:\ELE\yten\pro\Release\List\stm32f10x_rtc.lst #
# Object file = E:\ELE\yten\pro\Release\Obj\stm32f10x_rtc.o #
# #
# #
###############################################################################
E:\library\src\stm32f10x_rtc.c
1 /******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
2 * File Name : stm32f10x_rtc.c
3 * Author : MCD Application Team
4 * Version : V1.0
5 * Date : 10/08/2007
6 * Description : This file provides all the RTC firmware functions.
7 ********************************************************************************
8 * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 *******************************************************************************/
15
16 /* Includes ------------------------------------------------------------------*/
17 #include "stm32f10x_rtc.h"
18
19 /* Private typedef -----------------------------------------------------------*/
20 /* Private define ------------------------------------------------------------*/
21 #define CRL_CNF_Set ((u16)0x0010) /* Configuration Flag Enable Mask */
22 #define CRL_CNF_Reset ((u16)0xFFEF) /* Configuration Flag Disable Mask */
23 #define RTC_LSB_Mask ((u32)0x0000FFFF) /* RTC LSB Mask */
24 #define RTC_MSB_Mask ((u32)0xFFFF0000) /* RTC MSB Mask */
25 #define PRLH_MSB_Mask ((u32)0x000F0000) /* RTC Prescaler MSB Mask */
26
27 /* Private macro -------------------------------------------------------------*/
28 /* Private variables ---------------------------------------------------------*/
29 /* Private function prototypes -----------------------------------------------*/
30 /* Private functions ---------------------------------------------------------*/
31
32 /*******************************************************************************
33 * Function Name : RTC_ITConfig
34 * Description : Enables or disables the specified RTC interrupts.
35 * Input : - RTC_IT: specifies the RTC interrupts sources to be enabled
36 * or disabled.
37 * This parameter can be any combination of the following values:
38 * - RTC_IT_OW: Overflow interrupt
39 * - RTC_IT_ALR: Alarm interrupt
40 * - RTC_IT_SEC: Second interrupt
41 * - NewState: new state of the specified RTC interrupts.
42 * This parameter can be: ENABLE or DISABLE.
43 * Output : None
44 * Return : None
45 *******************************************************************************/
46 void RTC_ITConfig(u16 RTC_IT, FunctionalState NewState)
47 {
48 /* Check the parameters */
49 assert_param(IS_RTC_IT(RTC_IT));
50 assert_param(IS_FUNCTIONAL_STATE(NewState));
51
52 if (NewState != DISABLE)
53 {
54 RTC->CRH |= RTC_IT;
55 }
56 else
57 {
58 RTC->CRH &= (u16)~RTC_IT;
59 }
60 }
61
62 /*******************************************************************************
63 * Function Name : RTC_EnterConfigMode
64 * Description : Enters the RTC configuration mode.
65 * Input : None
66 * Output : None
67 * Return : None
68 *******************************************************************************/
69 void RTC_EnterConfigMode(void)
70 {
71 /* Set the CNF flag to enter in the Configuration Mode */
72 RTC->CRL |= CRL_CNF_Set;
73 }
74
75 /*******************************************************************************
76 * Function Name : RTC_ExitConfigMode
77 * Description : Exits from the RTC configuration mode.
78 * Input : None
79 * Output : None
80 * Return : None
81 *******************************************************************************/
82 void RTC_ExitConfigMode(void)
83 {
84 /* Reset the CNF flag to exit from the Configuration Mode */
85 RTC->CRL &= CRL_CNF_Reset;
86 }
87
88 /*******************************************************************************
89 * Function Name : RTC_GetCounter
90 * Description : Gets the RTC counter value.
91 * Input : None
92 * Output : None
93 * Return : RTC counter value.
94 *******************************************************************************/
95 u32 RTC_GetCounter(void)
96 {
97 u16 tmp = 0;
98 tmp = RTC->CNTL;
99
100 return (((u32)RTC->CNTH << 16 ) | tmp) ;
101 }
102
103 /*******************************************************************************
104 * Function Name : RTC_SetCounter
105 * Description : Sets the RTC counter value.
106 * Input : - CounterValue: RTC counter new value.
107 * Output : None
108 * Return : None
109 *******************************************************************************/
110 void RTC_SetCounter(u32 CounterValue)
111 {
112 RTC_EnterConfigMode();
113
114 /* Set RTC COUNTER MSB word */
115 RTC->CNTH = (CounterValue & RTC_MSB_Mask) >> 16;
116 /* Set RTC COUNTER LSB word */
117 RTC->CNTL = (CounterValue & RTC_LSB_Mask);
118
119 RTC_ExitConfigMode();
120 }
121
122 /*******************************************************************************
123 * Function Name : RTC_SetPrescaler
124 * Description : Sets the RTC prescaler value.
125 * Input : - PrescalerValue: RTC prescaler new value.
126 * Output : None
127 * Return : None
128 *******************************************************************************/
129 void RTC_SetPrescaler(u32 PrescalerValue)
130 {
131 /* Check the parameters */
132 assert_param(IS_RTC_PRESCALER(PrescalerValue));
133
134 RTC_EnterConfigMode();
135
136 /* Set RTC PRESCALER MSB word */
137 RTC->PRLH = (PrescalerValue & PRLH_MSB_Mask) >> 0x10;
138 /* Set RTC PRESCALER LSB word */
139 RTC->PRLL = (PrescalerValue & RTC_LSB_Mask);
140
141 RTC_ExitConfigMode();
142 }
143
144 /*******************************************************************************
145 * Function Name : RTC_SetAlarm
146 * Description : Sets the RTC alarm value.
147 * Input : - AlarmValue: RTC alarm new value.
148 * Output : None
149 * Return : None
150 *******************************************************************************/
151 void RTC_SetAlarm(u32 AlarmValue)
152 {
153 RTC_EnterConfigMode();
154
155 /* Set the ALARM MSB word */
156 RTC->ALRH = (AlarmValue & RTC_MSB_Mask) >> 16;
157 /* Set the ALARM LSB word */
158 RTC->ALRL = (AlarmValue & RTC_LSB_Mask);
159
160 RTC_ExitConfigMode();
161 }
162
163 /*******************************************************************************
164 * Function Name : RTC_GetDivider
165 * Description : Gets the RTC divider value.
166 * Input : None
167 * Output : None
168 * Return : RTC Divider value.
169 *******************************************************************************/
170 u32 RTC_GetDivider(void)
171 {
172 u32 tmp = 0x00;
173
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -