j

Dependents:   LPC-SD-35

Fork of ds3231 by Maxim Integrated

Committer:
j3
Date:
Thu Nov 20 00:03:27 2014 +0000
Revision:
2:4e6e761c60f2
Parent:
1:c814af60fdbf
Child:
3:312589d8185c
initial implementation of member functions

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 0:b00c4699ae6f 1 /******************************************************************//**
j3 0:b00c4699ae6f 2 * @file ds3231.h
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 Header 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 #ifndef DS3231_H
j3 0:b00c4699ae6f 50 #define DS3231_H
j3 0:b00c4699ae6f 51
j3 0:b00c4699ae6f 52
j3 0:b00c4699ae6f 53 #include "mbed.h"
j3 0:b00c4699ae6f 54
j3 0:b00c4699ae6f 55
j3 0:b00c4699ae6f 56 #define DS3231_I2C_ADRS 0x68 //7bit, shift left 1 and 'OR' with R/W bit
j3 0:b00c4699ae6f 57 #define I2C_WRITE 0
j3 0:b00c4699ae6f 58 #define I2C_READ 1
j3 0:b00c4699ae6f 59
j3 2:4e6e761c60f2 60 #define AM_PM (1 << 5)
j3 2:4e6e761c60f2 61 #define MODE (1 << 6)
j3 2:4e6e761c60f2 62 #define DY_DT (1 << 6)
j3 2:4e6e761c60f2 63 #define ALRM_MASK (1 << 7)
j3 0:b00c4699ae6f 64
j3 0:b00c4699ae6f 65 //control register bit masks
j3 0:b00c4699ae6f 66 #define A1IE (1 << 0)
j3 0:b00c4699ae6f 67 #define A2IE (1 << 1)
j3 0:b00c4699ae6f 68 #define INTCN (1 << 2)
j3 0:b00c4699ae6f 69 #define RS1 (1 << 3)
j3 0:b00c4699ae6f 70 #define RS2 (1 << 4)
j3 0:b00c4699ae6f 71 #define CONV (1 << 5)
j3 0:b00c4699ae6f 72 #define BBSQW (1 << 6)
j3 2:4e6e761c60f2 73 #define EOSC (1 << 7)
j3 0:b00c4699ae6f 74
j3 0:b00c4699ae6f 75 //status register bit masks
j3 0:b00c4699ae6f 76 #define A1F (1 << 0)
j3 0:b00c4699ae6f 77 #define A2F (1 << 1)
j3 0:b00c4699ae6f 78 #define BSY (1 << 2)
j3 0:b00c4699ae6f 79 #define EN32KHZ (1 << 3)
j3 0:b00c4699ae6f 80 #define OSF (1 << 7)
j3 0:b00c4699ae6f 81
j3 0:b00c4699ae6f 82
j3 0:b00c4699ae6f 83 typedef enum
j3 0:b00c4699ae6f 84 {
j3 0:b00c4699ae6f 85 SECONDS,
j3 0:b00c4699ae6f 86 MINUTES,
j3 0:b00c4699ae6f 87 HOURS,
j3 0:b00c4699ae6f 88 DAY,
j3 0:b00c4699ae6f 89 DATE,
j3 0:b00c4699ae6f 90 MONTH,
j3 0:b00c4699ae6f 91 YEAR,
j3 0:b00c4699ae6f 92 ALRM1_SECONDS,
j3 0:b00c4699ae6f 93 ALRM1_MINUTES,
j3 0:b00c4699ae6f 94 ALRM1_HOURS,
j3 0:b00c4699ae6f 95 ALRM1_DAY_DATE,
j3 0:b00c4699ae6f 96 ALRM2_MINUTES,
j3 0:b00c4699ae6f 97 ALRM2_HOURS,
j3 0:b00c4699ae6f 98 ALRM2_DAY_DATE,
j3 0:b00c4699ae6f 99 CONTROL,
j3 0:b00c4699ae6f 100 STATUS,
j3 0:b00c4699ae6f 101 AGING_OFFSET, //don't touch this register
j3 0:b00c4699ae6f 102 MSB_TEMP,
j3 0:b00c4699ae6f 103 LSB_TEMP
j3 0:b00c4699ae6f 104 }ds3231_regs_t;
j3 0:b00c4699ae6f 105
j3 0:b00c4699ae6f 106
j3 0:b00c4699ae6f 107 typedef struct
j3 0:b00c4699ae6f 108 {
j3 0:b00c4699ae6f 109 uint8_t seconds;
j3 0:b00c4699ae6f 110 uint8_t minutes;
j3 0:b00c4699ae6f 111 uint8_t hours;
j3 2:4e6e761c60f2 112 bool am_pm; //TRUE for PM, same logic as datasheet
j3 2:4e6e761c60f2 113 bool mode; //TRUE for 12 hour, same logic as datasheet
j3 0:b00c4699ae6f 114 }ds3231_time_t;
j3 0:b00c4699ae6f 115
j3 0:b00c4699ae6f 116
j3 0:b00c4699ae6f 117 typedef struct
j3 0:b00c4699ae6f 118 {
j3 0:b00c4699ae6f 119 uint8_t day;
j3 0:b00c4699ae6f 120 uint8_t date;
j3 0:b00c4699ae6f 121 uint8_t month;
j3 0:b00c4699ae6f 122 uint8_t year;
j3 0:b00c4699ae6f 123 }ds3231_calendar_t;
j3 0:b00c4699ae6f 124
j3 0:b00c4699ae6f 125
j3 0:b00c4699ae6f 126 typedef struct
j3 0:b00c4699ae6f 127 {
j3 0:b00c4699ae6f 128 uint8_t seconds; //not used for alarm2
j3 0:b00c4699ae6f 129 uint8_t minutes;
j3 0:b00c4699ae6f 130 uint8_t hours;
j3 0:b00c4699ae6f 131 uint8_t day;
j3 0:b00c4699ae6f 132 uint8_t date;
j3 2:4e6e761c60f2 133 bool am1; //not used for alarm 2
j3 2:4e6e761c60f2 134 bool am2;
j3 2:4e6e761c60f2 135 bool am3;
j3 2:4e6e761c60f2 136 bool am4;
j3 2:4e6e761c60f2 137 bool am_pm; //TRUE for PM, same logic as datasheet
j3 2:4e6e761c60f2 138 bool mode; //TRUE for 12 hour, same logic as datasheet
j3 2:4e6e761c60f2 139 bool dy_dt; //TRUE for Day, same logic as datasheet
j3 0:b00c4699ae6f 140 }ds3231_alrm_t;
j3 0:b00c4699ae6f 141
j3 0:b00c4699ae6f 142
j3 0:b00c4699ae6f 143 typedef struct
j3 0:b00c4699ae6f 144 {
j3 0:b00c4699ae6f 145 uint8_t control;
j3 0:b00c4699ae6f 146 uint8_t status;
j3 0:b00c4699ae6f 147 }ds3231_cntl_stat_t;
j3 0:b00c4699ae6f 148
j3 0:b00c4699ae6f 149
j3 0:b00c4699ae6f 150 /******************************************************************//**
j3 0:b00c4699ae6f 151 * Ds3231 Class
j3 0:b00c4699ae6f 152 **********************************************************************/
j3 1:c814af60fdbf 153 class Ds3231 : public I2C
j3 0:b00c4699ae6f 154 {
j3 0:b00c4699ae6f 155 uint8_t w_adrs, r_adrs;
j3 0:b00c4699ae6f 156
j3 2:4e6e761c60f2 157 /**********************************************************//**
j3 2:4e6e761c60f2 158 * Private mmber fx, converts unsigned char to BCD
j3 2:4e6e761c60f2 159 *
j3 2:4e6e761c60f2 160 * On Entry:
j3 2:4e6e761c60f2 161 * @param[in] data - 0-255
j3 2:4e6e761c60f2 162 *
j3 2:4e6e761c60f2 163 * On Exit:
j3 2:4e6e761c60f2 164 * @return bcd_result = BCD representation of data
j3 2:4e6e761c60f2 165 *
j3 2:4e6e761c60f2 166 **************************************************************/
j3 2:4e6e761c60f2 167 uint16_t uchar_2_bcd(uint8_t data);
j3 2:4e6e761c60f2 168
j3 2:4e6e761c60f2 169
j3 2:4e6e761c60f2 170 /**********************************************************//**
j3 2:4e6e761c60f2 171 * Private mmber fx, converts BCD to a uint8_t
j3 2:4e6e761c60f2 172 *
j3 2:4e6e761c60f2 173 * On Entry:
j3 2:4e6e761c60f2 174 * @param[in] bcd - 0-99
j3 2:4e6e761c60f2 175 *
j3 2:4e6e761c60f2 176 * On Exit:
j3 2:4e6e761c60f2 177 * @return rtn_val = integer rep. of BCD
j3 2:4e6e761c60f2 178 *
j3 2:4e6e761c60f2 179 **************************************************************/
j3 2:4e6e761c60f2 180 uint8_t bcd_2_uchar(uint8_t bcd);
j3 2:4e6e761c60f2 181
j3 0:b00c4699ae6f 182 public:
j3 0:b00c4699ae6f 183 /**********************************************************//**
j3 0:b00c4699ae6f 184 * Constructor for Ds3231 Class
j3 0:b00c4699ae6f 185 *
j3 0:b00c4699ae6f 186 * On Entry:
j3 1:c814af60fdbf 187 * @param[in] sda - sda pin of I2C bus
j3 1:c814af60fdbf 188 * @param[in] scl - scl pin of I2C bus
j3 0:b00c4699ae6f 189 *
j3 0:b00c4699ae6f 190 * On Exit:
j3 0:b00c4699ae6f 191 * @return none
j3 0:b00c4699ae6f 192 *
j3 0:b00c4699ae6f 193 * Example:
j3 0:b00c4699ae6f 194 * @code
j3 0:b00c4699ae6f 195 *
j3 0:b00c4699ae6f 196 * //instantiate rtc object
j3 1:c814af60fdbf 197 * Ds3231 rtc(D14, D15);
j3 0:b00c4699ae6f 198 *
j3 0:b00c4699ae6f 199 * @endcode
j3 0:b00c4699ae6f 200 **************************************************************/
j3 1:c814af60fdbf 201 Ds3231(PinName sda, PinName scl);
j3 0:b00c4699ae6f 202
j3 0:b00c4699ae6f 203
j3 0:b00c4699ae6f 204 /**********************************************************//**
j3 0:b00c4699ae6f 205 * Sets the time on DS3231
j3 2:4e6e761c60f2 206 * Struct data is in integrer format, not BCD. Fx will convert
j3 2:4e6e761c60f2 207 * to BCD for you.
j3 0:b00c4699ae6f 208 *
j3 0:b00c4699ae6f 209 * On Entry:
j3 0:b00c4699ae6f 210 * @param[in] time - struct cotaining time data;
j3 0:b00c4699ae6f 211 * seconds, minutes and hours
j3 0:b00c4699ae6f 212 *
j3 0:b00c4699ae6f 213 * On Exit:
j3 0:b00c4699ae6f 214 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 215 *
j3 0:b00c4699ae6f 216 * Example:
j3 0:b00c4699ae6f 217 * @code
j3 0:b00c4699ae6f 218 *
j3 0:b00c4699ae6f 219 * //instantiate rtc object
j3 1:c814af60fdbf 220 * Ds3231 rtc(D14, D15);
j3 0:b00c4699ae6f 221 *
j3 0:b00c4699ae6f 222 * ds3231_time_t time = {0, 0, 0} // time = 0:0:0 24hr format
j3 0:b00c4699ae6f 223 * uint16_t rtn_val;
j3 0:b00c4699ae6f 224 *
j3 0:b00c4699ae6f 225 * rtn_val = rtc.set_time(time);
j3 0:b00c4699ae6f 226 *
j3 0:b00c4699ae6f 227 * @endcode
j3 0:b00c4699ae6f 228 **************************************************************/
j3 0:b00c4699ae6f 229 uint16_t set_time(ds3231_time_t time);
j3 0:b00c4699ae6f 230
j3 0:b00c4699ae6f 231
j3 0:b00c4699ae6f 232 /**********************************************************//**
j3 0:b00c4699ae6f 233 * Sets the calendar on DS3231
j3 2:4e6e761c60f2 234 * Struct data is in integrer format, not BCD. Fx will convert
j3 2:4e6e761c60f2 235 * to BCD for you.
j3 0:b00c4699ae6f 236 *
j3 0:b00c4699ae6f 237 * On Entry:
j3 0:b00c4699ae6f 238 * @param[in] calendar - struct cotaining calendar data;
j3 0:b00c4699ae6f 239 * day, date, month, year
j3 0:b00c4699ae6f 240 *
j3 0:b00c4699ae6f 241 * On Exit:
j3 0:b00c4699ae6f 242 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 243 *
j3 0:b00c4699ae6f 244 * Example:
j3 0:b00c4699ae6f 245 * @code
j3 0:b00c4699ae6f 246 *
j3 0:b00c4699ae6f 247 * //instantiate rtc object
j3 1:c814af60fdbf 248 * Ds3231 rtc(D14, D15);
j3 0:b00c4699ae6f 249 *
j3 0:b00c4699ae6f 250 * //see datasheet for calendar format
j3 0:b00c4699ae6f 251 * ds3231_calendar_t calendar = {1, 1, 1, 0};
j3 0:b00c4699ae6f 252 * uint16_t rtn_val;
j3 0:b00c4699ae6f 253 *
j3 0:b00c4699ae6f 254 * rtn_val = rtc.set_calendar(calendar);
j3 0:b00c4699ae6f 255 *
j3 0:b00c4699ae6f 256 * @endcode
j3 0:b00c4699ae6f 257 **************************************************************/
j3 0:b00c4699ae6f 258 uint16_t set_calendar(ds3231_calendar_t calendar);
j3 0:b00c4699ae6f 259
j3 0:b00c4699ae6f 260
j3 0:b00c4699ae6f 261 /**********************************************************//**
j3 0:b00c4699ae6f 262 * Set either Alarm1 or Alarm2 of DS3231
j3 2:4e6e761c60f2 263 * Struct data is in integrer format, not BCD. Fx will convert
j3 2:4e6e761c60f2 264 * to BCD for you.
j3 0:b00c4699ae6f 265 *
j3 0:b00c4699ae6f 266 * On Entry:
j3 0:b00c4699ae6f 267 * @param[in] alarm - struct cotaining alarm data
j3 0:b00c4699ae6f 268 * seconds, minutes, hours, day, date
j3 0:b00c4699ae6f 269 * seconds used on Alarm1 only
j3 0:b00c4699ae6f 270 * @param[in] one_r_two - TRUE for Alarm1 and FALSE for
j3 0:b00c4699ae6f 271 * Alarm2
j3 0:b00c4699ae6f 272 *
j3 0:b00c4699ae6f 273 * On Exit:
j3 0:b00c4699ae6f 274 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 275 *
j3 0:b00c4699ae6f 276 * Example:
j3 0:b00c4699ae6f 277 * @code
j3 0:b00c4699ae6f 278 *
j3 0:b00c4699ae6f 279 * //instantiate rtc object
j3 1:c814af60fdbf 280 * Ds3231 rtc(D14, D15);
j3 0:b00c4699ae6f 281 *
j3 0:b00c4699ae6f 282 * //see datasheet for alarm format
j3 0:b00c4699ae6f 283 * ds3231_alrm_t alarm = {0, 0, 0, 0, 0};
j3 0:b00c4699ae6f 284 * uint16_t rtn_val;
j3 0:b00c4699ae6f 285 *
j3 0:b00c4699ae6f 286 * rtn_val = rtc.set_alarm(alarm, FALSE);
j3 0:b00c4699ae6f 287 *
j3 0:b00c4699ae6f 288 * @endcode
j3 0:b00c4699ae6f 289 **************************************************************/
j3 0:b00c4699ae6f 290 uint16_t set_alarm(ds3231_alrm_t alarm, bool one_r_two);
j3 0:b00c4699ae6f 291
j3 0:b00c4699ae6f 292
j3 0:b00c4699ae6f 293 /**********************************************************//**
j3 0:b00c4699ae6f 294 * Set control and status registers of DS3231
j3 0:b00c4699ae6f 295 *
j3 0:b00c4699ae6f 296 * On Entry:
j3 0:b00c4699ae6f 297 * @param[in] data - Struct containing control and status
j3 0:b00c4699ae6f 298 * register data
j3 0:b00c4699ae6f 299 *
j3 0:b00c4699ae6f 300 * On Exit:
j3 0:b00c4699ae6f 301 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 302 *
j3 0:b00c4699ae6f 303 * Example:
j3 0:b00c4699ae6f 304 * @code
j3 0:b00c4699ae6f 305 *
j3 0:b00c4699ae6f 306 * //instantiate rtc object
j3 1:c814af60fdbf 307 * Ds3231 rtc(D14, D15);
j3 0:b00c4699ae6f 308 *
j3 0:b00c4699ae6f 309 * //do not use 0xAA, see datasheet for appropriate data
j3 0:b00c4699ae6f 310 * ds3231_cntl_stat_t data = {0xAA, 0xAA};
j3 0:b00c4699ae6f 311 *
j3 0:b00c4699ae6f 312 * rtn_val = rtc.set_cntl_stat_reg(data);
j3 0:b00c4699ae6f 313 *
j3 0:b00c4699ae6f 314 * @endcode
j3 0:b00c4699ae6f 315 **************************************************************/
j3 0:b00c4699ae6f 316 uint16_t set_cntl_stat_reg(ds3231_cntl_stat_t data);
j3 0:b00c4699ae6f 317
j3 0:b00c4699ae6f 318
j3 0:b00c4699ae6f 319 /**********************************************************//**
j3 0:b00c4699ae6f 320 * Gets the time on DS3231
j3 0:b00c4699ae6f 321 *
j3 0:b00c4699ae6f 322 * On Entry:
j3 2:4e6e761c60f2 323 * @param[in] time - pointer to struct for storing time
j3 2:4e6e761c60f2 324 * data; seconds, minutes and hours
j3 0:b00c4699ae6f 325 *
j3 0:b00c4699ae6f 326 * On Exit:
j3 2:4e6e761c60f2 327 * @param[out] time - contains current integrer rtc time
j3 2:4e6e761c60f2 328 * data
j3 0:b00c4699ae6f 329 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 330 *
j3 0:b00c4699ae6f 331 * Example:
j3 0:b00c4699ae6f 332 * @code
j3 0:b00c4699ae6f 333 *
j3 0:b00c4699ae6f 334 * //instantiate rtc object
j3 1:c814af60fdbf 335 * Ds3231 rtc(D14, D15);
j3 0:b00c4699ae6f 336 *
j3 0:b00c4699ae6f 337 * ds3231_time_t time = {0, 0, 0} // time = 0:0:0 24hr format
j3 0:b00c4699ae6f 338 * uint16_t rtn_val;
j3 0:b00c4699ae6f 339 *
j3 0:b00c4699ae6f 340 * rtn_val = rtc.get_time(time);
j3 0:b00c4699ae6f 341 *
j3 0:b00c4699ae6f 342 * @endcode
j3 0:b00c4699ae6f 343 **************************************************************/
j3 2:4e6e761c60f2 344 uint16_t get_time(ds3231_time_t* time);
j3 0:b00c4699ae6f 345
j3 0:b00c4699ae6f 346
j3 0:b00c4699ae6f 347 /**********************************************************//**
j3 0:b00c4699ae6f 348 * Gets the calendar on DS3231
j3 0:b00c4699ae6f 349 *
j3 0:b00c4699ae6f 350 * On Entry:
j3 2:4e6e761c60f2 351 * @param[in] calendar - pointer to struct for storing
j3 2:4e6e761c60f2 352 * calendar data;
j3 0:b00c4699ae6f 353 * day, date, month, year
j3 0:b00c4699ae6f 354 *
j3 0:b00c4699ae6f 355 * On Exit:
j3 2:4e6e761c60f2 356 * @param[out] calendar - contains current integer rtc
j3 2:4e6e761c60f2 357 * calendar data
j3 0:b00c4699ae6f 358 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 359 *
j3 0:b00c4699ae6f 360 * Example:
j3 0:b00c4699ae6f 361 * @code
j3 0:b00c4699ae6f 362 *
j3 0:b00c4699ae6f 363 * //instantiate rtc object
j3 1:c814af60fdbf 364 * Ds3231 rtc(D14, D15);
j3 0:b00c4699ae6f 365 *
j3 0:b00c4699ae6f 366 * //see datasheet for calendar format
j3 0:b00c4699ae6f 367 * ds3231_calendar_t calendar = {1, 1, 1, 0};
j3 0:b00c4699ae6f 368 * uint16_t rtn_val;
j3 0:b00c4699ae6f 369 *
j3 0:b00c4699ae6f 370 * rtn_val = rtc.get_calendar(calendar);
j3 0:b00c4699ae6f 371 *
j3 0:b00c4699ae6f 372 * @endcode
j3 0:b00c4699ae6f 373 **************************************************************/
j3 2:4e6e761c60f2 374 uint16_t get_calendar(ds3231_calendar_t* calendar);
j3 0:b00c4699ae6f 375
j3 0:b00c4699ae6f 376
j3 0:b00c4699ae6f 377 /**********************************************************//**
j3 0:b00c4699ae6f 378 * Get either Alarm1 or Alarm2 of DS3231
j3 0:b00c4699ae6f 379 *
j3 0:b00c4699ae6f 380 * On Entry:
j3 2:4e6e761c60f2 381 * @param[in] alarm - pointer to struct for storing alarm
j3 2:4e6e761c60f2 382 * data;
j3 0:b00c4699ae6f 383 * seconds, minutes, hours, day, date
j3 0:b00c4699ae6f 384 * seconds used on Alarm1 only
j3 2:4e6e761c60f2 385 *
j3 0:b00c4699ae6f 386 * @param[in] one_r_two - TRUE for Alarm1 and FALSE for
j3 0:b00c4699ae6f 387 * Alarm2
j3 0:b00c4699ae6f 388 *
j3 0:b00c4699ae6f 389 * On Exit:
j3 2:4e6e761c60f2 390 * @param[out] alarm - contains integer alarm data
j3 0:b00c4699ae6f 391 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 392 *
j3 0:b00c4699ae6f 393 * Example:
j3 0:b00c4699ae6f 394 * @code
j3 0:b00c4699ae6f 395 *
j3 0:b00c4699ae6f 396 * //instantiate rtc object
j3 1:c814af60fdbf 397 * Ds3231 rtc(D14, D15);
j3 0:b00c4699ae6f 398 *
j3 0:b00c4699ae6f 399 * //see datasheet for alarm format
j3 0:b00c4699ae6f 400 * ds3231_alrm_t alarm = {0, 0, 0, 0, 0};
j3 0:b00c4699ae6f 401 * uint16_t rtn_val;
j3 0:b00c4699ae6f 402 *
j3 0:b00c4699ae6f 403 * rtn_val = rtc.get_alarm(alarm, FALSE);
j3 0:b00c4699ae6f 404 *
j3 0:b00c4699ae6f 405 * @endcode
j3 0:b00c4699ae6f 406 **************************************************************/
j3 2:4e6e761c60f2 407 uint16_t get_alarm(ds3231_alrm_t* alarm, bool one_r_two);
j3 0:b00c4699ae6f 408
j3 0:b00c4699ae6f 409
j3 0:b00c4699ae6f 410 /**********************************************************//**
j3 0:b00c4699ae6f 411 * Get control and status registers of DS3231
j3 0:b00c4699ae6f 412 *
j3 0:b00c4699ae6f 413 * On Entry:
j3 2:4e6e761c60f2 414 * @param[in] data - pointer to struct for storing control
j3 2:4e6e761c60f2 415 * nd status register data
j3 0:b00c4699ae6f 416 *
j3 0:b00c4699ae6f 417 * On Exit:
j3 0:b00c4699ae6f 418 * @param[out] data - contains control and status registers
j3 0:b00c4699ae6f 419 * data
j3 0:b00c4699ae6f 420 * @return return value = 0 on success, non-0 on failure
j3 0:b00c4699ae6f 421 *
j3 0:b00c4699ae6f 422 * Example:
j3 0:b00c4699ae6f 423 * @code
j3 0:b00c4699ae6f 424 *
j3 0:b00c4699ae6f 425 * //instantiate rtc object
j3 1:c814af60fdbf 426 * Ds3231 rtc(D14, D15);
j3 0:b00c4699ae6f 427 *
j3 0:b00c4699ae6f 428 * //do not use 0xAA, see datasheet for appropriate data
j3 0:b00c4699ae6f 429 * ds3231_cntl_stat_t data = {0xAA, 0xAA};
j3 0:b00c4699ae6f 430 *
j3 0:b00c4699ae6f 431 * rtn_val = rtc.get_cntl_stat_reg(data);
j3 0:b00c4699ae6f 432 *
j3 0:b00c4699ae6f 433 * @endcode
j3 0:b00c4699ae6f 434 **************************************************************/
j3 2:4e6e761c60f2 435 uint16_t get_cntl_stat_reg(ds3231_cntl_stat_t* data);
j3 0:b00c4699ae6f 436
j3 0:b00c4699ae6f 437
j3 0:b00c4699ae6f 438 /**********************************************************//**
j3 0:b00c4699ae6f 439 * Get temperature data of DS3231
j3 0:b00c4699ae6f 440 *
j3 0:b00c4699ae6f 441 * On Entry:
j3 0:b00c4699ae6f 442 *
j3 0:b00c4699ae6f 443 * On Exit:
j3 2:4e6e761c60f2 444 * @return return value = raw temperature data
j3 0:b00c4699ae6f 445 *
j3 0:b00c4699ae6f 446 * Example:
j3 0:b00c4699ae6f 447 * @code
j3 0:b00c4699ae6f 448 *
j3 0:b00c4699ae6f 449 * //instantiate rtc object
j3 1:c814af60fdbf 450 * Ds3231 rtc(D14, D15);
j3 0:b00c4699ae6f 451 *
j3 0:b00c4699ae6f 452 * uint16_t temp;
j3 0:b00c4699ae6f 453 *
j3 2:4e6e761c60f2 454 * temp = rtc.get_temperature();
j3 0:b00c4699ae6f 455 *
j3 0:b00c4699ae6f 456 * @endcode
j3 0:b00c4699ae6f 457 **************************************************************/
j3 2:4e6e761c60f2 458 uint16_t get_temperature(void);
j3 0:b00c4699ae6f 459
j3 0:b00c4699ae6f 460 };
j3 0:b00c4699ae6f 461 #endif /* DS3231_H*/