From 1c51fc97104e0bb92164bf00b601c366350ddec4 Mon Sep 17 00:00:00 2001 From: Th3maz1ng Date: Fri, 3 Feb 2023 13:37:36 +0100 Subject: [PATCH] Renamed and cleaned up the CST816D_sleep function + implemented the CST816D_hardware_reset function --- .../app/app_drivers/i2c/CST816D.c | 21 ++++++++++--------- .../app/app_drivers/i2c/CST816D.h | 12 +++++++++-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/W800 SDK v1.00.08/app/app_drivers/i2c/CST816D.c b/src/W800 SDK v1.00.08/app/app_drivers/i2c/CST816D.c index df7688e..a6a5ea7 100644 --- a/src/W800 SDK v1.00.08/app/app_drivers/i2c/CST816D.c +++ b/src/W800 SDK v1.00.08/app/app_drivers/i2c/CST816D.c @@ -1,5 +1,6 @@ #include "i2c.h" #include "wm_gpio.h" +#include "wm_osal.h" #include "FreeRTOS.h" #include "app_log.h" #include "CST816D.h" @@ -26,19 +27,19 @@ bool CST816D_read_touch_event(CST816D_Touch_Data_t * const touch_data) return false; } -bool CST816D_set_power_mode(void) +void CST816D_hardware_reset(void) { - tls_gpio_cfg(WM_IO_PA_00, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING); + tls_gpio_cfg(LCD_TOUCH_PANEL_RESET, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING); - tls_gpio_write(WM_IO_PA_00, 0); + tls_gpio_write(LCD_TOUCH_PANEL_RESET, 0); tls_os_time_delay(pdMS_TO_TICKS(5)); - tls_gpio_write(WM_IO_PA_00, 1); + tls_gpio_write(LCD_TOUCH_PANEL_RESET, 1); +} + +bool CST816D_sleep(void) +{ + CST816D_hardware_reset(); tls_os_time_delay(pdMS_TO_TICKS(50)); - uint8_t data; - - i2c_read_reg(CST816D_I2C_ADDR, 0xA5, &data); - - i2c_write_reg(CST816D_I2C_ADDR, 0xA5, 0x03); - APP_LOG_DEBUG("CST 0xA5 : %u", data); + return i2c_write_reg(CST816D_I2C_ADDR, 0xA5, 0x03); } diff --git a/src/W800 SDK v1.00.08/app/app_drivers/i2c/CST816D.h b/src/W800 SDK v1.00.08/app/app_drivers/i2c/CST816D.h index 3541da2..061a844 100644 --- a/src/W800 SDK v1.00.08/app/app_drivers/i2c/CST816D.h +++ b/src/W800 SDK v1.00.08/app/app_drivers/i2c/CST816D.h @@ -57,10 +57,18 @@ typedef struct CST816D_Touch_Data bool CST816D_read_touch_event(CST816D_Touch_Data_t * const touch_data); /** - * @brief Issues a hardware reset of the touch panel. + * @brief Issues a physical hardware reset of the touch panel IC using the reset pin. */ void CST816D_hardware_reset(void); -bool CST816D_set_power_mode(void); +/** + * @brief Sets the touch panel in sleep mode. + * A call to this function does not seem to have any effect on power consumption even though the touch IC + * acknowledges the command ... strange ! + * + * @return true if the IC acknowledged the command + * @return false otherwise + */ +bool CST816D_sleep(void); #endif //CST816D_H \ No newline at end of file