Page 1 of 1

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

Posted: Tue Jan 10, 2017 7:57 pm
by kolban
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.

Re: SPI: Use of the queue_size property in spi_device_interface_config_t

Posted: Wed Jan 11, 2017 1:41 am
by ESP_Sprite
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!