ISL1208 library based on original ISL1208 library, modified to suit our needs.

Fork of ISL1208 by Neil Thiessen

Committer:
goranirnas
Date:
Tue Apr 03 09:08:36 2018 +0000
Revision:
7:00b8ead188f8
Parent:
6:c0635401a37f
i2c object in library converted to a pointer to i2c object to more easily add several devices on i2c bus.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
neilt6 0:697ca602e934 1 /* ISL1208 Driver Library
neilt6 0:697ca602e934 2 * Copyright (c) 2013 Neil Thiessen
neilt6 0:697ca602e934 3 *
neilt6 0:697ca602e934 4 * Licensed under the Apache License, Version 2.0 (the "License");
neilt6 0:697ca602e934 5 * you may not use this file except in compliance with the License.
neilt6 0:697ca602e934 6 * You may obtain a copy of the License at
neilt6 0:697ca602e934 7 *
neilt6 0:697ca602e934 8 * http://www.apache.org/licenses/LICENSE-2.0
neilt6 0:697ca602e934 9 *
neilt6 0:697ca602e934 10 * Unless required by applicable law or agreed to in writing, software
neilt6 0:697ca602e934 11 * distributed under the License is distributed on an "AS IS" BASIS,
neilt6 0:697ca602e934 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
neilt6 0:697ca602e934 13 * See the License for the specific language governing permissions and
neilt6 0:697ca602e934 14 * limitations under the License.
neilt6 0:697ca602e934 15 */
neilt6 0:697ca602e934 16
neilt6 0:697ca602e934 17 #ifndef ISL1208_H
neilt6 0:697ca602e934 18 #define ISL1208_H
neilt6 0:697ca602e934 19
neilt6 0:697ca602e934 20 #include "mbed.h"
neilt6 0:697ca602e934 21
neilt6 0:697ca602e934 22 /** ISL1208 class.
neilt6 0:697ca602e934 23 * Used for controlling an ISL1208 real time clock connected via I2C.
neilt6 0:697ca602e934 24 *
neilt6 0:697ca602e934 25 * Example:
neilt6 0:697ca602e934 26 * @code
neilt6 0:697ca602e934 27 * #include "mbed.h"
neilt6 0:697ca602e934 28 * #include "ISL1208.h"
neilt6 0:697ca602e934 29 *
neilt6 0:697ca602e934 30 * ISL1208 rtc(p28, p27);
neilt6 0:697ca602e934 31 *
neilt6 0:697ca602e934 32 * int main()
neilt6 0:697ca602e934 33 * {
neilt6 0:697ca602e934 34 * //Try to open the ISL1208
neilt6 4:42dc07f9ffb3 35 * if (rtc.open()) {
neilt6 0:697ca602e934 36 * printf("Device detected!\n");
neilt6 0:697ca602e934 37 *
neilt6 4:42dc07f9ffb3 38 * //Configure the oscillator for a 32.768kHz crystal
neilt6 4:42dc07f9ffb3 39 * rtc.oscillatorMode(ISL1208::OSCILLATOR_CRYSTAL);
neilt6 4:42dc07f9ffb3 40 *
neilt6 0:697ca602e934 41 * //Check if we need to reset the time
neilt6 0:697ca602e934 42 * if (rtc.powerFailed()) {
neilt6 0:697ca602e934 43 * //The time has been lost due to a power complete power failure
neilt6 0:697ca602e934 44 * printf("Device has lost power! Resetting time...\n");
neilt6 0:697ca602e934 45 *
neilt6 0:697ca602e934 46 * //Set RTC time to Wed, 28 Oct 2009 11:35:37
neilt6 0:697ca602e934 47 * rtc.time(1256729737);
neilt6 0:697ca602e934 48 * }
neilt6 0:697ca602e934 49 *
neilt6 0:697ca602e934 50 * while(1) {
neilt6 0:697ca602e934 51 * //Get the current time
neilt6 0:697ca602e934 52 * time_t seconds = rtc.time();
neilt6 0:697ca602e934 53 *
neilt6 0:697ca602e934 54 * //Print the time in various formats
neilt6 0:697ca602e934 55 * printf("\nTime as seconds since January 1, 1970 = %d\n", seconds);
neilt6 0:697ca602e934 56 * printf("Time as a basic string = %s", ctime(&seconds));
neilt6 0:697ca602e934 57 * char buffer[32];
neilt6 0:697ca602e934 58 * strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
neilt6 0:697ca602e934 59 * printf("Time as a custom formatted string = %s", buffer);
neilt6 0:697ca602e934 60 *
neilt6 0:697ca602e934 61 * //Delay for 1.0 seconds
neilt6 0:697ca602e934 62 * wait(1.0);
neilt6 0:697ca602e934 63 * }
neilt6 0:697ca602e934 64 * } else {
neilt6 1:c951ff6da740 65 * error("Device not detected!\n");
neilt6 0:697ca602e934 66 * }
neilt6 0:697ca602e934 67 * }
neilt6 0:697ca602e934 68 * @endcode
neilt6 0:697ca602e934 69 */
neilt6 0:697ca602e934 70 class ISL1208
neilt6 0:697ca602e934 71 {
neilt6 0:697ca602e934 72 public:
neilt6 0:697ca602e934 73 /** Represents the different oscillator modes for the ISL1208
neilt6 0:697ca602e934 74 */
neilt6 0:697ca602e934 75 enum OscillatorMode {
neilt6 0:697ca602e934 76 OSCILLATOR_CRYSTAL, /**< The internal crystal oscillator is enabled */
neilt6 0:697ca602e934 77 OSCILLATOR_EXTERNAL /**< The internal crystal oscillator is disabled, an external 32kHz oscillator is connected to X1 */
neilt6 0:697ca602e934 78 };
neilt6 0:697ca602e934 79
neilt6 0:697ca602e934 80 /** Represents the different output frequencies for the IRQ/fOUT pin on the ISL1208
neilt6 0:697ca602e934 81 */
neilt6 0:697ca602e934 82 enum OutputFrequency {
neilt6 0:697ca602e934 83 FOUT_DISABLED = 0, /**< Disable frequency generation on the IRQ/fOUT pin */
neilt6 0:697ca602e934 84 FOUT_32768_HZ, /**< Generate 32.768kHz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 85 FOUT_4096_HZ, /**< Generate 4.096kHz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 86 FOUT_1024_HZ, /**< Generate 1.024kHz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 87 FOUT_64_HZ, /**< Generate 64Hz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 88 FOUT_32_HZ, /**< Generate 32Hz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 89 FOUT_16_HZ, /**< Generate 16Hz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 90 FOUT_8_HZ, /**< Generate 8Hz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 91 FOUT_4_HZ, /**< Generate 4Hz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 92 FOUT_2_HZ, /**< Generate 2Hz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 93 FOUT_1_HZ, /**< Generate 1Hz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 94 FOUT_1_2_HZ, /**< Generate 1/2Hz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 95 FOUT_1_4_HZ, /**< Generate 1/4Hz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 96 FOUT_1_8_HZ, /**< Generate 1/8Hz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 97 FOUT_1_16_HZ, /**< Generate 1/16Hz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 98 FOUT_1_32_HZ /**< Generate 1/32Hz on the IRQ/fOUT pin */
neilt6 0:697ca602e934 99 };
neilt6 0:697ca602e934 100
neilt6 0:697ca602e934 101 /** Represents the power mode of the ISL1208
neilt6 0:697ca602e934 102 */
neilt6 0:697ca602e934 103 enum PowerMode {
neilt6 0:697ca602e934 104 POWER_NORMAL, /**< VBAT supply will be used when VDD < VBAT - VBATHYS and VDD < VTRIP */
neilt6 0:697ca602e934 105 POWER_LPMODE /**< VBAT supply will be used when VDD < VBAT - VBATHYS */
neilt6 0:697ca602e934 106 };
neilt6 0:697ca602e934 107
neilt6 0:697ca602e934 108 /** Represents the alarm mode of the ISL1208
neilt6 0:697ca602e934 109 */
neilt6 0:697ca602e934 110 enum AlarmMode {
neilt6 0:697ca602e934 111 ALARM_DISABLED, /**< The alarm function is disabled */
neilt6 0:697ca602e934 112 ALARM_SINGLE, /**< Only a one-time match will be made between the RTC and alarm registers, and the IRQ/fOUT pin will pull low until the alarm flag is cleared */
neilt6 0:697ca602e934 113 ALARM_INTERRUPT /**< Every time an alarm match is made the IRQ/fOUT pin will pull low for 250ms, the alarm flag does not have to be cleared */
neilt6 0:697ca602e934 114 };
neilt6 0:697ca602e934 115
neilt6 0:697ca602e934 116 /** Represents the different battery mode ATR selections of the ISL1208
neilt6 0:697ca602e934 117 */
neilt6 0:697ca602e934 118 enum BatteryModeATR {
neilt6 0:697ca602e934 119 BMATR_ZERO = 0, /**< Delta capacitance = 0pF */
neilt6 0:697ca602e934 120 BMATR_MINUS_0_5, /**< Delta capacitance = -0.5pF (≈ +2ppm) */
neilt6 0:697ca602e934 121 BMATR_PLUS_0_5, /**< Delta capacitance = +0.5pF (≈ -2ppm) */
neilt6 0:697ca602e934 122 BMATR_PLUS_1_0 /**< Delta capacitance = +1pF (≈ -4ppm) */
neilt6 0:697ca602e934 123 };
neilt6 0:697ca602e934 124
neilt6 0:697ca602e934 125 /** Represents the different digital trim selections of the ISL1208
neilt6 0:697ca602e934 126 */
neilt6 0:697ca602e934 127 enum DigitalTrim {
neilt6 0:697ca602e934 128 DTR_ZERO = 0, /**< Digital trim = 0ppm */
neilt6 0:697ca602e934 129 DTR_PLUS_20, /**< Digital trim = ≈ +20ppm */
neilt6 0:697ca602e934 130 DTR_PLUS_40, /**< Digital trim = ≈ +40ppm */
neilt6 0:697ca602e934 131 DTR_PLUS_60, /**< Digital trim = ≈ +60ppm */
neilt6 0:697ca602e934 132 DTR_MINUS_20 = 5, /**< Digital trim = ≈ -20ppm */
neilt6 0:697ca602e934 133 DTR_MINUS_40, /**< Digital trim = ≈ -40ppm */
neilt6 0:697ca602e934 134 DTR_MINUS_60 /**< Digital trim = ≈ -60ppm */
neilt6 0:697ca602e934 135 };
neilt6 0:697ca602e934 136
neilt6 0:697ca602e934 137 /** Create a ISL1208 object connected to the specified I2C pins
neilt6 0:697ca602e934 138 *
neilt6 0:697ca602e934 139 * @param sda The I2C data pin.
neilt6 0:697ca602e934 140 * @param scl The I2C clock pin.
neilt6 6:c0635401a37f 141 * @param hz The I2C bus frequency (defaults to 400kHz).
neilt6 0:697ca602e934 142 */
goranirnas 7:00b8ead188f8 143 //ISL1208(PinName sda, PinName scl, int hz = 400000);
goranirnas 7:00b8ead188f8 144 ISL1208(I2C *p_I2C = NULL);
neilt6 0:697ca602e934 145
neilt6 4:42dc07f9ffb3 146 /** Probe for the ISL1208 and configure auto reset if present
neilt6 0:697ca602e934 147 *
neilt6 0:697ca602e934 148 * @returns
neilt6 0:697ca602e934 149 * 'true' if the device exists on the bus,
neilt6 0:697ca602e934 150 * 'false' if the device doesn't exist on the bus.
neilt6 0:697ca602e934 151 */
neilt6 4:42dc07f9ffb3 152 bool open();
neilt6 0:697ca602e934 153
neilt6 0:697ca602e934 154 /** Get the current time from the ISL1208
neilt6 0:697ca602e934 155 *
neilt6 0:697ca602e934 156 * @returns The current time as a Unix timestamp.
neilt6 0:697ca602e934 157 */
neilt6 2:f33dbb2535a3 158 time_t time();
neilt6 0:697ca602e934 159
neilt6 0:697ca602e934 160 /** Set the current time on the ISL1208 from a Unix timestamp
neilt6 0:697ca602e934 161 *
neilt6 0:697ca602e934 162 * @param t The current time as a Unix timestamp.
neilt6 0:697ca602e934 163 */
neilt6 0:697ca602e934 164 void time(time_t t);
neilt6 0:697ca602e934 165
neilt6 0:697ca602e934 166 /** Determine whether the RTC has completely lost power (and hence the time and SRAM)
neilt6 0:697ca602e934 167 *
neilt6 0:697ca602e934 168 * @returns Whether or not the RTC has completely lost power.
neilt6 0:697ca602e934 169 */
neilt6 2:f33dbb2535a3 170 bool powerFailed();
neilt6 0:697ca602e934 171
neilt6 0:697ca602e934 172 /** Determine whether the RTC has been on battery backup
neilt6 0:697ca602e934 173 *
neilt6 0:697ca602e934 174 * @returns Whether or not the RTC has been on battery backup.
neilt6 0:697ca602e934 175 */
neilt6 2:f33dbb2535a3 176 bool batteryFlag();
neilt6 0:697ca602e934 177
neilt6 0:697ca602e934 178 /** Clear the battery backup flag
neilt6 0:697ca602e934 179 */
neilt6 2:f33dbb2535a3 180 void clearBatteryFlag();
neilt6 0:697ca602e934 181
neilt6 0:697ca602e934 182 /** Determine whether the alarm has matched the RTC
neilt6 0:697ca602e934 183 *
neilt6 0:697ca602e934 184 * @returns Whether or not the alarm has matched the RTC.
neilt6 0:697ca602e934 185 */
neilt6 2:f33dbb2535a3 186 bool alarmFlag();
neilt6 0:697ca602e934 187
neilt6 0:697ca602e934 188 /** Clear the alarm flag
neilt6 0:697ca602e934 189 */
neilt6 2:f33dbb2535a3 190 void clearAlarmFlag();
neilt6 0:697ca602e934 191
neilt6 4:42dc07f9ffb3 192 /** Get the current oscillator mode of the ISL1208
neilt6 4:42dc07f9ffb3 193 *
neilt6 4:42dc07f9ffb3 194 * @returns The current oscillator mode as a OscillatorMode enum.
neilt6 4:42dc07f9ffb3 195 */
neilt6 4:42dc07f9ffb3 196 ISL1208::OscillatorMode oscillatorMode();
neilt6 4:42dc07f9ffb3 197
neilt6 4:42dc07f9ffb3 198 /** Set the oscillator mode of the ISL1208
neilt6 4:42dc07f9ffb3 199 *
neilt6 4:42dc07f9ffb3 200 * @param mode The new oscillator mode as a OscillatorMode enum.
neilt6 4:42dc07f9ffb3 201 */
neilt6 4:42dc07f9ffb3 202 void oscillatorMode(OscillatorMode mode);
neilt6 4:42dc07f9ffb3 203
neilt6 0:697ca602e934 204 /** Get the current output frequency on the IRQ/fOUT pin
neilt6 0:697ca602e934 205 *
neilt6 0:697ca602e934 206 * @returns The current output frequency.
neilt6 0:697ca602e934 207 */
neilt6 2:f33dbb2535a3 208 ISL1208::OutputFrequency foutFrequency();
neilt6 0:697ca602e934 209
neilt6 0:697ca602e934 210 /** Set the output frequency on the IRQ/fOUT pin
neilt6 0:697ca602e934 211 *
neilt6 0:697ca602e934 212 * @param freq The new output frequency.
neilt6 0:697ca602e934 213 */
neilt6 0:697ca602e934 214 void foutFrequency(OutputFrequency freq);
neilt6 0:697ca602e934 215
neilt6 0:697ca602e934 216 /** Determine whether or not the IRQ/fOUT pin will continue to output on battery power
neilt6 0:697ca602e934 217 *
neilt6 0:697ca602e934 218 * @returns Whether or not the IRQ/fOUT pin will continue to output on battery power.
neilt6 0:697ca602e934 219 */
neilt6 2:f33dbb2535a3 220 bool outputOnBattery();
neilt6 0:697ca602e934 221
neilt6 0:697ca602e934 222 /** Set whether or not the IRQ/fOUT pin should continue to output on battery power
neilt6 0:697ca602e934 223 *
neilt6 0:697ca602e934 224 * @param output Whether or not the IRQ/fOUT pin should continue to output on battery power.
neilt6 0:697ca602e934 225 */
neilt6 0:697ca602e934 226 void outputOnBattery(bool output);
neilt6 0:697ca602e934 227
neilt6 0:697ca602e934 228 /** Get the current power mode of the ISL1208
neilt6 0:697ca602e934 229 *
neilt6 0:697ca602e934 230 * @returns The current power mode as a PowerMode enum.
neilt6 0:697ca602e934 231 */
neilt6 2:f33dbb2535a3 232 ISL1208::PowerMode powerMode();
neilt6 0:697ca602e934 233
neilt6 0:697ca602e934 234 /** Set the power mode of the ISL1208
neilt6 0:697ca602e934 235 *
neilt6 0:697ca602e934 236 * @param mode The new power mode as a PowerMode enum.
neilt6 0:697ca602e934 237 */
neilt6 0:697ca602e934 238 void powerMode(PowerMode mode);
neilt6 0:697ca602e934 239
neilt6 0:697ca602e934 240 /** Get the current alarm mode of the ISL1208
neilt6 0:697ca602e934 241 *
neilt6 0:697ca602e934 242 * @returns The current alarm mode as an AlarmMode enum.
neilt6 0:697ca602e934 243 */
neilt6 2:f33dbb2535a3 244 ISL1208::AlarmMode alarmMode();
neilt6 0:697ca602e934 245
neilt6 0:697ca602e934 246 /** Set the alarm mode of the ISL1208
neilt6 0:697ca602e934 247 *
neilt6 0:697ca602e934 248 * @param mode The new alarm mode as an AlarmMode enum.
neilt6 0:697ca602e934 249 */
neilt6 0:697ca602e934 250 void alarmMode(AlarmMode mode);
neilt6 0:697ca602e934 251
neilt6 0:697ca602e934 252 /** Get the current analog trim of the ISL1208
neilt6 0:697ca602e934 253 *
neilt6 0:697ca602e934 254 * @returns The current analog trim in pF.
neilt6 0:697ca602e934 255 */
neilt6 2:f33dbb2535a3 256 float analogTrim();
neilt6 0:697ca602e934 257
neilt6 0:697ca602e934 258 /** Set the analog trim of the ISL1208
neilt6 0:697ca602e934 259 *
neilt6 0:697ca602e934 260 * @param trim The new analog trim in pF (valid range 4.5pF to 20.25pF in 0.25pF steps).
neilt6 0:697ca602e934 261 */
neilt6 0:697ca602e934 262 void analogTrim(float trim);
neilt6 0:697ca602e934 263
neilt6 0:697ca602e934 264 /** Get the current battery mode analog trim of the ISL1208
neilt6 0:697ca602e934 265 *
neilt6 0:697ca602e934 266 * @returns The current battery mode analog trim as a BatteryModeATR enum.
neilt6 0:697ca602e934 267 */
neilt6 2:f33dbb2535a3 268 ISL1208::BatteryModeATR batteryModeATR();
neilt6 0:697ca602e934 269
neilt6 0:697ca602e934 270 /** Set the battery mode analog trim of the ISL1208
neilt6 0:697ca602e934 271 *
neilt6 0:697ca602e934 272 * @param mode The new battery mode analog trim as a BatteryModeATR enum.
neilt6 0:697ca602e934 273 */
neilt6 0:697ca602e934 274 void batteryModeATR(BatteryModeATR atr);
neilt6 0:697ca602e934 275
neilt6 0:697ca602e934 276 /** Get the current digital trim of the ISL1208
neilt6 0:697ca602e934 277 *
neilt6 0:697ca602e934 278 * @returns The current digital trim as a DigitalTrim enum.
neilt6 0:697ca602e934 279 */
neilt6 2:f33dbb2535a3 280 ISL1208::DigitalTrim digitalTrim();
neilt6 0:697ca602e934 281
neilt6 0:697ca602e934 282 /** Set the digital trim of the ISL1208
neilt6 0:697ca602e934 283 *
neilt6 0:697ca602e934 284 * @param mode The new digital trim as a DigitalTrim enum.
neilt6 0:697ca602e934 285 */
neilt6 0:697ca602e934 286 void digitalTrim(DigitalTrim dtr);
neilt6 0:697ca602e934 287
neilt6 0:697ca602e934 288 /** Get the alarm time from the ISL1208
neilt6 0:697ca602e934 289 *
neilt6 0:697ca602e934 290 * @returns The current alarm time as a Unix timestamp (with the current year)
neilt6 0:697ca602e934 291 */
neilt6 2:f33dbb2535a3 292 time_t alarmTime();
neilt6 0:697ca602e934 293
neilt6 0:697ca602e934 294 /** Set the alarm time on the ISL1208 from a Unix timestamp
neilt6 0:697ca602e934 295 *
neilt6 0:697ca602e934 296 * @param t The alarm time as a Unix timestamp.
neilt6 0:697ca602e934 297 * @param sc Enable or disable seconds matching.
neilt6 0:697ca602e934 298 * @param mn Enable or disable minutes matching.
neilt6 0:697ca602e934 299 * @param hr Enable or disable hours matching.
neilt6 0:697ca602e934 300 * @param dt Enable or disable date matching.
neilt6 0:697ca602e934 301 * @param mo Enable or disable month matching.
neilt6 0:697ca602e934 302 * @param dw Enable or disable day of week matching.
neilt6 0:697ca602e934 303 */
neilt6 0:697ca602e934 304 void alarmTime(time_t t, bool sc = true, bool mn = true, bool hr = true, bool dt = true, bool mo = true, bool dw = true);
neilt6 0:697ca602e934 305
neilt6 0:697ca602e934 306 /** Read the contents of the battery-backed SRAM
neilt6 0:697ca602e934 307 *
neilt6 0:697ca602e934 308 * @returns The current contents of the SRAM.
neilt6 0:697ca602e934 309 */
neilt6 2:f33dbb2535a3 310 unsigned short sram();
neilt6 0:697ca602e934 311
neilt6 0:697ca602e934 312 /** Write new data to the battery-backed SRAM
neilt6 0:697ca602e934 313 *
neilt6 0:697ca602e934 314 * @param data The new data for the SRAM.
neilt6 0:697ca602e934 315 */
neilt6 0:697ca602e934 316 void sram(unsigned short data);
neilt6 0:697ca602e934 317
neilt6 0:697ca602e934 318 private:
neilt6 0:697ca602e934 319 //I2C register addresses
neilt6 0:697ca602e934 320 enum Register {
neilt6 0:697ca602e934 321 REG_RTC_SC = 0x00,
neilt6 0:697ca602e934 322 REG_RTC_MN,
neilt6 0:697ca602e934 323 REG_RTC_HR,
neilt6 0:697ca602e934 324 REG_RTC_DT,
neilt6 0:697ca602e934 325 REG_RTC_MO,
neilt6 0:697ca602e934 326 REG_RTC_YR,
neilt6 0:697ca602e934 327 REG_RTC_DW,
neilt6 0:697ca602e934 328 REG_CTL_SR,
neilt6 0:697ca602e934 329 REG_CTL_INT,
neilt6 0:697ca602e934 330 REG_CTL_ATR = 0x0A,
neilt6 0:697ca602e934 331 REG_CTL_DTR,
neilt6 0:697ca602e934 332 REG_ALM_SCA,
neilt6 0:697ca602e934 333 REG_ALM_MNA,
neilt6 0:697ca602e934 334 REG_ALM_HRA,
neilt6 0:697ca602e934 335 REG_ALM_DTA,
neilt6 0:697ca602e934 336 REG_ALM_MOA,
neilt6 0:697ca602e934 337 REG_ALM_DWA,
neilt6 0:697ca602e934 338 REG_USR_USR1,
neilt6 0:697ca602e934 339 REG_USR_USR2
neilt6 0:697ca602e934 340 };
neilt6 0:697ca602e934 341
neilt6 0:697ca602e934 342 //Member constants
neilt6 5:d67ac8351c76 343 static const int m_ADDR;
neilt6 0:697ca602e934 344
neilt6 0:697ca602e934 345 //Member variables
goranirnas 7:00b8ead188f8 346 I2C *m_I2C;
neilt6 0:697ca602e934 347
neilt6 0:697ca602e934 348 //Internal functions
neilt6 0:697ca602e934 349 char read8(char reg);
neilt6 0:697ca602e934 350 void write8(char reg, char data);
neilt6 0:697ca602e934 351 unsigned short read16(char reg);
neilt6 0:697ca602e934 352 void write16(char reg, unsigned short data);
neilt6 0:697ca602e934 353 unsigned int bcd2bin(unsigned char val);
neilt6 0:697ca602e934 354 char bin2bcd(unsigned int val);
neilt6 0:697ca602e934 355 };
neilt6 0:697ca602e934 356
neilt6 0:697ca602e934 357 #endif