librairie DS1338
Fork of rtc_lib by
ds1338.h@0:69d7ae72902c, 2016-10-11 (annotated)
- Committer:
- Asoumy
- Date:
- Tue Oct 11 13:24:16 2016 +0000
- Revision:
- 0:69d7ae72902c
RTC;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Asoumy | 0:69d7ae72902c | 1 | #ifndef __EEPROM__H_ |
Asoumy | 0:69d7ae72902c | 2 | #define __EEPROM__H_ |
Asoumy | 0:69d7ae72902c | 3 | |
Asoumy | 0:69d7ae72902c | 4 | #include "mbed.h" |
Asoumy | 0:69d7ae72902c | 5 | |
Asoumy | 0:69d7ae72902c | 6 | #define DS1338_ADR 0xd0 |
Asoumy | 0:69d7ae72902c | 7 | #define DS1338_BUFFER_SIZE 10 |
Asoumy | 0:69d7ae72902c | 8 | |
Asoumy | 0:69d7ae72902c | 9 | |
Asoumy | 0:69d7ae72902c | 10 | /** |
Asoumy | 0:69d7ae72902c | 11 | * class to use a DS1338 rtc |
Asoumy | 0:69d7ae72902c | 12 | */ |
Asoumy | 0:69d7ae72902c | 13 | class DS1338 { |
Asoumy | 0:69d7ae72902c | 14 | public: |
Asoumy | 0:69d7ae72902c | 15 | /* |
Asoumy | 0:69d7ae72902c | 16 | * Constructor, initialize the ds1338 on i2c interface. |
Asoumy | 0:69d7ae72902c | 17 | * @param sda : sda i2c pin (PinName) |
Asoumy | 0:69d7ae72902c | 18 | * @param scl : scl i2c pin (PinName) |
Asoumy | 0:69d7ae72902c | 19 | */ |
Asoumy | 0:69d7ae72902c | 20 | DS1338(PinName sda, PinName scl); |
Asoumy | 0:69d7ae72902c | 21 | /** |
Asoumy | 0:69d7ae72902c | 22 | * read bytes |
Asoumy | 0:69d7ae72902c | 23 | * @param adr the start address |
Asoumy | 0:69d7ae72902c | 24 | * @param count number of byte to read |
Asoumy | 0:69d7ae72902c | 25 | * @param data where to put the bytes |
Asoumy | 0:69d7ae72902c | 26 | * @return the byte |
Asoumy | 0:69d7ae72902c | 27 | */ |
Asoumy | 0:69d7ae72902c | 28 | void read(unsigned char adr,unsigned char count,char * data); |
Asoumy | 0:69d7ae72902c | 29 | /** |
Asoumy | 0:69d7ae72902c | 30 | * write bytes |
Asoumy | 0:69d7ae72902c | 31 | * @param adr the start address |
Asoumy | 0:69d7ae72902c | 32 | * @param count number of byte to write |
Asoumy | 0:69d7ae72902c | 33 | * @param data to be written |
Asoumy | 0:69d7ae72902c | 34 | * @return the byte |
Asoumy | 0:69d7ae72902c | 35 | */ |
Asoumy | 0:69d7ae72902c | 36 | void write(unsigned char adr,unsigned char count,char * data); |
Asoumy | 0:69d7ae72902c | 37 | /** |
Asoumy | 0:69d7ae72902c | 38 | * read the current time |
Asoumy | 0:69d7ae72902c | 39 | * @param x the time; |
Asoumy | 0:69d7ae72902c | 40 | */ |
Asoumy | 0:69d7ae72902c | 41 | void readTime(tm * x); |
Asoumy | 0:69d7ae72902c | 42 | /** |
Asoumy | 0:69d7ae72902c | 43 | * read the current time |
Asoumy | 0:69d7ae72902c | 44 | * @param x the time; |
Asoumy | 0:69d7ae72902c | 45 | */ |
Asoumy | 0:69d7ae72902c | 46 | void writeTime(tm * x); |
Asoumy | 0:69d7ae72902c | 47 | private: |
Asoumy | 0:69d7ae72902c | 48 | I2C _i2c; |
Asoumy | 0:69d7ae72902c | 49 | char buffer[DS1338_BUFFER_SIZE]; |
Asoumy | 0:69d7ae72902c | 50 | }; |
Asoumy | 0:69d7ae72902c | 51 | #endif |