Created
May 31, 2012 23:53
-
-
Save johnhowe/2847298 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int mma8451_change_mode(struct i2c_client *client, int mode) | |
{ | |
int result; | |
u8 tmp_data = 0; | |
mma_status.ctl_reg1 = 0; | |
result = i2c_smbus_write_byte_data(client, MMA8451_CTRL_REG1, 0); | |
if (result < 0) | |
goto out; | |
//open-drain selection on interrupt pad | |
tmp_data = 0x01; | |
result = i2c_smbus_write_byte_data(client, MMA8451_CTRL_REG3,tmp_data); | |
if (result < 0) | |
goto out; | |
mma_status.mode = mode; | |
result = i2c_smbus_write_byte_data(client, MMA8451_XYZ_DATA_CFG, | |
mma_status.mode); | |
if (result < 0) | |
goto out; | |
mma_status.ctl_reg1 |= 0x01; | |
result = i2c_smbus_write_byte_data(client, MMA8451_CTRL_REG1, | |
mma_status.ctl_reg1); | |
if (result < 0) | |
goto out; | |
mdelay(MODE_CHANGE_DELAY_MS); | |
return 0; | |
out: | |
dev_err(&client->dev, "error when init mma8451:(%d)", result); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment