/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock

« back to all changes in this revision

Viewing changes to test/rtc-test/util/DS1307.h

  • Committer: Tim Marston
  • Date: 2012-05-18 18:29:50 UTC
  • Revision ID: tim@ed.am-20120518182950-t85bn9a21n72uzm8
text messages are now individually enabled and draw()n automatically

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  DS1307.h - library for DS1307 rtc
 
3
*/
 
4
 
 
5
// ensure this library description is only included once
 
6
#ifndef DS1307_h
 
7
#define DS1307_h
 
8
 
 
9
// include types & constants of core API
 
10
#include <Arduino.h>
 
11
 
 
12
// include types & constants of Wire ic2 lib
 
13
#include <Wire.h>
 
14
 
 
15
#define DS1307_SEC 0
 
16
#define DS1307_MIN 1
 
17
#define DS1307_HR 2
 
18
#define DS1307_DOW 3
 
19
#define DS1307_DAY 4
 
20
#define DS1307_MTH 5
 
21
#define DS1307_YR 6
 
22
 
 
23
#define DS1307_BASE_YR 2000
 
24
 
 
25
#define DS1307_CTRL_ID B1101000  //DS1307
 
26
 
 
27
 // Define register bit masks
 
28
#define DS1307_CLOCKHALT B10000000
 
29
 
 
30
#define DS1307_LO_BCD B00001111
 
31
#define DS1307_HI_BCD B11110000
 
32
 
 
33
#define DS1307_HI_SEC B01110000
 
34
#define DS1307_HI_MIN B01110000
 
35
#define DS1307_HI_HR  B00110000
 
36
#define DS1307_LO_DOW B00000111
 
37
#define DS1307_HI_DAY B00110000
 
38
#define DS1307_HI_MTH B00110000
 
39
#define DS1307_HI_YR  B11110000
 
40
 
 
41
// library interface description
 
42
class DS1307
 
43
{
 
44
public:
 
45
    DS1307();
 
46
    void get(int *, boolean);
 
47
    int get(int, boolean);
 
48
        void set(int, int);
 
49
    void start(void);
 
50
    void stop(void);
 
51
 
 
52
private:
 
53
    // used prior to read/set ds1307 registers;
 
54
    byte rtc_bcd[7];
 
55
 
 
56
        void read(void);
 
57
        void save(void);
 
58
};
 
59
 
 
60
extern DS1307 RTC;
 
61
 
 
62
#endif