• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ i2c_smbus_write_byte函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中i2c_smbus_write_byte函数的典型用法代码示例。如果您正苦于以下问题:C++ i2c_smbus_write_byte函数的具体用法?C++ i2c_smbus_write_byte怎么用?C++ i2c_smbus_write_byte使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了i2c_smbus_write_byte函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: tsl2550_set_power_state

static int tsl2550_set_power_state(struct i2c_client *client, int state)
{
	struct tsl2550_data *data = i2c_get_clientdata(client);
	int ret;

	if (state == 0)
		ret = i2c_smbus_write_byte(client, TSL2550_POWER_DOWN);
	else {
		ret = i2c_smbus_write_byte(client, TSL2550_POWER_UP);

		/* On power up we should reset operating mode also... */
		tsl2550_set_operating_mode(client, data->operating_mode);
	}

	data->power_state = state;

	return ret;
}
开发者ID:avagin,项目名称:linux,代码行数:18,代码来源:tsl2550.c


示例2: mcsdl_erase_flash

static int mcsdl_erase_flash(void)
{
	int i;
	int ret = 0;
	int read_data = 0;
	uint8_t i2c_buffer[4] = {0x0F, 						/* isp erase timing cmd */
							0x01, 						/* isp erase timing value 0 */
							0xD4, 						/* isp erase timing value 1 */
							0xC0};						/* isp erase timing value 2 */

	/* Send Erase Setting code */
	for(i=0; i<4; i++){
		ret = i2c_smbus_write_byte(g_client, i2c_buffer[i]);
		if( 0 != ret ){
			printk("mcsdl prepare erase flash error\n");
			return -1;
		}
		udelay(15);
	}
	udelay(500);

	/* Read Result */
	read_data = i2c_smbus_read_byte(g_client);
	if (read_data != 0x8F) {							/* isp ack prepare erase done */
		printk("mcsdl erase flash error0\n");
		return -1;
	}
	mdelay(1);

	/*Send Erase code */
	ret = i2c_smbus_write_byte(g_client, 0x02);
	if( 0 != ret ){
		printk("mcsdl send erase code error\n");
		return -1;
	}
	mdelay(45);
	read_data = i2c_smbus_read_byte(g_client);
	if (read_data != 0x82) {
		printk("mcsdl erase flash error1\n");
		return -1;
	}
	return 0;
}
开发者ID:Simo2553,项目名称:kernel_huawei_u8160,代码行数:43,代码来源:melfas_i2c_ts.c


示例3: tsl2550_set_operating_mode

static int tsl2550_set_operating_mode(struct i2c_client *client, int mode)
{
	struct tsl2550_data *data = i2c_get_clientdata(client);

	int ret = i2c_smbus_write_byte(client, TSL2550_MODE_RANGE[mode]);

	data->operating_mode = mode;

	return ret;
}
开发者ID:19Dan01,项目名称:linux,代码行数:10,代码来源:tsl2550.c


示例4: bh1721fvc_write_byte

static int bh1721fvc_write_byte(struct i2c_client *client, u8 value)
{
	int retry;

	for (retry = 0; retry < 5; retry++)
		if (!i2c_smbus_write_byte(client, value))
			return 0;

	return -EIO;
}
开发者ID:AndreiLux,项目名称:Perseus-S3,代码行数:10,代码来源:bh1721.c


示例5: max1363_smbus_send

static int max1363_smbus_send(const struct i2c_client *client, const char *buf,
		int count)
{
	int i, err;

	for (i = err = 0; err == 0 && i < count; ++i)
		err = i2c_smbus_write_byte(client, buf[i]);

	return err ? err : count;
}
开发者ID:AnadoluPanteri,项目名称:kernel-plus-harmattan,代码行数:10,代码来源:max1363.c


示例6: smbus_write_op

