fastshift / arduino-for-keil Goto Github PK
View Code? Open in Web Editor NEWA lightweight Arduino framework for Keil projects.
License: MIT License
A lightweight Arduino framework for Keil projects.
License: MIT License
跟随大佬从arduino贴吧到QQ空间再到此
请问大佬如果说我将Arduino这个框架移植到N32G45X(ARM-Coterx-M4)是不是同样适用?
用STM32F411CEU6直接用模板工程下载程序会导致芯片锁死,是不是还有其他内容需要配置?
void TwoWire::set_scl(bool state)
{
I2C_DELAY(this->i2c_delay);
digitalWrite(this->scl_pin, state);
//Allow for clock stretching - dangerous currently
if (state == HIGH)
{
while(digitalRead(this->scl_pin) == 0);
}
}
卡在了 while里面 请问这个 while有什么作用
用stm32f103c8t6核心板。sd卡库编译通过,但是连不上sd卡。用stm32的spi引脚(PA4 CS, 5 SCK, 6 MISO, 7 MOSI)。我用stlink调试得到卡在了SdVolume的init初始化上,前一步card.init可以。想得到大佬的帮助。
引脚重映射还是只能用标准库, f103定时器定义太少 发f103zg有8个定时器 但是只定义4个
Hello.
I have been for a while diving in information and looking in the internet before coming to ask.
I am testing out the Low Power Modes in the STM32F03F4P6, at this point I have been able to use the STOPMode and wake-up with a pin Interrupt, in my custom PCB the power goes low to 10uA, really good.
But I want to know how to make it awake every certain amount of time then sleep again, for example to read a sensor, send the data then sleep some minutes and do it again.
I have been trying using the Timer example, not success there. Probably I am missing something important. I read something about this line of code NVIC_SystemLPConfig(NVIC_LP_SLEEPONEXIT, ENABLE); but I really cannot understand the process to follow, if someone can point me in the right direction it will be great.
This is the code I have been trying unsuccessfully.
` #include "Arduino.h"
#define LED_Pin PA4
#define KEY_Pin PA1
void Timer1_Callback(){
pinMode(LED_Pin, OUTPUT);
togglePin(LED_Pin);
TIM_Cmd(TIM1, DISABLE);
InternalClocks_Init(); //Setup the clock after awake
}
void enterStopMode(){
Timer_SetInterrupt(TIM1, 1000000/@1s/, Timer1_Callback);
TIM_Cmd(TIM1, ENABLE);
//I dont know what the below line does but decrease the power by 10uA
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); //Turn on the power management clock
//Set the Regulator in Low Power and can be awake by an interrupt
PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
}
//Set Pins to Analog to decrease power usage
void setPinsToAnalog(){
pinMode(PA0, INPUT_ANALOG);
pinMode(PA1, INPUT_ANALOG); //If set to analog Interrupt do not work
pinMode(PA2, INPUT_ANALOG);
pinMode(PA3, INPUT_ANALOG);
pinMode(PA4, INPUT_ANALOG);
pinMode(PA5, INPUT_ANALOG);
pinMode(PA6, INPUT_ANALOG);
pinMode(PA7, INPUT_ANALOG);
pinMode(PA9, INPUT_ANALOG);
pinMode(PA10, INPUT_ANALOG);
pinMode(PB1, INPUT_ANALOG);
pinMode(PF0, INPUT_ANALOG);
pinMode(PF1, INPUT_ANALOG);
}
void setup(){
pinMode(LED_Pin, OUTPUT);
pinMode(KEY_Pin, INPUT_PULLDOWN);
// it is supposed to allow to wakeup with the time but it did not work.
NVIC_SystemLPConfig(NVIC_LP_SEVONPEND, ENABLE);
}
void loop(){
//Just Keep the LED On to measure the running power
digitalWrite(LED_Pin, HIGH);
delay(5000);
digitalWrite(LED_Pin, LOW);
//Go to Sleep
setPinsToAnalog();
enterStopMode();
}
/**
int main(void)
{
InternalClocks_Init(); //Set the internal clock @ 8MHz
Delay_Init();
setup();
for(;;)loop();
} `
..\Libs\ArduinoAPI\Printable.h(25): error: #20: identifier "class" is undefined
..\Libs\ArduinoAPI\Printable.h(34): error: #65: expected a ";"
..\Libs\ArduinoAPI\Print.h(66): error: #147-D: declaration is incompatible with "size_t println(const char *)" (declared at line 65)
..\Libs\ArduinoAPI\Print.h(67): error: #147-D: declaration is incompatible with "size_t println(uint8, int)" (declared at line 65)
..........
大佬们,我在STM32F10X的工程中更换了芯片STM32F103RC,这是为了能够在proteus中进行仿真。但是直接这样报错了,我参考野火的例程,应该要更换启动文件为ld.s,但是我直接添加进去还是有错,然后我又想着把ArduinoAPI和内核移植到野火的例程中,还是错误。想知道怎么更换芯片能够不报错啊!
Hi! Planning to use the HAL library and CUBEMX?
Alexander.
[email protected]
真是一个很棒的项目,arduino也能在keil上面用了。
手头上有一块F407和F429,如何能移植到这上面用呢?
谢谢
大佬 你好
我在移植一个Arduino工程,需要用到18b20、31865、热敏打印机库等库,麻烦大佬给适配一下。谢谢
*** Using Compiler '', folder: 'D:\Kil_v5\ARM\ARMCC\bin'
Build target 'Project'
compiling main.cpp...
..\USER\main.cpp(12): error: #289: no instance of constructor "HardwareSerial::HardwareSerial" matches the argument list
argument types are: (Pin_Type, Pin_Type)
HardwareSerial PB(PA10,PA9);
错误如下:Device下各个组件为红色报错
Warning #440: Requested device 'STM32F407VE' is subsituted with variant 'STM32F407VETx' for target 'Project'
Error instantiating RTE components
Error #540: 'Keil::Device:StdPeriph Drivers:ADC:1.3.0' component is not available for target 'Project', pack 'Keil.STM32F4xx_DFP.1.0.8' is not selected
Error #540: 'Keil::Device:StdPeriph Drivers:DCMI:1.3.0' component is not available for target 'Project', pack 'Keil.STM32F4xx_DFP.1.0.8' is not selected
Error #540: 'Keil::Device:StdPeriph Drivers:DMA:1.3.0' component is not available for target 'Project', pack 'Keil.STM32F4xx_DFP.1.0.8' is not selected
Error #540: 'Keil::Device:StdPeriph Drivers:EXTI:1.3.0' component is not available for target 'Project', pack 'Keil.STM32F4xx_DFP.1.0.8' is not selected
Error #540: 'Keil::Device:StdPeriph Drivers:Flash:1.3.0' component is not available for target 'Project', pack 'Keil.STM32F4xx_DFP.1.0.8' is not selected
Error #540: 'Keil::Device:StdPeriph Drivers:Framework:1.3.1' component is not available for target 'Project', pack 'Keil.STM32F4xx_DFP.1.0.8' is not selected
Error #540: 'Keil::Device:StdPeriph Drivers:GPIO:1.3.0' component is not available for target 'Project', pack 'Keil.STM32F4xx_DFP.1.0.8' is not selected
Error #540: 'Keil::Device:StdPeriph Drivers:I2C:1.3.0' component is not available for target 'Project', pack 'Keil.STM32F4xx_DFP.1.0.8' is not selected
Error #540: 'Keil::Device:StdPeriph Drivers:RCC:1.3.0' component is not available for target 'Project', pack 'Keil.STM32F4xx_DFP.1.0.8' is not selected
Error #540: 'Keil::Device:StdPeriph Drivers:SPI:1.3.0' component is not available for target 'Project', pack 'Keil.STM32F4xx_DFP.1.0.8' is not selected
Error #540: 'Keil::Device:StdPeriph Drivers:SYSCFG:1.3.0' component is not available for target 'Project', pack 'Keil.STM32F4xx_DFP.1.0.8' is not selected
Error #540: 'Keil::Device:StdPeriph Drivers:TIM:1.3.0' component is not available for target 'Project', pack 'Keil.STM32F4xx_DFP.1.0.8' is not selected
Error #540: 'Keil::Device:StdPeriph Drivers:USART:1.3.0' component is not available for target 'Project', pack 'Keil.STM32F4xx_DFP.1.0.8' is not selected
我用millis()多线程运行时间,发现运行millis()时间不对,慢的很多。
const int ledPin = PC13; // the LED pin number connected
int ledState = LOW; // used to set the LED state
unsigned long previousMillis = 0; //will store last time LED was blinked
const long period = 300;
unsigned long currentMillis = millis(); // store the current time
pinMode(PC13, OUTPUT);
if (currentMillis - previousMillis >= period) { // check if 1000ms passed
previousMillis = currentMillis; // save the last time you blinked the LED
if (ledState == LOW) { // if the LED is off turn it on and vice-versa
ledState = HIGH;
} else {
ledState = LOW;
}
digitalWrite(ledPin, ledState);//set LED with ledState to blink again
}
上面是我的代码,其中const long period = 300; 这个原来是1000ms,我发现PC13 的led灯闪烁间隔有7秒的间隔,改了300ms还是7秒左右,是不是我写的有问题?你有这个millis()的测试代码吗?
谢谢了 又问了你一个问题 麻烦了
H750挺不错的,便宜量足
need to english documantation
教程如下
https://blog.csdn.net/m0_50926303/article/details/120585496
下方为错误信息
Build started: Project: proj
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'Project'
compiling SPFD5408_Adafruit_GFX.cpp...
..\Libraries\SPFD5408-master\SPFD5408_Adafruit_GFX.cpp(37): error: #5: cannot open source input file "SPFD5408_Adafruit_GFX.h": No such file or directory
#include <SPFD5408_Adafruit_GFX.h>
..\Libraries\SPFD5408-master\SPFD5408_Adafruit_GFX.cpp: 0 warnings, 1 error
compiling SPFD5408_TouchScreen.cpp...
..\Libraries\SPFD5408-master\SPFD5408_TouchScreen.cpp(6): error: #5: cannot open source input file "pins_arduino.h": No such file or directory
#include "pins_arduino.h"
..\Libraries\SPFD5408-master\SPFD5408_TouchScreen.cpp: 0 warnings, 1 error
compiling SPFD5408_Adafruit_TFTLCD.cpp...
..\Libraries\SPFD5408-master\SPFD5408_Adafruit_TFTLCD.h(18): error: #5: cannot open source input file "SPFD5408_Adafruit_GFX.h": No such file or directory
#include <SPFD5408_Adafruit_GFX.h>
..\Libraries\SPFD5408-master\SPFD5408_Adafruit_TFTLCD.cpp: 0 warnings, 1 error
".\Objects\proj.axf" - 3 Error(s), 0 Warning(s).
Target not created.
我在使用其他.c文件加载#include "FileGroup.h",这个FileGroup.h前面有×,无法build,显示..\ArduinoAPI\Printable.h(25): error: #20: identifier "class" is undefined,..\ArduinoAPI\Print.h(101): error: #169: expected a declaration。我是初学者,在这麻烦你解决下,谢谢,最近下载的文件,是最新的。使用main.cpp,build是没有问题的,就是其他的.c文件加头文件include "FileGroup.h"build出错
在当前更新空模板上,项目只加载extEEPROM库后预编译提示11个错误,错误信息
compiling extEEPROM.cpp...
..\ArduinoAPI\WString.h(174): error: #338: more than one instance of overloaded function "operator+" has "C" linkage
friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr);
..\ArduinoAPI\WString.h(175): error: #338: more than one instance of overloaded function "operator+" has "C" linkage
friend StringSumHelper & operator + (const StringSumHelper &lhs, char c);
..\ArduinoAPI\WString.h(176): error: #338: more than one instance of overloaded function "operator+" has "C" linkage
friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num);
..\ArduinoAPI\WString.h(177): error: #338: more than one instance of overloaded function "operator+" has "C" linkage
friend StringSumHelper & operator + (const StringSumHelper &lhs, int num);
..\ArduinoAPI\WString.h(178): error: #338: more than one instance of overloaded function "operator+" has "C" linkage
friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num);
..\ArduinoAPI\WString.h(179): error: #338: more than one instance of overloaded function "operator+" has "C" linkage
friend StringSumHelper & operator + (const StringSumHelper &lhs, long num);
..\ArduinoAPI\WString.h(180): error: #338: more than one instance of overloaded function "operator+" has "C" linkage
friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num);
..\ArduinoAPI\WString.h(181): error: #338: more than one instance of overloaded function "operator+" has "C" linkage
friend StringSumHelper & operator + (const StringSumHelper &lhs, float num);
..\ArduinoAPI\WString.h(182): error: #338: more than one instance of overloaded function "operator+" has "C" linkage
friend StringSumHelper & operator + (const StringSumHelper &lhs, double num);
..\ArduinoAPI\WString.h(183): error: #338: more than one instance of overloaded function "operator+" has "C" linkage
friend StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs);
..\ArduinoAPI\Print.h(100): error: #800: this declaration may not have extern "C" linkage
template inline Print &operator << (Print &obj, T arg) {
..\Libraries\extEEPROM\extEEPROM.cpp: 0 warnings, 11 errors
compiling Tone.cpp...
compiling adc.c...
compiling delay.c...
assembling startup_stm32f10x_md.s...
compiling exti.c...
compiling gpio.c...
compiling pwm.c...
compiling timer.c...
compiling main.cpp...
compiling system_stm32f10x.c...
compiling misc.c...
compiling stm32f10x_adc.c...
compiling stm32f10x_dma.c...
compiling stm32f10x_exti.c...
compiling stm32f10x_flash.c...
compiling stm32f10x_gpio.c...
compiling stm32f10x_rcc.c...
compiling stm32f10x_spi.c...
compiling stm32f10x_usart.c...
compiling stm32f10x_tim.c...
"..\OBJ\Pro.axf" - 11 Error(s), 0 Warning(s).
Target not created.
在上个更新模板下加载extEEPROM过是正常编译的。
stm32f030f4可以在keil中使用arduino编程,或者在arduino ide中对stm32f030f4编程吗?
大佬,用的的框架里面定时器库函数想实现定时器通过编码器接口获取编码值,却找不到相关命令,只能通过标准库实现,能否升级一下
标准库相关实现命令:
void Encoder_init(void)
{
//1、开启时钟
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStructure);
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;
TIM_TimeBaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInitStructure.TIM_Period = 65536-1;
TIM_TimeBaseInitStructure.TIM_Prescaler = 1-1;
TIM_TimeBaseInitStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM3,&TIM_TimeBaseInitStructure);
TIM_ICInitTypeDef TIM_ICInitStructure;
TIM_ICStructInit(&TIM_ICInitStructure);
TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;
TIM_ICInitStructure.TIM_ICFilter = 0xF;
TIM_ICInit(TIM3,&TIM_ICInitStructure);
TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;
TIM_ICInitStructure.TIM_ICFilter = 0xF;
TIM_ICInit(TIM3,&TIM_ICInitStructure);
TIM_EncoderInterfaceConfig(TIM3,TIM_EncoderMode_TI12,TIM_ICPolarity_Rising,TIM_ICPolarity_Rising);
TIM_Cmd(TIM3,ENABLE);
}
int16_t Encoder_Get(void)
{
int16_t Temp;
Temp = TIM_GetCounter(TIM3);
TIM_SetCounter(TIM3,0);
return Temp;
}
@FASTSHIFT
I want to share the libraries I use and that I tested with the real hardware.
My setup: SMT32F030 with internal clock @8MHz
I use this libraries, sensors and displays in other arduino projects and I want to share it.
All this libraries are working, I did changes in some of them in order to work correctly, also I added the examples as I use in Keil.
List:
Sensors
BMP085 Adafruit_BMP085
BME280 Grove_-_Barometer_Sensor_BME280
SHT31 Adafruit_SHT31
Display
OLED SSD1306 Adafruit_SSD1306_extra (note, this is a mod from the original library to support the 64x48 screen)
& also need the Adafruit_GFX_Library (attached here too).
PCD8544 (Nokia 3310) pcd8544 (not adafruit, this is a lightweight alternative, easy to use).
Wireless
RFM69 RFM69_LowPowerLab.
Others
JSON jWrite (to make JSON format data)
pcd8544.zip
RFM69_LowPowerLab.zip
Adafruit_BMP085_Library.zip
Adafruit_GFX_Library.zip
Adafruit_SHT31_Library.zip
Adafruit_SSD1306_extra.zip
Grove_-_Barometer_Sensor_BME280.zip
jWrite.zip
编译无法使用C++11 arduino的很多库在头文件中就给成员赋值了 导致出错 这个问题怎么解决
作者你好,在加入MPU6050_DMP库,使用示例时#include "MPU6050_6Axis_MotionApps20.h"报错,问题:error in include chain (helper_3dmath.h):call to 'sqrt' is ambiguous.
(头文件已包含)
请问是什么原因造成。
Hello FASTSHIFT.
I am a hobbyist of Arduino and recently discovered your job and I have been playing with it for 2 or 3 days, I blinked a LED, fade in and out and printed to serial using your examples, so far, so good.
I bought some months ago a board with STM32F030F4P6 (SSOP-20 package), really cheap and I have been working to move some of attiny84 projects to this MCU, not luck with it, code was too big until I found your project.
Now I am trying to Port some of the Arduino libraries for my sensors and screens, many of them are I2C (BMP085, BME280, OLED SSD1306...) So first I tried to use the I2C scanner code from the Arduino community but seems it hangs up the whole thing and don't even get serial Port outputs.
I will be very happy if you can help me on it.
This is the code:
/I2C Scanner
//#define pinSDA PA1
//#define pinSCL PA2
#define SDA_Pin PA1
#define SCL_Pin PA2
#include <Wire.h>
//TwoWire Wire(pinSCL, pinSDA, SOFT_FAST);
void Serial_EventHandler()
{
togglePin(LED_Pin);
}
void setup()
{
Wire.begin();
Serial.begin(9600);
//Serial.setTimeout(10);
//Serial.attachInterrupt(Serial_EventHandler);
Serial.println("\nI2C Scanner");
}
void loop()
{
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.printf("I2C device found at address 0x");
if (address<16)
Serial.printf("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.printf("Unknow error at address 0x");
if (address<16)
Serial.printf("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000); // wait 5 seconds for next scan
}
int main(void)
{
Delay_Init();
setup();
for(;;)loop();
}
This is my board:
By the way, the code use the internal oscillator or external?
先谢谢大佬的开源,我尝试编译了一下oled的库,有点小问题
Compiler:ac5
IDE:KEIL v5.27pre
错误信息:
..\Libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp(184): error: #513: a value of type "volatile std::uint32_t *" cannot be assigned to an entity of type "PortReg *"
解决方法:
添加强制类型转换 (PortReg *)
csport = (PortReg*)portOutputRegister(digitalPinToPort(cs));
cspinmask = digitalPinToBitMask(cs);
dcport = (PortReg*)portOutputRegister(digitalPinToPort(dc));
dcpinmask = digitalPinToBitMask(dc);
linking...
.\Objects\proj.axf: Error: L6218E: Undefined symbol Adafruit_MS_PWMServoDriver::setPWMFreq(float) (referred from qgpmaker_motorshield.o).
.\Objects\proj.axf: Error: L6218E: Undefined symbol Adafruit_MS_PWMServoDriver::begin() (referred from qgpmaker_motorshield.o).
.\Objects\proj.axf: Error: L6218E: Undefined symbol Adafruit_MS_PWMServoDriver::setPWM(unsigned char, unsigned short, unsigned short) (referred from qgpmaker_motorshield.o).
.\Objects\proj.axf: Error: L6218E: Undefined symbol Adafruit_MS_PWMServoDriver::Adafruit_MS_PWMServoDriver(unsigned char) (referred from qgpmaker_motorshield.o).
Not enough information to list image symbols.
Finished: 1 information, 0 warning and 4 error messages.
编译时间太久了, 当然比arduino IDE好多了
修改为F401RC的改动:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.