///< 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;
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.
*
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);
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;
}