示例#1
0
static int mma7660_start_dev(struct i2c_client *client, char rate)
{
	char buffer[MMA7660_REG_LEN];
	int ret = 0;

	buffer[0] = MMA7660_REG_INTSU;
	buffer[1] = 0x10;	//0x10; modify by zhao
	ret = mma7660_tx_data(client, &buffer[0], 2);
	ret = mma7660_rx_data(client, &buffer[0], 1);

	ret = mma7660_set_rate(client, rate);

	buffer[0] = MMA7660_REG_MODE;
	buffer[1] = 0x01;
	ret = mma7660_tx_data(client, &buffer[0], 2);
	ret = mma7660_rx_data(client, &buffer[0], 1);

	//enable_irq(client->irq);

#ifdef MMA7660_DATA_FILTER
	mma7660_adjust.count = 0;
#endif

	return ret;
}
示例#2
0
static int mma7660_set_rate(struct i2c_client *client, char rate)
{
	char buffer[2];
	int ret = 0;
	
	if (rate > 128)
        return -EINVAL;
	rk28printk("[ZWP]%s,rate = %d\n",__FUNCTION__,rate);
	//因为增加了滤波功能,即每RawDataLength次才上报一次,所以提升gsensor两个档级
	if(rate > 2)
		rate -= 2;
	rk28printk("[ZWP]%s,new rate = %d\n",__FUNCTION__,rate);

/*	
    for (i = 0; i < 7; i++) {
        if (rate & (0x1 << i))
            break;
    }   
    

	buffer[0] = MMA7660_REG_SR;
	buffer[1] = 0xf8 | (0x07 & (~i));
*/
	buffer[0] = MMA7660_REG_SR;
	buffer[1] = 0xf8 | (0x07 & rate);

	ret = mma7660_tx_data(client, &(buffer[0]), 2);
	ret = mma7660_rx_data(client, &(buffer[0]), 1);

	return ret;
}
示例#3
0
static int mma7660_close_dev(struct i2c_client *client)
{    	
	char buffer[2];

	disable_irq_nosync(client->irq);

	buffer[0] = MMA7660_REG_MODE;
	buffer[1] = 0x00;
	
	return mma7660_tx_data(client, buffer, 2);
}
示例#4
0
static int mma7660_start_dev(struct i2c_client *client, char rate)
{
	char buffer[MMA7660_REG_LEN];
	int ret = 0;

	buffer[0] = MMA7660_REG_INTSU;
	buffer[1] = 0x10;	//0x10; modify by zhao
	ret = mma7660_tx_data(client, &buffer[0], 2);
	ret = mma7660_rx_data(client, &buffer[0], 1);

	ret = mma7660_set_rate(client, rate);

	buffer[0] = MMA7660_REG_MODE;
	buffer[1] = 0x01;
	ret = mma7660_tx_data(client, &buffer[0], 2);
	ret = mma7660_rx_data(client, &buffer[0], 1);

	enable_irq(client->irq);
	rk28printk("\n----------------------------mma7660_start------------------------\n");
	
	return ret;
}
示例#5
0
static int mma7660_set_rate(struct i2c_client *client, char rate)
{
	struct mma7660_data *mma7660 = (struct mma7660_data *)i2c_get_clientdata(client);
	char buffer[2];
	int ret = 0;
	int i;
	
	//if (rate > 128)
	//	return -EINVAL;

	rate = MMA7660_MAX_RATE;
	
	//williamdeng wisky 20120424 GSENSOR��Ƶ�ʶ������������������޸��µĶ������㷽ʽ
	
	/*for (i = 0; i < 7; i++) {
		if (rate & (0x1 << i))
			break;
	}*/
	switch(rate)
	{
	case 1:  i=7;break;
	case 2:  i=6;break;
	case 4:  i=5;break;
	case 8:  i=4;break;
	case 16: i=3;break;
	case 32: i=2;break;
	case 64: i=1;break;
	case 120:i=0;break;
	default: i=1;break;//set default to 64 samples/second
	}
	//end williamdeng wisky 20120424
	
	buffer[0] = MMA7660_REG_SR;
	buffer[1] = 0xf8 | (0x07 & (i));

	ret = mma7660_tx_data(client, &(buffer[0]), 2);
	ret = mma7660_rx_data(client, &(buffer[0]), 1);

	mma7660->curr_tate = rate;
		
	return ret;
}