From 4833eaac65b02d4b90ce292afa15ac3f56af4608 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Mon, 13 Jun 2022 23:15:35 +0200 Subject: [PATCH] move all arch dependent port register declarations to MotorDriver.h --- GITHUB_SHA.h | 2 +- MotorDriver.cpp | 6 +++--- MotorDriver.h | 26 ++++++++++++++------------ TrackManager.cpp | 7 ------- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index 20a16e5..06deeac 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "TM-PORTX-20220611-1" +#define GITHUB_SHA "TM-PORTX-20220613" diff --git a/MotorDriver.cpp b/MotorDriver.cpp index 930a993..6e1da57 100644 --- a/MotorDriver.cpp +++ b/MotorDriver.cpp @@ -27,9 +27,9 @@ bool MotorDriver::commonFaultPin=false; -volatile byte fakePORTA; -volatile byte fakePORTB; -volatile byte fakePORTC; +volatile portreg_t fakePORTA; +volatile portreg_t fakePORTB; +volatile portreg_t fakePORTC; MotorDriver::MotorDriver(VPIN power_pin, byte signal_pin, byte signal_pin2, int8_t brake_pin, byte current_pin, float sense_factor, unsigned int trip_milliamps, byte fault_pin) { diff --git a/MotorDriver.h b/MotorDriver.h index fe262f1..27ccff7 100644 --- a/MotorDriver.h +++ b/MotorDriver.h @@ -63,20 +63,22 @@ #endif #if defined(__IMXRT1062__) || defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) -struct FASTPIN { - volatile uint32_t *inout; - uint32_t maskHIGH; - uint32_t maskLOW; - volatile uint32_t *shadowinout; -}; +typedef uint32_t portreg_t; #else -struct FASTPIN { - volatile uint8_t *inout; - uint8_t maskHIGH; - uint8_t maskLOW; - volatile uint8_t *shadowinout; -}; +typedef uint8_t portreg_t; #endif +struct FASTPIN { + volatile portreg_t *inout; + portreg_t maskHIGH; + portreg_t maskLOW; + volatile portreg_t *shadowinout; +}; +// The port registers that are shadowing +// the real port registers. These are +// defined in Motordriver.cpp +extern volatile portreg_t fakePORTA; +extern volatile portreg_t fakePORTB; +extern volatile portreg_t fakePORTC; enum class POWERMODE : byte { OFF, ON, OVERLOAD }; diff --git a/TrackManager.cpp b/TrackManager.cpp index 5b48cc4..3995dbf 100644 --- a/TrackManager.cpp +++ b/TrackManager.cpp @@ -86,13 +86,6 @@ void TrackManager::addTrack(byte t, MotorDriver* driver) { } } -// The port registers that are shadowing -// the real port registers. These are -// defined in Motordriver.cpp -extern byte fakePORTA; -extern byte fakePORTB; -extern byte fakePORTC; - // setDCCSignal(), called from interrupt context // does assume ports are shadowed if they can be void TrackManager::setDCCSignal( bool on) {