Coder Social home page Coder Social logo

rtduino / rtduino Goto Github PK

View Code? Open in Web Editor NEW
94.0 4.0 21.0 17.01 MB

Arduino Ecosystem Compatibility Layer for RT-Thread | RT-Thread的Arduino生态兼容层

Home Page: https://docs.rtduino.com

License: Other

Python 5.29% C 26.66% C++ 68.05%
arduino rt-thread rtos compatibility-layer rtduino

rtduino's Introduction

中文 | English


logo

RTduino
RT-Thread操作系统的Arduino生态兼容层

RTduino
Arduino Ecosystem Compatibility Layer for RT-Thread

1 简介

RTduino是RT-Thread实时操作系统的Arduino生态兼容层,为RT-Thread社区的子社区,旨在兼容Arduino社区生态来丰富RT-Thread社区软件包生态(如上千种分门别类的Arduino库,以及Arduino社区优秀的开源项目),并降低RT-Thread操作系统以及与RT-Thread适配的芯片的学习门槛。通过RTduino,可以让用户使用Arduino的函数、编程方法,轻松地将RT-Thread和BSP使用起来。用户也可以直接使用Arduino社区第三方库(例如传感器驱动库、算法库等)直接用在RT-Thread工程中,极大地补充了RT-Thread社区生态。

framework-zh

2 已经适配RTduino的RT-Thread BSP

BSP名称 源码链接 DigitalWrite & Read AnalogWrite / PWM AnalogRead / ADC 串口 I2C SPI
瑞萨 RA6M3 HMI Github / Gitee
NXP LPC55S69 EVK Github / Gitee ×
STM32F407星火一号 Github / Gitee
Raspberry Pi Pico Github / Gitee
STM32F072 Nucleo Github / Gitee
STM32F401 Nucleo Github / Gitee
STM32F410 Nucleo Github / Gitee ×
STM32F411 Nucleo Github / Gitee
STM32F412 Nucleo Github / Gitee
STM32L476 Nucleo Github / Gitee
STM32G474 Nucleo Github / Gitee
STM32U575 Nucleo Github / Gitee ×
STM32F469 Discovery Github / Gitee
STM32F103 BluePill Github / Gitee
STM32F401 BlackPill Github / Gitee
STM32F411 BlackPill Github / Gitee
STM32L475潘多拉 Github / Gitee
STM32L431小熊派 Github / Gitee
大疆STM32F427 RoboMaster A板 Github / Gitee ×
大疆STM32F407 Robomaster C型 Github / Gitee ×
CH32V307V-R1 Github / Gitee ×
CH32V208W-R0 Github / Gitee ×
ES32F3696 Github / Gitee
ES32VF2264 Github / Gitee

3 开发环境

RTduino 支持以下开发环境:

  • GCC
  • VSCode
  • RT-Thread Studio
  • Keil MDK5
  • Keil MDK6

注: RTduino作为RT-Thread软件包,其本身支持GCC工具链以及Keil AC5、AC6集成开发环境(IDE),但由于Arduino社区第三方库均为GCC工具链下编写,因此建议使用基于GCC工具链的开发环境。

4 官网与代码仓库

5 感谢以下小伙伴对本仓库的贡献

rtduino's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rtduino's Issues

TODO

一期目标

二期目标

三期目标

四期目标

开发随记

  • 非标准libc的支持可以参考一下esp8266和STM32duino的Arduino是怎么支持的

警惕C++里的构造函数

构造函数里初始化设备这种行为可能会引发一些行为不可控。因为构造函数什么时候初始化并不确定,例如,一旦传感器通过构造函数初始化的时机比IIc设备框架要早,那么,传感器肯定是不工作的。例如:

SmartDrive smd = SmartDrive(SmartDrive_DefaultAddress); //<= 这个函数内部调用了Wire.begin函数, 调用Wire.begin初始化的时候很有可能iic都没有初始化. 因此最好的方法是将其放在setup函数中。

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  //Print on serial monitor
  Serial.print("Motor powered: " + smd.IsMotorPowered(SmartDrive_Motor_ID_1));

  delay(1000);
}

TODO 2023

一期目标

二期目标

三期目标

四期目标

BSP

文档

  • 增加scons --sketch= 命令的描述以及自动运行sketch宏的介绍
  • 增加Env+VSCode环境搭建和编译文档
  • 翻译英文
  • doxygen文档部署

其他

  • 补充基本例程以及readme
  • 翻译英文
  • LOGO设计
  • 可兼容性一览表整理
  • 网页设计

pins_arduino.h missing RA6M3 HMI-Board

RT-Thread reports rtduino is missing pins_arduino.h for the RA6M3 HMI-Board.

Is there a fix for this?

