nxp bsp support: frdm-mcxa346 (#10625)

* update nxp mcxa driver to support frdm-mcxa346

* update NXP bsp README

* update frdm-mcxa346 project
This commit is contained in:
杨熙
2025-08-21 11:06:06 +08:00
committed by GitHub
parent 0ef17c91cc
commit 3fbd23bc63
16 changed files with 1123 additions and 282 deletions

View File

@@ -1,8 +1,41 @@
# NXP BSP 说明
# NXP BSP 支持说明
存放RT-Thread NXP BSP目录目前支持MCX系列之前一些老的IC支持(如LPC/Kinetis/I.MXRT)会逐步放到此目录下
NXP 系列 BSP 目前支持情况如下表所示:
| BSP 文件夹名称 | 开发板名称 |
|:------------------------- |:-------------------------- |
| mcxn | frdm-mcxn947 |
| mcxa | frdm-mcxa153 |
| **BSP 文件夹名称** | **开发板名称** |
|:------------------------------------------------ |:----------------------------------- |
| **MCXN 系列** | |
| [frdm-mcxn947](mcx/mcxn/frdm-mcxn947) | NXP 官方 FRDM-MCXN947 开发板 |
| [frdm-mcxn236](mcx/mcxn/frdm-mcxn236) | NXP 官方 FRDM-MCXN236 开发板 |
| **MCXA 系列** | |
| [frdm-mcxa153](mcx/mcxa/frdm-mcxa153) | NXP 官方 FRDM-MCXA153 开发板 |
| [frdm-mcxa156](mcx/mcxa/frdm-mcxa156) | NXP 官方 FRDM-MCXA156 开发板 |
| [frdm-mcxa346](mcx/mcxa/frdm-mcxa346) | NXP 官方 FRDM-MCXA346 开发板 |
| [frdm-mcxa344](mcx/mcxa/frdm-mcxa344) | NXP 官方 FRDM-MCXA344 开发板 |
| **MCXC 系列** | |
| [frdm-mcxc444](mcx/mcxc/frdm-mcxc444) | NXP 官方 FRDM-MCXC444 开发板 |
| **LPC 系列** | |
| [lpc43xx](lpc/lpc43xx) | NXP LPC43xx 系列开发板 |
| [lpc55sxx](lpc/lpc55sxx) | NXP LPC55Sxx 系列开发板 |
| [lpc176x](lpc/lpc176x) | NXP LPC176x 系列开发板 |
| [lpc178x](lpc/lpc178x) | NXP LPC178x 系列开发板 |
| [lpc408x](lpc/lpc408x) | NXP LPC408x 系列开发板 |
| [lpc824](lpc/lpc824) | NXP LPC824 开发板 |
| [lpc1114](lpc/lpc1114) | NXP LPC1114 开发板 |
| [lpc2148](lpc/lpc2148) | NXP LPC2148 开发板 |
| [lpc2478](lpc/lpc2478) | NXP LPC2478 开发板 |
| [lpc5410x](lpc/lpc5410x) | NXP LPC5410x 系列开发板 |
| [lpc54114-lite](lpc/lpc54114-lite) | NXP LPC54114-Lite 开发板 |
| [lpc54608-lpcxpresso](lpc/lpc54608-lpcxpresso) | NXP 官方 LPC54608-LPCXpresso 开发板 |
另外,我们还提供了一些热门开发板的上手说明:
* [NXP FRDM-MCXN947上手指南](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/tutorial/quick-start/frdm_mcxn947/quick-start)
* [NXP FRDM-MCXA156上手指南](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/tutorial/quick-start/frdm_mcxa156/quick-start)
## 注意事项
- MCX 系列是 NXP 最新推出的 MCU 系列,具有高性能和低功耗特性
- 部分老旧系列LPC/Kinetis/i.MX RT正在逐步迁移和更新中
- 建议优先选择 MCX 系列进行新项目开发
- 各系列 BSP 的具体支持功能请参考对应目录下的 README 文档

View File

@@ -14,6 +14,10 @@
#include "fsl_lpadc.h"
#include "fsl_spc.h"
#define DBG_TAG "drv.adc"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#ifdef RT_USING_ADC
#define DEFAULT_HW_AVG (kLPADC_HardwareAverageCount4)

View File

@@ -16,16 +16,27 @@
#ifdef RT_USING_I2C
#define DBG_TAG "drv.i2c"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
enum
{
#ifdef BSP_USING_I2C0
I2C0_INDEX,
#endif
#ifdef BSP_USING_I2C1
I2C1_INDEX,
#endif
#ifdef BSP_USING_I2C2
I2C2_INDEX,
#endif
#ifdef BSP_USING_I2C3
I2C3_INDEX,
#endif
};
#define i2c_dbg rt_kprintf
struct lpc_i2c_bus
{
struct rt_i2c_bus_device parent;
@@ -44,12 +55,58 @@ struct lpc_i2c_bus lpc_obj[] =
{
.I2C = LPI2C0,
.baud = 100000U,
#if (defined(CPU_MCXA346VLH) || defined(CPU_MCXA346VLL) || defined(CPU_MCXA346VLQ) || defined(CPU_MCXA346VPN))
.clock_attach_id = kFRO_LF_DIV_to_LPI2C0,
#else
.clock_attach_id = kFRO12M_to_LPI2C0,
#endif
.clock_div_name = kCLOCK_DivLPI2C0,
.clock_src = kCLOCK_Fro12M,
.name = "i2c0",
},
#endif
#ifdef BSP_USING_I2C1
{
.I2C = LPI2C1,
.baud = 100000U,
#if (defined(CPU_MCXA346VLH) || defined(CPU_MCXA346VLL) || defined(CPU_MCXA346VLQ) || defined(CPU_MCXA346VPN))
.clock_attach_id = kFRO_LF_DIV_to_LPI2C1,
#else
.clock_attach_id = kFRO12M_to_LPI2C1,
#endif
.clock_div_name = kCLOCK_DivLPI2C1,
.clock_src = kCLOCK_Fro12M,
.name = "i2c1",
},
#endif
#ifdef BSP_USING_I2C2
{
.I2C = LPI2C2,
.baud = 100000U,
#if (defined(CPU_MCXA346VLH) || defined(CPU_MCXA346VLL) || defined(CPU_MCXA346VLQ) || defined(CPU_MCXA346VPN))
.clock_attach_id = kFRO_LF_DIV_to_LPI2C2,
#else
.clock_attach_id = kFRO12M_to_LPI2C2,
#endif
.clock_div_name = kCLOCK_DivLPI2C2,
.clock_src = kCLOCK_Fro12M,
.name = "i2c2",
},
#endif
#ifdef BSP_USING_I2C3
{
.I2C = LPI2C3,
.baud = 100000U,
#if (defined(CPU_MCXA346VLH) || defined(CPU_MCXA346VLL) || defined(CPU_MCXA346VLQ) || defined(CPU_MCXA346VPN))
.clock_attach_id = kFRO_LF_DIV_to_LPI2C3,
#else
.clock_attach_id = kFRO12M_to_LPI2C3,
#endif
.clock_div_name = kCLOCK_DivLPI2C3,
.clock_src = kCLOCK_Fro12M,
.name = "i2c3",
},
#endif
};
static rt_ssize_t lpc_i2c_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num)
@@ -80,7 +137,7 @@ static rt_ssize_t lpc_i2c_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg
if (LPI2C_MasterTransferBlocking(lpc_i2c->I2C, &xfer) != kStatus_Success)
{
i2c_dbg("i2c bus read failed!\n");
LOG_D("i2c bus read failed!\n");
return i;
}
}
@@ -99,7 +156,7 @@ static rt_ssize_t lpc_i2c_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg
if (LPI2C_MasterTransferBlocking(lpc_i2c->I2C, &xfer) != kStatus_Success)
{
i2c_dbg("i2c bus write failed!\n");
LOG_D("i2c bus write failed!\n");
return i;
}
}

