sdcard: update sdcard detection to avoid 0xff assignment to bool type

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
Petro Karashchenko
2023-06-10 20:28:57 +03:00
committed by Xiang Xiao
parent ef60a2e56a
commit dcd26ac6b2
15 changed files with 74 additions and 108 deletions
@@ -57,7 +57,7 @@
static struct sdio_dev_s *g_sdio_dev;
#ifdef HAVE_NCD
static bool g_sd_inserted = 0xff; /* Impossible value */
static bool g_sd_inserted;
#endif
/****************************************************************************
@@ -104,13 +104,6 @@ int gd32_sdio_initialize(void)
{
int ret;
#ifdef HAVE_NCD
/* Card detect */
bool cd_status;
#endif
/* Mount the SDIO-based MMC/SD block driver
* First, get an instance of the SDIO interface
*/
@@ -140,10 +133,10 @@ int gd32_sdio_initialize(void)
#ifdef HAVE_NCD
/* Use SD card detect pin to check if a card is g_sd_inserted */
cd_status = !gd32_gpio_read(GPIO_SDMMC1_NCD);
finfo("Card detect : %d\n", cd_status);
g_sd_inserted = !gd32_gpio_read(GPIO_SDMMC1_NCD);
finfo("Card detect : %d\n", g_sd_inserted);
sdio_mediachange(g_sdio_dev, cd_status);
sdio_mediachange(g_sdio_dev, g_sd_inserted);
#else
/* Assume that the SD card is inserted. What choice do we have? */