Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Detektor_Pokreta Dino_Martic_Programski
RtcCls.h@6:bba89618ee63, 2013-06-23 (annotated)
- Committer:
- leihen
- Date:
- Sun Jun 23 18:26:47 2013 +0000
- Revision:
- 6:bba89618ee63
- Parent:
- 5:30531f2121a2
rewritten the Header due to some strange error while compiling.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| leihen | 6:bba89618ee63 | 1 | /* RtcCls.h */ |
| leihen | 6:bba89618ee63 | 2 | /* |
| leihen | 6:bba89618ee63 | 3 | Copyright (c) 2013 Henry Leinen (henry[dot]leinen [at] online [dot] de) |
| leihen | 6:bba89618ee63 | 4 | |
| leihen | 6:bba89618ee63 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy |
| leihen | 6:bba89618ee63 | 6 | of this software and associated documentation files (the "Software"), to deal |
| leihen | 6:bba89618ee63 | 7 | in the Software without restriction, including without limitation the rights |
| leihen | 6:bba89618ee63 | 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| leihen | 6:bba89618ee63 | 9 | copies of the Software, and to permit persons to whom the Software is |
| leihen | 6:bba89618ee63 | 10 | furnished to do so, subject to the following conditions: |
| leihen | 6:bba89618ee63 | 11 | |
| leihen | 6:bba89618ee63 | 12 | The above copyright notice and this permission notice shall be included in |
| leihen | 6:bba89618ee63 | 13 | all copies or substantial portions of the Software. |
| leihen | 6:bba89618ee63 | 14 | |
| leihen | 6:bba89618ee63 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| leihen | 6:bba89618ee63 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| leihen | 6:bba89618ee63 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| leihen | 6:bba89618ee63 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| leihen | 6:bba89618ee63 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| leihen | 6:bba89618ee63 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| leihen | 6:bba89618ee63 | 21 | THE SOFTWARE. |
| leihen | 6:bba89618ee63 | 22 | */ |
| leihen | 6:bba89618ee63 | 23 | #ifndef __RTCCLS_H__ |
| leihen | 6:bba89618ee63 | 24 | #define __RTCCLS_H__ |
| leihen | 5:30531f2121a2 | 25 | |
| leihen | 4:d2cc690aaac7 | 26 | |
| leihen | 4:d2cc690aaac7 | 27 | #include "Rtc_Ds1307.h" |
| leihen | 4:d2cc690aaac7 | 28 | |
| leihen | 6:bba89618ee63 | 29 | typedef void (*RtcCallback_t) (void); |
| leihen | 4:d2cc690aaac7 | 30 | |
| leihen | 6:bba89618ee63 | 31 | |
| leihen | 6:bba89618ee63 | 32 | class RtcCls : public Rtc_Ds1307 |
| leihen | 4:d2cc690aaac7 | 33 | { |
| leihen | 5:30531f2121a2 | 34 | protected: |
| leihen | 6:bba89618ee63 | 35 | InterruptIn m_sqw; |
| leihen | 6:bba89618ee63 | 36 | bool m_bUseSqw; |
| leihen | 6:bba89618ee63 | 37 | time_t m_time; // Only used in case SQW is used |
| leihen | 6:bba89618ee63 | 38 | |
| leihen | 6:bba89618ee63 | 39 | bool m_bAlarmEnabled; |
| leihen | 6:bba89618ee63 | 40 | RtcCallback_t m_alarmfunc; |
| leihen | 6:bba89618ee63 | 41 | time_t m_alarmTime; |
| leihen | 6:bba89618ee63 | 42 | |
| leihen | 5:30531f2121a2 | 43 | public: |
| leihen | 5:30531f2121a2 | 44 | RtcCls(PinName sda, PinName scl, PinName sqw, bool bUseSqw); |
| leihen | 6:bba89618ee63 | 45 | |
| leihen | 5:30531f2121a2 | 46 | protected: |
| leihen | 5:30531f2121a2 | 47 | static void _callback(void); |
| leihen | 6:bba89618ee63 | 48 | |
| leihen | 5:30531f2121a2 | 49 | public: |
| leihen | 6:bba89618ee63 | 50 | time_t getTime(); |
| leihen | 6:bba89618ee63 | 51 | void setTime(time_t t); |
| leihen | 5:30531f2121a2 | 52 | public: |
| leihen | 6:bba89618ee63 | 53 | void setAlarm(int nSeconds, RtcCallback_t alarmfunc) { |
| leihen | 5:30531f2121a2 | 54 | m_alarmfunc = alarmfunc; |
| leihen | 5:30531f2121a2 | 55 | m_alarmTime = m_time + nSeconds; |
| leihen | 5:30531f2121a2 | 56 | m_bAlarmEnabled = (alarmfunc == NULL) ? false : true; |
| leihen | 5:30531f2121a2 | 57 | } |
| leihen | 4:d2cc690aaac7 | 58 | }; |
| leihen | 6:bba89618ee63 | 59 | |
| leihen | 6:bba89618ee63 | 60 | #endif // __RTCCLS_H__ |