From 2a7d85cfa4705cbf2a95c61f31671d3453dac6bc Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 23 Apr 2018 14:35:13 +0800 Subject: [PATCH] sdmmc, sdspi: fix initializers to be C++-compatible, add test Closes https://github.com/espressif/esp-idf/issues/1861 Closes https://github.com/espressif/arduino-esp32/issues/1312 --- components/driver/include/driver/sdmmc_host.h | 2 +- components/driver/include/driver/sdspi_host.h | 5 +++-- .../driver/test/test_sdmmc_sdspi_init.cpp | 20 +++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 components/driver/test/test_sdmmc_sdspi_init.cpp diff --git a/components/driver/include/driver/sdmmc_host.h b/components/driver/include/driver/sdmmc_host.h index aa3357a73..2c610ad36 100644 --- a/components/driver/include/driver/sdmmc_host.h +++ b/components/driver/include/driver/sdmmc_host.h @@ -43,9 +43,9 @@ extern "C" { .set_card_clk = &sdmmc_host_set_card_clk, \ .do_transaction = &sdmmc_host_do_transaction, \ .deinit = &sdmmc_host_deinit, \ - .command_timeout_ms = 0, \ .io_int_enable = sdmmc_host_io_int_enable, \ .io_int_wait = sdmmc_host_io_int_wait, \ + .command_timeout_ms = 0, \ } /** diff --git a/components/driver/include/driver/sdspi_host.h b/components/driver/include/driver/sdspi_host.h index 9dad6cf7a..9f72cb0dc 100644 --- a/components/driver/include/driver/sdspi_host.h +++ b/components/driver/include/driver/sdspi_host.h @@ -40,6 +40,7 @@ extern "C" { .io_voltage = 3.3f, \ .init = &sdspi_host_init, \ .set_bus_width = NULL, \ + .get_bus_width = NULL, \ .set_card_clk = &sdspi_host_set_card_clk, \ .do_transaction = &sdspi_host_do_transaction, \ .deinit = &sdspi_host_deinit, \ @@ -72,8 +73,8 @@ typedef struct { .gpio_mosi = GPIO_NUM_15, \ .gpio_sck = GPIO_NUM_14, \ .gpio_cs = GPIO_NUM_13, \ - .gpio_cd = SDMMC_SLOT_NO_CD, \ - .gpio_wp = SDMMC_SLOT_NO_WP, \ + .gpio_cd = SDSPI_SLOT_NO_CD, \ + .gpio_wp = SDSPI_SLOT_NO_WP, \ .dma_channel = 1 \ } diff --git a/components/driver/test/test_sdmmc_sdspi_init.cpp b/components/driver/test/test_sdmmc_sdspi_init.cpp new file mode 100644 index 000000000..d2406f582 --- /dev/null +++ b/components/driver/test/test_sdmmc_sdspi_init.cpp @@ -0,0 +1,20 @@ +#include "driver/sdmmc_host.h" +#include "driver/sdspi_host.h" + + +/** + * Check that C-style designated initializers are valid in C++ file. + */ +static void test_initializers() __attribute__((unused)); + +static void test_initializers() +{ + sdmmc_host_t sdmmc_host = SDMMC_HOST_DEFAULT(); + (void) sdmmc_host; + sdmmc_slot_config_t sdmmc_slot = SDMMC_SLOT_CONFIG_DEFAULT(); + (void) sdmmc_slot; + sdmmc_host_t sdspi_host = SDSPI_HOST_DEFAULT(); + (void) sdspi_host; + sdspi_slot_config_t sdspi_slot = SDSPI_SLOT_CONFIG_DEFAULT(); + (void) sdspi_slot; +}