コード例 #1
0
uint8_t expander_read(uint8_t addr)
{
    uint8_t 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[] = {
        {CORE_GPIO_EXPANDER_I2C_ADDRESS, I2C_M_WR, 1, &addr},
        {CORE_GPIO_EXPANDER_I2C_ADDRESS, I2C_M_RD, 1, &ret}
    };

    qup_i2c_xfer(dev, msg_buf, 2);

    return ret;
}
コード例 #2
0
uint32_t eprom_read (uint16_t addr, uint8_t count) {
    uint32_t ret = 0;
    if(!dev){
        return ret;
    }
    /* 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[] = {
        {EEPROM_I2C_ADDRESS, I2C_M_WR, 2, &addr},
        {EEPROM_I2C_ADDRESS, I2C_M_RD, count, &ret}
    };

    qup_i2c_xfer(dev, msg_buf, 2);
    return ret;
}
コード例 #3
0
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;
}
コード例 #4
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;
}
コード例 #5
0
uint8_t expander_write(uint8_t addr, uint8_t val)
{
    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[] = { {CORE_GPIO_EXPANDER_I2C_ADDRESS,
                                  I2C_M_WR, 2, data_buf}
    };

    qup_i2c_xfer(dev, msg_buf, 1);

    /* Double check that the write worked. */
    if (val != expander_read(addr)) {
        return -1;
    }

    return 0;
}
コード例 #6
0
void eeprom_read_test()
{

	struct qup_i2c_dev  *dev;
	char ret[100] = {'\0'};

	dev = qup_blsp_i2c_init(BLSP_ID_2, QUP_ID_4, 100000, 19200000);

	if (!dev) {
		dprintf(CRITICAL, "Failed initializing I2c\n");
		return;
	}

	/* Create a i2c_msg buffer, to read from eprom */

	struct i2c_msg msg_buf[] = {
		{EEPROM_HW_I2C_ADDRESS, I2C_M_RD, 100, ret}
	};

	qup_i2c_xfer(dev, msg_buf, 1);
}