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; static struct sdio_dev_s *g_sdio_dev;
#ifdef HAVE_NCD #ifdef HAVE_NCD
static bool g_sd_inserted = 0xff; /* Impossible value */ static bool g_sd_inserted;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -104,13 +104,6 @@ int gd32_sdio_initialize(void)
{ {
int ret; int ret;
#ifdef HAVE_NCD
/* Card detect */
bool cd_status;
#endif
/* Mount the SDIO-based MMC/SD block driver /* Mount the SDIO-based MMC/SD block driver
* First, get an instance of the SDIO interface * First, get an instance of the SDIO interface
*/ */
@@ -140,10 +133,10 @@ int gd32_sdio_initialize(void)
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Use SD card detect pin to check if a card is g_sd_inserted */ /* Use SD card detect pin to check if a card is g_sd_inserted */
cd_status = !gd32_gpio_read(GPIO_SDMMC1_NCD); g_sd_inserted = !gd32_gpio_read(GPIO_SDMMC1_NCD);
finfo("Card detect : %d\n", cd_status); finfo("Card detect : %d\n", g_sd_inserted);
sdio_mediachange(g_sdio_dev, cd_status); sdio_mediachange(g_sdio_dev, g_sd_inserted);
#else #else
/* Assume that the SD card is inserted. What choice do we have? */ /* Assume that the SD card is inserted. What choice do we have? */
@@ -151,6 +151,9 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef NSH_HAVE_MMCSD #ifdef NSH_HAVE_MMCSD
static struct sdio_dev_s *g_sdiodev; static struct sdio_dev_s *g_sdiodev;
#endif #endif
#ifdef NSH_HAVE_MMCSD_CD
static bool g_sd_inserted;
#endif
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
@@ -205,14 +208,13 @@ static int nsh_waiter(int argc, char *argv[])
#ifdef NSH_HAVE_MMCSD_CDINT #ifdef NSH_HAVE_MMCSD_CDINT
static int nsh_cdinterrupt(int irq, void *context, void *arg) static int nsh_cdinterrupt(int irq, void *context, void *arg)
{ {
static bool inserted = 0xff; /* Impossible value */
bool present; bool present;
present = !lpc17_40_gpioread(GPIO_SD_CD); present = !lpc17_40_gpioread(GPIO_SD_CD);
if (present != inserted) if (present != g_sd_inserted)
{ {
sdio_mediachange(g_sdiodev, present); sdio_mediachange(g_sdiodev, present);
inserted = present; g_sd_inserted = present;
} }
return OK; return OK;
@@ -275,7 +277,8 @@ static int nsh_sdinitialize(void)
*/ */
#ifdef NSH_HAVE_MMCSD_CD #ifdef NSH_HAVE_MMCSD_CD
sdio_mediachange(g_sdiodev, !lpc17_40_gpioread(GPIO_SD_CD)); g_sd_inserted = !lpc17_40_gpioread(GPIO_SD_CD);
sdio_mediachange(g_sdiodev, g_sd_inserted);
#else #else
sdio_mediachange(g_sdiodev, true); sdio_mediachange(g_sdiodev, true);
#endif #endif
@@ -150,6 +150,9 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef NSH_HAVE_MMCSD #ifdef NSH_HAVE_MMCSD
static struct sdio_dev_s *g_sdiodev; static struct sdio_dev_s *g_sdiodev;
#endif #endif
#ifdef NSH_HAVE_MMCSD_CD
static bool g_sd_inserted;
#endif
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
@@ -204,14 +207,13 @@ static int nsh_waiter(int argc, char *argv[])
#ifdef NSH_HAVE_MMCSD_CDINT #ifdef NSH_HAVE_MMCSD_CDINT
static int nsh_cdinterrupt(int irq, void *context, void *arg) static int nsh_cdinterrupt(int irq, void *context, void *arg)
{ {
static bool inserted = 0xff; /* Impossible value */
bool present; bool present;
present = !lpc17_40_gpioread(GPIO_SD_CD); present = !lpc17_40_gpioread(GPIO_SD_CD);
if (present != inserted) if (present != g_sd_inserted)
{ {
sdio_mediachange(g_sdiodev, present); sdio_mediachange(g_sdiodev, present);
inserted = present; g_sd_inserted = present;
} }
return OK; return OK;
@@ -273,7 +275,8 @@ static int nsh_sdinitialize(void)
*/ */
#ifdef NSH_HAVE_MMCSD_CD #ifdef NSH_HAVE_MMCSD_CD
sdio_mediachange(g_sdiodev, !lpc17_40_gpioread(GPIO_SD_CD)); g_sd_inserted = !lpc17_40_gpioread(GPIO_SD_CD);
sdio_mediachange(g_sdiodev, g_sd_inserted);
#else #else
sdio_mediachange(g_sdiodev, true); sdio_mediachange(g_sdiodev, true);
#endif #endif
@@ -147,6 +147,9 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef NSH_HAVE_MMCSD #ifdef NSH_HAVE_MMCSD
static struct sdio_dev_s *g_sdiodev; static struct sdio_dev_s *g_sdiodev;
#endif #endif
#ifdef NSH_HAVE_MMCSD_CD
static bool g_sd_inserted;
#endif
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
@@ -201,14 +204,13 @@ static int nsh_waiter(int argc, char *argv[])
#ifdef NSH_HAVE_MMCSD_CDINT #ifdef NSH_HAVE_MMCSD_CDINT
static int nsh_cdinterrupt(int irq, void *context) static int nsh_cdinterrupt(int irq, void *context)
{ {
static bool inserted = 0xff; /* Impossible value */
bool present; bool present;
present = !lpc17_40_gpioread(GPIO_SD_CD); present = !lpc17_40_gpioread(GPIO_SD_CD);
if (present != inserted) if (present != g_sd_inserted)
{ {
sdio_mediachange(g_sdiodev, present); sdio_mediachange(g_sdiodev, present);
inserted = present; g_sd_inserted = present;
} }
return OK; return OK;
@@ -270,7 +272,8 @@ static int nsh_sdinitialize(void)
*/ */
#ifdef NSH_HAVE_MMCSD_CD #ifdef NSH_HAVE_MMCSD_CD
sdio_mediachange(g_sdiodev, !lpc17_40_gpioread(GPIO_SD_CD)); g_sd_inserted = !lpc17_40_gpioread(GPIO_SD_CD);
sdio_mediachange(g_sdiodev, g_sd_inserted);
#else #else
sdio_mediachange(g_sdiodev, true); sdio_mediachange(g_sdiodev, true);
#endif #endif
@@ -150,6 +150,9 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef NSH_HAVE_MMCSD #ifdef NSH_HAVE_MMCSD
static struct sdio_dev_s *g_sdiodev; static struct sdio_dev_s *g_sdiodev;
#endif #endif
#ifdef NSH_HAVE_MMCSD_CD
static bool g_sd_inserted;
#endif
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
@@ -204,14 +207,13 @@ static int nsh_waiter(int argc, char *argv[])
#ifdef NSH_HAVE_MMCSD_CDINT #ifdef NSH_HAVE_MMCSD_CDINT
static int nsh_cdinterrupt(int irq, void *context, void *arg) static int nsh_cdinterrupt(int irq, void *context, void *arg)
{ {
static bool inserted = 0xff; /* Impossible value */
bool present; bool present;
present = !lpc17_40_gpioread(GPIO_SD_CD); present = !lpc17_40_gpioread(GPIO_SD_CD);
if (present != inserted) if (present != g_sd_inserted)
{ {
sdio_mediachange(g_sdiodev, present); sdio_mediachange(g_sdiodev, present);
inserted = present; g_sd_inserted = present;
} }
return OK; return OK;
@@ -274,7 +276,8 @@ static int nsh_sdinitialize(void)
*/ */
#ifdef NSH_HAVE_MMCSD_CD #ifdef NSH_HAVE_MMCSD_CD
sdio_mediachange(g_sdiodev, !lpc17_40_gpioread(GPIO_SD_CD)); g_sd_inserted = !lpc17_40_gpioread(GPIO_SD_CD);
sdio_mediachange(g_sdiodev, g_sd_inserted);
#else #else
sdio_mediachange(g_sdiodev, true); sdio_mediachange(g_sdiodev, true);
#endif #endif
+4 -7
View File
@@ -54,7 +54,7 @@
static struct sdio_dev_s *g_sdio_dev; static struct sdio_dev_s *g_sdio_dev;
#ifdef HAVE_NCD #ifdef HAVE_NCD
static bool g_sd_inserted = 0xff; /* Impossible value */ static bool g_sd_inserted;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -102,8 +102,6 @@ int stm32_sdio_initialize(void)
int ret; int ret;
#ifdef HAVE_NCD #ifdef HAVE_NCD
bool cd_status;
/* Configure the card detect GPIO */ /* Configure the card detect GPIO */
stm32_configgpio(GPIO_SDIO_NCD); stm32_configgpio(GPIO_SDIO_NCD);
@@ -112,7 +110,6 @@ int stm32_sdio_initialize(void)
stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true, stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true,
stm32_ncd_interrupt, NULL); stm32_ncd_interrupt, NULL);
#endif #endif
/* Mount the SDIO-based MMC/SD block driver. /* Mount the SDIO-based MMC/SD block driver.
@@ -142,9 +139,9 @@ int stm32_sdio_initialize(void)
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Use SD card detect pin to check if a card is g_sd_inserted */ /* Use SD card detect pin to check if a card is g_sd_inserted */
cd_status = !stm32_gpioread(GPIO_SDIO_NCD); g_sd_inserted = !stm32_gpioread(GPIO_SDIO_NCD);
finfo("Card detect : %d\n", cd_status); finfo("Card detect : %d\n", g_sd_inserted);
sdio_mediachange(g_sdio_dev, cd_status); sdio_mediachange(g_sdio_dev, g_sd_inserted);
#else #else
/* Assume that the SD card is inserted. What choice do we have? */ /* Assume that the SD card is inserted. What choice do we have? */
@@ -95,6 +95,7 @@
#ifdef CONFIG_MMCSD #ifdef CONFIG_MMCSD
static struct sdio_dev_s *g_sdiodev; static struct sdio_dev_s *g_sdiodev;
static bool g_sd_inserted;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -112,14 +113,13 @@ static struct sdio_dev_s *g_sdiodev;
#ifdef NSH_HAVEMMCSD #ifdef NSH_HAVEMMCSD
static int nsh_cdinterrupt(int irq, void *context, void *arg) static int nsh_cdinterrupt(int irq, void *context, void *arg)
{ {
static bool inserted = 0xff; /* Impossible value */
bool present; bool present;
present = !stm32_gpioread(GPIO_SD_CD); present = !stm32_gpioread(GPIO_SD_CD);
if (present != inserted) if (present != g_sd_inserted)
{ {
sdio_mediachange(g_sdiodev, present); sdio_mediachange(g_sdiodev, present);
inserted = present; g_sd_inserted = present;
} }
return OK; return OK;
@@ -158,10 +158,6 @@ int board_app_initialize(uintptr_t arg)
int ret; int ret;
#ifdef NSH_HAVEMMCSD #ifdef NSH_HAVEMMCSD
/* Card detect */
bool cd_status;
/* Configure the card detect GPIO */ /* Configure the card detect GPIO */
stm32_configgpio(GPIO_SD_CD); 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 */ /* Use SD card detect pin to check if a card is inserted */
cd_status = !stm32_gpioread(GPIO_SD_CD); g_sd_inserted = !stm32_gpioread(GPIO_SD_CD);
_info("Card detect : %hhu\n", cd_status); _info("Card detect : %hhu\n", g_sd_inserted);
sdio_mediachange(g_sdiodev, cd_status); sdio_mediachange(g_sdiodev, g_sd_inserted);
#endif #endif
#ifdef CONFIG_INPUT #ifdef CONFIG_INPUT
@@ -58,7 +58,7 @@
static struct sdio_dev_s *g_sdio_dev; static struct sdio_dev_s *g_sdio_dev;
#ifdef HAVE_NCD #ifdef HAVE_NCD
static bool g_sd_inserted = 0xff; /* Impossible value */ static bool g_sd_inserted;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -106,10 +106,6 @@ int stm32_sdio_initialize(void)
int ret; int ret;
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Card detect */
bool cd_status;
/* Configure the card detect GPIO */ /* Configure the card detect GPIO */
stm32_configgpio(GPIO_SDMMC1_NCD); stm32_configgpio(GPIO_SDMMC1_NCD);
@@ -149,10 +145,10 @@ int stm32_sdio_initialize(void)
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Use SD card detect pin to check if a card is g_sd_inserted */ /* Use SD card detect pin to check if a card is g_sd_inserted */
cd_status = !stm32_gpioread(GPIO_SDMMC1_NCD); g_sd_inserted = !stm32_gpioread(GPIO_SDMMC1_NCD);
finfo("Card detect : %d\n", cd_status); finfo("Card detect : %d\n", g_sd_inserted);
sdio_mediachange(g_sdio_dev, cd_status); sdio_mediachange(g_sdio_dev, g_sd_inserted);
#else #else
/* Assume that the SD card is inserted. What choice do we have? */ /* Assume that the SD card is inserted. What choice do we have? */
@@ -56,7 +56,7 @@
static struct sdio_dev_s *g_sdio_dev; static struct sdio_dev_s *g_sdio_dev;
#ifdef HAVE_NCD #ifdef HAVE_NCD
static bool g_sd_inserted = 0xff; /* Impossible value */ static bool g_sd_inserted;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -104,10 +104,6 @@ int stm32_sdio_initialize(void)
int ret; int ret;
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Card detect */
bool cd_status;
/* Configure the card detect GPIO */ /* Configure the card detect GPIO */
stm32_configgpio(GPIO_SDIO_NCD); stm32_configgpio(GPIO_SDIO_NCD);
@@ -147,10 +143,10 @@ int stm32_sdio_initialize(void)
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Use SD card detect pin to check if a card is g_sd_inserted */ /* Use SD card detect pin to check if a card is g_sd_inserted */
cd_status = !stm32_gpioread(GPIO_SDIO_NCD); g_sd_inserted = !stm32_gpioread(GPIO_SDIO_NCD);
finfo("Card detect : %d\n", cd_status); finfo("Card detect : %d\n", g_sd_inserted);
sdio_mediachange(g_sdio_dev, cd_status); sdio_mediachange(g_sdio_dev, g_sd_inserted);
#else #else
/* Assume that the SD card is inserted. What choice do we have? */ /* Assume that the SD card is inserted. What choice do we have? */
@@ -56,7 +56,7 @@
static struct sdio_dev_s *g_sdio_dev; static struct sdio_dev_s *g_sdio_dev;
#ifdef HAVE_NCD #ifdef HAVE_NCD
static bool g_sd_inserted = 0xff; /* Impossible value */ static bool g_sd_inserted;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -104,10 +104,6 @@ int stm32_sdio_initialize(void)
int ret; int ret;
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Card detect */
bool cd_status;
/* Configure the card detect GPIO */ /* Configure the card detect GPIO */
stm32_configgpio(GPIO_SDIO_NCD); stm32_configgpio(GPIO_SDIO_NCD);
@@ -147,10 +143,10 @@ int stm32_sdio_initialize(void)
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Use SD card detect pin to check if a card is g_sd_inserted */ /* Use SD card detect pin to check if a card is g_sd_inserted */
cd_status = !stm32_gpioread(GPIO_SDIO_NCD); g_sd_inserted = !stm32_gpioread(GPIO_SDIO_NCD);
finfo("Card detect : %d\n", cd_status); finfo("Card detect : %d\n", g_sd_inserted);
sdio_mediachange(g_sdio_dev, cd_status); sdio_mediachange(g_sdio_dev, g_sd_inserted);
#else #else
/* Assume that the SD card is inserted. What choice do we have? */ /* Assume that the SD card is inserted. What choice do we have? */
@@ -58,7 +58,7 @@
static struct sdio_dev_s *g_sdio_dev; static struct sdio_dev_s *g_sdio_dev;
#ifdef HAVE_NCD #ifdef HAVE_NCD
static bool g_sd_inserted = 0xff; /* Impossible value */ static bool g_sd_inserted;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -106,10 +106,6 @@ int stm32_sdio_initialize(void)
int ret; int ret;
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Card detect */
bool cd_status;
/* Configure the card detect GPIO */ /* Configure the card detect GPIO */
stm32_configgpio(GPIO_SDMMC1_NCD); stm32_configgpio(GPIO_SDMMC1_NCD);
@@ -149,10 +145,10 @@ int stm32_sdio_initialize(void)
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Use SD card detect pin to check if a card is g_sd_inserted */ /* Use SD card detect pin to check if a card is g_sd_inserted */
cd_status = !stm32_gpioread(GPIO_SDMMC1_NCD); g_sd_inserted = !stm32_gpioread(GPIO_SDMMC1_NCD);
finfo("Card detect : %d\n", cd_status); finfo("Card detect : %d\n", g_sd_inserted);
sdio_mediachange(g_sdio_dev, cd_status); sdio_mediachange(g_sdio_dev, g_sd_inserted);
#else #else
/* Assume that the SD card is inserted. What choice do we have? */ /* Assume that the SD card is inserted. What choice do we have? */
@@ -54,7 +54,7 @@
static struct sdio_dev_s *g_sdio_dev; static struct sdio_dev_s *g_sdio_dev;
#ifdef HAVE_NCD #ifdef HAVE_NCD
static bool g_sd_inserted = 0xff; /* Impossible value */ static bool g_sd_inserted;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -102,10 +102,6 @@ int stm32_sdio_initialize(void)
int ret; int ret;
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Card detect */
bool cd_status;
/* Configure the card detect GPIO */ /* Configure the card detect GPIO */
stm32_configgpio(GPIO_SDIO_NCD); stm32_configgpio(GPIO_SDIO_NCD);
@@ -145,10 +141,10 @@ int stm32_sdio_initialize(void)
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Use SD card detect pin to check if a card is g_sd_inserted */ /* Use SD card detect pin to check if a card is g_sd_inserted */
cd_status = !stm32_gpioread(GPIO_SDIO_NCD); g_sd_inserted = !stm32_gpioread(GPIO_SDIO_NCD);
finfo("Card detect : %d\n", cd_status); finfo("Card detect : %d\n", g_sd_inserted);
sdio_mediachange(g_sdio_dev, cd_status); sdio_mediachange(g_sdio_dev, g_sd_inserted);
#else #else
/* Assume that the SD card is inserted. What choice do we have? */ /* Assume that the SD card is inserted. What choice do we have? */
@@ -55,7 +55,7 @@
static struct sdio_dev_s *g_sdio_dev; static struct sdio_dev_s *g_sdio_dev;
#ifdef HAVE_NCD #ifdef HAVE_NCD
static bool g_sd_inserted = 0xff; /* Impossible value */ static bool g_sd_inserted;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -103,10 +103,6 @@ int stm32_sdio_initialize(void)
int ret; int ret;
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Card detect */
bool cd_status;
/* Configure the card detect GPIO */ /* Configure the card detect GPIO */
stm32_configgpio(GPIO_SDIO_NCD); stm32_configgpio(GPIO_SDIO_NCD);
@@ -146,10 +142,10 @@ int stm32_sdio_initialize(void)
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Use SD card detect pin to check if a card is g_sd_inserted */ /* Use SD card detect pin to check if a card is g_sd_inserted */
cd_status = !stm32_gpioread(GPIO_SDIO_NCD); g_sd_inserted = !stm32_gpioread(GPIO_SDIO_NCD);
finfo("Card detect : %d\n", cd_status); finfo("Card detect : %d\n", g_sd_inserted);
sdio_mediachange(g_sdio_dev, cd_status); sdio_mediachange(g_sdio_dev, g_sd_inserted);
#else #else
/* Assume that the SD card is inserted. What choice do we have? */ /* Assume that the SD card is inserted. What choice do we have? */
@@ -55,7 +55,7 @@
static struct sdio_dev_s *g_sdio_dev; static struct sdio_dev_s *g_sdio_dev;
#ifdef HAVE_NCD #ifdef HAVE_NCD
static bool g_sd_inserted = 0xff; /* Impossible value */ static bool g_sd_inserted;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -103,10 +103,6 @@ int stm32_sdio_initialize(void)
int ret; int ret;
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Card detect */
bool cd_status;
/* Configure the card detect GPIO */ /* Configure the card detect GPIO */
stm32_configgpio(GPIO_SDIO_NCD); stm32_configgpio(GPIO_SDIO_NCD);
@@ -146,10 +142,10 @@ int stm32_sdio_initialize(void)
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Use SD card detect pin to check if a card is g_sd_inserted */ /* Use SD card detect pin to check if a card is g_sd_inserted */
cd_status = !stm32_gpioread(GPIO_SDIO_NCD); g_sd_inserted = !stm32_gpioread(GPIO_SDIO_NCD);
finfo("Card detect : %d\n", cd_status); finfo("Card detect : %d\n", g_sd_inserted);
sdio_mediachange(g_sdio_dev, cd_status); sdio_mediachange(g_sdio_dev, g_sd_inserted);
#else #else
/* Assume that the SD card is inserted. What choice do we have? */ /* Assume that the SD card is inserted. What choice do we have? */
@@ -58,7 +58,7 @@
static struct sdio_dev_s *g_sdio_dev; static struct sdio_dev_s *g_sdio_dev;
#ifdef HAVE_NCD #ifdef HAVE_NCD
static bool g_sd_inserted = 0xff; /* Impossible value */ static bool g_sd_inserted;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -106,10 +106,6 @@ int stm32l4_sdio_initialize(void)
int ret; int ret;
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Card detect */
bool cd_status;
/* Configure the card detect GPIO */ /* Configure the card detect GPIO */
stm32l4_configgpio(GPIO_SDMMC1_NCD); stm32l4_configgpio(GPIO_SDMMC1_NCD);
@@ -149,10 +145,10 @@ int stm32l4_sdio_initialize(void)
#ifdef HAVE_NCD #ifdef HAVE_NCD
/* Use SD card detect pin to check if a card is g_sd_inserted */ /* Use SD card detect pin to check if a card is g_sd_inserted */
cd_status = !stm32l4_gpioread(GPIO_SDMMC1_NCD); g_sd_inserted = !stm32l4_gpioread(GPIO_SDMMC1_NCD);
finfo("Card detect : %d\n", cd_status); finfo("Card detect : %d\n", g_sd_inserted);
sdio_mediachange(g_sdio_dev, cd_status); sdio_mediachange(g_sdio_dev, g_sd_inserted);
#else #else
/* Assume that the SD card is inserted. What choice do we have? */ /* Assume that the SD card is inserted. What choice do we have? */