RTC on M0 and class design without rtc and target
Quote:
Example for training purposes only!!!
RTC/I2C data for target LPC11U24 Humer M0-Board and no data for others!!!
See RTC WIKI
rtc.h@0:397b5462e6d7, 2018-11-15 (annotated)
- Committer:
- fpucher
- Date:
- Thu Nov 15 06:55:25 2018 +0000
- Revision:
- 0:397b5462e6d7
ifdef target
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fpucher | 0:397b5462e6d7 | 1 | /*********************************** |
fpucher | 0:397b5462e6d7 | 2 | name: rtc.h Version: 0.1 |
fpucher | 0:397b5462e6d7 | 3 | author: PE HTL BULME |
fpucher | 0:397b5462e6d7 | 4 | email: pe@bulme.at |
fpucher | 0:397b5462e6d7 | 5 | description: |
fpucher | 0:397b5462e6d7 | 6 | Definition portion of the class rtc |
fpucher | 0:397b5462e6d7 | 7 | |
fpucher | 0:397b5462e6d7 | 8 | |
fpucher | 0:397b5462e6d7 | 9 | ***********************************/ |
fpucher | 0:397b5462e6d7 | 10 | |
fpucher | 0:397b5462e6d7 | 11 | #include "mbed.h" |
fpucher | 0:397b5462e6d7 | 12 | #include "const.h" |
fpucher | 0:397b5462e6d7 | 13 | |
fpucher | 0:397b5462e6d7 | 14 | #if !defined (RTC_H) |
fpucher | 0:397b5462e6d7 | 15 | #define RTC_H |
fpucher | 0:397b5462e6d7 | 16 | |
fpucher | 0:397b5462e6d7 | 17 | /** RTC Class |
fpucher | 0:397b5462e6d7 | 18 | */ |
fpucher | 0:397b5462e6d7 | 19 | |
fpucher | 0:397b5462e6d7 | 20 | /** |
fpucher | 0:397b5462e6d7 | 21 | name: rtc.h Version: 0.1 |
fpucher | 0:397b5462e6d7 | 22 | author: PE HTL BULME |
fpucher | 0:397b5462e6d7 | 23 | email: pe@bulme.at |
fpucher | 0:397b5462e6d7 | 24 | description: |
fpucher | 0:397b5462e6d7 | 25 | Definition portion of the class rtc |
fpucher | 0:397b5462e6d7 | 26 | |
fpucher | 0:397b5462e6d7 | 27 | |
fpucher | 0:397b5462e6d7 | 28 | ***********************************/ |
fpucher | 0:397b5462e6d7 | 29 | class RTC |
fpucher | 0:397b5462e6d7 | 30 | { |
fpucher | 0:397b5462e6d7 | 31 | protected: |
fpucher | 0:397b5462e6d7 | 32 | //PinName _sda, _scl; |
fpucher | 0:397b5462e6d7 | 33 | #ifdef TARGET_LPC11XX |
fpucher | 0:397b5462e6d7 | 34 | I2C i2c; /**< I2C definition */ |
fpucher | 0:397b5462e6d7 | 35 | #endif |
fpucher | 0:397b5462e6d7 | 36 | char week_val; |
fpucher | 0:397b5462e6d7 | 37 | |
fpucher | 0:397b5462e6d7 | 38 | /** |
fpucher | 0:397b5462e6d7 | 39 | protected methodes for internal purposes only |
fpucher | 0:397b5462e6d7 | 40 | */ |
fpucher | 0:397b5462e6d7 | 41 | void error(); /**< Error: stops and all LEDs are blinking*/ |
fpucher | 0:397b5462e6d7 | 42 | |
fpucher | 0:397b5462e6d7 | 43 | public: |
fpucher | 0:397b5462e6d7 | 44 | /** Create a RTC object connected to the specified pin |
fpucher | 0:397b5462e6d7 | 45 | * @param pin sda/scl pin to connect to |
fpucher | 0:397b5462e6d7 | 46 | */ |
fpucher | 0:397b5462e6d7 | 47 | RTC(); /**< default constructor; sda(p28), sdc(p27) */ |
fpucher | 0:397b5462e6d7 | 48 | RTC(PinName sda, PinName scl); /**< parameterized constructor with sda-pin, sdc-pin)*/ |
fpucher | 0:397b5462e6d7 | 49 | ~RTC(); |
fpucher | 0:397b5462e6d7 | 50 | char rtc_read(char address); /**< read value from I2C bus; ToDo --> Error()*/ |
fpucher | 0:397b5462e6d7 | 51 | void rtc_write(char address, char value); /**< write value to I2C bus; ToDo --> Error()*/ |
fpucher | 0:397b5462e6d7 | 52 | void rtc_init(); /**< initialize the RTC to a given date and time; ToDo --> Error()*/ |
fpucher | 0:397b5462e6d7 | 53 | void rtc_alarm(); |
fpucher | 0:397b5462e6d7 | 54 | }; |
fpucher | 0:397b5462e6d7 | 55 | |
fpucher | 0:397b5462e6d7 | 56 | #endif |