DS3231

Dependents:   LoRa_Access_Point

Revision:
16:610f7091e0ac
Parent:
15:bf11392ccaea
--- a/DS3231.h	Thu Mar 28 09:55:44 2019 +0000
+++ b/DS3231.h	Sat May 08 16:13:55 2021 +0000
@@ -72,8 +72,13 @@
 #ifndef MBED_DS3231_H
 #define MBED_DS3231_H
 
+#define DS3231_I2C_ADRS 0x68 
+#define I2C_WRITE 0
+#define I2C_READ  1
+
 //DS3231 8 bit adress
 #define DS3231_Address          0xD0
+//#define DS3231_Address          0x68
 
 //DS3231 registers
 #define DS3231_Seconds          0x00
@@ -119,9 +124,52 @@
 #define DS3231_MSB_Temp         0x11
 #define DS3231_LSB_Temp         0x12
 
+/**
+* ds3231_cntl_stat_t - Struct for containing control and status 
+* register data.
+* 
+* Members:
+*
+* - uint8_t control - Binary data for read/write of control register 
+*
+* - uint8_t status  - Binary data  for read/write of status register 
+*/
+typedef struct
+{
+    uint8_t control; 
+    uint8_t status; 
+}ds3231_cntl_stat_t;
+
 /* Interface to MAXIM DS3231 RTC */
 class DS3231
     {public :
+    
+    /**
+        * ds3231_regs_t - enumerated DS3231 registers 
+        */
+        typedef enum
+        {
+            SECONDS,
+            MINUTES,
+            HOURS,
+            DAY,
+            DATE,
+            MONTH,
+            YEAR,
+            ALRM1_SECONDS,
+            ALRM1_MINUTES,
+            ALRM1_HOURS,
+            ALRM1_DAY_DATE,
+            ALRM2_MINUTES,
+            ALRM2_HOURS,
+            ALRM2_DAY_DATE,
+            CONTROL,
+            STATUS,
+            AGING_OFFSET, //don't touch this register
+            MSB_TEMP,
+            LSB_TEMP
+        }ds3231_regs_t;
+        
      /** Create an instance of the DS3231 connected to specfied I2C pins
      *
      * @param sda The I2C data pin
@@ -210,7 +258,10 @@
      
      bool error;
      
+     uint16_t set_cntl_stat_reg(ds3231_cntl_stat_t data);
+     
      private :
+     uint8_t w_adrs, r_adrs;
      I2C i2c;
      int bcd2dec(int k); // bcd to decimal conversion
      int dec2bcd(int k); // decimal to bcd conversion