System Management code
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
Libs/IMD/IMD.h@39:ddf38df9699e, 2015-02-11 (annotated)
- Committer:
- pspatel321
- Date:
- Wed Feb 11 23:09:57 2015 +0000
- Revision:
- 39:ddf38df9699e
- Parent:
- 38:8efacce315ae
Updated CAN IDs for datalogging. Changed profile encoding.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pspatel321 | 30:91af74a299e1 | 1 | // copied idea from http://developer.mbed.org/forum/mbed/topic/466/?page=1#comment-2457 |
pspatel321 | 30:91af74a299e1 | 2 | |
pspatel321 | 30:91af74a299e1 | 3 | #ifndef _FILE_IMD_H |
pspatel321 | 30:91af74a299e1 | 4 | #define _FILE_IMD_H |
pspatel321 | 30:91af74a299e1 | 5 | |
pspatel321 | 30:91af74a299e1 | 6 | #include "mbed.h" |
pspatel321 | 30:91af74a299e1 | 7 | |
pspatel321 | 30:91af74a299e1 | 8 | enum IMDstatus { |
pspatel321 | 39:ddf38df9699e | 9 | OFF = 1<<0, |
pspatel321 | 39:ddf38df9699e | 10 | NORMAL = 1<<1, |
pspatel321 | 39:ddf38df9699e | 11 | UNDERVOLT = 1<<2, |
pspatel321 | 39:ddf38df9699e | 12 | SPEEDSTART = 1<<3, |
pspatel321 | 39:ddf38df9699e | 13 | ERROR = 1<<4, |
pspatel321 | 39:ddf38df9699e | 14 | GROUNDERR = 1<<5, |
pspatel321 | 39:ddf38df9699e | 15 | INVALID = 1<<6, |
pspatel321 | 30:91af74a299e1 | 16 | }; |
pspatel321 | 30:91af74a299e1 | 17 | |
pspatel321 | 30:91af74a299e1 | 18 | class IMD{ |
pspatel321 | 30:91af74a299e1 | 19 | public: |
pspatel321 | 36:0afc0fc8f86b | 20 | IMD(PinName _pin); |
pspatel321 | 30:91af74a299e1 | 21 | |
pspatel321 | 30:91af74a299e1 | 22 | char status(); |
pspatel321 | 30:91af74a299e1 | 23 | // Gets the insulation resistance reading |
pspatel321 | 30:91af74a299e1 | 24 | // Returns 0 to 50,000,000 in normal/UV modes |
pspatel321 | 30:91af74a299e1 | 25 | // Returns 0 or 50,000,000 in speed start (good/bad only) |
pspatel321 | 30:91af74a299e1 | 26 | // Nan for invalid measurement (out of permissible range) |
pspatel321 | 30:91af74a299e1 | 27 | // Nan for not avail. in this mode |
pspatel321 | 30:91af74a299e1 | 28 | float resistance(); |
pspatel321 | 30:91af74a299e1 | 29 | |
pspatel321 | 30:91af74a299e1 | 30 | // Interrupt function for the edge type detected |
pspatel321 | 30:91af74a299e1 | 31 | void edgeIRQ(); |
pspatel321 | 30:91af74a299e1 | 32 | // Used to zero (reset) the data on timeout |
pspatel321 | 30:91af74a299e1 | 33 | void zeroIRQ(); |
pspatel321 | 30:91af74a299e1 | 34 | |
pspatel321 | 30:91af74a299e1 | 35 | private: |
pspatel321 | 30:91af74a299e1 | 36 | float frequency(); |
pspatel321 | 30:91af74a299e1 | 37 | float duty(); |
pspatel321 | 30:91af74a299e1 | 38 | |
pspatel321 | 30:91af74a299e1 | 39 | volatile uint32_t startTime; |
pspatel321 | 30:91af74a299e1 | 40 | volatile uint32_t widthTicks; |
pspatel321 | 30:91af74a299e1 | 41 | volatile uint32_t periodTicks; |
pspatel321 | 30:91af74a299e1 | 42 | volatile bool first; |
pspatel321 | 30:91af74a299e1 | 43 | |
pspatel321 | 30:91af74a299e1 | 44 | LPC_TIM_TypeDef *timerBase; // Base address of the active timer module |
pspatel321 | 30:91af74a299e1 | 45 | int pin; // Capture pin#, 0 or 1 |
pspatel321 | 30:91af74a299e1 | 46 | int timer; |
pspatel321 | 30:91af74a299e1 | 47 | }; |
pspatel321 | 30:91af74a299e1 | 48 | |
pspatel321 | 30:91af74a299e1 | 49 | #endif |