1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-25 05:31:24 +01:00

Bug fixes, update registers

This commit is contained in:
peteGSX 2022-12-11 19:44:42 +10:00
parent 9699a44081
commit 785b515f9e
2 changed files with 21 additions and 27 deletions

View File

@ -18,17 +18,12 @@
*/ */
/* /*
* This file defines default pin maps for the various architectures supported * This file defines default pin numbers for the various architectures supported
* by default by EX-IOExpander. * by default by EX-IOExpander.
* *
* Custom user defined pinmaps should be defined in myEX-IOExpander.h.
*
* Any modifications to this file will be overwritten by future software updates. * Any modifications to this file will be overwritten by future software updates.
*/ */
// #define DEFAULT_NANO_DIGITAL_PINMAP 2,3,4,5,6,7,8,9,10,11,12,13
// #define DEFAULT_NANO_ANALOGUE_PINMAP A0,A1,A2,A3,A6,A7
#define EXIO_UNO_DIGITAL_PINS 12 #define EXIO_UNO_DIGITAL_PINS 12
#define EXIO_UNO_ANALOGUE_PINS 4 #define EXIO_UNO_ANALOGUE_PINS 4
@ -37,10 +32,3 @@
#define EXIO_MEGA_DIGITAL_PINS 46 #define EXIO_MEGA_DIGITAL_PINS 46
#define EXIO_MEGA_ANALOGUE_PINS 16 #define EXIO_MEGA_ANALOGUE_PINS 16
// #define EXIO_UNO_DIGITAL_PINMAP 2,3,4,5,6,7,8,9,10,11,12,13
// #define EXIO_UNO_ANALOGUE_PINMAP A0,A1,A2,A3
// #define DEFAULT_MEGA_DIGITAL_PINMAP 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,22,23,24,25,26,27,28,29, \
// 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49
// #define DEFAULT_MEGA_ANALOGUE_PINMAP A0,A1,A2,A3,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15

View File

@ -84,19 +84,25 @@ private:
// Enable digital ports // Enable digital ports
_digitalPinBytes = (_numDigitalPins + 7) / 8; _digitalPinBytes = (_numDigitalPins + 7) / 8;
uint8_t enableDigitalPins[_digitalPinBytes]; uint8_t enableDigitalPins[_digitalPinBytes];
for (uint8_t pin = 0; pin < _numDigitalPins; pin++) { for (uint8_t byte = 0; byte < _digitalPinBytes; byte++) {
int pinByte = ((pin + 7) / 8); enableDigitalPins[byte] = 0;
bitSet(enableDigitalPins[pinByte], (pin - (pinByte * 8)));
} }
I2CManager.write(_i2cAddress, _digitalPinBytes + 1, REG_EXIODPIN, enableDigitalPins); for (uint8_t pin = 0; pin < _numDigitalPins; pin++) {
int pinByte = pin / 8;
bitSet(enableDigitalPins[pinByte], pin - pinByte * 8);
}
I2CManager.write(_i2cAddress, _digitalPinBytes + 1, REG_EXIODPIN, *enableDigitalPins);
// Enable analogue ports // Enable analogue ports
_analoguePinBytes = (_numAnaloguePins + 7) / 8; _analoguePinBytes = (_numAnaloguePins + 7) / 8;
uint8_t enableAnaloguePins[_analoguePinBytes]; uint8_t enableAnaloguePins[_analoguePinBytes];
for (uint8_t pin = 0; pin < _numAnaloguePins; pin++) { for (uint8_t byte = 0; byte < _analoguePinBytes; byte++) {
int pinByte = ((pin + 7) / 8); enableAnaloguePins[byte] = 0;
bitSet(enableAnaloguePins[pinByte], (pin - (pinByte * 8)));
} }
I2CManager.write(_i2cAddress, _analoguePinBytes + 1, REG_EXIOAPIN, enableAnaloguePins); for (uint8_t pin = 0; pin < _numAnaloguePins; pin++) {
int pinByte = pin / 8;
bitSet(enableAnaloguePins[pinByte], pin - pinByte * 8);
}
I2CManager.write(_i2cAddress, _analoguePinBytes + 1, REG_EXIOAPIN, *enableAnaloguePins);
} }
void _display() override { void _display() override {
@ -111,12 +117,12 @@ private:
int _analoguePinBytes; int _analoguePinBytes;
enum { enum {
REG_EXIOINIT = 0x00, // Flag to initialise setup procedure REG_EXIOINIT = 0xE0, // Flag to initialise setup procedure
REG_EXIODPIN = 0x01, // Flag we're sending digital pin assignments REG_EXIODPIN = 0xE1, // Flag we're sending digital pin assignments
REG_EXIOAPIN = 0x02, // Flag we're sending analogue pin assignments REG_EXIOAPIN = 0xE2, // Flag we're sending analogue pin assignments
REG_EXIORDY = 0x03, // Flag we have completed setup procedure, also for EX-IO to ACK setup REG_EXIORDY = 0xE3, // Flag we have completed setup procedure, also for EX-IO to ACK setup
REG_EXIODDIR = 0x04, // Flag we're sending digital pin direction configuration REG_EXIODDIR = 0xE4, // Flag we're sending digital pin direction configuration
REG_EXIODPUP = 0x05, // Flag we're sending digital pin pullup configuration REG_EXIODPUP = 0xE5, // Flag we're sending digital pin pullup configuration
}; };
}; };