Browse Source

Merge pull request #4608 from thinkyhead/rc_more_twibus_tweaks

Additional details for I2C_SLAVE_ADDRESS
Scott Lahteine 8 years ago
parent
commit
464d594450

+ 1
- 1
.travis.yml View File

209
   #
209
   #
210
   - restore_configs
210
   - restore_configs
211
   - opt_enable_adv BEZIER_CURVE_SUPPORT EXPERIMENTAL_I2CBUS
211
   - opt_enable_adv BEZIER_CURVE_SUPPORT EXPERIMENTAL_I2CBUS
212
-  - opt_set_adv I2C_SLAVE_ADDRESS 1
212
+  - opt_set_adv I2C_SLAVE_ADDRESS 63
213
   - build_marlin
213
   - build_marlin
214
   #
214
   #
215
   # Enable COREXY
215
   # Enable COREXY

+ 1
- 1
Marlin/Configuration_adv.h View File

795
 // @section i2cbus
795
 // @section i2cbus
796
 
796
 
797
 //#define EXPERIMENTAL_I2CBUS
797
 //#define EXPERIMENTAL_I2CBUS
798
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
798
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
799
 
799
 
800
 #endif // CONFIGURATION_ADV_H
800
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/Marlin_main.cpp View File

5294
     }
5294
     }
5295
   }
5295
   }
5296
 
5296
 
5297
-#endif //EXPERIMENTAL_I2CBUS
5297
+#endif // EXPERIMENTAL_I2CBUS
5298
 
5298
 
5299
 /**
5299
 /**
5300
  * M200: Set filament diameter and set E axis units to cubic units
5300
  * M200: Set filament diameter and set E axis units to cubic units

+ 11
- 0
Marlin/SanityCheck.h View File

747
 #if ENABLED(EMERGENCY_PARSER) && defined(USBCON)
747
 #if ENABLED(EMERGENCY_PARSER) && defined(USBCON)
748
   #error "EMERGENCY_PARSER does not work on boards with AT90USB processors (USBCON)."
748
   #error "EMERGENCY_PARSER does not work on boards with AT90USB processors (USBCON)."
749
 #endif
749
 #endif
750
+
751
+/**
752
+ * I2C bus
753
+ */
754
+#if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0
755
+  #if I2C_SLAVE_ADDRESS < 8
756
+    #error "I2C_SLAVE_ADDRESS can't be less than 8. (Addresses 0 - 7 are reserved.)"
757
+  #elif I2C_SLAVE_ADDRESS > 127
758
+    #error "I2C_SLAVE_ADDRESS can't be over 127. (Only 7 bits allowed.)"
759
+  #endif
760
+#endif

+ 1
- 1
Marlin/example_configurations/Cartesio/Configuration_adv.h View File

795
 // @section i2cbus
795
 // @section i2cbus
796
 
796
 
797
 //#define EXPERIMENTAL_I2CBUS
797
 //#define EXPERIMENTAL_I2CBUS
798
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
798
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
799
 
799
 
800
 #endif // CONFIGURATION_ADV_H
800
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/Felix/Configuration_adv.h View File

795
 // @section i2cbus
795
 // @section i2cbus
796
 
796
 
797
 //#define EXPERIMENTAL_I2CBUS
797
 //#define EXPERIMENTAL_I2CBUS
798
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
798
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
799
 
799
 
800
 #endif // CONFIGURATION_ADV_H
800
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/Hephestos/Configuration_adv.h View File

795
 // @section i2cbus
795
 // @section i2cbus
796
 
796
 
797
 //#define EXPERIMENTAL_I2CBUS
797
 //#define EXPERIMENTAL_I2CBUS
798
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
798
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
799
 
799
 
800
 #endif // CONFIGURATION_ADV_H
800
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/Hephestos_2/Configuration_adv.h View File

795
 // @section i2cbus
795
 // @section i2cbus
796
 
796
 
797
 //#define EXPERIMENTAL_I2CBUS
797
 //#define EXPERIMENTAL_I2CBUS
798
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
798
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
799
 
799
 
800
 #endif // CONFIGURATION_ADV_H
800
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/K8200/Configuration_adv.h View File

801
 // @section i2cbus
801
 // @section i2cbus
802
 
802
 
803
 //#define EXPERIMENTAL_I2CBUS
803
 //#define EXPERIMENTAL_I2CBUS
804
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
804
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
805
 
805
 
806
 #endif // CONFIGURATION_ADV_H
806
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/K8400/Configuration_adv.h View File

795
 // @section i2cbus
795
 // @section i2cbus
796
 
796
 
797
 //#define EXPERIMENTAL_I2CBUS
797
 //#define EXPERIMENTAL_I2CBUS
798
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
798
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
799
 
799
 
800
 #endif // CONFIGURATION_ADV_H
800
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/RigidBot/Configuration_adv.h View File

795
 // @section i2cbus
795
 // @section i2cbus
796
 
796
 
797
 //#define EXPERIMENTAL_I2CBUS
797
 //#define EXPERIMENTAL_I2CBUS
798
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
798
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
799
 
799
 
800
 #endif // CONFIGURATION_ADV_H
800
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/SCARA/Configuration_adv.h View File

795
 // @section i2cbus
795
 // @section i2cbus
796
 
796
 
797
 //#define EXPERIMENTAL_I2CBUS
797
 //#define EXPERIMENTAL_I2CBUS
798
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
798
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
799
 
799
 
800
 #endif // CONFIGURATION_ADV_H
800
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/TAZ4/Configuration_adv.h View File

803
 // @section i2cbus
803
 // @section i2cbus
804
 
804
 
805
 //#define EXPERIMENTAL_I2CBUS
805
 //#define EXPERIMENTAL_I2CBUS
806
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
806
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
807
 
807
 
808
 #endif // CONFIGURATION_ADV_H
808
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/WITBOX/Configuration_adv.h View File

795
 // @section i2cbus
795
 // @section i2cbus
796
 
796
 
797
 //#define EXPERIMENTAL_I2CBUS
797
 //#define EXPERIMENTAL_I2CBUS
798
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
798
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
799
 
799
 
800
 #endif // CONFIGURATION_ADV_H
800
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/delta/biv2.5/Configuration_adv.h View File

797
 // @section i2cbus
797
 // @section i2cbus
798
 
798
 
799
 //#define EXPERIMENTAL_I2CBUS
799
 //#define EXPERIMENTAL_I2CBUS
800
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
800
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
801
 
801
 
802
 #endif // CONFIGURATION_ADV_H
802
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/delta/generic/Configuration_adv.h View File

797
 // @section i2cbus
797
 // @section i2cbus
798
 
798
 
799
 //#define EXPERIMENTAL_I2CBUS
799
 //#define EXPERIMENTAL_I2CBUS
800
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
800
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
801
 
801
 
802
 #endif // CONFIGURATION_ADV_H
802
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h View File

796
 // @section i2cbus
796
 // @section i2cbus
797
 
797
 
798
 //#define EXPERIMENTAL_I2CBUS
798
 //#define EXPERIMENTAL_I2CBUS
799
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
799
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
800
 
800
 
801
 #endif // CONFIGURATION_ADV_H
801
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h View File

801
 // @section i2cbus
801
 // @section i2cbus
802
 
802
 
803
 //#define EXPERIMENTAL_I2CBUS
803
 //#define EXPERIMENTAL_I2CBUS
804
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
804
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
805
 
805
 
806
 #endif // CONFIGURATION_ADV_H
806
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h View File

797
 // @section i2cbus
797
 // @section i2cbus
798
 
798
 
799
 //#define EXPERIMENTAL_I2CBUS
799
 //#define EXPERIMENTAL_I2CBUS
800
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
800
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
801
 
801
 
802
 #endif // CONFIGURATION_ADV_H
802
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/makibox/Configuration_adv.h View File

795
 // @section i2cbus
795
 // @section i2cbus
796
 
796
 
797
 //#define EXPERIMENTAL_I2CBUS
797
 //#define EXPERIMENTAL_I2CBUS
798
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
798
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
799
 
799
 
800
 #endif // CONFIGURATION_ADV_H
800
 #endif // CONFIGURATION_ADV_H

+ 1
- 1
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

795
 // @section i2cbus
795
 // @section i2cbus
796
 
796
 
797
 //#define EXPERIMENTAL_I2CBUS
797
 //#define EXPERIMENTAL_I2CBUS
798
-#define I2C_SLAVE_ADDRESS  0 // Set non-zero to act as a slave
798
+#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
799
 
799
 
800
 #endif // CONFIGURATION_ADV_H
800
 #endif // CONFIGURATION_ADV_H

+ 5
- 0
Marlin/twibus.cpp View File

43
 }
43
 }
44
 
44
 
45
 void TWIBus::address(const uint8_t adr) {
45
 void TWIBus::address(const uint8_t adr) {
46
+  if (adr < 8 || adr > 127) {
47
+    SERIAL_ECHO_START;
48
+    SERIAL_ECHOLNPGM("Bad I2C address (8-127)");
49
+  }
50
+
46
   this->addr = adr;
51
   this->addr = adr;
47
 
52
 
48
   #if ENABLED(DEBUG_TWIBUS)
53
   #if ENABLED(DEBUG_TWIBUS)

Loading…
Cancel
Save