View File

@@ -17,22 +17,25 @@
#ifdef RT_USING_PIN
#define DBG_TAG "drv.pin"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#define GET_GPIO_PORT(x) ((x) / 32)
#define GET_GPIO_PIN(x) ((x) % 32)
static struct rt_pin_ops mcx_pin_ops;
static GPIO_Type *GPIO_TYPE_TBL[] = {GPIO0, GPIO1, GPIO2, GPIO3};
static PORT_Type *PORT_TYPE_TBL[] = {PORT0, PORT1, PORT2, PORT3};
static IRQn_Type IRQ_TYPE_TBL[] = {GPIO0_IRQn, GPIO1_IRQn, GPIO2_IRQn, GPIO3_IRQn};
static GPIO_Type *GPIO_TYPE_TBL[] = GPIO_BASE_PTRS;
static PORT_Type *PORT_TYPE_TBL[] = PORT_BASE_PTRS;
static IRQn_Type IRQ_TYPE_TBL[] = GPIO_IRQS;
#define PIN2GPIO(x) GPIO_TYPE_TBL[GET_GPIO_PORT(x)]
#define PIN2PORT(x) PORT_TYPE_TBL[GET_GPIO_PORT(x)]
#define PIN2IRQ(x) IRQ_TYPE_TBL[GET_GPIO_PORT(x)]
struct rt_pin_irq_hdr pin_irq_hdr_tab[32*4] = {0};
struct rt_pin_irq_hdr pin_irq_hdr_tab[32*5] = {0};
static void mcx_pin_mode(rt_device_t dev, rt_base_t pin, rt_uint8_t mode)
{
@@ -143,6 +146,11 @@ void GPIO3_IRQHandler(void)
pin_irq_handler(3);
}
void GPIO4_IRQHandler(void)
{
pin_irq_handler(4);
}
static rt_err_t mcx_pin_attach_irq(struct rt_device *device, rt_base_t pin, rt_uint8_t mode, void (*hdr)(void *args), void *args)
{

View File

@@ -0,0 +1,278 @@
/*
* Copyright (c) 2006-2025, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2025-08-19 Alex Yang Add MCXA346 RTC driver for RT-Thread
*/
#include <rtthread.h>
#include <rtdevice.h>
#include <sys/time.h>
#ifdef BSP_USING_RTC
#define DBG_TAG "drv.rtc"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#include "fsl_rtc.h"
#include "fsl_clock.h"
/* Get RTC timestamp */
static time_t get_rtc_timestamp(void)
{
rtc_datetime_t datetime;
struct tm tm_new;
/* Get current time from RTC */
RTC_GetDatetime(RTC0, &datetime);
tm_new.tm_sec = datetime.second;
tm_new.tm_min = datetime.minute;
tm_new.tm_hour = datetime.hour;
tm_new.tm_mday = datetime.day;
tm_new.tm_mon = datetime.month - 1;
tm_new.tm_year = datetime.year - 1900;
tm_new.tm_isdst = 0;
LOG_D("get rtc time: %04d-%02d-%02d %02d:%02d:%02d",
datetime.year, datetime.month, datetime.day,
datetime.hour, datetime.minute, datetime.second);
return mktime(&tm_new);
}
/* Set RTC timestamp */
static rt_err_t set_rtc_time_stamp(time_t time_stamp)
{
rtc_datetime_t datetime;
struct tm *time_tm;
time_tm = gmtime(&time_stamp);
if (time_tm->tm_year < 70) /* Year should be >= 1970 */
{
LOG_E("Invalid year: %d", time_tm->tm_year + 1900);
return -RT_ERROR;
}
/* Convert to RTC datetime format */
datetime.year = time_tm->tm_year + 1900;
datetime.month = time_tm->tm_mon + 1;
datetime.day = time_tm->tm_mday;
datetime.hour = time_tm->tm_hour;
datetime.minute = time_tm->tm_min;
datetime.second = time_tm->tm_sec;
/* Set RTC time */
RTC_StopTimer(RTC0);
RTC_SetDatetime(RTC0, &datetime);
RTC_StartTimer(RTC0);
LOG_D("set rtc time: %04d-%02d-%02d %02d:%02d:%02d",
datetime.year, datetime.month, datetime.day,
datetime.hour, datetime.minute, datetime.second);
return RT_EOK;
}
/* RTC configuration */
static rt_err_t rt_rtc_config(void)
{
rtc_config_t rtc_config;
/* Get default RTC configuration */
RTC_GetDefaultConfig(&rtc_config);
/* Initialize RTC - Note: RTC_Init returns void, not status */
RTC_Init(RTC0, &rtc_config);
/* Start RTC timer */
RTC_StartTimer(RTC0);
return RT_EOK;
}
/* RTC initialization */
static rt_err_t _rtc_init(void)
{
/* Configure RTC */
if (rt_rtc_config() != RT_EOK)
{
LOG_E("RTC config failed.");
return -RT_ERROR;
}
LOG_D("RTC initialized successfully");
return RT_EOK;
}
/* Get RTC seconds */
static rt_err_t _rtc_get_secs(time_t *args)
{
RT_ASSERT(args != RT_NULL);
*args = get_rtc_timestamp();
LOG_D("RTC: get rtc_time %x", *args);
return RT_EOK;
}
/* Set RTC seconds */
static rt_err_t _rtc_set_secs(time_t *args)
{
rt_err_t result = RT_EOK;
RT_ASSERT(args != RT_NULL);
if (set_rtc_time_stamp(*args) != RT_EOK)
{
result = -RT_ERROR;
}
LOG_D("RTC: set rtc_time %x", *args);
return result;
}
/* Get RTC alarm */
static rt_err_t _rtc_get_alarm(struct rt_rtc_wkalarm *wkalarm)
{
rtc_datetime_t datetime;
RT_ASSERT(wkalarm != RT_NULL);
/* Get alarm time from RTC */
RTC_GetAlarm(RTC0, &datetime);
/* Convert to wkalarm format */
wkalarm->tm_sec = datetime.second;
wkalarm->tm_min = datetime.minute;
wkalarm->tm_hour = datetime.hour;
wkalarm->tm_mday = datetime.day;
wkalarm->tm_mon = datetime.month - 1;
wkalarm->tm_year = datetime.year - 1900;
/* Check if alarm is enabled */
wkalarm->enable = (RTC_GetEnabledInterrupts(RTC0) & kRTC_AlarmInterruptEnable) ? 1 : 0;
LOG_D("RTC: get alarm %04d-%02d-%02d %02d:%02d:%02d (%s)",
datetime.year, datetime.month, datetime.day,
datetime.hour, datetime.minute, datetime.second,
wkalarm->enable ? "ENABLED" : "DISABLED");
return RT_EOK;
}
/* Set RTC alarm */
static rt_err_t _rtc_set_alarm(struct rt_rtc_wkalarm *wkalarm)
{
rtc_datetime_t datetime;
RT_ASSERT(wkalarm != RT_NULL);
/* Convert from wkalarm format */
datetime.year = wkalarm->tm_year + 1900;
datetime.month = wkalarm->tm_mon + 1;
datetime.day = wkalarm->tm_mday;
datetime.hour = wkalarm->tm_hour;
datetime.minute = wkalarm->tm_min;
datetime.second = wkalarm->tm_sec;
/* Set alarm time */
RTC_SetAlarm(RTC0, &datetime);
/* Enable/disable alarm interrupt */
if (wkalarm->enable)
{
RTC_EnableInterrupts(RTC0, kRTC_AlarmInterruptEnable);
EnableIRQ(RTC_IRQn); /* Use RTC_IRQn instead of RTC0_IRQn */
LOG_D("RTC alarm enabled");
}
else
{
RTC_DisableInterrupts(RTC0, kRTC_AlarmInterruptEnable);
LOG_D("RTC alarm disabled");
}
LOG_D("RTC: set alarm %04d-%02d-%02d %02d:%02d:%02d",
datetime.year, datetime.month, datetime.day,
datetime.hour, datetime.minute, datetime.second);
return RT_EOK;
}
/* RTC operations structure */
static const struct rt_rtc_ops _rtc_ops =
{
_rtc_init,
_rtc_get_secs,
_rtc_set_secs,
_rtc_get_alarm,
_rtc_set_alarm,
RT_NULL, /* get_timeval */
RT_NULL, /* set_timeval */
};
static rt_rtc_dev_t mcxa_rtc_dev;
/* RTC interrupt handler */
void RTC_IRQHandler(void)
{
rt_interrupt_enter();
/* Get interrupt status */
uint32_t status = RTC_GetStatusFlags(RTC0);
/* Handle alarm interrupt */
if (status & kRTC_AlarmFlag)
{
/* Clear alarm flag */
RTC_ClearStatusFlags(RTC0, kRTC_AlarmFlag);
LOG_D("RTC alarm triggered");
/* If alarm framework is available, notify it */
#ifdef RT_USING_ALARM
/* Send alarm event to alarm thread */
rt_event_send(&_container.event, 1);
#endif
}
/* Handle seconds interrupt if needed */
if (status & kRTC_SecondsInterruptEnable)
{
LOG_D("RTC seconds interrupt");
}
rt_interrupt_leave();
}
/* Hardware RTC initialization */
int rt_hw_rtc_init(void)
{
rt_err_t result;
/* Set RTC operations */
mcxa_rtc_dev.ops = &_rtc_ops;
/* Register RTC device */
result = rt_hw_rtc_register(&mcxa_rtc_dev, "rtc", RT_DEVICE_FLAG_RDWR, RT_NULL);
if (result != RT_EOK)
{
LOG_E("RTC register failed, err code: %d", result);
return result;
}
LOG_D("RTC init success");
return RT_EOK;
}
INIT_DEVICE_EXPORT(rt_hw_rtc_init);
#endif /* BSP_USING_RTC */

View File

@@ -10,9 +10,13 @@
#include "rtdevice.h"
#include "drv_spi.h"
#include "fsl_lpspi.h"
#include "fsl_lpspi_edma.h"
#define DMA_MAX_TRANSFER_SIZE (32767)
#ifdef RT_USING_SPI
#define DBG_TAG "drv.spi"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
enum
{
@@ -32,14 +36,6 @@ struct lpc_spi
clock_div_name_t clock_div_name;
clock_name_t clock_name;
DMA_Type *DMAx;
uint8_t tx_dma_chl;
uint8_t rx_dma_chl;
edma_handle_t dma_tx_handle;
edma_handle_t dma_rx_handle;
dma_request_source_t tx_dma_request;
dma_request_source_t rx_dma_request;
lpspi_master_edma_handle_t spi_dma_handle;
rt_sem_t sem;
char *name;
@@ -50,28 +46,26 @@ static struct lpc_spi lpc_obj[] =
#ifdef BSP_USING_SPI0
{
.LPSPIx = LPSPI0,
#if (defined(CPU_MCXA346VLH) || defined(CPU_MCXA346VLL) || defined(CPU_MCXA346VLQ) || defined(CPU_MCXA346VPN))
kFRO_LF_DIV_to_LPSPI0,
#else
.clock_attach_id = kFRO12M_to_LPSPI0,
#endif
.clock_div_name = kCLOCK_DivLPSPI0,
.clock_name = kCLOCK_Fro12M,
.tx_dma_request = kDma0RequestLPSPI0Tx,
.rx_dma_request = kDma0RequestLPSPI0Rx,
.DMAx = DMA0,
.tx_dma_chl = 0,
.rx_dma_chl = 1,
.name = "spi0",
},
#endif
#ifdef BSP_USING_SPI1
{
.LPSPIx = LPSPI1,
#if (defined(CPU_MCXA346VLH) || defined(CPU_MCXA346VLL) || defined(CPU_MCXA346VLQ) || defined(CPU_MCXA346VPN))
kFRO_LF_DIV_to_LPSPI1,
#else
.clock_attach_id = kFRO12M_to_LPSPI1,
#endif
.clock_div_name = kCLOCK_DivLPSPI1,
.clock_name = kCLOCK_Fro12M,
.tx_dma_request = kDma0RequestLPSPI1Tx,
.rx_dma_request = kDma0RequestLPSPI1Rx,
.DMAx = DMA0,
.tx_dma_chl = 0,
.rx_dma_chl = 1,
.name = "spi1",
},
#endif
@@ -93,17 +87,12 @@ static rt_err_t spi_configure(struct rt_spi_device *device, struct rt_spi_config
return RT_EOK;
}
static void LPSPI_MasterUserCallback(LPSPI_Type *base, lpspi_master_edma_handle_t *handle, status_t status, void *userData)
{
struct lpc_spi *spi = (struct lpc_spi *)userData;
rt_sem_release(spi->sem);
}
static rt_ssize_t spixfer(struct rt_spi_device *device, struct rt_spi_message *message)
{
int i;
lpspi_transfer_t transfer = {0};
status_t status;
RT_ASSERT(device != RT_NULL);
RT_ASSERT(device->bus != RT_NULL);
@@ -119,40 +108,25 @@ static rt_ssize_t spixfer(struct rt_spi_device *device, struct rt_spi_message *m
transfer.dataSize = message->length;
transfer.rxData = (uint8_t *)(message->recv_buf);
transfer.txData = (uint8_t *)(message->send_buf);
transfer.configFlags = kLPSPI_MasterPcs0;
/* if(message->length < MAX_DMA_TRANSFER_SIZE)*/
uint32_t block, remain;
block = message->length / DMA_MAX_TRANSFER_SIZE;
remain = message->length % DMA_MAX_TRANSFER_SIZE;
for (i = 0; i < block; i++)
{
transfer.dataSize = DMA_MAX_TRANSFER_SIZE;
if (message->recv_buf) transfer.rxData = (uint8_t *)(message->recv_buf + i *DMA_MAX_TRANSFER_SIZE);
if (message->send_buf) transfer.txData = (uint8_t *)(message->send_buf + i *DMA_MAX_TRANSFER_SIZE);
LPSPI_MasterTransferEDMA(spi->LPSPIx, &spi->spi_dma_handle, &transfer);
rt_sem_take(spi->sem, RT_WAITING_FOREVER);
}
if (remain)
{
transfer.dataSize = remain;
if (message->recv_buf) transfer.rxData = (uint8_t *)(message->recv_buf + i *DMA_MAX_TRANSFER_SIZE);
if (message->send_buf) transfer.txData = (uint8_t *)(message->send_buf + i *DMA_MAX_TRANSFER_SIZE);
LPSPI_MasterTransferEDMA(spi->LPSPIx, &spi->spi_dma_handle, &transfer);
rt_sem_take(spi->sem, RT_WAITING_FOREVER);
}
// Use blocking transfer instead of DMA
status = LPSPI_MasterTransferBlocking(spi->LPSPIx, &transfer);
if (message->cs_release)
{
rt_pin_write(device->cs_pin, PIN_HIGH);
}
if (status != kStatus_Success)
{
return 0; // Transfer failed
}
return message->length;
}
static struct rt_spi_ops lpc_spi_ops =
{
.configure = spi_configure,
@@ -173,23 +147,18 @@ int rt_hw_spi_init(void)
lpspi_master_config_t masterConfig;
LPSPI_MasterGetDefaultConfig(&masterConfig);
masterConfig.baudRate = 1 * 1000 * 1000;
masterConfig.baudRate = 10 * 1000 * 1000;
masterConfig.pcsToSckDelayInNanoSec = 1000000000U / masterConfig.baudRate * 1U;
masterConfig.lastSckToPcsDelayInNanoSec = 1000000000U / masterConfig.baudRate * 1U;
masterConfig.betweenTransferDelayInNanoSec = 1000000000U / masterConfig.baudRate * 1U;
LPSPI_MasterInit(lpc_obj[i].LPSPIx, &masterConfig, CLOCK_GetFreq(lpc_obj[i].clock_name));
EDMA_CreateHandle(&lpc_obj[i].dma_tx_handle, lpc_obj[i].DMAx, lpc_obj[i].tx_dma_chl);
EDMA_CreateHandle(&lpc_obj[i].dma_rx_handle, lpc_obj[i].DMAx, lpc_obj[i].rx_dma_chl);
EDMA_SetChannelMux(lpc_obj[i].DMAx, lpc_obj[i].tx_dma_chl, lpc_obj[i].tx_dma_request);
EDMA_SetChannelMux(lpc_obj[i].DMAx, lpc_obj[i].rx_dma_chl, lpc_obj[i].rx_dma_request);
LPSPI_MasterTransferCreateHandleEDMA(lpc_obj[i].LPSPIx, &lpc_obj[i].spi_dma_handle, LPSPI_MasterUserCallback, &lpc_obj[i], &lpc_obj[i].dma_rx_handle, &lpc_obj[i].dma_tx_handle);
rt_spi_bus_register(&lpc_obj[i].parent, lpc_obj[i].name, &lpc_spi_ops);
}
return RT_EOK;
}
INIT_DEVICE_EXPORT(rt_hw_spi_init);
#endif /* RT_USING_SPI */

View File

@@ -14,6 +14,10 @@
#ifdef RT_USING_SERIAL
#define DBG_TAG "drv.uart"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
struct mcx_uart
{
struct rt_serial_device *serial;

View File

@@ -0,0 +1,73 @@
#include <rtthread.h>
#ifdef BSP_USING_RW007
#include <rtdbg.h>
#include <rtdevice.h>
#include <board.h>
#include <spi_wifi_rw007.h>
#define BOARD_RW007_DEVICE_NAME "rw007"
extern void spi_wifi_isr(int vector);
static void rw007_gpio_init(void)
{
/* Configure IO */
rt_pin_mode(BOARD_RW007_RST_PIN, PIN_MODE_OUTPUT);
rt_pin_mode(BOARD_RW007_INT_BUSY_PIN, PIN_MODE_INPUT_PULLDOWN);
/* Reset rw007 and config mode */
rt_pin_write(BOARD_RW007_RST_PIN, PIN_LOW);
rt_thread_delay(rt_tick_from_millisecond(100));
rt_pin_write(BOARD_RW007_RST_PIN, PIN_HIGH);
/* Wait rw007 ready(exit busy stat) */
while (!rt_pin_read(BOARD_RW007_INT_BUSY_PIN))
{
rt_thread_delay(5);
}
rt_thread_delay(rt_tick_from_millisecond(200));
rt_pin_mode(BOARD_RW007_INT_BUSY_PIN, PIN_MODE_INPUT_PULLUP);
}
int wifi_spi_device_init(void)
{
int ret = 0;
char sn_version[32];
struct rt_spi_device *spi_device = rt_malloc(sizeof(struct rt_spi_device));
if (!spi_device) return -1;
rw007_gpio_init();
ret = rt_spi_bus_attach_device_cspin(spi_device, BOARD_RW007_DEVICE_NAME, BOARD_RW007_SPI_BUS_NAME, BOARD_RW007_CS_PIN, RT_NULL);
if (ret != RT_EOK) return -2;
rt_hw_wifi_init("rw007");
rt_wlan_set_mode(RT_WLAN_DEVICE_STA_NAME, RT_WLAN_STATION);
rt_wlan_set_mode(RT_WLAN_DEVICE_AP_NAME, RT_WLAN_AP);
rw007_sn_get(sn_version);
rt_kprintf("\nrw007 sn: [%s]\n", sn_version);
rw007_version_get(sn_version);
rt_kprintf("rw007 ver: [%s]\n\n", sn_version);
return 0;
}
INIT_APP_EXPORT(wifi_spi_device_init);
static void int_wifi_irq(void *p)
{
((void)p);
spi_wifi_isr(0);
}
void spi_wifi_hw_init(void)
{
rt_pin_attach_irq(BOARD_RW007_INT_BUSY_PIN, PIN_IRQ_MODE_FALLING, int_wifi_irq, 0);
rt_pin_irq_enable(BOARD_RW007_INT_BUSY_PIN, RT_TRUE);
}
#endif

View File

@@ -9,18 +9,27 @@
* 2019-10-24 Magicoe first version
* 2020-01-10 Kevin/Karl Add PS demo
* 2020-09-21 supperthomas fix the main.c
* 2025-08-18 Alex Yang Add P1_7 button with LED blink control
*
*/
#include <rtdevice.h>
#include "drv_pin.h"
#define LED_PIN ((3*32)+18)
#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 */
/* Button interrupt callback function */
void button_irq_callback(void *args)
{
rt_kprintf("SW2 pressed\n");
}
int main(void)
{
#if defined(__CC_ARM)
rt_kprintf("using armcc, version: %d\n", __ARMCC_VERSION);
#elif defined(__clang__)
@@ -31,16 +40,26 @@ int main(void)
rt_kprintf("using gcc, version: %d.%d\n", __GNUC__, __GNUC_MINOR__);
#endif
rt_kprintf("MCXA346 HelloWorld\r\n");
rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT); /* Set GPIO as Output */
rt_kprintf("FRDM-MCXA346\r\n");
/* Configure LED pin as output */
rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT);
rt_pin_write(LED_PIN, PIN_LOW);
/* Configure button pin as input with pull-up */
rt_pin_mode(BUTTON_PIN, PIN_MODE_INPUT_PULLUP);
/* Attach interrupt to button pin */
rt_pin_attach_irq(BUTTON_PIN, PIN_IRQ_MODE_FALLING, button_irq_callback, RT_NULL);
rt_pin_irq_enable(BUTTON_PIN, PIN_IRQ_ENABLE);
while (1)
{
rt_pin_write(LED_PIN, PIN_HIGH); /* Set GPIO output 1 */
rt_thread_mdelay(500); /* Delay 500mS */
rt_pin_write(LED_PIN, PIN_LOW); /* Set GPIO output 0 */
rt_thread_mdelay(500); /* Delay 500mS */
/* Toggle LED state */
led_state = !led_state;
rt_pin_write(LED_PIN, led_state ? PIN_HIGH : PIN_LOW);
rt_thread_mdelay(500);
}
}
// end file

View File

@@ -40,11 +40,8 @@ menu "On-chip Peripheral Drivers"
default y
if BSP_USING_I2C
config BSP_USING_I2C0
bool "Enable Flexcomm0 I2C"
default y
config BSP_USING_I2C1
bool "Enable Flexcomm1 I2C"
config BSP_USING_I2C3
bool "Enable Flexcomm3 I2C"
default y
endif
@@ -67,26 +64,8 @@ menu "On-chip Peripheral Drivers"
default y
if BSP_USING_ADC
config BSP_USING_ADC0_CH0
bool "Enable ADC0 Channel0"
default y
config BSP_USING_ADC0_CH1
bool "Enable ADC0 Channel1"
default n
config BSP_USING_ADC0_CH8
bool "Enable ADC0 Channel8"
default n
config BSP_USING_ADC0_CH13
bool "Enable ADC0 Channel13"
default n
config BSP_USING_ADC0_CH26
bool "Enable ADC0 Channel26"
config BSP_USING_ADC0_CH22
bool "Enable ADC0 Channel22"
default n
endif
@@ -162,15 +141,15 @@ menu "Board extended module Drivers"
config BOARD_RW007_CS_PIN
hex "CS pin index"
default 0x46
default 107
config BOARD_RW007_INT_BUSY_PIN
hex "INT/BUSY pin index"
default 0x71
default 109
config BOARD_RW007_RST_PIN
hex "RESET pin index"
default 0x2F
default 131
endif

View File

@@ -14,6 +14,7 @@
#include "fsl_common.h"
#include "fsl_port.h"
#include "fsl_edma.h"
#include "pin_mux.h"
@@ -22,34 +23,40 @@ void BOARD_InitBootPins(void)
BOARD_InitPins();
}
static void release_reset_array(const reset_ip_name_t *resets, uint32_t count)
{
for (uint32_t i = 0; i < count; i++) {
RESET_ReleasePeripheralReset(resets[i]);
}
}
void BOARD_InitPins(void)
{
/* Enable all PORT clocks */
CLOCK_EnableClock(kCLOCK_GatePORT0);
CLOCK_EnableClock(kCLOCK_GatePORT1);
CLOCK_EnableClock(kCLOCK_GatePORT2);
CLOCK_EnableClock(kCLOCK_GatePORT3);
static const clock_ip_name_t port_clocks[] = PORT_CLOCKS;
static const clock_ip_name_t gpio_clocks[] = GPIO_CLOCKS;
/* Enable all GPIO clocks */
CLOCK_EnableClock(kCLOCK_GateGPIO0);
CLOCK_EnableClock(kCLOCK_GateGPIO1);
CLOCK_EnableClock(kCLOCK_GateGPIO2);
CLOCK_EnableClock(kCLOCK_GateGPIO3);
// Enable clocks
for (uint32_t i = 0; i < ARRAY_SIZE(port_clocks); i++) {
CLOCK_EnableClock(port_clocks[i]);
CLOCK_EnableClock(gpio_clocks[i]);
}
/* Release all PORT resets */
RESET_ReleasePeripheralReset(kPORT0_RST_SHIFT_RSTn);
RESET_ReleasePeripheralReset(kPORT1_RST_SHIFT_RSTn);
RESET_ReleasePeripheralReset(kPORT2_RST_SHIFT_RSTn);
RESET_ReleasePeripheralReset(kPORT3_RST_SHIFT_RSTn);
// SDK predefined reset arrays
static const reset_ip_name_t port_resets[] = PORT_RSTS_N;
static const reset_ip_name_t gpio_resets[] = GPIO_RSTS_N;
static const reset_ip_name_t uart_resets[] = LPUART_RSTS;
static const reset_ip_name_t i2c_resets[] = LPI2C_RSTS;
static const reset_ip_name_t spi_resets[] = LPSPI_RSTS;
static const reset_ip_name_t dma_resets[] = DMA_RSTS_N;
RESET_ReleasePeripheralReset(kGPIO0_RST_SHIFT_RSTn);
RESET_ReleasePeripheralReset(kGPIO1_RST_SHIFT_RSTn);
RESET_ReleasePeripheralReset(kGPIO2_RST_SHIFT_RSTn);
RESET_ReleasePeripheralReset(kGPIO3_RST_SHIFT_RSTn);
// Release resets
release_reset_array(port_resets, ARRAY_SIZE(port_resets));
release_reset_array(gpio_resets, ARRAY_SIZE(gpio_resets));
release_reset_array(uart_resets, ARRAY_SIZE(uart_resets));
release_reset_array(i2c_resets, ARRAY_SIZE(i2c_resets));
release_reset_array(spi_resets, ARRAY_SIZE(spi_resets));
release_reset_array(dma_resets, ARRAY_SIZE(dma_resets));
RESET_ReleasePeripheralReset(kLPUART0_RST_SHIFT_RSTn);
RESET_ReleasePeripheralReset(kLPUART1_RST_SHIFT_RSTn);
RESET_ReleasePeripheralReset(kLPUART2_RST_SHIFT_RSTn);
const port_pin_config_t port2_2_pin35_config = {/* Internal pull-up resistor is enabled */
.pullSelect = kPORT_PullUp,
@@ -125,5 +132,357 @@ void BOARD_InitPins(void)
/* Pin Control Register fields [15:0] are not locked */
.lockRegister = kPORT_UnlockRegister};
/* PORT3_18 (pin 86) is configured as P3_18 */
PORT_SetPinConfig(PORT3, 18, &LED_RED);
PORT_SetPinConfig(BOARD_INITLEDSPINS_LED_RED_PORT, BOARD_INITLEDSPINS_LED_RED_PIN, &LED_RED);
const port_pin_config_t LED_GREEN = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* 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 P3_19 */
.mux = kPORT_MuxAlt0,
/* 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};
/* PORT3_19 (pin 85) is configured as P3_19 */
PORT_SetPinConfig(BOARD_INITLEDSPINS_LED_GREEN_PORT, BOARD_INITLEDSPINS_LED_GREEN_PIN, &LED_GREEN);
const port_pin_config_t LED_BLUE = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* 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 P3_21 */
.mux = kPORT_MuxAlt0,
/* 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};
/* PORT3_21 (pin 82) is configured as P3_21 */
PORT_SetPinConfig(BOARD_INITLEDSPINS_LED_BLUE_PORT, BOARD_INITLEDSPINS_LED_BLUE_PIN, &LED_BLUE);
const port_pin_config_t port1_8_pin1_config = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* 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 LPI2C2_SDA */
.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};
/* PORT1_8 (pin 1) is configured as LPI2C2_SDA */
PORT_SetPinConfig(PORT1, 8U, &port1_8_pin1_config);
const port_pin_config_t port1_9_pin2_config = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* 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 LPI2C2_SCL */
.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};
/* PORT1_9 (pin 2) is configured as LPI2C2_SCL */
PORT_SetPinConfig(PORT1, 9U, &port1_9_pin2_config);
const port_pin_config_t port3_27_pin74_config = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* 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 LPI2C3_SCL */
.mux = kPORT_MuxAlt2,
/* 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};
/* PORT3_27 (pin 74) is configured as LPI2C3_SCL */
PORT_SetPinConfig(PORT3, 27U, &port3_27_pin74_config);
const port_pin_config_t port3_28_pin73_config = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* 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 LPI2C3_SDA */
.mux = kPORT_MuxAlt2,
/* 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};
/* PORT3_28 (pin 73) is configured as LPI2C3_SDA */
PORT_SetPinConfig(PORT3, 28U, &port3_28_pin73_config);
const port_pin_config_t port1_0_pin135_config = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* 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 LPSPI0_SDO */
.mux = kPORT_MuxAlt2,
/* 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};
/* PORT1_0 (pin 135) is configured as LPSPI0_SDO */
PORT_SetPinConfig(PORT1, 0U, &port1_0_pin135_config);
const port_pin_config_t port1_1_pin136_config = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* 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 LPSPI0_SCK */
.mux = kPORT_MuxAlt2,
/* 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};
/* PORT1_1 (pin 136) is configured as LPSPI0_SCK */
PORT_SetPinConfig(PORT1, 1U, &port1_1_pin136_config);
const port_pin_config_t port1_2_pin137_config = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* 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 LPSPI0_SDI */
.mux = kPORT_MuxAlt2,
/* 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};
/* PORT1_2 (pin 137) is configured as LPSPI0_SDI */
PORT_SetPinConfig(PORT1, 2U, &port1_2_pin137_config);
const port_pin_config_t port1_3_pin138_config = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* 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 LPSPI0_PCS0 */
.mux = kPORT_MuxAlt2,
/* 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};
/* PORT1_3 (pin 138) is configured as LPSPI0_PCS0 */
PORT_SetPinConfig(PORT1, 3U, &port1_3_pin138_config);
const port_pin_config_t port3_10_pin96_config = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* 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 LPSPI1_SCK */
.mux = kPORT_MuxAlt2,
/* 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};
/* PORT3_10 (pin 96) is configured as LPSPI1_SCK */
PORT_SetPinConfig(PORT3, 10U, &port3_10_pin96_config);
const port_pin_config_t port3_11_pin95_config = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* 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 LPSPI1_PCS0 */
.mux = kPORT_MuxAlt2,
/* 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};
/* PORT3_11 (pin 95) is configured as LPSPI1_PCS0 */
PORT_SetPinConfig(PORT3, 11U, &port3_11_pin95_config);
const port_pin_config_t port3_8_pin98_config = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* 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 LPSPI1_SDO */
.mux = kPORT_MuxAlt2,
/* 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};
/* PORT3_8 (pin 98) is configured as LPSPI1_SDO */
PORT_SetPinConfig(PORT3, 8U, &port3_8_pin98_config);
const port_pin_config_t port3_9_pin97_config = {/* Internal pull-up/down resistor is disabled */
.pullSelect = kPORT_PullDisable,
/* 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 LPSPI1_SDI */
.mux = kPORT_MuxAlt2,
/* 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};
/* PORT3_9 (pin 97) is configured as LPSPI1_SDI */
PORT_SetPinConfig(PORT3, 9U, &port3_9_pin97_config);
}

