EMIR - Ekvitermní mikroprocesorová regulace https://code.google.com/p/emir/ https://code.google.com/p/emir/wiki/DesignV3

Dependencies:   ConfigFile DS1307 OneWire SDFileSystem USBDeviceLite mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers rtc.cpp Source File

rtc.cpp

00001 #include "mbed.h"
00002 #include "rtos.h"
00003 #include "DS1307.h"
00004 #include "rtc.h"
00005 
00006 DS1307 rtc(I2C_SDA, I2C_SCL);
00007 Mutex rtc_mutex;
00008 
00009 time_t get_rtc()
00010 {
00011     rtc_mutex.lock();
00012     time_t m_time = rtc.now();
00013     rtc_mutex.unlock();
00014     set_time(m_time);
00015     return m_time;
00016 }
00017 
00018 bool set_rtc(time_t time)
00019 {
00020     rtc_mutex.lock();
00021     bool b = rtc.set_time(time);
00022     rtc_mutex.unlock();
00023     set_time(time);
00024     return b;
00025 }