easier way to program on STM32 in C++
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);
}
}
git clone https://github.com/Neutree/STM32f103DriverLib.git
example
folder with MDK5, compile and download to your board and runMain.cpp
,Configuration.h
,UserInterrupt.cpp
, code your code and config configuration.Configuration.h
select UTF-8 without signature before you start code
keil->edit->configuration->editor->encoding
lib
driver 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/driverName
example related to stm32
example/offchip/driverName
module example not belong to stm32
template
project template
tool
: tools
Refer Here
Danyuanhong