In file included from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Print.h:39,
                 from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Stream.h:38,
                 from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\Wire/Wire.h:40,
                 from ../src/hal_entry.c:14:
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Printable.h:37:1: error: unknown type name 'class'
   37 | class Print;
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Printable.h:45:1: error: unknown type name 'class'
   45 | class Printable
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Printable.h:46:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   46 | {
      | ^
In file included from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Stream.h:38,
                 from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\Wire/Wire.h:40,
                 from ../src/hal_entry.c:14:
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Print.h:46:1: error: unknown type name 'class'
   46 | class Print
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Print.h:47:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   47 | {
      | ^
In file included from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\Wire/Wire.h:40,
                 from ../src/hal_entry.c:14:
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Stream.h:61:1: error: unknown type name 'class'
   61 | class Stream : public Print
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Stream.h:61:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
   61 | class Stream : public Print
      |              ^
In file included from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\Wire/Wire.h:41,
                 from ../src/hal_entry.c:14:
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Arduino.h:57:10: fatal error: pins_arduino.h: No such file or directory
   57 | #include "pins_arduino.h"
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
make: *** [src/subdir.mk:18: src/hal_entry.o] Error 1
make: *** Waiting for unfinished jobs....
"make -j4 all" terminated with exit code 2. Build might be incomplete.

03:21:58 Build Failed. 10 errors, 0 warnings. (took 7s.964ms)

After enabling the RTduino: Arduino Ecological Compatibility Layer, it cannot be built.

I am using the Renesas RA6M3 HMI Board, which is currently supported by RTduino. However, after I enable the RTduino on the RT-Thread settings, I cannot build it due to linker script problem.

I am using GNU Tools for ARM Embedded Version 10.2.1 (2021-03-02).

The specific error was inputted below:

14:19:19 **** Incremental Build of configuration Debug for project templatetrial2 ****
make -j8 all
linking...
c:/rt-threadstudio/repo/extract/toolchain_support_packages/arm/gnu_tools_for_arm_embedded_processors/10.2.1/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: cannot open linker script file memory_regions.ld: No such file or directory
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:95: rtthread.elf] Error 1
"make -j8 all" terminated with exit code 2. Build might be incomplete.

14:19:20 Build Failed. 2 errors, 0 warnings. (took 550ms)

需要注意的问题以及扩展功能

1.启用PWM不能调用pinMode(led_pin, OUTPUT) 否则pwm会失效

void setup() {
  //Declaring LED pin as output
  //pinMode(led_pin, OUTPUT); //不能设置为OUTPUT,否则PWM会失效
}
void loop() {
  //Fading the LED
  for(int i=0; i<255; i++){
    analogWrite(led_pin, i);
    delay(5);
  }
  for(int i=255; i>0; i--){
    analogWrite(led_pin, i);
    delay(5);
  }
}

因为底层已经将对应的IO设置为模拟输入或者复用推挽,结果pinMode之后把IO模式改成了纯输入输出,因此不好使了。
不需要特别修正,只需要知道调用analogRead和analogWrite的时候不需要设置pinMode即可。一旦调用pinMode,该引脚将丧失analogWrite或者analogRead功能,后续只能当做普通IO使用。
Arduino 官方文档也是这么建议的:

You do not need to call pinMode() to set the pin as an output before calling analogWrite().
The analogWrite function has nothing to do with the analog pins or the analogRead function.

2 扩展API

以下三个函数为非Arduino-AVR中存在,但是在Arduino-STM32中扩展:
analogReadResolution()
analogWriteResolution()
analogWriteFrequency()
RTduino扩展:
mapFloat() 双精度浮点映射

3 包含Arduino.h头文件

调用到Arduino相关函数和宏的源文件,请包含Arduino.h头文件
cannot_find_setuploop
includearduino

4 Serial.begin

目前Serial.begin设置波特率是无效的,串口的波特率跟随RT-Thread的串口设备框架设置的波特率走,默认是115200.
换句话说,即便Serial.begin(9600), 串口的波特率依然是115200

5. Keil AC5

如果使用Keil AC5环境,需要勾选GNU extension。AC6不需要。

'class' not being recognized in SPI.h, Wire.h, Print.h, Printable.h and Stream.h... rtduino RA6M3 HMI-Board

This is almost a duplicate of my issue with the pins_arduino as the error is included in that but here it is isolated as purely the issue with 'class' not being recognised...

In file included from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Print.h:39,
                 from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Stream.h:38,
                 from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\Wire/Wire.h:40,
                 from ../src/hal_entry.c:15:
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Printable.h:37:1: error: unknown type name 'class'
   37 | class Print;
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Printable.h:45:1: error: unknown type name 'class'
   45 | class Printable
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Printable.h:46:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   46 | {
      | ^
In file included from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Stream.h:38,
                 from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\Wire/Wire.h:40,
                 from ../src/hal_entry.c:15:
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Print.h:46:1: error: unknown type name 'class'
   46 | class Print
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Print.h:47:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   47 | {
      | ^
In file included from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\Wire/Wire.h:40,
                 from ../src/hal_entry.c:15:
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Stream.h:61:1: error: unknown type name 'class'
   61 | class Stream : public Print
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Stream.h:61:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
   61 | class Stream : public Print
      |              ^
In file included from ../src/hal_entry.c:15:
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\Wire/Wire.h:53:1: error: unknown type name 'class'
   53 | class TwoWire : public Stream
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\Wire/Wire.h:53:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
   53 | class TwoWire : public Stream
      |               ^
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\Wire/Wire.h:112:8: error: unknown type name 'TwoWire'
  112 | extern TwoWire Wire;
      |        ^~~~~~~
In file included from ../src/hal_entry.c:16:
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\SPI/SPI.h:83:1: error: unknown type name 'class'
   83 | class SPISettings
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\SPI/SPI.h:84:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   84 | {
      | ^
In file included from ../src/hal_entry.c:16:
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\SPI/SPI.h:93:1: error: unknown type name 'class'
   93 | class SPIClass
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\SPI/SPI.h:94:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   94 | {
      | ^
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\SPI/SPI.h:111:8: error: unknown type name 'SPIClass'
  111 | extern SPIClass SPI;
      |        ^~~~~~~~
../src/hal_entry.c:17:10: fatal error: Adafruit_Sensor.h: No such file or directory
   17 | #include <Adafruit_Sensor.h>
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [src/subdir.mk:18: src/hal_entry.o] Error 1
make: *** Waiting for unfinished jobs....
"make -j4 all" terminated with exit code 2. Build might be incomplete.

04:21:02 Build Failed. 18 errors, 0 warnings. (took 9s.596ms)

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.