diff options
Diffstat (limited to 'fw/fe310/eos/dev/ctp.c')
-rw-r--r-- | fw/fe310/eos/dev/ctp.c | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/fw/fe310/eos/dev/ctp.c b/fw/fe310/eos/dev/ctp.c index fcc3c68..b6459b4 100644 --- a/fw/fe310/eos/dev/ctp.c +++ b/fw/fe310/eos/dev/ctp.c @@ -10,17 +10,13 @@ #include "eve/eve_touch_engine.h" #include "egpio.h" +#include "egpio_priv.h" #include "eve.h" -#include "pwr.h" #include "drv/fxl6408.h" #include "drv/gt911.h" #include "ctp.h" -#ifdef EOS_DEBUG -#include <stdio.h> -#endif - int eos_ctp_init(void) { uint8_t wakeup_cause; int rv, rst; @@ -37,6 +33,7 @@ int eos_ctp_init(void) { } int eos_ctp_reset(void) { + uint8_t status = 0; int rv; if (eos_i2s_running() || !eos_egpio_get_val(EGPIO_PIN_DISP_SEL) || !eos_egpio_get_val(EGPIO_PIN_CTP_SEL)) return EOS_ERR_BUSY; @@ -56,6 +53,7 @@ int eos_ctp_sleep(void) { int rv; if (eos_i2s_running() || !eos_egpio_get_val(EGPIO_PIN_DISP_SEL) || !eos_egpio_get_val(EGPIO_PIN_CTP_SEL)) return EOS_ERR_BUSY; + if (!gt911_running()) return EOS_ERR; rv = eos_egpio_intr_disable(); if (rv) return rv; @@ -73,6 +71,7 @@ int eos_ctp_wake(void) { int rv; if (eos_i2s_running() || !eos_egpio_get_val(EGPIO_PIN_DISP_SEL) || !eos_egpio_get_val(EGPIO_PIN_CTP_SEL)) return EOS_ERR_BUSY; + if (gt911_running()) return EOS_ERR; rv = eos_egpio_fxl_set_pin(EGPIO_PIN_CTP_INT, FXL6408_REG_PULL_DIR, 1); if (rv) return rv; @@ -94,10 +93,10 @@ int eos_ctp_give(void) { rv = eos_egpio_intr_disable(); if (rv) return rv; - rv = eve_select(); + rv = eos_egpio_set_val(EGPIO_PIN_CTP_SEL, 0); if (rv) return rv; - rv = eos_egpio_set_val(EGPIO_PIN_CTP_SEL, 0); + rv = eve_select(); if (rv) return rv; eve_touch_set_engine(EVE_TOUCH_ENGINE_GOODIX); @@ -138,7 +137,6 @@ int eos_ctp_take(void) { int eos_ctp_handle_intr(void) { uint8_t status; uint8_t points[GT911_SIZE_PBUF * GT911_MAX_POINTS]; - static int clear_tag0 = 0; int i, num_points; int rv; uint32_t start; @@ -150,11 +148,11 @@ int eos_ctp_handle_intr(void) { num_points = status & 0xf; if (num_points > 5) { rv = EOS_ERR; - goto handle_intr_fin; + goto handle_intr_fin1; } rv = eve_select(); - if (rv) goto handle_intr_fin; + if (rv) goto handle_intr_fin1; start = eos_get_tick(); while (!eve_touch_ehost_ready()) { @@ -163,20 +161,14 @@ int eos_ctp_handle_intr(void) { if (eos_tdelta_ms(start) > EVE_CMD_EXEC_TO) { rv = EOS_ERR_TIMEOUT; - eve_deselect(); - goto handle_intr_fin; + goto handle_intr_fin0; } if (num_points) { - if (clear_tag0) { - eve_touch_clear_tag0(); - clear_tag0 = 0; - } rv = gt911_get_points(num_points, points); if (rv) { rv = EOS_ERR; - eve_deselect(); - goto handle_intr_fin; + goto handle_intr_fin0; } for (i=0; i<num_points; i++) { @@ -193,20 +185,14 @@ int eos_ctp_handle_intr(void) { } } else { eve_touch_ehost_enter(0, 0x8000, 0x8000); - clear_tag0 = 1; } eve_touch_ehost_end(); +handle_intr_fin0: eve_deselect(); - -handle_intr_fin: +handle_intr_fin1: gt911_set_status(0); - if (rv) { -#ifdef EOS_DEBUG - printf("CTP HANDLE INTR ERR:%d\n", rv); -#endif - return rv; - } + if (rv) return rv; - return 1; + return status; } |