Firmware project for STM32 microcontrollers developed with STM32CubeIDE. The code was written to be soft real time, the code here is non-blocking with use of interrupts and dma.
Core/
├── Inc/ # Shared header files
├── Src/ # Source code
│ ├── Controls/ # Actuators control
│ │ ├── end_eff_gpio.c
│ │ ├── nidec_h24.c
│ │ └── servo.c
│ ├── Encapsulation/ # For better modularity
│ │ ├── loops.c
│ │ └── setup.c
│ ├── Exceptions/ # Software exception handling
│ │ └── sw_exceptions.c
│ ├── Periphs/ # Hardware peripheral drivers
│ │ ├── encoder.c
│ │ ├── led.c
│ │ └── icm20948.c
│ ├── Processing/ # Application logic and algorithms
│ │ ├── pid.c
│ │ ├── sw_crc.c
│ │ └── uart_processing.c
│ └── main.c # Application entry point
└── Startup/ # Startup code generated by STM32CubeIDE
- IDE: STM32CubeIDE (latest version recommended)
- Toolchain: GCC for ARM Embedded
- Debugger: ST-Link (v2 or v3)
- Target board: STM32 NUCLEO F446RE
- Operative System: Bare metal
- Open STM32CubeIDE
- Go to
File > Import > Existing Projects into Workspace - Select the cloned project folder and then Stm32Code
- Click
Finish
- Connect your STM32 board to the PC via USB
- Select the debug configuration
- Press
RunorDebugto flash the firmware
Contains the main() function and main system initialization.
In the while (1) there is code that is interrupt driven without the stringent need to be inside the timers.
end_eff_gpio.c: GPIO control for end-effector actuators.nidec_h24.c: Brushless motor control for NIDEC H24.servo.c: Servo Motor Control.
loops.c: File that contains the functions in control or check loops.setup.c: File that contains all the setup functions required by the code.
sw_exceptions.c: Handling of custom software exceptions
encoder.c: Library for encoder reading.led.c: LED control.icm20948.c: Library for icm20948 IMU sensor (and ak09916) via I2C.
pid.c: PID control algorithm implementation.sw_crc.c: Software CRC calculation (for packet verification).uart_processing.c: UART command parsing and handling.
The image below shows a flow chart representing the main logic implemented in the STM32 firmware code.
To calibrate the icm20948, click here.
You can check out the pinout configuration at this link.
If you are interested in learning more, you can find detailed explanations in the code itself and in the full project report!
Shunko_Bot © 2025 by Francesco Stasi, Davide Tonti, Simona Vatinno is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
For issues or requests, please open a GitHub issue.
