This is my first project that involves parallel programming so forgive me if I'm not using the proper terminology.
I want to interface a RaspberryPi 4 with a peripheral board using an SPI serial interface. In order to completely understand the serial communication I want to code the SPI communication without using an external library.
The purpose of the program is to send data to the peripheral and to read data from it, while plotting the recived data "in real time".
In order to easily manage the communication I need to run a thread that will generate the sclk and chip select signals, and another thread that will read/write data and plot them.
My question is: given that I will use a sclk frequency around 1MHz, is it a problem that I'm threading the functions instead of making them really parallel (using multiprocessing)?
I'd say that the clock frequency of the Rpi4 is much higher than the sclk frequency, so the time delay due to the "fake" parallelism is not a problem (considering the fact that all the threads are made of few instructions), but I want to know if there are other factors to consider. Thank you!
You absolutely do not want separate threads generating clock and data.  This is a SERIAL protocol, so those two things have to be synchronous.  The 1MHz number is just a maximum limit.  The clock doesn't have to be exact, nor does it have to be regular.  You, as the master, are in full control of that.  Everything is based on the transitions.  In this order, you set the output pin, assert the clock, read the input pin, deassert the clock, rinse and repeat.  One function, easy as pie. You might need to add some stalls if that process takes less than a microsecond.
RaspberryPi and peripheral SPI interface using python