This project provides bare-metal peripheral drivers for STM32F4xx microcontrollers, implemented from scratch without using HAL or CMSIS. The goal is to develop a deeper understanding of low-level embedded programming by directly interacting with hardware registers. This project includes both polling-based and interrupt-based implementations for all peripheral drivers, ensuring efficient and responsive communication. Future plans include implementing DMA-based data transfer for enhanced performance.
✔️ GPIO (General Purpose Input/Output) Driver with Polling and Interrupt Support
✔️ I2C (Inter-Integrated Circuit) Driver with Polling and Interrupt Support
✔️ SPI (Serial Peripheral Interface) Driver with Polling and Interrupt Support
✔️ Bare-metal register-level programming (No HAL, No CMSIS)
✔️ Structured, modular, and reusable driver architecture
✔️ Upcoming: DMA-based data transfer for optimized performance
EmbeddedPeripheralDrivers_STM32/
│
├── Src/ # Source files
│ ├── main.c # Application code
│ ├── gpio_driver.c # GPIO driver implementation
│ ├── i2c_driver.c # I2C driver implementation
│ ├── spi_driver.c # SPI driver implementation
│
├── Inc/ # Header files
│ ├── gpio_driver.h
│ ├── i2c_driver.h
│ ├── spi_driver.h
│
├── Startup/ # Startup assembly file
│ └── startup_stm32f407xx.s
│
├── Linker/ # Linker scripts
│ ├── STM32F407VGTX_FLASH.ld
│ ├── STM32F407VGTX_RAM.ld
│
├── .gitignore
├── README.md # Project documentation
└── LICENSE # Project license
- ✅ Hardware: STM32F4 Discovery Board or equivalent
- ✅ Toolchain: ARM GCC Compiler, STM32CubeIDE, or Keil uVision
- ✅ Debugger: ST-Link V2 / Onboard Debugger
- Clone the Repository
git clone https://github.com/bobburudinesh/EmbeddedPeripheralDrivers_STM32.git
- Open the project in STM32CubeIDE / Keil / Any ARM Compiler
- Build the project
- Flash the binary to STM32F4 using ST-Link
- Verify the peripheral functionality
- Configures pin modes, speed, and pull-up/pull-down resistors.
- Example usage:
GPIO_InitTypeDef gpio; gpio.pin = GPIO_PIN_13; gpio.mode = GPIO_MODE_OUTPUT; gpio.speed = GPIO_SPEED_LOW; GPIO_Init(GPIOC, &gpio); GPIO_TogglePin(GPIOC, GPIO_PIN_13);
- Implements I2C communication using register-level programming.
- Example usage:
uint8_t data = 0xAA; I2C_MasterTransmit(&i2c, EEPROM_ADDRESS, &data, 1);
- Supports master/slave communication, full-duplex data transmission.
- Example usage:
uint8_t tx_data = 0x55, rx_data; SPI_Transmit(&spi, &tx_data, 1); SPI_Receive(&spi, &rx_data, 1);
This project includes a basic GPIO LED blink example using the custom GPIO driver.
#include "gpio_driver.h"
int main(void) {
GPIO_InitTypeDef gpio;
gpio.pin = GPIO_PIN_13;
gpio.mode = GPIO_MODE_OUTPUT;
GPIO_Init(GPIOC, &gpio);
while (1) {
GPIO_TogglePin(GPIOC, GPIO_PIN_13);
for (volatile int i = 0; i < 100000; i++); // Delay
}
}
🚀 Adding DMA-based peripheral communication for optimized performance
🚀 Adding UART Driver
🚀 Adding PWM Driver
Contributions are welcome! To contribute:
- Fork the repository
- Create a new feature branch
- Commit and push your changes
- Open a pull request
This project is licensed under the MIT License – see the LICENSE file for details.