Переглянути джерело

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

0r31 5 роки тому
джерело
коміт
b57ef4b261

+ 11
- 3
Marlin/Configuration_adv.h Переглянути файл

2449
 
2449
 
2450
 #endif // HAS_L64XX
2450
 #endif // HAS_L64XX
2451
 
2451
 
2452
+// @section i2cbus
2453
+
2454
+//
2455
+// I2C Master ID for LPC176x LCD and Digital Current control
2456
+// Does not apply to other peripherals based on the Wire library.
2457
+//
2458
+//#define I2C_MASTER_ID  1  // Set a value from 0 to 2
2459
+
2452
 /**
2460
 /**
2453
  * TWI/I2C BUS
2461
  * TWI/I2C BUS
2454
  *
2462
  *
2477
  * echo:i2c-reply: from:99 bytes:5 data:hello
2485
  * echo:i2c-reply: from:99 bytes:5 data:hello
2478
  */
2486
  */
2479
 
2487
 
2480
-// @section i2cbus
2481
-
2482
 //#define EXPERIMENTAL_I2CBUS
2488
 //#define EXPERIMENTAL_I2CBUS
2483
-#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
2489
+#if ENABLED(EXPERIMENTAL_I2CBUS)
2490
+  #define I2C_SLAVE_ADDRESS  0  // Set a value from 8 to 127 to act as a slave
2491
+#endif
2484
 
2492
 
2485
 // @section extras
2493
 // @section extras
2486
 
2494
 

+ 3
- 4
Marlin/src/HAL/HAL_LPC1768/include/i2c_util.c Переглянути файл

26
 
26
 
27
 #ifdef TARGET_LPC1768
27
 #ifdef TARGET_LPC1768
28
 
28
 
29
-#include "../../../inc/MarlinConfigPre.h"
30
 #include "i2c_util.h"
29
 #include "i2c_util.h"
31
 
30
 
32
 #define U8G_I2C_OPT_FAST 16  // from u8g.h
31
 #define U8G_I2C_OPT_FAST 16  // from u8g.h
43
   PinCfg.OpenDrain = 0;
42
   PinCfg.OpenDrain = 0;
44
   PinCfg.Pinmode = 0;
43
   PinCfg.Pinmode = 0;
45
   PinCfg.Portnum = 0;
44
   PinCfg.Portnum = 0;
46
-  #if USEDI2CDEV_M == 0
45
+  #if I2C_MASTER_ID == 0
47
     PinCfg.Funcnum = 1;
46
     PinCfg.Funcnum = 1;
48
     PinCfg.Pinnum = 27;     // SDA0 / D57  AUX-1 ... SCL0 / D58  AUX-1
47
     PinCfg.Pinnum = 27;     // SDA0 / D57  AUX-1 ... SCL0 / D58  AUX-1
49
-  #elif USEDI2CDEV_M == 1
48
+  #elif I2C_MASTER_ID == 1
50
     PinCfg.Funcnum = 3;
49
     PinCfg.Funcnum = 3;
51
     PinCfg.Pinnum = 0;      // SDA1 / D20 SCA ... SCL1 / D21 SCL
50
     PinCfg.Pinnum = 0;      // SDA1 / D20 SCA ... SCL1 / D21 SCL
52
-  #elif USEDI2CDEV_M == 2
51
+  #elif I2C_MASTER_ID == 2
53
     PinCfg.Funcnum = 2;
52
     PinCfg.Funcnum = 2;
54
     PinCfg.Pinnum = 10;     // SDA2 / D38  X_ENABLE_PIN ... SCL2 / D55  X_DIR_PIN
53
     PinCfg.Pinnum = 10;     // SDA2 / D38  X_ENABLE_PIN ... SCL2 / D55  X_DIR_PIN
55
   #endif
54
   #endif

+ 7
- 5
Marlin/src/HAL/HAL_LPC1768/include/i2c_util.h Переглянути файл

25
  * HAL_LPC1768/include/i2c_util.h
25
  * HAL_LPC1768/include/i2c_util.h
26
  */
26
  */
27
 
27
 
28
-#ifndef USEDI2CDEV_M
29
-  #define USEDI2CDEV_M  1  // By default use I2C1 controller
28
+#include "../../../inc/MarlinConfigPre.h"
29
+
30
+#ifndef I2C_MASTER_ID
31
+  #define I2C_MASTER_ID 1
30
 #endif
32
 #endif
31
 
33
 
32
-#if USEDI2CDEV_M == 0
34
+#if I2C_MASTER_ID == 0
33
   #define I2CDEV_M LPC_I2C0
35
   #define I2CDEV_M LPC_I2C0
34
-#elif USEDI2CDEV_M == 1
36
+#elif I2C_MASTER_ID == 1
35
   #define I2CDEV_M LPC_I2C1
37
   #define I2CDEV_M LPC_I2C1
36
-#elif USEDI2CDEV_M == 2
38
+#elif I2C_MASTER_ID == 2
37
   #define I2CDEV_M LPC_I2C2
39
   #define I2CDEV_M LPC_I2C2
38
 #else
40
 #else
39
   #error "Master I2C device not defined!"
41
   #error "Master I2C device not defined!"

+ 3
- 3
Marlin/src/HAL/HAL_LPC1768/u8g/LCD_I2C_routines.cpp Переглянути файл

25
 
25
 
26
 #ifdef TARGET_LPC1768
26
 #ifdef TARGET_LPC1768
27
 
27
 
28
+#include "../include/i2c_util.h"
29
+#include "../../../core/millis_t.h"
30
+
28
 extern int millis();
31
 extern int millis();
29
 
32
 
30
 #ifdef __cplusplus
33
 #ifdef __cplusplus
31
   extern "C" {
34
   extern "C" {
32
 #endif
35
 #endif
33
 
36
 
34
-#include "../include/i2c_util.h"
35
-#include "../../../core/millis_t.h"
36
-
37
 //////////////////////////////////////////////////////////////////////////////////////
37
 //////////////////////////////////////////////////////////////////////////////////////
38
 
38
 
39
 // These two routines are exact copies of the lpc17xx_i2c.c routines.  Couldn't link to
39
 // These two routines are exact copies of the lpc17xx_i2c.c routines.  Couldn't link to

Завантаження…
Відмінити
Зберегти