Simple RTC class based on DS1307. Emphasis on simple. Allows you to run at 100k or 400k Hz (for newer DS1307 capable devices). MapTime() allows you to set the time() service to the same as the RTC. Uses struct tm throughout so you can use traditional time functions for manipulation.
time_helper.cpp
- Committer:
- vtraveller
- Date:
- 2014-08-11
- Revision:
- 8:2192f2809f59
File content as of revision 8:2192f2809f59:
#include "mbed.h" #include "time_helper.h" void GetTime(tm & out_sTM) { time_t nTime = time(0); tm * pTM = ::localtime(&nTime); ::memcpy(&out_sTM,pTM,sizeof(out_sTM)); } void SetTime(const tm & in_sTM) { tm sTM = { 0 }; memcpy(&sTM,&in_sTM,sizeof(sTM)); time_t nTime = mktime(&sTM); set_time(nTime); }