Class library for the Dallas Semiconductor DS1307 RTC Basic Functionality, read and set RTC

Committer:
jebradshaw
Date:
Sat Oct 11 06:04:41 2014 +0000
Revision:
0:2bbb23558624
Child:
1:95a90bac5d6d
DS1307 Real Time Clock Library (I2C Interface)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jebradshaw 0:2bbb23558624 1
jebradshaw 0:2bbb23558624 2 #ifndef DS1307_RTC_H
jebradshaw 0:2bbb23558624 3 #define DS1307_RTC_H
jebradshaw 0:2bbb23558624 4
jebradshaw 0:2bbb23558624 5 #include "mbed.h"
jebradshaw 0:2bbb23558624 6
jebradshaw 0:2bbb23558624 7 #define DS1307_addr 0xd0
jebradshaw 0:2bbb23558624 8
jebradshaw 0:2bbb23558624 9 #define YEAR_OFFSET 2000
jebradshaw 0:2bbb23558624 10
jebradshaw 0:2bbb23558624 11 class DS1307_RTC{
jebradshaw 0:2bbb23558624 12 public:
jebradshaw 0:2bbb23558624 13 DS1307_RTC(PinName sda, PinName scl);
jebradshaw 0:2bbb23558624 14
jebradshaw 0:2bbb23558624 15 void RTC_write_reg(int reg, int val);
jebradshaw 0:2bbb23558624 16 int RTC_read_reg(char reg);
jebradshaw 0:2bbb23558624 17 int bcd(int dec);
jebradshaw 0:2bbb23558624 18 int unbcd(int bcd);
jebradshaw 0:2bbb23558624 19 void set_RTC_time(void);
jebradshaw 0:2bbb23558624 20 void get_RTC_time(char *str);
jebradshaw 0:2bbb23558624 21
jebradshaw 0:2bbb23558624 22 char *Day[];
jebradshaw 0:2bbb23558624 23 char *Mon[];
jebradshaw 0:2bbb23558624 24
jebradshaw 0:2bbb23558624 25 int rtc_sec;
jebradshaw 0:2bbb23558624 26 int rtc_minute;
jebradshaw 0:2bbb23558624 27 int rtc_hours;
jebradshaw 0:2bbb23558624 28 int rtc_day;
jebradshaw 0:2bbb23558624 29 int rtc_date;
jebradshaw 0:2bbb23558624 30 int rtc_month;
jebradshaw 0:2bbb23558624 31 int rtc_year;
jebradshaw 0:2bbb23558624 32
jebradshaw 0:2bbb23558624 33 private:
jebradshaw 0:2bbb23558624 34 I2C _i2c;
jebradshaw 0:2bbb23558624 35
jebradshaw 0:2bbb23558624 36 };
jebradshaw 0:2bbb23558624 37
jebradshaw 0:2bbb23558624 38 #endif /* DS1307_RTC_H */