static int
smbus_write_op(struct smbus_op_params *params, const struct smbus_op *op)
{
	int result;

	/* FIXME: Why is this needed if the open_i2c_slave performs the ioctl
	 * with I2C_SLAVE? */
	/* Double cast the last argument for compat with klibc. */
	if (ioctl(params->fd, I2C_SLAVE_FORCE,
	          (void *)(intptr_t)params->address) < 0) {
		fprintf(stderr, "can't set address 0x%02X, %s\n",
		        params->address, strerror(errno));
		return -1;
	}

	switch (op->size) {
	case SMBUS_SIZE_8:
		result = i2c_smbus_write_byte_data(params->fd, params->reg,
		             params->data.fixed.u8);
		break;
	case SMBUS_SIZE_16:
		result = i2c_smbus_write_word_data(params->fd, params->reg,
		             params->data.fixed.u16);
		break;
	case SMBUS_SIZE_BLOCK:
		result = i2c_smbus_write_block_data(params->fd, params->reg,
		             params->len, params->data.array);
		break;
	case SMBUS_SIZE_BYTE:
		result = i2c_smbus_write_byte(params->fd,
		                              params->data.fixed.u8);
		break;
	case SMBUS_QUICK:
		result = i2c_smbus_write_quick(params->fd,
		                              params->data.fixed.u8);
		break;
	default:
		fprintf(stderr, "Illegal SMBus size for write operation.\n");
		return -1;
	}

	if (result < 0) {
		if (op->size != SMBUS_SIZE_BYTE && op->size != SMBUS_QUICK) {
			fprintf(stderr, "can't write register 0x%02X, %s\n",
			        params->reg, strerror(errno));
		} else {
			fprintf(stderr, "can't write to device 0x%02X, %s\n",
			        params->address, strerror(errno));
		}
		return -1;
	}

	return 0;
}
开发者ID:jetma,项目名称:iotools,代码行数:54,代码来源:smbus_rw.c


示例7: gw_pld_output8

static int gw_pld_output8(struct gpio_chip *gc, unsigned offset, int value)
{
	struct gw_pld *gw = gpiochip_get_data(gc);

	if (value)
		gw->out |= BIT(offset);
	else
		gw->out &= ~BIT(offset);

	return i2c_smbus_write_byte(gw->client, gw->out);
}
开发者ID:Anjali05,项目名称:linux,代码行数:11,代码来源:gpio-gw-pld.c


示例8: qt2160_write

static int __devinit qt2160_write(struct i2c_client *client, u8 reg, u8 data)
{
	int error;

	error = i2c_smbus_write_byte(client, reg);
	if (error) {
		dev_err(&client->dev,
			"couldn't send request. Returned %d\n", error);
		return error;
	}

	error = i2c_smbus_write_byte(client, data);
	if (error) {
		dev_err(&client->dev,
			"couldn't write data. Returned %d\n", error);
		return error;
	}

	return error;
}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:20,代码来源:qt2160.c


示例9: bh1721fvc_write_byte

static int bh1721fvc_write_byte(struct i2c_client *client, u8 value)
{
	int retry;

	for (retry = 0; retry < 10; retry++)
		if (!i2c_smbus_write_byte(client, value))
			return 0;

	printk("I2C read failed.. retry %d\n", retry);
	return -EIO;
}
开发者ID:motley-git,项目名称:Kernel-GT-P7310,代码行数:11,代码来源:bh1721fvc.c


示例10: bh1780_probe

//[*]--------------------------------------------------------------------------------------------------[*]
static int bh1780_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	struct bh1780_data  *bh1780;
	int                 err;

	/* setup private data */
	bh1780 = kzalloc(sizeof(struct bh1780_data), GFP_KERNEL);
	if (!bh1780) {
		pr_err("%s: failed to allocate memory for module\n", __func__);
		return -ENOMEM;
	}

	i2c_set_clientdata(client, bh1780);

	dev_set_drvdata(&client->dev, bh1780);

	bh1780->client = client;

	/* detect and init hardware */
	if ((err = bh1780_detect(client, NULL)) != 0)   goto error;

	if((err = i2c_smbus_write_byte(bh1780->client, (BH1780_COMMAND_REG + BH1780_PART_REV_REG))) < 0)	{
		dev_err(&client->dev, "I2C write byte error: data=0x%02x\n", (BH1780_COMMAND_REG + BH1780_PART_REV_REG));
		goto error;
	}
	if((err = i2c_smbus_read_byte(client)) < 0)	{
		dev_err(&client->dev, "I2C read byte error\n");
		goto error;
	}

	dev_info(&client->dev, "%s found\n", id->name);
	dev_info(&client->dev, "part number=%d, rev=%d\n", ((err >> 4) & 0x0F), (err & 0x0F));

	bh1780_power_up(bh1780);

	INIT_DELAYED_WORK(&bh1780->work, bh1780_work_func);

	#if defined(CONFIG_ODROID_EXYNOS5_IOBOARD_DEBUG)
		bh1780->enabled = 1;
	#endif

	if(bh1780->enabled) schedule_delayed_work(&bh1780->work, BH1780_WORK_PERIOD);

	if ((err = sysfs_create_group(&client->dev.kobj, &bh1780_attribute_group)) < 0)		goto error;

	printk("\n=================== ioboard_%s ===================\n\n", __func__);

	return 0;

error:
	printk("\n=================== ioboard_%s FAIL! ===================\n\n", __func__);

	return err;
}
开发者ID:tiagormk,项目名称:linux-vitamins-odroidxu,代码行数:55,代码来源:ioboard-bh1780.c


示例11: blinkm_write

static int blinkm_write(struct i2c_client *client, int cmd, u8 *arg)
{
	int result;
	int i;
	int arglen = blinkm_cmds[cmd].nr_args;
	/* write out cmd to blinkm - always / default step */
	result = i2c_smbus_write_byte(client, blinkm_cmds[cmd].cmdbyte);
	if (result < 0)
		return result;
	/* no args to write out */
	if (arglen == 0)
		return 0;

	for (i = 0; i < arglen; i++) {
		/* repeat for arglen */
		result = i2c_smbus_write_byte(client, arg[i]);
		if (result < 0)
			return result;
	}
	return 0;
}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:21,代码来源:leds-blinkm.c


示例12: lightning_flash_mux_sel_chan

/* Enable the mux to select a particular channel */
int
lightning_flash_mux_sel_chan(uint8_t mux, uint8_t channel) {

  int dev;
  int ret;
  uint8_t addr;
  uint8_t chan_en;
  char bus[32];

  if (mux == I2C_MUX_FLASH1)
    sprintf(bus, "%s", I2C_DEV_FLASH1);
  else if (mux == I2C_MUX_FLASH2)
    sprintf(bus, "%s", I2C_DEV_FLASH2);

  dev = open(bus, O_RDWR);
  if (dev < 0) {
    syslog(LOG_ERR, "lightning_flash_mux_sel_chan: open() failed");
    return -1;
  }

  switch(mux) {
    case I2C_MUX_FLASH1:
      addr = I2C_MUX_FLASH1_ADDR,
      chan_en = (1 << 3) | channel;
      break;

    case I2C_MUX_FLASH2:
      addr = I2C_MUX_FLASH2_ADDR,
      chan_en = (1 << 3) | channel;
      break;
  }

  /* Assign the i2c device address */
  ret = ioctl(dev, I2C_SLAVE, addr);
  if (ret < 0) {
    syslog(LOG_ERR, "lightning_flash_mux_sel_chan: ioctl() assigning i2c addr failed");
    close(dev);
    return -1;
  }

  /* Write the channel number to enable it */
  ret = i2c_smbus_write_byte(dev, chan_en);
  if (ret < 0) {
    syslog(LOG_ERR, "lightning_flash_mux_sel_chan: i2c_smbus_write_byte failed");
    close(dev);
    return -1;
  }

  close(dev);

  return 0;
}
开发者ID:StartE,项目名称:openbmc,代码行数:53,代码来源:lightning_flash.c


示例13: write_mark1_reg

char write_mark1_reg(unsigned char add){
    int resp = 0 ;
    if (ioctl(i2c_bus -> file, I2C_SLAVE, MARK1_ADDR) < 0) {
        /* ERROR HANDLING; you can check errno to see what went wrong */
        exit(1);
    }
    resp = i2c_smbus_write_byte(i2c_bus -> file, add);
    if (resp < 0) {
    	printf("error accessing i2c bus , returned :%d \n", resp);    
	exit(-1);    
    }
    return resp;
}
开发者ID:AshirogiMaxx,项目名称:fpga-cam,代码行数:13,代码来源:serial_fpga_loader.c


示例14: myI2C_write_byte

int myI2C_write_byte(int file, uint8_t data)
{
    int res = i2c_smbus_write_byte(file, data);
    /** S Addr Wr [A] Data [A] P **/
    if (res<0)
    {
        printf("result i2c write error");
        return -1;
    }

    //printf("after mode 1 write: 0x%02X to register 0x%02X \n", buf[1], buf[0]);
    return 0;
}
开发者ID:Cragjock,项目名称:LCDI2C,代码行数:13,代码来源:myI2C.c


示例15: to_i2c_client

static struct pem_data *pem_update_device(struct device *dev)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct pem_data *data = i2c_get_clientdata(client);
	struct pem_data *ret = data;

	mutex_lock(&data->update_lock);

	if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
		int result;

		/* Read data string */
		result = pem_read_block(client, PEM_READ_DATA_STRING,
					data->data_string,
					sizeof(data->data_string));
		if (unlikely(result < 0)) {
			ret = ERR_PTR(result);
			goto abort;
		}

		/* Read input string */
		if (data->input_length) {
			result = pem_read_block(client, PEM_READ_INPUT_STRING,
						data->input_string,
						data->input_length);
			if (unlikely(result < 0)) {
				ret = ERR_PTR(result);
				goto abort;
			}
		}

		/* Read fan speeds */
		if (data->fans_supported) {
			result = pem_read_block(client, PEM_READ_FAN_SPEED,
						data->fan_speed,
						sizeof(data->fan_speed));
			if (unlikely(result < 0)) {
				ret = ERR_PTR(result);
				goto abort;
			}
		}

		i2c_smbus_write_byte(client, PEM_CLEAR_INFO_FLAGS);

		data->last_updated = jiffies;
		data->valid = 1;
	}
