Fork of Ds3231 library that replaces inheritance of I2C class with a private member var of type I2C *
Dependents: ard2pmod DS3231_Alarm_Demo MAXREFDES130_131_Demo MAXREFDES130_Demo
Fork of ds3231 by
Diff: ds3231.h
- Revision:
- 14:11630748e2f2
- Parent:
- 13:aa3eb69b25bb
- Child:
- 15:16ca4c747252
diff -r aa3eb69b25bb -r 11630748e2f2 ds3231.h --- a/ds3231.h Tue Mar 17 00:34:36 2015 +0000 +++ b/ds3231.h Wed Mar 18 00:06:59 2015 +0000 @@ -79,7 +79,118 @@ #define EN32KHZ (1 << 3) #define OSF (1 << 7) + +/** +* 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; + /******************************************************************//** * Ds3231 Class **********************************************************************/ @@ -139,117 +250,7 @@ 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