waalsh
September 25, 2022, 10:33am
1
Dear All,
I am trying to read an SD card using an ESP32 but get an error message from the SPI library. Also when I try the example program from the SPI library I get the same error. I hope someone can help me.
below the error code i get while compiling:
I get this error both in the Arduino IDE (1.8.13) and with Visual Studio
I used this library: GitHub - espressif/arduino-esp32: Arduino core for the ESP32
Error code:
Compiling 'SD_Test' for 'ESP32 Dev Module'
SPI.cpp: In member function void SPIClass::transferBytes(const uint8_t*, uint8_t*, uint32_t)
SPI.cpp: 297:43: error: invalid conversion from 'const uint8_t* {aka const unsigned char*}' to 'uint8_t* {aka unsigned char*}' [-fpermissive]
spiTransferBytes(_spi, data, out, size)
Error compiling libraries
Build failed for project 'SD_Test'
SPI.h:26: In file included from
SPI.cpp:22: from
esp32-hal-spi.h:108: note initializing argument 2 of void spiTransferBytes(spi_t*, uint8_t*, uint8_t*, uint32_t)
void spiTransferBytes(spi_t * spi, uint8_t * data, uint8_t * out, uint32_t size)
I hope you can help me out!
Thanks in advance,
Hugo
There is very little chance of being able to provide help unless you post the code that produced the errors
Help you out without being able to view the code, not happening.
Oh, CODE TAGS.
Here is how I tranfer data using the ESP32's SPI API:
///////////////////////////////////////////////////////////////
int fReadSPIdata16bits( spi_device_handle_t &h, int _address )
{
uint8_t address = _address;
esp_err_t intError = 0;
low=0; high=0;
spi_transaction_t trans_desc;
trans_desc = { };
trans_desc.addr = 0;
trans_desc.cmd = 0;
trans_desc.flags = 0;
trans_desc.length = (8 * 3); // total data bits
trans_desc.tx_buffer = txData;
trans_desc.rxlength = 8 * 2 ; // Number of bits NOT number of bytes
trans_desc.rx_buffer = rxData;
txData[0] = address | 0x80;
intError = spi_device_transmit( h, &trans_desc);
low = rxData[0]; high = rxData[1];
return intError;
} // void fSendSPI( uint8_t count, uint8_t address, uint8_t DataT
int fWriteSPIdata8bits( spi_device_handle_t &h, int _address, int _sendData )
{
uint8_t address = _address;
uint8_t sendData = _sendData;
esp_err_t intError;
spi_transaction_t trans_desc;
trans_desc = { };
trans_desc.addr = 0;
trans_desc.cmd = 0;
trans_desc.flags = 0;
trans_desc.length = (8 * 2); // total data bits
trans_desc.tx_buffer = txData;
trans_desc.rxlength = 0 ; // Number of bits NOT number of bytes
trans_desc.rx_buffer = NULL;
txData[0] = address & 0x7F;
txData[1] = sendData;
intError = spi_device_transmit( h, &trans_desc);
return intError;
} // void fWriteSPIdata8bits( spi_device_handle_t &h, uint8_t address, uint8_t sendData )
//
waalsh
September 25, 2022, 2:51pm
4
This is the code
SD_Test.ino (5.4 KB)
waalsh
September 25, 2022, 3:33pm
5
This is the code
SD_Test.ino (5.4 KB)
Why not post it here in a reply, using code tags when you do ?
system
Closed
March 24, 2023, 3:59pm
8
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.