Try This —> Pull up SDA ,SDL to V-EXT(2.8 v) with a 4.7K Resistor .
Connect i2c Gyro–>Lsm6dsl
configure i2c in H/w or S/w mode
/*Hardware i2c mode */
u32 h_s=1; //1=hardware I2c mode,0=Software I2c mode
u32 chnl=1;//channel select =1
ret = Ql_IIC_Init(chnl,PINNAME_RI,PINNAME_DCD,h_s);
ret = Ql_IIC_Config(chnl,TRUE,0xD4,300);// IIC interface ,Device ID IicSpeed.
/*reading Who am I register inside a 2 sec timer */
void Timer_handler(u32 timerId, void* param)
{
u8 read_data[2]={0,0};
u8 read_data1[2]={0,0};
u8 registerAdrr[2]={0x0F,0x00};//
u8 x=1;
s32 ret;
((s32)param) +=1;
if(Stack_timer == timerId)
{
// wrire and read seperate functions
ret = Ql_IIC_Write(chnl,0xD4,(u8*) registerAdrr,1);// To read LSM6dsl Who am I(dev id 0XD4,Register address 0X0F)
if(ret < 0)
{
APP_DEBUG("\r\n<–Failed !! IIC controller Ql_IIC_Write channel 1 fail ret=%d–>\r\n",ret);
}
else{
APP_DEBUG("\r\n<–IIC controller Ql_IIC_Write ret=%d–>\r\n",ret);
}
ret = Ql_IIC_Read(chnl, 0xD4, read_data,1); // read Who am I value to read_data[0]
APP_DEBUG("< read i2c iRet=%d, value=0X%x >\n", ret, read_data[0]);
if(ret <0)
{
APP_DEBUG("\r\n<–Failed !! IIC patameter error Ql_IIC_Read channel 1 fail ret=%d–>\r\n",ret);
}
Ql_Sleep(100);
// Single wrire read function
ret = Ql_IIC_Write_Read(1, 0xD4,(u8*)registerAdrr,1,read_data1,1);
if(ret < 0)
{
APP_DEBUG("\r\n<–Failed !! Ql_IIC_Write_Read channel 0 fail ret=%d–>\r\n",ret);
}
else
{
APP_DEBUG("\r\n<–channel 0 Ql_IIC_Write_Read ret=0X-%x–>\r\n",read_data[0]);
}
}
}