sdio: update the host example to support working with a slave without DAT1

The interrupt line (DAT1) is an extra pin comparing to SD memory,
allowing the slave to actively inform the host some events.

It's possible for two ESP32 chips to communicate with each other in
1-bit mode or SPI mode without the DAT1 line by polling the slave's
interrupt registers. But this will increase the CPU load of the host,
and do harm to the response speed to slave events.
This commit is contained in:
michael
2019-12-24 15:57:44 +08:00
committed by bot
parent 3c44ab4192
commit 1f43f33567
2 changed files with 31 additions and 8 deletions

View File

@@ -284,22 +284,34 @@ void slave_power_on(void)
DMA_ATTR uint8_t rcv_buffer[READ_BUFFER_LEN];
static esp_err_t get_intr(essl_handle_t handle, uint32_t* out_raw, uint32_t* out_st)
{
esp_err_t ret = ESP_OK;
#ifndef CONFIG_EXAMPLE_NO_INTR_LINE
ret = essl_wait_int(handle, 0);
if (ret != ESP_OK) {
return ret;
}
#endif
ret = essl_get_intr(handle, out_raw, out_st, TIMEOUT_MAX);
if (ret != ESP_OK) return ret;
ret = essl_clear_intr(handle, *out_raw, TIMEOUT_MAX);
if (ret != ESP_OK) return ret;
ESP_LOGD(TAG, "intr: %08X", *out_raw);
return ESP_OK;
}
//try to get an interrupt from the slave and handle it, return if none.
esp_err_t process_event(essl_handle_t handle)
{
esp_err_t ret = essl_wait_int(handle, 0);
uint32_t intr_raw, intr_st;
esp_err_t ret = get_intr(handle, &intr_raw, &intr_st);
if (ret == ESP_ERR_TIMEOUT) {
return ret;
}
ESP_ERROR_CHECK(ret);
uint32_t intr_raw, intr_st;
ret = essl_get_intr(handle, &intr_raw, &intr_st, TIMEOUT_MAX);
ESP_ERROR_CHECK(ret);
ret = essl_clear_intr(handle, intr_raw, TIMEOUT_MAX);
ESP_ERROR_CHECK(ret);
ESP_LOGD(TAG, "intr: %08X", intr_raw);
for (int i = 0; i < 8; i++) {
if (intr_raw & BIT(i)) {
ESP_LOGI(TAG, "host int: %d", i);