The master-slave communication example form here https://github.com/espressif/esp-idf/tr ... /spi_slave is wonderful. It does exactly what it should.
However, I would like to use this example with
Code: Select all
spi_device_queue_trans
Code: Select all
esp_err_tspi_device_get_trans_result
Code: Select all
static void SPI_TX (void *arg){
spi_transaction_t t;
memset(&t, 0, sizeof(t));
t.length=SPI_BUF_SIZE_SMALL*8;
t.tx_buffer=spi_tx_buf;
t.rx_buffer=NULL;
while(1){
memset(&spi_tx_buf,0x78,sizeof(spi_tx_buf));
xSemaphoreTake(rdySem, portMAX_DELAY); //Wait until slave is ready - handshake
t1.tx_buffer = spi_tx_buf;
esp_err_t ret = spi_device_queue_trans(handle, &t, portMAX_DELAY);
if(ret!=ESP_OK){
ESP_LOGW(SPI_TAG,"error master queue %d",ret);
}
}
}
Code: Select all
static void SPI_RX (void *arg){
spi_transaction_t t;
memset(&t, 0, sizeof(t));
t.length=SPI_BUF_SIZE_SMALL*8;
t.tx_buffer=NULL;
t.rx_buffer=spi_rx_buf;
while(1){
esp_err_t ret = spi_device_get_trans_result(handle, &t, portMAX_DELAY);
if(ret!=ESP_OK){
ESP_LOGW(SPI_TAG,"error master queue");
}
for(int i=0;i<SPI_BUF_SIZE_SMALL;i++){
printf("%d",spi_rx_buf[i]);
}
taskYIELD();
}
}
Code: Select all
spi_device_queue_trans
Code: Select all
xSemaphoreTake(rdySem, portMAX_DELAY);
Most likely I didn't understand the functions well enough. Could someone enlighten me?
I don't get any error messages, I just reveive garbage from the SPI_RX function.