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.
Dependencies: CANBuffer mbed SystemManagement mbed-rtos
RTCStore/Store_RTC.h@7:5f6e31faa08e, 2014-10-10 (annotated)
- Committer:
- martydd3
- Date:
- Fri Oct 10 20:59:36 2014 +0000
- Revision:
- 7:5f6e31faa08e
- Parent:
- 1:e02eb179aed3
PollSwitch code;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| martydd3 | 0:e516fcccccda | 1 | /* Test Code |
| martydd3 | 0:e516fcccccda | 2 | #include "Battery_Status.h" |
| martydd3 | 0:e516fcccccda | 3 | #include"mbed.h" |
| martydd3 | 0:e516fcccccda | 4 | BatteryStatus battery; |
| martydd3 | 0:e516fcccccda | 5 | |
| martydd3 | 0:e516fcccccda | 6 | int main() |
| martydd3 | 0:e516fcccccda | 7 | { |
| martydd3 | 0:e516fcccccda | 8 | //battery.write(6.92,0); |
| martydd3 | 0:e516fcccccda | 9 | printf("LPC_RTC->GPREG0:%f\n\r",battery.read(0)); |
| martydd3 | 0:e516fcccccda | 10 | //battery.write(7.92,1); |
| martydd3 | 0:e516fcccccda | 11 | printf("LPC_RTC->GPREG1:%f\n\r",battery.read(1)); |
| martydd3 | 0:e516fcccccda | 12 | //battery.write(8.92,2); |
| martydd3 | 0:e516fcccccda | 13 | printf("LPC_RTC->GPREG2:%f\n\r",battery.read(2)); |
| martydd3 | 0:e516fcccccda | 14 | //battery.write(9.92,3); |
| martydd3 | 0:e516fcccccda | 15 | printf("LPC_RTC->GPREG3:%f\n\r",battery.read(3)); |
| martydd3 | 0:e516fcccccda | 16 | //battery.write(10.92,4); |
| martydd3 | 0:e516fcccccda | 17 | printf("LPC_RTC->GPREG4:%f\n\r",battery.read(4)); |
| martydd3 | 0:e516fcccccda | 18 | } |
| martydd3 | 0:e516fcccccda | 19 | */ |
| martydd3 | 0:e516fcccccda | 20 | |
| martydd3 | 0:e516fcccccda | 21 | #ifndef _BATTERY_STATUS_ |
| martydd3 | 0:e516fcccccda | 22 | #define _BATTERY_STATUS_ |
| martydd3 | 0:e516fcccccda | 23 | #include"mbed.h" |
| martydd3 | 0:e516fcccccda | 24 | |
| martydd3 | 1:e02eb179aed3 | 25 | // General purpose register 0 |
| martydd3 | 0:e516fcccccda | 26 | #define _GPREG_BASE 0x40024044 |
| martydd3 | 0:e516fcccccda | 27 | |
| martydd3 | 0:e516fcccccda | 28 | // RTC = Real-Time Clock |
| martydd3 | 0:e516fcccccda | 29 | |
| martydd3 | 0:e516fcccccda | 30 | class RTCStore |
| martydd3 | 0:e516fcccccda | 31 | { |
| martydd3 | 0:e516fcccccda | 32 | public: |
| martydd3 | 0:e516fcccccda | 33 | RTCStore() |
| martydd3 | 0:e516fcccccda | 34 | { |
| martydd3 | 0:e516fcccccda | 35 | LPC_SC->PCONP |= (1<<9); //Enable RTC Peripheral |
| martydd3 | 0:e516fcccccda | 36 | } |
| martydd3 | 0:e516fcccccda | 37 | |
| martydd3 | 0:e516fcccccda | 38 | void write(float data, int block) |
| martydd3 | 0:e516fcccccda | 39 | { |
| martydd3 | 0:e516fcccccda | 40 | *(uint32_t*)(_GPREG_BASE + (0x04*block)) = *((uint32_t*)&data); |
| martydd3 | 0:e516fcccccda | 41 | //LPC_RTC->GPREG0 = *((uint32_t*)&data); |
| martydd3 | 0:e516fcccccda | 42 | } |
| martydd3 | 0:e516fcccccda | 43 | |
| martydd3 | 0:e516fcccccda | 44 | float read(int block) |
| martydd3 | 0:e516fcccccda | 45 | { |
| martydd3 | 0:e516fcccccda | 46 | return *((float*)(uint32_t*)(_GPREG_BASE + (0x04*block))); |
| martydd3 | 0:e516fcccccda | 47 | //return *((float*)&(LPC_RTC->GPREG0)); |
| martydd3 | 0:e516fcccccda | 48 | } |
| martydd3 | 0:e516fcccccda | 49 | }; |
| martydd3 | 0:e516fcccccda | 50 | #endif /* _BATTERY_STATUS_ */ |
| martydd3 | 0:e516fcccccda | 51 |