Skip to content

Commit 68d3cf7

Browse files
committed
default enables, safe pin claims, reuse feq msg, use preprocessor
1 parent c872258 commit 68d3cf7

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed

ports/espressif/boards/makerfabs_tft7/mpconfigboard.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ CIRCUITPY_ESP_PSRAM_FREQ = 80m
1515

1616
CIRCUITPY_DOTCLOCKFRAMEBUFFER = 1
1717

18-
CIRCUITPY_SDIOIO = 1
19-
2018
# To build with USB disabled allowing access to I2S pins
2119
#CIRCUITPY_CREATOR_ID = 0x1A000000
2220
#CIRCUITPY_CREATION_ID = 0x005381BF

ports/espressif/common-hal/sdioio/SDCard.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ static void common_hal_sdioio_sdcard_check_for_deinit(sdioio_sdcard_obj_t *self)
2828
}
2929

3030
static int check_pins(const mcu_pin_obj_t *clock, const mcu_pin_obj_t *command, const uint8_t num_data, const mcu_pin_obj_t **data) {
31-
if (CONFIG_SOC_SDMMC_USE_GPIO_MATRIX) {
32-
// ESP32-S3 and P4 can use any pin for any SDMMC func in either slot
33-
// Default to SLOT_1 for SD cards
34-
ESP_LOGI(TAG, "Using chip with CONFIG_SOC_SDMMC_USE_GPIO_MATRIX");
35-
return SDMMC_HOST_SLOT_1;
36-
}
31+
#ifdef CONFIG_SOC_SDMMC_USE_GPIO_MATRIX
32+
// ESP32-S3 and P4 can use any pin for any SDMMC func in either slot
33+
// Default to SLOT_1 for SD cards
34+
ESP_LOGI(TAG, "Using chip with CONFIG_SOC_SDMMC_USE_GPIO_MATRIX");
35+
return SDMMC_HOST_SLOT_1;
36+
#endif
3737
if (command->number == GPIO_NUM_11 && clock->number == GPIO_NUM_6 && data[0]->number == GPIO_NUM_7) {
3838
// Might be slot 0
3939
if (num_data == 1 || (num_data == 4 && data[1]->number == GPIO_NUM_8 && data[2]->number == GPIO_NUM_9 && data[3]->number == GPIO_NUM_10)) {
@@ -62,11 +62,8 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
6262
raise_ValueError_invalid_pins();
6363
}
6464

65-
if (frequency > 40000000) {
66-
// Higher than max 40Mhz frequency
67-
mp_raise_ValueError(MP_ERROR_TEXT("SDIO: requested frequency out of range"));
68-
}
69-
65+
// max 40Mhz frequency
66+
mp_arg_validate_int_max(frequency,40000000,MP_QSTR_frequency);
7067
ESP_LOGI(TAG, "Using slot %d", sd_slot);
7168
self->slot = (uint8_t)sd_slot;
7269
esp_err_t err = ESP_OK;
@@ -77,24 +74,18 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
7774
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
7875
slot_config.width = 1;
7976
slot_config.clk = clock->number;
80-
claim_pin(clock);
8177
self->clock = clock->number;
8278
slot_config.cmd = command->number;
83-
claim_pin(command);
8479
self->command = command->number;
8580
slot_config.d0 = data[0]->number;
8681
self->data[0] = data[0]->number;
87-
claim_pin(data[0]);
8882
if (num_data == 4) {
8983
slot_config.width = 4;
9084
slot_config.d1 = data[1]->number;
91-
claim_pin(data[1]);
9285
self->data[1] = data[1]->number;
9386
slot_config.d2 = data[2]->number;
94-
claim_pin(data[2]);
9587
self->data[2] = data[2]->number;
9688
slot_config.d3 = data[3]->number;
97-
claim_pin(data[3]);
9889
self->data[3] = data[3]->number;
9990
}
10091

@@ -124,6 +115,15 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
124115

125116
common_hal_sdioio_sdcard_check_for_deinit(self);
126117

118+
claim_pin(clock);
119+
claim_pin(command);
120+
claim_pin(data[0]);
121+
if (num_data == 4) {
122+
claim_pin(data[1]);
123+
claim_pin(data[2]);
124+
claim_pin(data[3]);
125+
}
126+
127127
ESP_LOGI(TAG, "Initialized SD card with ID %d:%d-%s",
128128
self->card.cid.mfg_id, self->card.cid.oem_id, self->card.cid.name);
129129

ports/espressif/mpconfigport.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ CIRCUITPY_PARALLELDISPLAYBUS ?= 1
5151
CIRCUITPY_PS2IO ?= 1
5252
CIRCUITPY_RGBMATRIX ?= 1
5353
CIRCUITPY_ROTARYIO ?= 1
54-
CIRCUITPY_SDIOIO ?= 0
54+
CIRCUITPY_SDIOIO ?= 1
5555
CIRCUITPY_SYNTHIO_MAX_CHANNELS ?= 12
5656
CIRCUITPY_TOUCHIO_USE_NATIVE ?= 1
5757
CIRCUITPY_WATCHDOG ?= 1
@@ -124,6 +124,9 @@ CIRCUITPY_FREQUENCYIO = 0
124124
CIRCUITPY_COUNTIO = 0
125125
CIRCUITPY_ROTARYIO = 0
126126

127+
# No SDMMC
128+
CIRCUITPY_SDIOIO = 0
129+
127130
CIRCUITPY_TOUCHIO ?= 1
128131
CIRCUITPY_TOUCHIO_USE_NATIVE = 0
129132
# Features
@@ -183,9 +186,6 @@ CIRCUITPY_BLEIO = 0
183186
CIRCUITPY_WIFI = 0
184187
CIRCUITPY_SSL = 0
185188

186-
# No SDMMC
187-
CIRCUITPY_SDIOIO = 0
188-
189189
CIRCUITPY_TOUCHIO = 1
190190
CIRCUITPY_TOUCHIO_USE_NATIVE = 0
191191

0 commit comments

Comments
 (0)