Override for LPC1768 u8g/digipot I2C master ID (#16622)

This commit is contained in:
0r31 2020-01-21 03:09:16 +01:00 committed by Scott Lahteine
parent 1a5cbc9052
commit b57ef4b261
4 changed files with 24 additions and 15 deletions

View file

@ -2449,6 +2449,14 @@
#endif // HAS_L64XX #endif // HAS_L64XX
// @section i2cbus
//
// I2C Master ID for LPC176x LCD and Digital Current control
// Does not apply to other peripherals based on the Wire library.
//
//#define I2C_MASTER_ID 1 // Set a value from 0 to 2
/** /**
* TWI/I2C BUS * TWI/I2C BUS
* *
@ -2477,10 +2485,10 @@
* echo:i2c-reply: from:99 bytes:5 data:hello * echo:i2c-reply: from:99 bytes:5 data:hello
*/ */
// @section i2cbus
//#define EXPERIMENTAL_I2CBUS //#define EXPERIMENTAL_I2CBUS
#define I2C_SLAVE_ADDRESS 0 // Set a value from 8 to 127 to act as a slave #if ENABLED(EXPERIMENTAL_I2CBUS)
#define I2C_SLAVE_ADDRESS 0 // Set a value from 8 to 127 to act as a slave
#endif
// @section extras // @section extras

View file

@ -26,7 +26,6 @@
#ifdef TARGET_LPC1768 #ifdef TARGET_LPC1768
#include "../../../inc/MarlinConfigPre.h"
#include "i2c_util.h" #include "i2c_util.h"
#define U8G_I2C_OPT_FAST 16 // from u8g.h #define U8G_I2C_OPT_FAST 16 // from u8g.h
@ -43,13 +42,13 @@ void configure_i2c(const uint8_t clock_option) {
PinCfg.OpenDrain = 0; PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0; PinCfg.Pinmode = 0;
PinCfg.Portnum = 0; PinCfg.Portnum = 0;
#if USEDI2CDEV_M == 0 #if I2C_MASTER_ID == 0
PinCfg.Funcnum = 1; PinCfg.Funcnum = 1;
PinCfg.Pinnum = 27; // SDA0 / D57 AUX-1 ... SCL0 / D58 AUX-1 PinCfg.Pinnum = 27; // SDA0 / D57 AUX-1 ... SCL0 / D58 AUX-1
#elif USEDI2CDEV_M == 1 #elif I2C_MASTER_ID == 1
PinCfg.Funcnum = 3; PinCfg.Funcnum = 3;
PinCfg.Pinnum = 0; // SDA1 / D20 SCA ... SCL1 / D21 SCL PinCfg.Pinnum = 0; // SDA1 / D20 SCA ... SCL1 / D21 SCL
#elif USEDI2CDEV_M == 2 #elif I2C_MASTER_ID == 2
PinCfg.Funcnum = 2; PinCfg.Funcnum = 2;
PinCfg.Pinnum = 10; // SDA2 / D38 X_ENABLE_PIN ... SCL2 / D55 X_DIR_PIN PinCfg.Pinnum = 10; // SDA2 / D38 X_ENABLE_PIN ... SCL2 / D55 X_DIR_PIN
#endif #endif

View file

@ -25,15 +25,17 @@
* HAL_LPC1768/include/i2c_util.h * HAL_LPC1768/include/i2c_util.h
*/ */
#ifndef USEDI2CDEV_M #include "../../../inc/MarlinConfigPre.h"
#define USEDI2CDEV_M 1 // By default use I2C1 controller
#ifndef I2C_MASTER_ID
#define I2C_MASTER_ID 1
#endif #endif
#if USEDI2CDEV_M == 0 #if I2C_MASTER_ID == 0
#define I2CDEV_M LPC_I2C0 #define I2CDEV_M LPC_I2C0
#elif USEDI2CDEV_M == 1 #elif I2C_MASTER_ID == 1
#define I2CDEV_M LPC_I2C1 #define I2CDEV_M LPC_I2C1
#elif USEDI2CDEV_M == 2 #elif I2C_MASTER_ID == 2
#define I2CDEV_M LPC_I2C2 #define I2CDEV_M LPC_I2C2
#else #else
#error "Master I2C device not defined!" #error "Master I2C device not defined!"

View file

@ -25,15 +25,15 @@
#ifdef TARGET_LPC1768 #ifdef TARGET_LPC1768
#include "../include/i2c_util.h"
#include "../../../core/millis_t.h"
extern int millis(); extern int millis();
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "../include/i2c_util.h"
#include "../../../core/millis_t.h"
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
// These two routines are exact copies of the lpc17xx_i2c.c routines. Couldn't link to // These two routines are exact copies of the lpc17xx_i2c.c routines. Couldn't link to