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
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,3 @@ Peripheral.arduino:
kconfig:
- CONFIG_BSP_USING_ARDUINO=y

# ------ utest CI ------
utest.pin:
<<: *scons
kconfig:
- CONFIG_RT_USING_UTESTCASES=y
- CONFIG_RT_CONSOLEBUF_SIZE=256
- CONFIG_RT_UTEST_PIN=y

23 changes: 22 additions & 1 deletion bsp/nxp/mcx/mcxa/frdm-mcxa366/.config
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ CONFIG_RT_USING_SPI_ISR=y
# CONFIG_RT_USING_LCD is not set
# CONFIG_RT_USING_HWCRYPTO is not set
# CONFIG_RT_USING_WIFI is not set
# CONFIG_RT_USING_RPMSG is not set
# CONFIG_RT_USING_BLK is not set
# CONFIG_RT_USING_REGULATOR is not set
# CONFIG_RT_USING_POWER_SUPPLY is not set
Expand Down Expand Up @@ -836,7 +837,21 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_NRFX is not set
# CONFIG_PKG_USING_RASPBERRYPI_PICO_RP2350_SDK is not set
# CONFIG_PKG_USING_RASPBERRYPI_PICO_SDK is not set
# CONFIG_PKG_USING_MM32 is not set

#
# MM32 HAL & SDK Drivers
#
# CONFIG_PKG_USING_MM32F103XX_CMSIS is not set
# CONFIG_PKG_USING_MM32F3270X_CMSIS is not set
# CONFIG_PKG_USING_MM32F5260X_CMSIS is not set
# CONFIG_PKG_USING_MM32L0XX_CMSIS is not set
# CONFIG_PKG_USING_MM32L3XX_CMSIS is not set
# CONFIG_PKG_USING_MM32F103XX_HAL_DRIVER is not set
# CONFIG_PKG_USING_MM32F3270X_HAL_DRIVER is not set
# CONFIG_PKG_USING_MM32F5260X_HAL_DRIVER is not set
# CONFIG_PKG_USING_MM32L0XX_HAL_DRIVER is not set
# CONFIG_PKG_USING_MM32L3XX_HAL_DRIVER is not set
# end of MM32 HAL & SDK Drivers

#
# WCH HAL & SDK Drivers
Expand Down Expand Up @@ -930,6 +945,12 @@ CONFIG_PKG_NXP_MCX_SERIES_DRIVER_VER="latest"
# CONFIG_PKG_USING_FT32F4_STD_DRIVER is not set
# CONFIG_PKG_USING_FT32F4_CMSIS_DRIVER is not set
# end of FT32 HAL & SDK Drivers

#
# NOVOSNS Drivers
#
# CONFIG_PKG_USING_NOVOSNS_SERIES_DRIVER is not set
# end of NOVOSNS Drivers
# end of HAL & SDK Drivers

#
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// <<< Use Configuration Wizard in Context Menu >>>

// <o0> SWO pin
// <i> The SWO (Serial Wire Output) pin optionally provides data from the ITM
// <i> for an external debug tool to evaluate.
// <0=> PIO0_10
// <1=> PIO0_8
SWO_Pin = 0;
//

// <h>Debug Configuration
// <o.0> StopAfterBootloader <i> Stop after Bootloader
// </h>
Dbg_CR = 0x00000001;
//


// <<< end of configuration section >>>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// <<< Use Configuration Wizard in Context Menu >>>

// <o0> SWO pin
// <i> The SWO (Serial Wire Output) pin optionally provides data from the ITM
// <i> for an external debug tool to evaluate.
// <0=> PIO0_10
// <1=> PIO0_8
SWO_Pin = 0;
//

// <h>Debug Configuration
// <o.0> StopAfterBootloader <i> Stop after Bootloader
// </h>
Dbg_CR = 0x00000001;
//


// <<< end of configuration section >>>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// <<< Use Configuration Wizard in Context Menu >>>

// <o0> SWO pin
// <i> The SWO (Serial Wire Output) pin optionally provides data from the ITM
// <i> for an external debug tool to evaluate.
// <0=> PIO0_10
// <1=> PIO0_8
SWO_Pin = 0;
//

// <h>Debug Configuration
// <o.0> StopAfterBootloader <i> Stop after Bootloader
// </h>
Dbg_CR = 0x00000001;
//


// <<< end of configuration section >>>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// <<< Use Configuration Wizard in Context Menu >>>

// <o0> SWO pin
// <i> The SWO (Serial Wire Output) pin optionally provides data from the ITM
// <i> for an external debug tool to evaluate.
// <0=> PIO0_10
// <1=> PIO0_8
SWO_Pin = 0;
//

// <h>Debug Configuration
// <o.0> StopAfterBootloader <i> Stop after Bootloader
// </h>
Dbg_CR = 0x00000001;
//


// <<< end of configuration section >>>
65 changes: 64 additions & 1 deletion bsp/nxp/mcx/mcxa/frdm-mcxa366/applications/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,67 @@

#include <rtdevice.h>
#include "drv_pin.h"

#include <rtthread.h>
#define LED_PIN ((3*32)+18) /* Original LED pin */
#define BUTTON_PIN ((1*32)+7) /* P1_7 button pin */

static rt_bool_t led_state = RT_FALSE; /* Current LED state */

#define SAMPLE_UART1_NAME "uart3" /* 串口设备名称 */
static rt_device_t serial_uart3; /* 串口设备句柄 */
static struct rt_semaphore rx_sem; /* 用于接收消息的信号量 */
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; /* 初始化配置参数 */

/* 接收数据回调函数 */
static rt_err_t uart_input(rt_device_t dev,rt_size_t size)//接收数据回调(消息队列处理)函数
{
rt_sem_release(&rx_sem);//串口接收数据产生中断,调用该函数发送接收信号量
return RT_EOK;
}

