Skip to content

Commit

Permalink
[STM32][SPI]移除内部编写的延时函数使用统一延时接口
Browse files Browse the repository at this point in the history
  • Loading branch information
wdfk-prog committed Jul 1, 2024
1 parent 2ab4e15 commit e94d7b1
Showing 1 changed file with 2 additions and 32 deletions.
34 changes: 2 additions & 32 deletions bsp/stm32/libraries/HAL_Drivers/drivers/drv_soft_spi.c
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down Expand Up @@ -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);
Expand All @@ -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,
};

Expand Down

0 comments on commit e94d7b1

Please sign in to comment.