Library for DS3231 RTC

Dependents:   ard2pmod DS3231demo DS3231demo_COM_Port_Output MAXREFDES99_RTC_Display ... more

DS3231 Component Page

Committer:
j3
Date:
Tue Nov 18 22:28:04 2014 +0000
Revision:
0:b00c4699ae6f
Child:
1:c814af60fdbf
initial commit, member fxs not defined yet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 0:b00c4699ae6f 1 /******************************************************************//**
j3 0:b00c4699ae6f 2 * @file ds3231.cpp
j3 0:b00c4699ae6f 3 *
j3 0:b00c4699ae6f 4 * @author Justin Jordan
j3 0:b00c4699ae6f 5 *
j3 0:b00c4699ae6f 6 * @version 0.0
j3 0:b00c4699ae6f 7 *
j3 0:b00c4699ae6f 8 * Started: 11NOV14
j3 0:b00c4699ae6f 9 *
j3 0:b00c4699ae6f 10 * Updated:
j3 0:b00c4699ae6f 11 *
j3 0:b00c4699ae6f 12 * @brief Source file for DS3231 class
j3 0:b00c4699ae6f 13 *
j3 0:b00c4699ae6f 14 ***********************************************************************
j3 0:b00c4699ae6f 15 *
j3 0:b00c4699ae6f 16 * @copyright
j3 0:b00c4699ae6f 17 * Copyright (C) 2013 Maxim Integrated Products, Inc., All Rights Reserved.
j3 0:b00c4699ae6f 18 *
j3 0:b00c4699ae6f 19 * Permission is hereby granted, free of charge, to any person obtaining a
j3 0:b00c4699ae6f 20 * copy of this software and associated documentation files (the "Software"),
j3 0:b00c4699ae6f 21 * to deal in the Software without restriction, including without limitation
j3 0:b00c4699ae6f 22 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 0:b00c4699ae6f 23 * and/or sell copies of the Software, and to permit persons to whom the
j3 0:b00c4699ae6f 24 * Software is furnished to do so, subject to the following conditions:
j3 0:b00c4699ae6f 25 *
j3 0:b00c4699ae6f 26 * The above copyright notice and this permission notice shall be included
j3 0:b00c4699ae6f 27 * in all copies or substantial portions of the Software.
j3 0:b00c4699ae6f 28 *
j3 0:b00c4699ae6f 29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 0:b00c4699ae6f 30 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 0:b00c4699ae6f 31 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 0:b00c4699ae6f 32 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 0:b00c4699ae6f 33 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 0:b00c4699ae6f 34 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 0:b00c4699ae6f 35 * OTHER DEALINGS IN THE SOFTWARE.
j3 0:b00c4699ae6f 36 *
j3 0:b00c4699ae6f 37 * Except as contained in this notice, the name of Maxim Integrated
j3 0:b00c4699ae6f 38 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 0:b00c4699ae6f 39 * Products, Inc. Branding Policy.
j3 0:b00c4699ae6f 40 *
j3 0:b00c4699ae6f 41 * The mere transfer of this software does not imply any licenses
j3 0:b00c4699ae6f 42 * of trade secrets, proprietary technology, copyrights, patents,
j3 0:b00c4699ae6f 43 * trademarks, maskwork rights, or any other form of intellectual
j3 0:b00c4699ae6f 44 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 0:b00c4699ae6f 45 * ownership rights.
j3 0:b00c4699ae6f 46 **********************************************************************/
j3 0:b00c4699ae6f 47
j3 0:b00c4699ae6f 48
j3 0:b00c4699ae6f 49 #include "ds3231.h"
j3 0:b00c4699ae6f 50
j3 0:b00c4699ae6f 51
j3 0:b00c4699ae6f 52 /**********************************************************//**
j3 0:b00c4699ae6f 53 * Constructor for Ds3231 Class
j3 0:b00c4699ae6f 54 *
j3 0:b00c4699ae6f 55 * On Entry:
j3 0:b00c4699ae6f 56 * @param[in] p_i2c - pointer to I2C object for bus
j3 0:b00c4699ae6f 57 *
j3 0:b00c4699ae6f 58 * On Exit:
j3 0:b00c4699ae6f 59 * @return none
j3 0:b00c4699ae6f 60 *
j3 0:b00c4699ae6f 61 * Example:
j3 0:b00c4699ae6f 62 * @code
j3 0:b00c4699ae6f 63 *
j3 0:b00c4699ae6f 64 * I2C i2c_bus(D14, D15); //instantiate I2C bus
j3 0:b00c4699ae6f 65 * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus
j3 0:b00c4699ae6f 66 *
j3 0:b00c4699ae6f 67 * //instantiate rtc object
j3 0:b00c4699ae6f 68 * Ds3231 rtc(p_i2c_bus);
j3 0:b00c4699ae6f 69 *
j3 0:b00c4699ae6f 70 * @endcode
j3 0:b00c4699ae6f 71 **************************************************************/
j3 0:b00c4699ae6f 72 Ds3231::Ds3231(I2C* ptr_i2c_bus)
j3 0:b00c4699ae6f 73 {
j3 0:b00c4699ae6f 74 p_i2c = ptr_i2c_bus;
j3 0:b00c4699ae6f 75 w_adrs = ((DS3231_I2C_ADRS << 1) | I2C_WRITE);
j3 0:b00c4699ae6f 76 r_adrs = ((DS3231_I2C_ADRS << 1) | I2C_READ);
j3 0:b00c4699ae6f 77 }
j3 0:b00c4699ae6f 78
j3 0:b00c4699ae6f 79
j3 0:b00c4699ae6f 80 /**********************************************************//**
j3 0:b00c4699ae6f 81 * Sets the time on DS3231
j3 0:b00c4699ae6f 82 *
j3 0:b00c4699ae6f 83 * On Entry:
j3 0:b00c4699ae6f 84 * @param[in] time - struct cotaining time data;
j3 0:b00c4699ae6f 85 * seconds, minutes and hours
j3 0:b00c4699ae6f 86 *
j3 0:b00c4699ae6f 87 * On Exit:
j3 0:b00c4699ae6f 88 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 89 *
j3 0:b00c4699ae6f 90 * Example:
j3 0:b00c4699ae6f 91 * @code
j3 0:b00c4699ae6f 92 *
j3 0:b00c4699ae6f 93 * I2C i2c_bus(D14, D15); //instantiate I2C bus
j3 0:b00c4699ae6f 94 * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus
j3 0:b00c4699ae6f 95 *
j3 0:b00c4699ae6f 96 * //instantiate rtc object
j3 0:b00c4699ae6f 97 * Ds3231 rtc(p_i2c_bus);
j3 0:b00c4699ae6f 98 *
j3 0:b00c4699ae6f 99 * ds3231_time_t time = {0, 0, 0} // time = 0:0:0 24hr format
j3 0:b00c4699ae6f 100 * uint16_t rtn_val;
j3 0:b00c4699ae6f 101 *
j3 0:b00c4699ae6f 102 * rtn_val = rtc.set_time(time);
j3 0:b00c4699ae6f 103 *
j3 0:b00c4699ae6f 104 * @endcode
j3 0:b00c4699ae6f 105 **************************************************************/
j3 0:b00c4699ae6f 106 uint16_t Ds3231::set_time(ds3231_time_t time)
j3 0:b00c4699ae6f 107 {
j3 0:b00c4699ae6f 108
j3 0:b00c4699ae6f 109 return 0;
j3 0:b00c4699ae6f 110 }
j3 0:b00c4699ae6f 111
j3 0:b00c4699ae6f 112
j3 0:b00c4699ae6f 113 /**********************************************************//**
j3 0:b00c4699ae6f 114 * Sets the calendar on DS3231
j3 0:b00c4699ae6f 115 *
j3 0:b00c4699ae6f 116 * On Entry:
j3 0:b00c4699ae6f 117 * @param[in] calendar - struct cotaining calendar data;
j3 0:b00c4699ae6f 118 * day, date, month, year
j3 0:b00c4699ae6f 119 *
j3 0:b00c4699ae6f 120 * On Exit:
j3 0:b00c4699ae6f 121 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 122 *
j3 0:b00c4699ae6f 123 * Example:
j3 0:b00c4699ae6f 124 * @code
j3 0:b00c4699ae6f 125 *
j3 0:b00c4699ae6f 126 * I2C i2c_bus(D14, D15); //instantiate I2C bus
j3 0:b00c4699ae6f 127 * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus
j3 0:b00c4699ae6f 128 *
j3 0:b00c4699ae6f 129 * //instantiate rtc object
j3 0:b00c4699ae6f 130 * Ds3231 rtc(p_i2c_bus);
j3 0:b00c4699ae6f 131 *
j3 0:b00c4699ae6f 132 * //see datasheet for calendar format
j3 0:b00c4699ae6f 133 * ds3231_calendar_t calendar = {1, 1, 1, 0};
j3 0:b00c4699ae6f 134 * uint16_t rtn_val;
j3 0:b00c4699ae6f 135 *
j3 0:b00c4699ae6f 136 * rtn_val = rtc.set_calendar(calendar);
j3 0:b00c4699ae6f 137 *
j3 0:b00c4699ae6f 138 * @endcode
j3 0:b00c4699ae6f 139 **************************************************************/
j3 0:b00c4699ae6f 140 uint16_t Ds3231::set_calendar(ds3231_calendar_t calendar)
j3 0:b00c4699ae6f 141 {
j3 0:b00c4699ae6f 142
j3 0:b00c4699ae6f 143 return 0;
j3 0:b00c4699ae6f 144 }
j3 0:b00c4699ae6f 145
j3 0:b00c4699ae6f 146
j3 0:b00c4699ae6f 147 /**********************************************************//**
j3 0:b00c4699ae6f 148 * Set either Alarm1 or Alarm2 of DS3231
j3 0:b00c4699ae6f 149 *
j3 0:b00c4699ae6f 150 * On Entry:
j3 0:b00c4699ae6f 151 * @param[in] alarm - struct cotaining alarm data
j3 0:b00c4699ae6f 152 * seconds, minutes, hours, day, date
j3 0:b00c4699ae6f 153 * seconds used on Alarm1 only
j3 0:b00c4699ae6f 154 * @param[in] one_r_two - TRUE for Alarm1 and FALSE for
j3 0:b00c4699ae6f 155 * Alarm2
j3 0:b00c4699ae6f 156 *
j3 0:b00c4699ae6f 157 * On Exit:
j3 0:b00c4699ae6f 158 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 159 *
j3 0:b00c4699ae6f 160 * Example:
j3 0:b00c4699ae6f 161 * @code
j3 0:b00c4699ae6f 162 *
j3 0:b00c4699ae6f 163 * I2C i2c_bus(D14, D15); //instantiate I2C bus
j3 0:b00c4699ae6f 164 * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus
j3 0:b00c4699ae6f 165 *
j3 0:b00c4699ae6f 166 * //instantiate rtc object
j3 0:b00c4699ae6f 167 * Ds3231 rtc(p_i2c_bus);
j3 0:b00c4699ae6f 168 *
j3 0:b00c4699ae6f 169 * //see datasheet for alarm format
j3 0:b00c4699ae6f 170 * ds3231_alrm_t alarm = {0, 0, 0, 0, 0};
j3 0:b00c4699ae6f 171 * uint16_t rtn_val;
j3 0:b00c4699ae6f 172 *
j3 0:b00c4699ae6f 173 * rtn_val = rtc.set_alarm(alarm, FALSE);
j3 0:b00c4699ae6f 174 *
j3 0:b00c4699ae6f 175 * @endcode
j3 0:b00c4699ae6f 176 **************************************************************/
j3 0:b00c4699ae6f 177 uint16_t Ds3231::set_alarm(ds3231_alrm_t alarm, bool one_r_two)
j3 0:b00c4699ae6f 178 {
j3 0:b00c4699ae6f 179
j3 0:b00c4699ae6f 180 return 0;
j3 0:b00c4699ae6f 181 }
j3 0:b00c4699ae6f 182
j3 0:b00c4699ae6f 183
j3 0:b00c4699ae6f 184 /**********************************************************//**
j3 0:b00c4699ae6f 185 * Set control and status registers of DS3231
j3 0:b00c4699ae6f 186 *
j3 0:b00c4699ae6f 187 * On Entry:
j3 0:b00c4699ae6f 188 * @param[in] data - Struct containing control and status
j3 0:b00c4699ae6f 189 * register data
j3 0:b00c4699ae6f 190 *
j3 0:b00c4699ae6f 191 * On Exit:
j3 0:b00c4699ae6f 192 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 193 *
j3 0:b00c4699ae6f 194 * Example:
j3 0:b00c4699ae6f 195 * @code
j3 0:b00c4699ae6f 196 *
j3 0:b00c4699ae6f 197 * I2C i2c_bus(D14, D15); //instantiate I2C bus
j3 0:b00c4699ae6f 198 * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus
j3 0:b00c4699ae6f 199 *
j3 0:b00c4699ae6f 200 * //instantiate rtc object
j3 0:b00c4699ae6f 201 * Ds3231 rtc(p_i2c_bus);
j3 0:b00c4699ae6f 202 *
j3 0:b00c4699ae6f 203 * //do not use 0xAA, see datasheet for appropriate data
j3 0:b00c4699ae6f 204 * ds3231_cntl_stat_t data = {0xAA, 0xAA};
j3 0:b00c4699ae6f 205 *
j3 0:b00c4699ae6f 206 * rtn_val = rtc.set_cntl_stat_reg(data);
j3 0:b00c4699ae6f 207 *
j3 0:b00c4699ae6f 208 * @endcode
j3 0:b00c4699ae6f 209 **************************************************************/
j3 0:b00c4699ae6f 210 uint16_t Ds3231::set_cntl_stat_reg(ds3231_cntl_stat_t data)
j3 0:b00c4699ae6f 211 {
j3 0:b00c4699ae6f 212
j3 0:b00c4699ae6f 213 return 0;
j3 0:b00c4699ae6f 214 }
j3 0:b00c4699ae6f 215
j3 0:b00c4699ae6f 216
j3 0:b00c4699ae6f 217 /**********************************************************//**
j3 0:b00c4699ae6f 218 * Gets the time on DS3231
j3 0:b00c4699ae6f 219 *
j3 0:b00c4699ae6f 220 * On Entry:
j3 0:b00c4699ae6f 221 * @param[in] time - struct for storing time data;
j3 0:b00c4699ae6f 222 * seconds, minutes and hours
j3 0:b00c4699ae6f 223 *
j3 0:b00c4699ae6f 224 * On Exit:
j3 0:b00c4699ae6f 225 * @param[out] time - contains current rtc time data
j3 0:b00c4699ae6f 226 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 227 *
j3 0:b00c4699ae6f 228 * Example:
j3 0:b00c4699ae6f 229 * @code
j3 0:b00c4699ae6f 230 *
j3 0:b00c4699ae6f 231 * I2C i2c_bus(D14, D15); //instantiate I2C bus
j3 0:b00c4699ae6f 232 * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus
j3 0:b00c4699ae6f 233 *
j3 0:b00c4699ae6f 234 * //instantiate rtc object
j3 0:b00c4699ae6f 235 * Ds3231 rtc(p_i2c_bus);
j3 0:b00c4699ae6f 236 *
j3 0:b00c4699ae6f 237 * ds3231_time_t time = {0, 0, 0} // time = 0:0:0 24hr format
j3 0:b00c4699ae6f 238 * uint16_t rtn_val;
j3 0:b00c4699ae6f 239 *
j3 0:b00c4699ae6f 240 * rtn_val = rtc.get_time(time);
j3 0:b00c4699ae6f 241 *
j3 0:b00c4699ae6f 242 * @endcode
j3 0:b00c4699ae6f 243 **************************************************************/
j3 0:b00c4699ae6f 244 uint16_t Ds3231::get_time(ds3231_time_t time)
j3 0:b00c4699ae6f 245 {
j3 0:b00c4699ae6f 246
j3 0:b00c4699ae6f 247 return 0;
j3 0:b00c4699ae6f 248 }
j3 0:b00c4699ae6f 249
j3 0:b00c4699ae6f 250
j3 0:b00c4699ae6f 251 /**********************************************************//**
j3 0:b00c4699ae6f 252 * Gets the calendar on DS3231
j3 0:b00c4699ae6f 253 *
j3 0:b00c4699ae6f 254 * On Entry:
j3 0:b00c4699ae6f 255 * @param[in] calendar - struct for storing calendar data;
j3 0:b00c4699ae6f 256 * day, date, month, year
j3 0:b00c4699ae6f 257 *
j3 0:b00c4699ae6f 258 * On Exit:
j3 0:b00c4699ae6f 259 * @param[out] calendar - contains current rtc calendar
j3 0:b00c4699ae6f 260 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 261 *
j3 0:b00c4699ae6f 262 * Example:
j3 0:b00c4699ae6f 263 * @code
j3 0:b00c4699ae6f 264 *
j3 0:b00c4699ae6f 265 * I2C i2c_bus(D14, D15); //instantiate I2C bus
j3 0:b00c4699ae6f 266 * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus
j3 0:b00c4699ae6f 267 *
j3 0:b00c4699ae6f 268 * //instantiate rtc object
j3 0:b00c4699ae6f 269 * Ds3231 rtc(p_i2c_bus);
j3 0:b00c4699ae6f 270 *
j3 0:b00c4699ae6f 271 * //see datasheet for calendar format
j3 0:b00c4699ae6f 272 * ds3231_calendar_t calendar = {1, 1, 1, 0};
j3 0:b00c4699ae6f 273 * uint16_t rtn_val;
j3 0:b00c4699ae6f 274 *
j3 0:b00c4699ae6f 275 * rtn_val = rtc.get_calendar(calendar);
j3 0:b00c4699ae6f 276 *
j3 0:b00c4699ae6f 277 * @endcode
j3 0:b00c4699ae6f 278 **************************************************************/
j3 0:b00c4699ae6f 279 uint16_t Ds3231::get_calendar(ds3231_calendar_t calendar)
j3 0:b00c4699ae6f 280 {
j3 0:b00c4699ae6f 281
j3 0:b00c4699ae6f 282 return 0;
j3 0:b00c4699ae6f 283 }
j3 0:b00c4699ae6f 284
j3 0:b00c4699ae6f 285
j3 0:b00c4699ae6f 286 /**********************************************************//**
j3 0:b00c4699ae6f 287 * Get either Alarm1 or Alarm2 of DS3231
j3 0:b00c4699ae6f 288 *
j3 0:b00c4699ae6f 289 * On Entry:
j3 0:b00c4699ae6f 290 * @param[in] alarm - struct for storing alarm data
j3 0:b00c4699ae6f 291 * seconds, minutes, hours, day, date
j3 0:b00c4699ae6f 292 * seconds used on Alarm1 only
j3 0:b00c4699ae6f 293 * @param[in] one_r_two - TRUE for Alarm1 and FALSE for
j3 0:b00c4699ae6f 294 * Alarm2
j3 0:b00c4699ae6f 295 *
j3 0:b00c4699ae6f 296 * On Exit:
j3 0:b00c4699ae6f 297 * @param[out] alarm - contains alarm register data
j3 0:b00c4699ae6f 298 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 299 *
j3 0:b00c4699ae6f 300 * Example:
j3 0:b00c4699ae6f 301 * @code
j3 0:b00c4699ae6f 302 *
j3 0:b00c4699ae6f 303 * I2C i2c_bus(D14, D15); //instantiate I2C bus
j3 0:b00c4699ae6f 304 * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus
j3 0:b00c4699ae6f 305 *
j3 0:b00c4699ae6f 306 * //instantiate rtc object
j3 0:b00c4699ae6f 307 * Ds3231 rtc(p_i2c_bus);
j3 0:b00c4699ae6f 308 *
j3 0:b00c4699ae6f 309 * //see datasheet for alarm format
j3 0:b00c4699ae6f 310 * ds3231_alrm_t alarm = {0, 0, 0, 0, 0};
j3 0:b00c4699ae6f 311 * uint16_t rtn_val;
j3 0:b00c4699ae6f 312 *
j3 0:b00c4699ae6f 313 * rtn_val = rtc.get_alarm(alarm, FALSE);
j3 0:b00c4699ae6f 314 *
j3 0:b00c4699ae6f 315 * @endcode
j3 0:b00c4699ae6f 316 **************************************************************/
j3 0:b00c4699ae6f 317 uint16_t Ds3231::get_alarm(ds3231_alrm_t alarm, bool one_r_two)
j3 0:b00c4699ae6f 318 {
j3 0:b00c4699ae6f 319
j3 0:b00c4699ae6f 320 return 0;
j3 0:b00c4699ae6f 321 }
j3 0:b00c4699ae6f 322
j3 0:b00c4699ae6f 323
j3 0:b00c4699ae6f 324 /**********************************************************//**
j3 0:b00c4699ae6f 325 * Get control and status registers of DS3231
j3 0:b00c4699ae6f 326 *
j3 0:b00c4699ae6f 327 * On Entry:
j3 0:b00c4699ae6f 328 * @param[in] data - Struct for storing control and status
j3 0:b00c4699ae6f 329 * register data
j3 0:b00c4699ae6f 330 *
j3 0:b00c4699ae6f 331 * On Exit:
j3 0:b00c4699ae6f 332 * @param[out] data - contains control and status registers
j3 0:b00c4699ae6f 333 * data
j3 0:b00c4699ae6f 334 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 335 *
j3 0:b00c4699ae6f 336 * Example:
j3 0:b00c4699ae6f 337 * @code
j3 0:b00c4699ae6f 338 *
j3 0:b00c4699ae6f 339 * I2C i2c_bus(D14, D15); //instantiate I2C bus
j3 0:b00c4699ae6f 340 * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus
j3 0:b00c4699ae6f 341 *
j3 0:b00c4699ae6f 342 * //instantiate rtc object
j3 0:b00c4699ae6f 343 * Ds3231 rtc(p_i2c_bus);
j3 0:b00c4699ae6f 344 *
j3 0:b00c4699ae6f 345 * //do not use 0xAA, see datasheet for appropriate data
j3 0:b00c4699ae6f 346 * ds3231_cntl_stat_t data = {0xAA, 0xAA};
j3 0:b00c4699ae6f 347 *
j3 0:b00c4699ae6f 348 * rtn_val = rtc.get_cntl_stat_reg(data);
j3 0:b00c4699ae6f 349 *
j3 0:b00c4699ae6f 350 * @endcode
j3 0:b00c4699ae6f 351 **************************************************************/
j3 0:b00c4699ae6f 352 uint16_t Ds3231::get_cntl_stat_reg(ds3231_cntl_stat_t data)
j3 0:b00c4699ae6f 353 {
j3 0:b00c4699ae6f 354
j3 0:b00c4699ae6f 355 return 0;
j3 0:b00c4699ae6f 356 }
j3 0:b00c4699ae6f 357
j3 0:b00c4699ae6f 358
j3 0:b00c4699ae6f 359 /**********************************************************//**
j3 0:b00c4699ae6f 360 * Get temperature data of DS3231
j3 0:b00c4699ae6f 361 *
j3 0:b00c4699ae6f 362 * On Entry:
j3 0:b00c4699ae6f 363 * @param[in] temp - Integer for storing temperature data
j3 0:b00c4699ae6f 364 *
j3 0:b00c4699ae6f 365 * On Exit:
j3 0:b00c4699ae6f 366 * @param[out] temp - contains temperature data
j3 0:b00c4699ae6f 367 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 368 *
j3 0:b00c4699ae6f 369 * Example:
j3 0:b00c4699ae6f 370 * @code
j3 0:b00c4699ae6f 371 *
j3 0:b00c4699ae6f 372 * I2C i2c_bus(D14, D15); //instantiate I2C bus
j3 0:b00c4699ae6f 373 * I2C * p_i2c_bus = &i2c_bus; //create pointer to bus
j3 0:b00c4699ae6f 374 *
j3 0:b00c4699ae6f 375 * //instantiate rtc object
j3 0:b00c4699ae6f 376 * Ds3231 rtc(p_i2c_bus);
j3 0:b00c4699ae6f 377 *
j3 0:b00c4699ae6f 378 * //do not use 0xAA, see datasheet for appropriate data
j3 0:b00c4699ae6f 379 * uint16_t temp;
j3 0:b00c4699ae6f 380 *
j3 0:b00c4699ae6f 381 * rtn_val = rtc.get_temperature(data);
j3 0:b00c4699ae6f 382 *
j3 0:b00c4699ae6f 383 * @endcode
j3 0:b00c4699ae6f 384 **************************************************************/
j3 0:b00c4699ae6f 385 uint16_t Ds3231::get_temperature(uint16_t temp)
j3 0:b00c4699ae6f 386 {
j3 0:b00c4699ae6f 387
j3 0:b00c4699ae6f 388 return 0;
j3 0:b00c4699ae6f 389 }
j3 0:b00c4699ae6f 390