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:
- 1:c814af60fdbf
- Parent:
- 0:b00c4699ae6f
- Child:
- 2:4e6e761c60f2
--- a/ds3231.h Tue Nov 18 22:28:04 2014 +0000 +++ b/ds3231.h Wed Nov 19 04:16:33 2014 +0000 @@ -140,10 +140,8 @@ /******************************************************************//** * Ds3231 Class **********************************************************************/ -class Ds3231 +class Ds3231 : public I2C { - //private members - I2C* p_i2c; uint8_t w_adrs, r_adrs; public: @@ -151,7 +149,8 @@ * Constructor for Ds3231 Class * * On Entry: - * @param[in] p_i2c - pointer to I2C object for bus + * @param[in] sda - sda pin of I2C bus + * @param[in] scl - scl pin of I2C bus * * On Exit: * @return none @@ -159,15 +158,12 @@ * Example: * @code * - * I2C i2c_bus(D14, D15); //instantiate I2C bus - * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus - * * //instantiate rtc object - * Ds3231 rtc(p_i2c_bus); + * Ds3231 rtc(D14, D15); * * @endcode **************************************************************/ - Ds3231(I2C* ptr_i2c_bus); + Ds3231(PinName sda, PinName scl); /**********************************************************//** @@ -183,11 +179,8 @@ * Example: * @code * - * I2C i2c_bus(D14, D15); //instantiate I2C bus - * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus - * * //instantiate rtc object - * Ds3231 rtc(p_i2c_bus); + * Ds3231 rtc(D14, D15); * * ds3231_time_t time = {0, 0, 0} // time = 0:0:0 24hr format * uint16_t rtn_val; @@ -212,11 +205,8 @@ * Example: * @code * - * I2C i2c_bus(D14, D15); //instantiate I2C bus - * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus - * * //instantiate rtc object - * Ds3231 rtc(p_i2c_bus); + * Ds3231 rtc(D14, D15); * * //see datasheet for calendar format * ds3231_calendar_t calendar = {1, 1, 1, 0}; @@ -245,11 +235,8 @@ * Example: * @code * - * I2C i2c_bus(D14, D15); //instantiate I2C bus - * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus - * * //instantiate rtc object - * Ds3231 rtc(p_i2c_bus); + * Ds3231 rtc(D14, D15); * * //see datasheet for alarm format * ds3231_alrm_t alarm = {0, 0, 0, 0, 0}; @@ -275,11 +262,8 @@ * Example: * @code * - * I2C i2c_bus(D14, D15); //instantiate I2C bus - * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus - * * //instantiate rtc object - * Ds3231 rtc(p_i2c_bus); + * Ds3231 rtc(D14, D15); * * //do not use 0xAA, see datasheet for appropriate data * ds3231_cntl_stat_t data = {0xAA, 0xAA}; @@ -305,11 +289,8 @@ * Example: * @code * - * I2C i2c_bus(D14, D15); //instantiate I2C bus - * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus - * * //instantiate rtc object - * Ds3231 rtc(p_i2c_bus); + * Ds3231 rtc(D14, D15); * * ds3231_time_t time = {0, 0, 0} // time = 0:0:0 24hr format * uint16_t rtn_val; @@ -335,11 +316,8 @@ * Example: * @code * - * I2C i2c_bus(D14, D15); //instantiate I2C bus - * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus - * * //instantiate rtc object - * Ds3231 rtc(p_i2c_bus); + * Ds3231 rtc(D14, D15); * * //see datasheet for calendar format * ds3231_calendar_t calendar = {1, 1, 1, 0}; @@ -369,11 +347,8 @@ * Example: * @code * - * I2C i2c_bus(D14, D15); //instantiate I2C bus - * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus - * * //instantiate rtc object - * Ds3231 rtc(p_i2c_bus); + * Ds3231 rtc(D14, D15); * * //see datasheet for alarm format * ds3231_alrm_t alarm = {0, 0, 0, 0, 0}; @@ -401,11 +376,8 @@ * Example: * @code * - * I2C i2c_bus(D14, D15); //instantiate I2C bus - * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus - * * //instantiate rtc object - * Ds3231 rtc(p_i2c_bus); + * Ds3231 rtc(D14, D15); * * //do not use 0xAA, see datasheet for appropriate data * ds3231_cntl_stat_t data = {0xAA, 0xAA}; @@ -430,16 +402,13 @@ * Example: * @code * - * I2C i2c_bus(D14, D15); //instantiate I2C bus - * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus - * * //instantiate rtc object - * Ds3231 rtc(p_i2c_bus); + * Ds3231 rtc(D14, D15); * * //do not use 0xAA, see datasheet for appropriate data * uint16_t temp; * - * rtn_val = rtc.get_temperature(data); + * rtn_val = rtc.get_temperature(temp); * * @endcode **************************************************************/