/*********************************************************************** [function]: callback: read a byte data from ctpm; [parameters]: buffer[in]: read buffer; length[in]: the size of read data; [return]: FTS_TRUE: success; FTS_FALSE: io fail; ************************************************************************/ static bool byte_read(u8* buffer, int length) { printk("[ELDIAU] ft5406_ts.c: byte_read\n"); return i2c_read_interface(buffer, length); }
u8 hc_register_read(u8 e_reg_name, u8* pbt_buf, u8 bt_len) { #if 1 u8 read_cmd[3]= {0}; u8 cmd_len = 0; read_cmd[0] = e_reg_name; cmd_len = 1; if(!i2c_write_interface(I2C_CTPM_ADDRESS, read_cmd, cmd_len)) { return HC_FALSE; } /*call the read callback function to get the register value*/ if(!i2c_read_interface(I2C_CTPM_ADDRESS, pbt_buf, bt_len)) { return HC_FALSE; } return HC_TRUE; #else u8 read_cmd[3] = {0}; u8 i = 0; for(i=0; i<bt_len; i++) { read_cmd[0] = e_reg_name + i; if(!i2c_write_interface(I2C_CTPM_ADDRESS, read_cmd, 1)) { return HC_FALSE; } /*call the read callback function to get the register value*/ if(!i2c_read_interface(I2C_CTPM_ADDRESS, pbt_buf+i, 1)) { return HC_FALSE; } } return HC_TRUE; #endif }
/*********************************************************************** [function]: callback: read register value ftom ctpm by i2c interface; [parameters]: reg_name[in]: the register which you want to read; rx_buf[in]: data buffer which is used to store register value; rx_length[in]: the length of the data buffer; [return]: FTS_TRUE: success; FTS_FALSE: fail; ************************************************************************/ static bool fts_register_read(u8 reg_name, u8* rx_buf, int rx_length) { u8 read_cmd[2]= {0}; u8 cmd_len = 0; read_cmd[0] = reg_name; cmd_len = 1; /*send register addr*/ if(!i2c_write_interface(&read_cmd[0], cmd_len)) { return false; } /*call the read callback function to get the register value*/ if(!i2c_read_interface(rx_buf, rx_length)) { return false; } return true; }
/*********************************************************************** [function]: callback: read a byte data from ctpm; [parameters]: buffer[in]: read buffer; length[in]: the size of read data; [return]: FTS_TRUE: success; FTS_FALSE: io fail; ************************************************************************/ static bool byte_read(u8* buffer, int length) { return i2c_read_interface(buffer, length); }