BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ds3231.h
Go to the documentation of this file.
1 /* Copyright 2013-2014, Peter A. Bigot
2  *
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * * Neither the name of the software nor the names of its contributors may be
16  * used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef BSP430_CHIPS_DS3231_H
33 #define BSP430_CHIPS_DS3231_H
34 
54 #include <bsp430/core.h>
55 #include <time.h>
56 
58 #define DS3231_I2C_ADDRESS 0x68
59 
61 #if defined(BSP430_DOXYGEN)
63 #else /* BSP430_DOXYGEN */
65 #endif /* BSP430_DOXYGEN */
66 {
67  uint8_t seconds;
68  uint8_t minutes;
69  uint8_t hours;
70  uint8_t dow;
71  uint8_t dom;
72  uint8_t mon_cen;
73  uint8_t year;
74  uint8_t alrm1_sec;
75  uint8_t alrm1_min;
76  uint8_t alrm1_hr;
77  uint8_t alrm1_doa;
78  uint8_t alrm2_min;
79  uint8_t alrm2_hr;
80  uint8_t alrm2_doa;
81  uint8_t ctrl;
82  uint8_t stat;
83  uint8_t aging;
84  uint8_t temp_msb;
85  uint8_t temp_lsb;
86 };
89 
98 uint8_t ucDS3231encodeHour (unsigned int hours,
99  int is_12h);
100 
105 unsigned int uiDS3231decodeHour (uint8_t hour_ds3231);
106 
119 const struct tm *
121  struct tm * timep);
122 
133 const sDS3231registers *
134 xDS3231tmToRegisters (const struct tm * timep,
135  sDS3231registers * regp);
136 
137 #endif /* BSP430_CHIPS_DS3231_H */
uint8_t alrm1_doa
Definition: ds3231.h:77
uint8_t dom
Definition: ds3231.h:71
uint8_t dow
Definition: ds3231.h:70
uint8_t temp_msb
Definition: ds3231.h:84
uint8_t aging
Definition: ds3231.h:83
Common header included by all BSP430 leaf headers.
uint8_t alrm2_min
Definition: ds3231.h:78
uint8_t alrm2_hr
Definition: ds3231.h:79
uint8_t alrm2_doa
Definition: ds3231.h:80
uint8_t temp_lsb
Definition: ds3231.h:85
#define BSP430_CORE_PACKED_STRUCT(nm_)
Definition: core.h:468
uint8_t ctrl
Definition: ds3231.h:81
uint8_t seconds
Definition: ds3231.h:67
unsigned int uiDS3231decodeHour(uint8_t hour_ds3231)
const struct tm * xDS3231registersToTm(const sDS3231registers *regp, struct tm *timep)
uint8_t mon_cen
Definition: ds3231.h:72
const sDS3231registers * xDS3231tmToRegisters(const struct tm *timep, sDS3231registers *regp)
uint8_t alrm1_hr
Definition: ds3231.h:76
Definition: ds3231.h:62
uint8_t minutes
Definition: ds3231.h:68
uint8_t alrm1_min
Definition: ds3231.h:75
uint8_t ucDS3231encodeHour(unsigned int hours, int is_12h)
uint8_t hours
Definition: ds3231.h:69
uint8_t alrm1_sec
Definition: ds3231.h:74
uint8_t stat
Definition: ds3231.h:82
uint8_t year
Definition: ds3231.h:73