mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 08:06:13 +01:00
Compare commits
6 Commits
a9a40c807a
...
c867f22c71
Author | SHA1 | Date | |
---|---|---|---|
|
c867f22c71 | ||
|
83d4930124 | ||
|
5d411e6a08 | ||
|
7bd1bae470 | ||
|
7cc3cf9c65 | ||
|
2738d86431 |
|
@ -809,7 +809,9 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
CommandDistributor::setVirtualLCDSerial(stream);
|
CommandDistributor::setVirtualLCDSerial(stream);
|
||||||
StringFormatter::send(stream,
|
StringFormatter::send(stream,
|
||||||
F("<@ 0 0 \"DCC-EX v" VERSION "\">\n"
|
F("<@ 0 0 \"DCC-EX v" VERSION "\">\n"
|
||||||
"<@ 0 1 \"Lic GPLv3\">\n"));
|
"<@ 0 1 \"Lic GPLv3 \">\n"
|
||||||
|
"<@ 0 8 \"Powered by DCC-EX \">\n"
|
||||||
|
CommandDistributor::setVirtualLCDSerial(NULL);
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
default: //anything else will diagnose and drop out to <X>
|
default: //anything else will diagnose and drop out to <X>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* © 2022-2023 Paul M. Antoine
|
* © 2022-2024 Paul M. Antoine
|
||||||
* © 2021 Mike S
|
* © 2021 Mike S
|
||||||
* © 2021-2023 Harald Barth
|
* © 2021-2023 Harald Barth
|
||||||
* © 2021 Fred Decker
|
* © 2021 Fred Decker
|
||||||
|
@ -135,6 +135,8 @@ private:
|
||||||
#if defined (ARDUINO_ARCH_STM32)
|
#if defined (ARDUINO_ARCH_STM32)
|
||||||
// bit array of used pins (max 32)
|
// bit array of used pins (max 32)
|
||||||
static uint32_t usedpins;
|
static uint32_t usedpins;
|
||||||
|
static uint32_t * analogchans; // Array of channel numbers to be scanned
|
||||||
|
static ADC_TypeDef * * adcchans; // Array to capture which ADC is each input channel on
|
||||||
#else
|
#else
|
||||||
// bit array of used pins (max 16)
|
// bit array of used pins (max 16)
|
||||||
static uint16_t usedpins;
|
static uint16_t usedpins;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* © 2023 Neil McKechnie
|
* © 2023 Neil McKechnie
|
||||||
* © 2022-2023 Paul M. Antoine
|
* © 2022-2024 Paul M. Antoine
|
||||||
* © 2021 Mike S
|
* © 2021 Mike S
|
||||||
* © 2021, 2023 Harald Barth
|
* © 2021, 2023 Harald Barth
|
||||||
* © 2021 Fred Decker
|
* © 2021 Fred Decker
|
||||||
|
@ -34,6 +34,7 @@
|
||||||
#include "TrackManager.h"
|
#include "TrackManager.h"
|
||||||
#endif
|
#endif
|
||||||
#include "DIAG.h"
|
#include "DIAG.h"
|
||||||
|
#include <wiring_private.h>
|
||||||
|
|
||||||
#if defined(ARDUINO_NUCLEO_F401RE) || defined(ARDUINO_NUCLEO_F411RE)
|
#if defined(ARDUINO_NUCLEO_F401RE) || defined(ARDUINO_NUCLEO_F411RE)
|
||||||
// Nucleo-64 boards don't have additional serial ports defined by default
|
// Nucleo-64 boards don't have additional serial ports defined by default
|
||||||
|
@ -363,9 +364,9 @@ void DCCTimer::DCCEXanalogWrite(uint8_t pin, int value, bool invert) {
|
||||||
uint32_t ADCee::usedpins = 0; // Max of 32 ADC input channels!
|
uint32_t ADCee::usedpins = 0; // Max of 32 ADC input channels!
|
||||||
uint8_t ADCee::highestPin = 0; // Highest pin to scan
|
uint8_t ADCee::highestPin = 0; // Highest pin to scan
|
||||||
int * ADCee::analogvals = NULL; // Array of analog values last captured
|
int * ADCee::analogvals = NULL; // Array of analog values last captured
|
||||||
uint32_t * analogchans = NULL; // Array of channel numbers to be scanned
|
uint32_t * ADCee::analogchans = NULL; // Array of channel numbers to be scanned
|
||||||
// bool adc1configured = false;
|
// bool adc1configured = false;
|
||||||
ADC_TypeDef * * adcchans = NULL; // Array to capture which ADC is each input channel on
|
ADC_TypeDef * * ADCee::adcchans = NULL; // Array to capture which ADC is each input channel on
|
||||||
|
|
||||||
int16_t ADCee::ADCmax()
|
int16_t ADCee::ADCmax()
|
||||||
{
|
{
|
||||||
|
@ -383,9 +384,10 @@ int ADCee::init(uint8_t pin) {
|
||||||
uint32_t adcchan = STM_PIN_CHANNEL(pinmap_function(stmpin, PinMap_ADC)); // find ADC input channel
|
uint32_t adcchan = STM_PIN_CHANNEL(pinmap_function(stmpin, PinMap_ADC)); // find ADC input channel
|
||||||
ADC_TypeDef *adc = (ADC_TypeDef *)pinmap_find_peripheral(stmpin, PinMap_ADC); // find which ADC this pin is on ADC1/2/3 etc.
|
ADC_TypeDef *adc = (ADC_TypeDef *)pinmap_find_peripheral(stmpin, PinMap_ADC); // find which ADC this pin is on ADC1/2/3 etc.
|
||||||
int adcnum = 1;
|
int adcnum = 1;
|
||||||
|
// All variants have ADC1
|
||||||
if (adc == ADC1)
|
if (adc == ADC1)
|
||||||
DIAG(F("ADCee::init(): found pin %d on ADC1"), pin);
|
DIAG(F("ADCee::init(): found pin %d on ADC1"), pin);
|
||||||
// Checking for ADC2 and ADC3 being defined helps cater for more variants later
|
// Checking for ADC2 and ADC3 being defined helps cater for more variants
|
||||||
#if defined(ADC2)
|
#if defined(ADC2)
|
||||||
else if (adc == ADC2)
|
else if (adc == ADC2)
|
||||||
{
|
{
|
||||||
|
@ -432,6 +434,18 @@ int ADCee::init(uint8_t pin) {
|
||||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOFEN; //Power up PORTF
|
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOFEN; //Power up PORTF
|
||||||
gpioBase = GPIOF;
|
gpioBase = GPIOF;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
#if defined(GPIOG)
|
||||||
|
case 0x06:
|
||||||
|
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOGEN; //Power up PORTG
|
||||||
|
gpioBase = GPIOG;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#if defined(GPIOH)
|
||||||
|
case 0x07:
|
||||||
|
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOHEN; //Power up PORTH
|
||||||
|
gpioBase = GPIOH;
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
return -1023; // some silly value as error
|
return -1023; // some silly value as error
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* © 2022-2023 Paul M Antoine
|
* © 2022-2024 Paul M Antoine
|
||||||
* © 2021 Mike S
|
* © 2021 Mike S
|
||||||
* © 2021 Fred Decker
|
* © 2021 Fred Decker
|
||||||
* © 2020-2023 Harald Barth
|
* © 2020-2023 Harald Barth
|
||||||
|
@ -38,6 +38,8 @@ volatile portreg_t shadowPORTC;
|
||||||
volatile portreg_t shadowPORTD;
|
volatile portreg_t shadowPORTD;
|
||||||
volatile portreg_t shadowPORTE;
|
volatile portreg_t shadowPORTE;
|
||||||
volatile portreg_t shadowPORTF;
|
volatile portreg_t shadowPORTF;
|
||||||
|
volatile portreg_t shadowPORTG;
|
||||||
|
volatile portreg_t shadowPORTH;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, int16_t brake_pin,
|
MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, int16_t brake_pin,
|
||||||
|
@ -88,6 +90,16 @@ MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, i
|
||||||
fastSignalPin.shadowinout = fastSignalPin.inout;
|
fastSignalPin.shadowinout = fastSignalPin.inout;
|
||||||
fastSignalPin.inout = &shadowPORTF;
|
fastSignalPin.inout = &shadowPORTF;
|
||||||
}
|
}
|
||||||
|
if (HAVE_PORTG(fastSignalPin.inout == &PORTG)) {
|
||||||
|
DIAG(F("Found PORTG pin %d"),signalPin);
|
||||||
|
fastSignalPin.shadowinout = fastSignalPin.inout;
|
||||||
|
fastSignalPin.inout = &shadowPORTG;
|
||||||
|
}
|
||||||
|
if (HAVE_PORTH(fastSignalPin.inout == &PORTH)) {
|
||||||
|
DIAG(F("Found PORTH pin %d"),signalPin);
|
||||||
|
fastSignalPin.shadowinout = fastSignalPin.inout;
|
||||||
|
fastSignalPin.inout = &shadowPORTF;
|
||||||
|
}
|
||||||
|
|
||||||
signalPin2=signal_pin2;
|
signalPin2=signal_pin2;
|
||||||
if (signalPin2!=UNUSED_PIN) {
|
if (signalPin2!=UNUSED_PIN) {
|
||||||
|
@ -126,6 +138,16 @@ MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, i
|
||||||
fastSignalPin2.shadowinout = fastSignalPin2.inout;
|
fastSignalPin2.shadowinout = fastSignalPin2.inout;
|
||||||
fastSignalPin2.inout = &shadowPORTF;
|
fastSignalPin2.inout = &shadowPORTF;
|
||||||
}
|
}
|
||||||
|
if (HAVE_PORTG(fastSignalPin2.inout == &PORTG)) {
|
||||||
|
DIAG(F("Found PORTG pin %d"),signalPin2);
|
||||||
|
fastSignalPin2.shadowinout = fastSignalPin2.inout;
|
||||||
|
fastSignalPin2.inout = &shadowPORTG;
|
||||||
|
}
|
||||||
|
if (HAVE_PORTH(fastSignalPin2.inout == &PORTH)) {
|
||||||
|
DIAG(F("Found PORTH pin %d"),signalPin2);
|
||||||
|
fastSignalPin2.shadowinout = fastSignalPin2.inout;
|
||||||
|
fastSignalPin2.inout = &shadowPORTH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else dualSignal=false;
|
else dualSignal=false;
|
||||||
|
|
||||||
|
@ -393,6 +415,18 @@ void MotorDriver::setDCSignal(byte speedcode, uint8_t frequency /*default =0*/)
|
||||||
setSignal(tDir);
|
setSignal(tDir);
|
||||||
HAVE_PORTF(PORTF=shadowPORTF);
|
HAVE_PORTF(PORTF=shadowPORTF);
|
||||||
interrupts();
|
interrupts();
|
||||||
|
} else if (HAVE_PORTG(fastSignalPin.shadowinout == &PORTG)) {
|
||||||
|
noInterrupts();
|
||||||
|
HAVE_PORTG(shadowPORTG=PORTG);
|
||||||
|
setSignal(tDir);
|
||||||
|
HAVE_PORTG(PORTG=shadowPORTG);
|
||||||
|
interrupts();
|
||||||
|
} else if (HAVE_PORTH(fastSignalPin.shadowinout == &PORTH)) {
|
||||||
|
noInterrupts();
|
||||||
|
HAVE_PORTH(shadowPORTH=PORTH);
|
||||||
|
setSignal(tDir);
|
||||||
|
HAVE_PORTH(PORTH=shadowPORTH);
|
||||||
|
interrupts();
|
||||||
} else {
|
} else {
|
||||||
noInterrupts();
|
noInterrupts();
|
||||||
setSignal(tDir);
|
setSignal(tDir);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* © 2022-2023 Paul M. Antoine
|
* © 2022-2024 Paul M. Antoine
|
||||||
* © 2021 Mike S
|
* © 2021 Mike S
|
||||||
* © 2021 Fred Decker
|
* © 2021 Fred Decker
|
||||||
* © 2020 Chris Harlow
|
* © 2020 Chris Harlow
|
||||||
|
@ -26,6 +26,7 @@
|
||||||
#include "FSH.h"
|
#include "FSH.h"
|
||||||
#include "IODevice.h"
|
#include "IODevice.h"
|
||||||
#include "DCCTimer.h"
|
#include "DCCTimer.h"
|
||||||
|
#include <wiring_private.h>
|
||||||
|
|
||||||
// use powers of two so we can do logical and/or on the track modes in if clauses.
|
// use powers of two so we can do logical and/or on the track modes in if clauses.
|
||||||
// RACK_MODE_DCX is (TRACK_MODE_DC|TRACK_MODE_INV)
|
// RACK_MODE_DCX is (TRACK_MODE_DC|TRACK_MODE_INV)
|
||||||
|
@ -83,6 +84,14 @@ enum TRACK_MODE : byte {TRACK_MODE_NONE = 1, TRACK_MODE_MAIN = 2, TRACK_MODE_PRO
|
||||||
#define PORTF GPIOF->ODR
|
#define PORTF GPIOF->ODR
|
||||||
#define HAVE_PORTF(X) X
|
#define HAVE_PORTF(X) X
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(GPIOG)
|
||||||
|
#define PORTG GPIOG->ODR
|
||||||
|
#define HAVE_PORTG(X) X
|
||||||
|
#endif
|
||||||
|
#if defined(GPIOH)
|
||||||
|
#define PORTH GPIOH->ODR
|
||||||
|
#define HAVE_PORTH(X) X
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// if macros not defined as pass-through we define
|
// if macros not defined as pass-through we define
|
||||||
|
@ -106,6 +115,12 @@ enum TRACK_MODE : byte {TRACK_MODE_NONE = 1, TRACK_MODE_MAIN = 2, TRACK_MODE_PRO
|
||||||
#ifndef HAVE_PORTF
|
#ifndef HAVE_PORTF
|
||||||
#define HAVE_PORTF(X) byte TOKENPASTE2(Unique_, __LINE__) __attribute__((unused)) =0
|
#define HAVE_PORTF(X) byte TOKENPASTE2(Unique_, __LINE__) __attribute__((unused)) =0
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef HAVE_PORTG
|
||||||
|
#define HAVE_PORTG(X) byte TOKENPASTE2(Unique_, __LINE__) __attribute__((unused)) =0
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_PORTH
|
||||||
|
#define HAVE_PORTH(X) byte TOKENPASTE2(Unique_, __LINE__) __attribute__((unused)) =0
|
||||||
|
#endif
|
||||||
|
|
||||||
// Virtualised Motor shield 1-track hardware Interface
|
// Virtualised Motor shield 1-track hardware Interface
|
||||||
|
|
||||||
|
@ -145,6 +160,8 @@ extern volatile portreg_t shadowPORTC;
|
||||||
extern volatile portreg_t shadowPORTD;
|
extern volatile portreg_t shadowPORTD;
|
||||||
extern volatile portreg_t shadowPORTE;
|
extern volatile portreg_t shadowPORTE;
|
||||||
extern volatile portreg_t shadowPORTF;
|
extern volatile portreg_t shadowPORTF;
|
||||||
|
extern volatile portreg_t shadowPORTG;
|
||||||
|
extern volatile portreg_t shadowPORTH;
|
||||||
|
|
||||||
enum class POWERMODE : byte { OFF, ON, OVERLOAD, ALERT };
|
enum class POWERMODE : byte { OFF, ON, OVERLOAD, ALERT };
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user