4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-01-31 21:00:26 +08:00

[STM32][SPI]移除内部编写的延时函数使用统一延时接口

This commit is contained in:
wdfk-prog 2024-07-02 09:27:58 +08:00 committed by Rbb666
parent 6e7cf3a608
commit df948ad603

View File

@ -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,
};