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:
Fri Nov 07 21:26:46 2014 +0000
Revision:
24:f58a3c0071c3
Parent:
17:c9ce210f6654
finally compiles

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pspatel321 13:fbd9b3f5a07c 1 // copied idea from http://developer.mbed.org/forum/mbed/topic/466/?page=1#comment-2457
pspatel321 13:fbd9b3f5a07c 2
pspatel321 13:fbd9b3f5a07c 3 #ifndef _FILE_IMD_H
pspatel321 13:fbd9b3f5a07c 4 #define _FILE_IMD_H
pspatel321 13:fbd9b3f5a07c 5
pspatel321 13:fbd9b3f5a07c 6 #include "mbed.h"
pspatel321 13:fbd9b3f5a07c 7 #include "LPCDigitalIn.h"
pspatel321 13:fbd9b3f5a07c 8
pspatel321 13:fbd9b3f5a07c 9 const float ZERO_HZ_TIMEOUT = 0.1; // Time (sec) that must pass without an edge to call it 0 Hz, set to greater than the longest expected pulse width
pspatel321 13:fbd9b3f5a07c 10
pspatel321 13:fbd9b3f5a07c 11 enum EdgeT {
pspatel321 13:fbd9b3f5a07c 12 RISING=5,
pspatel321 13:fbd9b3f5a07c 13 FALLING=6,
pspatel321 13:fbd9b3f5a07c 14 BOTH=7,
pspatel321 13:fbd9b3f5a07c 15 };
pspatel321 17:c9ce210f6654 16
pspatel321 17:c9ce210f6654 17 enum IMDstatus {
pspatel321 17:c9ce210f6654 18 OFF=0,
pspatel321 17:c9ce210f6654 19 NORMAL=1,
pspatel321 17:c9ce210f6654 20 UNDERVOLT=2,
pspatel321 17:c9ce210f6654 21 SPEEDSTART=3,
pspatel321 17:c9ce210f6654 22 ERROR=4,
pspatel321 17:c9ce210f6654 23 GROUNDERR=5,
pspatel321 17:c9ce210f6654 24 INVALID=6,
pspatel321 17:c9ce210f6654 25 };
pspatel321 17:c9ce210f6654 26
pspatel321 13:fbd9b3f5a07c 27 class IMD{
pspatel321 13:fbd9b3f5a07c 28 public:
pspatel321 13:fbd9b3f5a07c 29 IMD();
pspatel321 13:fbd9b3f5a07c 30
pspatel321 13:fbd9b3f5a07c 31 char status();
pspatel321 13:fbd9b3f5a07c 32 // Gets the insulation resistance reading
pspatel321 13:fbd9b3f5a07c 33 // Returns 0 to 50,000,000 in normal/UV modes
pspatel321 13:fbd9b3f5a07c 34 // Returns 0 or 50,000,000 in speed start (good/bad only)
pspatel321 13:fbd9b3f5a07c 35 // -1 for invalid measurement (out of permissible range)
pspatel321 13:fbd9b3f5a07c 36 // and NaN for not applicable mode
pspatel321 13:fbd9b3f5a07c 37 float resistance();
pspatel321 13:fbd9b3f5a07c 38
pspatel321 13:fbd9b3f5a07c 39 // Interrupt function for the edge type detected
pspatel321 13:fbd9b3f5a07c 40 void edgeIRQ();
pspatel321 13:fbd9b3f5a07c 41 // Used to zero (reset) the data on timeout
pspatel321 13:fbd9b3f5a07c 42 void zeroIRQ();
pspatel321 13:fbd9b3f5a07c 43
pspatel321 13:fbd9b3f5a07c 44 private:
pspatel321 13:fbd9b3f5a07c 45 float frequency();
pspatel321 13:fbd9b3f5a07c 46 float duty();
pspatel321 17:c9ce210f6654 47 volatile uint32_t startTime;
pspatel321 17:c9ce210f6654 48 volatile uint32_t widthTicks;
pspatel321 17:c9ce210f6654 49 volatile uint32_t periodTicks;
pspatel321 17:c9ce210f6654 50 volatile bool first;
pspatel321 13:fbd9b3f5a07c 51 };
pspatel321 13:fbd9b3f5a07c 52
pspatel321 13:fbd9b3f5a07c 53 #endif