View File

@@ -17,6 +17,45 @@
* @{
*/
/* Symbols to be used with GPIO driver */
#define BOARD_INITLEDSPINS_LED_RED_GPIO GPIO3 /*!<@brief GPIO peripheral base pointer */
#define BOARD_INITLEDSPINS_LED_RED_GPIO_PIN 18U /*!<@brief GPIO pin number */
#define BOARD_INITLEDSPINS_LED_RED_GPIO_PIN_MASK (1U << 18U) /*!<@brief GPIO pin mask */
/* Symbols to be used with PORT driver */
#define BOARD_INITLEDSPINS_LED_RED_PORT PORT3 /*!<@brief PORT peripheral base pointer */
#define BOARD_INITLEDSPINS_LED_RED_PIN 18U /*!<@brief PORT pin number */
#define BOARD_INITLEDSPINS_LED_RED_PIN_MASK (1U << 18U) /*!<@brief PORT pin mask */
/* @} */
/*! @name PORT3_19 (number 85), LED_GREEN
@{ */
/* Symbols to be used with GPIO driver */
#define BOARD_INITLEDSPINS_LED_GREEN_GPIO GPIO3 /*!<@brief GPIO peripheral base pointer */
#define BOARD_INITLEDSPINS_LED_GREEN_GPIO_PIN 19U /*!<@brief GPIO pin number */
#define BOARD_INITLEDSPINS_LED_GREEN_GPIO_PIN_MASK (1U << 19U) /*!<@brief GPIO pin mask */
/* Symbols to be used with PORT driver */
#define BOARD_INITLEDSPINS_LED_GREEN_PORT PORT3 /*!<@brief PORT peripheral base pointer */
#define BOARD_INITLEDSPINS_LED_GREEN_PIN 19U /*!<@brief PORT pin number */
#define BOARD_INITLEDSPINS_LED_GREEN_PIN_MASK (1U << 19U) /*!<@brief PORT pin mask */
/* @} */
/*! @name PORT3_21 (number 82), LED_BLUE
@{ */
/* Symbols to be used with GPIO driver */
#define BOARD_INITLEDSPINS_LED_BLUE_GPIO GPIO3 /*!<@brief GPIO peripheral base pointer */
#define BOARD_INITLEDSPINS_LED_BLUE_GPIO_PIN 21U /*!<@brief GPIO pin number */
#define BOARD_INITLEDSPINS_LED_BLUE_GPIO_PIN_MASK (1U << 21U) /*!<@brief GPIO pin mask */
/* Symbols to be used with PORT driver */
#define BOARD_INITLEDSPINS_LED_BLUE_PORT PORT3 /*!<@brief PORT peripheral base pointer */
#define BOARD_INITLEDSPINS_LED_BLUE_PIN 21U /*!<@brief PORT pin number */
#define BOARD_INITLEDSPINS_LED_BLUE_PIN_MASK (1U << 21U) /*!<@brief PORT pin mask */
/* @} */
/***********************************************************************************************************************
* API
**********************************************************************************************************************/

View File

@@ -63,16 +63,7 @@ void rt_hw_board_init()
#endif
}
/**
* This function will called when memory fault.
*/
void MemManage_Handler(void)
{
extern void HardFault_Handler(void);
rt_kprintf("Memory Fault!\n");
HardFault_Handler();
}
void rt_hw_us_delay(rt_uint32_t us)
{
@@ -103,3 +94,14 @@ void rt_hw_us_delay(rt_uint32_t us)
}
}
}
/**
* This function will called when memory fault.
*/
void MemManage_Handler(void)
{
extern void HardFault_Handler(void);
rt_kprintf("Memory Fault!\n");
HardFault_Handler();
}

