Do not use SPI.writeBytes on the ESP8266

This commit is contained in:
Kristian Sloth Lauszus 2017-06-13 12:40:07 +02:00
parent 453a4e1f7f
commit 84bab2d748

View file

@ -176,24 +176,17 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
c[0] = reg | 0x02; c[0] = reg | 0x02;
c[1] = data; c[1] = data;
spi4teensy3::send(c, 2); spi4teensy3::send(c, 2);
#elif defined(SPI_HAS_TRANSACTION) #elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266)
#ifdef ESP8266
uint32_t c[2]; // The data needs to be aligned to 32-bit
c[0] = reg | 0x02;
c[1] = data;
SPI.writeBytes((uint8_t*)c, 2);
#else
uint8_t c[2]; uint8_t c[2];
c[0] = reg | 0x02; c[0] = reg | 0x02;
c[1] = data; c[1] = data;
SPI.transfer(c, 2); SPI.transfer(c, 2);
#endif
#elif defined(STM32F4) #elif defined(STM32F4)
uint8_t c[2]; uint8_t c[2];
c[0] = reg | 0x02; c[0] = reg | 0x02;
c[1] = data; c[1] = data;
HAL_SPI_Transmit(&SPI_Handle, c, 2, HAL_MAX_DELAY); HAL_SPI_Transmit(&SPI_Handle, c, 2, HAL_MAX_DELAY);
#elif !defined(SPDR) #elif !defined(SPDR) // ESP8266
SPI.transfer(reg | 0x02); SPI.transfer(reg | 0x02);
SPI.transfer(data); SPI.transfer(data);
#else #else