[RT1060][SPI]完善SPI支持,完善SPI对RW007的支持 (#7193)
* [RT1060][SPI]添加SPI支持,并完善RW007支持
This commit is contained in:
parent
2352d3e310
commit
93361c31f0
|
@ -164,6 +164,10 @@ endmenu
|
|||
|
||||
menu "On-chip Peripheral Drivers"
|
||||
|
||||
config BSP_USING_DMA
|
||||
bool "Enable DMA"
|
||||
default n
|
||||
|
||||
config BSP_USING_GPIO
|
||||
bool "Enable GPIO"
|
||||
select RT_USING_PIN
|
||||
|
@ -254,6 +258,38 @@ menu "On-chip Peripheral Drivers"
|
|||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_SPI
|
||||
bool "Enable SPI"
|
||||
select RT_USING_SPI
|
||||
select RT_USING_PIN
|
||||
default n
|
||||
|
||||
if BSP_USING_SPI
|
||||
config BSP_USING_SPI1
|
||||
bool "Enable SPI1"
|
||||
default n
|
||||
|
||||
config BSP_USING_BLOCKING_SPI
|
||||
bool "Enable SPI Polling xfer"
|
||||
default n
|
||||
|
||||
config BSP_SPI1_USING_DMA
|
||||
bool "Enable SPI1 DMA xfer"
|
||||
depends on BSP_USING_SPI1
|
||||
select BSP_USING_DMA
|
||||
default n
|
||||
|
||||
config BSP_SPI1_RX_DMA_CHANNEL
|
||||
depends on BSP_SPI1_USING_DMA
|
||||
int "Set SPI1 RX DMA channel (0-32)"
|
||||
default 0
|
||||
|
||||
config BSP_SPI1_TX_DMA_CHANNEL
|
||||
depends on BSP_SPI1_USING_DMA
|
||||
int "Set SPI1 TX DMA channel (0-32)"
|
||||
default 1
|
||||
endif
|
||||
|
||||
config BSP_USING_PXP
|
||||
bool "Enable PXP"
|
||||
default n
|
||||
|
|
|
@ -211,6 +211,20 @@ void imxrt_dma_init(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_SPI
|
||||
void imxrt_spi_pins_init(void) {
|
||||
CLOCK_EnableClock(kCLOCK_Iomuxc);
|
||||
|
||||
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B0_00_LPSPI1_SCK, 0U);
|
||||
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B0_02_LPSPI1_SDO, 0U);
|
||||
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B0_03_LPSPI1_SDI, 0U);
|
||||
|
||||
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B0_00_LPSPI1_SCK,0x10B0);
|
||||
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B0_02_LPSPI1_SDO,0x10B0);
|
||||
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B0_03_LPSPI1_SDI,0x10B0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_LPUART
|
||||
void imxrt_uart_pins_init(void)
|
||||
{
|
||||
|
@ -1211,6 +1225,10 @@ void rt_hw_board_init()
|
|||
rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_SPI
|
||||
imxrt_spi_pins_init();
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
rt_components_board_init();
|
||||
#endif
|
||||
|
|
|
@ -246,6 +246,7 @@ static void lpspi_normal_config(struct imxrt_spi *spi)
|
|||
|
||||
static void lpspi_dma_config(struct imxrt_spi *spi)
|
||||
{
|
||||
#ifdef BSP_USING_DMA
|
||||
RT_ASSERT(spi != RT_NULL);
|
||||
|
||||
DMAMUX_SetSource(DMAMUX, spi->dma->rx_channel, spi->dma->rx_request);
|
||||
|
@ -264,6 +265,7 @@ static void lpspi_dma_config(struct imxrt_spi *spi)
|
|||
&spi->dma->tx_edma);
|
||||
|
||||
LOG_D("%s dma config done\n", spi->bus_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
static rt_err_t spi_configure(struct rt_spi_device *device, struct rt_spi_configuration *cfg)
|
||||
|
@ -362,13 +364,16 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
|
|||
{
|
||||
#ifdef BSP_USING_BLOCKING_SPI
|
||||
status = LPSPI_MasterTransferBlocking(spi->base, &transfer);
|
||||
rt_sem_release(spi->xfer_sem);
|
||||
#else
|
||||
status = LPSPI_MasterTransferNonBlocking(spi->base, &spi->spi_normal, &transfer);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef BSP_USING_DMA
|
||||
status = LPSPI_MasterTransferEDMA(spi->base,&spi->dma->spi_edma,&transfer);
|
||||
#endif
|
||||
}
|
||||
rt_sem_take(spi->xfer_sem, RT_WAITING_FOREVER);
|
||||
|
||||
|
@ -404,7 +409,7 @@ int rt_hw_spi_bus_init(void)
|
|||
lpspis[i].spi_bus.parent.user_data = &lpspis[i];
|
||||
|
||||
ret = rt_spi_bus_register(&lpspis[i].spi_bus, lpspis[i].bus_name, &imxrt_spi_ops);
|
||||
|
||||
#ifndef BSP_USING_BLOCKING_SPI
|
||||
if(RT_TRUE == lpspis[i].dma_flag)
|
||||
{
|
||||
lpspi_dma_config(&lpspis[i]);
|
||||
|
@ -413,6 +418,7 @@ int rt_hw_spi_bus_init(void)
|
|||
{
|
||||
lpspi_normal_config(&lpspis[i]);
|
||||
}
|
||||
#endif
|
||||
char sem_name[RT_NAME_MAX];
|
||||
rt_sprintf(sem_name, "%s_s", lpspis[i].bus_name);
|
||||
lpspis[i].xfer_sem = rt_sem_create(sem_name, 0, RT_IPC_FLAG_PRIO);
|
||||
|
|
Loading…
Reference in New Issue