/* 串口处理线程函数 */
static void serial_thread_entry(void* parameter)
{
char ch;
rt_kprintf("serial task run\n");
/* 接收到信号量后处理串口数据 */
while(1)
{
while(rt_device_read(serial_uart3,-1,&ch,1)!=1)//阻塞等待接收信号量,等到信号量后读取1个字节的数据
rt_sem_take(&rx_sem,RT_WAITING_FOREVER);
rt_device_write(serial_uart3,0,&ch,1);//读取到的数据通过串口错位输出
}
}

/* 串口主函数调用 */
static int uart_int_sample(void)
{
rt_err_t ret=RT_EOK;
char uart_name[RT_NAME_MAX];
char str[] = "RT-Thread MCX A366 uart3 Start!\n";
rt_strncpy(uart_name,SAMPLE_UART1_NAME,RT_NAME_MAX);
serial_uart3=rt_device_find(uart_name);//查找串口设备
if(!serial_uart3)
{
rt_kprintf("find %s failed!\n",uart_name);
return RT_ERROR;
}
rt_kprintf("start mq\n");
rt_device_open(serial_uart3,RT_DEVICE_FLAG_INT_RX);//以轮询方式打开串口
rt_sem_init(&rx_sem,"rx_sem",0,RT_IPC_FLAG_FIFO);//初始化信号量
rt_device_set_rx_indicate(serial_uart3,uart_input);//设置接收回调(消息队列处理)函数
rt_device_write(serial_uart3,0,str,(sizeof(str)-1));//发送字符串
rt_thread_t thread=rt_thread_create("serial",serial_thread_entry,RT_NULL,1024,25,10);//创建串口处理线程
if(thread!=RT_NULL)
{
rt_kprintf("start thread\n");
rt_thread_startup(thread);
}
else
ret=RT_ERROR;
return ret;//返回结果
}


/* Button interrupt callback function */
void button_irq_callback(void *args)
Expand Down Expand Up @@ -48,6 +103,8 @@ int main(void)

/* Configure button pin as input with pull-up */
rt_pin_mode(BUTTON_PIN, PIN_MODE_INPUT_PULLUP);

uart_int_sample();

/* Attach interrupt to button pin */
rt_pin_attach_irq(BUTTON_PIN, PIN_IRQ_MODE_FALLING, button_irq_callback, RT_NULL);
Expand All @@ -63,3 +120,9 @@ int main(void)
rt_thread_mdelay(500);
}
}

void cmd_reboot(void)
{
rt_hw_cpu_reset();
}
MSH_CMD_EXPORT_ALIAS(cmd_reboot, reboot, Reboot);
48 changes: 48 additions & 0 deletions bsp/nxp/mcx/mcxa/frdm-mcxa366/board/MCUX_Config/board/pin_mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,55 @@ void BOARD_InitPins(void)
/* PORT2_3 (pin 36) is configured as LPUART2_RXD */
PORT_SetPinConfig(PORT2, 3U, &port2_3_pin36_config);

const port_pin_config_t port4_2_pin_config = {/* Internal pull-up resistor is enabled */
.pullSelect = kPORT_PullUp,
/* Low internal pull resistor value is selected. */
.pullValueSelect = kPORT_LowPullResistor,
/* Fast slew rate is configured */
.slewRate = kPORT_FastSlewRate,
/* Passive input filter is disabled */
.passiveFilterEnable = kPORT_PassiveFilterDisable,
/* Open drain output is disabled */
.openDrainEnable = kPORT_OpenDrainDisable,
/* Low drive strength is configured */
.driveStrength = kPORT_LowDriveStrength,
/* Normal drive strength is configured */
.driveStrength1 = kPORT_NormalDriveStrength,
/* Pin is configured as LPUART2_TXD */
.mux = kPORT_MuxAlt3,
/* Digital input enabled */
.inputBuffer = kPORT_InputBufferEnable,
/* Digital input is not inverted */
.invertInput = kPORT_InputNormal,
/* Pin Control Register fields [15:0] are not locked */
.lockRegister = kPORT_UnlockRegister};
/* PORT2_2 (pin 35) is configured as LPUART2_TXD */
PORT_SetPinConfig(PORT4, 2U, &port4_2_pin_config);

const port_pin_config_t port4_5_pin_config = {/* Internal pull-up resistor is enabled */
.pullSelect = kPORT_PullUp,
/* Low internal pull resistor value is selected. */
.pullValueSelect = kPORT_LowPullResistor,
/* Fast slew rate is configured */
.slewRate = kPORT_FastSlewRate,
/* Passive input filter is disabled */
.passiveFilterEnable = kPORT_PassiveFilterDisable,
/* Open drain output is disabled */
.openDrainEnable = kPORT_OpenDrainDisable,
/* Low drive strength is configured */
.driveStrength = kPORT_LowDriveStrength,
/* Normal drive strength is configured */
.driveStrength1 = kPORT_NormalDriveStrength,
/* Pin is configured as LPUART2_RXD */
.mux = kPORT_MuxAlt3,
/* Digital input enabled */
.inputBuffer = kPORT_InputBufferEnable,
/* Digital input is not inverted */
.invertInput = kPORT_InputNormal,
/* Pin Control Register fields [15:0] are not locked */
.lockRegister = kPORT_UnlockRegister};
/* PORT2_3 (pin 36) is configured as LPUART2_RXD */
PORT_SetPinConfig(PORT4, 5U, &port4_5_pin_config);
const port_pin_config_t LED_RED = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* Low internal pull resistor value is selected. */
Expand Down
Loading
Loading