From 823ebba0f0ca3b9b62052111b556abf4758cf63d Mon Sep 17 00:00:00 2001 From: michael Date: Fri, 6 Jul 2018 16:02:32 +0800 Subject: [PATCH] fix(sdio_slave): fix minor issues like return value of send function, output arg, etc. --- components/driver/include/driver/sdio_slave.h | 22 +++++++++---------- components/driver/sdio_slave.c | 8 ++++--- .../peripherals/sdio/host/Kconfig.projbuild | 19 ---------------- 3 files changed, 16 insertions(+), 33 deletions(-) delete mode 100644 examples/peripherals/sdio/host/Kconfig.projbuild diff --git a/components/driver/include/driver/sdio_slave.h b/components/driver/include/driver/sdio_slave.h index 472acd02f..55fe6af77 100644 --- a/components/driver/include/driver/sdio_slave.h +++ b/components/driver/include/driver/sdio_slave.h @@ -72,20 +72,20 @@ typedef struct { ///< Buffer size of the slave pre-defined between host and slave before communication. All receive buffer given to the driver should be larger than this. sdio_event_cb_t event_cb; ///< when the host interrupts slave, this callback will be called with interrupt number (0-7). uint32_t flags; ///< Features to be enabled for the slave, combinations of ``SDIO_SLAVE_FLAG_*``. -#define SDIO_SLAVE_FLAG_DAT2_DISABLED BIT(0) /**< It is required by the SD specification that all 4 data - lines should be used and pulled up even in 1-bit mode or SPI mode. However, as a feature, the user can speicfy - this flag to make use of DAT2 pin in 1-bit mode. Note that the host cannot read CCCR registers to know we don't +#define SDIO_SLAVE_FLAG_DAT2_DISABLED BIT(0) /**< It is required by the SD specification that all 4 data + lines should be used and pulled up even in 1-bit mode or SPI mode. However, as a feature, the user can specify + this flag to make use of DAT2 pin in 1-bit mode. Note that the host cannot read CCCR registers to know we don't support 4-bit mode anymore, please do this at your own risk. */ -#define SDIO_SLAVE_FLAG_HOST_INTR_DISABLED BIT(1) /**< The DAT1 line is used as the interrupt line in SDIO - protocol. However, as a feature, the user can speicfy this flag to make use of DAT1 pin of the slave in 1-bit +#define SDIO_SLAVE_FLAG_HOST_INTR_DISABLED BIT(1) /**< The DAT1 line is used as the interrupt line in SDIO + protocol. However, as a feature, the user can specify this flag to make use of DAT1 pin of the slave in 1-bit mode. Note that the host has to do polling to the interrupt registers to know whether there are interrupts from - the slave. And it cannot read CCCR registers to know we don't support 4-bit mode anymore, please do this at + the slave. And it cannot read CCCR registers to know we don't support 4-bit mode anymore, please do this at your own risk. */ -#define SDIO_SLAVE_FLAG_INTERNAL_PULLUP BIT(2) /**< Enable internal pullups for enabled pins. It is required - by the SD specification that all the 4 data lines should be pulled up even in 1-bit mode or SPI mode. Note that - the internal pull-ups are not sufficient for stable communication, please do connect external pull-ups on the +#define SDIO_SLAVE_FLAG_INTERNAL_PULLUP BIT(2) /**< Enable internal pullups for enabled pins. It is required + by the SD specification that all the 4 data lines should be pulled up even in 1-bit mode or SPI mode. Note that + the internal pull-ups are not sufficient for stable communication, please do connect external pull-ups on the bus. This is only for example and debug use. */ } sdio_slave_config_t; @@ -214,12 +214,12 @@ uint8_t* sdio_slave_recv_get_buf(sdio_slave_buf_handle_t handle, size_t *len_o); esp_err_t sdio_slave_send_queue(uint8_t* addr, size_t len, void* arg, TickType_t wait); /** Return the ownership of a finished transaction. - * @param arg_o Argument of the finished transaction. + * @param out_arg Argument of the finished transaction. Set to NULL if unused. * @param wait Time to wait if there's no finished sending transaction. * * @return ESP_ERR_TIMEOUT if no transaction finished, or ESP_OK if succeed. */ -esp_err_t sdio_slave_send_get_finished(void** arg_o, TickType_t wait); +esp_err_t sdio_slave_send_get_finished(void** out_arg, TickType_t wait); /** Start a new sending transfer, and wait for it (blocked) to be finished. * diff --git a/components/driver/sdio_slave.c b/components/driver/sdio_slave.c index e64802aa5..970871575 100644 --- a/components/driver/sdio_slave.c +++ b/components/driver/sdio_slave.c @@ -277,7 +277,7 @@ static inline uint8_t* sdio_ringbuf_offset_ptr(sdio_ringbuf_t *buf, sdio_ringbuf static esp_err_t sdio_ringbuf_send(sdio_ringbuf_t* buf, esp_err_t (*copy_callback)(uint8_t*, void*), void* arg, TickType_t wait) { portBASE_TYPE ret = xSemaphoreTake(buf->remain_cnt, wait); - if (ret != pdTRUE) return NULL; + if (ret != pdTRUE) return ESP_ERR_TIMEOUT; portENTER_CRITICAL(&buf->write_spinlock); uint8_t* get_ptr = sdio_ringbuf_offset_ptr(buf, ringbuf_write_ptr, buf->item_size); @@ -929,9 +929,11 @@ esp_err_t sdio_slave_send_queue(uint8_t* addr, size_t len, void* arg, TickType_t return ESP_OK; } -esp_err_t sdio_slave_send_get_finished(void** arg, TickType_t wait) +esp_err_t sdio_slave_send_get_finished(void** out_arg, TickType_t wait) { - portBASE_TYPE err = xQueueReceive(context.ret_queue, arg, wait); + void* arg = NULL; + portBASE_TYPE err = xQueueReceive(context.ret_queue, &arg, wait); + if (out_arg) *out_arg = arg; if (err != pdTRUE) return ESP_ERR_TIMEOUT; return ESP_OK; } diff --git a/examples/peripherals/sdio/host/Kconfig.projbuild b/examples/peripherals/sdio/host/Kconfig.projbuild deleted file mode 100644 index bd33b51d0..000000000 --- a/examples/peripherals/sdio/host/Kconfig.projbuild +++ /dev/null @@ -1,19 +0,0 @@ -menu "Example Configuration" - -choice EXAMPLE_SLAVE - prompt "Id of Slave used in Espressif master-slave board." - default EXAMPLE_SLAVE_NONE - help - If Espressif master-slave board is used, select which slave is used. - -config EXAMPLE_SLAVE_NONE - bool "Not using Espressif master-slave board." -config EXAMPLE_SLAVE_B1 - bool "Using slave B1" -config EXAMPLE_SLAVE_B2 - bool "Using slave B2" -config EXAMPLE_SLAVE_B3 - bool "Using slave B3" -endchoice - -endmenu