Pinconfig für Endbadge.
[hackover2013-badge-firmware.git] / drivers / rtc / isl12022m / isl12022m.h
1 /**************************************************************************/
2 /*!
3 @file isl12022m.h
4 @author K. Townsend (microBuilder.eu)
5
6 @section LICENSE
7
8 Software License Agreement (BSD License)
9
10 Copyright (c) 2010, microBuilder SARL
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 1. Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 2. Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 3. Neither the name of the copyright holders nor the
21 names of its contributors may be used to endorse or promote products
22 derived from this software without specific prior written permission.
23
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35 /**************************************************************************/
36
37 #ifndef _ISL12022M_H_
38 #define _ISL12022M_H_
39
40 #include "projectconfig.h"
41 #include "core/i2c/i2c.h"
42
43 #define ISL12022M_RTC_ADDRESS (0xDE) // 1101111 shifted left 1 bit = 0xDE
44 #define ISL12022M_SRAM_ADDRESS (0xAE) // 1010111 shifted left 1 bit = 0xAE
45 #define ISL12022M_READBIT (0x01)
46
47 #define ISL12022M_HR_MILITARY (1<<7) // 1 = 24-Hour, 0 = 12-Hour
48 #define ISL12022M_HR_AMPM (1<<5) // If 24-hour time enabled, 0 = AM, 1 = PM
49
50 #define ISL12022M_STATUS_BUSY (1<<7)
51 #define ISL12022M_STATUS_OSCFAIL (1<<6)
52 #define ISL12022M_STATUS_DSTADJUST (1<<5)
53 #define ISL12022M_STATUS_ALARM (1<<4)
54 #define ISL12022M_STATUS_LOWVDD (1<<3)
55 #define ISL12022M_STATUS_LOWBATT85 (1<<2)
56 #define ISL12022M_STATUS_LOWBATT75 (1<<1)
57 #define ISL12022M_STATUS_RTCFAIL (1<<0)
58
59 #define ISL12022M_INT_AUTORESET (1<<7)
60 #define ISL12022M_INT_WRITEENABLE (1<<6)
61 #define ISL12022M_INT_INTALARM (1<<5)
62 #define ISL12022M_INT_FOBATB (1<<4)
63
64 #define ISL12022M_BETA_TEMPENABLE (1<<7) // Temperature Sensor Enabled Bit
65
66 enum
67 {
68 // RTC Registers
69 ISL12022M_REG_RTC_SC = 0x00,
70 ISL12022M_REG_RTC_MN = 0x01,
71 ISL12022M_REG_RTC_HR = 0x02,
72 ISL12022M_REG_RTC_DT = 0x03,
73 ISL12022M_REG_RTC_MO = 0x04,
74 ISL12022M_REG_RTC_YR = 0x05,
75 ISL12022M_REG_RTC_DW = 0x06,
76 // Control and Status Registers
77 ISL12022M_REG_CSR_SR = 0x07,
78 ISL12022M_REG_CSR_INT = 0x08,
79 ISL12022M_REG_CSR_PWR_VDD = 0x09,
80 ISL12022M_REG_CSR_PWR_VBAT = 0x0A,
81 ISL12022M_REG_CSR_ITRO = 0x0B,
82 ISL12022M_REG_CSR_ALPHA = 0x0C,
83 ISL12022M_REG_CSR_BETA = 0x0D,
84 ISL12022M_REG_CSR_FATR = 0x0E,
85 ISL12022M_REG_CSR_FDTR = 0x0F,
86 // Alarm Registers
87 ISL12022M_REG_ALARM_SCA0 = 0x10,
88 ISL12022M_REG_ALARM_MNA0 = 0x11,
89 ISL12022M_REG_ALARM_HRA0 = 0x12,
90 ISL12022M_REG_ALARM_DTA0 = 0x13,
91 ISL12022M_REG_ALARM_MOA0 = 0x14,
92 ISL12022M_REG_ALARM_DWA0 = 0x15,
93 //
94 ISL12022M_REG_TSV2B_VSC = 0x16,
95 ISL12022M_REG_TSV2B_VMN = 0x17,
96 ISL12022M_REG_TSV2B_VHR = 0x18,
97 ISL12022M_REG_TSV2B_VDT = 0x19,
98 ISL12022M_REG_TSV2B_VMO = 0x1A,
99 ISL12022M_REG_TSV2B_TSB2V = 0x1B,
100 ISL12022M_REG_TSV2B_BMN = 0x1C,
101 ISL12022M_REG_TSV2B_BHR = 0x1D,
102 ISL12022M_REG_TSV2B_BDT = 0x1E,
103 ISL12022M_REG_TSV2B_BMO = 0x1F,
104 // DST Control Registers
105 ISL12022M_REG_DSTCR_DSTMOFD = 0x20,
106 ISL12022M_REG_DSTCR_DSTDWFD = 0x21,
107 ISL12022M_REG_DSTCR_DSTDTFD = 0x22,
108 ISL12022M_REG_DSTCR_DSTHRFD = 0x23,
109 ISL12022M_REG_DSTCR_DSTMORV = 0x24,
110 ISL12022M_REG_DSTCR_DSTDWRV = 0x25,
111 ISL12022M_REG_DSTCR_DSTDTRV = 0x26,
112 ISL12022M_REG_DSTCR_DSTHRRV = 0x27,
113 // Temperature Registers
114 ISL12022M_REG_TEMP_TKOL = 0x28,
115 ISL12022M_REG_TEMP_TKOM = 0x29,
116 // NPPM Registers
117 ISL12022M_REG_NPPM_NPPML = 0x2A,
118 ISL12022M_REG_NPPM_NPPMH = 0x2B,
119 // XTO Register
120 ISL12022M_REG_XT0_XT0 = 0x2C,
121 // Alpha Hot Register
122 ISL12022M_REG_ALPHAH_ALPHAH = 0x2D,
123 // General Purpose Memory (SRAM) Registers
124 ISL12022M_REG_GPM_GPM1 = 0x2E,
125 ISL12022M_REG_GPM_GPM2 = 0x2F
126 };
127
128 typedef enum
129 {
130 ISL12022M_ERROR_OK = 0, // Everything executed normally
131 ISL12022M_ERROR_I2C_INIT, // Unable to initialise I2C
132 ISL12022M_ERROR_I2C_BUSY, // I2C already in use
133 ISL12022M_ERROR_I2C_BUFFEROVERFLOW, // I2C Buffer is too small
134 ISL12022M_ERROR_RTC_LOWBATT, // RTC battery low ... value may not be accurate
135 ISL12022M_ERROR_LAST
136 }
137 isl12022mError_t;
138
139 // ISL12022M time + status placeholder
140 typedef struct
141 {
142 uint8_t interrupt;
143 uint8_t status;
144 uint8_t dayofweek;
145 uint8_t year;
146 uint8_t month;
147 uint8_t day;
148 uint8_t hour;
149 uint8_t minute;
150 uint8_t second;
151 }
152 isl12022mTime_t;
153
154 isl12022mError_t isl12022mInit(void);
155 isl12022mError_t isl12022mGetTime(isl12022mTime_t *time);
156 isl12022mError_t isl12022mSetTime(uint8_t dayofweek, uint8_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second);
157 isl12022mError_t isl12022mGetTemp(uint8_t *celsius);
158
159 #endif
This page took 0.056967 seconds and 5 git commands to generate.