This is pretty old and was made when I was just getting into embedded programming. Hopefully it'll be useful as a demonstration, but I have no doubt it could be seriously optimized and written better.
This is a Sonar based on the STM32 microcontroller. It uses the following parts:
- STM32F428I-DISC1 Devboard
- HC-SR04 ultrasonic sensor
- Generic mini-servo motor
Two hardware timers of the STM32 are implemented, one for measuring the ECHO of the ultrasonic sensor, one for generating the PWM to drive the servo. One GPIO pin is implemented to send the trigger signal to the ultrasonic sensor. In software, FreeRTOS is used for multi-threading.
The following is a list which shows files that could be of interest to you if you are inspecting the source code. Most of the code in the repository is pre-generated by TouchGFX/STM32 software, so this is a quick glossary of the files where I've actually written code.
- core/src/main.c
- STM32CubeIDE/Application/User/hcsr04.c (and the corresponding .h file in core/src/inc)
- STM32CubeIDE/Application/User/PWM.c (and the corresponding .h file in core/src/inc)
- TouchGFX/gui/src/home_screen/homeView.cpp