Penn Electric Racing / Mbed 2 deprecated SystemManagement

Dependencies:   mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP

Fork of SystemManagement by Martin Deng

Committer:
martydd3
Date:
Wed Oct 01 12:52:26 2014 +0000
Revision:
0:e516fcccccda
Child:
1:e02eb179aed3
Added LPCDigitalOut, LPCDigitalIn, and CANBuffer Libaries; Comments on code in SysMngmt.cpp involving register and pin access; Note: LPCDigitalOut.h defines a void mode(PinMode) which isn't in LPCDigitalOut.cpp, causes a linking error if used

Who changed what in which revision?

UserRevisionLine numberNew 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 0:e516fcccccda 25 #define _GPREG_BASE 0x40024044
martydd3 0:e516fcccccda 26
martydd3 0:e516fcccccda 27 // RTC = Real-Time Clock
martydd3 0:e516fcccccda 28
martydd3 0:e516fcccccda 29 class RTCStore
martydd3 0:e516fcccccda 30 {
martydd3 0:e516fcccccda 31 public:
martydd3 0:e516fcccccda 32 RTCStore()
martydd3 0:e516fcccccda 33 {
martydd3 0:e516fcccccda 34 LPC_SC->PCONP |= (1<<9); //Enable RTC Peripheral
martydd3 0:e516fcccccda 35 }
martydd3 0:e516fcccccda 36
martydd3 0:e516fcccccda 37 void write(float data, int block)
martydd3 0:e516fcccccda 38 {
martydd3 0:e516fcccccda 39 *(uint32_t*)(_GPREG_BASE + (0x04*block)) = *((uint32_t*)&data);
martydd3 0:e516fcccccda 40 //LPC_RTC->GPREG0 = *((uint32_t*)&data);
martydd3 0:e516fcccccda 41 }
martydd3 0:e516fcccccda 42
martydd3 0:e516fcccccda 43 float read(int block)
martydd3 0:e516fcccccda 44 {
martydd3 0:e516fcccccda 45 return *((float*)(uint32_t*)(_GPREG_BASE + (0x04*block)));
martydd3 0:e516fcccccda 46 //return *((float*)&(LPC_RTC->GPREG0));
martydd3 0:e516fcccccda 47 }
martydd3 0:e516fcccccda 48 };
martydd3 0:e516fcccccda 49 #endif /* _BATTERY_STATUS_ */
martydd3 0:e516fcccccda 50