41
NXPTM M522XX, KINETIS and i.MX RT / Re: Using different pins for SD VSELECT, PWREN and CARD DETECT?
« Last post by mark on December 28, 2023, 12:37:46 AM »Hi
The selections are in the file app_hw_xxxx.h since it is specific to the HW.
Assuming you are working with an i.MX RT the default tends to be
#define SDCARD_DETECT_INPUT_INTERRUPT // use card detect interrupt rather than polling the card
#define SDCARD_DETECTION() ((SDHC_PRSSTAT & SDHC_PRSSTAT_CINST) != 0) // card detection input
and if SDHC_DETECT_INTERRUPT_GPIO is enabled a GPIO can be used instead.
but it can be polled (via GPIO) with
#define SDCARD_DETECT_INPUT_POLL // use card detect switch for detection polling (use together with T_CHECK_CARD_REMOVAL)
or polled by reading an SD card register if neither is enabled.
There is no specific VSEL control for the i.MX RT but if needed it can be added to the POWER_TO_SD_CARD() macro via a GPIO.
Regards
Mark
P.S: Note that the i.MX RT project has only used the SDHC's dedicated card detection line and so I found that I needed to adjust some conditional defines in the mass storage code so that the GPIO interrupt initialisation was included (for example). I have checked these changes in but not tested on HW (only in simulator). I used this on an RT 1020:
#define SDCARD_DETECT_INPUT_INTERRUPT // use card detect interrupt rather than polling the card
#define SDHC_DETECT_INTERRUPT_GPIO // use general GPIO rather than the SDHC's detect input
#if defined SDHC_DETECT_INTERRUPT_GPIO
#define SDCARD_DETECT_PORT PORT2
#define SDCARD_DETECT_PIN PIN_GPIO_EMC_00_GPIO2_IO00
#define PRIORITY_SDCARD_DETECT_PORT_INT PRIORITY_PORT_2_LOW
#define SDCARD_DETECTION() (_READ_PORT_MASK(2, SDCARD_DETECT_PIN) == 0) // card detection input
The selections are in the file app_hw_xxxx.h since it is specific to the HW.
Assuming you are working with an i.MX RT the default tends to be
#define SDCARD_DETECT_INPUT_INTERRUPT // use card detect interrupt rather than polling the card
#define SDCARD_DETECTION() ((SDHC_PRSSTAT & SDHC_PRSSTAT_CINST) != 0) // card detection input
and if SDHC_DETECT_INTERRUPT_GPIO is enabled a GPIO can be used instead.
but it can be polled (via GPIO) with
#define SDCARD_DETECT_INPUT_POLL // use card detect switch for detection polling (use together with T_CHECK_CARD_REMOVAL)
or polled by reading an SD card register if neither is enabled.
There is no specific VSEL control for the i.MX RT but if needed it can be added to the POWER_TO_SD_CARD() macro via a GPIO.
Regards
Mark
P.S: Note that the i.MX RT project has only used the SDHC's dedicated card detection line and so I found that I needed to adjust some conditional defines in the mass storage code so that the GPIO interrupt initialisation was included (for example). I have checked these changes in but not tested on HW (only in simulator). I used this on an RT 1020:
#define SDCARD_DETECT_INPUT_INTERRUPT // use card detect interrupt rather than polling the card
#define SDHC_DETECT_INTERRUPT_GPIO // use general GPIO rather than the SDHC's detect input
#if defined SDHC_DETECT_INTERRUPT_GPIO
#define SDCARD_DETECT_PORT PORT2
#define SDCARD_DETECT_PIN PIN_GPIO_EMC_00_GPIO2_IO00
#define PRIORITY_SDCARD_DETECT_PORT_INT PRIORITY_PORT_2_LOW
#define SDCARD_DETECTION() (_READ_PORT_MASK(2, SDCARD_DETECT_PIN) == 0) // card detection input