File diff suppressed because it is too large Load Diff

View File

@@ -338,9 +338,9 @@
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls>--target=arm-arm-none-eabi</MiscControls>
<Define>CPU_MCXA346VLQ, __STDC_LIMIT_MACROS, DEBUG, RT_USING_LIBC, __RTTHREAD__, RT_USING_ARMLIBC, __CLK_TCK=RT_TICK_PER_SECOND</Define>
<Define>__RTTHREAD__, CPU_MCXA346VLQ, RT_USING_ARMLIBC, DEBUG, __STDC_LIMIT_MACROS, RT_USING_LIBC, __CLK_TCK=RT_TICK_PER_SECOND</Define>
<Undefine></Undefine>
<IncludePath>packages\nxp-mcx-series-latest\MCXA346;..\..\..\..\..\components\libc\compilers\common\extension\fcntl\octal;packages\nxp-mcx-series-latest\MCXA346\periph2;..\..\..\..\..\components\drivers\include;..\..\..\..\..\components\drivers\include;..\..\..\..\..\libcpu\arm\common;..\..\..\..\..\components\libc\compilers\common\extension;applications;board\MCUX_Config\board;..\..\..\..\..\components\drivers\include;.;..\..\..\..\..\components\drivers\phy;..\..\..\..\..\components\libc\posix\io\epoll;packages\nxp-mcx-series-latest\MCXA346\drivers;packages\nxp-mcx-cmsis-latest\Core\Include;..\..\..\..\..\libcpu\arm\cortex-m33;..\..\..\..\..\components\libc\posix\io\poll;..\..\..\..\..\components\drivers\include;..\..\..\..\..\components\drivers\include;..\..\..\..\..\include;..\..\..\..\..\components\drivers\include;..\..\..\..\..\components\drivers\include;..\..\..\..\..\components\libc\posix\ipc;..\..\..\..\..\components\drivers\include;..\..\..\..\..\components\libc\posix\io\eventfd;..\..\..\..\..\components\finsh;packages\nxp-mcx-series-latest\MCXA346\components\codec;..\..\..\..\..\components\drivers\include;..\Libraries\drivers;..\..\..\..\..\components\libc\compilers\common\include;..\..\..\..\..\components\drivers\spi;..\Libraries\drivers\config;..\..\..\..\..\components\drivers\smp_call;board;..\..\..\..\..\components\drivers\include</IncludePath>
<IncludePath>..\..\..\..\..\components\drivers\include;applications;..\..\..\..\..\components\drivers\include;..\..\..\..\..\components\libc\posix\io\poll;..\..\..\..\..\components\libc\compilers\common\extension;..\..\..\..\..\components\drivers\include;..\..\..\..\..\components\drivers\smp_call;..\Libraries\drivers\config;..\..\..\..\..\components\drivers\spi;..\..\..\..\..\components\drivers\include;.;..\..\..\..\..\libcpu\arm\common;packages\nxp-mcx-cmsis-latest\Core\Include;packages\nxp-mcx-series-latest\MCXA346\drivers;..\..\..\..\..\components\drivers\include;..\..\..\..\..\components\drivers\include;..\..\..\..\..\components\libc\posix\io\eventfd;..\..\..\..\..\components\drivers\include;packages\nxp-mcx-series-latest\MCXA346\periph2;..\..\..\..\..\libcpu\arm\cortex-m33;..\..\..\..\..\components\libc\posix\ipc;..\..\..\..\..\components\finsh;packages\nxp-mcx-series-latest\MCXA346;..\..\..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\Libraries\drivers;..\..\..\..\..\components\drivers\include;..\..\..\..\..\include;..\..\..\..\..\components\libc\posix\io\epoll;board\MCUX_Config\board;..\..\..\..\..\components\drivers\include;packages\nxp-mcx-series-latest\MCXA346\components\codec;..\..\..\..\..\components\drivers\include;..\..\..\..\..\components\libc\compilers\common\include;board;..\..\..\..\..\components\drivers\phy</IncludePath>
</VariousControls>
</Cads>
<Aads>
@@ -384,6 +384,11 @@
<Group>
<GroupName>Applications</GroupName>
<Files>
<File>
<FileName>drv_spi_sample_rw007.c</FileName>
<FileType>1</FileType>
<FilePath>applications\drv_spi_sample_rw007.c</FilePath>
</File>
<File>
<FileName>main.c</FileName>
<FileType>1</FileType>
@@ -1599,16 +1604,16 @@
<FileType>1</FileType>
<FilePath>..\..\..\..\..\components\finsh\cmd.c</FilePath>
</File>
<File>
<FileName>shell.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\..\components\finsh\shell.c</FilePath>
</File>
<File>
<FileName>msh_parse.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\..\components\finsh\msh_parse.c</FilePath>
</File>
<File>
<FileName>shell.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\..\components\finsh\shell.c</FilePath>
</File>
<File>
<FileName>msh.c</FileName>
<FileType>1</FileType>
@@ -2464,31 +2469,31 @@
<Group>
<GroupName>klibc</GroupName>
<Files>
<File>
<FileName>kstring.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\..\src\klibc\kstring.c</FilePath>
</File>
<File>
<FileName>kerrno.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\..\src\klibc\kerrno.c</FilePath>
</File>
<File>
<FileName>rt_vsnprintf_tiny.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\..\src\klibc\rt_vsnprintf_tiny.c</FilePath>
</File>
<File>
<FileName>kstdio.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\..\src\klibc\kstdio.c</FilePath>
</File>
<File>
<FileName>kstring.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\..\src\klibc\kstring.c</FilePath>
</File>
<File>
<FileName>rt_vsscanf.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\..\src\klibc\rt_vsscanf.c</FilePath>
</File>
<File>
<FileName>rt_vsnprintf_tiny.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\..\src\klibc\rt_vsnprintf_tiny.c</FilePath>
</File>
</Files>
</Group>
<Group>