Merge pull request #473 from xxxajk/master

Fix corruption. NEVER use SPI method transfer on a pointer.
This commit is contained in:
Kristian Sloth Lauszus 2019-08-05 18:09:39 +02:00 committed by GitHub
commit 821e37ed18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -228,21 +228,15 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t*
spi4teensy3::send(reg | 0x02); spi4teensy3::send(reg | 0x02);
spi4teensy3::send(data_p, nbytes); spi4teensy3::send(data_p, nbytes);
data_p += nbytes; data_p += nbytes;
#elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266) && !defined(ESP32)
USB_SPI.transfer(reg | 0x02);
USB_SPI.transfer(data_p, nbytes);
data_p += nbytes;
#elif defined(__ARDUINO_X86__)
USB_SPI.transfer(reg | 0x02);
USB_SPI.transferBuffer(data_p, NULL, nbytes);
data_p += nbytes;
#elif defined(STM32F4) #elif defined(STM32F4)
uint8_t data = reg | 0x02; uint8_t data = reg | 0x02;
HAL_SPI_Transmit(&SPI_Handle, &data, 1, HAL_MAX_DELAY); HAL_SPI_Transmit(&SPI_Handle, &data, 1, HAL_MAX_DELAY);
HAL_SPI_Transmit(&SPI_Handle, data_p, nbytes, HAL_MAX_DELAY); HAL_SPI_Transmit(&SPI_Handle, data_p, nbytes, HAL_MAX_DELAY);
data_p += nbytes; data_p += nbytes;
#elif !defined(SPDR) // ESP8266, ESP32 #elif !defined(__AVR__) || !defined(SPDR)
#if defined(ESP8266) || defined(ESP32)
yield(); yield();
#endif
USB_SPI.transfer(reg | 0x02); USB_SPI.transfer(reg | 0x02);
while(nbytes) { while(nbytes) {
USB_SPI.transfer(*data_p); USB_SPI.transfer(*data_p);