Martin Deng / Mbed 2 deprecated SystemManagement

Dependencies:   CANBuffer mbed SystemManagement mbed-rtos

Dependents:   SystemManagement

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Store_RTC.h Source File

Store_RTC.h

00001 /*  Test Code
00002     #include "Battery_Status.h"
00003     #include"mbed.h"   
00004     BatteryStatus battery;
00005     
00006     int main()
00007     {
00008         //battery.write(6.92,0);
00009         printf("LPC_RTC->GPREG0:%f\n\r",battery.read(0));
00010         //battery.write(7.92,1);
00011         printf("LPC_RTC->GPREG1:%f\n\r",battery.read(1));
00012         //battery.write(8.92,2);
00013         printf("LPC_RTC->GPREG2:%f\n\r",battery.read(2));
00014         //battery.write(9.92,3);
00015         printf("LPC_RTC->GPREG3:%f\n\r",battery.read(3));
00016         //battery.write(10.92,4);
00017         printf("LPC_RTC->GPREG4:%f\n\r",battery.read(4));
00018     }
00019 */        
00020 
00021 #ifndef _BATTERY_STATUS_
00022 #define _BATTERY_STATUS_
00023 #include"mbed.h"
00024 
00025 // General purpose register 0
00026 #define _GPREG_BASE 0x40024044
00027 
00028 // RTC = Real-Time Clock
00029 
00030 class RTCStore
00031 {
00032     public:
00033       RTCStore()
00034       {
00035           LPC_SC->PCONP |= (1<<9);        //Enable RTC Peripheral
00036       }
00037       
00038       void write(float data, int block)
00039       {
00040          *(uint32_t*)(_GPREG_BASE + (0x04*block)) = *((uint32_t*)&data);
00041          //LPC_RTC->GPREG0 = *((uint32_t*)&data);
00042       }
00043       
00044       float read(int block)
00045       {
00046           return *((float*)(uint32_t*)(_GPREG_BASE + (0x04*block)));
00047           //return *((float*)&(LPC_RTC->GPREG0));
00048       }              
00049 };
00050 #endif /* _BATTERY_STATUS_ */
00051