mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-07 00:59:00 +08:00
Adapt RTduino package for stm32f469-st-disco BSP (#6139)
* Adapt RTdunio package for stm32f469-st-disco BSP
This commit is contained in:
@@ -8,6 +8,9 @@ main.c
|
||||
lcd_init.c
|
||||
""")
|
||||
|
||||
if GetDepend(['PKG_USING_RTDUINO']) and not GetDepend(['RTDUINO_NO_SETUP_LOOP']):
|
||||
src += ['arduino_main.cpp']
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
list = os.listdir(cwd)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-12-10 Meco Man first version
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
uint8_t led = LED_BUILTIN;
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
/* put your setup code here, to run once: */
|
||||
pinMode(led, OUTPUT);
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
/* put your main code here, to run repeatedly: */
|
||||
digitalWrite(led, !digitalRead(led));
|
||||
delay(100);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
# STM32F69 Discovery开发板的Arduino生态兼容说明
|
||||
|
||||
## 1 RTduino - RT-Thread的Arduino生态兼容层
|
||||
|
||||
STM32F469 Discovery开发板已经完整适配了[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 --->
|
||||
[*] Support Arduino
|
||||
```
|
||||
|
||||
## 2 Arduino引脚排布
|
||||
|
||||

|
||||
|
||||
该BSP遵照Arduino UNO板的引脚排列方式。详见 `pins_arduino.c`
|
||||
|
||||
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
|
||||
| --------------- | ------------- | ------ | ------------------------------------------------------------ |
|
||||
| 0 (D0) | -- | | 该引脚在UNO板中为串口RX引脚,不可当做普通IO |
|
||||
| 1 (D1) | -- | | 该引脚在UNO板中为串口TX引脚,不可当做普通IO |
|
||||
| 2 (D2) | PG13 | 是 | |
|
||||
| 3 (D3) | PA1 | 是 | PWM(定时器2发生) |
|
||||
| 4 (D4) | PG12 | 是 | |
|
||||
| 5 (D5) | PA2 | 是 | PWM(定时器2发生) |
|
||||
| 6 (D6) | PA6 | 是 | PWM(定时器3发生) |
|
||||
| 7 (D7) | PG11 | 是 | |
|
||||
| 8 (D8) | PG10 | 是 | |
|
||||
| 9 (D9) | PA7 | 是 | PWM(定时器3发生) |
|
||||
| 10 (D10) | PH6 | 是 | PWM(定时器12发生) |
|
||||
| 11 (D11) | PB15 | 是 | PWM(定时器12发生) |
|
||||
| 12 (D12) | PB14 | 是 | |
|
||||
| 13 (D13) | PD3 | 是 | RTduino LED |
|
||||
| 14 (D14) | PB9 | 是 | I2C1-SDA,被RT-Thread的I2C设备框架i2c1总线接管,不可当做普通IO |
|
||||
| 15 (D15) | PB8 | 是 | I2C1_SCL,被RT-Thread的I2C设备框架i2c1总线接管,不可当做普通IO |
|
||||
| 16 (D16) | PA0 | 是 | Discovery板载用户按键(蓝色) |
|
||||
| 17(D17) | PG6 | 是 | user LED1(用户LED) |
|
||||
| 18(D18) | PD4 | 是 | user LED2(用户LED) |
|
||||
| 19(D19) | PD5 | 是 | user LED3(用户LED) |
|
||||
| 20(D20) | PK3 | 是 | user LED4(用户LED) |
|
||||
| A0 | PB1 | 是 | ADC Channel_9 |
|
||||
| A1 | PC2 | 是 | ADC Channel_12 |
|
||||
| A2 | PC3 | 是 | ADC Channel_13 |
|
||||
| A3 | PC4 | 是 | ADC Channel_14 |
|
||||
| A4 | PC5 | 是 | ADC Channel_15 |
|
||||
| A5 | PA4 | 是 | ADC Channel_4 |
|
||||
| A6 | -- | | 芯片内部参考电压 ADC |
|
||||
| A7 | -- | | 芯片内部温度 ADC |
|
||||
|
||||
> 注意:
|
||||
>
|
||||
> - 暂无
|
||||
|
||||
> 参考资料
|
||||
>
|
||||
> 【1】[STM32F469 Discovery官方资料](https://www.st.com/en/evaluation-tools/32f469idiscovery.html#documentation)
|
||||
|
||||
## 3 I2C总线
|
||||
|
||||
STM32F469 Discovery板的I2C总线是板上丝印的 `SCL/D15` 和 `SDA/D14` 引脚,这两个引脚是被RT-Thread I2C设备框架接管的,不需要直接操控这两个引脚,直接引用`#include <Wire.h>`(Arduino官方I2C头文件)即可使用。
|
||||
@@ -0,0 +1,9 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
inc = [cwd]
|
||||
|
||||
group = DefineGroup('Arduino', src, depend = ['PKG_USING_RTDUINO'], CPPPATH = inc)
|
||||
|
||||
Return('group')
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 138 KiB |
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-07-04 solar first version
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <board.h>
|
||||
#include "pins_arduino.h"
|
||||
|
||||
/*
|
||||
{Arduino Pin, RT-Thread Pin [, Device Name(PWM or ADC), 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}, /* RX */
|
||||
{D1}, /* TX */
|
||||
{D2, GET_PIN(G,13)},
|
||||
{D3, GET_PIN(A,1), "pwm2", 2}, /* PWM */
|
||||
{D4, GET_PIN(G,12)},
|
||||
{D5, GET_PIN(A,2), "pwm2", 3}, /* PWM */
|
||||
{D6, GET_PIN(A,6), "pwm3", 1}, /* PWM */
|
||||
{D7, GET_PIN(G,11)},
|
||||
{D8, GET_PIN(G,10)},
|
||||
{D9, GET_PIN(A,7), "pwm3", 2}, /* PWM */
|
||||
{D10, GET_PIN(H,6),"pwm12", 1}, /* PWM */
|
||||
{D11, GET_PIN(B,15),"pwm12", 2}, /* PWM */
|
||||
{D12, GET_PIN(B,14)},
|
||||
{D13, GET_PIN(D,3)},
|
||||
{D14}, /* I2C1-SDA */
|
||||
{D15}, /* I2C1-SCL */
|
||||
{D16, GET_PIN(A,0)}, /* user button */
|
||||
{D17, GET_PIN(G,6)}, /* user LED */
|
||||
{D18, GET_PIN(D,4)}, /* user LED */
|
||||
{D19, GET_PIN(D,5)}, /* user LED */
|
||||
{D20, GET_PIN(K,3)}, /* user LED */
|
||||
{A0, GET_PIN(B,1), "adc1", 9}, /* ADC */
|
||||
{A1, GET_PIN(C,2), "adc1", 12}, /* ADC */
|
||||
{A2, GET_PIN(C,3), "adc1", 13}, /* ADC */
|
||||
{A3, GET_PIN(C,4), "adc1", 14}, /* ADC */
|
||||
{A4, GET_PIN(C,5), "adc1", 15}, /* ADC */
|
||||
{A5, GET_PIN(A,4), "adc1", 4}, /* ADC */
|
||||
{A6, RT_NULL, "adc1", 17}, /* ADC, On-Chip: internal reference voltage, ADC_CHANNEL_VREFINT */
|
||||
{A7, RT_NULL, "adc1", 16} /* ADC, On-Chip: internal temperature sensor, ADC_CHANNEL_TEMPSENSOR */
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-07-04 solar 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 A0 (21)
|
||||
#define A1 (22)
|
||||
#define A2 (23)
|
||||
#define A3 (24)
|
||||
#define A4 (25)
|
||||
#define A5 (26)
|
||||
#define A6 (27)
|
||||
#define A7 (28)
|
||||
|
||||
#define F_CPU 180000000L /* CPU: 180MHz */
|
||||
#define LED_BUILTIN D13 /* Default Built-in LED */
|
||||
|
||||
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"
|
||||
|
||||
#endif /* Pins_Arduino_h */
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -36,6 +36,8 @@
|
||||
/* Global variables ---------------------------------------------------------*/
|
||||
extern PDM_Filter_Handler_t PDM1_filter_handler;
|
||||
extern PDM_Filter_Config_t PDM1_filter_config;
|
||||
extern PDM_Filter_Handler_t PDM2_filter_handler;
|
||||
extern PDM_Filter_Config_t PDM2_filter_config;
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
/* USER CODE END 1 */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,7 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -63,7 +63,7 @@ extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
|
||||
/* USER CODE END EV */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M4 Processor Interruption and Exception Handlers */
|
||||
/* Cortex-M4 Processor Interruption and Exception Handlers */
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* @brief This function handles Non maskable interrupt.
|
||||
|
||||
@@ -15,6 +15,31 @@ menu "Onboard Peripheral Drivers"
|
||||
select BSP_USING_TOUCH
|
||||
default n
|
||||
|
||||
config BSP_USING_ARDUINO
|
||||
bool "Support Arduino"
|
||||
select PKG_USING_RTDUINO
|
||||
select BSP_USING_STLINK_TO_USART
|
||||
select BSP_USING_GPIO
|
||||
select BSP_USING_ADC
|
||||
select BSP_USING_ADC1
|
||||
select BSP_USING_PWM
|
||||
select BSP_USING_PWM2
|
||||
select BSP_USING_PWM2_CH2
|
||||
select BSP_USING_PWM2_CH3
|
||||
select BSP_USING_PWM3
|
||||
select BSP_USING_PWM3_CH1
|
||||
select BSP_USING_PWM3_CH2
|
||||
select BSP_USING_PWM12
|
||||
select BSP_USING_PWM12_CH1
|
||||
select BSP_USING_PWM12_CH2
|
||||
select BSP_USING_I2C
|
||||
select BSP_USING_I2C1
|
||||
imply RTDUINO_USING_SERVO
|
||||
imply RTDUINO_USING_WIRE
|
||||
imply RTDUINO_USING_ADAFRUIT
|
||||
imply RTDUINO_USING_MSTIMER2
|
||||
default n
|
||||
|
||||
if BSP_USING_LVGL
|
||||
config BSP_USING_LVGL_DEMO
|
||||
bool "Enable LVGL demo"
|
||||
@@ -103,6 +128,62 @@ menu "On-chip Peripheral Drivers"
|
||||
select RT_USING_PIN
|
||||
default y
|
||||
|
||||
menuconfig BSP_USING_ADC
|
||||
bool "Enable ADC"
|
||||
default n
|
||||
select RT_USING_ADC
|
||||
if BSP_USING_ADC
|
||||
config BSP_USING_ADC1
|
||||
bool "Enable ADC1"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_PWM
|
||||
bool "Enable PWM"
|
||||
default n
|
||||
select RT_USING_PWM
|
||||
if BSP_USING_PWM
|
||||
menuconfig BSP_USING_PWM2
|
||||
bool "Enable timer2 output PWM"
|
||||
default n
|
||||
if BSP_USING_PWM2
|
||||
config BSP_USING_PWM2_CH2
|
||||
bool "Enable PWM2 channel2"
|
||||
default n
|
||||
endif
|
||||
if BSP_USING_PWM2
|
||||
config BSP_USING_PWM2_CH3
|
||||
bool "Enable PWM2 channel3"
|
||||
default n
|
||||
endif
|
||||
menuconfig BSP_USING_PWM3
|
||||
bool "Enable timer3 output PWM"
|
||||
default n
|
||||
if BSP_USING_PWM3
|
||||
config BSP_USING_PWM3_CH1
|
||||
bool "Enable PWM3 channel1"
|
||||
default n
|
||||
endif
|
||||
if BSP_USING_PWM3
|
||||
config BSP_USING_PWM3_CH2
|
||||
bool "Enable PWM3 channel2"
|
||||
default n
|
||||
endif
|
||||
menuconfig BSP_USING_PWM12
|
||||
bool "Enable timer12 output PWM"
|
||||
default n
|
||||
if BSP_USING_PWM12
|
||||
config BSP_USING_PWM12_CH1
|
||||
bool "Enable PWM12 channel1"
|
||||
default n
|
||||
endif
|
||||
if BSP_USING_PWM12
|
||||
config BSP_USING_PWM12_CH2
|
||||
bool "Enable PWM12 channel2"
|
||||
default n
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_UART
|
||||
bool "Enable UART"
|
||||
select RT_USING_SERIAL
|
||||
|
||||
Reference in New Issue
Block a user