[bsp][pico] add rtduino

This commit is contained in:
Z8MAN8 2023-11-27 23:15:41 +08:00 committed by Meco Man
parent 4d22242ea5
commit 71dad1ccf2
7 changed files with 203 additions and 2 deletions

View File

@ -44,6 +44,18 @@ menu "Onboard Peripheral Drivers"
default y
endif
config BSP_USING_ARDUINO
bool "Compatible with Arduino Ecosystem (RTduino)"
select PKG_USING_RTDUINO
select BSP_USING_UART0
select BSP_UART0_TX_PIN_0
select BSP_UART0_RX_PIN_1
select BSP_USING_UART1
select BSP_UART1_TX_PIN_8
select BSP_UART1_RX_PIN_9
select BSP_USING_GPIO
default n
config BSP_USING_ON_CHIP_FLASH
bool "Enable On-Chip FLASH"
select FAL_DEBUG_CONFIG

View File

@ -1,9 +1,12 @@
from building import *
import os
cwd = GetCurrentDir()
src = ['main.c']
cwd = GetCurrentDir()
CPPPATH = [cwd]
src = Glob('*.c')
if GetDepend(['PKG_USING_RTDUINO']) and not GetDepend(['RTDUINO_NO_SETUP_LOOP']):
src += ['arduino_main.cpp']
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)

View File

@ -0,0 +1,24 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-11-27 ShichengChu first version
*/
#include <Arduino.h>
void setup(void)
{
/* put your setup code here, to run once: */
Serial.begin();
}
void loop(void)
{
/* put your main code here, to run repeatedly: */
Serial.println("Hello Arduino!");
delay(800);
}

View File

@ -0,0 +1,54 @@
# xxx 开发板的Arduino生态兼容说明
## 1 RTduino - RT-Thread的Arduino生态兼容层
xxx 开发板已经完整适配了[RTduino软件包](https://github.com/RTduino/RTduino)即RT-Thread的Arduino生态兼容层。用户可以按照Arduino的编程习惯来操作该BSP并且可以使用大量Arduino社区丰富的库是对RT-Thread生态的极大增强。更多信息请参见[RTduino软件包说明文档](https://github.com/RTduino/RTduino)。
### 1.1 如何开启针对本BSP的Arduino生态兼容层
Env 工具下敲入 menuconfig 命令,或者 RT-Thread Studio IDE 下选择 RT-Thread Settings
```Kconfig
Hardware Drivers Config --->
Onboard Peripheral Drivers --->
[*] Compatible with Arduino Ecosystem (RTduino)
```
## 2 Arduino引脚排布
更多引脚布局相关信息参见 [pins_arduino.c](pins_arduino.c) 和 [pins_arduino.h](pins_arduino.h)。
![xxx-pinout](xxx-pinout.jpg)
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
| ------------------- | --------- | ---- | ------------------------------------------------------------------------- |
| 0 (D0) | P | 是/否 | Serial-TX默认被RT-Thread的UART设备框架uart1接管 |
| 1 (D1) | P | 是/否 | Serial-RX默认被RT-Thread的UART设备框架uart1接管 |
| 2 (D2) | P | 是/否 | |
| 3 (D3) | P | 是/否 | |
| 4 (D4) | P | 是/否 | |
| 5 (D5) | P | 是/否 | |
| 6 (D6) | P | 是/否 | |
| 7 (D7) | P | 是/否 | |
| 8 (D8) | P | 是/否 | Serial2-TX默认被RT-Thread的UART设备框架uart2接管 |
| 9 (D9) | P | 是/否 | Serial2-RX默认被RT-Thread的UART设备框架uart2接管 |
| 10 (D10) | P | 是/否 | |
| 11 (D11) | P | 是/否 | |
| 12 (D12) | P | 是/否 | |
| 13 (D13) | P | 是/否 | |
| 14 (D14) | P | 是/否 | |
| 15 (D15) | P | 是/否 | |
| 16 (D16) | P | 是/否 | |
| 17 (D17) | P | 是/否 | |
| 18 (D18) | P | 是/否 | |
| 19 (D19) | P | 是/否 | |
| 20 (D20) | P | 是/否 | |
| 21 (D21) | P | 是/否 | |
| 22 (D22) | P | 是/否 | |
| 23 (D23) | P | 是/否 | 板载用户LED |
| 24 (D24) | P | 是/否 | |
| 25 (D25) | P | 是/否 | |
> 注意:
>
> 1. xxxxxxxxx
> 2. xxxxxxxxx

View File

@ -0,0 +1,9 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c') + Glob('*.cpp')
inc = [cwd]
group = DefineGroup('RTduino', src, depend = ['PKG_USING_RTDUINO'], CPPPATH = inc)
Return('group')

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-11-27 ShichengChu first version
*/
#include <Arduino.h>
#include <board.h>
#include "pins_arduino.h"
/*
* {Arduino Pin, RT-Thread Pin [, Device Name, Channel]}
* [] means optional
* Digital pins must NOT give the device name and channel.
* Analog pins MUST give the device name and channel(ADC, PWM or DAC).
* Arduino Pin must keep in sequence.
*/
const pin_map_t pin_map_table[]=
{
{D0, 0, "uart1"}, /* Serial-TX */
{D1, 1, "uart1"}, /* Serial-RX */
{D2, 2},
{D3, 3},
{D4, 4},
{D5, 5},
{D6, 6},
{D7, 7},
{D8, 8, "uart2"}, /* Serial2-TX */
{D9, 9, "uart2"}, /* Serial2-RX */
{D10, 10},
{D11, 11},
{D12, 12},
{D13, 13},
{D14, 14},
{D15, 15},
{D16, 16},
{D17, 17},
{D18, 18},
{D19, 19},
{D20, 20},
{D21, 21},
{D22, 22},
{D23, 25}, /* LED_BUILTIN */
{D24, 26},
{D25, 27},
};

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-11-27 ShichengChu first version
*/
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
/* pins alias. Must keep in sequence */
#define D0 (0)
#define D1 (1)
#define D2 (2)
#define D3 (3)
#define D4 (4)
#define D5 (5)
#define D6 (6)
#define D7 (7)
#define D8 (8)
#define D9 (9)
#define D10 (10)
#define D11 (11)
#define D12 (12)
#define D13 (13)
#define D14 (14)
#define D15 (15)
#define D16 (16)
#define D17 (17)
#define D18 (18)
#define D19 (19)
#define D20 (20)
#define D21 (21)
#define D22 (22)
#define D23 (23)
#define D24 (24)
#define D25 (25)
#define F_CPU 133000000L /* CPU:133MHz */
#define LED_BUILTIN D23 /* Default Built-in LED */
/* Serial2 : P-TX P-RX */
#define RTDUINO_SERIAL2_DEVICE_NAME "uart2"
#endif /* Pins_Arduino_h */