From 6d476d71447e707df2ee5b3c367a650235357f9b Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 27 Sep 2020 14:29:07 +0200 Subject: [PATCH] Still use SWI2C on RAMBo10a boards The wiring for the PAT9125 on RAMBo10a boards is not directly connected to the SCL pin and requires the sw mode. Detect this requirement by checking the definition for the SWI2C_SCL pin in the board definition. Remove SWI2C_SCL/SDA from the other boards to use the HW mode. --- Firmware/config.h | 5 ++++- Firmware/pins_Einsy_1_0.h | 6 ------ Firmware/pins_Rambo_1_3.h | 3 --- Firmware/swi2c.c | 3 +++ 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Firmware/config.h b/Firmware/config.h index c64bd441..922a5398 100644 --- a/Firmware/config.h +++ b/Firmware/config.h @@ -31,8 +31,11 @@ //PAT9125 configuration //#define PAT9125_SWSPI // software SPI mode (incomplete) -//#define PAT9125_SWI2C // software I2C mode +#ifdef SWI2C_SCL +#define PAT9125_SWI2C // software I2C mode +#else #define PAT9125_I2C // hardware I2C mode +#endif #define PAT9125_I2C_ADDR 0x75 //ID=LO //#define PAT9125_I2C_ADDR 0x79 //ID=HI diff --git a/Firmware/pins_Einsy_1_0.h b/Firmware/pins_Einsy_1_0.h index 14b56233..21578ebd 100755 --- a/Firmware/pins_Einsy_1_0.h +++ b/Firmware/pins_Einsy_1_0.h @@ -18,12 +18,6 @@ #define W25X20CL // external 256kB flash #define BOOTAPP // bootloader support - -#define SWI2C_SDA 20 //SDA on P3 -#define SWI2C_SCL 21 //SCL on P3 - - - #define X_TMC2130_CS 41 #define X_TMC2130_DIAG 64 // !!! changed from 40 (EINY03) #define X_STEP_PIN 37 diff --git a/Firmware/pins_Rambo_1_3.h b/Firmware/pins_Rambo_1_3.h index 538fb4f3..522ad28f 100644 --- a/Firmware/pins_Rambo_1_3.h +++ b/Firmware/pins_Rambo_1_3.h @@ -11,9 +11,6 @@ #define PINDA_THERMISTOR -#define SWI2C_SDA 20 //SDA on P3 -#define SWI2C_SCL 21 //SCL on P3 - #ifdef MICROMETER_LOGGING #define D_DATACLOCK 24 //Y_MAX (green) #define D_DATA 30 //X_MAX (blue) diff --git a/Firmware/swi2c.c b/Firmware/swi2c.c index 49fbc5ef..62a28e1a 100644 --- a/Firmware/swi2c.c +++ b/Firmware/swi2c.c @@ -7,6 +7,7 @@ #include "pins.h" #include "io_atmega2560.h" +#ifdef SWI2C_SCL #define SWI2C_RMSK 0x01 //read mask (bit0 = 1) #define SWI2C_WMSK 0x00 //write mask (bit0 = 0) @@ -187,3 +188,5 @@ uint8_t swi2c_writeByte_A16(uint8_t dev_addr, unsigned short addr, uint8_t* pbyt } #endif //SWI2C_A16 + +#endif //SWI2C_SCL