配置Linux I2C速度 [英] Configure Linux I2C Speed

查看:1170
本文介绍了配置Linux I2C速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Snowball板上使用I2C,默认情况下以400KHz运行,并且希望将其降低到100KHz.

I am using I2C on the Snowball board, running at 400KHz by default and would like to reduce this to 100KHz.

我使用在中定义的api并进行如下配置

I use the api defined in and configure as follows

m_fd = open(m_filename.c_str(), O_RDWR);

if (ioctl(m_fd, I2C_SLAVE_FORCE, m_addr) < 0) 
{
    throw I2cError(DeviceConfigFail);
}

有人知道我如何将速度更改为标准模式.

Does anyone know how I would go about changing the speed to standard mode.

谢谢

推荐答案

您可以在驱动程序的"struct i2c_gpio_platform_data"中更改I2C SCL频率.

You can change the I2C SCL frequency in your driver's 'struct i2c_gpio_platform_data'.

    static struct i2c_gpio_platform_data xyz_i2c_gpio_data = {
    .sda_pin = GPIO_XYZ_SDA,
    .scl_pin = GPIO_XYZ_SCL,
    .udelay = 5, //@udelay: signal toggle delay. SCL frequency is (500 / udelay) kHz
    ....
};

更改"udelay"会更改"xyz" i2c设备的时钟频率.

Changing 'udelay' changes your 'xyz' i2c device's clock frequency.

这篇关于配置Linux I2C速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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