SPI Transmit from Firmware

Discussion related to "under the hood" OpenMV topics.
Rossco
Posts: 2
Joined: Mon May 20, 2019 1:14 am

SPI Transmit from Firmware

Postby Rossco » Thu Jul 25, 2019 1:17 am

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?

Code: Select all

HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout)
Any assistance is greatly appreciated. Thanks!
User avatar
kwagyeman
Posts: 3829
Joined: Sun May 24, 2015 2:10 pm

Re: SPI Transmit from Firmware

Postby kwagyeman » Thu Jul 25, 2019 2:32 am

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.
Nyamekye,
Rossco
Posts: 2
Joined: Mon May 20, 2019 1:14 am

Re: SPI Transmit from Firmware

Postby Rossco » Mon Oct 14, 2019 10:25 pm

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.

Code: Select 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!

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests