JQIamo / AD536x-arduino

Arduino library for interfacing with Analog Devices AD5360 series DACs (AD5360, AD5361, AD5362, AD5363)
4 stars 2 forks source link

SPI.begin commented out #2

Open 3sigma opened 2 years ago

3sigma commented 2 years ago

Hello,

SPI.begin is inside the comment here:

https://github.com/JQIamo/AD536x-arduino/blob/973da6937a741e8c4176e5d58689b1e054edfa08/AD536x.cpp#L71

It should be outside, otherwise SPI communication doesn't start.

Thanks,

Nicolas

restelli commented 2 years ago

@3sigma thanks for signaling this bug. I think that the interface is based on the legacy SPI Aarduino library. The current library (https://www.arduino.cc/en/reference/SPI) uses the SPI.beginTransaction() and the SPI.endTransaction() methods and the SPISettings() type to reconfigure the SPI interface. The whole code must therefore be refactored to use the new updated interface. I believe that the author of the library @npisenti commented those lines because ultimately he usually initializes SPI somewhere else in the code. Being SPI an Arduino global class it should be possibile to do so. There was a note that was removed in this commit that was suggesting to uncomment the SPI.begin() line. I think that all depends on what SPI interface you are using and if you have initialized the SPI interface elsewhere.