I2c tranmitter


#1

hello everyone,
i want to i2c comunication with redbear. I just want to read the register(slave device BQ24298 pmic).
My reference sample WICED-SDK\libraries\drivers\audio\AK4954
My problem is that the function wiced_i2c_init_rx_message does not write single byte. Function does not start sending sizeof parameter as single byte. In two bytes, the address I want to read is deleted.

wiced_i2c_init( &i2c_dev );

wiced_rtos_delay_milliseconds(50);
temp_data[0] = INPUT_SOURCE_REGISTER; // reg: 0x00

wiced_i2c_init_tx_message( &msg[0], temp_data, 2, 3, 1 );

if(wiced_i2c_init_rx_message(&msg[1], temp_data, 1 , 3, 1 ) == WICED_SUCCESS);

wiced_i2c_transfer( &i2c_dev, msg, 2  );

logic analysis output.

Only when I do the reading:

wiced_i2c_init( &i2c_dev );

wiced_rtos_delay_milliseconds(50);
temp_data[0] = INPUT_SOURCE_REGISTER;

if(wiced_i2c_init_rx_message(&msg[0], temp_data, 1 , 3, 1 ) == WICED_SUCCESS);   
wiced_i2c_transfer( &i2c_dev, msg, 1  );

I only do the writing process:

wiced_i2c_init( &i2c_dev );

wiced_rtos_delay_milliseconds(50);
temp_data[0] = INPUT_SOURCE_REGISTER;

wiced_i2c_init_tx_message( &msg[0], temp_data, 2, 1, 1 );

wiced_i2c_transfer( &i2c_dev, msg, 1  );

I used an Arduino to read the register of the PMIC chip and everything worked fine. Below is the screenshot:


#2

We made the following changes and Worked correctly.

wiced_i2c_init( &i2c_dev );

wiced_rtos_delay_milliseconds(50);
temp_data[0] = INPUT_SOURCE_REGISTER; // reg: 0x00

wiced_i2c_init_tx_message( &msg[0], temp_data, 1, 3, 1 );

if(wiced_i2c_init_rx_message(&msg[1], temp_data, 1 , 3, 1 ) == WICED_SUCCESS);
wiced_i2c_transfer( &i2c_dev, msg, 2  );

The retries parameter should be 3.