How Can I Run Parallel Scripts with the Promira Serial Platform To Toggle GPIO During SPI Writes?

Question from the Customer:

I am using the Promira Serial Platform with Promira Software API I2C/SPI Active. I’m looking to create a script (in Python) so that the SPI and GPIO commands occur in parallel; the GPIO toggles during SPI writes. Here is a summary of what I’m looking to do:


start gpio toggle;
submit spi write queue;
stop gpio toggling;

How can I make that work?

Response from Technical Support:
Thanks for your question! You can toggle GPIOs in parallel while the SPI lines are toggling by using separate queues to execute GPIO and SPI commands.

How to Create Separate Queues (Multiple Threads)

To create a separate queue for GPIO:

gpio_queue = ps_queue_create(conn, PS_MODULE_ID_GPIO);


To create a separate queue for SPI:

spi_queue = ps_queue_create(conn, PS_MODULE_ID_SPI_ACTIVE);

Here is a summary of what you could do:

The queue handles gpio_queue and spi_queue can be used to send commands in each queue.

For SPI and GPIO queue operations to perform simultaneously:

  • Create a routine to queue GPIO toggling functions in a GPIO queue
  • Call that routine by submitting the queue in a separate thread before spi_write starts.
  • Once the SPI write operation is complete, you can stop the thread execution and destroy GPIO queue with the API command ps_queue_destroy.

For more information about queuing and related commands, please refer to the Queue Overview and API Documentation sections in the Promira Serial Platform I2C/SPI Active User Manual. Also, functional API programs are provided with Promira Software API I2C/SPI Active, which can be used as is or modified as needed. For the operations you need, we suggest looking at and modifying the commands for your specifications.

We hope this answers your question. Additional resources that you may find helpful include the following:

We hope this answers your question. Need more information? You can contact us at, as well as request a demo that applies to your application, as well as ask questions about our Total Phase products.

Request a Demo