Kaynağa Gözat

Support for newer Wire library

Scott Lahteine 8 yıl önce
ebeveyn
işleme
0c24e0e445
2 değiştirilmiş dosya ile 11 ekleme ve 13 silme
  1. 11
    11
      Marlin/dac_mcp4728.cpp
  2. 0
    2
      Marlin/dac_mcp4728.h

+ 11
- 11
Marlin/dac_mcp4728.cpp Dosyayı Görüntüle

@@ -43,9 +43,9 @@ void mcp4728_init() {
43 43
   Wire.begin();
44 44
   Wire.requestFrom(int(DAC_DEV_ADDRESS), 24);
45 45
   while(Wire.available()) {
46
-    int deviceID = Wire.receive();
47
-    int hiByte = Wire.receive();
48
-    int loByte = Wire.receive();
46
+    int deviceID = Wire.read();
47
+    int hiByte = Wire.read();
48
+    int loByte = Wire.read();
49 49
 
50 50
     int isEEPROM = (deviceID & 0B00001000) >> 3;
51 51
     int channel = (deviceID & 0B00110000) >> 4;
@@ -70,10 +70,10 @@ uint8_t mcp4728_analogWrite(uint8_t channel, uint16_t value) {
70 70
  */
71 71
 uint8_t mcp4728_eepromWrite() {
72 72
   Wire.beginTransmission(DAC_DEV_ADDRESS);
73
-  Wire.send(SEQWRITE);
73
+  Wire.write(SEQWRITE);
74 74
   for (uint8_t channel=0; channel <= 3; channel++) {
75
-    Wire.send(DAC_STEPPER_VREF << 7 | 0 << 5 | DAC_STEPPER_GAIN << 4 | highByte(mcp4728_values[channel]));
76
-    Wire.send(lowByte(mcp4728_values[channel]));
75
+    Wire.write(DAC_STEPPER_VREF << 7 | 0 << 5 | DAC_STEPPER_GAIN << 4 | highByte(mcp4728_values[channel]));
76
+    Wire.write(lowByte(mcp4728_values[channel]));
77 77
   }
78 78
   return Wire.endTransmission();
79 79
 }
@@ -83,7 +83,7 @@ uint8_t mcp4728_eepromWrite() {
83 83
  */
84 84
 uint8_t mcp4728_setVref_all(uint8_t value) {
85 85
   Wire.beginTransmission(DAC_DEV_ADDRESS);
86
-  Wire.send(VREFWRITE | value << 3 | value << 2 | value << 1 | value);
86
+  Wire.write(VREFWRITE | value << 3 | value << 2 | value << 1 | value);
87 87
   return Wire.endTransmission();
88 88
 }
89 89
 /**
@@ -91,7 +91,7 @@ uint8_t mcp4728_setVref_all(uint8_t value) {
91 91
  */
92 92
 uint8_t mcp4728_setGain_all(uint8_t value) {
93 93
   Wire.beginTransmission(DAC_DEV_ADDRESS);
94
-  Wire.send(GAINWRITE | value << 3 | value << 2 | value << 1 | value);
94
+  Wire.write(GAINWRITE | value << 3 | value << 2 | value << 1 | value);
95 95
   return Wire.endTransmission();
96 96
 }
97 97
 
@@ -120,8 +120,8 @@ uint16_t mcp4728_getVout(uint8_t channel) {
120 120
 uint8_t mcp4728_fastWrite() {
121 121
   Wire.beginTransmission(DAC_DEV_ADDRESS);
122 122
   for (uint8_t channel=0; channel <= 3; channel++) {
123
-    Wire.send(highByte(mcp4728_values[channel]));
124
-    Wire.send(lowByte(mcp4728_values[channel]));
123
+    Wire.write(highByte(mcp4728_values[channel]));
124
+    Wire.write(lowByte(mcp4728_values[channel]));
125 125
   }
126 126
   return Wire.endTransmission();
127 127
 }
@@ -131,7 +131,7 @@ uint8_t mcp4728_fastWrite() {
131 131
  */
132 132
 uint8_t mcp4728_simpleCommand(byte simpleCommand) {
133 133
   Wire.beginTransmission(GENERALCALL);
134
-  Wire.send(simpleCommand);
134
+  Wire.write(simpleCommand);
135 135
   return Wire.endTransmission();
136 136
 }
137 137
 

+ 0
- 2
Marlin/dac_mcp4728.h Dosyayı Görüntüle

@@ -31,9 +31,7 @@
31 31
 #include "Configuration_adv.h"
32 32
 
33 33
 #if ENABLED(DAC_STEPPER_CURRENT)
34
-#include "WProgram.h"
35 34
 #include "Wire.h"
36
-//#include <Wire.h>
37 35
 
38 36
 #define defaultVDD 5000
39 37
 #define BASE_ADDR 0x60

Loading…
İptal
Kaydet