diff --git a/boards/arm/samv7/common/include/board_hsmci.h b/boards/arm/samv7/common/include/board_hsmci.h index 94dc1dced5..db256f016c 100644 --- a/boards/arm/samv7/common/include/board_hsmci.h +++ b/boards/arm/samv7/common/include/board_hsmci.h @@ -59,7 +59,7 @@ extern "C" ****************************************************************************/ int sam_hsmci_initialize(int slotno, int minor, gpio_pinset_t cdcfg, - int cdirq); + int cdirq, bool cdinvert); /**************************************************************************** * Name: sam_cardinserted diff --git a/boards/arm/samv7/common/src/sam_hsmci.c b/boards/arm/samv7/common/src/sam_hsmci.c index e0a2bd8e09..576bce0894 100644 --- a/boards/arm/samv7/common/src/sam_hsmci.c +++ b/boards/arm/samv7/common/src/sam_hsmci.c @@ -56,6 +56,7 @@ struct sam_hsmci_state_s int cdirq; /* Interrupt number (same as pid) */ uint8_t slotno; /* Slot number */ bool cd; /* TRUE: card is inserted */ + bool cdinvert; /* Invert card detection to 0 signaling card */ }; /**************************************************************************** @@ -89,9 +90,9 @@ static bool sam_cardinserted_internal(struct sam_hsmci_state_s *state) /* Get the state of the PIO pin */ - inserted = sam_gpioread(state->cdcfg); - finfo("Slot %d inserted: %s\n", state->slotno, inserted ? "NO" : "YES"); - return !inserted; + inserted = sam_gpioread(state->cdcfg) != state->cdinvert; + finfo("Slot %d inserted: %s\n", state->slotno, inserted ? "YES" : "NO"); + return inserted; } /**************************************************************************** @@ -181,7 +182,7 @@ static inline struct sam_hsmci_state_s *sam_hsmci_state(int slotno) ****************************************************************************/ int sam_hsmci_initialize(int slotno, int minor, gpio_pinset_t cdcfg, - int cdirq) + int cdirq, bool cdinvert) { struct sam_hsmci_state_s *state; int ret; @@ -197,6 +198,7 @@ int sam_hsmci_initialize(int slotno, int minor, gpio_pinset_t cdcfg, state->cdcfg = cdcfg; state->cdirq = cdirq; + state->cdinvert = cdinvert; /* Initialize card-detect, write-protect, and power enable PIOs */ diff --git a/boards/arm/samv7/same70-qmtech/src/sam_bringup.c b/boards/arm/samv7/same70-qmtech/src/sam_bringup.c index 3039d11486..53835364df 100644 --- a/boards/arm/samv7/same70-qmtech/src/sam_bringup.c +++ b/boards/arm/samv7/same70-qmtech/src/sam_bringup.c @@ -160,7 +160,7 @@ int sam_bringup(void) /* Initialize the HSMCI0 driver */ ret = sam_hsmci_initialize(HSMCI0_SLOTNO, HSMCI0_MINOR, GPIO_HSMCI0_CD, - IRQ_HSMCI0_CD); + IRQ_HSMCI0_CD, true); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", diff --git a/boards/arm/samv7/same70-xplained/src/sam_bringup.c b/boards/arm/samv7/same70-xplained/src/sam_bringup.c index 688ae3064d..082da6c93c 100644 --- a/boards/arm/samv7/same70-xplained/src/sam_bringup.c +++ b/boards/arm/samv7/same70-xplained/src/sam_bringup.c @@ -221,7 +221,7 @@ int sam_bringup(void) /* Initialize the HSMCI0 driver */ ret = sam_hsmci_initialize(HSMCI0_SLOTNO, HSMCI0_MINOR, GPIO_HSMCI0_CD, - IRQ_HSMCI0_CD); + IRQ_HSMCI0_CD, true); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", diff --git a/boards/arm/samv7/samv71-xult/src/sam_bringup.c b/boards/arm/samv7/samv71-xult/src/sam_bringup.c index 38d816ed2a..0a93b62257 100644 --- a/boards/arm/samv7/samv71-xult/src/sam_bringup.c +++ b/boards/arm/samv7/samv71-xult/src/sam_bringup.c @@ -337,7 +337,7 @@ int sam_bringup(void) /* Initialize the HSMCI0 driver */ ret = sam_hsmci_initialize(HSMCI0_SLOTNO, HSMCI0_MINOR, GPIO_HSMCI0_CD, - IRQ_HSMCI0_CD); + IRQ_HSMCI0_CD, true); if (ret < 0) { syslog(LOG_ERR, "ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n",