Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a753474

Browse files
committedOct 21, 2024·
Merge branch 'feat/sdmm-p4' of https://github.com/P-R-O-C-H-Y/arduino-esp32 into feat/sdmm-p4
2 parents a14824f + f9a5271 commit a753474

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed
 

‎libraries/SD_MMC/src/SD_MMC.cpp

+13-12
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ SDMMCFS::SDMMCFS(FSImplPtr impl) : FS(impl), _card(nullptr) {
4949
_pin_d3 = SDMMC_D3;
5050
#endif // BOARD_HAS_1BIT_SDMMC
5151

52-
#elif defined(SOC_SDMMC_USE_IOMUX) && defined(BOARD_HAS_SDMMC) && defined(CONFIG_IDF_TARGET_ESP32)
52+
#elif defined(SOC_SDMMC_USE_IOMUX) && defined(BOARD_HAS_SDMMC) && defined(CONFIG_IDF_TARGET_ESP32)
5353
_pin_clk = SDMMC_SLOT1_IOMUX_PIN_NUM_CLK;
5454
_pin_cmd = SDMMC_SLOT1_IOMUX_PIN_NUM_CMD;
5555
_pin_d0 = SDMMC_SLOT1_IOMUX_PIN_NUM_D0;
@@ -80,7 +80,7 @@ SDMMCFS::SDMMCFS(FSImplPtr impl) : FS(impl), _card(nullptr) {
8080
_pin_d3 = SDMMC_D3;
8181
#endif // BOARD_HAS_1BIT_SDMMC
8282
#endif // BOARD_SDMMC_SLOT_NO
83-
#endif
83+
#endif
8484
#if defined(SOC_SDMMC_IO_POWER_EXTERNAL) && defined(BOARD_SDMMC_POWER_CHANNEL)
8585
_power_channel = BOARD_SDMMC_POWER_CHANNEL;
8686
#endif
@@ -183,8 +183,9 @@ bool SDMMCFS::begin(const char *mountpoint, bool mode1bit, bool format_if_mount_
183183
}
184184
//mount
185185
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
186-
#if (defined(SOC_SDMMC_USE_GPIO_MATRIX) && !defined(CONFIG_IDF_TARGET_ESP32P4)) || (defined(CONFIG_IDF_TARGET_ESP32P4) && ((defined(BOARD_SDMMC_SLOT) && (BOARD_SDMMC_SLOT == 1)) || !defined(BOARD_HAS_SDMMC)))
187-
log_d("pin_cmd: %d, pin_clk: %d, pin_d0: %d, pin_d1: %d, pin_d2: %d, pin_d3: %d", _pin_cmd, _pin_clk, _pin_d0, _pin_d1, _pin_d2, _pin_d3);
186+
#if (defined(SOC_SDMMC_USE_GPIO_MATRIX) && !defined(CONFIG_IDF_TARGET_ESP32P4)) \
187+
|| (defined(CONFIG_IDF_TARGET_ESP32P4) && ((defined(BOARD_SDMMC_SLOT) && (BOARD_SDMMC_SLOT == 1)) || !defined(BOARD_HAS_SDMMC)))
188+
log_d("pin_cmd: %d, pin_clk: %d, pin_d0: %d, pin_d1: %d, pin_d2: %d, pin_d3: %d", _pin_cmd, _pin_clk, _pin_d0, _pin_d1, _pin_d2, _pin_d3);
188189
// SoC supports SDMMC pin configuration via GPIO matrix.
189190
// Check that the pins have been set either in the constructor or setPins function.
190191
if (_pin_cmd == -1 || _pin_clk == -1 || _pin_d0 == -1 || (!mode1bit && (_pin_d1 == -1 || _pin_d2 == -1 || _pin_d3 == -1))) {
@@ -247,25 +248,25 @@ bool SDMMCFS::begin(const char *mountpoint, bool mode1bit, bool format_if_mount_
247248
_mode1bit = mode1bit;
248249

249250
#ifdef SOC_SDMMC_IO_POWER_EXTERNAL
250-
if(_power_channel == -1) {
251+
if (_power_channel == -1) {
251252
log_i("On-chip power channel specified, use external power for SDMMC");
252253
} else {
253254
sd_pwr_ctrl_ldo_config_t ldo_config = {
254-
.ldo_chan_id = _power_channel,
255+
.ldo_chan_id = _power_channel,
255256
};
256257
sd_pwr_ctrl_handle_t pwr_ctrl_handle = NULL;
257258

258-
if(sd_pwr_ctrl_new_on_chip_ldo(&ldo_config, &pwr_ctrl_handle) != ESP_OK) {
259-
log_e("Failed to create a new on-chip LDO power control driver");
260-
return false;
259+
if (sd_pwr_ctrl_new_on_chip_ldo(&ldo_config, &pwr_ctrl_handle) != ESP_OK) {
260+
log_e("Failed to create a new on-chip LDO power control driver");
261+
return false;
261262
}
262263
host.pwr_ctrl_handle = pwr_ctrl_handle;
263264
}
264265
#endif
265266

266267
#if defined(BOARD_SDMMC_POWER_PIN)
267268
#ifndef BOARD_SDMMC_POWER_ON_LEVEL
268-
#error "BOARD_SDMMC_POWER_ON_LEVEL not defined, please define it in pins_arduino.h"
269+
#error "BOARD_SDMMC_POWER_ON_LEVEL not defined, please define it in pins_arduino.h"
269270
#endif
270271
pinMode(BOARD_SDMMC_POWER_PIN, OUTPUT);
271272
digitalWrite(BOARD_SDMMC_POWER_PIN, !BOARD_SDMMC_POWER_ON_LEVEL);
@@ -340,9 +341,9 @@ void SDMMCFS::end() {
340341
perimanClearPinBus(_pin_d2);
341342
perimanClearPinBus(_pin_d3);
342343
}
343-
#if defined(BOARD_SDMMC_POWER_PIN)
344+
#if defined(BOARD_SDMMC_POWER_PIN)
344345
perimanClearPinBus(BOARD_SDMMC_POWER_PIN);
345-
#endif
346+
#endif
346347
}
347348
}
348349

‎variants/esp32p4/pins_arduino.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,19 @@ static const uint8_t T13 = 15;
6767

6868
//SDMMC
6969
#define BOARD_HAS_SDMMC
70-
#define BOARD_SDMMC_SLOT 0
71-
#define BOARD_SDMMC_POWER_CHANNEL 4
72-
#define BOARD_SDMMC_POWER_PIN 45
70+
#define BOARD_SDMMC_SLOT 0
71+
#define BOARD_SDMMC_POWER_CHANNEL 4
72+
#define BOARD_SDMMC_POWER_PIN 45
7373
#define BOARD_SDMMC_POWER_ON_LEVEL LOW
7474

7575
//WIFI - ESP32C6
7676
#define BOARD_HAS_SDIO_ESP_HOSTED
77-
#define BOARD_SDIO_ESP_HOSTED_CLK 18
78-
#define BOARD_SDIO_ESP_HOSTED_CMD 19
79-
#define BOARD_SDIO_ESP_HOSTED_D0 14
80-
#define BOARD_SDIO_ESP_HOSTED_D1 15
81-
#define BOARD_SDIO_ESP_HOSTED_D2 16
82-
#define BOARD_SDIO_ESP_HOSTED_D3 17
77+
#define BOARD_SDIO_ESP_HOSTED_CLK 18
78+
#define BOARD_SDIO_ESP_HOSTED_CMD 19
79+
#define BOARD_SDIO_ESP_HOSTED_D0 14
80+
#define BOARD_SDIO_ESP_HOSTED_D1 15
81+
#define BOARD_SDIO_ESP_HOSTED_D2 16
82+
#define BOARD_SDIO_ESP_HOSTED_D3 17
8383
#define BOARD_SDIO_ESP_HOSTED_RESET 54
8484

8585
#endif /* Pins_Arduino_h */

0 commit comments

Comments
 (0)
Please sign in to comment.