Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: ard2pmod DS3231demo DS3231demo_COM_Port_Output MAXREFDES99_RTC_Display ... more
Revision 13:aa3eb69b25bb, committed 2015-03-17
- Comitter:
- j3
- Date:
- Tue Mar 17 00:34:36 2015 +0000
- Parent:
- 12:b9f13fd8c1b6
- Child:
- 14:11630748e2f2
- Commit message:
- moved enum and structs inside class
Changed in this revision
| ds3231.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/ds3231.h Thu Mar 12 19:36:30 2015 +0000
+++ b/ds3231.h Tue Mar 17 00:34:36 2015 +0000
@@ -78,143 +78,6 @@
#define BSY (1 << 2)
#define EN32KHZ (1 << 3)
#define OSF (1 << 7)
-
-/**
-* 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;
-
-
-/**
-* ds3231_time_t - Struct for containing time data.
-*
-* Members:
-*
-* - uint32_t seconds - Use decimal value. Member fx's convert to BCD
-*
-* - uint32_t minutes - Use decimal value. Member fx's convert to BCD
-*
-* - uint32_t hours - Use decimal value. Member fx's convert to BCD
-*
-* - bool am_pm - TRUE for PM, same logic as datasheet
-*
-* - bool mode - TRUE for 12 hour, same logic as datasheet
-*/
-typedef struct
-{
- uint32_t seconds;
- uint32_t minutes;
- uint32_t hours;
- bool am_pm;
- bool mode;
-}ds3231_time_t;
-
-
-/**
-* ds3231_calendar_t - Struct for containing calendar data.
-*
-* Members:
-*
-* - uint32_t day - Use decimal value. Member fx's convert to BCD
-*
-* - uint32_t date - Use decimal value. Member fx's convert to BCD
-*
-* - uint32_t month - Use decimal value. Member fx's convert to BCD
-*
-* - uint32_t year - Use decimal value. Member fx's convert to BCD
-*/
-typedef struct
-{
- uint32_t day;
- uint32_t date;
- uint32_t month;
- uint32_t year;
-}ds3231_calendar_t;
-
-
-/**
-* ds3231_alrm_t - Struct for containing alarm data.
-*
-* Members:
-*
-* - uint32_t seconds - Use decimal value. Member fx's convert to BCD
-*
-* - uint32_t minutes - Use decimal value. Member fx's convert to BCD
-*
-* - uint32_t hours - Use decimal value. Member fx's convert to BCD
-*
-* - uint32_t day - Use decimal value. Member fx's convert to BCD
-*
-* - uint32_t date - Use decimal value. Member fx's convert to BCD
-*
-* - bool am1 - Flag for setting alarm rate
-*
-* - bool am2 - Flag for setting alarm rate
-*
-* - bool am3 - Flag for setting alarm rate
-*
-* - bool am4 - Flag for setting alarm rate
-*
-* - bool am_pm - TRUE for PM, same logic as datasheet
-*
-* - bool mode - TRUE for 12 hour, same logic as datasheet
-*
-* - bool dy_dt - TRUE for Day, same logic as datasheet
-*/
-typedef struct
-{
- //Seconds and am1 not used for alarm2
- uint32_t seconds;
- uint32_t minutes;
- uint32_t hours;
- uint32_t day;
- uint32_t date;
- bool am1;
- bool am2;
- bool am3;
- bool am4;
- bool am_pm;
- bool mode;
- bool dy_dt;
-}ds3231_alrm_t;
-
-
-/**
-* 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;
/******************************************************************//**
@@ -250,6 +113,143 @@
uint8_t bcd_2_uchar(uint8_t bcd);
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;
+
+
+ /**
+ * ds3231_time_t - Struct for containing time data.
+ *
+ * Members:
+ *
+ * - uint32_t seconds - Use decimal value. Member fx's convert to BCD
+ *
+ * - uint32_t minutes - Use decimal value. Member fx's convert to BCD
+ *
+ * - uint32_t hours - Use decimal value. Member fx's convert to BCD
+ *
+ * - bool am_pm - TRUE for PM, same logic as datasheet
+ *
+ * - bool mode - TRUE for 12 hour, same logic as datasheet
+ */
+ typedef struct
+ {
+ uint32_t seconds;
+ uint32_t minutes;
+ uint32_t hours;
+ bool am_pm;
+ bool mode;
+ }ds3231_time_t;
+
+
+ /**
+ * ds3231_calendar_t - Struct for containing calendar data.
+ *
+ * Members:
+ *
+ * - uint32_t day - Use decimal value. Member fx's convert to BCD
+ *
+ * - uint32_t date - Use decimal value. Member fx's convert to BCD
+ *
+ * - uint32_t month - Use decimal value. Member fx's convert to BCD
+ *
+ * - uint32_t year - Use decimal value. Member fx's convert to BCD
+ */
+ typedef struct
+ {
+ uint32_t day;
+ uint32_t date;
+ uint32_t month;
+ uint32_t year;
+ }ds3231_calendar_t;
+
+
+ /**
+ * ds3231_alrm_t - Struct for containing alarm data.
+ *
+ * Members:
+ *
+ * - uint32_t seconds - Use decimal value. Member fx's convert to BCD
+ *
+ * - uint32_t minutes - Use decimal value. Member fx's convert to BCD
+ *
+ * - uint32_t hours - Use decimal value. Member fx's convert to BCD
+ *
+ * - uint32_t day - Use decimal value. Member fx's convert to BCD
+ *
+ * - uint32_t date - Use decimal value. Member fx's convert to BCD
+ *
+ * - bool am1 - Flag for setting alarm rate
+ *
+ * - bool am2 - Flag for setting alarm rate
+ *
+ * - bool am3 - Flag for setting alarm rate
+ *
+ * - bool am4 - Flag for setting alarm rate
+ *
+ * - bool am_pm - TRUE for PM, same logic as datasheet
+ *
+ * - bool mode - TRUE for 12 hour, same logic as datasheet
+ *
+ * - bool dy_dt - TRUE for Day, same logic as datasheet
+ */
+ typedef struct
+ {
+ //Seconds and am1 not used for alarm2
+ uint32_t seconds;
+ uint32_t minutes;
+ uint32_t hours;
+ uint32_t day;
+ uint32_t date;
+ bool am1;
+ bool am2;
+ bool am3;
+ bool am4;
+ bool am_pm;
+ bool mode;
+ bool dy_dt;
+ }ds3231_alrm_t;
+
+
+ /**
+ * 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;
/**********************************************************//**
* Constructor for Ds3231 Class
DS3231 Real Time Clock RTC Integrated Crystal, 2 Alarms, Extremely Accurate High Precision