A feature complete driver for the ISL1208 real time clock from Intersil.
Dependents: ISL1208_HelloWorld
Revision 2:f33dbb2535a3, committed 2013-11-07
- Comitter:
- neilt6
- Date:
- Thu Nov 07 17:58:43 2013 +0000
- Parent:
- 1:c951ff6da740
- Child:
- 3:115e4dacfe07
- Commit message:
- Minor improvements
Changed in this revision
ISL1208.cpp | Show annotated file Show diff for this revision Revisions of this file |
ISL1208.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/ISL1208.cpp Mon Sep 16 22:06:51 2013 +0000 +++ b/ISL1208.cpp Thu Nov 07 17:58:43 2013 +0000 @@ -18,7 +18,8 @@ ISL1208::ISL1208(PinName sda, PinName scl) : m_I2C(sda, scl) { - //Nothing else to initialize + //Set the I2C bus frequency to 400kHz + m_I2C.frequency(400000); } bool ISL1208::open(OscillatorMode mode) @@ -48,7 +49,7 @@ } } -time_t ISL1208::time(void) +time_t ISL1208::time() { //Setup a tm structure based on the RTC struct tm timeinfo; @@ -110,7 +111,7 @@ write8(REG_CTL_SR, sr); } -bool ISL1208::powerFailed(void) +bool ISL1208::powerFailed() { //Read the 8-bit register value char value = read8(REG_CTL_SR); @@ -122,7 +123,7 @@ return false; } -bool ISL1208::batteryFlag(void) +bool ISL1208::batteryFlag() { //Read the 8-bit register value char value = read8(REG_CTL_SR); @@ -134,7 +135,7 @@ return false; } -void ISL1208::clearBatteryFlag(void) +void ISL1208::clearBatteryFlag() { //Read the current 8-bit register value char value = read8(REG_CTL_SR); @@ -146,7 +147,7 @@ write8(REG_CTL_SR, value); } -bool ISL1208::alarmFlag(void) +bool ISL1208::alarmFlag() { //Read the 8-bit register value char value = read8(REG_CTL_SR); @@ -158,7 +159,7 @@ return false; } -void ISL1208::clearAlarmFlag(void) +void ISL1208::clearAlarmFlag() { //Read the current 8-bit register value char value = read8(REG_CTL_SR); @@ -170,7 +171,7 @@ write8(REG_CTL_SR, value); } -ISL1208::OutputFrequency ISL1208::foutFrequency(void) +ISL1208::OutputFrequency ISL1208::foutFrequency() { //Read the 8-bit register value char value = read8(REG_CTL_INT); @@ -194,7 +195,7 @@ write8(REG_CTL_INT, value); } -bool ISL1208::outputOnBattery(void) +bool ISL1208::outputOnBattery() { //Read the 8-bit register value char value = read8(REG_CTL_INT); @@ -221,7 +222,7 @@ write8(REG_CTL_INT, value); } -ISL1208::PowerMode ISL1208::powerMode(void) +ISL1208::PowerMode ISL1208::powerMode() { //Read the 8-bit register value char value = read8(REG_CTL_INT); @@ -248,7 +249,7 @@ write8(REG_CTL_INT, value); } -ISL1208::AlarmMode ISL1208::alarmMode(void) +ISL1208::AlarmMode ISL1208::alarmMode() { //Read the 8-bit register value char value = read8(REG_CTL_INT); @@ -282,7 +283,7 @@ write8(REG_CTL_INT, value); } -float ISL1208::analogTrim(void) +float ISL1208::analogTrim() { //Read the 8-bit register value char value = read8(REG_CTL_ATR); @@ -330,7 +331,7 @@ write8(REG_CTL_ATR, reg); } -ISL1208::BatteryModeATR ISL1208::batteryModeATR(void) +ISL1208::BatteryModeATR ISL1208::batteryModeATR() { //Read the 8-bit register value char value = read8(REG_CTL_ATR); @@ -357,7 +358,7 @@ write8(REG_CTL_ATR, value); } -ISL1208::DigitalTrim ISL1208::digitalTrim(void) +ISL1208::DigitalTrim ISL1208::digitalTrim() { //Read the 8-bit register value char value = read8(REG_CTL_DTR); @@ -384,7 +385,7 @@ write8(REG_CTL_DTR, value); } -time_t ISL1208::alarmTime(void) +time_t ISL1208::alarmTime() { //Setup a tm structure based on the RTC struct tm timeinfo; @@ -436,7 +437,7 @@ write8(REG_ALM_DWA, 0x0); } -unsigned short ISL1208::sram(void) +unsigned short ISL1208::sram() { //Return the complete contents of the SRAM return read16(REG_USR_USR1);
--- a/ISL1208.h Mon Sep 16 22:06:51 2013 +0000 +++ b/ISL1208.h Thu Nov 07 17:58:43 2013 +0000 @@ -151,7 +151,7 @@ * * @returns The current time as a Unix timestamp. */ - time_t time(void); + time_t time(); /** Set the current time on the ISL1208 from a Unix timestamp * @@ -163,33 +163,33 @@ * * @returns Whether or not the RTC has completely lost power. */ - bool powerFailed(void); + bool powerFailed(); /** Determine whether the RTC has been on battery backup * * @returns Whether or not the RTC has been on battery backup. */ - bool batteryFlag(void); + bool batteryFlag(); /** Clear the battery backup flag */ - void clearBatteryFlag(void); + void clearBatteryFlag(); /** Determine whether the alarm has matched the RTC * * @returns Whether or not the alarm has matched the RTC. */ - bool alarmFlag(void); + bool alarmFlag(); /** Clear the alarm flag */ - void clearAlarmFlag(void); + void clearAlarmFlag(); /** Get the current output frequency on the IRQ/fOUT pin * * @returns The current output frequency. */ - ISL1208::OutputFrequency foutFrequency(void); + ISL1208::OutputFrequency foutFrequency(); /** Set the output frequency on the IRQ/fOUT pin * @@ -201,7 +201,7 @@ * * @returns Whether or not the IRQ/fOUT pin will continue to output on battery power. */ - bool outputOnBattery(void); + bool outputOnBattery(); /** Set whether or not the IRQ/fOUT pin should continue to output on battery power * @@ -213,7 +213,7 @@ * * @returns The current power mode as a PowerMode enum. */ - ISL1208::PowerMode powerMode(void); + ISL1208::PowerMode powerMode(); /** Set the power mode of the ISL1208 * @@ -225,7 +225,7 @@ * * @returns The current alarm mode as an AlarmMode enum. */ - ISL1208::AlarmMode alarmMode(void); + ISL1208::AlarmMode alarmMode(); /** Set the alarm mode of the ISL1208 * @@ -237,7 +237,7 @@ * * @returns The current analog trim in pF. */ - float analogTrim(void); + float analogTrim(); /** Set the analog trim of the ISL1208 * @@ -249,7 +249,7 @@ * * @returns The current battery mode analog trim as a BatteryModeATR enum. */ - ISL1208::BatteryModeATR batteryModeATR(void); + ISL1208::BatteryModeATR batteryModeATR(); /** Set the battery mode analog trim of the ISL1208 * @@ -261,7 +261,7 @@ * * @returns The current digital trim as a DigitalTrim enum. */ - ISL1208::DigitalTrim digitalTrim(void); + ISL1208::DigitalTrim digitalTrim(); /** Set the digital trim of the ISL1208 * @@ -273,7 +273,7 @@ * * @returns The current alarm time as a Unix timestamp (with the current year) */ - time_t alarmTime(void); + time_t alarmTime(); /** Set the alarm time on the ISL1208 from a Unix timestamp * @@ -291,7 +291,7 @@ * * @returns The current contents of the SRAM. */ - unsigned short sram(void); + unsigned short sram(); /** Write new data to the battery-backed SRAM *