Procházet zdrojové kódy

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

0r31 před 4 roky
rodič
revize
b57ef4b261

+ 11
- 3
Marlin/Configuration_adv.h Zobrazit soubor

@@ -2449,6 +2449,14 @@
2449 2449
 
2450 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 2461
  * TWI/I2C BUS
2454 2462
  *
@@ -2477,10 +2485,10 @@
2477 2485
  * echo:i2c-reply: from:99 bytes:5 data:hello
2478 2486
  */
2479 2487
 
2480
-// @section i2cbus
2481
-
2482 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 2493
 // @section extras
2486 2494
 

+ 3
- 4
Marlin/src/HAL/HAL_LPC1768/include/i2c_util.c Zobrazit soubor

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

+ 7
- 5
Marlin/src/HAL/HAL_LPC1768/include/i2c_util.h Zobrazit soubor

@@ -25,15 +25,17 @@
25 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 32
 #endif
31 33
 
32
-#if USEDI2CDEV_M == 0
34
+#if I2C_MASTER_ID == 0
33 35
   #define I2CDEV_M LPC_I2C0
34
-#elif USEDI2CDEV_M == 1
36
+#elif I2C_MASTER_ID == 1
35 37
   #define I2CDEV_M LPC_I2C1
36
-#elif USEDI2CDEV_M == 2
38
+#elif I2C_MASTER_ID == 2
37 39
   #define I2CDEV_M LPC_I2C2
38 40
 #else
39 41
   #error "Master I2C device not defined!"

+ 3
- 3
Marlin/src/HAL/HAL_LPC1768/u8g/LCD_I2C_routines.cpp Zobrazit soubor

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

Loading…
Zrušit
Uložit