Giter VIP home page Giter VIP logo

arduino-for-keil's Introduction

Arduino for Keil

这是一个跨平台移植的项目,可以在Keil MDK5环境下使用Arduino的函数对STM32系列单片机进行编程。 它本质上是一个建立好的Keil工程,然后在它的基础上封装一套类似于Arduino的底层函数库,可以像在Arduino IDE一样直接调用写好的API, 只需将Arduino支持的第三方库的文件夹加入 "Libraries" 文件夹下即可,然后打开"USER"文件夹启动keil工程进行编写程序。

底层基于 STM32标准外设库 二次封装,安装之后才能正常编译,下载链接位于下方。

STM32F0xx标准外设库

STM32F10x标准外设库

STM32F3xx标准外设库

STM32F4xx标准外设库

部分源代码移植于 stm32duino,用法请参照Arduino语法

支持与寄存器和标准外设库的函数混用:

void setup()
{
	pinMode(PA0,OUTPUT);			//使用Arduino函数将配置PA0为输出模式
}

void loop()
{
	GPIOA -> BSRR = GPIO_Pin_0;		//使用寄存器将PA0电平拉高
	delay(1000);				//延时一秒
	GPIO_ResetBits(GPIOA, GPIO_Pin_0);	//使用标准外设库的函数将PA0电平拉低
	delay(1000);				//延时一秒
}

注意:

 1.请不要删除"main.cpp"中的FileGroup.h和main函数。 
 2.添加第三方库函数的时候要加入完整的路径. 
 3.由于平台的不同,所以不能保证兼容所有的Arduino第三方库函数,有的函数库可能要进行修改才能正常运行,
   具体修改方式请按照编译器的提示,或者可以提交Issues。 

支持Arduino函数有:

基本:

时间:

	delay(Time_ms);
	delayMicroseconds(Time_us);
	millis();
	micros();

输入输出:

	pinMode(Pin,Mode);
	attachInterrrupt(Pin,Trigger_Mode,Callback_function);	
	digitalWrite(Pin,State);
	digitalRead(Pin);
	analogRead(Pin);
	analogWrite(Pin,DutyCycle);
	shiftOut(dataPin,clockPin,bitOrder,value);
	shiftIn(dataPin,clockPin,bitOrder);
	tone(Pin,Frequency,Time_ms);
	tone(Pin,Frequency);

Print

	Serial.print("Hello STM32");
	Serial.printf("Hello STM%d",32);
	Serial << "Hello STM32" << "\r\n";

String

	String s1 = "Hello";
	String s2 = " STM32";
	Serial.print(s1 + s2);

Stream

	Serial.begin(115200);
	Serial.setTimeout(20);
	if(Serial.available())
	{
		String s = Serial.readString();
	}

外设:

Serial

 	Serial.begin(115200);
	while(Serial.available())
	{
		Serial.print(Serial.read());
	}

Wire

	Wire.begin();
	Wire.beginTransmission(0xFF);
	Wire.write(0x01);
	Wire.endTransmission();

SPI

	SPI.begin();
	SPI.transfer(0xFF);

arduino-for-keil's People

Contributors

fastshift avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.