示例#1
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;
}
示例#2
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;
}