Update

Dependents:   16A_Autopancakemaker

Committer:
pruek
Date:
Sat Dec 12 07:35:54 2015 +0000
Revision:
0:9570e313fcba
A

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pruek 0:9570e313fcba 1 #ifndef DS1307_H
pruek 0:9570e313fcba 2 #define DS1307_H
pruek 0:9570e313fcba 3 #include "mbed.h"
pruek 0:9570e313fcba 4
pruek 0:9570e313fcba 5 #define DS1307_addr 0xD0 // this is fixed by Dallas
pruek 0:9570e313fcba 6 #define DS1307_freq 100000 // this is the Dallas spec for operating i2c for this device
pruek 0:9570e313fcba 7 #define DS1307_sec 0x00 // seconds
pruek 0:9570e313fcba 8 #define DS1307_min 0x01 // min
pruek 0:9570e313fcba 9 #define DS1307_hour 0x02 // hours
pruek 0:9570e313fcba 10 #define DS1307_day 0x03 // day
pruek 0:9570e313fcba 11 #define DS1307_date 0x04 // date
pruek 0:9570e313fcba 12 #define DS1307_month 0x05 // month
pruek 0:9570e313fcba 13 #define DS1307_year 0x06 // year
pruek 0:9570e313fcba 14 #define DS1307_sqrout 0x07 // square output register
pruek 0:9570e313fcba 15 #define DS1307_ramstart 0x08 // register address that ram starts at
pruek 0:9570e313fcba 16 #define DS1307_lastreg 0x3F // this is the last register in the device (note also this register is used to address everything so it gets clobbered)
pruek 0:9570e313fcba 17 #define DS1307_lastram 0x3E // last usable ram by this class as the lastreg is clobbered by code for normal operation
pruek 0:9570e313fcba 18 class DS1307 {
pruek 0:9570e313fcba 19 public:
pruek 0:9570e313fcba 20 DS1307( PinName sda, PinName slc) ; // constructor
pruek 0:9570e313fcba 21
pruek 0:9570e313fcba 22 ~DS1307(); // destructor
pruek 0:9570e313fcba 23 int read( int addr, int quantity, char *data); // to read some of the 63 bytes from DS1307
pruek 0:9570e313fcba 24 int read(int addr, int *data);
pruek 0:9570e313fcba 25 int write( int addr, int quantity, char *data);
pruek 0:9570e313fcba 26 int write( int addr, int data ); // to write one byte only
pruek 0:9570e313fcba 27 int start_clock(void);
pruek 0:9570e313fcba 28 int stop_clock(void); // stop clock
pruek 0:9570e313fcba 29 int twelve_hour(void);
pruek 0:9570e313fcba 30 int twentyfour_hour(void);
pruek 0:9570e313fcba 31 int settime(int sec, int min, int hour, int day, int date, int month, int year);
pruek 0:9570e313fcba 32 int gettime(int *sec, int *min, int *hour, int *day, int *date, int *month, int *year); // to get the current time information
pruek 0:9570e313fcba 33
pruek 0:9570e313fcba 34
pruek 0:9570e313fcba 35 protected:
pruek 0:9570e313fcba 36 I2C ds1307i2c;
pruek 0:9570e313fcba 37 int dectobcd( int );
pruek 0:9570e313fcba 38 int bcdtodec( int );
pruek 0:9570e313fcba 39 int hilow_check( int, int, int);
pruek 0:9570e313fcba 40
pruek 0:9570e313fcba 41 };
pruek 0:9570e313fcba 42
pruek 0:9570e313fcba 43 #endif
pruek 0:9570e313fcba 44