Hi,
I want to I2C bus of Q2686 module to communicate with a accelerometer. Firstly, I made the subscription of I2C bus and got “0” value to the bus handle. Is it right? Then, I try to send test data to the slave device by using adl_busWrite() function. But, it will return error code: -2 (ADL_RET_ERR_PARAM), I checked my parameters and can not figure out the error. Can anyone help me with this problem? ( the below is my test code)
[color=red]adl_busI2CSettings_t MyI2CConfig =
{
0x18,
ADL_BUS_I2C_CLK_STD
};
#define WRITE_SIZE 5
#define READ_SIZE 3
adl_busAccess_t AccessConfig =
{
0, 0, 0, 0,
ADL_BUS_SIZE_BYTE
};
s32 I2CHandle;
adl_tmr_t *hTmr;
u8 WrtBuff[WRITE_SIZE], RdBuff[READ_SIZE];
void Timer_Handler ( u8 ID )
{
s32 ReadValue;
wm_memset(WrtBuff, WRITE_SIZE, 0);
AccessConfig.AddressLength = 0x08;
AccessConfig.Address = (u32) 0x06 << 24;
ReadValue = adl_busWrite(I2CHandle, &AccessConfig, WRITE_SIZE, WrtBuff);
TRACE (( 3, "Wrtie Bus: %d", ReadValue));
}
void MyFunction ( void )
{
I2CHandle = adl_busSubscribe(ADL_BUS_I2C, (adl_busSettings_u *)&MyI2CConfig);
TRACE (( 2, "Bus Handle: %d", I2CHandle ));
hTmr = adl_tmrSubscribe ( FALSE, 10, ADL_TMR_TYPE_100MS, Timer_Handler );
}
void adl_main ( adl_InitType_e InitType )
{
TRACE (( 1, “Embedded Application : Main” ));
// TO DO : Add your initialization code here
MyFunction();
}