在U-Boot中使用I2C读取多个字节 [英] Reading multiple bytes using I2C in U-Boot

查看:212
本文介绍了在U-Boot中使用I2C读取多个字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在飞思卡尔p1022tw板的I2C驱动程序上遇到问题. U-Boot控制台上有一个命令可以从I2C设备读取:

I am having a problem with the I2C driver for a Freescale p1022tw board. There is a command on U-Boot's console to read from an I2C device:

i2c md chip address[.0, .1, .2] [# of objects]

当我从地址为0x0的ID为0x60的设备读取4个字节时,我得到:

When I read 4 bytes from a device with id 0x60, at address 0x0, I get:

tw=>i2c md 60 0 4
0000: 45 45 45 45    EEEE

它返回的这些值是错误的.如果我一次读一个字节,我可以得到正确的值:

These values that it returned are wrong. I can get the right values if I read one byte at the time:

tw=>i2c md 60 0 1
0000: 45    E
tw=>i2c md 60 1 1
0001: 45    E
tw=>i2c md 60 2 1
0002: 46    F
tw=>i2c md 60 3 1
0003: 00    .

我应该在第一个命令中得到45 45 46 00EEF0.在该设备的多次读数中,它始终仅返回第一个字节值.如果我尝试从地址0x2开始获取6个字节,则输出为:

I should have gotten 45 45 46 00 or EEF0 in the first command. In multiple readings for this device, it is returning always just the first byte value. If I try to get 6 bytes starting at address 0x2, this is the output:

tw=>i2c md 60 2 6
0002: 46 46 46 46 46 46    FFFFFF

在总线上的其他设备上不会发生此问题.例如,在ID为0x4F的设备中,将打印正确的值:

This problem does not happen on other devices on the bus. For instance, in the device with id 0x4F, the right values are printed:

tw=>i2c md 4F 0.2 6
0000: 18 00 f6 48 00 00    ...H..

上一条命令中的地址为".2",因为芯片使用2个字节作为地址.第一个设备仅使用1,因此无需放置".1"(我已经测试过).

The address in the previous command has a ".2" because the chip uses 2 bytes for addresses. The first device only uses 1, so there's no need to put a ".1" (I already tested that).

我经历了I2C通信的飞思卡尔驱动程序的实现,但是我没有对其进行任何更改,它可以在其他设备上使用.我的同事还说,相同的代码也可以在他的板上工作.有没有人遇到过类似的问题,或者有任何关于为什么发生这种情况的理论?

I went through the implementation of the Freescale driver for the I2C communication, but I didn't change anything on it and it works for other devices. My coworker also says that the very same code works on his board. Have anybody had a similar issue or has any theory about why this is happening?

谢谢.

推荐答案

我遇到了这种情况.我具有驱动程序,读取和写入功能,但不适用于所有i2c设备.我发现这是由于无法正常运行的设备对多种操作具有不同的操作格式.不幸的是,这种情况发生了,这里有一种不标准的协议.当您打开有问题的设备的文档并将其与正常工作和/或与驱动程序实现进行比较时,您很可能会发现有所不同.

I met such a situation. I had driver, read and write functions, and it worked not for all i2c devices. I found that was caused the not working device had different operating format for a number of operation. Unfortunately this happens, there a kind of not standard protocols. When you open the doc for the problem device and compare it to working and/or to the driver implementation you most likely will see a difference.

这篇关于在U-Boot中使用I2C读取多个字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