mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-25 09:06:13 +01:00
Compare commits
No commits in common. "df2e6512174398b48314903fde2b6c891603c59d" and "415e756020707e1c0f1c145e0608d1493743d8dc" have entirely different histories.
df2e651217
...
415e756020
|
@ -219,9 +219,6 @@ void DCCEXParser::parse(Print *stream, byte *com, RingStream *ringStream) {
|
||||||
|
|
||||||
void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
{
|
{
|
||||||
#ifdef DISABLE_PROG
|
|
||||||
(void)ringStream;
|
|
||||||
#endif
|
|
||||||
#ifndef DISABLE_EEPROM
|
#ifndef DISABLE_EEPROM
|
||||||
(void)EEPROM; // tell compiler not to warn this is unused
|
(void)EEPROM; // tell compiler not to warn this is unused
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
#define GITHUB_SHA "devel-202308012308Z"
|
#define GITHUB_SHA "devel-202307250927Z"
|
||||||
|
|
|
@ -291,39 +291,14 @@ uint16_t taurustones[28] = { 165, 175, 196, 220,
|
||||||
void MotorDriver::setDCSignal(byte speedcode) {
|
void MotorDriver::setDCSignal(byte speedcode) {
|
||||||
if (brakePin == UNUSED_PIN)
|
if (brakePin == UNUSED_PIN)
|
||||||
return;
|
return;
|
||||||
switch(brakePin) {
|
|
||||||
#if defined(ARDUINO_AVR_UNO)
|
#if defined(ARDUINO_AVR_UNO)
|
||||||
// Not worth doin something here as:
|
TCCR2B = (TCCR2B & B11111000) | B00000110; // set divisor on timer 2 to result in (approx) 122.55Hz
|
||||||
// If we are on pin 9 or 10 we are on Timer1 and we can not touch Timer1 as that is our DCC source.
|
|
||||||
// If we are on pin 5 or 6 we are on Timer 0 ad we can not touch Timer0 as that is millis() etc.
|
|
||||||
// We are most likely not on pin 3 or 11 as no known motor shield has that as brake.
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560)
|
#if defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560)
|
||||||
case 9:
|
TCCR2B = (TCCR2B & B11111000) | B00000110; // set divisor on timer 2 to result in (approx) 122.55Hz
|
||||||
case 10:
|
TCCR4B = (TCCR4B & B11111000) | B00000100; // same for timer 4 but maxcount and thus divisor differs
|
||||||
// Timer2 (is differnet)
|
TCCR5B = (TCCR5B & B11111000) | B00000100; // same for timer 5 which is like timer 4
|
||||||
TCCR2A = (TCCR2A & B11111100) | B00000001; // set WGM1=0 and WGM0=1 phase correct PWM
|
|
||||||
TCCR2B = (TCCR2B & B11110000) | B00000110; // set WGM2=0 ; set divisor on timer 2 to 1/256 for 122.55Hz
|
|
||||||
//DIAG(F("2 A=%x B=%x"), TCCR2A, TCCR2B);
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
case 7:
|
|
||||||
case 8:
|
|
||||||
// Timer4
|
|
||||||
TCCR4A = (TCCR4A & B11111100) | B00000001; // set WGM0=1 and WGM1=0 for normal PWM 8-bit
|
|
||||||
TCCR4B = (TCCR4B & B11100000) | B00000100; // set WGM2=0 and WGM3=0 for normal PWM 8 bit and div 1/256 for 122.55Hz
|
|
||||||
break;
|
|
||||||
case 46:
|
|
||||||
case 45:
|
|
||||||
case 44:
|
|
||||||
// Timer5
|
|
||||||
TCCR5A = (TCCR5A & B11111100) | B00000001; // set WGM0=1 and WGM1=0 for normal PWM 8-bit
|
|
||||||
TCCR5B = (TCCR5B & B11100000) | B00000100; // set WGM2=0 and WGM3=0 for normal PWM 8 bit and div 1/256 for 122.55Hz
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// spedcoode is a dcc speed & direction
|
// spedcoode is a dcc speed & direction
|
||||||
byte tSpeed=speedcode & 0x7F; // DCC Speed with 0,1 stop and speed steps 2 to 127
|
byte tSpeed=speedcode & 0x7F; // DCC Speed with 0,1 stop and speed steps 2 to 127
|
||||||
byte tDir=speedcode & 0x80;
|
byte tDir=speedcode & 0x80;
|
||||||
|
@ -393,39 +368,14 @@ void MotorDriver::throttleInrush(bool on) {
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if(on){
|
if(on){
|
||||||
switch(brakePin) {
|
|
||||||
#if defined(ARDUINO_AVR_UNO)
|
#if defined(ARDUINO_AVR_UNO)
|
||||||
// Not worth doin something here as:
|
TCCR2B = (TCCR2B & B11111000) | B00000001; // div 1 is max
|
||||||
// If we are on pin 9 or 10 we are on Timer1 and we can not touch Timer1 as that is our DCC source.
|
|
||||||
// If we are on pin 5 or 6 we are on Timer 0 ad we can not touch Timer0 as that is millis() etc.
|
|
||||||
// We are most likely not on pin 3 or 11 as no known motor shield has that as brake.
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560)
|
#if defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560)
|
||||||
case 9:
|
TCCR2B = (TCCR2B & B11111000) | B00000001; // div 1 is max
|
||||||
case 10:
|
TCCR4B = (TCCR4B & B11111000) | B00000001; // div 1 is max
|
||||||
// Timer2 (is different)
|
TCCR5B = (TCCR5B & B11111000) | B00000001; // div 1 is max
|
||||||
TCCR2A = (TCCR2A & B11111100) | B00000011; // set WGM0=1 and WGM1=1 for fast PWM
|
|
||||||
TCCR2B = (TCCR2B & B11110000) | B00000001; // set WGM2=0 and prescaler div=1 (max)
|
|
||||||
DIAG(F("2 A=%x B=%x"), TCCR2A, TCCR2B);
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
case 7:
|
|
||||||
case 8:
|
|
||||||
// Timer4
|
|
||||||
TCCR4A = (TCCR4A & B11111100) | B00000001; // set WGM0=1 and WGM1=0 for fast PWM 8-bit
|
|
||||||
TCCR4B = (TCCR4B & B11100000) | B00001001; // set WGM2=1 and WGM3=0 for fast PWM 8 bit and div=1 (max)
|
|
||||||
break;
|
|
||||||
case 46:
|
|
||||||
case 45:
|
|
||||||
case 44:
|
|
||||||
// Timer5
|
|
||||||
TCCR5A = (TCCR5A & B11111100) | B00000001; // set WGM0=1 and WGM1=0 for fast PWM 8-bit
|
|
||||||
TCCR5B = (TCCR5B & B11100000) | B00001001; // set WGM2=1 and WGM3=0 for fast PWM 8 bit and div=1 (max)
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
analogWrite(brakePin,duty);
|
analogWrite(brakePin,duty);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -192,16 +192,11 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
|
||||||
|
|
||||||
//DIAG(F("Track=%c Mode=%d"),trackToSet+'A', mode);
|
//DIAG(F("Track=%c Mode=%d"),trackToSet+'A', mode);
|
||||||
// DC tracks require a motorDriver that can set brake!
|
// DC tracks require a motorDriver that can set brake!
|
||||||
if (mode==TRACK_MODE_DC || mode==TRACK_MODE_DCX) {
|
if ((mode==TRACK_MODE_DC || mode==TRACK_MODE_DCX)
|
||||||
#if defined(ARDUINO_AVR_UNO)
|
&& !track[trackToSet]->brakeCanPWM()) {
|
||||||
DIAG(F("Uno has no PWM timers available for DC"));
|
DIAG(F("Brake pin can't PWM: No DC"));
|
||||||
return false;
|
return false;
|
||||||
#endif
|
}
|
||||||
if (!track[trackToSet]->brakeCanPWM()) {
|
|
||||||
DIAG(F("Brake pin can't PWM: No DC"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
// remove pin from MUX matrix and turn it off
|
// remove pin from MUX matrix and turn it off
|
||||||
|
|
|
@ -3,11 +3,7 @@
|
||||||
|
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
|
|
||||||
#define VERSION "4.2.67"
|
#define VERSION "4.2.66"
|
||||||
// 4.2.67 - AVR: Pin specific timer register seting
|
|
||||||
// - Protect Uno user from choosing DC(X)
|
|
||||||
// - More Nucleo variant defines
|
|
||||||
// - GPIO PCA9555 / TCA9555 support
|
|
||||||
// 4.2.66 - Throttle inrush current by applying PWM to brake pin when
|
// 4.2.66 - Throttle inrush current by applying PWM to brake pin when
|
||||||
// fault pin goes active
|
// fault pin goes active
|
||||||
// 4.2.65 - new config WIFI_FORCE_AP option
|
// 4.2.65 - new config WIFI_FORCE_AP option
|
||||||
|
|
Loading…
Reference in New Issue
Block a user