/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock
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
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
  DS1307.h - library for DS1307 rtc
*/

// ensure this library description is only included once
#ifndef DS1307_h
#define DS1307_h

// include types & constants of core API
#include <Arduino.h>

// include types & constants of Wire ic2 lib
#include <Wire.h>

#define DS1307_SEC 0
#define DS1307_MIN 1
#define DS1307_HR 2
#define DS1307_DOW 3
#define DS1307_DAY 4
#define DS1307_MTH 5
#define DS1307_YR 6

#define DS1307_BASE_YR 2000

#define DS1307_CTRL_ID B1101000  //DS1307

 // Define register bit masks
#define DS1307_CLOCKHALT B10000000

#define DS1307_LO_BCD B00001111
#define DS1307_HI_BCD B11110000

#define DS1307_HI_SEC B01110000
#define DS1307_HI_MIN B01110000
#define DS1307_HI_HR  B00110000
#define DS1307_LO_DOW B00000111
#define DS1307_HI_DAY B00110000
#define DS1307_HI_MTH B00110000
#define DS1307_HI_YR  B11110000

// library interface description
class DS1307
{
public:
    DS1307();
    void get(int *, boolean);
    int get(int, boolean);
	void set(int, int);
    void start(void);
    void stop(void);

private:
    // used prior to read/set ds1307 registers;
    byte rtc_bcd[7];

	void read(void);
	void save(void);
};

extern DS1307 RTC;

#endif