How to use gpio_cd and gpio_wp?
I am unable to find it anywhere else but inside sdmmc_host_init_slot.
SDCard card detect and write protect pins
-
- Posts: 54
- Joined: Mon Dec 05, 2016 12:34 am
Re: SDCard card detect and write protect pins
If you set these pin numbers in the sdmcc_slot_config_t structure which is used to initialise the SDMMC host, then they will be used for these functions. Otherwise these functions are not used by the host.
Refer to this comment in the SDMMC example:
https://github.com/espressif/esp-idf/bl ... card.c#L31
And the relevant section in the documentation:
http://esp-idf.readthedocs.io/en/latest ... river-apis
If set, these pins will be configured as GPIO inputs by the driver during intialisation. There is not need to do separate pin configuration.
Refer to this comment in the SDMMC example:
https://github.com/espressif/esp-idf/bl ... card.c#L31
And the relevant section in the documentation:
http://esp-idf.readthedocs.io/en/latest ... river-apis
If set, these pins will be configured as GPIO inputs by the driver during intialisation. There is not need to do separate pin configuration.
Re: SDCard card detect and write protect pins
Within the driver will a specific error be thrown if a write operation is called and wp is on? There is an interrupt for card detect but I don't think any user callback.
Re: SDCard card detect and write protect pins
Hmm, i think we should handle WP in software, but i have just checked the code and I don't see that happening anywhere. Need to fix this, thanks for pointing this out. As a temporary workaround, please check the state of WP pin in the application before calling sdmmc driver write function.
Regarding card detect, there's no interrupt at this point. I think the application can configure an interrupt using the gpio driver (which will not interfere with SDMMC peripheral, because unlike other pins, card detect is routed via gpio mux).
Also good point on adding specific error codes for both errors.
Regarding card detect, there's no interrupt at this point. I think the application can configure an interrupt using the gpio driver (which will not interfere with SDMMC peripheral, because unlike other pins, card detect is routed via gpio mux).
Also good point on adding specific error codes for both errors.
Re: SDCard card detect and write protect pins
https://github.com/espressif/esp-idf/bl ... ost.c#L254
https://github.com/espressif/esp-idf/bl ... ion.c#L174
But yes it could be useful as a separate gpio interrupt, although may be nice if driver detects card is removed and gracefully aborts.
https://github.com/espressif/esp-idf/bl ... ion.c#L174
But yes it could be useful as a separate gpio interrupt, although may be nice if driver detects card is removed and gracefully aborts.
Re: SDCard card detect and write protect pins
What I meant was "no interrupt callback exposed to the application", sorry for not making this clear.
I think at this point if you unplug the card during the transfer, you will eventually get a transfer timeout reported by the SD host. Handling the CD interrupt properly will make the transfer bail out faster, and we can potentially give a better error code.
I think at this point if you unplug the card during the transfer, you will eventually get a transfer timeout reported by the SD host. Handling the CD interrupt properly will make the transfer bail out faster, and we can potentially give a better error code.
Re: SDCard card detect and write protect pins
Hi,
I need to detect sd card is plug out while application is running. Do we have event or interrupt handler.
I can detect using mount failure on startup. I wonder is there any method to detect failure of sd card during application is running.
Thanks,
Naeem
I need to detect sd card is plug out while application is running. Do we have event or interrupt handler.
I can detect using mount failure on startup. I wonder is there any method to detect failure of sd card during application is running.
Thanks,
Naeem
Who is online
Users browsing this forum: Majestic-12 [Bot] and 75 guests