From 84250ebd7e5e2520bafbaec3c8a8e7ce61e78806 Mon Sep 17 00:00:00 2001 From: wdfk-prog <1425075683@qq.com> Date: Sun, 30 Jun 2024 21:32:57 +0800 Subject: [PATCH] =?UTF-8?q?[STM32][SPI]=E7=A7=BB=E9=99=A4=E5=86=85?= =?UTF-8?q?=E9=83=A8=E7=BC=96=E5=86=99=E7=9A=84=E5=BB=B6=E6=97=B6=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E4=BD=BF=E7=94=A8=E7=BB=9F=E4=B8=80=E5=BB=B6=E6=97=B6?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HAL_Drivers/drivers/drv_soft_spi.c | 34 ++----------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_soft_spi.c b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_soft_spi.c index 912e70982043..ff9e12473d85 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_soft_spi.c +++ b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_soft_spi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2023, RT-Thread Development Team + * Copyright (c) 2006-2024, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -156,36 +156,6 @@ void stm32_dir_miso(void *data, rt_int32_t state) } } -static void stm32_udelay(rt_uint32_t us) -{ - rt_uint32_t ticks; - rt_uint32_t told, tnow, tcnt = 0; - rt_uint32_t reload = SysTick->LOAD; - - ticks = us * reload / (1000000UL / RT_TICK_PER_SECOND); - told = SysTick->VAL; - while (1) - { - tnow = SysTick->VAL; - if (tnow != told) - { - if (tnow < told) - { - tcnt += told - tnow; - } - else - { - tcnt += reload - tnow + told; - } - told = tnow; - if (tcnt >= ticks) - { - break; - } - } - } -} - static void stm32_pin_init(void) { rt_size_t obj_num = sizeof(spi_obj) / sizeof(struct stm32_soft_spi); @@ -209,7 +179,7 @@ static struct rt_spi_bit_ops stm32_soft_spi_ops = .get_miso = stm32_get_miso, .dir_mosi = stm32_dir_mosi, .dir_miso = stm32_dir_miso, - .udelay = stm32_udelay, + .udelay = rt_hw_us_delay, .delay_us = 1, };