-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDS1337RTC.h
executable file
·49 lines (40 loc) · 1.15 KB
/
DS1337RTC.h
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
48
49
/*
* DS1337RTC.h - library for DS1337 RTC
* This library is intended to be uses with Arduino Time.h library functions
*/
#ifndef DS1337RTC_h
#define DS1337RTC_h
#include <TimeLib.h>
#define DS1337_CTRL_ID 0x68
#define CLOCK_ADDRESS 0x00
#define ALARM1_ADDRESS 0x07
#define ALARM2_ADDRESS 0x0B
#define STATUS_ADDRESS 0x0F
#define CONTROL_ADDRESS 0x0E
#define INTB 0
#define SQW 1
// library interface description
class DS1337RTC
{
// user-accessible "public" interface
public:
DS1337RTC();
static time_t get(int address);
static void set(time_t t, int address);
static time_t sync();
static void read(tmElements_t &tm, int address);
static void write(tmElements_t &tm, int address);
static void enableAlarm(int address);
static void disableAlarm(int address);
static void resetAlarms();
static void interruptSelect(int mode);
static void freqSelect(int freq);
bool readOSF();
private:
static uint8_t dec2bcd(uint8_t num);
static uint8_t bcd2dec(uint8_t num);
static void startClock();
static void stopClock();
};
extern DS1337RTC RTC;
#endif