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