]> git.gir.st - tmk_keyboard.git/blob - protocol/lufa/LUFA-git/Projects/TempDataLogger/Lib/RTC.h
Squashed 'tmk_core/' changes from caca2c0..dc0e46e
[tmk_keyboard.git] / protocol / lufa / LUFA-git / Projects / TempDataLogger / Lib / RTC.h
1 /*
2 Copyright (C) Dean Camera, 2014.
3
4 dean [at] fourwalledcubicle [dot] com
5 www.lufa-lib.org
6 */
7
8 #ifndef _RTC_H_
9 #define _RTC_H_
10
11 /* Includes: */
12 #include <avr/io.h>
13
14 #include <LUFA/Drivers/Peripheral/TWI.h>
15
16 #include "Config/AppConfig.h"
17
18 /* Type Defines: */
19 typedef struct
20 {
21 uint8_t Hour;
22 uint8_t Minute;
23 uint8_t Second;
24 uint8_t Day;
25 uint8_t Month;
26 uint8_t Year;
27 } TimeDate_t;
28
29 typedef struct
30 {
31 union
32 {
33 struct
34 {
35 unsigned Sec : 4;
36 unsigned TenSec : 3;
37 unsigned CH : 1;
38 } Fields;
39
40 uint8_t IntVal;
41 } Byte1;
42
43 union
44 {
45 struct
46 {
47 unsigned Min : 4;
48 unsigned TenMin : 3;
49 unsigned Reserved : 1;
50 } Fields;
51
52 uint8_t IntVal;
53 } Byte2;
54
55 union
56 {
57 struct
58 {
59 unsigned Hour : 4;
60 unsigned TenHour : 2;
61 unsigned TwelveHourMode : 1;
62 unsigned Reserved : 1;
63 } Fields;
64
65 uint8_t IntVal;
66 } Byte3;
67
68 union
69 {
70 struct
71 {
72 unsigned DayOfWeek : 3;
73 unsigned Reserved : 5;
74 } Fields;
75
76 uint8_t IntVal;
77 } Byte4;
78
79 union
80 {
81 struct
82 {
83 unsigned Day : 4;
84 unsigned TenDay : 2;
85 unsigned Reserved : 2;
86 } Fields;
87
88 uint8_t IntVal;
89 } Byte5;
90
91 union
92 {
93 struct
94 {
95 unsigned Month : 4;
96 unsigned TenMonth : 1;
97 unsigned Reserved : 3;
98 } Fields;
99
100 uint8_t IntVal;
101 } Byte6;
102
103 union
104 {
105 struct
106 {
107 unsigned Year : 4;
108 unsigned TenYear : 4;
109 } Fields;
110
111 uint8_t IntVal;
112 } Byte7;
113 } DS1307_DateTimeRegs_t;
114
115 /* Macros: */
116 /** TWI address of the DS1307 device on the bus. */
117 #define DS1307_ADDRESS 0xD0
118
119 /* Function Prototypes: */
120 void RTC_Init(void);
121 void RTC_Tick500ms(void);
122 bool RTC_SetTimeDate(const TimeDate_t* NewTimeDate);
123 bool RTC_GetTimeDate(TimeDate_t* const TimeDate);
124
125 #endif
126
Imprint / Impressum