forked from GreyZhang/g_s32k144
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtc_lld.c
47 lines (43 loc) · 1.27 KB
/
rtc_lld.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
#include "rtc_lld.h"
#include "printf.h"
rtc_timedate_t current_time;
void rtc_lld_init(void)
{
/* Initialize RTC instance
* - See RTC configuration component for options
*/
RTC_DRV_Init(RTCTIMER1, &rtcTimer1_Config0);
/* Configure RTC Time Seconds Interrupt */
RTC_DRV_ConfigureSecondsInt(RTCTIMER1, &rtcTimer1_SecIntConfig0);
/* Set the time and date */
RTC_DRV_SetTimeDate(RTCTIMER1, &rtcTimer1_StartTime0);
/* Start the RTC counter */
RTC_DRV_StartCounter(RTCTIMER1);
}
void rtc_lld_step(void)
{
static uint8_t i = 0U;
/* Get current time */
RTC_DRV_GetCurrentTimeDate(RTCTIMER1, ¤t_time);
printf("%d/%d/%d/%d:%d:%d\n", current_time.year, current_time.month, current_time.day, \
current_time.hour, current_time.minutes, current_time.seconds);
i++;
if(i == 10U)
{
printf("set time to 2008/8/8/8:8:8\n");
current_time.year = 2008;
current_time.month = 8;
current_time.day = 8;
current_time.hour = 8;
current_time.minutes = 8;
current_time.seconds = 8;
RTC_DRV_StopCounter(RTCTIMER1);
RTC_DRV_SetTimeDate(RTCTIMER1, ¤t_time);
RTC_DRV_StartCounter(RTCTIMER1);
i = 0U;
}
else
{
/* no code */
}
}