diff --git a/configs/freedom-k64f/Kconfig b/configs/freedom-k64f/Kconfig index e1c32bbfb04..86130927032 100644 --- a/configs/freedom-k64f/Kconfig +++ b/configs/freedom-k64f/Kconfig @@ -8,7 +8,7 @@ if ARCH_BOARD_FREEDOM_K64F config FRDMK64F_SDHC_AUTOMOUNT bool "SDHC automounter" default n - depends on FS_AUTOMOUNTER && SAMA5_SDHC + depends on FS_AUTOMOUNTER && KINETIS_SDHC if FRDMK64F_SDHC_AUTOMOUNT @@ -22,7 +22,7 @@ config FRDMK64F_SDHC_AUTOMOUNT_BLKDEV config FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT string "SDHC mount point" - default "/mnt/sdcard0" + default "/mnt/sdcard" config FRDMK64F_SDHC_AUTOMOUNT_DDELAY int "SDHC debounce delay (milliseconds)" @@ -33,5 +33,4 @@ config FRDMK64F_SDHC_AUTOMOUNT_UDELAY default 2000 endif # FRDMK64F_SDHC_AUTOMOUNT - -endif +endif # ARCH_BOARD_FREEDOM_K64F diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index c53b23a15b9..9b7e6862967 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -853,6 +853,9 @@ Status 2016-07-13: Add SD automounter logic; broke out SDHC logic into a separate file. The nsh configuration now has SDHC enabled be default. Does not - yet work. You might want to disable SDHC and MMC/SD if you are using + yet work. The basic problem seems to be that it does not sense the + presence of the SD card on PTE6. No interrupts are generated when the + SD card is inserted or removed. You might want to disable SDHC and + MMC/SD if you are using this configuration. \ No newline at end of file diff --git a/configs/freedom-k64f/src/freedom-k64f.h b/configs/freedom-k64f/src/freedom-k64f.h index 227a6c71a22..aac232930bd 100644 --- a/configs/freedom-k64f/src/freedom-k64f.h +++ b/configs/freedom-k64f/src/freedom-k64f.h @@ -134,7 +134,7 @@ # endif # ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT -# define CONFIG_FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard0" +# define CONFIG_FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard" # endif # ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT_DDELAY diff --git a/configs/freedom-k64f/src/k64_automount.c b/configs/freedom-k64f/src/k64_automount.c index 4862d55dad4..8ec1be29ffe 100644 --- a/configs/freedom-k64f/src/k64_automount.c +++ b/configs/freedom-k64f/src/k64_automount.c @@ -149,7 +149,7 @@ static int k64_attach(FAR const struct automount_lower_s *lower, /* Recover references to our structure */ config = (FAR struct k64_automount_config_s *)lower; - DEBUGASSERT(config && config->state); + DEBUGASSERT(config != NULL && config->state != NULL); state = config->state; @@ -188,7 +188,7 @@ static void k64_enable(FAR const struct automount_lower_s *lower, bool enable) /* Recover references to our structure */ config = (FAR struct k64_automount_config_s *)lower; - DEBUGASSERT(config && config->state); + DEBUGASSERT(config != NULL && config->state != NULL); state = config->state; @@ -231,11 +231,6 @@ static void k64_enable(FAR const struct automount_lower_s *lower, bool enable) static bool k64_inserted(FAR const struct automount_lower_s *lower) { - FAR const struct k64_automount_config_s *config; - - config = (FAR struct k64_automount_config_s *)lower; - DEBUGASSERT(config && config->state); - return k64_cardinserted(); } diff --git a/configs/freedom-k64f/src/k64_sdhc.c b/configs/freedom-k64f/src/k64_sdhc.c index 6b4dcf35e36..4083235048b 100644 --- a/configs/freedom-k64f/src/k64_sdhc.c +++ b/configs/freedom-k64f/src/k64_sdhc.c @@ -114,11 +114,14 @@ static void k64_mediachange(void) */ inserted = !kinetis_gpioread(GPIO_SD_CARDDETECT); + mcinfo("inserted: %s\n", inserted ? "Yes" : "No"); /* Has the pin changed state? */ if (inserted != g_sdhc.inserted) { + mcinfo("Media change: %d->%d\n", g_sdhc.inserted, inserted); + /* Yes.. perform the appropriate action (this might need some debounce). */ g_sdhc.inserted = inserted; @@ -127,7 +130,7 @@ static void k64_mediachange(void) #ifdef CONFIG_FRDMK64F_SDHC_AUTOMOUNT /* Let the automounter know about the insertion event */ - k64_automount_event(SDHC0_SLOTNO, k64_cardinserted()); + k64_automount_event(k64_cardinserted()); #endif } } @@ -162,9 +165,10 @@ int k64_sdhc_initialize(void) /* Configure GPIO pins */ + kinetis_pinconfig(GPIO_SD_CARDDETECT); + /* Attached the card detect interrupt (but don't enable it yet) */ - kinetis_pinconfig(GPIO_SD_CARDDETECT); kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt); /* Configure the write protect GPIO -- None */ @@ -215,7 +219,15 @@ int k64_sdhc_initialize(void) #ifdef HAVE_AUTOMOUNTER bool k64_cardinserted(void) { - return !kinetis_gpioread(GPIO_SD_CARDDETECT); + 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"); + return inserted; } #endif