For example:
Code: Select all
{
......
const char *hello = "Hello, world!";
chip_cs_low(); // pulldown cs pin
SPI.transferBytes((uint8_t *) hello, 0, strlen(hello)); // write "hello world!"
chip_cs_high(); // pullup cs pin
......
}
// "Hello, world!" may only be transmitted by "Hello".
Code: Select all
On arduino\hardware\espressif\esp32\cores\esp32\esp32-hal-spi.c
void spiTransferBytes(spi_t * spi, uint8_t * data, uint8_t * out, uint32_t size)
{
if(!spi) {
return;
}
SPI_MUTEX_LOCK();
while(size) {
if(size > 64) {
__spiTransferBytes(spi, data, out, 64);
size -= 64;
if(data) {
data += 64;
}
if(out) {
out += 64;
}
} else {
__spiTransferBytes(spi, data, out, size);
size = 0;
+ if (!out) {
+ while(spi->dev->cmd.usr);
+ }
}
}
SPI_MUTEX_UNLOCK();
}