I'm using this b-g431b-esc1 discovery kit to drive and control an electric BLDC motor with hallsensors. It uses SimpleFOC in closed loop voltage mode.
This is the code that accompanies my 3hr code/build video. It's not identical, it has more debug code and some motor calibration to help with different motors:
Please note that this board at time of writing needs a couple of Pull Requests to be approved to be 'easy' to use from platformio and Arduino IDE:
stm32duino/Arduino_Core_STM32#1236 - this will add the board to the stm32duino board manager list. If you have added stm32duino as a board manager and this PR has been approved you should see it in the list of boards within Arduino
platformio/platform-ststm32#447 - this adds extra info required by platformio to find use the board.
Of lesser importance - I managed to get breakpoint debugging to work for stm32g4 boards like this one, again this needs another PR to be approved before it becomes easy from platformio: https://sourceforge.net/p/openocd/code/merge-requests/16/
The stm32 user manual for this board is excellent: https://www.st.com/resource/en/user_manual/dm00564746-electronic-speed-controller-discovery-kit-for-drones-with-stm32g431cb-stmicroelectronics.pdf