From 1755750b2ae4ee426c89162c9047bd8bcb545337 Mon Sep 17 00:00:00 2001 From: xiao xie <335266746@qq.com> Date: Tue, 8 Nov 2022 13:34:43 +0800 Subject: [PATCH] [sdio] remove mmcsd_delay_ms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改SD检测线程函数里面的延时实现,将mmcsd_delay_ms改为rt_thread_mdelay. mmcsd_delay_ms过时且延时计算错误。 --- components/drivers/include/drivers/mmcsd_host.h | 13 ------------- components/drivers/sdio/mmc.c | 4 ++-- components/drivers/sdio/mmcsd_core.c | 10 +++++----- components/drivers/sdio/sd.c | 2 +- components/drivers/sdio/sdio.c | 2 +- 5 files changed, 9 insertions(+), 22 deletions(-) diff --git a/components/drivers/include/drivers/mmcsd_host.h b/components/drivers/include/drivers/mmcsd_host.h index 7d987d4aa4..44f7b1c916 100644 --- a/components/drivers/include/drivers/mmcsd_host.h +++ b/components/drivers/include/drivers/mmcsd_host.h @@ -112,19 +112,6 @@ struct rt_mmcsd_host { void *private_data; }; - -rt_inline void mmcsd_delay_ms(rt_uint32_t ms) -{ - if (ms < 1000 / RT_TICK_PER_SECOND) - { - rt_thread_delay(1); - } - else - { - rt_thread_delay(ms/(1000 / RT_TICK_PER_SECOND)); - } -} - #ifdef __cplusplus } #endif diff --git a/components/drivers/sdio/mmc.c b/components/drivers/sdio/mmc.c index 74f0637ff8..0365de8ed7 100644 --- a/components/drivers/sdio/mmc.c +++ b/components/drivers/sdio/mmc.c @@ -355,7 +355,7 @@ static int mmc_select_bus_width(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd) bus_width = bus_widths[idx]; for(trys = 0; trys < 5; trys++){ mmcsd_set_bus_width(host, bus_width); - mmcsd_delay_ms(10); + rt_thread_mdelay(10); err = mmc_compare_ext_csds(card, ext_csd, bus_width); if(!err) break; @@ -421,7 +421,7 @@ rt_err_t mmc_send_op_cond(struct rt_mmcsd_host *host, err = -RT_ETIMEOUT; - mmcsd_delay_ms(10); //delay 10ms + rt_thread_mdelay(10); //delay 10ms } if (rocr && !controller_is_spi(host)) diff --git a/components/drivers/sdio/mmcsd_core.c b/components/drivers/sdio/mmcsd_core.c index 234b1474a1..179368026d 100644 --- a/components/drivers/sdio/mmcsd_core.c +++ b/components/drivers/sdio/mmcsd_core.c @@ -110,7 +110,7 @@ rt_int32_t mmcsd_go_idle(struct rt_mmcsd_host *host) if (!controller_is_spi(host)) { mmcsd_set_chip_select(host, MMCSD_CS_HIGH); - mmcsd_delay_ms(1); + rt_thread_mdelay(1); } rt_memset(&cmd, 0, sizeof(struct rt_mmcsd_cmd)); @@ -121,12 +121,12 @@ rt_int32_t mmcsd_go_idle(struct rt_mmcsd_host *host) err = mmcsd_send_cmd(host, &cmd, 0); - mmcsd_delay_ms(1); + rt_thread_mdelay(1); if (!controller_is_spi(host)) { mmcsd_set_chip_select(host, MMCSD_CS_IGNORE); - mmcsd_delay_ms(1); + rt_thread_mdelay(1); } return err; @@ -564,7 +564,7 @@ static void mmcsd_power_up(struct rt_mmcsd_host *host) * This delay should be sufficient to allow the power supply * to reach the minimum voltage. */ - mmcsd_delay_ms(10); + rt_thread_mdelay(10); host->io_cfg.clock = host->freq_min; host->io_cfg.power_mode = MMCSD_POWER_ON; @@ -574,7 +574,7 @@ static void mmcsd_power_up(struct rt_mmcsd_host *host) * This delay must be at least 74 clock sizes, or 1 ms, or the * time required to reach a stable voltage. */ - mmcsd_delay_ms(10); + rt_thread_mdelay(10); } static void mmcsd_power_off(struct rt_mmcsd_host *host) diff --git a/components/drivers/sdio/sd.c b/components/drivers/sdio/sd.c index a67d19c922..fe63cb86b5 100644 --- a/components/drivers/sdio/sd.c +++ b/components/drivers/sdio/sd.c @@ -403,7 +403,7 @@ rt_err_t mmcsd_send_app_op_cond(struct rt_mmcsd_host *host, err = -RT_ETIMEOUT; - mmcsd_delay_ms(10); //delay 10ms + rt_thread_mdelay(10); //delay 10ms } if (rocr && !controller_is_spi(host)) diff --git a/components/drivers/sdio/sdio.c b/components/drivers/sdio/sdio.c index 2ba1ddb51f..7d500c70a5 100644 --- a/components/drivers/sdio/sdio.c +++ b/components/drivers/sdio/sdio.c @@ -103,7 +103,7 @@ rt_int32_t sdio_io_send_op_cond(struct rt_mmcsd_host *host, err = -RT_ETIMEOUT; - mmcsd_delay_ms(10); + rt_thread_mdelay(10); } if (cmd5_resp) -- GitLab