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