[Answered] SPI: Use of the queue_size property in spi_device_interface_config_t

User avatar
Posts: 958
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

[Answered] SPI: Use of the queue_size property in spi_device_interface_config_t

Postby kolban » Tue Jan 10, 2017 7:57 pm

When using the SPI master driver, I need to call spi_bus_add_device()
http://esp-idf.readthedocs.io/en/latest ... e_handle_t

Which takes as input a struct spi_device_interface_config_t
http://esp-idf.readthedocs.io/en/latest ... e_config_t

which has a property called queue_size
http://esp-idf.readthedocs.io/en/latest ... ueue_sizeE

My question is ... what is a "good" value for queue_size? How does one size correctly? What are the "units of queue_size"? (transactions, data bytes, individual requests etc etc?).

I had assumed that if I was going to use spi_device_transmit() that I wouldn't need a queue so tried to specify 0 but that asserted immediately.
Last edited by kolban on Wed Jan 11, 2017 2:13 am, edited 1 time in total.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Posts: 1033
Joined: Thu Nov 26, 2015 4:08 am

Re: SPI: Use of the queue_size property in spi_device_interface_config_t

Postby ESP_Sprite » Wed Jan 11, 2017 1:41 am

Hum, I thought I documented that somewhere... The queue size is the amount of transactions that can be 'in the air' at the same time. If all you do is spi_device_queue_trans followed immediately by spi_device_get_trans_result (or use the equivalent spi_device_transmit function) you only need a queue_size of 1 because there's only going to be one transaction 'in the air' at the time. If you 'kick off' multiple (say x) transactions using spi_device_queue_trans at the time, and only later get the result of all of them using spi_device_get_trans_result, you will need the queue to be large enough to hold all these transactions; queue_size should then be equal to or bigger than x.

I'll see if I can amend the documentation, I agree that as is this is pretty unclear. Thanks for spotting it!

Who is online

Users browsing this forum: gatisp, MartyMacGyver and 6 guests