Save yourself the headache and use full duplex mode instead.
But if you really want to, here is an example:
https://github.com/STMicroelectronics/STM32CubeF1/blob/f5aaa9b45492d70585ade1dac4d1e33d5531c171/Projects/STM32F103RB-Nucleo/Examples_MIX/SPI/SPI_HalfDuplex_ComPollingIT/Src/main.c
If you feel a post has answered your question, please click "Accept as Solution".