Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync from master #6981

Merged
merged 23 commits into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
feed84b
fix rt_kprint 64bit error
zhkag Feb 20, 2023
ff58949
update rtdevice.h add lcd
XYZ-20240101 Feb 18, 2023
aaba21c
[fix]避免字符设备特殊控制指令和通用控制指令冲突
JonasWen Feb 21, 2023
1533b88
[arduino][lpc55s69] : 对接RTduino
Z8MAN8 Feb 22, 2023
b3b8c23
[spi] rt_spi_configure 增加对cs_pin处理
liYony Feb 23, 2023
52cb2f0
[lwIP] apply AF_UNIX feature (#6954)
Guozhanxin Feb 23, 2023
6d4764a
serial_v2 rt_device_write/read return data type as rt_ssize_t
JonasWen Feb 23, 2023
96a636f
[Renesas]Add tft-lcd lvgl support
Rbb666 Feb 22, 2023
08c2a65
[rtduino][lpc55s69] 修正RTduino框架下的引脚错误 (#6963)
kurisaW Feb 23, 2023
382e9bc
[rt-smart] handling kernel from accessing unmapped user stack (#6957)
polarvid Feb 24, 2023
7bf6648
[serial]增加at32的serial_v2驱动
JonasWen Feb 23, 2023
a5c62b9
[bsp/at32] add support usb driver (#6968)
sheltonyu Feb 25, 2023
022760c
[Infineon]Fix scb5 can't use bug
Rbb666 Feb 24, 2023
faddfec
[rtduino][lpc55s69] update (#6972)
Z8MAN8 Feb 25, 2023
7763183
[rtduino][lpc55s69] 纠正uart引脚错误并使能相关依赖项 (#6976)
kurisaW Feb 25, 2023
e50a7e3
🐞 fix(components/drivers/tty/pty.c): fix ptmx not init (#6970)
xqyjlj Feb 25, 2023
4c1c6ef
解决关中断时进行了调度操作
zhkag Feb 24, 2023
d3553e7
fixed fstat/stat/readlink syscall.
geniusgogo Feb 24, 2023
53afeda
fix inet_ioctlsocket set O_LARGEFILE flag by musl.
geniusgogo Feb 24, 2023
a53367a
fixed O_LARGEFILE not defined ci build error.
geniusgogo Feb 25, 2023
fef2607
[lwp] save virtual addr in shm structure
polarvid Feb 25, 2023
12f0df9
[libcpu/aarch64] stop when no page is free
polarvid Feb 25, 2023
e63e33a
[ch32][bsp] fix warning: rt_size_t to rt_ssize_t
linshire Feb 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[arduino][lpc55s69] : 对接RTduino
  • Loading branch information
Z8MAN8 authored and mysterywolf committed Feb 23, 2023
commit 1533b8839026c40845d891117b14f520adeed61a
8 changes: 4 additions & 4 deletions bsp/lpc55sxx/Libraries/drivers/drv_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static rt_err_t lpc_drv_pwm_get(struct rt_device_pwm *device, struct rt_pwm_conf

#ifdef BSP_USING_CTIMER2
/* get frequence */
pwmClock = CLOCK_GetFreq(kCLOCK_CTimer2) ;
pwmClock = CLOCK_GetFreq(kCLOCK_Timer2) ;
#endif

get_frequence = pwmClock / (base->MR[kCTIMER_Match_3] + 1);
Expand Down Expand Up @@ -110,7 +110,7 @@ static rt_err_t lpc_drv_pwm_set(struct rt_device_pwm *device, struct rt_pwm_conf
{
/* Get the PWM period match value and pulse width match value of DEFAULT_FREQ PWM signal with DEFAULT_DUTY dutycycle */
/* Calculate PWM period match value */
pwmPeriod = (( CLOCK_GetFreq(kCLOCK_CTimer2) / (config.prescale + 1) ) / DEFAULT_FREQ) - 1;
pwmPeriod = (( CLOCK_GetFreq(kCLOCK_Timer2) / (config.prescale + 1) ) / DEFAULT_FREQ) - 1;

/* Calculate pulse width match value */
if (DEFAULT_DUTY == 0)
Expand Down Expand Up @@ -175,7 +175,7 @@ int rt_hw_pwm_init(void)
#ifdef BSP_USING_CTIMER2_MAT1
/* Get the PWM period match value and pulse width match value of DEFAULT_FREQ PWM signal with DEFAULT_DUTY dutycycle */
/* Calculate PWM period match value */
pwmPeriod = (( CLOCK_GetFreq(kCLOCK_CTimer2) / (config.prescale + 1) ) / DEFAULT_FREQ) - 1;
pwmPeriod = (( CLOCK_GetFreq(kCLOCK_Timer2) / (config.prescale + 1) ) / DEFAULT_FREQ) - 1;

/* Calculate pulse width match value */
if (DEFAULT_DUTY == 0)
Expand All @@ -186,7 +186,7 @@ int rt_hw_pwm_init(void)
{
pulsePeriod = (pwmPeriod * (100 - DEFAULT_DUTY)) / 100;
}
CTIMER_SetupPwmPeriod(CTIMER2, kCTIMER_Match_1 , pwmPeriod, pulsePeriod, false);
CTIMER_SetupPwmPeriod(CTIMER2, kCTIMER_Match_3 , kCTIMER_Match_1, pwmPeriod, pulsePeriod, false);
#endif

ret = rt_device_pwm_register(&pwm1_device, "pwm1", &lpc_drv_ops, CTIMER2);
Expand Down
19 changes: 10 additions & 9 deletions bsp/lpc55sxx/lpc55s69_nxp_evk/applications/SConscript
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import rtconfig
from building import *
import os

cwd = GetCurrentDir()
src = Glob('main.c')
cwd = GetCurrentDir()
CPPPATH = [cwd]
src = Glob('*.c')

# add for startup script
if rtconfig.PLATFORM in ['gcc']:
CPPDEFINES = ['__START=entry']
else:
CPPDEFINES = []
if GetDepend(['PKG_USING_RTDUINO']) and not GetDepend(['RTDUINO_NO_SETUP_LOOP']):
src += ['arduino_main.cpp']

group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)

group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES)
list = os.listdir(cwd)
for item in list:
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
group = group + SConscript(os.path.join(item, 'SConscript'))

Return('group')
32 changes: 32 additions & 0 deletions bsp/lpc55sxx/lpc55s69_nxp_evk/applications/arduino_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-02-22 ChuShicheng first version
*/

#include <Arduino.h>

int led = 37; /* LED pin */
int brightness = 0;
int fadeAmount = 5;

void setup()
{
/* Do not invoke pinMode for the PWM IO! */
}

void loop()
{
analogWrite(led, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255)
{
fadeAmount = -fadeAmount;
}

delay(100);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# lpc55s69_nxp_evk开发板的Arduino生态兼容说明

## 1 RTduino - RT-Thread的Arduino生态兼容层

lpc55s69_nxp_evk开发板已经完整适配了[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)。

| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
| ------------------- | --------- | ---- | ------------------------------------------------------------------------- |
| 0 (D0) | P | 是/否 | |
| 1 (D1) | P | 是/否 | PWM1-CH3,默认被RT-Thread的PWM设备框架pwm1接管 |
| 2 (D2) | P | 是/否 | Serial-RX,默认被RT-Thread的UART设备框架uart1接管 |
| 3 (D3) | P | 是/否 | Serial-TX,默认被RT-Thread的UART设备框架uart1接管 |
| 4 (D4) | P | 是/否 | PWM2-CH1,默认被RT-Thread的PWM设备框架pwm2接管 |
| 5 (D5) | P | 是/否 | PWM2-CH2,默认被RT-Thread的PWM设备框架pwm2接管 |
| 6 (D6) | P | 是/否 | 板载用户LED |
| 7 (D7) | P | 是/否 | PWM1-CH0,默认被RT-Thread的PWM设备框架pwm1接管 |
| 8 (D8) | P | 是/否 | |
| 9 (D9) | P | 是/否 | PWM2-CH0,默认被RT-Thread的PWM设备框架pwm2接管 |
| 10 (D10) | P | 是/否 | |
| 11 (D11) | P | 是/否 | |
| 12 (D12) | P | 是/否 | |
| 13 (D13) | P | 是/否 | |
| 14 (D14) | P | 是/否 | PWM3-CH2,默认被RT-Thread的PWM设备框架pwm3接管 |
| 15 (D15) | P | 是/否 | |
| 16 (D16) | P | 是/否 | I2C1-SCL,默认被RT-Thread的I2C设备框架i2c1接管 |
| 17 (D17) | P | 是/否 | I2C1-SDA,默认被RT-Thread的I2C设备框架i2c1接管 |
| 18 (A0) | P | 是/否 | ADC0-CH8,默认被RT-Thread的ADC设备框架adc0接管 |
| 19 (A1) | P | 是/否 | ADC0-CH0,默认被RT-Thread的ADC设备框架adc0接管 |
| 20 (A2) | -- | | 芯片内部温度 ADC,默认被RT-Thread的ADC设备框架adc1接管 |
| 21 (A3) | -- | | 芯片内部参考电压 ADC,默认被RT-Thread的ADC设备框架adc1接管 |
Original file line number Diff line number Diff line change
@@ -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')
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-02-22 ChuShicheng 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, 50},
{D1, 49, "pwm1", 3}, /* PWM */
{D2, 57, "uart1"}, /* Serial-RX */
{D3, 28, "uart1"}, /* Serial-TX */
{D4, 39, "pwm2", 1}, /* PWM */
{D5, 40, "pwm2", 2}, /* PWM */
{D6, 37}, /* LED_BUILTIN */
{D7, 43, "pwm1", 0}, /* PWM */
{D8, 41},
{D9, 38, "pwm2", 0}, /* PWM */
{D10, 34},
{D11, 27},
{D12, 36},
{D13, 35},
{D14, 54, "pwm3", 2}, /* PWM */
{D15, 53},
{D16, 15, "i2c1"}, /* I2C-SCL (Wire) */
{D17, 14, "i2c1"}, /* I2C-SDA (Wire) */
{A0, 17, "adc0", 8}, /* ADC */
{A1, 24, "adc0", 0}, /* ADC */
{A2, RT_NULL, "adc0", 26}, /* ADC, On-Chip: internal temperature sensor, ADC_CHANNEL_TEMPSENSOR */
{A3, RT_NULL, "adc0", 13}, /* ADC, On-Chip: internal reference voltage, ADC_CHANNEL_VREFINT */
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-02-22 ChuShicheng 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 A0 (18)
#define A1 (19)
#define A2 (20)
#define A3 (21)

#define F_CPU 150000000L /* CPU:150MHz */

#define LED_BUILTIN D6 /* Default Built-in LED */

/* i2c1 : P-SDA P-SCL */
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"

#endif /* Pins_Arduino_h */
36 changes: 36 additions & 0 deletions bsp/lpc55sxx/lpc55s69_nxp_evk/board/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,18 @@ menu "On-chip Peripheral Drivers"
default y

if BSP_USING_PWM
config BSP_USING_CTIMER0_MAT3
bool "Enable CIMER0 Match3 as PWM output"
default y

config BSP_USING_CTIMER1_MAT0
bool "Enable CIMER1 Match0 as PWM output"
default y

config BSP_USING_CTIMER1_MAT3
bool "Enable CIMER1 Match3 as PWM output"
default y

config BSP_USING_CTIMER2_MAT0
bool "Enable CIMER2 Match0 as PWM output"
default y
Expand All @@ -191,6 +203,10 @@ menu "On-chip Peripheral Drivers"
config BSP_USING_CTIMER2_MAT2
bool "Enable CIMER2 Match2 as PWM output"
default n

config BSP_USING_CTIMER3_MAT2
bool "Enable CIMER3 Match2 as PWM output"
default n
endif
endmenu

Expand All @@ -215,6 +231,26 @@ menu "Onboard Peripheral Drivers"
default "i2c4"
endif

config BSP_USING_ARDUINO
bool "Compatible with Arduino Ecosystem (RTduino)"
select PKG_USING_RTDUINO
select BSP_USING_STLINK_TO_USART
select BSP_USING_GPIO
select BSP_USING_ADC
select BSP_USING_ADC0
select BSP_USING_PWM
select BSP_USING_CTIMER1_MAT0
select BSP_USING_CTIMER1_MAT3
select BSP_USING_CTIMER2_MAT0
select BSP_USING_CTIMER2_MAT1
select BSP_USING_CTIMER2_MAT2
select BSP_USING_CTIMER3_MAT2
select BSP_USING_I2C
select BSP_USING_I2C1
imply RTDUINO_USING_SERVO
imply RTDUINO_USING_WIRE
default n

endmenu

menu "Board extended module Drivers"
Expand Down
2 changes: 1 addition & 1 deletion bsp/lpc55sxx/lpc55s69_nxp_evk/rtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
PLATFORM = 'gcc'
EXEC_PATH = r'C:\Users\XXYYZZ'
elif CROSS_TOOL == 'keil':
PLATFORM = 'armcc'
PLATFORM = 'armclang'
EXEC_PATH = r'C:/Keil_v5'
elif CROSS_TOOL == 'iar':
PLATFORM = 'iccarm'
Expand Down