void SPIClass::setDataMode(uint8_t dataMode) {
/**
SPI_MODE0 0x00 - CPOL: 0 CPHA: 0
SPI_MODE1 0x01 - CPOL: 0 CPHA: 1
SPI_MODE2 0x10 - CPOL: 1 CPHA: 0
SPI_MODE3 0x11 - CPOL: 1 CPHA: 1
*/
bool CPOL = (dataMode & 0x10); ///< CPOL (Clock Polarity)
bool CPHA = (dataMode & 0x01); ///< CPHA (Clock Phase)
if(CPHA) {
SPI1U |= (SPIUSME);
} else {
SPI1U &= ~(SPIUSME);
}
if(CPOL) {
SPI1P |= 1<<29;
} else {
SPI1P &= ~(1<<29);
//todo test whether it is correct to set CPOL like this.
}
}
Also see https://github.com/reiyawea/Arduino/blo ... /SPI/SPI.h for all the SPI Classes and functions you can call, there is SPISettings which can set the mode and freq.
RichardS
https://epartsconnect.com
Live realtime stock market prediction website. https://www.stocksignalslive.com my latest creation. Uses AI and machine learning.
New site featuring ESP8266 and ESP32 projects. tutorials, and news.
http://EverythingESP.com
ESP8266.com Founder and Administrator
The Mind Factory (get more from your 3D printer)
Home of the ESP8266, ESP8285, and ESP32 microcontrollers....