From b60a55be73dd6f1951f65ce0ab98404260d39ae9 Mon Sep 17 00:00:00 2001 From: imi415 Date: Thu, 14 Jan 2021 23:23:52 +0800 Subject: [PATCH] Fixed recursion issue. --- depg0213_epd.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/depg0213_epd.c b/depg0213_epd.c index 1b585e9..4dee09b 100644 --- a/depg0213_epd.c +++ b/depg0213_epd.c @@ -52,6 +52,17 @@ depg0213_ret_t _depg0213_software_reset(depg0213_epd_t *epd) { uint8_t sw_reset_cmd = 0x12; // SW RST DEPG0213_ERROR_CHECK(epd->cb.write_cmd_cb(epd->user_data, &sw_reset_cmd, 0x01)); + DEPG0213_ERROR_CHECK(epd->cb.poll_busy_cb(epd->user_data)); + + return DEPG0213_OK; +} + +depg0213_ret_t _depg0213_hardware_reset(depg0213_epd_t *epd) { + + DEPG0213_ERROR_CHECK(epd->cb.reset_cb(epd->user_data)); + DEPG0213_ERROR_CHECK(epd->cb.poll_busy_cb(epd->user_data)); + + epd->deep_sleep = 0; return DEPG0213_OK; } @@ -64,6 +75,9 @@ depg0213_ret_t _depg0213_init_seq(depg0213_epd_t *epd) { i += DEPG0213_PANEL_SELECTION[i] + 2; } + // The end of the sequence is load LUT from OTP memory. + DEPG0213_ERROR_CHECK(epd->cb.poll_busy_cb(epd->user_data)); + return DEPG0213_OK; } @@ -80,25 +94,20 @@ depg0213_ret_t _depg0213_load_lut(depg0213_epd_t *epd) { #endif depg0213_ret_t depg0213_epd_init(depg0213_epd_t *epd) { - // HW Reset - DEPG0213_ERROR_CHECK(epd->cb.reset_cb(epd->user_data)); - DEPG0213_ERROR_CHECK(epd->cb.poll_busy_cb(epd->user_data)); - // SW Reset + // Software reset follows hardware reset + DEPG0213_ERROR_CHECK(_depg0213_hardware_reset(epd)); DEPG0213_ERROR_CHECK(_depg0213_software_reset(epd)); - DEPG0213_ERROR_CHECK(epd->cb.poll_busy_cb(epd->user_data)); + // Setup default direction DEPG0213_ERROR_CHECK(depg0213_epd_direction(epd, DEPG0213_VERTICAL)); DEPG0213_ERROR_CHECK(_depg0213_init_seq(epd)); - DEPG0213_ERROR_CHECK(epd->cb.poll_busy_cb(epd->user_data)); #if(!DEPG0213_LUT_OTP) DEPG0213_ERROR_CHECK(_depg0213_load_lut(epd)); #endif - epd->deep_sleep = 0; - return DEPG0213_OK; }