|
13 | 13 | #include <stdbool.h> |
14 | 14 | #include <time.h> |
15 | 15 |
|
| 16 | +#ifdef __cplusplus |
| 17 | +extern "C" { |
| 18 | +#endif |
| 19 | + |
16 | 20 | #define DS3231_ADDR 0x68 |
17 | 21 |
|
18 | | -#define DS3231_STAT_OSCILLATOR 0x80 |
19 | | -#define DS3231_STAT_32KHZ 0x08 |
20 | | -#define DS3231_STAT_BUSY 0x04 |
21 | | -#define DS3231_STAT_ALARM_2 0x02 |
22 | | -#define DS3231_STAT_ALARM_1 0x01 |
23 | | - |
24 | | -#define DS3231_CTRL_OSCILLATOR 0x80 |
25 | | -#define DS3231_CTRL_SQUAREWAVE_BB 0x40 |
26 | | -#define DS3231_CTRL_TEMPCONV 0x20 |
27 | | -#define DS3231_CTRL_SQWAVE_4096HZ 0x10 |
28 | | -#define DS3231_CTRL_SQWAVE_1024HZ 0x08 |
29 | | -#define DS3231_CTRL_SQWAVE_8192HZ 0x18 |
30 | | -#define DS3231_CTRL_SQWAVE_1HZ 0x00 |
31 | | -#define DS3231_CTRL_ALARM_INTS 0x04 |
32 | | -#define DS3231_CTRL_ALARM2_INT 0x02 |
33 | | -#define DS3231_CTRL_ALARM1_INT 0x01 |
34 | | - |
35 | | -#define DS3231_ALARM_WDAY 0x40 |
36 | | -#define DS3231_ALARM_NOTSET 0x80 |
37 | | - |
38 | | -#define DS3231_ADDR_TIME 0x00 |
39 | | -#define DS3231_ADDR_ALARM1 0x07 |
40 | | -#define DS3231_ADDR_ALARM2 0x0b |
41 | | -#define DS3231_ADDR_CONTROL 0x0e |
42 | | -#define DS3231_ADDR_STATUS 0x0f |
43 | | -#define DS3231_ADDR_AGING 0x10 |
44 | | -#define DS3231_ADDR_TEMP 0x11 |
45 | | - |
46 | | -#define DS3231_12HOUR_FLAG 0x40 |
47 | | -#define DS3231_12HOUR_MASK 0x1f |
48 | | -#define DS3231_PM_FLAG 0x20 |
49 | | -#define DS3231_MONTH_MASK 0x1f |
| 22 | +#define DS3231_STAT_OSCILLATOR 0x80 |
| 23 | +#define DS3231_STAT_32KHZ 0x08 |
| 24 | +#define DS3231_STAT_BUSY 0x04 |
| 25 | +#define DS3231_STAT_ALARM_2 0x02 |
| 26 | +#define DS3231_STAT_ALARM_1 0x01 |
| 27 | + |
| 28 | +#define DS3231_CTRL_OSCILLATOR 0x80 |
| 29 | +#define DS3231_CTRL_SQUAREWAVE_BB 0x40 |
| 30 | +#define DS3231_CTRL_TEMPCONV 0x20 |
| 31 | +#define DS3231_CTRL_SQWAVE_4096HZ 0x10 |
| 32 | +#define DS3231_CTRL_SQWAVE_1024HZ 0x08 |
| 33 | +#define DS3231_CTRL_SQWAVE_8192HZ 0x18 |
| 34 | +#define DS3231_CTRL_SQWAVE_1HZ 0x00 |
| 35 | +#define DS3231_CTRL_ALARM_INTS 0x04 |
| 36 | +#define DS3231_CTRL_ALARM2_INT 0x02 |
| 37 | +#define DS3231_CTRL_ALARM1_INT 0x01 |
| 38 | + |
| 39 | +#define DS3231_ALARM_WDAY 0x40 |
| 40 | +#define DS3231_ALARM_NOTSET 0x80 |
| 41 | + |
| 42 | +#define DS3231_ADDR_TIME 0x00 |
| 43 | +#define DS3231_ADDR_ALARM1 0x07 |
| 44 | +#define DS3231_ADDR_ALARM2 0x0b |
| 45 | +#define DS3231_ADDR_CONTROL 0x0e |
| 46 | +#define DS3231_ADDR_STATUS 0x0f |
| 47 | +#define DS3231_ADDR_AGING 0x10 |
| 48 | +#define DS3231_ADDR_TEMP 0x11 |
| 49 | + |
| 50 | +#define DS3231_12HOUR_FLAG 0x40 |
| 51 | +#define DS3231_12HOUR_MASK 0x1f |
| 52 | +#define DS3231_PM_FLAG 0x20 |
| 53 | +#define DS3231_MONTH_MASK 0x1f |
50 | 54 |
|
51 | 55 | enum { |
52 | 56 | DS3231_SET = 0, |
@@ -184,4 +188,8 @@ bool ds3231_getTempFloat(float *temp); |
184 | 188 | bool ds3231_getTime(struct tm *time); |
185 | 189 | void ds3231_Init(uint8_t scl, uint8_t sda); |
186 | 190 |
|
| 191 | +#ifdef __cplusplus |
| 192 | +} |
187 | 193 | #endif |
| 194 | + |
| 195 | +#endif /* __DS3231_H__ */ |
0 commit comments