1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-07-28 09:53:45 +02:00

Fault pin handling made more straight forward

This commit is contained in:
Harald Barth
2023-05-20 23:15:15 +02:00
parent 1a3d295564
commit 132b0773ef
4 changed files with 12 additions and 13 deletions

View File

@@ -214,14 +214,12 @@ int MotorDriver::getCurrentRaw(bool fromISR) {
// if (fromISR == false) DIAG(F("%c: %d"), trackLetter, current);
current = current-senseOffset; // adjust with offset
if (current<0) current=0-current;
if ((faultPin != UNUSED_PIN) && powerMode==POWERMODE::ON) {
if (invertFault && isLOW(fastFaultPin))
return (current == 0 ? -1 : -current);
if (!invertFault && !isLOW(fastFaultPin))
// current >= 0 here, we use negative current as fault pin flag
if ((faultPin != UNUSED_PIN) && powerPin) {
if (invertFault ? isHIGH(fastFaultPin) : isLOW(fastFaultPin))
return (current == 0 ? -1 : -current);
}
return current;
}
#ifdef ANALOG_READ_INTERRUPT