Qcom LK阶段如何使用I2C介绍

来源:互联网 发布:单片机为什么需要复位 编辑:程序博客网 时间:2024/06/05 02:28

下面是Qcom LK阶段使用I2C的代码:


#include <i2c_qup.h>#include <blsp_qup.h>static struct qup_i2c_dev  *i2c_dev;i2c_dev = qup_blsp_i2c_init(BLSP_ID_1, QUP_ID_1, 100000, 19200000);static int qrd_lcd_i2c_read(uint8_t addr){int ret = 0;/* Create a i2c_msg buffer, that is used to put the controller into read   mode and then to read some data. */struct i2c_msg msg_buf[] = {{QRD_LCD_I2C_ADDRESS, I2C_M_WR, 1, &addr},{QRD_LCD_I2C_ADDRESS, I2C_M_RD, 1, &ret}};ret = qup_i2c_xfer(i2c_dev, msg_buf, 2);if(ret < 0) {dprintf(CRITICAL, "qup_i2c_xfer error %d\n", ret);return ret;}return 0;}static int qrd_lcd_i2c_write(uint8_t addr, uint8_t val){int ret = 0;uint8_t data_buf[] = { addr, val };/* Create a i2c_msg buffer, that is used to put the controller into write   mode and then to write some data. */struct i2c_msg msg_buf[] = { {QRD_LCD_I2C_ADDRESS,      I2C_M_WR, 2, data_buf}};ret = qup_i2c_xfer(i2c_dev, msg_buf, 1);if(ret < 0) {dprintf(CRITICAL, "qup_i2c_xfer error %d\n", ret);return ret;}return 0;}


1 0
原创粉丝点击