From 1564735b5ccba8ca09cae340333b2bfb032205d3 Mon Sep 17 00:00:00 2001 From: GUI <39894654+GuEe-GUI@users.noreply.github.com> Date: Tue, 11 Feb 2025 14:54:59 +0800 Subject: [DM/SPI] Make CS pin config fixed in system (#9977) Make a max CS pin value (16) for SPI, that will not alloc `*cs_pins` by malloc, because drivers call `rt_device_unregister` may not free item. Fixup the QSPI init configure member in DM mode. Make SoC Kconfig import easy. Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/drivers/include/drivers/dev_spi.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'components/drivers/include') diff --git a/components/drivers/include/drivers/dev_spi.h b/components/drivers/include/drivers/dev_spi.h index 0aa08c49e8..ee757347f4 100644 --- a/components/drivers/include/drivers/dev_spi.h +++ b/components/drivers/include/drivers/dev_spi.h @@ -132,6 +132,8 @@ extern "C"{ #define RT_SPI_BUS_MODE_SPI (1<<0) #define RT_SPI_BUS_MODE_QSPI (1<<1) +#define RT_SPI_CS_CNT_MAX 16 + /** * @brief SPI message structure */ @@ -175,7 +177,8 @@ struct rt_spi_bus const struct rt_spi_ops *ops; #ifdef RT_USING_DM - rt_base_t *pins; + rt_base_t cs_pins[RT_SPI_CS_CNT_MAX]; + rt_uint8_t cs_active_vals[RT_SPI_CS_CNT_MAX]; rt_bool_t slave; int num_chipselect; #endif /* RT_USING_DM */ @@ -220,7 +223,7 @@ struct rt_spi_device const struct rt_spi_device_id *id; const struct rt_ofw_node_id *ofw_id; - rt_uint8_t chip_select; + rt_uint8_t chip_select[RT_SPI_CS_CNT_MAX]; struct rt_spi_delay cs_setup; struct rt_spi_delay cs_hold; struct rt_spi_delay cs_inactive; -- cgit v1.3.1