mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 05:11:24 +01:00
Merge branch 'currentsenseirq'
This commit is contained in:
commit
ca0c34f9fa
@ -886,7 +886,7 @@ void DCCEXParser::callback_R(int16_t result)
|
|||||||
void DCCEXParser::callback_Rloco(int16_t result) {
|
void DCCEXParser::callback_Rloco(int16_t result) {
|
||||||
const FSH * detail;
|
const FSH * detail;
|
||||||
if (result<=0) {
|
if (result<=0) {
|
||||||
detail=F("<r ERROR %d>\n");
|
detail=F("<r %d>\n");
|
||||||
} else {
|
} else {
|
||||||
bool longAddr=result & LONG_ADDR_MARKER; //long addr
|
bool longAddr=result & LONG_ADDR_MARKER; //long addr
|
||||||
if (longAddr)
|
if (longAddr)
|
||||||
|
@ -152,16 +152,16 @@ int MotorDriver::getCurrentRaw() {
|
|||||||
bool irq = disableInterrupts();
|
bool irq = disableInterrupts();
|
||||||
current = analogRead(currentPin)-senseOffset;
|
current = analogRead(currentPin)-senseOffset;
|
||||||
enableInterrupts(irq);
|
enableInterrupts(irq);
|
||||||
#elif defined(ARDUINO_TEENSY32) || defined(ARDUINO_TEENSY35)|| defined(ARDUINO_TEENSY36)
|
#else // Uno, Mega and all the TEENSY3* but not TEENSY4*
|
||||||
unsigned char sreg_backup;
|
unsigned char sreg_backup;
|
||||||
sreg_backup = SREG; /* save interrupt enable/disable state */
|
sreg_backup = SREG; /* save interrupt enable/disable state */
|
||||||
cli();
|
cli();
|
||||||
current = analogRead(currentPin)-senseOffset;
|
current = analogRead(currentPin)-senseOffset;
|
||||||
|
#if defined(ARDUINO_TEENSY32) || defined(ARDUINO_TEENSY35)|| defined(ARDUINO_TEENSY36)
|
||||||
overflow_count = 0;
|
overflow_count = 0;
|
||||||
SREG = sreg_backup; /* restore interrupt state */
|
|
||||||
#else
|
|
||||||
current = analogRead(currentPin)-senseOffset;
|
|
||||||
#endif
|
#endif
|
||||||
|
if (sreg_backup & 128) sei(); /* restore interrupt state */
|
||||||
|
#endif // outer #
|
||||||
if (current<0) current=0-current;
|
if (current<0) current=0-current;
|
||||||
if ((faultPin != UNUSED_PIN) && isLOW(fastFaultPin) && isHIGH(fastPowerPin))
|
if ((faultPin != UNUSED_PIN) && isLOW(fastFaultPin) && isHIGH(fastPowerPin))
|
||||||
return (current == 0 ? -1 : -current);
|
return (current == 0 ? -1 : -current);
|
||||||
|
Loading…
Reference in New Issue
Block a user