kal_bool ctp_cypress_cy8ctma340_init(void) { if(gpio_ctp_power_enable_pin != 0xFF) ctp_gpio_power_handle = DclGPIO_Open(DCL_GPIO, gpio_ctp_power_enable_pin); if(gpio_ctp_eint_pin != 0xFF) ctp_gpio_eint_handle = DclGPIO_Open(DCL_GPIO, gpio_ctp_eint_pin); if(gpio_ctp_reset_pin != 0xFF) ctp_gpio_reset_handle = DclGPIO_Open(DCL_GPIO, gpio_ctp_reset_pin); if(gpio_ctp_i2c_sda_pin != 0xFF) //SW I2C ctp_i2c_configure(CTP_SLAVE_ADDR, CTP_DELAY_TIME); else //HW I2C ctp_i2c_configure(CTP_SLAVE_ADDR, CTP_HW_I2C_SPEED); ctp_cypress_cy8ctma340_power(KAL_TRUE); ctp_cypress_cy8ctma340_enter_system_mode(); ctp_cypress_cy8ctma340_set_active_timeout(0xFF, 20); //20ms refresh period ctp_cypress_cy8ctma340_exit_system_mode(); CTP_I2C_write_byte(HST_MODE_ADDR, HST_MODE_NORMAL); //normal operation mode EINT_Set_Sensitivity(custom_eint_get_channel(touch_panel_eint_chann), EDGE_SENSITIVE); return KAL_TRUE; }
void ctp_cypress_cy8ctma340_exit_system_mode() { if((gpio_ctp_reset_pin != 0xFF) && (gpio_ctp_eint_pin != 0xFF)) { CTP_I2C_write_byte(HST_MODE_ADDR, HST_MODE_NORMAL); //normal operation mode ctp_i2c_udelay(200000); DclGPIO_Control(ctp_gpio_eint_handle, GPIO_CMD_WRITE_HIGH, NULL); DclGPIO_Control(ctp_gpio_eint_handle, GPIO_CMD_SET_MODE_1, NULL); DclGPIO_Control(ctp_gpio_eint_handle, GPIO_CMD_SET_DIR_IN, NULL); DclGPIO_Control(ctp_gpio_eint_handle, GPIO_CMD_ENABLE_PULL, NULL); DclGPIO_Control(ctp_gpio_eint_handle, GPIO_CMD_SET_PULL_HIGH, NULL); if(gpio_ctp_i2c_sda_pin != 0xFF) //SW I2C ctp_i2c_configure(CTP_SLAVE_ADDR, CTP_DELAY_TIME); else //HW I2C ctp_i2c_configure(CTP_SLAVE_ADDR, CTP_HW_I2C_SPEED); } }
void ctp_cypress_cy8ctma340_enter_system_mode() { if((gpio_ctp_reset_pin != 0xFF) && (gpio_ctp_eint_pin != 0xFF)) { ctp_i2c_configure(CTP_SLAVE_ADDR, 50); DclGPIO_Control(ctp_gpio_eint_handle, GPIO_CMD_SET_MODE_0, NULL); DclGPIO_Control(ctp_gpio_eint_handle, GPIO_CMD_WRITE_LOW, NULL); DclGPIO_Control(ctp_gpio_eint_handle, GPIO_CMD_SET_DIR_OUT, NULL); DclGPIO_Control(ctp_gpio_eint_handle, GPIO_CMD_ENABLE_PULL, NULL); DclGPIO_Control(ctp_gpio_eint_handle, GPIO_CMD_SET_PULL_HIGH, NULL); ctp_i2c_udelay(100000); CTP_I2C_write_byte(HST_MODE_ADDR, HST_MODE_RESET); //system information mode ctp_i2c_udelay(200000); CTP_I2C_write_byte(HST_MODE_ADDR, HST_MODE_SYSTEM_INFORMATION); //system information mode ctp_i2c_udelay(200000); } }
static VM_DRV_TP_BOOL ctp_goodix_gt9xx_init(void) { VM_DCL_HANDLE sda_handle, scl_handle; VM_DCL_HANDLE eint_handle, reset_handle; VM_DRV_TP_BOOL ack; ctp_info_t ctp_info; VMUINT16 reg_value; VMUINT8 i = 0; //turn on VSIM1 *VSIM1_CON2 = *VSIM1_CON2 | 0x0002; *VSIM1_CON0 = *VSIM1_CON0 | 0x0001; // init i2c if (gpio_ctp_i2c_sda_pin != 0xFF) { sda_handle = vm_dcl_open(VM_DCL_GPIO, gpio_ctp_i2c_sda_pin); scl_handle = vm_dcl_open(VM_DCL_GPIO, gpio_ctp_i2c_scl_pin); vm_dcl_control(sda_handle, VM_DCL_GPIO_COMMAND_SET_MODE_0, NULL); vm_dcl_control(scl_handle, VM_DCL_GPIO_COMMAND_SET_MODE_0, NULL); CTP_DELAY_TIME = 3; } ctp_i2c_configure(CTP_SLAVE_ADDR, CTP_DELAY_TIME); eint_handle = vm_dcl_open(VM_DCL_GPIO, gpio_ctp_eint_pin); reset_handle = vm_dcl_open(VM_DCL_GPIO, gpio_ctp_reset_pin); ////////////////////////////reset////////////////////////////////// vm_dcl_control(eint_handle, VM_DCL_GPIO_COMMAND_SET_DIRECTION_OUT, NULL); vm_dcl_control(eint_handle, VM_DCL_GPIO_COMMAND_WRITE_LOW, NULL); vm_dcl_control(reset_handle, VM_DCL_GPIO_COMMAND_SET_MODE_0, NULL); vm_dcl_control(reset_handle, VM_DCL_GPIO_COMMAND_SET_DIRECTION_OUT, NULL); vm_dcl_control(reset_handle, VM_DCL_GPIO_COMMAND_WRITE_LOW, NULL); delay_ms(5); vm_dcl_control(reset_handle, VM_DCL_GPIO_COMMAND_WRITE_HIGH, NULL); delay_ms(10); ////////////////////////////////////////////////////////////////// vm_dcl_close(eint_handle); vm_dcl_close(reset_handle); //vm_dcl_control(eint_handle, VM_DCL_GPIO_COMMAND_SET_DIRECTION_IN, NULL); //vm_dcl_control(eint_handle, gpio_ctp_eint_pin_M_EINT, NULL); //EINT_Set_Sensitivity(custom_eint_get_channel(touch_panel_eint_chann), EDGE_SENSITIVE); ctp_init_EINT(); ack = ctp_goodix_gt9xx_set_configuration(); if (ack == VM_DRV_TP_FALSE) { vm_log_info("ctp_goodix_gt9xx_set_configuration fail!!!"); return VM_DRV_TP_FALSE; } vm_log_info("ctp_goodix_gt9xx_set_configuration OK!!!"); ack = ctp_goodix_gt9xx_get_information(&ctp_info); if (ack == VM_DRV_TP_FALSE) { vm_log_info("read information fail"); return VM_DRV_TP_FALSE; } return VM_DRV_TP_TRUE; }