RTC Driver

Committer:
sk398
Date:
Sat Feb 20 13:32:01 2016 +0000
Revision:
0:4399479f355f
Initial commit.; ; Much work still needs done to interface the DS3231 correctly. ; ; I2C read/write functions work

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sk398 0:4399479f355f 1 #ifndef DS3231_H
sk398 0:4399479f355f 2 #define DS3231_H
sk398 0:4399479f355f 3
sk398 0:4399479f355f 4 #define TRUE 1
sk398 0:4399479f355f 5 #define FALSE 0
sk398 0:4399479f355f 6
sk398 0:4399479f355f 7 #define SINGLE_BYTE 1
sk398 0:4399479f355f 8
sk398 0:4399479f355f 9 #define DS3231_ADDRESS 0x68<<1/*0xAE*/
sk398 0:4399479f355f 10
sk398 0:4399479f355f 11 #define SECONDS 0x00
sk398 0:4399479f355f 12 #define MINUTES 0x01
sk398 0:4399479f355f 13 #define HOURS 0x02
sk398 0:4399479f355f 14 #define DAY 0x03
sk398 0:4399479f355f 15 #define DATE 0x04
sk398 0:4399479f355f 16 #define MONTH_CENTURY 0x05
sk398 0:4399479f355f 17 #define YEAR 0x06
sk398 0:4399479f355f 18
sk398 0:4399479f355f 19 #define ALARM_1_SECONDS 0x07
sk398 0:4399479f355f 20 #define ALARM_1_MINUTES 0x08
sk398 0:4399479f355f 21 #define ALARM_1_HOURS 0x09
sk398 0:4399479f355f 22 #define ALARM_1_DAY_DATE 0x0A
sk398 0:4399479f355f 23 #define ALARM_2_MINUTES 0x0B
sk398 0:4399479f355f 24 #define ALARM_2_HOURS 0x0C
sk398 0:4399479f355f 25 #define ALARM_2_DAY_DATE 0x0D
sk398 0:4399479f355f 26
sk398 0:4399479f355f 27 #define CONTROL 0x0E
sk398 0:4399479f355f 28 #define CONTROL_STATUS 0x0F
sk398 0:4399479f355f 29
sk398 0:4399479f355f 30 #define AGING_OFFSET 0x10
sk398 0:4399479f355f 31
sk398 0:4399479f355f 32 #define MSB_OF_TEMP 0x11
sk398 0:4399479f355f 33 #define LSB_OF_TEMP 0x12
sk398 0:4399479f355f 34
sk398 0:4399479f355f 35
sk398 0:4399479f355f 36
sk398 0:4399479f355f 37 class DS3231
sk398 0:4399479f355f 38 {
sk398 0:4399479f355f 39 public:
sk398 0:4399479f355f 40 DS3231(PinName sda, PinName scl);
sk398 0:4399479f355f 41 void readControl();
sk398 0:4399479f355f 42 private:
sk398 0:4399479f355f 43 int readByte(uint8_t registerAddress);
sk398 0:4399479f355f 44 int *readBytes(uint8_t registerAddress,uint8_t numBytes);
sk398 0:4399479f355f 45 int writeByte(uint8_t registerAddress,uint8_t outBuffer);
sk398 0:4399479f355f 46 // int writeBytes(uint8_t registerAddress, uint8_t *outBuffer,uint8_t numBytes);
sk398 0:4399479f355f 47
sk398 0:4399479f355f 48 protected:
sk398 0:4399479f355f 49
sk398 0:4399479f355f 50 I2C *_DS3231;
sk398 0:4399479f355f 51
sk398 0:4399479f355f 52
sk398 0:4399479f355f 53 };
sk398 0:4399479f355f 54
sk398 0:4399479f355f 55 #endif