Exemplo n.º 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;
}
Exemplo n.º 2
0
static int mma7660_hw_init(struct i2c_client *client)
{
	int comres = 0;

	// sample rate: 32
	comres += mma7660_set_rate(client, MMA7660_RATE_120);

	return comres;
}
Exemplo n.º 3
0
static ssize_t mma7660_rate_store(struct device *dev,
		struct device_attribute *attr,
		const char *buf, size_t count)
{
	unsigned long data;
	int error;
	struct i2c_client *client = to_i2c_client(dev);
	struct mma7660_data *mma7660 = i2c_get_clientdata(client);

	error = strict_strtoul(buf, 10, &data);
	if (error)
		return error;
	if (mma7660_set_rate(mma7660->mma7660_client, (unsigned char) data) < 0)
		return -EINVAL;

	return count;
}
Exemplo n.º 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;
}