注册已经完成,在调用rt_i2c_transfer()函数时,报硬件错误
查看更多
显示非对齐,你根据
bus 变量初始化了?bus 指针不是空?
static struct rt_i2c_bus_device *i2c_bus = RT_NULL; /* I2C总线设备句柄 */ i2c_bus = (struct rt_i2c_bus_device *)rt_device_find("i2c2"); if (i2c_bus == RT_NULL){ uart_debug("can't find i2c2 device!\n"); return RT_ERROR; }
static struct rt_i2c_bus_device *i2c_bus = RT_NULL; /* I2C总线设备句柄 */
i2c_bus = (struct rt_i2c_bus_device *)rt_device_find("i2c2");
if (i2c_bus == RT_NULL){
uart_debug("can't find i2c2 device!\n");
return RT_ERROR;
}
需要这样先去把找到设备总线 把i2c_bus 初始化完成
bus 空的可能性非常大
IIC配置与对应IO不匹配,就会报这个问题,结案
欢迎发表与嵌入式相关的技术分享、开发技巧、工具介绍、技术设想、职业心得、行业评论等对他人有启发,排版优雅的文章
回到 顶部
发布 问题
分享 好友
手机 浏览
投诉 建议
回到 底部