EEPROM with 64kByte Memory

Files at this revision

API Documentation at this revision

Comitter:
x1dmoesc
Date:
Tue Mar 05 09:44:30 2019 +0000
Parent:
3:8a0bfc787463
Commit message:
debug function write() and read()

Changed in this revision

AT24C64D.cpp Show annotated file Show diff for this revision Revisions of this file
AT24C64D.h Show annotated file Show diff for this revision Revisions of this file
--- a/AT24C64D.cpp	Fri Mar 01 11:26:26 2019 +0000
+++ b/AT24C64D.cpp	Tue Mar 05 09:44:30 2019 +0000
@@ -28,6 +28,22 @@
 }
 
 
+//******************************************************************************//
+//  Returns the address of the spi bus. This is the combination of the Hardware //
+//  chip address and the user defined addres [A2..A0]                           //
+//******************************************************************************//
+uint8_t AT24C64D::getAddrBus(){
+    return AT24C64D_W;
+}
+
+
+
+//******************************************************************************//
+//  Returns the user defined address [A2..A0]                                   //
+//******************************************************************************//
+uint8_t AT24C64D::getAddrUser(){
+    return (AT24C64D_W >> 1) & USER_ADDR_MASK;
+}
 
 //******************************************************************************//
 //  Sets the address for the writing position. If the address is higher as the  //
@@ -131,7 +147,7 @@
 // not implemented
 /******************************************************************************/
 bool  AT24C64D::erase(){
-    return ACK;
+    return NACK;
 }
 
 
@@ -160,8 +176,6 @@
     while(not isReady());
     ACKpolling(AT24C64D_W);
     
-//    printf("TimeOut: %d\n", uiTimeOut);
-    
     uiAddr      = uiAddr & ADDR_MASK;            
     cBuffer[0]  = (uiAddr >> 8) & 0xFF;
     cBuffer[1]  = uiAddr & 0xFF;
@@ -174,7 +188,7 @@
     
     
     uiAddrWrite = uiAddr;
-    incAddrWrite();
+    //incAddrWrite();
     
     return bAck;
 }
@@ -196,16 +210,7 @@
 //
 //******************************************************************************//
 bool AT24C64D::read(char *cData){ 
-
-    //bAck = ACKpolling(AT24C64D_R);                                              // polling for ACK
-    
-    //if(bAck == ACK){        
-        i2c->start();                                                           // send a start condition
-        i2c->write(AT24C64D_R);
-        *cData = i2c->read(false);
-        i2c->stop();
-    //}
-    return bAck;
+    return read(uiAddrRead, cData);
 }
 
 
--- a/AT24C64D.h	Fri Mar 01 11:26:26 2019 +0000
+++ b/AT24C64D.h	Tue Mar 05 09:44:30 2019 +0000
@@ -18,6 +18,8 @@
     
         // function
         AT24C64D(I2C *_i2c, uint8_t uiAddr);
+        virtual uint8_t getAddrBus();
+        virtual uint8_t getAddrUser();
         
         virtual bool write(char * cData);
         virtual bool write(uint16_t uiAddr, char *cData);
@@ -73,7 +75,7 @@
         uint8_t uiAddrQuotient;                                                  // 
         uint8_t uiAddrRemainder;                                                 //         
         
-        //char cBuffer[2 + SIZE_PAGE];                                            // 2 Address Bytes + 32 Byte Data
+        char cBuffer[2 + SIZE_PAGE];                                            // 2 Address Bytes + 32 Byte Data
         
         // Class
         I2C *i2c;
@@ -85,7 +87,6 @@
         void startTimer();
         bool ACKpolling(uint8_t uiAdr);
         //virtual void abortTransmition();
-        
 
 };