From 8ffb38265cfd42cba22757aeb9bb4b8d104a2352 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 18 Nov 2019 13:42:22 +0100 Subject: [PATCH] driver: fix gpio pin_bit_mask truncation in sdspi_host and others Closes https://github.com/espressif/esp-idf/issues/4348 --- components/driver/sdmmc_host.c | 2 +- components/driver/sdspi_host.c | 8 ++++---- components/driver/test/test_pwm.c | 10 +++++----- components/sdmmc/test/test_sdio.c | 2 +- examples/peripherals/sdio/host/main/app_main.c | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/components/driver/sdmmc_host.c b/components/driver/sdmmc_host.c index fedf294268..d3aa93b87c 100644 --- a/components/driver/sdmmc_host.c +++ b/components/driver/sdmmc_host.c @@ -343,7 +343,7 @@ esp_err_t sdmmc_host_init_slot(int slot, const sdmmc_slot_config_t* slot_config) // Force D3 high to make slave enter SD mode. // Connect to peripheral after width configuration. gpio_config_t gpio_conf = { - .pin_bit_mask = BIT(pslot->d3_gpio), + .pin_bit_mask = BIT64(pslot->d3_gpio), .mode = GPIO_MODE_OUTPUT , .pull_up_en = 0, .pull_down_en = 0, diff --git a/components/driver/sdspi_host.c b/components/driver/sdspi_host.c index 3a36ed7698..a42c23393e 100644 --- a/components/driver/sdspi_host.c +++ b/components/driver/sdspi_host.c @@ -315,7 +315,7 @@ esp_err_t sdspi_host_init_slot(int slot, const sdspi_slot_config_t* slot_config) gpio_config_t io_conf = { .intr_type = GPIO_PIN_INTR_DISABLE, .mode = GPIO_MODE_OUTPUT, - .pin_bit_mask = 1LL << slot_config->gpio_cs, + .pin_bit_mask = 1ULL << slot_config->gpio_cs, }; ret = gpio_config(&io_conf); @@ -333,14 +333,14 @@ esp_err_t sdspi_host_init_slot(int slot, const sdspi_slot_config_t* slot_config) .pull_up_en = true }; if (slot_config->gpio_cd != SDSPI_SLOT_NO_CD) { - io_conf.pin_bit_mask |= (1 << slot_config->gpio_cd); + io_conf.pin_bit_mask |= (1ULL << slot_config->gpio_cd); s_slots[slot].gpio_cd = slot_config->gpio_cd; } else { s_slots[slot].gpio_cd = GPIO_UNUSED; } if (slot_config->gpio_wp != SDSPI_SLOT_NO_WP) { - io_conf.pin_bit_mask |= (1 << slot_config->gpio_wp); + io_conf.pin_bit_mask |= (1ULL << slot_config->gpio_wp); s_slots[slot].gpio_wp = slot_config->gpio_wp; } else { s_slots[slot].gpio_wp = GPIO_UNUSED; @@ -360,7 +360,7 @@ esp_err_t sdspi_host_init_slot(int slot, const sdspi_slot_config_t* slot_config) .intr_type = GPIO_INTR_LOW_LEVEL, .mode = GPIO_MODE_INPUT, .pull_up_en = true, - .pin_bit_mask = (1 << slot_config->gpio_int), + .pin_bit_mask = (1ULL << slot_config->gpio_int), }; ret = gpio_config(&io_conf); if (ret != ESP_OK) { diff --git a/components/driver/test/test_pwm.c b/components/driver/test/test_pwm.c index 5e2f8526ec..76efc6aef2 100644 --- a/components/driver/test/test_pwm.c +++ b/components/driver/test/test_pwm.c @@ -271,7 +271,7 @@ static void cycle_fault_test(mcpwm_unit_t unit, mcpwm_io_signals_t mcpwm_a, mcpw gpio_config_t gp; gp.intr_type = GPIO_INTR_DISABLE; gp.mode = GPIO_MODE_OUTPUT; - gp.pin_bit_mask = (1 << FAULT_SIG_NUM); + gp.pin_bit_mask = (1ULL << FAULT_SIG_NUM); gpio_config(&gp); // gpio configure should be more previous than mcpwm configuration gpio_set_level(FAULT_SIG_NUM, !input_sig); @@ -300,7 +300,7 @@ static void oneshot_fault_test(mcpwm_unit_t unit, mcpwm_io_signals_t mcpwm_a, mc gpio_config_t gp; gp.intr_type = GPIO_INTR_DISABLE; gp.mode = GPIO_MODE_OUTPUT; - gp.pin_bit_mask = (1 << FAULT_SIG_NUM); + gp.pin_bit_mask = (1ULL << FAULT_SIG_NUM); gpio_config(&gp); // gpio configure should be more previous than mcpwm configuration gpio_set_level(FAULT_SIG_NUM, !input_sig); @@ -328,7 +328,7 @@ static void sync_test(mcpwm_unit_t unit, mcpwm_io_signals_t mcpwm_a, mcpwm_io_si gpio_config_t gp; gp.intr_type = GPIO_INTR_DISABLE; gp.mode = GPIO_MODE_OUTPUT; - gp.pin_bit_mask = (1 << SYN_SIG_NUM); + gp.pin_bit_mask = (1ULL << SYN_SIG_NUM); gpio_config(&gp); gpio_set_level(SYN_SIG_NUM, 0); @@ -426,10 +426,10 @@ static void gpio_test_signal(void *arg) { printf("intializing test signal...\n"); - gpio_config_t gp; + gpio_config_t gp = {}; gp.intr_type = GPIO_INTR_DISABLE; gp.mode = GPIO_MODE_OUTPUT; - gp.pin_bit_mask = 1<