mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-30 03:26:13 +01:00
HAL defaults control
This commit is contained in:
parent
8216579f62
commit
95bf5aae38
|
@ -67,6 +67,7 @@
|
||||||
#undef FWD
|
#undef FWD
|
||||||
#undef GREEN
|
#undef GREEN
|
||||||
#undef HAL
|
#undef HAL
|
||||||
|
#undef HAL_IGNORE_DEFAULTS
|
||||||
#undef IF
|
#undef IF
|
||||||
#undef IFAMBER
|
#undef IFAMBER
|
||||||
#undef IFCLOSED
|
#undef IFCLOSED
|
||||||
|
@ -218,6 +219,7 @@
|
||||||
#define FWD(speed)
|
#define FWD(speed)
|
||||||
#define GREEN(signal_id)
|
#define GREEN(signal_id)
|
||||||
#define HAL(haltype,params...)
|
#define HAL(haltype,params...)
|
||||||
|
#define HAL_IGNORE_DEFAULTS
|
||||||
#define IF(sensor_id)
|
#define IF(sensor_id)
|
||||||
#define IFAMBER(signal_id)
|
#define IFAMBER(signal_id)
|
||||||
#define IFCLOSED(turnout_id)
|
#define IFCLOSED(turnout_id)
|
||||||
|
|
|
@ -143,8 +143,12 @@ static_assert(!hasdup(compileTimeSequenceList[0],1),"Duplicate SEQUENCE/ROUTE/AU
|
||||||
#include "EXRAIL2MacroReset.h"
|
#include "EXRAIL2MacroReset.h"
|
||||||
#undef HAL
|
#undef HAL
|
||||||
#define HAL(haltype,params...) haltype::create(params);
|
#define HAL(haltype,params...) haltype::create(params);
|
||||||
void exrailHalSetup() {
|
#undef HAL_IGNORE_DEFAULTS
|
||||||
|
#define HAL_IGNORE_DEFAULTS ignore_defaults=true;
|
||||||
|
bool exrailHalSetup() {
|
||||||
|
bool ignore_defaults=false;
|
||||||
#include "myAutomation.h"
|
#include "myAutomation.h"
|
||||||
|
return ignore_defaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass 1c detect compile time featurtes
|
// Pass 1c detect compile time featurtes
|
||||||
|
@ -460,6 +464,7 @@ int RMFT2::onLCCLookup[RMFT2::countLCCLookup];
|
||||||
#define FWD(speed) OPCODE_FWD,V(speed),
|
#define FWD(speed) OPCODE_FWD,V(speed),
|
||||||
#define GREEN(signal_id) OPCODE_GREEN,V(signal_id),
|
#define GREEN(signal_id) OPCODE_GREEN,V(signal_id),
|
||||||
#define HAL(haltype,params...)
|
#define HAL(haltype,params...)
|
||||||
|
#define HAL_IGNORE_DEFAULTS
|
||||||
#define IF(sensor_id) OPCODE_IF,V(sensor_id),
|
#define IF(sensor_id) OPCODE_IF,V(sensor_id),
|
||||||
#define IFAMBER(signal_id) OPCODE_IFAMBER,V(signal_id),
|
#define IFAMBER(signal_id) OPCODE_IFAMBER,V(signal_id),
|
||||||
#define IFCLOSED(turnout_id) OPCODE_IFCLOSED,V(turnout_id),
|
#define IFCLOSED(turnout_id) OPCODE_IFCLOSED,V(turnout_id),
|
||||||
|
|
34
IODevice.cpp
34
IODevice.cpp
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
// Link to halSetup function. If not defined, the function reference will be NULL.
|
// Link to halSetup function. If not defined, the function reference will be NULL.
|
||||||
extern __attribute__((weak)) void halSetup();
|
extern __attribute__((weak)) void halSetup();
|
||||||
extern __attribute__((weak)) void exrailHalSetup();
|
extern __attribute__((weak)) bool exrailHalSetup();
|
||||||
|
|
||||||
//==================================================================================================================
|
//==================================================================================================================
|
||||||
// Static methods
|
// Static methods
|
||||||
|
@ -60,33 +60,30 @@ void IODevice::begin() {
|
||||||
halSetup();
|
halSetup();
|
||||||
|
|
||||||
// include any HAL devices defined in exrail.
|
// include any HAL devices defined in exrail.
|
||||||
|
bool ignoreDefaults=false;
|
||||||
if (exrailHalSetup)
|
if (exrailHalSetup)
|
||||||
exrailHalSetup();
|
ignoreDefaults=exrailHalSetup();
|
||||||
|
if (ignoreDefaults) return;
|
||||||
|
|
||||||
// Predefine two PCA9685 modules 0x40-0x41 if no conflicts
|
// Predefine two PCA9685 modules 0x40-0x41 if no conflicts
|
||||||
// Allocates 32 pins 100-131
|
// Allocates 32 pins 100-131
|
||||||
if (checkNoOverlap(100, 16, 0x40)) {
|
const bool silent=true; // no message if these conflict
|
||||||
|
if (checkNoOverlap(100, 16, 0x40, silent)) {
|
||||||
PCA9685::create(100, 16, 0x40);
|
PCA9685::create(100, 16, 0x40);
|
||||||
} else {
|
|
||||||
DIAG(F("Default PCA9685 at I2C 0x40 disabled due to configured user device"));
|
|
||||||
}
|
}
|
||||||
if (checkNoOverlap(116, 16, 0x41)) {
|
|
||||||
|
if (checkNoOverlap(116, 16, 0x41, silent)) {
|
||||||
PCA9685::create(116, 16, 0x41);
|
PCA9685::create(116, 16, 0x41);
|
||||||
} else {
|
|
||||||
DIAG(F("Default PCA9685 at I2C 0x41 disabled due to configured user device"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Predefine two MCP23017 module 0x20/0x21 if no conflicts
|
// Predefine two MCP23017 module 0x20/0x21 if no conflicts
|
||||||
// Allocates 32 pins 164-195
|
// Allocates 32 pins 164-195
|
||||||
if (checkNoOverlap(164, 16, 0x20)) {
|
if (checkNoOverlap(164, 16, 0x20, silent)) {
|
||||||
MCP23017::create(164, 16, 0x20);
|
MCP23017::create(164, 16, 0x20);
|
||||||
} else {
|
|
||||||
DIAG(F("Default MCP23017 at I2C 0x20 disabled due to configured user device"));
|
|
||||||
}
|
}
|
||||||
if (checkNoOverlap(180, 16, 0x21)) {
|
|
||||||
|
if (checkNoOverlap(180, 16, 0x21, silent)) {
|
||||||
MCP23017::create(180, 16, 0x21);
|
MCP23017::create(180, 16, 0x21);
|
||||||
} else {
|
|
||||||
DIAG(F("Default MCP23017 at I2C 0x21 disabled due to configured user device"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +336,10 @@ IODevice *IODevice::findDeviceFollowing(VPIN vpin) {
|
||||||
// returns true if pins DONT overlap with existing device
|
// returns true if pins DONT overlap with existing device
|
||||||
// TODO: Move the I2C address reservation and checks into the I2CManager code.
|
// TODO: Move the I2C address reservation and checks into the I2CManager code.
|
||||||
// That will enable non-HAL devices to reserve I2C addresses too.
|
// That will enable non-HAL devices to reserve I2C addresses too.
|
||||||
bool IODevice::checkNoOverlap(VPIN firstPin, uint8_t nPins, I2CAddress i2cAddress) {
|
// Silent is used by the default setup so that there is no message if the default
|
||||||
|
// device has already been handled by the user setup.
|
||||||
|
bool IODevice::checkNoOverlap(VPIN firstPin, uint8_t nPins,
|
||||||
|
I2CAddress i2cAddress, bool silent) {
|
||||||
#ifdef DIAG_IO
|
#ifdef DIAG_IO
|
||||||
DIAG(F("Check no overlap %u %u %s"), firstPin,nPins,i2cAddress.toString());
|
DIAG(F("Check no overlap %u %u %s"), firstPin,nPins,i2cAddress.toString());
|
||||||
#endif
|
#endif
|
||||||
|
@ -352,14 +352,14 @@ bool IODevice::checkNoOverlap(VPIN firstPin, uint8_t nPins, I2CAddress i2cAddres
|
||||||
VPIN lastDevPin=firstDevPin+dev->_nPins-1;
|
VPIN lastDevPin=firstDevPin+dev->_nPins-1;
|
||||||
bool noOverlap= firstPin>lastDevPin || lastPin<firstDevPin;
|
bool noOverlap= firstPin>lastDevPin || lastPin<firstDevPin;
|
||||||
if (!noOverlap) {
|
if (!noOverlap) {
|
||||||
DIAG(F("WARNING HAL Overlap, redefinition of Vpins %u to %u ignored."),
|
if (!silent) DIAG(F("WARNING HAL Overlap, redefinition of Vpins %u to %u ignored."),
|
||||||
firstPin, lastPin);
|
firstPin, lastPin);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check for overlapping I2C address
|
// Check for overlapping I2C address
|
||||||
if (i2cAddress && dev->_I2CAddress==i2cAddress) {
|
if (i2cAddress && dev->_I2CAddress==i2cAddress) {
|
||||||
DIAG(F("WARNING HAL Overlap. i2c Addr %s ignored."),i2cAddress.toString());
|
if (!silent) DIAG(F("WARNING HAL Overlap. i2c Addr %s ignored."),i2cAddress.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,8 @@ public:
|
||||||
void setGPIOInterruptPin(int16_t pinNumber);
|
void setGPIOInterruptPin(int16_t pinNumber);
|
||||||
|
|
||||||
// Method to check if pins will overlap before creating new device.
|
// Method to check if pins will overlap before creating new device.
|
||||||
static bool checkNoOverlap(VPIN firstPin, uint8_t nPins=1, I2CAddress i2cAddress=0);
|
static bool checkNoOverlap(VPIN firstPin, uint8_t nPins=1,
|
||||||
|
I2CAddress i2cAddress=0, bool silent=false);
|
||||||
|
|
||||||
// Method used by IODevice filters to locate slave pins that may be overlayed by their own
|
// Method used by IODevice filters to locate slave pins that may be overlayed by their own
|
||||||
// pin range.
|
// pin range.
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
|
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
|
|
||||||
#define VERSION "5.2.25"
|
#define VERSION "5.2.26"
|
||||||
|
// 5.2.26 - Silently ignore overridden HAL defaults
|
||||||
|
// - include HAL_IGNORE_DEFAULTS macro in EXRAIL
|
||||||
// 5.2.25 - Fix bug causing <X> after working <D commands
|
// 5.2.25 - Fix bug causing <X> after working <D commands
|
||||||
// 5.2.24 - Exrail macro asserts to catch
|
// 5.2.24 - Exrail macro asserts to catch
|
||||||
// : duplicate/missing automation/route/sequence/call ids
|
// : duplicate/missing automation/route/sequence/call ids
|
||||||
|
|
Loading…
Reference in New Issue
Block a user