System Management code
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
LatchMonitor.cpp
00001 #include "LatchMonitor.h" 00002 00003 LatchMonitor::LatchMonitor(PinName _ok, PinName _fault) : okPin(_ok, PullDown), faultPin(_fault, PullDown) 00004 { 00005 started = false; 00006 startDelay = 0; 00007 } 00008 00009 void LatchMonitor::setup(float* _startDelay) 00010 { 00011 startDelay = _startDelay; 00012 } 00013 00014 void LatchMonitor::delayStart() 00015 { 00016 if (startDelay == 0) return; // Not setup yet 00017 00018 // Power-on reset detected 00019 if (LPC_SC->RSID & 1) { 00020 LPC_SC->RSID = 1; // Clear POR flag 00021 started = false; // Use the blocking startup timer 00022 startup.attach(this, &LatchMonitor::startupDelay, *startDelay); 00023 } else { 00024 started = true; // Not a power-cycle, do not use the timer 00025 } 00026 } 00027 00028 void LatchMonitor::startupDelay() 00029 { 00030 started = true; 00031 } 00032 char LatchMonitor::update() 00033 { 00034 char ret = 0; 00035 ret |= (!okPin << 0); // Mirror the ok pin 00036 ret |= (faultPin << 1); // Copy the fault pin 00037 00038 if (started) { 00039 ret |= !okPin << 2; // Mirror the ok pin when started only 00040 if (!okPin && !faultPin) { // If started && okFault but not caught in hardware 00041 //ret |= HARD_FAULT; 00042 } 00043 } 00044 return ret; 00045 }
Generated on Fri Jul 15 2022 06:07:18 by
1.7.2
