From 0c24e0e44524686d2c12efe8d1f17e61fae48075 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 27 Jun 2016 12:51:50 -0700 Subject: [PATCH] Support for newer Wire library --- Marlin/dac_mcp4728.cpp | 22 +++++++++++----------- Marlin/dac_mcp4728.h | 2 -- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Marlin/dac_mcp4728.cpp b/Marlin/dac_mcp4728.cpp index 3060e6e18..01e38edf8 100644 --- a/Marlin/dac_mcp4728.cpp +++ b/Marlin/dac_mcp4728.cpp @@ -43,9 +43,9 @@ void mcp4728_init() { Wire.begin(); Wire.requestFrom(int(DAC_DEV_ADDRESS), 24); while(Wire.available()) { - int deviceID = Wire.receive(); - int hiByte = Wire.receive(); - int loByte = Wire.receive(); + int deviceID = Wire.read(); + int hiByte = Wire.read(); + int loByte = Wire.read(); int isEEPROM = (deviceID & 0B00001000) >> 3; int channel = (deviceID & 0B00110000) >> 4; @@ -70,10 +70,10 @@ uint8_t mcp4728_analogWrite(uint8_t channel, uint16_t value) { */ uint8_t mcp4728_eepromWrite() { Wire.beginTransmission(DAC_DEV_ADDRESS); - Wire.send(SEQWRITE); + Wire.write(SEQWRITE); for (uint8_t channel=0; channel <= 3; channel++) { - Wire.send(DAC_STEPPER_VREF << 7 | 0 << 5 | DAC_STEPPER_GAIN << 4 | highByte(mcp4728_values[channel])); - Wire.send(lowByte(mcp4728_values[channel])); + Wire.write(DAC_STEPPER_VREF << 7 | 0 << 5 | DAC_STEPPER_GAIN << 4 | highByte(mcp4728_values[channel])); + Wire.write(lowByte(mcp4728_values[channel])); } return Wire.endTransmission(); } @@ -83,7 +83,7 @@ uint8_t mcp4728_eepromWrite() { */ uint8_t mcp4728_setVref_all(uint8_t value) { Wire.beginTransmission(DAC_DEV_ADDRESS); - Wire.send(VREFWRITE | value << 3 | value << 2 | value << 1 | value); + Wire.write(VREFWRITE | value << 3 | value << 2 | value << 1 | value); return Wire.endTransmission(); } /** @@ -91,7 +91,7 @@ uint8_t mcp4728_setVref_all(uint8_t value) { */ uint8_t mcp4728_setGain_all(uint8_t value) { Wire.beginTransmission(DAC_DEV_ADDRESS); - Wire.send(GAINWRITE | value << 3 | value << 2 | value << 1 | value); + Wire.write(GAINWRITE | value << 3 | value << 2 | value << 1 | value); return Wire.endTransmission(); } @@ -120,8 +120,8 @@ uint16_t mcp4728_getVout(uint8_t channel) { uint8_t mcp4728_fastWrite() { Wire.beginTransmission(DAC_DEV_ADDRESS); for (uint8_t channel=0; channel <= 3; channel++) { - Wire.send(highByte(mcp4728_values[channel])); - Wire.send(lowByte(mcp4728_values[channel])); + Wire.write(highByte(mcp4728_values[channel])); + Wire.write(lowByte(mcp4728_values[channel])); } return Wire.endTransmission(); } @@ -131,7 +131,7 @@ uint8_t mcp4728_fastWrite() { */ uint8_t mcp4728_simpleCommand(byte simpleCommand) { Wire.beginTransmission(GENERALCALL); - Wire.send(simpleCommand); + Wire.write(simpleCommand); return Wire.endTransmission(); } diff --git a/Marlin/dac_mcp4728.h b/Marlin/dac_mcp4728.h index 1f659bf88..18d22f21f 100644 --- a/Marlin/dac_mcp4728.h +++ b/Marlin/dac_mcp4728.h @@ -31,9 +31,7 @@ #include "Configuration_adv.h" #if ENABLED(DAC_STEPPER_CURRENT) -#include "WProgram.h" #include "Wire.h" -//#include #define defaultVDD 5000 #define BASE_ADDR 0x60