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

Committer:
jebradshaw
Date:
Sat Nov 01 14:56:37 2014 +0000
Revision:
2:a9a0784930bd
Parent:
1:95a90bac5d6d
Still need to implement arrays for day and month names

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 1:95a90bac5d6d 20 void set_RTC_time_UTC(float utc_time, int timezone);
jebradshaw 0:2bbb23558624 21 void get_RTC_time(char *str);
jebradshaw 0:2bbb23558624 22
jebradshaw 2:a9a0784930bd 23 // char *Day[];
jebradshaw 2:a9a0784930bd 24 // char *Mon[];
jebradshaw 0:2bbb23558624 25
jebradshaw 0:2bbb23558624 26 int rtc_sec;
jebradshaw 0:2bbb23558624 27 int rtc_minute;
jebradshaw 0:2bbb23558624 28 int rtc_hours;
jebradshaw 0:2bbb23558624 29 int rtc_day;
jebradshaw 0:2bbb23558624 30 int rtc_date;
jebradshaw 0:2bbb23558624 31 int rtc_month;
jebradshaw 0:2bbb23558624 32 int rtc_year;
jebradshaw 0:2bbb23558624 33
jebradshaw 0:2bbb23558624 34 private:
jebradshaw 0:2bbb23558624 35 I2C _i2c;
jebradshaw 0:2bbb23558624 36
jebradshaw 0:2bbb23558624 37 };
jebradshaw 0:2bbb23558624 38
jebradshaw 0:2bbb23558624 39 #endif /* DS1307_RTC_H */