{"id":23744857,"url":"https://github.com/stm32duino/stm32sd","last_synced_at":"2025-04-05T02:08:31.625Z","repository":{"id":52644488,"uuid":"101858752","full_name":"stm32duino/STM32SD","owner":"stm32duino","description":"Enables reading and writing on SD card using SD card slot of the STM32 Board.","archived":false,"fork":false,"pushed_at":"2025-03-27T18:26:46.000Z","size":206,"stargazers_count":162,"open_issues_count":1,"forks_count":25,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-29T01:08:47.037Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stm32duino.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-30T08:43:01.000Z","updated_at":"2025-03-27T18:26:50.000Z","dependencies_parsed_at":"2022-08-13T02:01:19.965Z","dependency_job_id":"3e6b335f-3f51-4939-8774-b11da5c2a502","html_url":"https://github.com/stm32duino/STM32SD","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stm32duino%2FSTM32SD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stm32duino%2FSTM32SD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stm32duino%2FSTM32SD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stm32duino%2FSTM32SD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stm32duino","download_url":"https://codeload.github.com/stm32duino/STM32SD/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276164,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-31T12:50:11.601Z","updated_at":"2025-04-05T02:08:31.609Z","avatar_url":"https://github.com/stm32duino.png","language":"C","readme":"# STM32 SD library for Arduino\n\nWith an STM32 board with SD card slot availability, this library enables\nreading and writing on SD card using SD card slot of a STM32 board (NUCLEO, DISCOVERY, ...).\nThis library is for SD card slots connected to the SDIO-/SDMMC-hardware of the processor.\nFor slots connected to SPI-hardware use the standard Arduino SD library.\n\nThis library follow Arduino API.\n\nFor more information about it, please visit:\nhttp://www.arduino.cc/en/Reference/SD\n\n## Dependency\n\nThis library is based on FatFs, a generic FAT file system module for small embedded systems.\n[http://elm-chan.org/fsw/ff](http://elm-chan.org/fsw/ff/00index_e.html)\n\nThe FatFs has been ported as Arduino library [here](https://github.com/stm32duino/FatFs).\nThe STM32SD library depends on it.\n\n## Configuration\n\n### FatFs\nThe FatFs has several user defined options, which is specified from within the `ffconf.h` file.\n\nThis library provides a default user defined options file named `ffconf_default.h`.\n\nUser can provide his own defined options by adding his configuration in a file named\n`ffconf_custom.h` at sketch level or in variant folder.\n\n### SD\n\nSome default definitions can be overridden using:\n * board `variant*.h`\n * `build_opt.h`: see [Customize build options](https://github.com/stm32duino/Arduino_Core_STM32/wiki/Customize-build-options-using-build_opt.h)\n\n * `hal_conf_extra.h`: see [HAL configuration](https://github.com/stm32duino/Arduino_Core_STM32/wiki/HAL-configuration)\n\n#### SDIO/SDMMC pins definition\n\n\u003e [!IMPORTANT]\n\u003e Since STM32 core v2.6.0, the `PinMap_SD[]` array defined in the `PeripheralPins*.c` has been split per signals:\n\n```C\nPinMap_SD_CK[]\nPinMap_SD_DATA0[]\nPinMap_SD_DATA1[]\nPinMap_SD_DATA2[]\nPinMap_SD_DATA3[]\nPinMap_SD_DATA4[]\nPinMap_SD_DATA5[]\nPinMap_SD_DATA6[]\nPinMap_SD_DATA7[]\n/* Only for SDMMC */\nPinMap_SD_CKIN[]\nPinMap_SD_CDIR[]\nPinMap_SD_D0DIR[]\nPinMap_SD_D123DIR[]\n```\n\nThis allows to define the SDIO/SDMMC pins to use instead of using all the pins defined in the old array.\nBy default, if no pins are explicitly defined, the first one from each array is used.\n\n* To redefine the default one, use the following macros:\n\n  * `SDX_D0`\n  * `SDX_D1`\n  * `SDX_D2`\n  * `SDX_D3`\n  * `SDX_CMD`\n  * `SDX_CK`\n\n  * Only for `SDMMC`:\n    * `SDX_CKIN`\n    * `SDX_CDIR`\n    * `SDX_D0DIR`\n    * `SDX_D123DIR`\n\n* or redefine the default one before call of `begin()` of `SDClass` or `init()` of `Sd2Card`, using the following methods:\n\n  * `setDx(uint32_t data0, uint32_t data1, uint32_t data2, uint32_t data3)`\n  \u003e [!NOTE]\n  \u003e If `SD_BUS_WIDE_1B` is used only `data0` is needed.\n  * `setCK(uint32_t ck)`\n  * `setCK(PinName ck)`\n  * `setCMD(uint32_t cmd)`\n  * `setCMD(PinName cmd)`\n\n  * Only for `SDMMC`:\n    * `setCKIN(uint32_t ckin)`\n    * `setCKIN(PinName ckin)`\n    * `setCDIR(uint32_t cdir)`\n    * `setCDIR(PinName cdir)`\n    * `setDxDIR(uint32_t d0dir, uint32_t d123dir)`\n    * `setDxDIR(PinName d0dir, PinName d123dir)`\n\n  *Code snippet:*\n```C++\n  Sd2Card card;\n  card.setDx(PE12, PE13, PE14, PE15);\n  card.setCMD(PB_14); // using PinName\n  card.setCK(PB15);\n  card.init();\n```\n  or\n```C++\n  SD.setDx(PE12, PE13, PE14, PE15);\n  SD.setCMD(PB14);\n  SD.setCK(PB_15); // using PinName\n  SD.begin();\n```\n\n#### SD configurations\n\n* `SD_INSTANCE`: some STM32 can have 2 SD peripherals `SDMMC1` and `SDMMC2`, note that this library can managed only one peripheral\n  * `SDIO` or `SDMMC1` (default)\n  * `SDMMC2`\n\n* `SD_HW_FLOW_CTRL`: specifies whether the SDMMC hardware flow control is enabled or disabled\n  * `SD_HW_FLOW_CTRL_ENABLE`\n  * `SD_HW_FLOW_CTRL_DISABLE` (default)\n\n* `SD_BUS_WIDE`: specifies the SDMMC bus width\n  * `SD_BUS_WIDE_1B`\n  * `SD_BUS_WIDE_4B` (default)\n\n* `SD_CLK_DIV`: specifies the clock frequency of the SDMMC controller (0-255)\n  * `SDIO_TRANSFER_CLK_DIV` (default) for `SDIO`\n  * `SDMMC_TRANSFER_CLK_DIV` or `SDMMC_NSpeed_CLK_DIV` (default) for `SDMMC`\n\n#### SD Transceiver\n\n* To specifies whether external Transceiver is present and enabled (Available only on some STM32) add:\n\n  `#define USE_SD_TRANSCEIVER  1`\n* Then define pins:\n  * `SD_TRANSCEIVER_EN` pin number to enable the level shifter\n  * `SD_TRANSCEIVER_SEL` pin number for voltage selection\n\n#### SD detect and timeout\n* `SD_DETECT_PIN` pin number\n* `SD_DETECT_LEVEL` default `LOW`\n* `SD_DATATIMEOUT` constant for Read/Write block\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstm32duino%2Fstm32sd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstm32duino%2Fstm32sd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstm32duino%2Fstm32sd/lists"}