Stéphane Cachat / DS1338
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ds1338.h Source File

ds1338.h

00001 #ifndef __EEPROM__H_
00002 #define __EEPROM__H_
00003 
00004 #include "mbed.h"
00005 
00006 #define DS1338_ADR     0xd0
00007 #define DS1338_BUFFER_SIZE 10
00008 
00009 
00010 /**
00011  * class to use a DS1338 rtc
00012  */
00013 class DS1338 {
00014 public:
00015     /*
00016      * Constructor, initialize the ds1338 on i2c interface.
00017      * @param sda : sda i2c pin (PinName)
00018      * @param scl : scl i2c pin (PinName)
00019     */
00020     DS1338(PinName sda, PinName scl);
00021     /**
00022      * read bytes
00023      * @param adr the start address
00024      * @param count number of byte to read
00025      * @param data where to put the bytes
00026      * @return the byte
00027      */
00028     void read(unsigned char adr,unsigned char count,char * data);
00029     /**
00030      * write bytes
00031      * @param adr the start address
00032      * @param count number of byte to write
00033      * @param data to be written
00034      * @return the byte
00035      */
00036     void write(unsigned char adr,unsigned char count,char * data);
00037     /**
00038      * read the current time
00039      * @param x the time;
00040      */
00041     void readTime(tm * x);
00042     /**
00043      * read the current time
00044      * @param x the time;
00045      */
00046     void writeTime(tm * x);
00047 private:
00048     I2C _i2c;
00049     char buffer[DS1338_BUFFER_SIZE];
00050 };
00051 #endif