Skip to content

Commit df948ad

Browse files
wdfk-progRbb666
authored andcommitted
[STM32][SPI]移除内部编写的延时函数使用统一延时接口
1 parent 6e7cf3a commit df948ad

File tree

1 file changed

+2
-32
lines changed

1 file changed

+2
-32
lines changed

Diff for: bsp/stm32/libraries/HAL_Drivers/drivers/drv_soft_spi.c

+2-32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2023, RT-Thread Development Team
2+
* Copyright (c) 2006-2024, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -156,36 +156,6 @@ void stm32_dir_miso(void *data, rt_int32_t state)
156156
}
157157
}
158158

159-
static void stm32_udelay(rt_uint32_t us)
160-
{
161-
rt_uint32_t ticks;
162-
rt_uint32_t told, tnow, tcnt = 0;
163-
rt_uint32_t reload = SysTick->LOAD;
164-
165-
ticks = us * reload / (1000000UL / RT_TICK_PER_SECOND);
166-
told = SysTick->VAL;
167-
while (1)
168-
{
169-
tnow = SysTick->VAL;
170-
if (tnow != told)
171-
{
172-
if (tnow < told)
173-
{
174-
tcnt += told - tnow;
175-
}
176-
else
177-
{
178-
tcnt += reload - tnow + told;
179-
}
180-
told = tnow;
181-
if (tcnt >= ticks)
182-
{
183-
break;
184-
}
185-
}
186-
}
187-
}
188-
189159
static void stm32_pin_init(void)
190160
{
191161
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 =
209179
.get_miso = stm32_get_miso,
210180
.dir_mosi = stm32_dir_mosi,
211181
.dir_miso = stm32_dir_miso,
212-
.udelay = stm32_udelay,
182+
.udelay = rt_hw_us_delay,
213183
.delay_us = 1,
214184
};
215185

0 commit comments

Comments
 (0)