Ejemplo n.º 1
0
//[*]----------------------------------------------------------------------------------------------[*]
int 				hkc1xx_touch_write		(unsigned char addr, unsigned char *wdata, unsigned char wsize)
{
	unsigned char cnt, ack;

	// start
	gpio_i2c_start();
	
	gpio_i2c_byte_write(TOUCH_WR_ADDR);	// i2c address

	if((ack = gpio_i2c_chk_ack()))	{
		#if defined(DEBUG_GPIO_I2C)
			DEBUG_MSG(("%s [write address] : no ack\n",__FUNCTION__));
		#endif

		goto	write_stop;
	}
	
	gpio_i2c_byte_write(addr);	// register
	
	if((ack = gpio_i2c_chk_ack()))	{
		#if defined(DEBUG_GPIO_I2C)
			DEBUG_MSG(("%s [write register] : no ack\n",__FUNCTION__));
		#endif
	}
	
	if(wsize)	{
		for(cnt = 0; cnt < wsize; cnt++)	{
			gpio_i2c_byte_write(wdata[cnt]);

			if((ack = gpio_i2c_chk_ack()))	{
				#if defined(DEBUG_GPIO_I2C)
					DEBUG_MSG(("%s [write register] : no ack\n",__FUNCTION__));
				#endif

				goto	write_stop;
			}
		}
	}

write_stop:
	
#if defined(CONFIG_TOUCHSCREEN_HKDKC1XX) || defined(CONFIG_TOUCHSCREEN_ODROID_T)
	if(wsize)	gpio_i2c_stop();
#else	// defined(CONFIG_TOUCHSCREEN_ODROID_S)
	gpio_i2c_stop();
#endif

//	if(ack)	printk("%s : error ack(%d)\n", __FUNCTION__, ack);
	
	#if defined(DEBUG_GPIO_I2C)
		DEBUG_MSG(("%s : %d\n", __FUNCTION__, ack));
	#endif
	return	ack;
}
Ejemplo n.º 2
0
//[*]----------------------------------------------------------------------------------------------[*]
int 				pmic_read		(unsigned char reg, unsigned char *rdata, unsigned char rsize)
{
	unsigned char ack, cnt;

	// register pointer write
	if(pmic_write(reg, NULL, 0))		goto	read_stop;
	
	// restart
	gpio_i2c_start();

	gpio_i2c_byte_write(MAX77687_ADDR + I2C_READ);	// i2c address

	if((ack = gpio_i2c_chk_ack()))		goto	read_stop;
	
	for(cnt=0; cnt < rsize; cnt++)	{
		
		gpio_i2c_byte_read(&rdata[cnt]);
		
		if(cnt == rsize -1)		gpio_i2c_send_noack();
		else					gpio_i2c_send_ack();
	}
	
read_stop:
	gpio_i2c_stop();

	return	ack;
}
Ejemplo n.º 3
0
//[*]----------------------------------------------------------------------------------------------[*]
int 				pmic_write		(unsigned char reg, unsigned char *wdata, unsigned char wsize)
{
	unsigned char cnt, ack;

	// start
	gpio_i2c_start();
	
	gpio_i2c_byte_write(MAX77687_ADDR + I2C_WRITE);	// i2c address

	if((ack = gpio_i2c_chk_ack()))		goto	write_stop;
	
	gpio_i2c_byte_write(reg);	// register
	
	if((ack = gpio_i2c_chk_ack()))		goto	write_stop;
	
	if(wsize)	{
		for(cnt = 0; cnt < wsize; cnt++)	{
			gpio_i2c_byte_write(wdata[cnt]);

			if((ack = gpio_i2c_chk_ack()))	goto	write_stop;
		}
	}

write_stop:
	
	if(wsize)	gpio_i2c_stop();

	return	ack;
}
Ejemplo n.º 4
0
static uint32_t ks103_read_reg_i2c(uint8_t addr, uint8_t reg)
{
	uint8_t data_read;

	/* 需要读取的寄存器 */
	gpio_i2c_start();
	gpio_i2c_write(addr);
	if(gpio_i2c_ack() != 0){ /* 无应答 */
		return KS103_DATA_ERROR;
	}
	gpio_i2c_write(reg);
	if(gpio_i2c_ack() != 0){ /* 无应答 */
		return KS103_DATA_ERROR;
	}

	/* 读取寄存器的数值 */
	gpio_i2c_start();
	gpio_i2c_write(addr + 1);
	if(gpio_i2c_ack() != 0){ /* 无应答 */
		return KS103_DATA_ERROR;
	}
	data_read = gpio_i2c_read();
	gpio_i2c_ack();
	gpio_i2c_stop();

	return (uint32_t) data_read;
}
Ejemplo n.º 5
0
//[*]----------------------------------------------------------------------------------------------[*]
int 				hkc1xx_touch_read		(unsigned char *rdata, unsigned char rsize)
{
	unsigned char ack, cnt;

	// start
	gpio_i2c_start();

	gpio_i2c_byte_write(TOUCH_RD_ADDR);	// i2c address

	if((ack = gpio_i2c_chk_ack()))	{
		#if defined(DEBUG_GPIO_I2C)
			DEBUG_MSG(("%s [write address] : no ack\n",__FUNCTION__));
		#endif

		goto	read_stop;
	}
	
	for(cnt=0; cnt < rsize; cnt++)	{
		
		gpio_i2c_byte_read(&rdata[cnt]);
		
		if(cnt == rsize -1)		gpio_i2c_send_noack();
		else					gpio_i2c_send_ack();
	}
	
read_stop:
	gpio_i2c_stop();

//	if(ack)	printk("%s : error ack(%d)\n", __FUNCTION__, ack);

	#if defined(DEBUG_GPIO_I2C)
		DEBUG_MSG(("%s : %d\n", __FUNCTION__, ack));
	#endif
	return	ack;
}
Ejemplo n.º 6
0
static uint32_t ks103_send_cmd_i2c(uint8_t addr, uint8_t reg, uint8_t cmd)
{
	gpio_i2c_start();
	gpio_i2c_write(addr);
	if(gpio_i2c_ack() != 0){ /* 无应答 */
		return KS103_DATA_ERROR;
	}
	gpio_i2c_write(reg);
	if(gpio_i2c_ack() != 0){ /* 无应答 */
		return KS103_DATA_ERROR;
	}
	gpio_i2c_write(cmd);
	gpio_i2c_ack();
	gpio_i2c_stop();
	return 0;
}