SPI Transmit from Firmware

G’day!

I’m working on some code that has to be implemented within the firmware - a custom function that is running correctly, and determines the x and y position of an object in frame. I need to transmit that position to another microcontroller, and I’m going to use SPI, but I’m having issues working out how to do this (using SPI2 on OPENMV H7). I’d rather not pass the data back to the top level and then transmit it via the python code, I’d like to have it hard coded in the function itself as speed is a critical factor (and in all honesty, I haven’t yet worked out how to pass data from the firmware back to the top level python for use in the IDE).
Primarily, I’m having trouble determining what I should be using for the SPI_HandleTypeDef *hspi shown below - or if this is even the correct way to go about it - should I be using a different SPI transmit function?

HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout)

Any assistance is greatly appreciated. Thanks!

Um, have you looked at SPI.c in the MicroPython src?

Check the STM32 port. Just follow how they do things in the code to get it working.

I just realised (a cookie of months later…) that I didn’t post my solution (in case anyone else is having the same problem).

I am able to transmit over SPI (SPI2) from within a custom function in the firmware. It was simply a matter of finding the SPI_HandleTypeDef within the STM32 port (like Kwagyeman posted above), and then doing Rebuild All.

HAL_SPI_Transmit(&SPIHandle2, (uint8_t*)pos, sizeof(pos), 10);

SPIHandle2 did the trick. I’m used to using &hspi2 whenever I use STM32.

Thanks again!