[bsp][nxp/mcxa153]添加spi缺失的文件路径

This commit is contained in:
Rbb666 2024-08-08 13:55:44 +08:00 committed by Rbb666
parent 836865f404
commit fd111e7af4
5 changed files with 33 additions and 46 deletions

View File

@ -49,6 +49,10 @@ src += ['MCXA153/drivers/fsl_waketimer.c']
src += ['MCXA153/drivers/fsl_wuu.c']
src += ['MCXA153/drivers/fsl_wwdt.c']
if GetDepend('BSP_USING_SPI'):
src += ['MCXA153/drivers/fsl_lpspi.c']
src += ['MCXA153/drivers/fsl_lpspi_edma.c']
group = DefineGroup('Libraries', src, depend = [''], CPPPATH = path)
Return('group')

View File

@ -7,34 +7,34 @@ src = []
if GetDepend('BSP_USING_PIN'):
src += ['drv_pin.c']
if GetDepend('BSP_USING_UART'):
if GetDepend('BSP_USING_UART'):
src += ['drv_uart.c']
if GetDepend('BSP_USING_RTC'):
src += ['drv_rtc.c']
if GetDepend('BSP_USING_SPI'):
if GetDepend('BSP_USING_SPI'):
src += ['drv_spi.c']
if GetDepend('BSP_USING_SDIO'):
if GetDepend('BSP_USING_SDIO'):
src += ['drv_sdio.c']
if GetDepend('BSP_USING_I2C'):
if GetDepend('BSP_USING_I2C'):
src += ['drv_i2c.c']
if GetDepend('BSP_USING_ADC'):
if GetDepend('BSP_USING_ADC'):
src += ['drv_adc.c']
if GetDepend('BSP_USING_HWTIMER'):
if GetDepend('BSP_USING_HWTIMER'):
src += ['drv_hwtimer.c']
if GetDepend('BSP_USING_WDT'):
if GetDepend('BSP_USING_WDT'):
src += ['drv_wdt.c']
if GetDepend('BSP_USING_PWM'):
if GetDepend('BSP_USING_PWM'):
src += ['drv_pwm.c']
if GetDepend('BSP_USING_FLASH'):
if GetDepend('BSP_USING_FLASH'):
src += ['drv_chipflash.c']
path = [cwd,cwd + '/config']

View File

@ -36,6 +36,7 @@ static mcx_pwm_obj_t mcx_pwm_list[]=
}
#endif
};
volatile uint32_t g_pwmPeriod = 0U;
volatile uint32_t g_pulsePeriod = 0U;

View File

@ -9,7 +9,6 @@
*/
#include "rtdevice.h"
#include "drv_spi.h"
#include "fsl_common.h"
#include "fsl_lpspi.h"
#include "fsl_lpspi_edma.h"
@ -43,7 +42,6 @@ struct lpc_spi
char *name;
};
static struct lpc_spi lpc_obj[] =
{
#ifdef BSP_USING_SPI0
@ -83,13 +81,11 @@ rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name,
return ret;
}
static rt_err_t spi_configure(struct rt_spi_device *device, struct rt_spi_configuration *cfg)
{
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;
@ -106,7 +102,6 @@ static rt_ssize_t spixfer(struct rt_spi_device *device, struct rt_spi_message *m
RT_ASSERT(device->bus != RT_NULL);
RT_ASSERT(device->bus->parent.user_data != RT_NULL);
struct lpc_spi *spi = (struct lpc_spi *)(device->bus->parent.user_data);
struct lpc_sw_spi_cs *cs = device->parent.user_data;
@ -120,37 +115,29 @@ static rt_ssize_t spixfer(struct rt_spi_device *device, struct rt_spi_message *m
transfer.txData = (uint8_t *)(message->send_buf);
/* if(message->length < MAX_DMA_TRANSFER_SIZE)*/
if (0)
uint32_t block, remain;
block = message->length / DMA_MAX_TRANSFER_SIZE;
remain = message->length % DMA_MAX_TRANSFER_SIZE;
for (i = 0; i < block; i++)
{
LPSPI_MasterTransferBlocking(spi->LPSPIx, &transfer);
}
else
{
uint32_t block, remain;
block = message->length / DMA_MAX_TRANSFER_SIZE;
remain = message->length % DMA_MAX_TRANSFER_SIZE;
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);
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);
}
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);
}
if (message->cs_release)
{
@ -160,16 +147,12 @@ static rt_ssize_t spixfer(struct rt_spi_device *device, struct rt_spi_message *m
return message->length;
}
static struct rt_spi_ops lpc_spi_ops =
{
.configure = spi_configure,
.xfer = spixfer
};
int rt_hw_spi_init(void)
{
int i;

View File

@ -27,7 +27,6 @@ processor_version: 0.14.3
#include "fsl_ctimer.h"
#include "pin_mux.h"
void BOARD_InitBootPins(void)
{
BOARD_InitPins();