sparkfun / SparkFun_ADXL345_Arduino_Library

Arduino Library for the ADXL345
46 stars 52 forks source link

SPI.setDataMode() deprecated #7

Open SDAMcIntyre opened 7 years ago

SDAMcIntyre commented 7 years ago

I was wondering if it would be valuable to update some of the SPI code. I'm referring to lines 49-52 in "SparkFun_ADXL345.cpp":

SPI.begin();
SPI.setDataMode(SPI_MODE3);
pinMode(_CS, OUTPUT);
digitalWrite(_CS, HIGH);

It seems that SPI.setDataMode() is deprecated (https://www.arduino.cc/en/Reference/SPISetDataMode) and that SPISettings(), SPI.beginTransaction() and SPI.endTransaction() should be used in the writeToSPI() and readFromSPI() functions.

Also, is it necessary to pull CS/SS high, since SPI.begin() says it does this already? https://www.arduino.cc/en/Reference/SPIBegin