abort:
	mutex_unlock(&data->update_lock);
	return ret;
}
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:51,代码来源:lineage-pem.c


示例16: openfile

void openfile()
{
    //open the device file
    snprintf(filename, 19, "/dev/i2c-%d", adapter_nr);
    file = open(filename, O_RDWR);

    if (file < 0)
    {
        printf("Failed to open i2c device.\n");
        exit(1);
    }

    //specify what device address you want to communicate

    int addr = 0x52;	 //address for nunchuck

		//Access the I2C slave

    if(ioctl(file, I2C_SLAVE, addr) < 0)
    {
        printf("Failed to acquire bus access to slave.\n");
        printf("error..., something is wrong %s\n", strerror(errno));
        exit(1);
    }

		//TODO: write initialization data to the nunchuk.
        //if it returns with error (-1) exit with status 1\

    // Initialize white nunchuck
//    if(i2c_smbus_write_byte(file, 0x40) == -1) {
//        printf("error..., something is wrong  gvcn jhbv %s\n", strerror(errno));
//        exit(1);
//    }
//    if(i2c_smbus_write_byte(file, 0x00) == -1) {
//        printf("error..., something is wrong %s\n", strerror(errno));
//        exit(1);
//    }

    if(i2c_smbus_write_byte_data(file, 0x40, 0x00) == -1)
    {
        printf("error..., something is wrong %s\n", strerror(errno));
        exit(1);
    }

    if(i2c_smbus_write_byte(file, 0x00) == -1) {
        printf("error..., something is wrong %s\n", strerror(errno));
        exit(1);
    }

}
开发者ID:yoos,项目名称:school,代码行数:50,代码来源:dialog.cpp


示例17: max732x_writeb

static int max732x_writeb(struct max732x_chip *chip, int group_a, uint8_t val)
{
	struct i2c_client *client;
	int ret;

	client = group_a ? chip->client_group_a : chip->client_group_b;
	ret = i2c_smbus_write_byte(client, val);
	if (ret < 0) {
		dev_err(&client->dev, "failed writing\n");
		return ret;
	}

	return 0;
}
开发者ID:12rafael,项目名称:jellytimekernel,代码行数:14,代码来源:max732x.c


示例18: vct_get_version

u8 vct_get_version(int i2c) {
	if (i2c_smbus_write_byte(i2c, 0x03) < 0) {
		perror("Error sending version command");
		return 0;
	}

	int ver = i2c_smbus_read_byte(i2c);
	if (ver < 0) {
		perror("Error getting version number");
		return 0;
	}

	return ver;
}
开发者ID:ondrej-zary,项目名称:vct_flash,代码行数:14,代码来源:vct_flash.c


示例19: ad525x_write

/**
 * ad525x_write - store the given value in the specified register on
 * the AD5258 device.
 * @client: value returned from i2c_new_device()
 * @reg: the register to write
 * @value: the byte to store in the register
 *
 * For certain instructions that do not require a data byte, "NULL"
 * should be specified for the "value" parameter.  These instructions
 * include NOP, RESTORE_FROM_EEPROM, and STORE_TO_EEPROM.
 *
 * A negative return value indicates an error occurred while reading
 * the register.
 */
static s32 ad525x_write(struct i2c_client *client, u8 reg, u8 value)
{
	struct dpot_data *data = i2c_get_clientdata(client);

	/* Only write the instruction byte for certain commands */
	if (reg & AD525X_I2C_CMD)
		return i2c_smbus_write_byte(client, reg);

	if (data->max_pos > 256)
		return i2c_smbus_write_word_data(client, (reg & 0xF8) |
						((reg & 0x7) << 1), value);
	else
		/* All other registers require instruction + data bytes */
		return i2c_smbus_write_byte_data(client, reg, value);
}
开发者ID:A2109devs,项目名称:lenovo_a2109a_kernel,代码行数:29,代码来源:ad525x_dpot.c


示例20: tsc2004_cmd

static int tsc2004_cmd(struct device *dev, u8 cmd)
{
	u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd;
	s32 data;
	struct i2c_client *i2c = to_i2c_client(dev);

	data = i2c_smbus_write_byte(i2c, tx);
	if (data < 0) {
		dev_err(dev, "%s: failed, command: %x i2c error: %d\n",
			__func__, cmd, data);
		return data;
	}

	return 0;
}
开发者ID:AK101111,项目名称:linux,代码行数:15,代码来源:tsc2004.c



注:本文中的i2c_smbus_write_byte函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ i2c_smbus_write_byte_data函数代码示例发布时间:2022-05-31
下一篇:
C++ i2c_smbus_read_word_data函数代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap