Code to interface with the MCP7940 Real time clock. Supports getting and setting the time in 24 hour format
Diff: MCP7940.h
- Revision:
- 1:8f330348d96b
- Child:
- 2:941a59078507
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MCP7940.h Tue Sep 29 07:56:30 2015 +0000 @@ -0,0 +1,60 @@ +#ifndef __MCP7940_H__ +#define __MCP7940_H__ + +#include "mbed.h" + +class MCP7940{ +public: +MCP7940(PinName sda, PinName scl); +MCP7940(PinName sda, PinName scl, int StartYear); +MCP7940(); + int Day(); + int Month(); + int Year(); + int Hour(); + int Minutes(); + int Seconds(); + int MilliSeconds(); + int DayOfWeek(); + + int setTime(); + int setTime(int Year, int Month, int Day, int Hour, int Mins); + int setTime(int Year, int Month, int Day, int Hour, int Mins, int Secs); + int setTime(int Year, int Month, int Day, int Hour, int Mins, int Secs, int MiliSecs); + int setTime(int Year, int Month, int Day, int Hour, int Mins, int Secs, int MiliSecs, int DayOfWeek); + + int setDefaultTime(); + int getTime(); + void StartClock(); + char IntToBCD(char Data); + char BCDtoInt(char Data); + + char * TimeStamp(); + void TimeStamp(char * buf); + void niceTimeStamp(char * buf); + void niceDate(char * buf); + void niceTime(char * buf); + + private: + char _TimeStamp[20]; + int _Day; + int _Month; + int _Year; + int _Hour; + int _Minutes; + int _Seconds; + int _MilliSeconds; + int _DayOfWeek; + + int _YearStart; + + protected: + I2C Clock; + + int _addr; + + +}; + + +#endif \ No newline at end of file