Penn Electric Racing / Mbed 2 deprecated SystemManagement

Dependencies:   mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP

Fork of SystemManagement by Martin Deng

CoulombCounter/RTCStore.h

Committer:
pspatel321
Date:
2014-10-25
Revision:
17:c9ce210f6654
Parent:
13:fbd9b3f5a07c

File content as of revision 17:c9ce210f6654:

/*  Test Code
    #include "Battery_Status.h"
    #include"mbed.h"   
    BatteryStatus battery;
    
    int main()
    {
        //battery.write(6.92,0);
        printf("LPC_RTC->GPREG0:%f\n\r",battery.read(0));
        //battery.write(7.92,1);
        printf("LPC_RTC->GPREG1:%f\n\r",battery.read(1));
        //battery.write(8.92,2);
        printf("LPC_RTC->GPREG2:%f\n\r",battery.read(2));
        //battery.write(9.92,3);
        printf("LPC_RTC->GPREG3:%f\n\r",battery.read(3));
        //battery.write(10.92,4);
        printf("LPC_RTC->GPREG4:%f\n\r",battery.read(4));
    }
*/

#ifndef _RTC_STORE_H
#define _RTC_STORE_H
#include "mbed.h"

class RTCStore {
public:
    RTCStore() {
        LPC_SC->PCONP |= (1<<9);        // Enable RTC Peripheral
    }
    void write(float data, int block) {
        *((float*)(&LPC_RTC->GPREG0)+block) = data;
    }
    float read(int block) {
        return *((float*)(&LPC_RTC->GPREG0)+block);
    }              
};
#endif