From b19b4c8e47538b77f776a2ee60a91ae686a7ed0e Mon Sep 17 00:00:00 2001 From: Xiao Xufeng Date: Fri, 7 Apr 2023 15:27:05 +0800 Subject: [PATCH] sdio_example: fix meaningless print in host, make shared reg access more readable in slave --- .../peripherals/sdio/host/main/app_main.c | 2 +- .../peripherals/sdio/slave/main/app_main.c | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/examples/peripherals/sdio/host/main/app_main.c b/examples/peripherals/sdio/host/main/app_main.c index 0ef1a20ebf..ff39f922b1 100644 --- a/examples/peripherals/sdio/host/main/app_main.c +++ b/examples/peripherals/sdio/host/main/app_main.c @@ -416,7 +416,7 @@ void job_write_reg(essl_handle_t handle, int value) } ESP_LOGI(TAG, "read registers:"); - ESP_LOG_BUFFER_HEXDUMP(TAG, reg_read, 64, ESP_LOG_INFO); + ESP_LOG_BUFFER_HEXDUMP(TAG, reg_read, 60, ESP_LOG_INFO); } //the slave only load 16 buffers a time diff --git a/examples/peripherals/sdio/slave/main/app_main.c b/examples/peripherals/sdio/slave/main/app_main.c index f32766e0aa..f78ad91070 100644 --- a/examples/peripherals/sdio/slave/main/app_main.c +++ b/examples/peripherals/sdio/slave/main/app_main.c @@ -62,6 +62,9 @@ #define EV_STR(s) "================ "s" ================" +//skip interrupt regs. +#define SLAVE_ADDR(i) ((i) >= 28? (i) + 4: (i)) + typedef enum { JOB_IDLE = 0, JOB_RESET = 1, @@ -123,19 +126,15 @@ static esp_err_t task_write_reg(void) { //the host write REG1, the slave should write its registers according to value of REG1 uint8_t read = sdio_slave_read_reg(1); - for (int i = 0; i < 64; i++) { - //skip interrupt regs. - if (i >= 28 && i <= 31) continue; - sdio_slave_write_reg(i, read+3*i); + for (int i = 0; i < 60; i++) { + sdio_slave_write_reg(SLAVE_ADDR(i), read + 3*i); } - uint8_t reg[64] = {0}; - for (int i = 0; i < 64; i++) { - //skip interrupt regs. - if (i >= 28 && i <= 31) continue; - reg[i] = sdio_slave_read_reg(i); + uint8_t reg[60] = {0}; + for (int i = 0; i < 60; i++) { + reg[i] = sdio_slave_read_reg(SLAVE_ADDR(i)); } ESP_LOGI(TAG, "write regs:"); - ESP_LOG_BUFFER_HEXDUMP(TAG, reg, 64, ESP_LOG_INFO); + ESP_LOG_BUFFER_HEXDUMP(TAG, reg, 60, ESP_LOG_INFO); return ESP_OK; }