From fb8cca8d3507e5722ae7eed6b84c9a2ac4cfcdb2 Mon Sep 17 00:00:00 2001 From: FranziHH <45534937+FranziHH@users.noreply.github.com> Date: Wed, 30 Aug 2023 21:02:37 +0200 Subject: [PATCH] FastClock BUG serial is working I2C is wrong First, the initialization was incorrect. The FastClock was initialized before the I2C Manager was initialized Second: FastClock Functions are missing --- I2CManager.cpp | 6 +++++- IODevice.cpp | 12 +++++++++++- IO_EXFastclock.h | 4 ++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/I2CManager.cpp b/I2CManager.cpp index d0d8550..a68d08d 100644 --- a/I2CManager.cpp +++ b/I2CManager.cpp @@ -48,6 +48,10 @@ static const FSH * guessI2CDeviceType(uint8_t address) { if (address >= 0x20 && address <= 0x26) return F("GPIO Expander"); +#ifdef FAST_CLOCK_I2C + else if (address == FAST_CLOCK_I2C) + return F("Fast Clock"); +#endif else if (address == 0x27) return F("GPIO Expander or LCD Display"); else if (address == 0x29) @@ -363,4 +367,4 @@ void I2CAddress::toHex(const uint8_t value, char *buffer) { /* static */ bool I2CAddress::_addressWarningDone = false; -#endif \ No newline at end of file +#endif diff --git a/IODevice.cpp b/IODevice.cpp index 2ed21b6..1155c85 100644 --- a/IODevice.cpp +++ b/IODevice.cpp @@ -27,6 +27,12 @@ #include "IO_MCP23017.h" #include "DCCTimer.h" +#if !defined(IO_NO_HAL) + #ifdef FAST_CLOCK_I2C + #include "IO_EXFastClock.h" // FastClock driver + #endif +#endif + #if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR) #define USE_FAST_IO #endif @@ -75,6 +81,11 @@ void IODevice::begin() { } else { DIAG(F("Default PCA9685 at I2C 0x41 disabled due to configured user device")); } + + #ifdef FAST_CLOCK_I2C + EXFastClock::create(FAST_CLOCK_I2C); + DIAG(F("EXFastClock::create")); + #endif // Predefine two MCP23017 module 0x20/0x21 if no conflicts // Allocates 32 pins 164-195 @@ -582,4 +593,3 @@ bool ArduinoPins::fastReadDigital(uint8_t pin) { #endif return result; } - diff --git a/IO_EXFastclock.h b/IO_EXFastclock.h index 5ed237e..06d546f 100644 --- a/IO_EXFastclock.h +++ b/IO_EXFastclock.h @@ -56,12 +56,12 @@ static void create(I2CAddress i2cAddress) { // XXXX change thistosave2 bytes if (_checkforclock == 0) { FAST_CLOCK_EXISTS = true; - //DIAG(F("I2C Fast Clock found at %s"), i2cAddress.toString()); + DIAG(F("I2C Fast Clock found at %s"), i2cAddress.toString()); new EXFastClock(i2cAddress); } else { FAST_CLOCK_EXISTS = false; - //DIAG(F("No Fast Clock found")); + DIAG(F("No Fast Clock found")); LCD(6,F("CLOCK NOT FOUND")); }