System Management code
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
Libs/LatchMonitor/LatchMonitor.cpp@30:91af74a299e1, 2014-11-13 (annotated)
- Committer:
- pspatel321
- Date:
- Thu Nov 13 10:53:10 2014 +0000
- Revision:
- 30:91af74a299e1
- Child:
- 36:0afc0fc8f86b
Parth's edits for the week.; DC-DC completed and fixed, IMD updated, LatchMonitor and Temperature added. Serial dashboard updated. File structure changed Everything tested. Compiles and runs.; Still need to write CAN in/out interface.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pspatel321 | 30:91af74a299e1 | 1 | #include "LatchMonitor.h" |
pspatel321 | 30:91af74a299e1 | 2 | |
pspatel321 | 30:91af74a299e1 | 3 | LatchMonitor::LatchMonitor(LPC_pin _ok, LPC_pin _fault, unsigned int startupDelay_ms):okPin(_ok, PullDown), faultPin(_fault, PullDown) { |
pspatel321 | 30:91af74a299e1 | 4 | |
pspatel321 | 30:91af74a299e1 | 5 | // Power-on reset detected |
pspatel321 | 30:91af74a299e1 | 6 | if (LPC_SC->RSID & 1) { |
pspatel321 | 30:91af74a299e1 | 7 | LPC_SC->RSID = 1; // Clear POR flag |
pspatel321 | 30:91af74a299e1 | 8 | started = false; // Use the blocking startup timer |
pspatel321 | 30:91af74a299e1 | 9 | startup.attach_us(this, &LatchMonitor::startupDelay, startupDelay_ms*1000); |
pspatel321 | 30:91af74a299e1 | 10 | } else { |
pspatel321 | 30:91af74a299e1 | 11 | started = true; // Not a power-cycle, do not use the timer |
pspatel321 | 30:91af74a299e1 | 12 | } |
pspatel321 | 30:91af74a299e1 | 13 | } |
pspatel321 | 30:91af74a299e1 | 14 | |
pspatel321 | 30:91af74a299e1 | 15 | void LatchMonitor::startupDelay() { |
pspatel321 | 30:91af74a299e1 | 16 | started = true; |
pspatel321 | 30:91af74a299e1 | 17 | } |
pspatel321 | 30:91af74a299e1 | 18 | char LatchMonitor::update() { |
pspatel321 | 30:91af74a299e1 | 19 | char ret = 0; |
pspatel321 | 30:91af74a299e1 | 20 | ret |= (!okPin << 0); // Mirror the ok pin |
pspatel321 | 30:91af74a299e1 | 21 | ret |= (faultPin << 1); // Copy the fault pin |
pspatel321 | 30:91af74a299e1 | 22 | |
pspatel321 | 30:91af74a299e1 | 23 | if (started) { |
pspatel321 | 30:91af74a299e1 | 24 | ret |= !okPin << 2; // Mirror the ok pin when started only |
pspatel321 | 30:91af74a299e1 | 25 | if (!okPin && !faultPin) { // If started && okFault but not caught in hardware |
pspatel321 | 30:91af74a299e1 | 26 | ret |= 1 << 3; |
pspatel321 | 30:91af74a299e1 | 27 | } |
pspatel321 | 30:91af74a299e1 | 28 | } |
pspatel321 | 30:91af74a299e1 | 29 | return ret; |
pspatel321 | 30:91af74a299e1 | 30 | } |