| BlueNRG-1 Peripherals drivers APIs

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

BlueNRG1_rtc.c
Go to the documentation of this file.
1
22 /* Includes ------------------------------------------------------------------*/
23 #include "BlueNRG1_rtc.h"
24
25
85 void RTC_Init(RTC_InitType* RTC_InitStruct)
86 {
87 /* Check the parameters */
88 assert_param(IS_RTC_TIMER_MODE(RTC_InitStruct->RTC_operatingMode));
89 assert_param(IS_PATTERN(RTC_InitStruct->RTC_PATTERN_SIZE));
90
91 RTC->TCR_b.OS = RTC_InitStruct->RTC_operatingMode;
92 RTC->TCR_b.SP = RTC_InitStruct->RTC_PATTERN_SIZE;
93
94 RTC->TLR1 = RTC_InitStruct->RTC_TLR1;
95 RTC->TLR2 = RTC_InitStruct->RTC_TLR2;
96 RTC->TPR1 = RTC_InitStruct->RTC_PATTERN1;
97 RTC->TPR2 = RTC_InitStruct->RTC_PATTERN2;
98 RTC->TPR3 = RTC_InitStruct->RTC_PATTERN3;
99 RTC->TPR4 = RTC_InitStruct->RTC_PATTERN4;
100
101 }
102
109 void RTC_Cmd(FunctionalState NewState)
110 {
111 /* Check the parameters */
112 assert_param(IS_FUNCTIONAL_STATE(NewState));
113
114 if (NewState != DISABLE) {
115 RTC->TCR_b.EN = SET;
116 }
117 else {
118 RTC->TCR_b.EN = RESET;
119
120 }
121 }
122
132 void RTC_IT_Config(uint8_t RTC_IT, FunctionalState NewState)
133 {
134 /* Check the parameters */
135 assert_param(IS_FUNCTIONAL_STATE(NewState));
136 assert_param(IS_RTC_IT(RTC_IT));
137
138 if (RTC_IT == RTC_IT_CLOCKWATCH) {
139 /* Enable the selected RTC interrupts */
140 RTC->IMSC_b.WIMSC = NewState;
141 }
142 else {
143 /* Disable the selected RTC interrupts */
144 RTC->IMSC_b.TIMSC = NewState;
145 }
146 }
147
156 ITStatus RTC_IT_Status(uint8_t RTC_IT)
157 {
158 /* Check the parameters */
159 assert_param(IS_RTC_IT(RTC_IT));
160
161 /* Check the status of the specified RTC flag */
162 if ((RTC->RIS & RTC_IT) != RESET) {
163 /* RTC_IT is set */
164 return SET;
165 }
166 else {
167 /* RTC_IT is reset */
168 return RESET;
169 }
170 }
171
179 void RTC_IT_Clear(uint8_t RTC_IT)
180 {
181 /* Check the parameters */
182 assert_param(IS_RTC_IT(RTC_IT));
183
184 RTC->ICR = RTC_IT;
185 }
186
187
194 void RTC_ClockwatchCmd(FunctionalState NewState)
195 {
196 /* Check the parameters */
197 assert_param(IS_FUNCTIONAL_STATE(NewState));
198
199 if (NewState != DISABLE) {
200 RTC->CTCR_b.CWEN = SET;
201 }
202 else {
203 RTC->CTCR_b.CWEN = RESET;
204 }
205 }
206
213 void RTC_SetTimeDate(RTC_DateTimeType* RTC_DateTime)
214 {
215 /* Check the parameters */
216 assert_param(IS_SECOND(RTC_DateTime->Second));
217 assert_param(IS_MINUTE(RTC_DateTime->Minute));
218 assert_param(IS_HOUR(RTC_DateTime->Hour));
219 assert_param(IS_WEEKDAY(RTC_DateTime->WeekDay));
220 assert_param(IS_MONTHDAY(RTC_DateTime->MonthDay));
221 assert_param(IS_MONTH(RTC_DateTime->Month));
222 assert_param(IS_YEAR(RTC_DateTime->Year));
223
225 RTC->CWDLR_b.CWSECL = RTC_DateTime->Second;
226
228 RTC->CWDLR_b.CWMINL = RTC_DateTime->Minute;
229
231 RTC->CWDLR_b.CWHOURL = RTC_DateTime->Hour;
232
234 RTC->CWDLR_b.CWDAYWL = RTC_DateTime->WeekDay;
235
237 RTC->CWDLR_b.CWDAYML = RTC_DateTime->MonthDay;
238
240 RTC->CWDLR_b.CWMONTHL = RTC_DateTime->Month;
241
242 /* Store data to load register */
243 RTC->CWYLR_b.CWYEARL = RTC_DateTime->Year;
244 }
245
252 void RTC_SetMatchTimeDate(RTC_DateTimeType* RTC_MatchDataTime)
253 {
254 /* Check the parameters */
255 assert_param(IS_SECOND(RTC_MatchDataTime->Second));
256 assert_param(IS_MINUTE(RTC_MatchDataTime->Minute));
257 assert_param(IS_HOUR(RTC_MatchDataTime->Hour));
258 assert_param(IS_MATCH_WEEKDAY(RTC_MatchDataTime->WeekDay));
259 assert_param(IS_MATCH_MONTHDAY(RTC_MatchDataTime->MonthDay));
260 assert_param(IS_MATCH_MONTH(RTC_MatchDataTime->Month));
261 assert_param(IS_MATCH_YEAR(RTC_MatchDataTime->Year));
262
263 /* Select seconds from the data structure */
264 RTC->CWDMR_b.CWSECM = RTC_MatchDataTime->Second;
265
266 /* Select minutes from the data structure */
267 RTC->CWDMR_b.CWMINM = RTC_MatchDataTime->Minute;
268
269 /* Select hours from the data structure */
270 RTC->CWDMR_b.CWHOURM = RTC_MatchDataTime->Hour;
271
272 /* Select week day from the data structure */
273 RTC->CWDMR_b.CWDAYWM = RTC_MatchDataTime->WeekDay;
274
275 /* Select month day from the data structure */
276 RTC->CWDMR_b.CWDAYMM = RTC_MatchDataTime->MonthDay;
277
278 /* Select month from the data structure */
279 RTC->CWDMR_b.CWMONTHM = RTC_MatchDataTime->Month;
280
281 /* Select year from the data structure */
282 RTC->CWYMR_b.CWYEARM = RTC_MatchDataTime->Year;
283 }
284
291 void RTC_GetTimeDate(RTC_DateTimeType* RTC_DataTime)
292 {
293 /* Select seconds from the RTC register */
294 RTC_DataTime->Second = RTC->CWDR_b.CWSEC;
295
296 /* Select minutes from the RTC register */
297 RTC_DataTime->Minute= RTC->CWDR_b.CWMIN;
298
299 /* Select hours from the RTC register */
300 RTC_DataTime->Hour= RTC->CWDR_b.CWHOUR;
301
302 /* Select week day from the RTC register */
303 RTC_DataTime->WeekDay = RTC->CWDR_b.CWDAYW;
304
305 /* Select month day from the RTC register */
306 RTC_DataTime->MonthDay = RTC->CWDR_b.CWDAYM;
307
308 /* Select month from the RTC register */
309 RTC_DataTime->Month = RTC->CWDR_b.CWMONTH;
310
311 /* Select year from the RTC register */
312 RTC_DataTime->Year = RTC->CWYR_b.CWYEAR;
313 }
314
320 uint32_t RTC_GetTimerValue(void)
321 {
322 /* Return the current Time Data Register */
323 return RTC->TDR;
324 }
325
331 uint32_t RTC_GetNumberIrqGenerated(void)
332 {
333 /* Return the current Time Data Register */
334 return RTC->TIN;
335 }
336
337
344 void RTC_AutoStart(FunctionalState NewState)
345 {
346 /* Check the parameters */
347 assert_param(IS_FUNCTIONAL_STATE(NewState));
348
349 if (NewState != DISABLE) {
350 RTC->TCR_b.S = SET;
351 }
352 else {
353 RTC->TCR_b.S = RESET;
354 }
355 }
356
357
364 void RTC_SelectTrimmedClock(FunctionalState NewState)
365 {
366 /* Check the parameters */
367 assert_param(IS_FUNCTIONAL_STATE(NewState));
368
369 if (NewState != DISABLE) {
370 RTC->TCR_b.CLK = SET;
371 }
372 else {
373 RTC->TCR_b.CLK = RESET;
374 }
375 }
376
389 /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
RTC_DateTimeType::Hour
uint8_t Hour
Definition: BlueNRG1_rtc.h:88
IS_MATCH_MONTH
#define IS_MATCH_MONTH(N)
Definition: BlueNRG1_rtc.h:149
RTC_Cmd
void RTC_Cmd(FunctionalState NewState)
Enables or disables selected RTC peripheral.
Definition: BlueNRG1_rtc.c:109
RTC_GetTimeDate
void RTC_GetTimeDate(RTC_DateTimeType *RTC_DataTime)
Set the RTC clockwatch match date and time registers.
Definition: BlueNRG1_rtc.c:291
RTC_InitType::RTC_PATTERN4
uint32_t RTC_PATTERN4
Definition: BlueNRG1_rtc.h:72
RTC_DateTimeType::Second
uint8_t Second
Definition: BlueNRG1_rtc.h:82
IS_MONTH
#define IS_MONTH(N)
Definition: BlueNRG1_rtc.h:144
RTC_DateTimeType::Month
uint8_t Month
Definition: BlueNRG1_rtc.h:97
RTC_InitType::RTC_PATTERN3
uint32_t RTC_PATTERN3
Definition: BlueNRG1_rtc.h:69
IS_WEEKDAY
#define IS_WEEKDAY(N)
Definition: BlueNRG1_rtc.h:142
RTC_SelectTrimmedClock
void RTC_SelectTrimmedClock(FunctionalState NewState)
Enables or disables the use of the trimmed 32 kHz clock.
Definition: BlueNRG1_rtc.c:364
RTC_SetMatchTimeDate
void RTC_SetMatchTimeDate(RTC_DateTimeType *RTC_MatchDataTime)
Set the RTC clockwatch match date and time registers.
Definition: BlueNRG1_rtc.c:252
RTC_DateTimeType::WeekDay
uint8_t WeekDay
Definition: BlueNRG1_rtc.h:91
RTC_GetNumberIrqGenerated
uint32_t RTC_GetNumberIrqGenerated(void)
Return the actual number of interrupt generated by RTC.
Definition: BlueNRG1_rtc.c:331
RTC_DateTimeType
Structure definition of RTC DateTime.
Definition: BlueNRG1_rtc.h:80
RTC_InitType::RTC_operatingMode
uint8_t RTC_operatingMode
Definition: BlueNRG1_rtc.h:51
RTC_InitType::RTC_PATTERN2
uint32_t RTC_PATTERN2
Definition: BlueNRG1_rtc.h:66
RTC_IT_Status
ITStatus RTC_IT_Status(uint8_t RTC_IT)
Return the RTC interrupt status for the specified IT.
Definition: BlueNRG1_rtc.c:156
RTC_GetTimerValue
uint32_t RTC_GetTimerValue(void)
Return the actual timer counter.
Definition: BlueNRG1_rtc.c:320
RTC_DateTimeType::MonthDay
uint8_t MonthDay
Definition: BlueNRG1_rtc.h:94
IS_HOUR
#define IS_HOUR(N)
Definition: BlueNRG1_rtc.h:141
RTC_IT_CLOCKWATCH
#define RTC_IT_CLOCKWATCH
Definition: BlueNRG1_rtc.h:162
RTC_InitType
Structure definition of RTC initialization.
Definition: BlueNRG1_rtc.h:49
IS_SECOND
#define IS_SECOND(N)
Definition: BlueNRG1_rtc.h:139
IS_RTC_TIMER_MODE
#define IS_RTC_TIMER_MODE(IT)
Definition: BlueNRG1_rtc.h:182
RTC_InitType::RTC_TLR1
uint32_t RTC_TLR1
Definition: BlueNRG1_rtc.h:54
RTC_InitType::RTC_TLR2
uint32_t RTC_TLR2
Definition: BlueNRG1_rtc.h:57
IS_MATCH_WEEKDAY
#define IS_MATCH_WEEKDAY(N)
Definition: BlueNRG1_rtc.h:147
RTC_InitType::RTC_PATTERN_SIZE
uint32_t RTC_PATTERN_SIZE
Definition: BlueNRG1_rtc.h:60
IS_MATCH_YEAR
#define IS_MATCH_YEAR(N)
Definition: BlueNRG1_rtc.h:150
RTC_AutoStart
void RTC_AutoStart(FunctionalState NewState)
Enables or disables the auto start on load register or pattern register write operation.
Definition: BlueNRG1_rtc.c:344
RTC_InitType::RTC_PATTERN1
uint32_t RTC_PATTERN1
Definition: BlueNRG1_rtc.h:63
RTC_ClockwatchCmd
void RTC_ClockwatchCmd(FunctionalState NewState)
Enables or disables selected RTC clockwatch.
Definition: BlueNRG1_rtc.c:194
RTC_IT_Config
void RTC_IT_Config(uint8_t RTC_IT, FunctionalState NewState)
Enables or disables selected RTC interrupt.
Definition: BlueNRG1_rtc.c:132
IS_YEAR
#define IS_YEAR(N)
Definition: BlueNRG1_rtc.h:145
RTC_DateTimeType::Year
uint16_t Year
Definition: BlueNRG1_rtc.h:100
RTC_IT_Clear
void RTC_IT_Clear(uint8_t RTC_IT)
Clear selected RTC interrupt.
Definition: BlueNRG1_rtc.c:179
IS_MINUTE
#define IS_MINUTE(N)
Definition: BlueNRG1_rtc.h:140
RTC_DateTimeType::Minute
uint8_t Minute
Definition: BlueNRG1_rtc.h:85
IS_RTC_IT
#define IS_RTC_IT(IT)
Definition: BlueNRG1_rtc.h:167
IS_PATTERN
#define IS_PATTERN(N)
Definition: BlueNRG1_rtc.h:193
RTC_SetTimeDate
void RTC_SetTimeDate(RTC_DateTimeType *RTC_DateTime)
Initialize the RTC clockwatch with present time and date.
Definition: BlueNRG1_rtc.c:213
BlueNRG1_rtc.h
This file contains all the functions prototypes for the RTC firmware library.
RTC_Init
void RTC_Init(RTC_InitType *RTC_InitStruct)
Initializes the RTC peripheral according to the specified parameters in the RTC_InitStruct.
Definition: BlueNRG1_rtc.c:85
IS_MATCH_MONTHDAY
#define IS_MATCH_MONTHDAY(N)
Definition: BlueNRG1_rtc.h:148
IS_MONTHDAY
#define IS_MONTHDAY(N)
Definition: BlueNRG1_rtc.h:143