Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
Diff: Libs/LatchMonitor/LatchMonitor.cpp
- Revision:
- 38:8efacce315ae
- Parent:
- 36:0afc0fc8f86b
- Child:
- 39:ddf38df9699e
--- a/Libs/LatchMonitor/LatchMonitor.cpp Thu Jan 22 07:59:48 2015 +0000
+++ b/Libs/LatchMonitor/LatchMonitor.cpp Sat Feb 07 08:54:51 2015 +0000
@@ -1,30 +1,47 @@
#include "LatchMonitor.h"
-LatchMonitor::LatchMonitor(PinName _ok, PinName _fault, unsigned int startupDelay_ms):okPin(_ok, PullDown), faultPin(_fault, PullDown) {
-
+LatchMonitor::LatchMonitor(PinName _ok, PinName _fault) : okPin(_ok, PullDown), faultPin(_fault, PullDown)
+{
+ started = false;
+ lastStat = 0;
+ startDelay = 0;
+}
+void LatchMonitor::setup(float* _startDelay)
+{
+ startDelay = _startDelay;
+}
+void LatchMonitor::delayStart()
+{
+ lastStat = 0;
+ update();
+ if (startDelay == 0) return; // Not setup yet
+
// Power-on reset detected
if (LPC_SC->RSID & 1) {
- LPC_SC->RSID = 1; // Clear POR flag
- started = false; // Use the blocking startup timer
- startup.attach_us(this, &LatchMonitor::startupDelay, startupDelay_ms*1000);
+ LPC_SC->RSID = 1; // Clear POR flag
+ started = false; // Use the blocking startup timer
+ startup.attach(this, &LatchMonitor::startupDelay, *startDelay);
} else {
- started = true; // Not a power-cycle, do not use the timer
+ started = true; // Not a power-cycle, do not use the timer
}
}
-void LatchMonitor::startupDelay() {
- started = true;
+void LatchMonitor::startupDelay()
+{
+ started = true;
}
-char LatchMonitor::update() {
+char LatchMonitor::update()
+{
char ret = 0;
ret |= (!okPin << 0); // Mirror the ok pin
ret |= (faultPin << 1); // Copy the fault pin
-
+
if (started) {
ret |= !okPin << 2; // Mirror the ok pin when started only
if (!okPin && !faultPin) { // If started && okFault but not caught in hardware
- ret |= 1 << 3;
+ ret |= HARD_FAULT;
}
}
+ lastStat = ret;
return ret;
}
