Author: Gregory Nutt <gnutt@nuttx.org>
Run all .c and .h files in last PR through nxstyle. Author: 脚蹬破拖鞋 <happypapa@yeah.net> Add Imxrt usdhc insert or remove detection (#43) * Add usdhc card insertion and removal detection using interrupt for imxrt. * Add interrupt handle when usdhc insert or remove.
This commit is contained in:
parent
981d7004fa
commit
0b3dac2c33
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/imxrt/imxrt_ehci.c
|
||||
*
|
||||
* Copyright (C) 2013-2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013-2017, 2020 Gregory Nutt. All rights reserved.
|
||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Dave Marples <dave@marples.net>
|
||||
*
|
||||
|
@ -78,7 +78,7 @@
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#if ((defined(CONFIG_IMXRT_USDHC1) && !defined(CONFIG_IMXRT_USDHC2)) || \
|
||||
#if ((defined(CONFIG_IMXRT_USDHC1) && !defined(CONFIG_IMXRT_USDHC2)) || \
|
||||
(defined(CONFIG_IMXRT_USDHC2) && !defined(CONFIG_IMXRT_USDHC1)))
|
||||
# define IMXRT_MAX_SDHC_DEV_SLOTS 1
|
||||
#elif (defined(CONFIG_IMXRT_USDHC1) && defined(CONFIG_IMXRT_USDHC2))
|
||||
@ -1232,11 +1232,30 @@ static int imxrt_interrupt(int irq, void *context, FAR void *arg)
|
||||
|
||||
/* We don't want any more ints now, so switch it off */
|
||||
|
||||
priv->cintints = 0;
|
||||
regval &= ~USDHC_INT_CINT;
|
||||
priv->cintints = regval;
|
||||
putreg32(regval, priv->addr + IMXRT_USDHC_IRQSIGEN_OFFSET);
|
||||
}
|
||||
|
||||
if ((pending & USDHC_INT_CINS) != 0 || (pending & USDHC_INT_CRM) != 0)
|
||||
{
|
||||
if (up_interrupt_context())
|
||||
{
|
||||
/* Yes.. queue it */
|
||||
|
||||
mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg);
|
||||
(void)work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback,
|
||||
priv->cbarg, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No.. then just call the callback here */
|
||||
|
||||
mcinfo("Callback to %p(%p)\n", priv->callback, priv->cbarg);
|
||||
priv->callback(priv->cbarg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle wait events *****************************************************/
|
||||
|
||||
pending = enabled & priv->waitints;
|
||||
@ -3019,7 +3038,14 @@ void imxrt_usdhc_set_sdio_card_isr(FAR struct sdio_dev_s *dev,
|
||||
priv->cintints = 0;
|
||||
}
|
||||
|
||||
flags = enter_critical_section();
|
||||
#if defined(CONFIG_MMCSD_HAVE_CARDDETECT)
|
||||
if (priv->sw_cd_gpio == 0)
|
||||
{
|
||||
priv->cintints |= USDHC_INT_CINS | USDHC_INT_CRM;
|
||||
}
|
||||
#endif
|
||||
|
||||
flags = enter_critical_section();
|
||||
regval = getreg32(priv->addr + IMXRT_USDHC_IRQSIGEN_OFFSET);
|
||||
regval = (regval & ~USDHC_INT_CINT) | priv->cintints;
|
||||
putreg32(regval, priv->addr + IMXRT_USDHC_IRQSIGEN_OFFSET);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/imxrt/imxrt1060-evk/src/imxrt_bringup.c
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2018, 2020 Gregory Nutt. All rights reserved.
|
||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||
* David Sidrane <david_s5@nscdg.com>
|
||||
*
|
||||
@ -121,7 +121,10 @@ static int nsh_sdmmc_initialize(void)
|
||||
"ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n",
|
||||
ret);
|
||||
}
|
||||
|
||||
imxrt_usdhc_set_sdio_card_isr(sdmmc, NULL, NULL);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user