您尚未登录。

楼主 #1 2019-07-19 14:12:44

晕哥小弟
会员
注册时间: 2019-04-04
已发帖子: 309
积分: 299.5

uboot 使用i2c

各位朋友,有谁在uboot  下使用了i2c么?
我首先在menuconfig 打开命令行i2c。
编译却报错:

 CC      cmd/gpio.o
  CC      cmd/i2c.o
cmd/i2c.c: In function ‘i2c_get_bus_speed’:
cmd/i2c.c:211:9: error: ‘CONFIG_SYS_I2C_SPEED’ undeclared (first use in this function); did you mean ‘CONFIG_SYS_I2C_SLAVE’?
  return CONFIG_SYS_I2C_SPEED;
         ^~~~~~~~~~~~~~~~~~~~
         CONFIG_SYS_I2C_SLAVE
cmd/i2c.c:211:9: note: each undeclared identifier is reported only once for each function it appears in
cmd/i2c.c: In function ‘i2c_set_bus_speed’:
cmd/i2c.c:230:15: error: ‘CONFIG_SYS_I2C_SPEED’ undeclared (first use in this function); did you mean ‘CONFIG_SYS_I2C_SLAVE’?
  if (speed != CONFIG_SYS_I2C_SPEED)
               ^~~~~~~~~~~~~~~~~~~~
               CONFIG_SYS_I2C_SLAVE
cmd/i2c.c: In function ‘do_i2c_reset’:
cmd/i2c.c:1925:11: error: ‘CONFIG_SYS_I2C_SPEED’ undeclared (first use in this function); did you mean ‘CONFIG_SYS_I2C_SLAVE’?
  i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
           ^~~~~~~~~~~~~~~~~~~~
           CONFIG_SYS_I2C_SLAVE
cmd/i2c.c: In function ‘i2c_get_bus_speed’:
cmd/i2c.c:212:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
make[1]: *** [cmd/i2c.o] Error 1
make: *** [cmd] Error 2

离线

#2 2019-07-19 14:26:38

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,235
积分: 9197

Re: uboot 使用i2c

没有玩过 I2C, 不过可以给你提供另一个思路:
https://github.com/qq516333132/u-boot/commit/f83a2b6ca9282b0b12f883108ec14fcd012cb78d

学华嵌 用 gpio 模拟spi 通讯, 你可以模拟 i2c 通讯。





在线

#3 2019-07-19 21:40:01

ippen
会员
注册时间: 2018-07-22
已发帖子: 345
积分: 339.5

Re: uboot 使用i2c

不是光打开i2c命令就行,要到drivers的路径下,将i2c的驱动等一系列东西启用才行

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn