WhyCan Forum

人过留名,雁过留声,感谢各位朋友不离不弃地支持。 QQ: 516333132, 微信: whycan_cn (哇酷网/挖坑网/填坑网) admin@whycan.cn

您尚未登录。

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

晕哥小弟
会员
注册时间: 2019-04-04
累计积分: 203

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

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 8,476

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
累计积分: 275

Re: uboot 使用i2c

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

离线

页脚