Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion bsp/nxp/mcx/mcxa/Libraries/drivers/drv_pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <rtthread.h>
#include <rtdevice.h>


#define GET_PINS(PORTx, PINx) (32 * PORTx + PINx)
extern int rt_hw_pin_init(void);

#endif /* __DRV_PIN_H__ */
14 changes: 14 additions & 0 deletions bsp/nxp/mcx/mcxa/frdm-mcxa346/.cl/attachconfig/RTduino.attach
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions bsp/nxp/mcx/mcxa/frdm-mcxa346/applications/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ src = Glob('*.c')

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)
for item in list:
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
Expand Down
25 changes: 25 additions & 0 deletions bsp/nxp/mcx/mcxa/frdm-mcxa346/applications/arduino_main.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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-pinout', src, depend = ['PKG_USING_RTDUINO'], CPPPATH = inc)

Return('group')
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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) */

};
Original file line number Diff line number Diff line change
@@ -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 */
18 changes: 18 additions & 0 deletions bsp/nxp/mcx/mcxa/frdm-mcxa346/board/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,24 @@ menu "On-chip Peripheral Drivers"
endif
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_PWM
select BSP_USING_ADC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的select不全,要依照你在pin_arduino.c中实际定义的外设全部选中,还有adc的通道,这块看看驱动上是怎么设计接口的,包括pwm通道

image

select BSP_USING_ADC0
select BSP_USING_ADC1
select BSP_USING_I2C
select BSP_USING_I2C1
select BSP_USING_I2C2
select BSP_USING_SPI
select BSP_USING_SPI1
default n
endmenu


menu "Board extended module Drivers"
menuconfig BSP_USING_RW007
Expand Down
Loading