mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
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:
committed by
Xiang Xiao
parent
ef60a2e56a
commit
dcd26ac6b2
@@ -54,7 +54,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
|
||||
|
||||
/****************************************************************************
|
||||
@@ -102,8 +102,6 @@ int stm32_sdio_initialize(void)
|
||||
int ret;
|
||||
|
||||
#ifdef HAVE_NCD
|
||||
bool cd_status;
|
||||
|
||||
/* Configure the card detect GPIO */
|
||||
|
||||
stm32_configgpio(GPIO_SDIO_NCD);
|
||||
@@ -112,7 +110,6 @@ int stm32_sdio_initialize(void)
|
||||
|
||||
stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true,
|
||||
stm32_ncd_interrupt, NULL);
|
||||
|
||||
#endif
|
||||
|
||||
/* Mount the SDIO-based MMC/SD block driver.
|
||||
@@ -142,9 +139,9 @@ int stm32_sdio_initialize(void)
|
||||
#ifdef HAVE_NCD
|
||||
/* Use SD card detect pin to check if a card is g_sd_inserted */
|
||||
|
||||
cd_status = !stm32_gpioread(GPIO_SDIO_NCD);
|
||||
finfo("Card detect : %d\n", cd_status);
|
||||
sdio_mediachange(g_sdio_dev, cd_status);
|
||||
g_sd_inserted = !stm32_gpioread(GPIO_SDIO_NCD);
|
||||
finfo("Card detect : %d\n", g_sd_inserted);
|
||||
sdio_mediachange(g_sdio_dev, g_sd_inserted);
|
||||
#else
|
||||
/* Assume that the SD card is inserted. What choice do we have? */
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
|
||||
#ifdef CONFIG_MMCSD
|
||||
static struct sdio_dev_s *g_sdiodev;
|
||||
static bool g_sd_inserted;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@@ -112,14 +113,13 @@ static struct sdio_dev_s *g_sdiodev;
|
||||
#ifdef NSH_HAVEMMCSD
|
||||
static int nsh_cdinterrupt(int irq, void *context, void *arg)
|
||||
{
|
||||
static bool inserted = 0xff; /* Impossible value */
|
||||
bool present;
|
||||
|
||||
present = !stm32_gpioread(GPIO_SD_CD);
|
||||
if (present != inserted)
|
||||
if (present != g_sd_inserted)
|
||||
{
|
||||
sdio_mediachange(g_sdiodev, present);
|
||||
inserted = present;
|
||||
g_sd_inserted = present;
|
||||
}
|
||||
|
||||
return OK;
|
||||
@@ -158,10 +158,6 @@ int board_app_initialize(uintptr_t arg)
|
||||
int ret;
|
||||
|
||||
#ifdef NSH_HAVEMMCSD
|
||||
/* Card detect */
|
||||
|
||||
bool cd_status;
|
||||
|
||||
/* Configure the card detect GPIO */
|
||||
|
||||
stm32_configgpio(GPIO_SD_CD);
|
||||
@@ -203,10 +199,10 @@ int board_app_initialize(uintptr_t arg)
|
||||
|
||||
/* Use SD card detect pin to check if a card is inserted */
|
||||
|
||||
cd_status = !stm32_gpioread(GPIO_SD_CD);
|
||||
_info("Card detect : %hhu\n", cd_status);
|
||||
g_sd_inserted = !stm32_gpioread(GPIO_SD_CD);
|
||||
_info("Card detect : %hhu\n", g_sd_inserted);
|
||||
|
||||
sdio_mediachange(g_sdiodev, cd_status);
|
||||
sdio_mediachange(g_sdiodev, g_sd_inserted);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_INPUT
|
||||
|
||||
@@ -58,7 +58,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
|
||||
|
||||
/****************************************************************************
|
||||
@@ -106,10 +106,6 @@ int stm32_sdio_initialize(void)
|
||||
int ret;
|
||||
|
||||
#ifdef HAVE_NCD
|
||||
/* Card detect */
|
||||
|
||||
bool cd_status;
|
||||
|
||||
/* Configure the card detect GPIO */
|
||||
|
||||
stm32_configgpio(GPIO_SDMMC1_NCD);
|
||||
@@ -149,10 +145,10 @@ int stm32_sdio_initialize(void)
|
||||
#ifdef HAVE_NCD
|
||||
/* Use SD card detect pin to check if a card is g_sd_inserted */
|
||||
|
||||
cd_status = !stm32_gpioread(GPIO_SDMMC1_NCD);
|
||||
finfo("Card detect : %d\n", cd_status);
|
||||
g_sd_inserted = !stm32_gpioread(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? */
|
||||
|
||||
|
||||
@@ -56,7 +56,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,10 +104,6 @@ int stm32_sdio_initialize(void)
|
||||
int ret;
|
||||
|
||||
#ifdef HAVE_NCD
|
||||
/* Card detect */
|
||||
|
||||
bool cd_status;
|
||||
|
||||
/* Configure the card detect GPIO */
|
||||
|
||||
stm32_configgpio(GPIO_SDIO_NCD);
|
||||
@@ -147,10 +143,10 @@ int stm32_sdio_initialize(void)
|
||||
#ifdef HAVE_NCD
|
||||
/* Use SD card detect pin to check if a card is g_sd_inserted */
|
||||
|
||||
cd_status = !stm32_gpioread(GPIO_SDIO_NCD);
|
||||
finfo("Card detect : %d\n", cd_status);
|
||||
g_sd_inserted = !stm32_gpioread(GPIO_SDIO_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? */
|
||||
|
||||
|
||||
@@ -56,7 +56,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,10 +104,6 @@ int stm32_sdio_initialize(void)
|
||||
int ret;
|
||||
|
||||
#ifdef HAVE_NCD
|
||||
/* Card detect */
|
||||
|
||||
bool cd_status;
|
||||
|
||||
/* Configure the card detect GPIO */
|
||||
|
||||
stm32_configgpio(GPIO_SDIO_NCD);
|
||||
@@ -147,10 +143,10 @@ int stm32_sdio_initialize(void)
|
||||
#ifdef HAVE_NCD
|
||||
/* Use SD card detect pin to check if a card is g_sd_inserted */
|
||||
|
||||
cd_status = !stm32_gpioread(GPIO_SDIO_NCD);
|
||||
finfo("Card detect : %d\n", cd_status);
|
||||
g_sd_inserted = !stm32_gpioread(GPIO_SDIO_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? */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user