sdmmc_default_configs.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include "sdkconfig.h"
  8. #include "sdmmc_types.h"
  9. #include "soc/soc_caps.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. #define SDMMC_HOST_SLOT_0 0 ///< SDMMC slot 0
  14. #define SDMMC_HOST_SLOT_1 1 ///< SDMMC slot 1
  15. /**
  16. * @brief Default sdmmc_host_t structure initializer for SDMMC peripheral
  17. *
  18. * Uses SDMMC peripheral, with 4-bit mode enabled, and max frequency set to 20MHz
  19. */
  20. #define SDMMC_HOST_DEFAULT() {\
  21. .flags = SDMMC_HOST_FLAG_8BIT | \
  22. SDMMC_HOST_FLAG_4BIT | \
  23. SDMMC_HOST_FLAG_1BIT | \
  24. SDMMC_HOST_FLAG_DDR, \
  25. .slot = SDMMC_HOST_SLOT_1, \
  26. .max_freq_khz = SDMMC_FREQ_DEFAULT, \
  27. .io_voltage = 3.3f, \
  28. .init = &sdmmc_host_init, \
  29. .set_bus_width = &sdmmc_host_set_bus_width, \
  30. .get_bus_width = &sdmmc_host_get_slot_width, \
  31. .set_bus_ddr_mode = &sdmmc_host_set_bus_ddr_mode, \
  32. .set_card_clk = &sdmmc_host_set_card_clk, \
  33. .set_cclk_always_on = &sdmmc_host_set_cclk_always_on, \
  34. .do_transaction = &sdmmc_host_do_transaction, \
  35. .deinit = &sdmmc_host_deinit, \
  36. .io_int_enable = sdmmc_host_io_int_enable, \
  37. .io_int_wait = sdmmc_host_io_int_wait, \
  38. .command_timeout_ms = 0, \
  39. .get_real_freq = &sdmmc_host_get_real_freq, \
  40. .input_delay_phase = SDMMC_DELAY_PHASE_0, \
  41. .set_input_delay = &sdmmc_host_set_input_delay \
  42. }
  43. #define SDMMC_SLOT_NO_CD GPIO_NUM_NC ///< indicates that card detect line is not used
  44. #define SDMMC_SLOT_NO_WP GPIO_NUM_NC ///< indicates that write protect line is not used
  45. #define SDMMC_SLOT_WIDTH_DEFAULT 0 ///< use the maximum possible width for the slot
  46. #if SOC_SDMMC_USE_IOMUX && !SOC_SDMMC_USE_GPIO_MATRIX
  47. /**
  48. * Macro defining default configuration of SDMMC host slot
  49. */
  50. #define SDMMC_SLOT_CONFIG_DEFAULT() {\
  51. .cd = SDMMC_SLOT_NO_CD, \
  52. .wp = SDMMC_SLOT_NO_WP, \
  53. .width = SDMMC_SLOT_WIDTH_DEFAULT, \
  54. .flags = 0, \
  55. }
  56. #else
  57. /**
  58. * Macro defining default configuration of SDMMC host slot
  59. */
  60. #if CONFIG_IDF_TARGET_ESP32P4
  61. #define SDMMC_SLOT_CONFIG_DEFAULT() {\
  62. .clk = GPIO_NUM_43, \
  63. .cmd = GPIO_NUM_44, \
  64. .d0 = GPIO_NUM_39, \
  65. .d1 = GPIO_NUM_40, \
  66. .d2 = GPIO_NUM_41, \
  67. .d3 = GPIO_NUM_42, \
  68. .d4 = GPIO_NUM_45, \
  69. .d5 = GPIO_NUM_46, \
  70. .d6 = GPIO_NUM_47, \
  71. .d7 = GPIO_NUM_48, \
  72. .cd = SDMMC_SLOT_NO_CD, \
  73. .wp = SDMMC_SLOT_NO_WP, \
  74. .width = SDMMC_SLOT_WIDTH_DEFAULT, \
  75. .flags = 0, \
  76. }
  77. #elif CONFIG_IDF_TARGET_ESP32S3
  78. #define SDMMC_SLOT_CONFIG_DEFAULT() {\
  79. .clk = GPIO_NUM_14, \
  80. .cmd = GPIO_NUM_15, \
  81. .d0 = GPIO_NUM_2, \
  82. .d1 = GPIO_NUM_4, \
  83. .d2 = GPIO_NUM_12, \
  84. .d3 = GPIO_NUM_13, \
  85. .d4 = GPIO_NUM_33, \
  86. .d5 = GPIO_NUM_34, \
  87. .d6 = GPIO_NUM_35, \
  88. .d7 = GPIO_NUM_36, \
  89. .cd = SDMMC_SLOT_NO_CD, \
  90. .wp = SDMMC_SLOT_NO_WP, \
  91. .width = SDMMC_SLOT_WIDTH_DEFAULT, \
  92. .flags = 0, \
  93. }
  94. #endif // GPIO Matrix chips
  95. #endif
  96. #ifdef __cplusplus
  97. }
  98. #endif