[add][RTduino] Fitter RTduino in frdm-mcxa346 (#11067)

* add mcxa346-RTduino
This commit is contained in:
xiyao
2026-01-06 09:37:55 +08:00
committed by GitHub
parent 9d1d4a08a9
commit 45511af114
11 changed files with 173 additions and 1 deletions

View File

@@ -16,7 +16,7 @@
#include <rtthread.h> #include <rtthread.h>
#include <rtdevice.h> #include <rtdevice.h>
#define GET_PINS(PORTx, PINx) (32 * PORTx + PINx)
extern int rt_hw_pin_init(void); extern int rt_hw_pin_init(void);
#endif /* __DRV_PIN_H__ */ #endif /* __DRV_PIN_H__ */

View File

@@ -0,0 +1,14 @@
CONFIG_PKG_USING_RTDUINO=y
CONFIG_PKG_RTDUINO_PATH="/packages/arduino/RTduino"
CONFIG_RTDUINO_THREAD_SIZE=2048
CONFIG_RTDUINO_THREAD_PRIO=30
CONFIG_RTDUINO_SUPPORT_HIGH_PRECISION_MICROS=y
CONFIG_PKG_USING_RTDUINO_LATEST_VERSION=y
CONFIG_PKG_RTDUINO_VER="latest"
CONFIG_BSP_USING_I2C=y
CONFIG_BSP_USING_I2C3=y
CONFIG_BSP_USING_SPI=y
CONFIG_BSP_USING_SPI1=y
CONFIG_BSP_USING_ADC=y
CONFIG_BSP_USING_PWM=y
CONFIG_BSP_USING_ARDUINO=y

View File

@@ -7,6 +7,9 @@ src = Glob('*.c')
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH) group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
if GetDepend(['PKG_USING_RTDUINO']) and not GetDepend(['RTDUINO_NO_SETUP_LOOP']):
src += ['arduino_main.cpp']
list = os.listdir(cwd) list = os.listdir(cwd)
for item in list: for item in list:
if os.path.isfile(os.path.join(cwd, item, 'SConscript')): if os.path.isfile(os.path.join(cwd, item, 'SConscript')):

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 KiB

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
* 2025-12-08 westcity-yolo first version
*
*/
#include <Arduino.h>
#include <board.h>
#include <drv_pin.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, GET_PINS(2,3), "uart2"}, /* Serial2-RX */
{D1, GET_PINS(2,2), "uart2"}, /* Serial2-TX */
{D2, GET_PINS(3,31)},
{D3, GET_PINS(3,14), "pwm1", 1}, /* PWM */
{D4, GET_PINS(4,7)},
{D5, GET_PINS(3,1), "pwm0", 0}, /* PWM */
{D6, GET_PINS(3,17), "pwm1", 0}, /* PWM */
{D7, GET_PINS(3,22)},
{D8, GET_PINS(4,3)},
{D9, GET_PINS(3,13), "pwm1", 2}, /* PWM */
{D10, GET_PINS(3,11),"spi1"}, /* SPI-SS */
{D11, GET_PINS(3,8), "spi1"}, /* SPI-SDO */
{D12, GET_PINS(3,9), "spi1"}, /* SPI-SDI */
{D13, GET_PINS(3,10),"spi1"}, /* SPI-SCK */
{D18, GET_PINS(1,8),"i2c2"}, /* I2C-SDA (Wire) */
{D19, GET_PINS(1,9),"i2c2"}, /* I2C-SCL (Wire) */
{A0, GET_PINS(1,14),"adc1", 12}, /* ADC */
{A1, GET_PINS(2,5), "adc1", 1}, /* ADC */
{A2, GET_PINS(2,7),"adc0", 7}, /* ADC */
{A3, GET_PINS(3,30),"adc1", 21},
{A4, GET_PINS(1,0),"i2c1"}, /* I2C-SDA (Wire) */
{A5, GET_PINS(1,1),"i2c1"}, /* I2C-SCL (Wire) */
};

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2025-12-08 westcity-yolo 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 D18 (14)
#define D19 (15)
#define A0 (16)
#define A1 (17)
#define A2 (18)
#define A3 (19)
#define A4 (20)
#define A5 (21)
#define A6 (22)
#define A7 (23)
#define RTDUINO_PIN_MAX_LIMIT A7 /* pin number max limit check */
#define F_CPU 180000000L /* CPU:180MHz */
/* i2c2 : P(,1_8-SDA P(,1_9-SCL */
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c2"
/* Serial2 : P(,2_2-TX P(,2_3-RX */
#define RTDUINO_SERIAL2_DEVICE_NAME "uart2"
/* spi1 : P(,3_8-SDO P(,3_9-SDI P(,3_10-SCK P(,3_11-SS */
#define RTDUINO_DEFAULT_SPI_BUS_NAME "spi1"
#endif /* Pins_Arduino_h */

View File

@@ -139,6 +139,20 @@ menu "On-chip Peripheral Drivers"
endmenu endmenu
menu "Onboard Peripheral Drivers"
config BSP_USING_ARDUINO
bool "Compatible with Arduino Ecosystem (RTduino)"
select PKG_USING_RTDUINO
select BSP_USING_UART2
select BSP_USING_GPIO
select BSP_USING_ADC0
select BSP_USING_PWM0
select BSP_USING_PWM1
select BSP_USING_I2C1
select BSP_USING_I2C2
select BSP_USING_SPI1
endmenu
menu "Board extended module Drivers" menu "Board extended module Drivers"
menuconfig BSP_USING_RW007 menuconfig BSP_USING_RW007