1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-23 16:16:13 +01:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Kcsmith0708
a9a40c807a
Merge 5d411e6a08 into b4e7982099 2024-04-25 07:36:22 -04:00
4 changed files with 7 additions and 74 deletions

View File

@ -1,5 +1,5 @@
/* /*
* © 2022-2024 Paul M. Antoine * © 2022-2023 Paul M. Antoine
* © 2021 Mike S * © 2021 Mike S
* © 2021-2023 Harald Barth * © 2021-2023 Harald Barth
* © 2021 Fred Decker * © 2021 Fred Decker
@ -135,8 +135,6 @@ 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;

View File

@ -1,6 +1,6 @@
/* /*
* © 2023 Neil McKechnie * © 2023 Neil McKechnie
* © 2022-2024 Paul M. Antoine * © 2022-2023 Paul M. Antoine
* © 2021 Mike S * © 2021 Mike S
* © 2021, 2023 Harald Barth * © 2021, 2023 Harald Barth
* © 2021 Fred Decker * © 2021 Fred Decker
@ -34,7 +34,6 @@
#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
@ -364,9 +363,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 * ADCee::analogchans = NULL; // Array of channel numbers to be scanned uint32_t * analogchans = NULL; // Array of channel numbers to be scanned
// bool adc1configured = false; // bool adc1configured = false;
ADC_TypeDef * * ADCee::adcchans = NULL; // Array to capture which ADC is each input channel on ADC_TypeDef * * adcchans = NULL; // Array to capture which ADC is each input channel on
int16_t ADCee::ADCmax() int16_t ADCee::ADCmax()
{ {
@ -384,10 +383,9 @@ 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 // Checking for ADC2 and ADC3 being defined helps cater for more variants later
#if defined(ADC2) #if defined(ADC2)
else if (adc == ADC2) else if (adc == ADC2)
{ {
@ -434,18 +432,6 @@ 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

View File

@ -1,5 +1,5 @@
/* /*
* © 2022-2024 Paul M Antoine * © 2022-2023 Paul M Antoine
* © 2021 Mike S * © 2021 Mike S
* © 2021 Fred Decker * © 2021 Fred Decker
* © 2020-2023 Harald Barth * © 2020-2023 Harald Barth
@ -38,8 +38,6 @@ 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,
@ -90,16 +88,6 @@ 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) {
@ -138,16 +126,6 @@ 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;
@ -415,18 +393,6 @@ 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);

View File

@ -1,5 +1,5 @@
/* /*
* © 2022-2024 Paul M. Antoine * © 2022-2023 Paul M. Antoine
* © 2021 Mike S * © 2021 Mike S
* © 2021 Fred Decker * © 2021 Fred Decker
* © 2020 Chris Harlow * © 2020 Chris Harlow
@ -26,7 +26,6 @@
#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)
@ -84,14 +83,6 @@ 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
@ -115,12 +106,6 @@ 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
@ -160,8 +145,6 @@ 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 };