RTC PCF2129 Library

Files at this revision

API Documentation at this revision

Comitter:
king33jp
Date:
Tue Jul 21 15:13:41 2015 +0000
Parent:
0:7f72438fee70
Commit message:
i2c addr parameter is deleted.

Changed in this revision

PCF2129.cpp Show annotated file Show diff for this revision Revisions of this file
PCF2129.h Show annotated file Show diff for this revision Revisions of this file
diff -r 7f72438fee70 -r a2f545432493 PCF2129.cpp
--- a/PCF2129.cpp	Thu Jul 16 14:51:05 2015 +0000
+++ b/PCF2129.cpp	Tue Jul 21 15:13:41 2015 +0000
@@ -5,8 +5,9 @@
 
 #include    "mbed.h"
 #include    "PCF2129.h"
+#define PCF2129_ADDRESS   0xA2
 
-PCF2129::PCF2129( PinName sda, PinName scl, char addr ) : m_i2c( sda, scl),m_addr(addr)
+PCF2129::PCF2129( PinName sda, PinName scl ) : m_i2c( sda, scl)
 {
     init( 0, 0, 0, 0x07 );      // int disable,CLKout diable
 }
@@ -27,7 +28,7 @@
     data[ 2 ]   = vControl_2;
     data[ 3 ]   = vControl_3;
 
-    err     = m_i2c.write( m_addr , data, sizeof( data ) );
+    err     = m_i2c.write( PCF2129_ADDRESS , data, sizeof( data ) );
     err    |= set_register( 0x0F, vCLKOUT_ctl );    // ClockOut Control
 
     return ( err ? I2C_ACCESS_FAIL : NO_ERROR );
@@ -51,7 +52,7 @@
     buf[ 6 ]    = Dec2RtcData( dtp->tm_mon  + 1   );
     buf[ 7 ]    = Dec2RtcData( dtp->tm_year - 100 );
 
-    err = m_i2c.write( m_addr, buf, 8 );
+    err = m_i2c.write( PCF2129_ADDRESS, buf, 8 );
 
     return ( err ? I2C_ACCESS_FAIL : NO_ERROR );
 }
@@ -69,10 +70,10 @@
 
     buf[ 0 ]    = 0x03;         //Seconds;  //  read start register address
 
-    if ( m_i2c.write( m_addr, buf, 1 ) )
+    if ( m_i2c.write( PCF2129_ADDRESS, buf, 1 ) )
         return ( TIME_FUNC_ERROR );
 
-    if ( m_i2c.read( m_addr, buf, 7 ) )
+    if ( m_i2c.read( PCF2129_ADDRESS, buf, 7 ) )
         return ( TIME_FUNC_ERROR );
 
     dtp->tm_sec     = RtcData2Dec( buf[ 0 ] );
@@ -106,7 +107,7 @@
     b[ 0 ]    = reg_addr;
     b[ 1 ]    = reg_data;
 
-    return ( m_i2c.write( m_addr, b, sizeof( b ) ) );
+    return ( m_i2c.write( PCF2129_ADDRESS, b, sizeof( b ) ) );
 }
 
 int PCF2129::read_register( char reg_addr )
@@ -114,8 +115,8 @@
     char    data;
 
     data    = reg_addr;
-    m_i2c.write( m_addr, &data, 1 );
-    m_i2c.read( m_addr, &data, 1 );
+    m_i2c.write( PCF2129_ADDRESS, &data, 1 );
+    m_i2c.read( PCF2129_ADDRESS, &data, 1 );
 
     return ( data );
 }
diff -r 7f72438fee70 -r a2f545432493 PCF2129.h
--- a/PCF2129.h	Thu Jul 16 14:51:05 2015 +0000
+++ b/PCF2129.h	Tue Jul 21 15:13:41 2015 +0000
@@ -70,9 +70,8 @@
      *
      *  @param I2C_sda      I2C-bus SDA pin
      *  @param I2C_scl      I2C-bus SCL pin
-     *  @param I2C_addr     I2C-bus slave address
      */
-    PCF2129( PinName sda, PinName scl , char addr);
+    PCF2129( PinName sda, PinName scl );
 
     /** Destractor
      */
@@ -117,7 +116,6 @@
     int     read_register( char reg_addr );
    
     I2C     m_i2c;
-    char    m_addr;
 }
 ;
 #endif  // end of "#ifndef MBED_PCF2129"