Dino Martic / RTC-DS1307

Dependents:   Detektor_Pokreta Dino_Martic_Programski

RtcCls.h

Committer:
leihen
Date:
2013-06-23
Revision:
4:d2cc690aaac7
Child:
5:30531f2121a2

File content as of revision 4:d2cc690aaac7:

#ifndef __RTC_H__
#define __RTC_H__

#include "Rtc_Ds1307.h"
#include "mbed.h"

typedef void (*callback_t)(void);

class RtcCls   :   public Rtc_Ds1307
{
    protected:
        InterruptIn         m_sqw;
        bool                m_bUseSqw;
        time_t              m_time;             //  Only used in case of SQW use
        
        bool                m_bAlarmEnabled;
        callback_t          m_alarmfunc;
        time_t              m_alarmTime;
        
    public:
        RtcCls(PinName sda, PinName scl, PinName sqw, bool bUseSqw);

    protected:        
        static void _callback(void);
        
    public:
        time_t              getTime();
        void                setTime(time_t t);
    public: 
        void                setAlarm(int nSeconds, callback_t alarmfunc)
        {
            m_alarmfunc = alarmfunc;
            m_alarmTime = m_time + nSeconds;
            m_bAlarmEnabled = (alarmfunc == NULL) ? false : true;
        }
};

#endif //   __RTC_H__