From 0396b52db046d715022f2e29b0ef923d8413171e Mon Sep 17 00:00:00 2001 From: mengplus Date: Tue, 21 Nov 2023 18:27:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(spi):=E5=A4=9A=E4=B8=AASPI=E5=85=AC?= =?UTF-8?q?=E7=94=A8=E4=B8=80=E4=B8=AAops.data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/stm32/libraries/HAL_Drivers/drv_soft_spi.c | 5 +++-- bsp/stm32/libraries/HAL_Drivers/drv_soft_spi.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_soft_spi.c b/bsp/stm32/libraries/HAL_Drivers/drv_soft_spi.c index eadf5eb4f3..fae3841a6f 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_soft_spi.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_soft_spi.c @@ -209,11 +209,12 @@ int rt_hw_softspi_init(void) for (int i = 0; i < obj_num; i++) { - stm32_soft_spi_ops.data = (void *)&soft_spi_config[i]; + memcpy(&spi_obj[i].ops, &stm32_soft_spi_ops, sizeof(struct rt_spi_bit_ops)); + spi_obj[i].ops.data = (void *)&soft_spi_config[i]; spi_obj[i].spi.ops = &stm32_soft_spi_ops; spi_obj[i].cfg = (void *)&soft_spi_config[i]; stm32_spi_gpio_init(&spi_obj[i]); - result = rt_spi_bit_add_bus(&spi_obj[i].spi, soft_spi_config[i].bus_name, &stm32_soft_spi_ops); + result = rt_spi_bit_add_bus(&spi_obj[i].spi, soft_spi_config[i].bus_name, &spi_obj[i].ops); RT_ASSERT(result == RT_EOK); } diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_soft_spi.h b/bsp/stm32/libraries/HAL_Drivers/drv_soft_spi.h index 9f70d61562..d6415875e8 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_soft_spi.h +++ b/bsp/stm32/libraries/HAL_Drivers/drv_soft_spi.h @@ -28,6 +28,7 @@ struct stm32_soft_spi_config struct stm32_soft_spi { struct rt_spi_bit_obj spi; + struct rt_spi_bit_ops ops; struct stm32_soft_spi_config *cfg; };