STM32f103DriverLib

easier way to program on STM32 in C++

Stars
48

STM32f103 Peripherals Driver Lib

To make program on STM32 more easier, we packet every peripheral and module as a C++ class, mask operation steps instead of function-oriented interface.

e.g. How to use USART to send data

# include "USART.h"
USART com(1,115200);
void main()
{
    com<<"test string\r\n";
}

e.g. Use temperature and humidity sensor

#include "I2C.h"
#include "Si7021.h"
#include "USART.h"
#include "TaskManager.h"

USART log(1,115200);
I2C i2c1(1);
Si7021 tempHumi;

int main()
{
  tempHumi.Init(&i2c1);
  while(1)
  {
    tempHumi.Update();

    log<<"temperature:"<<tempHumi.GetTemperature()<<"\n";
    log<<"humidity:"<<tempHumi.GetHumidity()<<"\n";

    TaskManager::DelayMs(100);
  }
}

How to use

  1. Install keil MDK 5 on windows
  2. clone or download this project to your PC
git clone https://github.com/Neutree/STM32f103DriverLib.git
  1. open example project in example folder with MDK5, compile and download to your board and run
  2. There's three files you should pay attention: Main.cpp,Configuration.h,UserInterrupt.cpp, code your code and config configuration.
  • Uncomment what you need in Configuration.h
  • And every one driver have one folder, you should see the header file before you start code, there's some attention and doc in the header file.

Convention

File encode format

select UTF-8 without signature before you start code

keil->edit->configuration->editor->encoding

Folders

libdriver lib

lib/math/: math lib

lib/onchip/: driver releated to stm32

lib/onchip/driverName: driver source code folder

lib/offchip/: module driver not belong to stm32

lib/offchip/driverName: driver source code folder

example: driver demo

example/onchip/driverNameexample related to stm32

example/offchip/driverNamemodule example not belong to stm32

templateproject template

tool: tools

Driver Brief

On chip

  • Interrupt
  • GPIOIOIO
  • USART14DMAFIFO
  • ADCADC
  • I2CI2CDMA
  • PWMPWM
  • Timer
  • TaskManagersystick
  • Capture
  • FlashSTM32FlashFlash
  • CAN
  • SPI
  • IWDG

Module Driver

  • LEDGPIOPWMLED
  • esp8266esp8266WIFIUSARTesp8266esp8266.cpp(SockeEsp8266.cpp),socket
  • GPSUSARTGPS
  • HMC5883LI2CHMC5883L
  • StepMotorGPIO
  • MPU60506
  • RemoteControl:RCPWMPPM
  • Ultrasonic systick
  • HMI
  • Si7021: Temperature and humidity sensor
  • PN53x: RFID/NFC reader
  • Relay
  • SPI Flash
  • Ethernet: W5500 ethernet communication
  • GNSS: GNSS NMEA parser (GPS)
  • ZPH01
  • SHARP_1014_PM2.5
  • MFRC522
  • MG996R
  • MZH14
  • yishan_PM2.5
  • Door: Reed Switch
  • HCHO
  • Joystick

Code Style

Refer Here

Contributors

AllenWang

Danyuanhong

infiniteYuan

lissettecarlr

neucrack

xz1996