本文整理汇总了C++中i2c_smbus_write_byte_data函数的典型用法代码示例。如果您正苦于以下问题:C++ i2c_smbus_write_byte_data函数的具体用法?C++ i2c_smbus_write_byte_data怎么用?C++ i2c_smbus_write_byte_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了i2c_smbus_write_byte_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: abov_glove_mode_enable
static int abov_glove_mode_enable(struct i2c_client *client, u8 cmd)
{
return i2c_smbus_write_byte_data(client, ABOV_GLOVE, cmd);
}
示例2: sfe4001_poweron
static int sfe4001_poweron(struct efx_nic *efx)
{
struct i2c_client *ioexp_client = falcon_board(efx)->ioexp_client;
struct i2c_client *hwmon_client = falcon_board(efx)->hwmon_client;
unsigned int i, j;
int rc;
u8 out;
/* Clear any previous over-temperature alert */
rc = i2c_smbus_read_byte_data(hwmon_client, MAX664X_REG_RSL);
if (rc < 0)
return rc;
/* Enable port 0 and port 1 outputs on IO expander */
rc = i2c_smbus_write_byte_data(ioexp_client, P0_CONFIG, 0x00);
if (rc)
return rc;
rc = i2c_smbus_write_byte_data(ioexp_client, P1_CONFIG,
0xff & ~(1 << P1_SPARE_LBN));
if (rc)
goto fail_on;
/* If PHY power is on, turn it all off and wait 1 second to
* ensure a full reset.
*/
rc = i2c_smbus_read_byte_data(ioexp_client, P0_OUT);
if (rc < 0)
goto fail_on;
out = 0xff & ~((0 << P0_EN_1V2_LBN) | (0 << P0_EN_2V5_LBN) |
(0 << P0_EN_3V3X_LBN) | (0 << P0_EN_5V_LBN) |
(0 << P0_EN_1V0X_LBN));
if (rc != out) {
netif_info(efx, hw, efx->net_dev, "power-cycling PHY\n");
rc = i2c_smbus_write_byte_data(ioexp_client, P0_OUT, out);
if (rc)
goto fail_on;
schedule_timeout_uninterruptible(HZ);
}
for (i = 0; i < 20; ++i) {
/* Turn on 1.2V, 2.5V, 3.3V and 5V power rails */
out = 0xff & ~((1 << P0_EN_1V2_LBN) | (1 << P0_EN_2V5_LBN) |
(1 << P0_EN_3V3X_LBN) | (1 << P0_EN_5V_LBN) |
(1 << P0_X_TRST_LBN));
if (efx->phy_mode & PHY_MODE_SPECIAL)
out |= 1 << P0_EN_3V3X_LBN;
rc = i2c_smbus_write_byte_data(ioexp_client, P0_OUT, out);
if (rc)
goto fail_on;
msleep(10);
/* Turn on 1V power rail */
out &= ~(1 << P0_EN_1V0X_LBN);
rc = i2c_smbus_write_byte_data(ioexp_client, P0_OUT, out);
if (rc)
goto fail_on;
netif_info(efx, hw, efx->net_dev,
"waiting for DSP boot (attempt %d)...\n", i);
/* In flash config mode, DSP does not turn on AFE, so
* just wait 1 second.
*/
if (efx->phy_mode & PHY_MODE_SPECIAL) {
schedule_timeout_uninterruptible(HZ);
return 0;
}
for (j = 0; j < 10; ++j) {
msleep(100);
/* Check DSP has asserted AFE power line */
rc = i2c_smbus_read_byte_data(ioexp_client, P1_IN);
if (rc < 0)
goto fail_on;
if (rc & (1 << P1_AFE_PWD_LBN))
return 0;
}
}
netif_info(efx, hw, efx->net_dev, "timed out waiting for DSP boot\n");
rc = -ETIMEDOUT;
fail_on:
sfe4001_poweroff(efx);
return rc;
}
示例3: da280_enable
static int da280_enable(struct i2c_client *client, bool enable)
{
u8 data = enable ? DA280_MODE_ENABLE : DA280_MODE_DISABLE;
return i2c_smbus_write_byte_data(client, DA280_REG_MODE_BW, data);
}
示例4: isp1301_clear_bits
static inline int
isp1301_clear_bits(struct isp1301 *isp, u8 reg, u8 bits)
{
return i2c_smbus_write_byte_data(isp->client, reg + 1, bits);
}
示例5: ms_nxtmmx_send_command
static int ms_nxtmmx_send_command(void *context,
struct tacho_motor_params *param,
enum tacho_motor_command command)
{
struct ms_nxtmmx_data *mmx = context;
int err;
u8 command_bytes[WRITE_SIZE];
if (IS_RUN_CMD(command)) {
/* fill in the setpoints with the correct polarity */
*(int *)command_bytes = cpu_to_le32(mmx->tm.params.position_sp);
command_bytes[WRITE_SPEED] = ms_nxtmmx_scale_speed(mmx->tm.params.speed_sp);
if (mmx->tm.params.polarity == DC_MOTOR_POLARITY_INVERSED) {
*(int *)command_bytes *= -1;
command_bytes[WRITE_SPEED] *= -1;
}
/* set the appropriate command flags based on the run command */
if (IS_POS_CMD(command))
mmx->command_flags |= CMD_FLAG_ENCODER_CTRL;
else
mmx->command_flags &= ~CMD_FLAG_ENCODER_CTRL;
if (command == TM_COMMAND_RUN_TO_REL_POS)
mmx->command_flags |= CMD_FLAG_RELATIVE;
else
mmx->command_flags &= ~CMD_FLAG_RELATIVE;
/* set bits for stop command */
if (mmx->tm.params.stop_command == TM_STOP_COMMAND_HOLD)
mmx->command_flags |= CMD_FLAG_HOLD;
else
mmx->command_flags &= ~CMD_FLAG_HOLD;
if (mmx->tm.params.stop_command == TM_STOP_COMMAND_BRAKE)
mmx->command_flags |= CMD_FLAG_BRAKE;
else
mmx->command_flags &= ~CMD_FLAG_BRAKE;
mmx->command_flags |= CMD_FLAG_GO;
command_bytes[WRITE_TIME] = 0; /* never use timed mode */
command_bytes[WRITE_COMMAND_B] = 0;
command_bytes[WRITE_COMMAND_A] = mmx->command_flags;
/* then write to the individual motor register to GO! */
err = i2c_smbus_write_i2c_block_data(mmx->i2c->client,
WRITE_REG(mmx->index), WRITE_SIZE, command_bytes);
if (err < 0)
return err;
} else if (command == TM_COMMAND_STOP) {
mmx->command_flags = CMD_FLAGS_DEFAULT_VALUE;
command_bytes[0] = (mmx->tm.params.stop_command == TM_STOP_COMMAND_COAST)
? COMMAND_FLOAT_STOP(mmx->index) : COMMAND_BRAKE_STOP(mmx->index);
err = i2c_smbus_write_byte_data(mmx->i2c->client,
COMMAND_REG, command_bytes[0]);
if (err < 0)
return err;
if (mmx->tm.params.stop_command == TM_STOP_COMMAND_HOLD) {
/*
* Hold only happens when encoder mode is enabled, so
* we have to issue a run command to tell it to run to
* the current position so that it will hold that position.
*/
err = i2c_smbus_read_i2c_block_data(mmx->i2c->client,
READ_ENCODER_POS_REG(mmx->index), ENCODER_SIZE, command_bytes);
if (err < 0)
return err;
mmx->command_flags = CMD_FLAGS_STOP_HOLD;
command_bytes[WRITE_SPEED] = 100;
command_bytes[WRITE_TIME] = 0;
command_bytes[WRITE_COMMAND_B] = 0;
command_bytes[WRITE_COMMAND_A] = mmx->command_flags;
err = i2c_smbus_write_i2c_block_data(mmx->i2c->client,
WRITE_REG(mmx->index), WRITE_SIZE, command_bytes);
if (err < 0)
return err;
}
} else if (command == TM_COMMAND_RESET) {
mmx->tm.params.speed_regulation = TM_SPEED_REGULATION_ON;
mmx->command_flags = CMD_FLAGS_DEFAULT_VALUE;
command_bytes[0] = COMMAND_FLOAT_STOP(mmx->index);
err = i2c_smbus_write_byte_data(mmx->i2c->client,
COMMAND_REG, command_bytes[0]);
if (err < 0)
return err;
command_bytes[0] = COMMAND_RESET_ENCODER(mmx->index);
err = i2c_smbus_write_byte_data(mmx->i2c->client,
COMMAND_REG, command_bytes[0]);
if (err < 0)
return err;
}
return 0;
}
示例6: max8952_write_reg
static int max8952_write_reg(struct max8952_data *max8952,
u8 reg, u8 value)
{
return i2c_smbus_write_byte_data(max8952->client, reg, value);
}
示例7: main
//.........这里部分代码省略.........
case I2C_SMBUS_BYTE:
oldvalue = i2c_smbus_read_byte(file);
break;
case I2C_SMBUS_WORD_DATA:
oldvalue = i2c_smbus_read_word_data(file, daddress);
break;
default:
oldvalue = i2c_smbus_read_byte_data(file, daddress);
}
if (oldvalue < 0) {
fprintf(stderr, "Error: Failed to read old value\n");
exit(1);
}
value = (value & vmask) | (oldvalue & ~vmask);
if (!yes) {
fprintf(stderr, "Old value 0x%0*x, write mask "
"0x%0*x: Will write 0x%0*x to register "
"0x%02x\n",
size == I2C_SMBUS_WORD_DATA ? 4 : 2, oldvalue,
size == I2C_SMBUS_WORD_DATA ? 4 : 2, vmask,
size == I2C_SMBUS_WORD_DATA ? 4 : 2, value,
daddress);
fprintf(stderr, "Continue? [Y/n] ");
fflush(stderr);
if (!user_ack(1)) {
fprintf(stderr, "Aborting on user request.\n");
exit(0);
}
}
}
if (pec && ioctl(file, I2C_PEC, 1) < 0) {
fprintf(stderr, "Error: Could not set PEC: %s\n",
strerror(errno));
close(file);
exit(1);
}
switch (size) {
case I2C_SMBUS_BYTE:
res = i2c_smbus_write_byte(file, daddress);
break;
case I2C_SMBUS_WORD_DATA:
res = i2c_smbus_write_word_data(file, daddress, value);
break;
default: /* I2C_SMBUS_BYTE_DATA */
res = i2c_smbus_write_byte_data(file, daddress, value);
}
if (res < 0) {
fprintf(stderr, "Error: Write failed\n");
close(file);
exit(1);
}
if (pec) {
if (ioctl(file, I2C_PEC, 0) < 0) {
fprintf(stderr, "Error: Could not clear PEC: %s\n",
strerror(errno));
close(file);
exit(1);
}
}
if (!readback) { /* We're done */
close(file);
exit(0);
}
switch (size) {
case I2C_SMBUS_BYTE:
res = i2c_smbus_read_byte(file);
value = daddress;
break;
case I2C_SMBUS_WORD_DATA:
res = i2c_smbus_read_word_data(file, daddress);
break;
default: /* I2C_SMBUS_BYTE_DATA */
res = i2c_smbus_read_byte_data(file, daddress);
}
close(file);
if (res < 0) {
printf("Warning - readback failed\n");
} else
if (res != value) {
printf("Warning - data mismatch - wrote "
"0x%0*x, read back 0x%0*x\n",
size == I2C_SMBUS_WORD_DATA ? 4 : 2, value,
size == I2C_SMBUS_WORD_DATA ? 4 : 2, res);
} else {
printf("Value 0x%0*x written, readback matched\n",
size == I2C_SMBUS_WORD_DATA ? 4 : 2, value);
}
exit(0);
}
示例8: write_reg
static int write_reg(struct i2c_client *client, u8 reg, u8 value)
{
return i2c_smbus_write_byte_data(client, reg, value);
}
示例9: g760a_write_value
static int g760a_write_value(struct i2c_client *client, enum g760a_regs reg,
u16 value)
{
return i2c_smbus_write_byte_data(client, reg, value);
}
示例10: hmc5883_stop_measure
static void hmc5883_stop_measure(struct hmc5883_data *hmc5883)
{
i2c_smbus_write_byte_data(hmc5883->client, HMC5883_REG_MODE, MODE_IDLE);
}
示例11: gp2a_disable
static int gp2a_disable(struct gp2a_data *dt)
{
return i2c_smbus_write_byte_data(dt->i2c_client, GP2A_ADDR_OPMOD,
0x00);
}
示例12: gp2a_enable
static int gp2a_enable(struct gp2a_data *dt)
{
return i2c_smbus_write_byte_data(dt->i2c_client, GP2A_ADDR_OPMOD,
GP2A_CTRL_SSD);
}
示例13: ad7414_write
static inline int ad7414_write(struct i2c_client *client, u8 reg, u8 value)
{
return i2c_smbus_write_byte_data(client, reg, value);
}
示例14: tsl4531_powerdown
static int tsl4531_powerdown(struct i2c_client *client)
{
return i2c_smbus_write_byte_data(client, TSL4531_CONTROL,
TSL4531_MODE_POWERDOWN);
}
示例15: tsl4531_resume
static int tsl4531_resume(struct device *dev)
{
return i2c_smbus_write_byte_data(to_i2c_client(dev), TSL4531_CONTROL,
TSL4531_MODE_NORMAL);
}