Hello to all,
I’m using I2C routines with Q2686H, FW R72, OS 6.10.05, and noticed some problems.
After perfoming and adl_busWrite another adl_buswrite or adl_busRead return ADL_RET_ERR_PARAM, waiting a bit or recalling the function it works. I’ve attached some sample routines when you can see the error, this example are for EEPROM.
I noticed the same error using an I2C I/O expander chip.
There was any problem on I2C library with firmware 6.xx.
Any suggest is appreciate, thank you.
Raffaele
const adl_busI2CSettings_t MyI2CConfig =
{
(0xae>>1),
ADL_BUS_I2C_CLK_STD,
ADL_BUS_I2C_ADDR_7_BITS,
ADL_BUS_I2C_MASTER_MODE
};
#define SIZE 5
adl_busAccess_t AccessConfig =
{
0,0
};
s32 MyI2Chandle;
u32 pp;
u8 WriteBuffer[SIZE], ReadBuffer[SIZE];
u8 i;
void MyI2CTestFunction()
{
s32 ReadValue;
u8 string[30];
u32 AddSize=0;
MyI2Chandle = adl_busSubscribe(ADL_BUS_I2C, 1, &MyI2CConfig);
wm_sprintf(string,"Handle %d\r\n",MyI2Chandle);
adl_atSendResponse ( ADL_AT_UNS, string);
AddSize = 16;
wm_sprintf(string,"adl_busIOCtl ADL_BUS_CMD_SET_ADD_SIZE %d\r\n",adl_busIOCtl (MyI2Chandle,ADL_BUS_CMD_SET_ADD_SIZE, &AddSize));
adl_atSendResponse ( ADL_AT_UNS, string);
wm_sprintf(string,"adl_busIOCtl ADL_BUS_CMD_GET_ADD_SIZE %d\r\n",adl_busIOCtl (MyI2Chandle,ADL_BUS_CMD_GET_ADD_SIZE,&AddSize));
adl_atSendResponse ( ADL_AT_UNS, string);
wm_sprintf(string,"Address Size %d\r\n",AddSize);
adl_atSendResponse ( ADL_AT_UNS, string);
for(i=0;i<SIZE;i++)
WriteBuffer[i] = WriteBuffer[i]+i+10;
for(i=0;i<SIZE;i++)
ReadBuffer[i] = 0;
AccessConfig.Address = 10;
wm_sprintf(string,"adl_busRead %d\r\n",adl_busRead (MyI2Chandle, &AccessConfig, SIZE, ReadBuffer));
adl_atSendResponse ( ADL_AT_UNS, string);
wm_sprintf(string,"1st Reading %d %d %d %d %d\r\n",ReadBuffer[0],ReadBuffer[1],ReadBuffer[2],ReadBuffer[3],ReadBuffer[4]);
adl_atSendResponse ( ADL_AT_UNS, string);
wm_sprintf(string,"To Write %d %d %d %d %d\r\n",WriteBuffer[0],WriteBuffer[1],WriteBuffer[2],WriteBuffer[3],WriteBuffer[4]);
adl_atSendResponse ( ADL_AT_UNS, string);
wm_sprintf(string,"adl_busWrite %d\r\n",adl_busWrite(MyI2Chandle, &AccessConfig, SIZE, WriteBuffer));
adl_atSendResponse ( ADL_AT_UNS, string);
for(i=0;i<SIZE;i++)
ReadBuffer[i] = 0;
/* -------------------------------------- */
/* Just after an adl_busWrite operation any Read or Write operation report -2 */
/* you need to wait or repeat the function again */
wm_sprintf(string,"adl_busRead %d\r\n",adl_busRead (MyI2Chandle, &AccessConfig, SIZE, ReadBuffer));
adl_atSendResponse ( ADL_AT_UNS, string);
wm_sprintf(string,"2nd Reading %d %d %d %d %d\r\n",ReadBuffer[0],ReadBuffer[1],ReadBuffer[2],ReadBuffer[3],ReadBuffer[4]);
adl_atSendResponse ( ADL_AT_UNS, string);
wm_sprintf(string,"adl_busRead %d\r\n",adl_busRead (MyI2Chandle, &AccessConfig, SIZE, ReadBuffer));
adl_atSendResponse ( ADL_AT_UNS, string);
wm_sprintf(string,"3rd Reading %d %d %d %d %d\r\n",ReadBuffer[0],ReadBuffer[1],ReadBuffer[2],ReadBuffer[3],ReadBuffer[4]);
adl_atSendResponse ( ADL_AT_UNS, string);
adl_busUnsubscribe(MyI2Chandle);
}