static void fmuk66_mediachange(struct fmuk66_sdhc_state_s *sdhc) { bool inserted; /* Get the current value of the card detect pin. This pin is pulled up on * board. So low means that a card is present. */ inserted = !kinetis_gpioread(GPIO_SD_CARDDETECT); mcinfo("inserted: %s\n", inserted ? "Yes" : "No"); /* Has the pin changed state? */ if (inserted != sdhc->inserted) { mcinfo("Media change: %d->%d\n", sdhc->inserted, inserted); /* Yes.. perform the appropriate action (this might need some debounce). */ sdhc->inserted = inserted; sdhc_mediachange(sdhc->sdhc, inserted); #ifdef CONFIG_FMUK66_SDHC_AUTOMOUNT /* Let the automounter know about the insertion event */ fmuk66_automount_event(fmuk66_cardinserted()); #endif } }
static void kinetis_mediachange(void) { bool inserted; /* Get the current value of the card detect pin. This pin is pulled up on * board. So low means that a card is present. */ inserted = !kinetis_gpioread(GPIO_SD_CARDDETECT); /* Has the pin changed state? */ if (inserted != g_nsh.inserted) { /* Yes.. perform the appropriate action (this might need some debounce). */ g_nsh.inserted = inserted; sdhc_mediachange(g_nsh.sdhc, inserted); /* If the card has been inserted, then check if it is write protected * as well. The pin is pulled up, but apparently logic high means * write protected. */ if (inserted) { sdhc_wrprotect(g_nsh.sdhc, kinetis_gpioread(GPIO_SD_WRPROTECT)); } } }
static void kinetis_mediachange(void) { bool inserted; /* Get the current value of the card detect pin. This pin is pulled up on * board. So low means that a card is present. */ inserted = !kinetis_gpioread(GPIO_SD_CARDDETECT); /* Has the pin changed state? */ if (inserted != g_nsh.inserted) { /* Yes.. perform the appropriate action (this might need some debounce). */ g_nsh.inserted = inserted; sdhc_mediachange(g_nsh.sdhc, inserted); } }