CLEON
Version 1
Cloud-Offloaded GPS Receiver
Main Page
Related Pages
Data Structures
Files
File List
Globals
hal_rtc.h
Go to the documentation of this file.
1
7
#ifndef __HAL_RTC_H__
8
#define __HAL_RTC_H__
9
10
#define HAL_RTC_EnableRDYIE() RTCCTL01 |= RTCRDYIE; // enable rtc ready interrupt; 1sec
11
#define HAL_RTC_DisableRDYIE() RTCCTL01 &= ~RTCRDYIE; // enable rtc ready interrupt; 1sec
12
13
#define HAL_RTC_Reset() do{ \
14
RT0PS = 0; \
15
RT1PS = 0; \
16
}while(0)
17
18
#define HAL_RTC_StartMillisecondTimer() TA1CCR0 = 12000; // Count 12000 to generate 1ms tick with 12MHz clock source
19
#define HAL_RTC_StopMillisecondTimer() TA1CCR0 = 0; // Stop millisecond timer by setting TA0CCR0 to 0
20
21
#define HAL_RTC_EnableSecondInterrupt() RTCCTL01 |= RTCRDYIE // Enable rtc ready interrupt; 1sec
22
#define HAL_RTC_DisableSecondInterrupt() RTCCTL01 &= ~RTCRDYIE // Disable rtc ready interrupt; 1sec
23
24
// This is for a normal year, it should be adjusted if leap year,
25
#define DAYS_IN_MONTHS_BEFORE_THE_FIRST_DAY_OF_JAN (0)
26
#define DAYS_IN_MONTHS_BEFORE_THE_FIRST_DAY_OF_FEB (31)
27
#define DAYS_IN_MONTHS_BEFORE_THE_FIRST_DAY_OF_MAR (31 + 28)
28
#define DAYS_IN_MONTHS_BEFORE_THE_FIRST_DAY_OF_APR (31 + 28 + 31)
29
#define DAYS_IN_MONTHS_BEFORE_THE_FIRST_DAY_OF_MAY (31 + 28 + 31 + 30)
30
#define DAYS_IN_MONTHS_BEFORE_THE_FIRST_DAY_OF_JUN (31 + 28 + 31 + 30 + 31)
31
#define DAYS_IN_MONTHS_BEFORE_THE_FIRST_DAY_OF_JUL (31 + 28 + 31 + 30 + 31 + 30)
32
#define DAYS_IN_MONTHS_BEFORE_THE_FIRST_DAY_OF_AUG (31 + 28 + 31 + 30 + 31 + 30 + 31)
33
#define DAYS_IN_MONTHS_BEFORE_THE_FIRST_DAY_OF_SEP (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31)
34
#define DAYS_IN_MONTHS_BEFORE_THE_FIRST_DAY_OF_OCT (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30)
35
#define DAYS_IN_MONTHS_BEFORE_THE_FIRST_DAY_OF_NOV (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31)
36
#define DAYS_IN_MONTHS_BEFORE_THE_FIRST_DAY_OF_DEC (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30)
37
38
typedef
union
{
39
unsigned
long
long
ullSecondTimeTick
;
40
unsigned
char
ucSingleByte[8];
41
}
seoncd_time_tick_u
;
42
43
typedef
union
{
44
unsigned
long
long
ullMillisecondTimeTick
;
45
unsigned
char
ucSingleByte[8];
46
}
milliseoncd_time_tick_u
;
47
48
typedef
struct
{
49
unsigned
char
ucYear
;
// 1 bytes
50
unsigned
char
ucMonth
;
// 1 byte
51
unsigned
char
ucDay
;
// 1 byte
52
unsigned
char
ucHour
;
// 1 byte
53
unsigned
char
ucMinute
;
// 1 byte
54
unsigned
char
ucSecond
;
// 1 byte
55
unsigned
int
uiMillisecond
;
// 2 byte
56
}
rtc_time_s
;
// 8 bytes
57
58
typedef
union
{
59
rtc_time_s
stRTCTime
;
60
unsigned
char
ucSingleBytes[8];
61
}
rtc_time_u
;
62
63
#define TIME_MEASUREMENT _DISABLE_
64
#define NUMBER_OF_TIME_MEASUREMENT_TEST 10
65
66
typedef
struct
{
67
unsigned
long
long
ullTimeAtUserButtonPressed
;
68
unsigned
long
long
ullTimeAtStartAPPLog
;
69
unsigned
long
long
ullTimeAtWriteHeaderToSDCard
;
70
unsigned
long
long
ullTimeAtFirstChunk
;
71
}
time_measurement_s
;
72
73
void
HAL_RTC_Init
(
void
);
74
void
HAL_RTC_ReadRTCTime
(
void
);
75
void
HAL_RTC_RestoreTimeTick
(
void
);
76
77
unsigned
long
long
HAL_RTC_GetSecondConvertedFromStoredRTCTime
(
rtc_time_u
*uniTempRTCTime);
78
79
unsigned
int
HAL_SetRTCYear
(
int
year);
80
unsigned
int
HAL_SetRTCMon
(
int
month);
81
unsigned
int
HAL_SetRTCDay
(
int
day);
82
unsigned
int
HAL_SetRTCDow
(
int
dow);
83
unsigned
int
HAL_SetRTCHour
(
int
hour);
84
unsigned
int
HAL_SetRTCMin
(
int
min);
85
unsigned
int
HAL_SetRTCSec
(
int
sec);
86
unsigned
int
HAL_SetRTCMilisec
(
int
millisec);
87
88
unsigned
int
HAL_GetRTCYear
(
void
);
89
unsigned
int
HAL_GetRTCMon
(
void
);
90
unsigned
int
HAL_GetRTCDow
(
void
);
91
unsigned
int
HAL_GetRTCDay
(
void
);
92
unsigned
int
HAL_GetRTCHour
(
void
);
93
unsigned
int
HAL_GetRTCMin
(
void
);
94
unsigned
int
HAL_GetRTCSec
(
void
);
95
unsigned
int
HAL_GetRTCMilisec
(
void
);
96
97
#endif
hal
hal_rtc.h
Generated on Tue May 28 2013 15:17:19 for CLEON by
1.8.2